MAJOR refactoring: all geometry-dependent data (tessf, geom3::, shapes, hpc) are now contained in a structure

This commit is contained in:
Zeno Rogue 2019-05-26 18:04:02 +02:00
parent 9c5344289a
commit b6e303ec7d
35 changed files with 3893 additions and 3836 deletions

View File

@ -11,8 +11,8 @@ ld eyepos;
#if MAXMDIM >= 4 #if MAXMDIM >= 4
#define S (scalefactor / 0.805578) #define S (cgi.scalefactor / 0.805578)
#define SH (scalefactor / 0.805578 * geom3::height_width / 1.5) #define SH (cgi.scalefactor / 0.805578 * geom3::height_width / 1.5)
#define revZ (WDIM == 2 ? -1 : 1) #define revZ (WDIM == 2 ? -1 : 1)
@ -22,7 +22,7 @@ hyperpoint front_leg, rear_leg;
transmatrix front_leg_move, rear_leg_move, front_leg_move_inverse, rear_leg_move_inverse; transmatrix front_leg_move, rear_leg_move, front_leg_move_inverse, rear_leg_move_inverse;
ld leg_length; ld leg_length;
vector<hyperpoint> get_shape(hpcshape sh) { vector<hyperpoint> geometry_information::get_shape(hpcshape sh) {
vector<hyperpoint> res; vector<hyperpoint> res;
for(int i=sh.s; i<sh.e-1; i++) res.push_back(hpc[i]); for(int i=sh.s; i<sh.e-1; i++) res.push_back(hpc[i]);
return res; return res;
@ -37,15 +37,15 @@ hyperpoint get_center(const vector<hyperpoint>& vh) {
ld zc(ld z) { ld zc(ld z) {
if(WDIM == 2 && GDIM == 3) if(WDIM == 2 && GDIM == 3)
return geom3::lev_to_factor(geom3::human_height * z); return geom3::lev_to_factor(cgi.human_height * z);
return geom3::human_height * (z - 0.5); return cgi.human_height * (z - 0.5);
} }
transmatrix zpush(ld z) { transmatrix zpush(ld z) {
return cpush(2, z); return cpush(2, z);
} }
void add_cone(ld z0, const vector<hyperpoint>& vh, ld z1) { void geometry_information::add_cone(ld z0, const vector<hyperpoint>& vh, ld z1) {
last->flags |= POLY_TRIANGLES; last->flags |= POLY_TRIANGLES;
for(int i=0; i<isize(vh); i++) { for(int i=0; i<isize(vh); i++) {
hpcpush(zpush(z0) * vh[i]); hpcpush(zpush(z0) * vh[i]);
@ -54,7 +54,7 @@ void add_cone(ld z0, const vector<hyperpoint>& vh, ld z1) {
} }
} }
void add_prism_sync(ld z0, vector<hyperpoint> vh0, ld z1, vector<hyperpoint> vh1) { void geometry_information::add_prism_sync(ld z0, vector<hyperpoint> vh0, ld z1, vector<hyperpoint> vh1) {
last->flags |= POLY_TRIANGLES; last->flags |= POLY_TRIANGLES;
for(int i=0; i<isize(vh0); i++) { for(int i=0; i<isize(vh0); i++) {
int i1 = (i+1) % isize(vh0); int i1 = (i+1) % isize(vh0);
@ -67,7 +67,7 @@ void add_prism_sync(ld z0, vector<hyperpoint> vh0, ld z1, vector<hyperpoint> vh1
} }
} }
void add_prism(ld z0, vector<hyperpoint> vh0, ld z1, vector<hyperpoint> vh1) { void geometry_information::add_prism(ld z0, vector<hyperpoint> vh0, ld z1, vector<hyperpoint> vh1) {
last->flags |= POLY_TRIANGLES; last->flags |= POLY_TRIANGLES;
struct mixed { struct mixed {
@ -97,15 +97,15 @@ void add_prism(ld z0, vector<hyperpoint> vh0, ld z1, vector<hyperpoint> vh1) {
} }
} }
void shift_last(ld z) { void geometry_information::shift_last(ld z) {
for(int i=last->s; i<isize(hpc); i++) hpc[i] = zshift(hpc[i], z); for(int i=last->s; i<isize(hpc); i++) hpc[i] = zshift(hpc[i], z);
} }
void shift_shape(hpcshape& sh, ld z) { void geometry_information::shift_shape(hpcshape& sh, ld z) {
for(int i=sh.s; i<sh.e; i++) hpc[i] = zshift(hpc[i], z); for(int i=sh.s; i<sh.e; i++) hpc[i] = zshift(hpc[i], z);
} }
void shift_shape_orthogonally(hpcshape& sh, ld z) { void geometry_information::shift_shape_orthogonally(hpcshape& sh, ld z) {
for(int i=sh.s; i<sh.e; i++) hpc[i] = orthogonal_move(hpc[i], z); for(int i=sh.s; i<sh.e; i++) hpc[i] = orthogonal_move(hpc[i], z);
} }
@ -113,7 +113,7 @@ extern renderbuffer *floor_textures;
basic_textureinfo models_texture; basic_textureinfo models_texture;
void add_texture(hpcshape& sh) { void geometry_information::add_texture(hpcshape& sh) {
if(!floor_textures) return; if(!floor_textures) return;
auto& utt = models_texture; auto& utt = models_texture;
sh.tinf = &utt; sh.tinf = &utt;
@ -133,7 +133,7 @@ vector<hyperpoint> scaleshape(const vector<hyperpoint>& vh, ld s) {
return res; return res;
} }
void make_ha_3d(hpcshape& sh, bool isarmor, ld scale) { void geometry_information::make_ha_3d(hpcshape& sh, bool isarmor, ld scale) {
shcenter = C0; shcenter = C0;
auto groin = get_shape(shHumanGroin); auto groin = get_shape(shHumanGroin);
@ -191,14 +191,14 @@ void make_ha_3d(hpcshape& sh, bool isarmor, ld scale) {
add_cone(zc(0.8), neck, zc(0.83)); add_cone(zc(0.8), neck, zc(0.83));
int at0 = isize(hpc); int at0 = isize(hpc);
ld h = geom3::human_height; ld h = human_height;
if(isize(arm) > 3) { if(isize(arm) > 3) {
shcenter = get_center(arm); shcenter = get_center(arm);
int arm0 = isize(hpc); int arm0 = isize(hpc);
add_prism_sync(geom3::BODY - h*.03, arm, geom3::BODY + h*.03, arm); add_prism_sync(BODY - h*.03, arm, BODY + h*.03, arm);
add_cone(geom3::BODY + h*.03, arm, geom3::BODY + h*.05); add_cone(BODY + h*.03, arm, BODY + h*.05);
add_cone(geom3::BODY - h*.03, arm, geom3::BODY - h*.05); add_cone(BODY - h*.03, arm, BODY - h*.05);
int arm1 = isize(hpc); int arm1 = isize(hpc);
for(int i=arm0; i<arm1; i++) { for(int i=arm0; i<arm1; i++) {
hyperpoint h = hpc[i]; hyperpoint h = hpc[i];
@ -207,7 +207,7 @@ void make_ha_3d(hpcshape& sh, bool isarmor, ld scale) {
ld rad = hdist0(h); ld rad = hdist0(h);
rad = (rad - 0.1124*S) / (0.2804*S - 0.1124*S); rad = (rad - 0.1124*S) / (0.2804*S - 0.1124*S);
rad = 1 - rad; rad = 1 - rad;
rad *= zc(0.7) - geom3::BODY; rad *= zc(0.7) - BODY;
hpc[i] = zpush(rad) * hpc[i]; hpc[i] = zpush(rad) * hpc[i];
} }
} }
@ -216,15 +216,15 @@ void make_ha_3d(hpcshape& sh, bool isarmor, ld scale) {
if(isize(hand) > 3) { if(isize(hand) > 3) {
shcenter = get_center(hand); shcenter = get_center(hand);
add_cone(geom3::BODY, hand, geom3::BODY + 0.05 * geom3::human_height); add_cone(BODY, hand, BODY + 0.05 * human_height);
add_cone(geom3::BODY, hand, geom3::BODY - 0.05 * geom3::human_height); add_cone(BODY, hand, BODY - 0.05 * human_height);
} }
int at1 = isize(hpc); int at1 = isize(hpc);
for(int i=at0; i<at1; i++) hpc.push_back(Mirror * hpc[i]); for(int i=at0; i<at1; i++) hpc.push_back(Mirror * hpc[i]);
add_texture(shPBody); add_texture(shPBody);
shift_last(-geom3::BODY); shift_last(-BODY);
} }
/* /*
@ -232,9 +232,9 @@ void make_humanoid_3d(hpcshape& sh) { make_ha_3d(sh, false, 0.90); }
void make_armor_3d(hpcshape& sh, ld scale = 1) { make_ha_3d(sh, true, scale); } void make_armor_3d(hpcshape& sh, ld scale = 1) { make_ha_3d(sh, true, scale); }
*/ */
void make_humanoid_3d(hpcshape& sh) { make_ha_3d(sh, false, 1); } void geometry_information::make_humanoid_3d(hpcshape& sh) { make_ha_3d(sh, false, 1); }
void addtri(array<hyperpoint, 3> hs, int kind) { void geometry_information::addtri(array<hyperpoint, 3> hs, int kind) {
ld ds[3]; ld ds[3];
ds[0] = hdist(hs[0], hs[1]); ds[0] = hdist(hs[0], hs[1]);
ds[1] = hdist(hs[1], hs[2]); ds[1] = hdist(hs[1], hs[2]);
@ -287,7 +287,7 @@ void addtri(array<hyperpoint, 3> hs, int kind) {
} }
ld levels[6] = {0, 0.125, 0.125, 0.250, 0.375, 0.5}; ld levels[6] = {0, 0.125, 0.125, 0.250, 0.375, 0.5};
for(int a=0; a<6; a++) for(int i=0; i<3; i++) for(int a=0; a<6; a++) for(int i=0; i<3; i++)
htx[a][i] = zpush(-min(shi[i], levels[a]) * geom3::human_height * revZ) * htx[a][i]; htx[a][i] = zpush(-min(shi[i], levels[a]) * human_height * revZ) * htx[a][i];
hpcpush(htx[0][0]); hpcpush(htx[0][0]);
hpcpush(htx[0][1]); hpcpush(htx[0][1]);
@ -320,7 +320,7 @@ void addtri(array<hyperpoint, 3> hs, int kind) {
} }
} }
void make_armor_3d(hpcshape& sh, int kind = 1) { void geometry_information::make_armor_3d(hpcshape& sh, int kind) {
auto body = get_shape(sh); auto body = get_shape(sh);
vector<vector<array<ld, 2> >> pts(2); vector<vector<array<ld, 2> >> pts(2);
@ -345,12 +345,12 @@ void make_armor_3d(hpcshape& sh, int kind = 1) {
add_texture(sh); add_texture(sh);
if(&sh == &shHood || &sh == &shWightCloak || &sh == &shArmor) if(&sh == &shHood || &sh == &shWightCloak || &sh == &shArmor)
shift_last(-geom3::HEAD); shift_last(-HEAD);
else else
shift_last(-geom3::BODY); shift_last(-BODY);
} }
void make_foot_3d(hpcshape& sh) { void geometry_information::make_foot_3d(hpcshape& sh) {
auto foot = get_shape(sh); auto foot = get_shape(sh);
auto leg = get_shape(shHumanLeg); auto leg = get_shape(shHumanLeg);
auto leg5 = scaleshape(leg, 0.8); auto leg5 = scaleshape(leg, 0.8);
@ -362,13 +362,13 @@ void make_foot_3d(hpcshape& sh) {
add_prism_sync(zc(0.1), leg, zc(0.4), leg5); add_prism_sync(zc(0.1), leg, zc(0.4), leg5);
add_cone(zc(0.4), leg5, zc(0.45)); add_cone(zc(0.4), leg5, zc(0.45));
add_texture(sh); add_texture(sh);
// shift_last(-geom3::LEG0); // shift_last(-LEG0);
for(int i=last->s; i<isize(hpc); i++) hpc[i] = cpush(0, -0.0125*S) * hpc[i]; for(int i=last->s; i<isize(hpc); i++) hpc[i] = cpush(0, -0.0125*S) * hpc[i];
} }
void make_head_only() { void geometry_information::make_head_only() {
auto addpt = [] (int d, int u) { auto addpt = [this] (int d, int u) {
hpcpush(zpush(zc(eyepos) + 0.06 * SH * sin(u * degree)) * xspinpush0(d * degree, 0.05 * S * cos(u * degree))); hpcpush(zpush(zc(eyepos) + 0.06 * SH * sin(u * degree)) * xspinpush0(d * degree, 0.05 * S * cos(u * degree)));
}; };
@ -385,11 +385,11 @@ void make_head_only() {
} }
add_texture(shPHeadOnly); add_texture(shPHeadOnly);
shift_last(-geom3::HEAD - revZ * 0.01 * SH); shift_last(-HEAD - revZ * 0.01 * SH);
} }
void make_head_3d(hpcshape& sh) { void geometry_information::make_head_3d(hpcshape& sh) {
auto head = get_shape(sh); auto head = get_shape(sh);
vector<vector<array<ld, 2> >> pts(2); vector<vector<array<ld, 2> >> pts(2);
@ -414,10 +414,10 @@ void make_head_3d(hpcshape& sh) {
} }
add_texture(sh); add_texture(sh);
shift_last(-geom3::HEAD); shift_last(-HEAD);
} }
void make_paw_3d(hpcshape& sh, hpcshape& legsh) { void geometry_information::make_paw_3d(hpcshape& sh, hpcshape& legsh) {
auto foot = get_shape(sh); auto foot = get_shape(sh);
auto leg = get_shape(legsh); auto leg = get_shape(legsh);
@ -430,7 +430,7 @@ void make_paw_3d(hpcshape& sh, hpcshape& legsh) {
add_texture(sh); add_texture(sh);
} }
void make_abody_3d(hpcshape& sh, ld tail) { void geometry_information::make_abody_3d(hpcshape& sh, ld tail) {
auto body = get_shape(sh); auto body = get_shape(sh);
shcenter = get_center(body); shcenter = get_center(body);
@ -448,10 +448,10 @@ void make_abody_3d(hpcshape& sh, ld tail) {
add_cone(zc(0.4), body8, zc(0.36)); add_cone(zc(0.4), body8, zc(0.36));
add_cone(zc(0.6), body8, zc(0.64)); add_cone(zc(0.6), body8, zc(0.64));
add_texture(sh); add_texture(sh);
if(GDIM == 3 && WDIM == 2) shift_last(-geom3::ABODY); if(GDIM == 3 && WDIM == 2) shift_last(-ABODY);
} }
void make_ahead_3d(hpcshape& sh) { void geometry_information::make_ahead_3d(hpcshape& sh) {
auto body = get_shape(sh); auto body = get_shape(sh);
shcenter = get_center(body); shcenter = get_center(body);
auto body8 = scaleshape(body, 0.5); auto body8 = scaleshape(body, 0.5);
@ -464,7 +464,7 @@ void make_ahead_3d(hpcshape& sh) {
add_texture(sh); add_texture(sh);
} }
void make_skeletal(hpcshape& sh, ld push = 0) { void geometry_information::make_skeletal(hpcshape& sh, ld push) {
auto body = get_shape(sh); auto body = get_shape(sh);
shcenter = get_center(body); shcenter = get_center(body);
@ -477,7 +477,7 @@ void make_skeletal(hpcshape& sh, ld push = 0) {
shift_last(-push); shift_last(-push);
} }
void make_revolution(hpcshape& sh, int mx = 180, ld push = 0) { void geometry_information::make_revolution(hpcshape& sh, int mx, ld push) {
auto body = get_shape(sh); auto body = get_shape(sh);
bshape(sh, PPR::MONSTER_BODY); bshape(sh, PPR::MONSTER_BODY);
int step = (mx == 360 ? 24 : 10); int step = (mx == 360 ? 24 : 10);
@ -498,7 +498,7 @@ void make_revolution(hpcshape& sh, int mx = 180, ld push = 0) {
shift_last(-push); shift_last(-push);
} }
void make_revolution_cut(hpcshape &sh, int each = 180, ld push = 0, ld width = 99) { void geometry_information::make_revolution_cut(hpcshape &sh, int each, ld push, ld width) {
auto body = get_shape(sh); auto body = get_shape(sh);
body.resize(isize(body) / 2); body.resize(isize(body) / 2);
ld fx = body[0][0]; ld fx = body[0][0];
@ -570,14 +570,14 @@ void disable(hpcshape& sh) {
sh.s = sh.e = 0; sh.s = sh.e = 0;
} }
void clone_shape(hpcshape& sh, hpcshape& target) { void geometry_information::clone_shape(hpcshape& sh, hpcshape& target) {
target = sh; target = sh;
target.s = isize(hpc); target.s = isize(hpc);
for(int i=sh.s; i<sh.e; i++) hpc.push_back(hpc[i]); for(int i=sh.s; i<sh.e; i++) hpc.push_back(hpc[i]);
target.e = isize(hpc); target.e = isize(hpc);
} }
void animate_bird(hpcshape& orig, hpcshape animated[30], ld body) { void geometry_information::animate_bird(hpcshape& orig, hpcshape animated[30], ld body) {
for(int i=0; i<30; i++) { for(int i=0; i<30; i++) {
auto& tgt = animated[i]; auto& tgt = animated[i];
clone_shape(orig, tgt); clone_shape(orig, tgt);
@ -591,11 +591,11 @@ void animate_bird(hpcshape& orig, hpcshape animated[30], ld body) {
} }
} }
} }
// for(int i=0; i<30; i++) shift_shape(animated[i], geom3::BIRD); // for(int i=0; i<30; i++) shift_shape(animated[i], BIRD);
// shift_shape(orig, geom3::BIRD); // shift_shape(orig, BIRD);
} }
void slimetriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev) { void geometry_information::slimetriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev) {
dynamicval<int> d(vid.texture_step, 8); dynamicval<int> d(vid.texture_step, 8);
texture_order([&] (ld x, ld y) { texture_order([&] (ld x, ld y) {
using namespace hyperpoint_vec; using namespace hyperpoint_vec;
@ -606,7 +606,7 @@ void slimetriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev) {
}); });
} }
void balltriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev) { void geometry_information::balltriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev) {
if(lev == 0) { if(lev == 0) {
hpcpush(a); hpcpush(a);
hpcpush(b); hpcpush(b);
@ -623,7 +623,7 @@ void balltriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev) {
} }
} }
void make_ball(hpcshape& sh, ld rad, int lev) { void geometry_information::make_ball(hpcshape& sh, ld rad, int lev) {
bshape(sh, sh.prio); bshape(sh, sh.prio);
sh.flags |= POLY_TRIANGLES; sh.flags |= POLY_TRIANGLES;
hyperpoint tip = xpush0(rad); hyperpoint tip = xpush0(rad);
@ -652,7 +652,7 @@ hyperpoint psmin(hyperpoint H) {
return res; return res;
} }
void adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye, ld shift_head, int q, ld zoom=1) { void geometry_information::adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye, ld shift_head, int q, ld zoom) {
using namespace hyperpoint_vec; using namespace hyperpoint_vec;
hyperpoint center = Hypc; hyperpoint center = Hypc;
for(int i=eye.s; i<eye.e; i++) if(q == 1 || hpc[i][1] > 0) center += hpc[i]; for(int i=eye.s; i<eye.e; i++) if(q == 1 || hpc[i][1] > 0) center += hpc[i];
@ -697,7 +697,7 @@ void adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye, ld shift_head, int q
// eye.prio = PPR::SUPERLINE; // eye.prio = PPR::SUPERLINE;
} }
void shift_last_straight(ld z) { void geometry_information::shift_last_straight(ld z) {
for(int i=last->s; i<isize(hpc); i++) hpc[i] = zpush(z) * hpc[i]; for(int i=last->s; i<isize(hpc); i++) hpc[i] = zpush(z) * hpc[i];
} }
@ -742,13 +742,13 @@ void queueball(const transmatrix& V, ld rad, color_t col, eItem what) {
} }
} }
void make_shadow(hpcshape& sh) { void geometry_information::make_shadow(hpcshape& sh) {
sh.shs = isize(hpc); sh.shs = isize(hpc);
for(int i=sh.s; i < sh.e; i++) hpcpush(orthogonal_move(hpc[i], geom3::FLOOR - geom3::human_height / 100)); for(int i=sh.s; i < sh.e; i++) hpcpush(orthogonal_move(hpc[i], FLOOR - human_height / 100));
sh.she = isize(hpc); sh.she = isize(hpc);
} }
void make_3d_models() { void geometry_information::make_3d_models() {
if(DIM == 2) return; if(DIM == 2) return;
eyepos = WDIM == 2 ? 0.875 : 0.925; eyepos = WDIM == 2 ? 0.875 : 0.925;
DEBBI(DF_POLY, ("make_3d_models")); DEBBI(DF_POLY, ("make_3d_models"));
@ -832,7 +832,7 @@ void make_3d_models() {
DEBB(DF_POLY, ("feet and paws")); DEBB(DF_POLY, ("feet and paws"));
make_foot_3d(shHumanFoot); make_foot_3d(shHumanFoot);
make_foot_3d(shYetiFoot); make_foot_3d(shYetiFoot);
make_skeletal(shSkeletalFoot, WDIM == 2 ? zc(0.5) + geom3::human_height/40 - geom3::FLOOR : 0); make_skeletal(shSkeletalFoot, WDIM == 2 ? zc(0.5) + human_height/40 - FLOOR : 0);
hyperpoint front_leg = Hypc; hyperpoint front_leg = Hypc;
hyperpoint rear_leg = Hypc; hyperpoint rear_leg = Hypc;
@ -856,29 +856,29 @@ void make_3d_models() {
// make_abody_3d(shWolfBody, 0.01); // make_abody_3d(shWolfBody, 0.01);
// make_ahead_3d(shWolfHead); // make_ahead_3d(shWolfHead);
// make_ahead_3d(shFamiliarHead); // make_ahead_3d(shFamiliarHead);
ld g = WDIM == 2 ? geom3::ABODY - zc(0.4) : 0; ld g = WDIM == 2 ? ABODY - zc(0.4) : 0;
make_revolution_cut(shWolfBody, 30, g, 0.01*S); make_revolution_cut(shWolfBody, 30, g, 0.01*S);
make_revolution_cut(shWolfHead, 180, geom3::AHEAD - geom3::ABODY +g); make_revolution_cut(shWolfHead, 180, AHEAD - ABODY +g);
make_revolution_cut(shRatHead, 180, geom3::AHEAD - geom3::ABODY +g, 0.04*scalefactor); make_revolution_cut(shRatHead, 180, AHEAD - ABODY +g, 0.04*scalefactor);
make_revolution_cut(shRatCape1, 180, geom3::AHEAD - geom3::ABODY +g); make_revolution_cut(shRatCape1, 180, AHEAD - ABODY +g);
make_revolution_cut(shFamiliarHead, 30, geom3::AHEAD - geom3::ABODY +g); make_revolution_cut(shFamiliarHead, 30, AHEAD - ABODY +g);
// make_abody_3d(shDogTorso, 0.01); // make_abody_3d(shDogTorso, 0.01);
make_revolution_cut(shDogTorso, 30, +g); make_revolution_cut(shDogTorso, 30, +g);
make_revolution_cut(shDogHead, 180, geom3::AHEAD - geom3::ABODY +g); make_revolution_cut(shDogHead, 180, AHEAD - ABODY +g);
// make_ahead_3d(shDogHead); // make_ahead_3d(shDogHead);
// make_abody_3d(shCatBody, 0.05); // make_abody_3d(shCatBody, 0.05);
// make_ahead_3d(shCatHead); // make_ahead_3d(shCatHead);
make_revolution_cut(shCatBody, 30, +g); make_revolution_cut(shCatBody, 30, +g);
make_revolution_cut(shCatHead, 180, geom3::AHEAD - geom3::ABODY +g, 0.055 * scalefactor); make_revolution_cut(shCatHead, 180, AHEAD - ABODY +g, 0.055 * scalefactor);
make_paw_3d(shReptileFrontFoot, shReptileFrontLeg); make_paw_3d(shReptileFrontFoot, shReptileFrontLeg);
make_paw_3d(shReptileRearFoot, shReptileRearLeg); make_paw_3d(shReptileRearFoot, shReptileRearLeg);
make_abody_3d(shReptileBody, -1); make_abody_3d(shReptileBody, -1);
// make_ahead_3d(shReptileHead); // make_ahead_3d(shReptileHead);
make_revolution_cut(shReptileHead, 180, geom3::AHEAD - geom3::ABODY+g); make_revolution_cut(shReptileHead, 180, AHEAD - ABODY+g);
make_paw_3d(shBullFrontHoof, shBullFrontHoof); make_paw_3d(shBullFrontHoof, shBullFrontHoof);
make_paw_3d(shBullRearHoof, shBullRearHoof); make_paw_3d(shBullRearHoof, shBullRearHoof);
@ -886,19 +886,19 @@ void make_3d_models() {
// make_ahead_3d(shBullHead); // make_ahead_3d(shBullHead);
// make_ahead_3d(shBullHorn); // make_ahead_3d(shBullHorn);
make_revolution_cut(shBullBody, 180, +g); make_revolution_cut(shBullBody, 180, +g);
make_revolution_cut(shBullHead, 60, geom3::AHEAD - geom3::ABODY +g); make_revolution_cut(shBullHead, 60, AHEAD - ABODY +g);
shift_shape(shBullHorn, -g-(geom3::AHEAD - geom3::ABODY)); shift_shape(shBullHorn, -g-(AHEAD - ABODY));
// make_revolution_cut(shBullHorn, 180, geom3::AHEAD - geom3::ABODY); // make_revolution_cut(shBullHorn, 180, AHEAD - ABODY);
make_paw_3d(shTrylobiteFrontClaw, shTrylobiteFrontLeg); make_paw_3d(shTrylobiteFrontClaw, shTrylobiteFrontLeg);
make_paw_3d(shTrylobiteRearClaw, shTrylobiteRearLeg); make_paw_3d(shTrylobiteRearClaw, shTrylobiteRearLeg);
make_abody_3d(shTrylobiteBody, 0); make_abody_3d(shTrylobiteBody, 0);
// make_ahead_3d(shTrylobiteHead); // make_ahead_3d(shTrylobiteHead);
make_revolution_cut(shTrylobiteHead, 180, geom3::AHEAD - geom3::ABODY +g); make_revolution_cut(shTrylobiteHead, 180, AHEAD - ABODY +g);
make_revolution_cut(shShark, 180, WDIM == 2 ? -geom3::FLOOR : 0); make_revolution_cut(shShark, 180, WDIM == 2 ? -FLOOR : 0);
make_revolution_cut(shGhost, 60, geom3::GHOST + g); make_revolution_cut(shGhost, 60, GHOST + g);
make_revolution_cut(shEagle, 180, 0, 0.05*S); make_revolution_cut(shEagle, 180, 0, 0.05*S);
make_revolution_cut(shHawk, 180, 0, 0.05*S); make_revolution_cut(shHawk, 180, 0, 0.05*S);
@ -913,8 +913,8 @@ void make_3d_models() {
make_revolution_cut(shBatWings, 180, 0, 0.05*S); make_revolution_cut(shBatWings, 180, 0, 0.05*S);
make_revolution_cut(shBatBody, 180, 0, 0.05*S); make_revolution_cut(shBatBody, 180, 0, 0.05*S);
make_revolution_cut(shMouse, 180, -geom3::FLOOR); make_revolution_cut(shMouse, 180, -FLOOR);
shift_shape(shMouseLegs, geom3::FLOOR - geom3::human_height / 200); shift_shape(shMouseLegs, FLOOR - human_height / 200);
make_revolution_cut(shJelly, 60); make_revolution_cut(shJelly, 60);
make_revolution(shFoxTail1); make_revolution(shFoxTail1);
@ -925,8 +925,8 @@ void make_3d_models() {
make_revolution_cut(shBugLeg, 60); make_revolution_cut(shBugLeg, 60);
make_revolution(shBugArmor, 180, geom3::ABODY); make_revolution(shBugArmor, 180, ABODY);
make_revolution_cut(shBugAntenna, 90, geom3::ABODY); make_revolution_cut(shBugAntenna, 90, ABODY);
make_revolution_cut(shButterflyBody, 180, 0); make_revolution_cut(shButterflyBody, 180, 0);
make_revolution_cut(shButterflyWing, 180, 0, 0.05*S); make_revolution_cut(shButterflyWing, 180, 0, 0.05*S);
@ -963,8 +963,8 @@ void make_3d_models() {
make_revolution_cut(shWormTail, 60, g); make_revolution_cut(shWormTail, 60, g);
make_revolution_cut(shSmallWormTail, 60, g); make_revolution_cut(shSmallWormTail, 60, g);
make_revolution_cut(shTentHead, 60, g); make_revolution_cut(shTentHead, 60, g);
make_revolution_cut(shKrakenHead, 60, -geom3::FLOOR); make_revolution_cut(shKrakenHead, 60, -FLOOR);
make_revolution_cut(shSeaTentacle, 60, -geom3::FLOOR); make_revolution_cut(shSeaTentacle, 60, -FLOOR);
make_revolution_cut(shDragonLegs, 60, g); make_revolution_cut(shDragonLegs, 60, g);
make_revolution_cut(shDragonWings, 60, g); make_revolution_cut(shDragonWings, 60, g);
disable(shDragonNostril); disable(shDragonNostril);
@ -981,36 +981,36 @@ void make_3d_models() {
if(WDIM == 2) { if(WDIM == 2) {
for(int i=0; i<3; i++) { for(int i=0; i<3; i++) {
clone_shape(shHalfFloor[i], shHalfFloor[i+3]); clone_shape(shHalfFloor[i], shHalfFloor[i+3]);
shift_shape_orthogonally(shHalfFloor[i], geom3::FLOOR - geom3::human_height * .007); shift_shape_orthogonally(shHalfFloor[i], FLOOR - human_height * .007);
shift_shape_orthogonally(shHalfFloor[i+3], geom3::WALL + geom3::human_height * .007); shift_shape_orthogonally(shHalfFloor[i+3], WALL + human_height * .007);
} }
} }
shift_shape(shBoatOuter, geom3::FLOOR); shift_shape(shBoatOuter, FLOOR);
shift_shape(shBoatInner, (geom3::FLOOR+geom3::LAKE)/2); shift_shape(shBoatInner, (FLOOR+LAKE)/2);
for(int i=0; i<14; i++) for(int i=0; i<14; i++)
shift_shape(shTriheptaSpecial[i], geom3::FLOOR); shift_shape(shTriheptaSpecial[i], FLOOR);
shift_shape_orthogonally(shBigCarpet1, geom3::FLOOR - geom3::human_height * 1/40); shift_shape_orthogonally(shBigCarpet1, FLOOR - human_height * 1/40);
shift_shape_orthogonally(shBigCarpet2, geom3::FLOOR - geom3::human_height * 2/40); shift_shape_orthogonally(shBigCarpet2, FLOOR - human_height * 2/40);
shift_shape_orthogonally(shBigCarpet3, geom3::FLOOR - geom3::human_height * 3/40); shift_shape_orthogonally(shBigCarpet3, FLOOR - human_height * 3/40);
for(int a=0; a<5; a++) for(int b=0; b<4; b++) for(int a=0; a<5; a++) for(int b=0; b<4; b++)
shift_shape(shReptile[a][b], geom3::FLOOR - geom3::human_height * min(b, 2) / 40); shift_shape(shReptile[a][b], FLOOR - human_height * min(b, 2) / 40);
shift_shape(shMineMark[0], geom3::FLOOR - geom3::human_height * 1/40); shift_shape(shMineMark[0], FLOOR - human_height * 1/40);
shift_shape(shMineMark[1], geom3::FLOOR - geom3::human_height * 1/40); shift_shape(shMineMark[1], FLOOR - human_height * 1/40);
for(int a=0; a<5; a++) shift_shape(shZebra[a], geom3::FLOOR); for(int a=0; a<5; a++) shift_shape(shZebra[a], FLOOR);
for(int t=0; t<13; t++) for(int u=0; u<6; u++) for(int t=0; t<13; t++) for(int u=0; u<6; u++)
shift_shape(shTortoise[t][u], geom3::FLOOR - geom3::human_height * (t+1) / 120); shift_shape(shTortoise[t][u], FLOOR - human_height * (t+1) / 120);
make_revolution_cut(shStatue, 60); make_revolution_cut(shStatue, 60);
shift_shape(shThorns, geom3::FLOOR - geom3::human_height * 1/40); shift_shape(shThorns, FLOOR - human_height * 1/40);
clone_shape(shRose, shRoseItem); clone_shape(shRose, shRoseItem);
shift_shape(shRose, geom3::FLOOR - geom3::human_height * 1/20); shift_shape(shRose, FLOOR - human_height * 1/20);
DEBB(DF_POLY, ("slime")); DEBB(DF_POLY, ("slime"));
bshape(shSlime, PPR::MONSTER_BODY); bshape(shSlime, PPR::MONSTER_BODY);
@ -1029,17 +1029,17 @@ void make_3d_models() {
} }
last->flags |= POLY_TRIANGLES; last->flags |= POLY_TRIANGLES;
add_texture(*last); add_texture(*last);
if(WDIM == 2) shift_last_straight(geom3::FLOOR); if(WDIM == 2) shift_last_straight(FLOOR);
finishshape(); finishshape();
shJelly = shSlime; shJelly = shSlime;
shift_shape(shMagicSword, geom3::ABODY); shift_shape(shMagicSword, ABODY);
shift_shape(shMagicShovel, geom3::ABODY); shift_shape(shMagicShovel, ABODY);
DEBB(DF_POLY, ("eyes")); DEBB(DF_POLY, ("eyes"));
adjust_eye(shSlimeEyes, shSlime, geom3::FLATEYE, 0, 2, 2); adjust_eye(shSlimeEyes, shSlime, FLATEYE, 0, 2, 2);
adjust_eye(shGhostEyes, shGhost, geom3::GHOST, geom3::GHOST, 2, WDIM == 2 ? 2 : 4); adjust_eye(shGhostEyes, shGhost, GHOST, GHOST, 2, WDIM == 2 ? 2 : 4);
adjust_eye(shMiniEyes, shMiniGhost, geom3::GHOST, geom3::GHOST, 2, 2); adjust_eye(shMiniEyes, shMiniGhost, GHOST, GHOST, 2, 2);
adjust_eye(shWormEyes, shWormHead, 0, 0, 2, 4); adjust_eye(shWormEyes, shWormHead, 0, 0, 2, 4);
adjust_eye(shDragonEyes, shDragonHead, 0, 0, 2, 4); adjust_eye(shDragonEyes, shDragonHead, 0, 0, 2, 4);
@ -1050,31 +1050,31 @@ void make_3d_models() {
shRatEye2 = shWolf2; shRatEye2 = shWolf2;
shRatEye3 = shWolf3; shRatEye3 = shWolf3;
adjust_eye(shWolf1, shDogHead, geom3::AHEAD, geom3::AHEAD, 1); adjust_eye(shWolf1, shDogHead, AHEAD, AHEAD, 1);
adjust_eye(shWolf2, shDogHead, geom3::AHEAD, geom3::AHEAD, 1); adjust_eye(shWolf2, shDogHead, AHEAD, AHEAD, 1);
adjust_eye(shWolf3, shDogHead, geom3::AHEAD, geom3::AHEAD, 1); adjust_eye(shWolf3, shDogHead, AHEAD, AHEAD, 1);
adjust_eye(shFamiliarEye, shWolfHead, geom3::AHEAD, geom3::AHEAD, 1); adjust_eye(shFamiliarEye, shWolfHead, AHEAD, AHEAD, 1);
adjust_eye(shRatEye1, shRatHead, geom3::AHEAD, geom3::AHEAD, 1); adjust_eye(shRatEye1, shRatHead, AHEAD, AHEAD, 1);
adjust_eye(shRatEye2, shRatHead, geom3::AHEAD, geom3::AHEAD, 1); adjust_eye(shRatEye2, shRatHead, AHEAD, AHEAD, 1);
for(int i=shRatEye3.s; i<shRatEye3.e; i++) hpc[i] = xpush(-scalefactor * 0.02) * hpc[i]; for(int i=shRatEye3.s; i<shRatEye3.e; i++) hpc[i] = xpush(-scalefactor * 0.02) * hpc[i];
adjust_eye(shRatEye3, shRatHead, geom3::AHEAD, geom3::AHEAD, 1); adjust_eye(shRatEye3, shRatHead, AHEAD, AHEAD, 1);
adjust_eye(shWolfEyes, shWolfHead, geom3::AHEAD, geom3::AHEAD, 1); adjust_eye(shWolfEyes, shWolfHead, AHEAD, AHEAD, 1);
adjust_eye(shReptileEye, shReptileHead, geom3::AHEAD, geom3::AHEAD, 1); adjust_eye(shReptileEye, shReptileHead, AHEAD, AHEAD, 1);
adjust_eye(shGadflyEye, shGadflyBody, 0, 0, 1); adjust_eye(shGadflyEye, shGadflyBody, 0, 0, 1);
adjust_eye(shSkullEyes, shPHeadOnly, geom3::HEAD1, geom3::HEAD, 2, 2); adjust_eye(shSkullEyes, shPHeadOnly, HEAD1, HEAD, 2, 2);
shSkullEyes.tinf = NULL; shSkullEyes.tinf = NULL;
adjust_eye(shMouseEyes, shMouse, geom3::FLOOR, geom3::FLOOR, 2, 1); adjust_eye(shMouseEyes, shMouse, FLOOR, FLOOR, 2, 1);
shift_shape(shRatTail, zc(0.5) - geom3::LEG); shift_shape(shRatTail, zc(0.5) - LEG);
for(int i=shRatTail.s; i<shRatTail.e; i++) hpc[i] = xpush(-scalefactor * 0.1) * hpc[i]; for(int i=shRatTail.s; i<shRatTail.e; i++) hpc[i] = xpush(-scalefactor * 0.1) * hpc[i];
shift_shape(shSemiFloorShadow, geom3::FLOOR - geom3::human_height / 100); shift_shape(shSemiFloorShadow, FLOOR - human_height / 100);
shift_shape(shSemiFloor[0], geom3::WALL); shift_shape(shSemiFloor[0], WALL);
bshape(shPalaceGate, PPR::WALL); bshape(shPalaceGate, PPR::WALL);
for(int i=0; i<4; i++) { for(int i=0; i<4; i++) {
@ -1082,12 +1082,12 @@ void make_3d_models() {
for(int j=0; j<12; j++) { for(int j=0; j<12; j++) {
hyperpoint left = xpush(x) * xspinpush0(j * 30 * degree, 0.02); hyperpoint left = xpush(x) * xspinpush0(j * 30 * degree, 0.02);
hyperpoint right = xpush(x) * xspinpush0((j+1) * 30 * degree, 0.02); hyperpoint right = xpush(x) * xspinpush0((j+1) * 30 * degree, 0.02);
hpcpush(orthogonal_move(left, geom3::FLOOR)); hpcpush(orthogonal_move(left, FLOOR));
hpcpush(orthogonal_move(right, geom3::FLOOR)); hpcpush(orthogonal_move(right, FLOOR));
hpcpush(orthogonal_move(left, geom3::WALL)); hpcpush(orthogonal_move(left, WALL));
hpcpush(orthogonal_move(right, geom3::FLOOR)); hpcpush(orthogonal_move(right, FLOOR));
hpcpush(orthogonal_move(left, geom3::WALL)); hpcpush(orthogonal_move(left, WALL));
hpcpush(orthogonal_move(right, geom3::WALL)); hpcpush(orthogonal_move(right, WALL));
} }
} }
shPalaceGate.flags |= POLY_TRIANGLES; shPalaceGate.flags |= POLY_TRIANGLES;
@ -1108,7 +1108,7 @@ void make_3d_models() {
hyperpoint hz = C0; hyperpoint hz = C0;
hyperpoint h = hx * x + hy * y + hz * z; hyperpoint h = hx * x + hy * y + hz * z;
h = mid(h, h); h = mid(h, h);
h = orthogonal_move(h, geom3::FLOOR - geom3::human_height * (i+2.5) / 100 * (x+y+1)/2); h = orthogonal_move(h, FLOOR - human_height * (i+2.5) / 100 * (x+y+1)/2);
hpcpush(h); hpcpush(h);
}); });
} }

View File

@ -434,10 +434,10 @@ struct hrmap_archimedean : hrmap {
origin->move(1)->c.connect(1, origin->move(0), 2*current.N-1, false); origin->move(1)->c.connect(1, origin->move(0), 2*current.N-1, false);
} }
base_distlimit = 0; cgi.base_distlimit = 0;
celllister cl(origin->c7, 1000, 200, NULL); celllister cl(origin->c7, 1000, 200, NULL);
ginf[geometry].distlimit[!BITRUNCATED] = base_distlimit = cl.dists.back(); ginf[geometry].distlimit[!BITRUNCATED] = cgi.base_distlimit = cl.dists.back();
if(sphere) base_distlimit = SEE_ALL; if(sphere) cgi.base_distlimit = SEE_ALL;
} }
~hrmap_archimedean() { ~hrmap_archimedean() {
@ -784,7 +784,6 @@ int readArgs() {
} }
else { else {
set_geometry(gArchimedean); set_geometry(gArchimedean);
need_reset_geometry = true;
current = at; current = at;
showstartmenu = false; showstartmenu = false;
} }
@ -982,7 +981,6 @@ void next_variation() {
PURE ? eVariation::dual : PURE ? eVariation::dual :
DUAL ? eVariation::bitruncated : DUAL ? eVariation::bitruncated :
eVariation::pure); eVariation::pure);
need_reset_geometry = true;
start_game(); start_game();
} }
@ -1012,7 +1010,6 @@ void enable(archimedean_tiling& arct) {
} }
} }
#endif #endif
need_reset_geometry = true;
start_game(); start_game();
} }

View File

@ -693,7 +693,8 @@ void resetGL() {
floor_textures = NULL; floor_textures = NULL;
} }
#endif #endif
resetGeometry(); // includes buildPoly cgi.require_shapes();
cgi.initPolyForGL();
} }
#endif #endif
@ -1101,7 +1102,7 @@ void displayColorButton(int x, int y, const string& name, int key, int align, in
} }
ld textscale() { ld textscale() {
return vid.fsize / (current_display->radius * crossf) * (1+vid.alpha) * 2; return vid.fsize / (current_display->radius * cgi.crossf) * (1+vid.alpha) * 2;
} }
// bool notgl = false; // bool notgl = false;
@ -1238,7 +1239,7 @@ void initgraph() {
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
arg::read(2); arg::read(2);
#endif #endif
precalc(); cgi.prepare_basics();
#if CAP_SDL #if CAP_SDL
setvideomode(); setvideomode();

View File

@ -601,7 +601,7 @@ namespace binary {
auto bt_config = addHook(hooks_args, 0, [] () { auto bt_config = addHook(hooks_args, 0, [] () {
using namespace arg; using namespace arg;
if(argis("-btwidth")) { if(argis("-btwidth")) {
shift_arg_formula(vid.binary_width, delayed_geo_reset); shift_arg_formula(vid.binary_width);
return 0; return 0;
} }
return 1; return 1;

View File

@ -121,7 +121,7 @@ void drawBlizzards() {
if(wmascii || wmblack) if(wmascii || wmblack)
queuechr(tpartial, .2, '.', 0xFFFFFF); queuechr(tpartial, .2, '.', 0xFFFFFF);
else else
queuepoly(tpartial, shSnowball, 0xFFFFFF80); queuepoly(tpartial, cgi.shSnowball, 0xFFFFFF80);
} }
} }
@ -130,9 +130,9 @@ void drawBlizzards() {
/* if(isNeighbor(bc.c, mouseover)) { /* if(isNeighbor(bc.c, mouseover)) {
if(againstWind(mouseover, bc.c)) if(againstWind(mouseover, bc.c))
queuepoly(*bc.gm, shHeptaMarker, 0x00C00040); queuepoly(*bc.gm, cgi.shHeptaMarker, 0x00C00040);
if(againstWind(bc.c, mouseover)) if(againstWind(bc.c, mouseover))
queuepoly(*bc.gm, shHeptaMarker, 0xC0000040); queuepoly(*bc.gm, cgi.shHeptaMarker, 0xC0000040);
} */ } */
forCellIdEx(c2, i, bc.c) if(bc.c == mouseover || c2 == mouseover) { forCellIdEx(c2, i, bc.c) if(bc.c == mouseover || c2 == mouseover) {
@ -144,7 +144,7 @@ void drawBlizzards() {
if(isPlayerOn(bc.c)) if(isPlayerOn(bc.c))
col ^= 0x00000040; col ^= 0x00000040;
if(againstWind(bc.c, c2)) if(againstWind(bc.c, c2))
queuepoly(*bc.gm * ddspin(bc.c, i) * xpush(cellgfxdist(bc.c, i)/2), shWindArrow, col); queuepoly(*bc.gm * ddspin(bc.c, i) * xpush(cellgfxdist(bc.c, i)/2), cgi.shWindArrow, col);
} }
int B = isize(bc.outorder); int B = isize(bc.outorder);
@ -230,7 +230,7 @@ void drawArrowTraps() {
transmatrix& tv = u ? t1 : t0; transmatrix& tv = u ? t1 : t0;
hyperpoint trel = inverse(tu) * tC0(tv); hyperpoint trel = inverse(tu) * tC0(tv);
transmatrix tpartial = tu * rspintox(trel) * xpush(hdist0(trel) * tt / 401.0); transmatrix tpartial = tu * rspintox(trel) * xpush(hdist0(trel) * tt / 401.0);
queuepoly(tpartial * ypush(.05), shTrapArrow, 0xFFFFFFFF); queuepoly(tpartial * ypush(.05), cgi.shTrapArrow, 0xFFFFFFFF);
} }
} }
#endif #endif

View File

@ -67,6 +67,8 @@ namespace hr { namespace inv { bool on, activating; } }
#include "polygons.cpp" #include "polygons.cpp"
#include "3d-models.cpp" #include "3d-models.cpp"
#include "floorshapes.cpp" #include "floorshapes.cpp"
#include "usershapes.cpp"
#include "drawing.cpp"
#include "mapeditor.cpp" #include "mapeditor.cpp"
#if CAP_MODEL #if CAP_MODEL
#include "netgen.cpp" #include "netgen.cpp"

View File

@ -648,7 +648,8 @@ void loadConfig() {
} }
polygonal::solve(); polygonal::solve();
precalc(); check_cgi();
cgi.prepare_basics();
} }
#endif #endif
@ -855,7 +856,6 @@ void showGraphConfig() {
else if(xuni == 'L') { else if(xuni == 'L') {
dialog::editNumber(vid.linequality, -3, 5, 1, 1, XLAT("line quality"), dialog::editNumber(vid.linequality, -3, 5, 1, 1, XLAT("line quality"),
XLAT("Higher numbers make the curved lines smoother, but reduce the performance.")); XLAT("Higher numbers make the curved lines smoother, but reduce the performance."));
dialog::reaction = delayed_geo_reset;
} }
#if CAP_FRAMELIMIT #if CAP_FRAMELIMIT
@ -913,7 +913,6 @@ void edit_whatever(char type, int index) {
dialog::editNumber(whateveri[index], -10, 10, 1, 0, XLAT("whatever"), dialog::editNumber(whateveri[index], -10, 10, 1, 0, XLAT("whatever"),
"i:" + its(index)); "i:" + its(index));
} }
dialog::reaction = delayed_geo_reset;
dialog::extra_options = [type, index] { dialog::extra_options = [type, index] {
dialog::addItem(XLAT("integer"), 'X'); dialog::addItem(XLAT("integer"), 'X');
dialog::add_action( [index] { popScreen(); edit_whatever('i', index); }); dialog::add_action( [index] { popScreen(); edit_whatever('i', index); });
@ -1259,7 +1258,6 @@ void add_edit_wall_quality(char c) {
floor_textures = NULL; floor_textures = NULL;
} }
#endif #endif
need_reset_geometry = true;
}; };
}); });
} }
@ -1395,7 +1393,6 @@ void show3D() {
else if(uni == 'c' && WDIM == 2) else if(uni == 'c' && WDIM == 2)
tc_camera = ticks, tc_camera = ticks,
dialog::editNumber(geom3::camera, 0, 5, .1, 1, XLAT(GDIM == 2 ? "Camera level above the plane" : "Z shift"), ""), dialog::editNumber(geom3::camera, 0, 5, .1, 1, XLAT(GDIM == 2 ? "Camera level above the plane" : "Z shift"), ""),
dialog::reaction = [] { if(GDIM == 2) need_reset_geometry = true; },
dialog::extra_options = [] { dialog::extra_options = [] {
dialog::addHelp(GDIM == 2 ? XLAT( dialog::addHelp(GDIM == 2 ? XLAT(
"Camera is placed %1 absolute units above a plane P in a three-dimensional " "Camera is placed %1 absolute units above a plane P in a three-dimensional "
@ -1415,7 +1412,6 @@ void show3D() {
else if(uni == 'g' && WDIM == 2) else if(uni == 'g' && WDIM == 2)
tc_depth = ticks, tc_depth = ticks,
dialog::editNumber(geom3::depth, 0, 5, .1, 1, XLAT("Ground level below the plane"), ""), dialog::editNumber(geom3::depth, 0, 5, .1, 1, XLAT("Ground level below the plane"), ""),
dialog::reaction = delayed_geo_reset,
dialog::extra_options = [] { dialog::extra_options = [] {
dialog::addHelp(XLAT( dialog::addHelp(XLAT(
"Ground level is actually an equidistant surface, " "Ground level is actually an equidistant surface, "
@ -1438,28 +1434,21 @@ void show3D() {
projectionDialog(); projectionDialog();
else if(uni == 'w' && WDIM == 2) { else if(uni == 'w' && WDIM == 2) {
dialog::editNumber(geom3::wall_height, 0, 1, .1, .3, XLAT("Height of walls"), ""); dialog::editNumber(geom3::wall_height, 0, 1, .1, .3, XLAT("Height of walls"), "");
dialog::reaction = delayed_geo_reset;
dialog::extra_options = [] () { dialog::extra_options = [] () {
dialog::addHelp(XLAT( dialog::addHelp(XLAT(
"The height of walls, in absolute units. For the current values of g and c, " "The height of walls, in absolute units. For the current values of g and c, "
"wall height of %1 absolute units corresponds to projection value of %2.", "wall height of %1 absolute units corresponds to projection value of %2.",
fts(actual_wall_height()), fts(factor_to_projection(geom3::WALL)))); fts(actual_wall_height()), fts(factor_to_projection(cgi.WALL))));
dialog::addBoolItem(XLAT("auto-adjust in Goldberg grids"), geom3::gp_autoscale_heights, 'O'); dialog::addBoolItem(XLAT("auto-adjust in Goldberg grids"), geom3::gp_autoscale_heights, 'O');
dialog::add_action([] () { dialog::add_action([] () {
geom3::gp_autoscale_heights = !geom3::gp_autoscale_heights; geom3::gp_autoscale_heights = !geom3::gp_autoscale_heights;
buildpolys();
#if CAP_GL
resetGL();
#endif
}); });
}; };
} }
else if(uni == 'l' && WDIM == 2) else if(uni == 'l' && WDIM == 2)
dialog::editNumber(geom3::lake_top, 0, 1, .1, .25, XLAT("Level of water surface"), ""), dialog::editNumber(geom3::lake_top, 0, 1, .1, .25, XLAT("Level of water surface"), "");
dialog::reaction = delayed_geo_reset;
else if(uni == 'k' && WDIM == 2) else if(uni == 'k' && WDIM == 2)
dialog::editNumber(geom3::lake_bottom, 0, 1, .1, .9, XLAT("Level of water bottom"), ""), dialog::editNumber(geom3::lake_bottom, 0, 1, .1, .9, XLAT("Level of water bottom"), "");
dialog::reaction = delayed_geo_reset;
else if(uni == 'r' && WDIM == 2) else if(uni == 'r' && WDIM == 2)
dialog::editNumber(geom3::rock_wall_ratio, 0, 1, .1, .9, XLAT("Rock-III to wall ratio"), ""), dialog::editNumber(geom3::rock_wall_ratio, 0, 1, .1, .9, XLAT("Rock-III to wall ratio"), ""),
dialog::extra_options = [] { dialog::addHelp(XLAT( dialog::extra_options = [] { dialog::addHelp(XLAT(
@ -1468,11 +1457,9 @@ void show3D() {
"ground level.", "ground level.",
fts(rock_wall_ratio), fts(wall_height * rock_wall_ratio), fts(rock_wall_ratio), fts(wall_height * rock_wall_ratio),
fts(cosh(depth - wall_height * rock_wall_ratio) / cosh(depth)))); fts(cosh(depth - wall_height * rock_wall_ratio) / cosh(depth))));
}, };
dialog::reaction = delayed_geo_reset;
else if(uni == 'h' && WDIM == 2) else if(uni == 'h' && WDIM == 2)
dialog::editNumber(geom3::human_wall_ratio, 0, 1, .1, .7, XLAT("Human to wall ratio"), ""), dialog::editNumber(geom3::human_wall_ratio, 0, 1, .1, .7, XLAT("Human to wall ratio"), ""),
dialog::reaction = delayed_geo_reset,
dialog::extra_options = [] { dialog::addHelp(XLAT( dialog::extra_options = [] { dialog::addHelp(XLAT(
"Humans are %1 " "Humans are %1 "
"absolute units high. Your head travels %2 times the distance travelled by your " "absolute units high. Your head travels %2 times the distance travelled by your "
@ -1482,11 +1469,9 @@ void show3D() {
); );
}; };
else if(uni == 'h' && WDIM == 3) else if(uni == 'h' && WDIM == 3)
dialog::editNumber(geom3::height_width, 0, 1, .1, .7, XLAT("Height to width"), ""), dialog::editNumber(geom3::height_width, 0, 1, .1, .7, XLAT("Height to width"), "");
dialog::reaction = delayed_geo_reset;
else if(uni == 'c' && WDIM == 3) else if(uni == 'c' && WDIM == 3)
dialog::editNumber(geom3::creature_scale, 0, 1, .1, .7, XLAT("Creature scale"), ""), dialog::editNumber(geom3::creature_scale, 0, 1, .1, .7, XLAT("Creature scale"), "");
dialog::reaction = delayed_geo_reset;
else if(uni == 'e') else if(uni == 'e')
pushScreen(showStereo); pushScreen(showStereo);
@ -1566,7 +1551,8 @@ void showCustomizeChar() {
transmatrix V = atscreenpos(vid.xres/2, firsty, scale); transmatrix V = atscreenpos(vid.xres/2, firsty, scale);
double alpha = atan2(mousex - vid.xres/2, mousey - firsty) - M_PI/2; double alpha = atan2(mousex - vid.xres/2, mousey - firsty) - M_PI/2;
drawMonsterType(moPlayer, NULL, V * spin(alpha), 0, cc_footphase / scale); V = V * spin(alpha);
drawMonsterType(moPlayer, NULL, V, 0, cc_footphase / scale);
quickqueue(); quickqueue();
keyhandler = [] (int sym, int uni) { keyhandler = [] (int sym, int uni) {

View File

@ -300,13 +300,13 @@ void handlePanning(int sym, int uni) {
if(conformal::on) if(conformal::on)
conformal::rotation++; conformal::rotation++;
else else
View = spin(M_PI/S21/2*shiftmul) * View, didsomething = true; View = spin(M_PI/cgi.S21/2*shiftmul) * View, didsomething = true;
} }
if(sym == SDLK_PAGEDOWN) { if(sym == SDLK_PAGEDOWN) {
if(conformal::on) if(conformal::on)
conformal::rotation++; conformal::rotation++;
else else
View = spin(-M_PI/S21/2*shiftmul) * View, didsomething = true; View = spin(-M_PI/cgi.S21/2*shiftmul) * View, didsomething = true;
} }
if(sym == SDLK_PAGEUP || sym == SDLK_PAGEDOWN) if(sym == SDLK_PAGEUP || sym == SDLK_PAGEDOWN)
@ -338,7 +338,6 @@ bool handleTune(int sym, int uni) {
else if(uni == 'z') else if(uni == 'z')
bscale7 = bscale6 = 1, brot7 = brot6 = 0; bscale7 = bscale6 = 1, brot7 = brot6 = 0;
else return false; else return false;
resetGeometry();
println(hlog, spaced(bscale7, brot7, bscale6, brot6)); println(hlog, spaced(bscale7, brot7, bscale6, brot6));
return true; return true;
} }

View File

@ -1025,7 +1025,6 @@ void set_crystal(int sides) {
static char buf[20]; static char buf[20];
sprintf(buf, "{%d,4}", sides); sprintf(buf, "{%d,4}", sides);
ginf[gCrystal].tiling_name = buf; ginf[gCrystal].tiling_name = buf;
need_reset_geometry = true;
if(sides < MAX_EDGE) if(sides < MAX_EDGE)
ginf[gCrystal].distlimit = distlimit_table[sides]; ginf[gCrystal].distlimit = distlimit_table[sides];
} }
@ -1329,7 +1328,6 @@ coord euclid3_to_crystal(euclid3::coord x) {
void transform_crystal_to_euclid () { void transform_crystal_to_euclid () {
euclid3::clear_torus3(); euclid3::clear_torus3();
geometry = gCubeTiling; geometry = gCubeTiling;
need_reset_geometry = true;
auto e = new euclid3::hrmap_euclid3; auto e = new euclid3::hrmap_euclid3;
auto m = crystal_map(); auto m = crystal_map();
auto infront = cwt.cpeek(); auto infront = cwt.cpeek();
@ -1391,7 +1389,6 @@ void transform_euclid_to_crystal () {
ginf[gCrystal].sides = 6; ginf[gCrystal].sides = 6;
ginf[gCrystal].vertex = 4; ginf[gCrystal].vertex = 4;
ginf[gCrystal].tiling_name = "{6,4}"; ginf[gCrystal].tiling_name = "{6,4}";
need_reset_geometry = true;
ginf[gCrystal].distlimit = distlimit_table[6]; ginf[gCrystal].distlimit = distlimit_table[6];
auto e = euclid3::cubemap(); auto e = euclid3::cubemap();

View File

@ -338,7 +338,7 @@ struct debugScreen {
if(what) { if(what) {
#if CAP_SHAPES #if CAP_SHAPES
queuepoly(gmatrix[what], shAsymmetric, 0x80808080); queuepoly(gmatrix[what], cgi.shAsymmetric, 0x80808080);
#endif #endif
char buf[200]; char buf[200];
sprintf(buf, "%p", what); sprintf(buf, "%p", what);
@ -682,13 +682,12 @@ int read_cheat_args() {
else if(argis("-wef")) { else if(argis("-wef")) {
PHASEFROM(2); PHASEFROM(2);
shift(); int index = argi(); shift(); int index = argi();
shift_arg_formula(whatever[index], delayed_geo_reset); shift_arg_formula(whatever[index]);
} }
else if(argis("-wei")) { else if(argis("-wei")) {
PHASEFROM(2); PHASEFROM(2);
shift(); int index = argi(); shift(); int index = argi();
shift(); whateveri[index] = argi(); shift(); whateveri[index] = argi();
delayed_geo_reset();
} }
else if(argis("-W3")) { else if(argis("-W3")) {
shift(); top_land = readland(args()); cheat(); shift(); top_land = readland(args()); cheat();

1680
drawing.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -323,6 +323,7 @@ ld expansion_analyzer::get_growth() {
if(!N) preliminary_grouping(), reduce_grouping(); if(!N) preliminary_grouping(), reduce_grouping();
vector<ld> eigen(N, 1); vector<ld> eigen(N, 1);
ld total; ld total;
for(int iter=0; iter<100000; iter++) { for(int iter=0; iter<100000; iter++) {
total = 0; total = 0;
vector<ld> neweigen(N, 0); vector<ld> neweigen(N, 0);
@ -828,7 +829,6 @@ int expansion_readArgs() {
if(x+y > 10) continue; if(x+y > 10) continue;
stop_game(); stop_game();
gp::param = gp::loc(x, y); gp::param = gp::loc(x, y);
need_reset_geometry = true;
set_variation(eVariation::goldberg); set_variation(eVariation::goldberg);
compute_coefficients(); compute_coefficients();
} }

View File

@ -1,40 +1,61 @@
namespace hr { namespace hr {
#if CAP_SHAPES #if CAP_SHAPES
vector<plain_floorshape*> all_plain_floorshapes;
vector<escher_floorshape*> all_escher_floorshapes;
plain_floorshape vector<basic_textureinfo> floor_texture_vertices;
shFloor, renderbuffer *floor_textures;
shMFloor, shMFloor2, shMFloor3, shMFloor4, shFullFloor,
shBigTriangle, shTriheptaFloor, shBigHepta;
escher_floorshape shStarFloor(1,2), void geometry_information::init_floorshapes() {
shCloudFloor(3, 4), all_escher_floorshapes.clear();
shCrossFloor(5, 6, 2, 54), all_plain_floorshapes = {
shChargedFloor(7, 385, 1, 10), &shFloor, &shMFloor, &shMFloor2, &shMFloor3, &shMFloor4,
shSStarFloor(11, 12), &shFullFloor, &shBigTriangle, &shTriheptaFloor, &shBigHepta
shOverFloor(13, 15, 1, 14), };
shTriFloor(17, 18, 0, 385),
shFeatherFloor(19, 21, 1, 20), for(auto s: all_plain_floorshapes) s->is_plain = true;
shBarrowFloor(23, 24, 1, 25),
shNewFloor(26, 27, 2, 54), auto init_escher = [this] (escher_floorshape& sh, int s0, int s1, int noft=0, int s2=0) {
shTrollFloor(28, 29), sh.shapeid0 = s0;
shButterflyFloor(325, 326, 1, 178), sh.shapeid1 = s1;
shLavaFloor(359, 360, 1, 178), sh.noftype = noft;
shLavaSeabed(386, 387, 1, 178), sh.shapeid2 = s2;
shSeabed(334, 335), sh.scale = 1;
shCloudSeabed(336, 337), sh.is_plain = false;
shCaveSeabed(338, 339, 2, 54), all_escher_floorshapes.push_back(&sh);
shPalaceFloor(45, 46, 0, 385), };
shDemonFloor(51, 50, 1, 178),
shCaveFloor(52, 53, 2, 54), init_escher(shStarFloor, 1,2);
shDesertFloor(55, 56, 0, 4), init_escher(shCloudFloor, 3, 4);
shPowerFloor(57, 58, 0, 12), /* dragon */ init_escher(shCrossFloor, 5, 6, 2, 54);
shRoseFloor(174, 175, 1, 173), init_escher(shChargedFloor, 7, 385, 1, 10);
shSwitchFloor(377, 378, 1, 379), init_escher(shSStarFloor, 11, 12);
shTurtleFloor(176, 177, 1, 178), init_escher(shOverFloor, 13, 15, 1, 14);
shRedRockFloor[3] = {{55, 56}, {55, 56}, {55, 56}}, // 1 - .1 * i init_escher(shTriFloor, 17, 18, 0, 385);
shDragonFloor(181, 182, 2, 183); /* dragon */ init_escher(shFeatherFloor, 19, 21, 1, 20);
init_escher(shBarrowFloor, 23, 24, 1, 25);
init_escher(shNewFloor, 26, 27, 2, 54);
init_escher(shTrollFloor, 28, 29);
init_escher(shButterflyFloor, 325, 326, 1, 178);
init_escher(shLavaFloor, 359, 360, 1, 178);
init_escher(shLavaSeabed, 386, 387, 1, 178);
init_escher(shSeabed, 334, 335);
init_escher(shCloudSeabed, 336, 337);
init_escher(shCaveSeabed, 338, 339, 2, 54);
init_escher(shPalaceFloor, 45, 46, 0, 385);
init_escher(shDemonFloor, 51, 50, 1, 178);
init_escher(shCaveFloor, 52, 53, 2, 54);
init_escher(shDesertFloor, 55, 56, 0, 4);
init_escher(shPowerFloor, 57, 58, 0, 12); /* dragon */
init_escher(shRoseFloor, 174, 175, 1, 173);
init_escher(shSwitchFloor, 377, 378, 1, 379);
init_escher(shTurtleFloor, 176, 177, 1, 178);
for(int i: {0,1,2})
init_escher(shRedRockFloor[i], 55, 56);
init_escher(shDragonFloor, 181, 182, 2, 183); /* dragon */
int ids = 0;
for(auto sh: all_plain_floorshapes) sh->id = ids++;
for(auto sh: all_escher_floorshapes) sh->id = ids++;
}
typedef pair<transmatrix, array<transmatrix, MAX_EDGE>> matrixitem; typedef pair<transmatrix, array<transmatrix, MAX_EDGE>> matrixitem;
@ -108,7 +129,7 @@ void generate_matrices_scale(ld scale, int noft) {
mesher ohex = msh(gNormal, 6, 0.329036, 0.566256, 0.620672, 0, 1); mesher ohex = msh(gNormal, 6, 0.329036, 0.566256, 0.620672, 0, 1);
mesher ohept = msh(gNormal, 7, hexf7, hcrossf7, hcrossf7, M_PI/7, 1); mesher ohept = msh(gNormal, 7, hexf7, hcrossf7, hcrossf7, M_PI/7, 1);
if(!BITRUNCATED) { if(!BITRUNCATED) {
mesher nall = msh(geometry, S7, rhexf, tessf, tessf, -M_PI, scale); mesher nall = msh(geometry, S7, cgi.rhexf, cgi.tessf, cgi.tessf, -M_PI, scale);
bool use = geosupport_football() < 2; bool use = geosupport_football() < 2;
if(use && noft == 1) { if(use && noft == 1) {
mesher opure = msh(gNormal, 7, 0.620672, 1.090550, 1.090550, M_PI/7, 1); mesher opure = msh(gNormal, 7, 0.620672, 1.090550, 1.090550, M_PI/7, 1);
@ -127,12 +148,12 @@ void generate_matrices_scale(ld scale, int noft) {
} }
} }
else { else {
generate_matrices(hex_matrices, ohex, msh(geometry, S6, hexvdist, hexhexdist, hcrossf, (S3-3)*M_PI/S3, scale)); generate_matrices(hex_matrices, ohex, msh(geometry, S6, cgi.hexvdist, cgi.hexhexdist, cgi.hcrossf, (S3-3)*M_PI/S3, scale));
generate_matrices(hept_matrices, ohept, msh(geometry, S7, rhexf, hcrossf, hcrossf, euclid6?0:euclid4?0:M_PI/S7, scale)); generate_matrices(hept_matrices, ohept, msh(geometry, S7, cgi.rhexf, cgi.hcrossf, cgi.hcrossf, euclid6?0:euclid4?0:M_PI/S7, scale));
} }
} }
void bshape2(hpcshape& sh, PPR prio, int shapeid, matrixlist& m) { void geometry_information::bshape2(hpcshape& sh, PPR prio, int shapeid, matrixlist& m) {
auto& matrices = m.v; auto& matrices = m.v;
int osym = m.o.sym; int osym = m.o.sym;
int nsym = m.n.sym; int nsym = m.n.sym;
@ -196,7 +217,7 @@ void bshape2(hpcshape& sh, PPR prio, int shapeid, matrixlist& m) {
hpcpush(hpc[last->s]); hpcpush(hpc[last->s]);
} }
void bshape_regular(floorshape &fsh, int id, int sides, int shift, ld size) { void geometry_information::bshape_regular(floorshape &fsh, int id, int sides, int shift, ld size) {
fsh.b.resize(2); fsh.b.resize(2);
fsh.shadow.resize(2); fsh.shadow.resize(2);
@ -272,7 +293,7 @@ template<class T> void sizeto(T& t, int n) {
// !siid equals pseudohept(c) // !siid equals pseudohept(c)
void generate_floorshapes_for(int id, cell *c, int siid, int sidir) { void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
DEBBI(DF_POLY, ("generate_floorshapes_for ", id)); DEBBI(DF_POLY, ("generate_floorshapes_for ", id));
for(auto pfsh: all_plain_floorshapes) { for(auto pfsh: all_plain_floorshapes) {
@ -470,13 +491,13 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
auto& fsh = *pfsh; auto& fsh = *pfsh;
for(int i=fsh.shadow[id].s; i<fsh.shadow[id].e; i++) for(int i=fsh.shadow[id].s; i<fsh.shadow[id].e; i++)
hpc[i] = orthogonal_move(hpc[i], geom3::FLOOR - geom3::human_height / 100); hpc[i] = orthogonal_move(hpc[i], FLOOR - human_height / 100);
for(int k=0; k<SIDEPARS; k++) { for(int k=0; k<SIDEPARS; k++) {
sizeto(fsh.levels[k], id); sizeto(fsh.levels[k], id);
bshape(fsh.levels[k][id], fsh.prio); bshape(fsh.levels[k][id], fsh.prio);
last->flags |= POLY_TRIANGLES; last->flags |= POLY_TRIANGLES;
last->tinf = &fsh.tinf3; last->tinf = &floor_texture_vertices[fsh.id];
last->texture_offset = 0; last->texture_offset = 0;
#if CAP_BT #if CAP_BT
@ -506,10 +527,10 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
sizeto(fsh.cone[co], id); sizeto(fsh.cone[co], id);
bshape(fsh.cone[co][id], fsh.prio); bshape(fsh.cone[co][id], fsh.prio);
last->flags |= POLY_TRIANGLES; last->flags |= POLY_TRIANGLES;
last->tinf = &fsh.tinf3; last->tinf = &floor_texture_vertices[fsh.id];
last->texture_offset = 0; last->texture_offset = 0;
ld h = (geom3::FLOOR - geom3::WALL) / (co+1); ld h = (FLOOR - WALL) / (co+1);
ld top = co ? (geom3::FLOOR + geom3::WALL) / 2 : geom3::WALL; ld top = co ? (FLOOR + WALL) / 2 : WALL;
#if CAP_BT #if CAP_BT
if(binarytiling) if(binarytiling)
for(int t=0; t<c->type; t++) for(int t=0; t<c->type; t++)
@ -534,9 +555,9 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
} }
for(int l=0; l<SIDEPARS; l++) { for(int l=0; l<SIDEPARS; l++) {
for(auto& li: fsh.side[l]) li.tinf = &fsh.tinf3; for(auto& li: fsh.side[l]) li.tinf = &floor_texture_vertices[fsh.id];
for(int e=0; e<MAX_EDGE; e++) for(int e=0; e<MAX_EDGE; e++)
for(auto& li: fsh.gpside[l][e]) li.tinf = &fsh.tinf3; for(auto& li: fsh.gpside[l][e]) li.tinf = &floor_texture_vertices[fsh.id];
} }
} }
@ -546,18 +567,18 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
for(int l=0; l<SIDEPARS; l++) { for(int l=0; l<SIDEPARS; l++) {
fsh.levels[l] = shFullFloor.levels[l]; fsh.levels[l] = shFullFloor.levels[l];
fsh.shadow = shFullFloor.shadow; fsh.shadow = shFullFloor.shadow;
for(auto& li: fsh.levels[l]) li.tinf = &fsh.tinf3; for(auto& li: fsh.levels[l]) li.tinf = &floor_texture_vertices[fsh.id];
fsh.side[l] = shFullFloor.side[l]; fsh.side[l] = shFullFloor.side[l];
for(auto& li: fsh.side[l]) li.tinf = &fsh.tinf3; for(auto& li: fsh.side[l]) li.tinf = &floor_texture_vertices[fsh.id];
for(int e=0; e<MAX_EDGE; e++) { for(int e=0; e<MAX_EDGE; e++) {
fsh.gpside[l][e] = shFullFloor.gpside[l][e]; fsh.gpside[l][e] = shFullFloor.gpside[l][e];
for(auto& li: fsh.gpside[l][e]) li.tinf = &fsh.tinf3; for(auto& li: fsh.gpside[l][e]) li.tinf = &floor_texture_vertices[fsh.id];
} }
fsh.cone[0] = shFullFloor.cone[0]; fsh.cone[0] = shFullFloor.cone[0];
fsh.cone[1] = shFullFloor.cone[1]; fsh.cone[1] = shFullFloor.cone[1];
for(int c=0; c<2; c++) for(int c=0; c<2; c++)
for(auto& li: fsh.cone[c]) for(auto& li: fsh.cone[c])
li.tinf = &fsh.tinf3; li.tinf = &floor_texture_vertices[fsh.id];
} }
} }
finishshape(); finishshape();
@ -565,9 +586,10 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
#endif #endif
} }
void generate_floorshapes() { void geometry_information::generate_floorshapes() {
DEBBI(DF_POLY, ("generate_floorshapes")); DEBBI(DF_POLY, ("generate_floorshapes"));
if(WDIM == 3) ; if(WDIM == 3) ;
#if CAP_IRR #if CAP_IRR
@ -645,10 +667,10 @@ namespace gp {
if(master) li.last_dir = -1; if(master) li.last_dir = -1;
DEBB(DF_GP, (format("last=%d at=%d,%d tot=%d siid=%d sidir=%d cor=%d id=%d\n", li.last_dir, li.relative.first, li.relative.second, li.total_dir, siid, sidir, cor, id))); DEBB(DF_GP, (format("last=%d at=%d,%d tot=%d siid=%d sidir=%d cor=%d id=%d\n", li.last_dir, li.relative.first, li.relative.second, li.total_dir, siid, sidir, cor, id)));
generate_floorshapes_for(id, c0, siid, sidir); cgi.generate_floorshapes_for(id, c0, siid, sidir);
finishshape(); last = NULL; cgi.finishshape();
extra_vertices(); cgi.extra_vertices();
} }
int get_plainshape_id(cell *c) { int get_plainshape_id(cell *c) {
@ -670,7 +692,7 @@ namespace gp {
sidir = 0; sidir = 0;
} }
auto& id = pshid[siid][sidir][draw_li.relative.first&31][draw_li.relative.second&31][fix6(draw_li.total_dir)]; auto& id = pshid[siid][sidir][draw_li.relative.first&31][draw_li.relative.second&31][fix6(draw_li.total_dir)];
if(id == -1 && sphere && isize(shFloor.b) > 0) { if(id == -1 && sphere && isize(cgi.shFloor.b) > 0) {
forCellEx(c1, c) if(!gmatrix0.count(c1)) return 0; forCellEx(c1, c) if(!gmatrix0.count(c1)) return 0;
} }
if(id == -1) build_plainshape(id, draw_li, c, siid, sidir); if(id == -1) build_plainshape(id, draw_li, c, siid, sidir);
@ -811,13 +833,12 @@ auto floor_hook =
#if MAXMDIM >= 4 #if MAXMDIM >= 4
renderbuffer *floor_textures; void draw_shape_for_texture(floorshape* sh) {
void draw_shape_for_texture(floorshape* sh, int& id) { int id = sh->id;
ld gx = (id % 8) * 1.5 - 3.5 * 1.5; ld gx = (id % 8) * 1.5 - 3.5 * 1.5;
ld gy = (id / 8) * 1.5 - 3.5 * 1.5; ld gy = (id / 8) * 1.5 - 3.5 * 1.5;
id++;
if(1) { if(1) {
dynamicval<ld> v(vid.linewidth, 8); dynamicval<ld> v(vid.linewidth, 8);
@ -835,8 +856,8 @@ void draw_shape_for_texture(floorshape* sh, int& id) {
for(int b=-1; b<=1; b++) for(int b=-1; b<=1; b++)
queuepoly(eupush(gx+a/2., gy+b/2.), sh->b[0], 0xFFFFFFFF); queuepoly(eupush(gx+a/2., gy+b/2.), sh->b[0], 0xFFFFFFFF);
if(sh == &shCrossFloor) { if(sh == &cgi.shCrossFloor) {
queuepoly(eupush(gx, gy) * spin(M_PI/4), shCross, 0x808080FF); queuepoly(eupush(gx, gy) * spin(M_PI/4), cgi.shCross, 0x808080FF);
} }
if(1) { if(1) {
@ -849,8 +870,9 @@ void draw_shape_for_texture(floorshape* sh, int& id) {
queuecurve(0x40404000 + sh->fstrength * 192/10, 0, PPR::LINE); queuecurve(0x40404000 + sh->fstrength * 192/10, 0, PPR::LINE);
} }
sh->tinf3.tvertices.clear(); auto& ftv = floor_texture_vertices[sh->id];
sh->tinf3.texture_id = floor_textures->renderedTexture; ftv.tvertices.clear();
ftv.texture_id = floor_textures->renderedTexture;
using namespace hyperpoint_vec; using namespace hyperpoint_vec;
hyperpoint center = eupush(gx, gy) * C0; hyperpoint center = eupush(gx, gy) * C0;
@ -865,94 +887,98 @@ void draw_shape_for_texture(floorshape* sh, int& id) {
glvec2 v; glvec2 v;
v[0] = (1 + inmodel[0] * vid.scale) / 2; v[0] = (1 + inmodel[0] * vid.scale) / 2;
v[1] = (1 - inmodel[1] * vid.scale) / 2; v[1] = (1 - inmodel[1] * vid.scale) / 2;
sh->tinf3.tvertices.push_back(glhr::makevertex(v[0], v[1], 0)); ftv.tvertices.push_back(glhr::makevertex(v[0], v[1], 0));
}); });
} }
const int FLOORTEXTURESIZE = 4096; const int FLOORTEXTURESIZE = 4096;
void make_floor_textures() { void geometry_information::make_floor_textures_here() {
if(1) { require_shapes();
DEBBI(DF_POLY, ("make_floor_textures"));
dynamicval<eGeometry> g(geometry, gEuclidSquare); dynamicval<videopar> vi(vid, vid);
dynamicval<eModel> gm(pmodel, mdDisk); vid.xres = FLOORTEXTURESIZE;
dynamicval<eVariation> va(variation, eVariation::pure); vid.yres = FLOORTEXTURESIZE;
dynamicval<bool> a3(geom3::always3, false); vid.scale = 0.25;
dynamicval<bool> hq(inHighQual, true); vid.camera_angle = 0;
dynamicval<int> hd(darken, 0); vid.alpha = 1;
dynamicval<ld> gd(geom3::depth, 1); dynamicval<ld> lw(vid.linewidth, 2);
dynamicval<ld> gc(geom3::camera, 1);
floor_textures = new renderbuffer(vid.xres, vid.yres, vid.usingGL);
resetbuffer rb;
floor_texture_vertices.resize(isize(all_escher_floorshapes) + isize(all_plain_floorshapes));
resetGeometry(); auto cd = current_display;
dynamicval<videopar> vi(vid, vid); cd->xtop = cd->ytop = 0;
vid.xres = FLOORTEXTURESIZE; cd->xsize = cd->ysize = FLOORTEXTURESIZE;
vid.yres = FLOORTEXTURESIZE; cd->xcenter = cd->ycenter = cd->scrsize = FLOORTEXTURESIZE/2;
vid.scale = 0.25;
vid.camera_angle = 0; cd->radius = cd->scrsize * vid.scale;
vid.alpha = 1;
dynamicval<ld> lw(vid.linewidth, 2);
floor_textures = new renderbuffer(vid.xres, vid.yres, vid.usingGL); floor_textures->enable();
resetbuffer rb; floor_textures->clear(0); // 0xE8E8E8 = 1
// gradient vertices
vector<glhr::colored_vertex> gv;
current_display->scrdist = 0;
gv.emplace_back(-1, -1, 0, 0, 0);
gv.emplace_back(+1, -1, 0, 0, 0);
gv.emplace_back(+1, +1, 1, 1, 1);
gv.emplace_back(-1, -1, 0, 0, 0);
gv.emplace_back(+1, +1, 1, 1, 1);
gv.emplace_back(-1, +1, 1, 1, 1);
auto cd = current_display; glhr::switch_mode(glhr::gmVarColored, glhr::shader_projection::standard);
cd->xtop = cd->ytop = 0; current_display->set_all(0);
cd->xsize = cd->ysize = FLOORTEXTURESIZE; glhr::new_projection();
cd->xcenter = cd->ycenter = cd->scrsize = FLOORTEXTURESIZE/2; glhr::id_modelview();
glhr::prepare(gv);
cd->radius = cd->scrsize * vid.scale; glhr::set_depthtest(false);
glDrawArrays(GL_TRIANGLES, 0, isize(gv));
shOverFloor.pstrength = 20;
shFeatherFloor.pstrength = 40;
shFeatherFloor.fstrength = 5;
shTrollFloor.pstrength = 25;
shCaveFloor.pstrength = 40;
shCaveFloor.fstrength = 0;
shDesertFloor.pstrength = 30;
shDesertFloor.fstrength =10;
shRoseFloor.pstrength = 30;
shDragonFloor.pstrength = 30;
shBarrowFloor.pstrength = 40;
floor_textures->enable(); // all using Tortoise
floor_textures->clear(0); // 0xE8E8E8 = 1 for(auto v: all_escher_floorshapes) if(v->shapeid2 == 178) v->pstrength = 20;
// gradient vertices ptds.clear();
vector<glhr::colored_vertex> gv;
current_display->scrdist = 0; for(auto v: all_plain_floorshapes) draw_shape_for_texture(v);
gv.emplace_back(-1, -1, 0, 0, 0); for(auto v: all_escher_floorshapes) draw_shape_for_texture(v);
gv.emplace_back(+1, -1, 0, 0, 0);
gv.emplace_back(+1, +1, 1, 1, 1); drawqueue();
gv.emplace_back(-1, -1, 0, 0, 0);
gv.emplace_back(+1, +1, 1, 1, 1); /*
gv.emplace_back(-1, +1, 1, 1, 1); SDL_Surface *sdark = floor_textures->render();
IMAGESAVE(sdark, "texture-test.png");
*/
rb.reset();
}
glhr::switch_mode(glhr::gmVarColored, glhr::shader_projection::standard); void make_floor_textures() {
current_display->set_all(0); DEBBI(DF_POLY, ("make_floor_textures"));
glhr::new_projection(); dynamicval<eGeometry> g(geometry, gEuclidSquare);
glhr::id_modelview(); dynamicval<eModel> gm(pmodel, mdDisk);
glhr::prepare(gv); dynamicval<eVariation> va(variation, eVariation::pure);
glhr::set_depthtest(false); dynamicval<bool> a3(geom3::always3, false);
glDrawArrays(GL_TRIANGLES, 0, isize(gv)); dynamicval<bool> hq(inHighQual, true);
dynamicval<int> hd(darken, 0);
shOverFloor.pstrength = 20; dynamicval<ld> gd(geom3::depth, 1);
shFeatherFloor.pstrength = 40; dynamicval<ld> gc(geom3::camera, 1);
shFeatherFloor.fstrength = 5; dynamicval<geometry_information*> dcgip(cgip, cgip);
shTrollFloor.pstrength = 25; check_cgi();
shCaveFloor.pstrength = 40; cgi.make_floor_textures_here();
shCaveFloor.fstrength = 0;
shDesertFloor.pstrength = 30;
shDesertFloor.fstrength =10;
shRoseFloor.pstrength = 30;
shDragonFloor.pstrength = 30;
shBarrowFloor.pstrength = 40;
// all using Tortoise
for(auto v: all_escher_floorshapes) if(v->shapeid2 == 178) v->pstrength = 20;
ptds.clear();
int id = 0;
for(auto v: all_plain_floorshapes) draw_shape_for_texture(v, id);
for(auto v: all_escher_floorshapes) draw_shape_for_texture(v, id);
drawqueue();
/*
SDL_Surface *sdark = floor_textures->render();
IMAGESAVE(sdark, "texture-test.png");
*/
rb.reset();
}
} }

View File

@ -2916,7 +2916,7 @@ void buildRosemap() {
} }
int getDistLimit() { return base_distlimit; } int getDistLimit() { return cgi.base_distlimit; }
bool nogoSlow(cell *to, cell *from) { bool nogoSlow(cell *to, cell *from) {
if(cellEdgeUnstable(to) && gravityLevelDiff(to, from) >= 0) return true; if(cellEdgeUnstable(to) && gravityLevelDiff(to, from) >= 0) return true;

View File

@ -484,10 +484,10 @@ void showEuclideanMenu() {
#if CAP_GP #if CAP_GP
if(GOLDBERG && S3) if(GOLDBERG && S3)
nom = 2 * (2*tv + ts * (gp::area-1)); nom = 2 * (2*tv + ts * (cgi.gpdata->area-1));
if(GOLDBERG && S3 == 4) if(GOLDBERG && S3 == 4)
nom = 2 * (2*tv + 2 * ts * (gp::area-1)); nom = 2 * (2*tv + 2 * ts * (cgi.gpdata->area-1));
#endif #endif
int worldsize; int worldsize;
@ -625,7 +625,6 @@ void showEuclideanMenu() {
dialog::add_action([] { dialog::add_action([] {
dialog::editNumber(vid.binary_width, 0, 2, 0.1, 1, XLAT("binary tiling width"), ""); dialog::editNumber(vid.binary_width, 0, 2, 0.1, 1, XLAT("binary tiling width"), "");
dialog::reaction = [] () { dialog::reaction = [] () {
need_reset_geometry = true;
#if CAP_TEXTURE #if CAP_TEXTURE
texture::config.remap(); texture::config.remap();
#endif #endif

View File

@ -5,30 +5,6 @@
namespace hr { namespace hr {
ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf;
// tessf: distance from heptagon center to another heptagon center
// hexf: distance from heptagon center to small heptagon vertex
// hcrossf: distance from heptagon center to big heptagon vertex
// crossf: distance from heptagon center to adjacent cell center (either hcrossf or tessf)
// hexhexdist: distance between adjacent hexagon vertices
// hexvdist: distance between hexagon vertex and hexagon center
// hepvdist: distance between heptagon vertex and hexagon center (either hcrossf or something else)
// rhexf: distance from heptagon center to heptagon vertex (either hexf or hcrossf)
int base_distlimit;
transmatrix heptmove[MAX_EDGE], hexmove[MAX_EDGE];
transmatrix invheptmove[MAX_EDGE], invhexmove[MAX_EDGE];
ld hexshift;
ld sword_size = 0;
ld corner_bonus = 0;
ld asteroid_size[8];
// the results are: // the results are:
// hexf = 0.378077 hcrossf = 0.620672 tessf = 1.090550 // hexf = 0.378077 hcrossf = 0.620672 tessf = 1.090550
// hexhexdist = 0.566256 // hexhexdist = 0.566256
@ -36,13 +12,11 @@ ld asteroid_size[8];
ld hcrossf7 = 0.620672; ld hcrossf7 = 0.620672;
ld hexf7 = 0.378077; ld hexf7 = 0.378077;
ld scalefactor, orbsize, floorrad0, floorrad1, zhexf;
// the distance between two hexagon centers // the distance between two hexagon centers
void precalc() { void geometry_information::prepare_basics() {
DEBBI(DF_INIT | DF_POLY | DF_GEOM, ("precalc")); DEBBI(DF_INIT | DF_POLY | DF_GEOM, ("prepare_basics"));
hexshift = 0; hexshift = 0;
@ -53,7 +27,6 @@ void precalc() {
if(euclid) { if(euclid) {
// dynamicval<eGeometry> g(geometry, gNormal); // dynamicval<eGeometry> g(geometry, gNormal);
// precalc(); }
// for(int i=0; i<S84; i++) spinmatrix[i] = spin(i * M_PI / S42); // for(int i=0; i<S84; i++) spinmatrix[i] = spin(i * M_PI / S42);
if(a4 && !BITRUNCATED) { if(a4 && !BITRUNCATED) {
crossf = .5; crossf = .5;
@ -187,6 +160,10 @@ void precalc() {
} }
set_sibling_limit(); set_sibling_limit();
prepare_compute3();
if(hyperbolic && &currfp != &fieldpattern::fp_invalid)
currfp.analyze();
} }
transmatrix xspinpush(ld dir, ld dist) { transmatrix xspinpush(ld dir, ld dist) {
@ -206,11 +183,9 @@ namespace geom3 {
ld depth = 1; // world below the plane ld depth = 1; // world below the plane
ld camera = 1; // camera above the plane ld camera = 1; // camera above the plane
ld wall_height = .3; ld wall_height = .3;
ld slev = .08;
ld lake_top = .25, lake_bottom = .9; ld lake_top = .25, lake_bottom = .9;
ld rock_wall_ratio = .9; ld rock_wall_ratio = .9;
ld human_wall_ratio = .7; ld human_wall_ratio = .7;
ld human_height;
bool gp_autoscale_heights = true; bool gp_autoscale_heights = true;
ld creature_scale, height_width; ld creature_scale, height_width;
@ -263,13 +238,6 @@ namespace geom3 {
return cosh(depth - lev); return cosh(depth - lev);
} }
ld INFDEEP, BOTTOM, HELLSPIKE, LAKE, WALL, FLOOR, STUFF,
SLEV[4], FLATEYE,
LEG0, LEG1, LEG, LEG3, GROIN, GROIN1, GHOST,
BODY, BODY1, BODY2, BODY3,
NECK1, NECK, NECK3, HEAD, HEAD1, HEAD2, HEAD3,
ALEG0, ALEG, ABODY, AHEAD, BIRD, LOWSKY, SKY, HIGH, HIGH2;
string invalid; string invalid;
ld actual_wall_height() { ld actual_wall_height() {
@ -279,8 +247,10 @@ namespace geom3 {
#endif #endif
return wall_height; return wall_height;
} }
}
void compute() { void geometry_information::prepare_compute3() {
using namespace geom3;
DEBBI(DF_INIT | DF_POLY | DF_GEOM, ("geom3::compute")); DEBBI(DF_INIT | DF_POLY | DF_GEOM, ("geom3::compute"));
// tanh(depth) / tanh(camera) == vid.alpha // tanh(depth) / tanh(camera) == vid.alpha
invalid = ""; invalid = "";
@ -388,11 +358,11 @@ namespace geom3 {
} }
} }
namespace geom3 {
#if MAXMDIM >= 4 #if MAXMDIM >= 4
void switch_always3() { void switch_always3() {
if(rug::rugged) rug::close(); if(rug::rugged) rug::close();
geom3::always3 = !geom3::always3; geom3::always3 = !geom3::always3;
need_reset_geometry = true;
swapmatrix(View); swapmatrix(View);
callhooks(hooks_swapdim); callhooks(hooks_swapdim);
} }
@ -431,7 +401,6 @@ void switch_always3() {
geom3::human_wall_ratio = 0.8; geom3::human_wall_ratio = 0.8;
geom3::camera = 0; geom3::camera = 0;
if(pmodel == mdDisk) pmodel = mdPerspective; if(pmodel == mdDisk) pmodel = mdPerspective;
need_reset_geometry = true;
swapmatrix(View); swapmatrix(View);
callhooks(hooks_swapdim); callhooks(hooks_swapdim);
#if CAP_RACING #if CAP_RACING
@ -445,7 +414,6 @@ void switch_always3() {
geom3::camera = 1; geom3::camera = 1;
geom3::depth = 1; geom3::depth = 1;
if(pmodel == mdPerspective) pmodel = mdDisk; if(pmodel == mdPerspective) pmodel = mdDisk;
need_reset_geometry = true;
swapmatrix(View); swapmatrix(View);
callhooks(hooks_swapdim); callhooks(hooks_swapdim);
} }
@ -454,8 +422,50 @@ void switch_always3() {
} }
void initgeo() { geometry_information *cgip;
// printf("%Lf\n", (ld) hdist0(xpush(-1)*ypush(0.01)*xpush(1)*C0)); map<string, geometry_information> cgis;
precalc();
void check_cgi() {
string s;
auto V = [&] (string a, string b) { s += a; s += ": "; s += b; s += "; "; };
V("GEO", its(int(geometry)));
V("VAR", its(int(variation)));
if(GOLDBERG) V("GP", its(gp::param.first) + "," + its(gp::param.second));
if(IRREGULAR) V("IRR", its(irr::irrid));
if(geometry == gArchimedean) V("ARCM", arcm::current.symbol);
if(geometry == gCrystal) V("CRYSTAL", its(ginf[gCrystal].sides) + its(ginf[gCrystal].vertex));
if(binarytiling || DIM == 3) V("WQ", its(vid.texture_step));
if(binarytiling) V("BT", fts(vid.binary_width));
if(GDIM == 2) {
V("CAMERA", fts(geom3::camera));
}
if(WDIM == 2) {
V("WH", fts(geom3::wall_height));
V("HW", fts(geom3::human_wall_ratio));
V("RW", fts(geom3::rock_wall_ratio));
V("DEPTH", fts(geom3::depth));
V("ASH", ONOFF(geom3::gp_autoscale_heights));
V("LT", fts(geom3::lake_top));
V("LB", fts(geom3::lake_bottom));
}
V("3D", ONOFF(geom3::always3));
if(WDIM == 3) {
V("CS", fts(geom3::creature_scale));
V("HTW", fts(geom3::height_width));
}
V("LQ", its(vid.linequality));
cgip = &cgis[s];
} }
} }

View File

@ -35,7 +35,7 @@ transmatrix master_relative(cell *c, bool get_inverse) {
} }
else { else {
auto li = gp::get_local_info(c); auto li = gp::get_local_info(c);
transmatrix T = spin(master_to_c7_angle()) * gp::Tf[li.last_dir][li.relative.first&31][li.relative.second&31][gp::fixg6(li.total_dir)]; transmatrix T = spin(master_to_c7_angle()) * cgi.gpdata->Tf[li.last_dir][li.relative.first&31][li.relative.second&31][gp::fixg6(li.total_dir)];
if(get_inverse) T = inverse(T); if(get_inverse) T = inverse(T);
return T; return T;
} }
@ -43,7 +43,7 @@ transmatrix master_relative(cell *c, bool get_inverse) {
#endif #endif
else if(BITRUNCATED && !euclid) { else if(BITRUNCATED && !euclid) {
for(int d=0; d<S7; d++) if(c->master->c7->move(d) == c) for(int d=0; d<S7; d++) if(c->master->c7->move(d) == c)
return (get_inverse?invhexmove:hexmove)[d]; return (get_inverse?cgi.invhexmove:cgi.hexmove)[d];
return Id; return Id;
} }
else if(WDIM == 3 || euclid) else if(WDIM == 3 || euclid)
@ -90,8 +90,8 @@ transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint
ld bestdist = 1e9; ld bestdist = 1e9;
for(int d=0; d<S7; d++) if(h2->move(d)) { for(int d=0; d<S7; d++) if(h2->move(d)) {
int sp = h2->c.spin(d); int sp = h2->c.spin(d);
transmatrix S = heptmove[sp] * spin(2*M_PI*d/S7); transmatrix S = cgi.heptmove[sp] * spin(2*M_PI*d/S7);
if(h2->c.mirror(d)) S = heptmove[sp] * Mirror * spin(2*M_PI*d/S7); if(h2->c.mirror(d)) S = cgi.heptmove[sp] * Mirror * spin(2*M_PI*d/S7);
if(h2->move(d) == h1) { if(h2->move(d) == h1) {
transmatrix T1 = gm * S * where; transmatrix T1 = gm * S * where;
auto curdist = hdist(tC0(T1), point_hint); auto curdist = hdist(tC0(T1), point_hint);
@ -99,7 +99,7 @@ transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint
} }
if(geometry != gMinimal) for(int e=0; e<S7; e++) if(h2->move(d)->move(e) == h1) { if(geometry != gMinimal) for(int e=0; e<S7; e++) if(h2->move(d)->move(e) == h1) {
int sp2 = h2->move(d)->c.spin(e); int sp2 = h2->move(d)->c.spin(e);
transmatrix T1 = gm * heptmove[sp2] * spin(2*M_PI*e/S7) * S * where; transmatrix T1 = gm * cgi.heptmove[sp2] * spin(2*M_PI*e/S7) * S * where;
auto curdist = hdist(tC0(T1), point_hint); auto curdist = hdist(tC0(T1), point_hint);
if(curdist < bestdist) T = T1, bestdist = curdist; if(curdist < bestdist) T = T1, bestdist = curdist;
} }
@ -108,7 +108,7 @@ transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint
} }
for(int d=0; d<S7; d++) if(h2->move(d) == h1) { for(int d=0; d<S7; d++) if(h2->move(d) == h1) {
int sp = h2->c.spin(d); int sp = h2->c.spin(d);
return gm * heptmove[sp] * spin(2*M_PI*d/S7) * where; return gm * cgi.heptmove[sp] * spin(2*M_PI*d/S7) * where;
} }
if(among(geometry, gFieldQuotient, gBring, gMacbeath)) { if(among(geometry, gFieldQuotient, gBring, gMacbeath)) {
int bestdist = 1000000, bestd = 0; int bestdist = 1000000, bestd = 0;
@ -117,7 +117,7 @@ transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint
if(dist < bestdist) bestdist = dist, bestd = d; if(dist < bestdist) bestdist = dist, bestd = d;
} }
int sp = h2->c.spin(bestd); int sp = h2->c.spin(bestd);
where = heptmove[sp] * spin(2*M_PI*bestd/S7) * where; where = cgi.heptmove[sp] * spin(2*M_PI*bestd/S7) * where;
h2 = h2->move(bestd); h2 = h2->move(bestd);
} }
#if CAP_CRYSTAL #if CAP_CRYSTAL
@ -127,7 +127,7 @@ transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint
if(visited.count(h3)) continue; if(visited.count(h3)) continue;
visited.insert(h3); visited.insert(h3);
int sp3 = h2->c.spin(d3); int sp3 = h2->c.spin(d3);
transmatrix where3 = heptmove[sp3] * spin(2*M_PI*d3/S7) * where; transmatrix where3 = cgi.heptmove[sp3] * spin(2*M_PI*d3/S7) * where;
ld dist = crystal::space_distance(h3->c7, c1); ld dist = crystal::space_distance(h3->c7, c1);
hbdist[dist].emplace_back(h3, where3); hbdist[dist].emplace_back(h3, where3);
} }
@ -140,12 +140,12 @@ transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint
else if(h1->distance < h2->distance) { else if(h1->distance < h2->distance) {
int sp = h2->c.spin(0); int sp = h2->c.spin(0);
h2 = h2->move(0); h2 = h2->move(0);
where = heptmove[sp] * where; where = cgi.heptmove[sp] * where;
} }
else { else {
int sp = h1->c.spin(0); int sp = h1->c.spin(0);
h1 = h1->move(0); h1 = h1->move(0);
gm = gm * invheptmove[sp]; gm = gm * cgi.invheptmove[sp];
} }
} }
/*if(hsol) { /*if(hsol) {
@ -184,11 +184,11 @@ transmatrix calc_relative_matrix_help(cell *c, heptagon *h1) {
#if CAP_GP #if CAP_GP
else if(GOLDBERG && c != c->master->c7) { else if(GOLDBERG && c != c->master->c7) {
auto li = gp::get_local_info(c); auto li = gp::get_local_info(c);
where = gp::Tf[li.last_dir][li.relative.first&31][li.relative.second&31][fix6(li.total_dir)]; where = cgi.gpdata->Tf[li.last_dir][li.relative.first&31][li.relative.second&31][fix6(li.total_dir)];
} }
#endif #endif
else if(BITRUNCATED) for(int d=0; d<S7; d++) if(h2->c7->move(d) == c) else if(BITRUNCATED) for(int d=0; d<S7; d++) if(h2->c7->move(d) == c)
where = hexmove[d]; where = cgi.hexmove[d];
// always add to last! // always add to last!
while(h1 != h2) { while(h1 != h2) {
for(int d=0; d<S7; d++) if(h1->move(d) == h2) printf("(adj) "); for(int d=0; d<S7; d++) if(h1->move(d) == h2) printf("(adj) ");
@ -196,13 +196,13 @@ transmatrix calc_relative_matrix_help(cell *c, heptagon *h1) {
int sp = h2->c.spin(0); int sp = h2->c.spin(0);
printf("A%d ", sp); printf("A%d ", sp);
h2 = h2->move(0); h2 = h2->move(0);
where = heptmove[sp] * where; where = cgi.heptmove[sp] * where;
} }
else { else {
int sp = h1->c.spin(0); int sp = h1->c.spin(0);
printf("B%d ", sp); printf("B%d ", sp);
h1 = h1->move(0); h1 = h1->move(0);
gm = gm * invheptmove[sp]; gm = gm * cgi.invheptmove[sp];
} }
} }
println(hlog, "OK"); println(hlog, "OK");
@ -286,7 +286,7 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
if(WDIM == 2 && !binarytiling) for(int d=0; d<S7; d++) { if(WDIM == 2 && !binarytiling) for(int d=0; d<S7; d++) {
heptspin hs(h, d, false); heptspin hs(h, d, false);
heptspin hs2 = hs + wstep; heptspin hs2 = hs + wstep;
transmatrix V2 = spin(-hs2.spin*2*M_PI/S7) * invheptmove[d]; transmatrix V2 = spin(-hs2.spin*2*M_PI/S7) * cgi.invheptmove[d];
horo_distance newz(check(V2 * at)); horo_distance newz(check(V2 * at));
if(newz < currz) { if(newz < currz) {
currz = newz; currz = newz;
@ -302,7 +302,7 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
else { else {
if(tohex && BITRUNCATED) for(int d=0; d<S7; d++) { if(tohex && BITRUNCATED) for(int d=0; d<S7; d++) {
cell *c = createMov(base, d); cell *c = createMov(base, d);
transmatrix V2 = spin(-base->c.spin(d)*2*M_PI/S6) * invhexmove[d]; transmatrix V2 = spin(-base->c.spin(d)*2*M_PI/S6) * cgi.invhexmove[d];
horo_distance newz(check(V2 * at)); horo_distance newz(check(V2 * at));
if(newz < currz) { if(newz < currz) {
currz = newz; currz = newz;
@ -367,7 +367,7 @@ void virtualRebaseSimple(heptagon*& base, transmatrix& at) {
for(int d=0; d<S7; d++) { for(int d=0; d<S7; d++) {
heptspin hs(h, d, false); heptspin hs(h, d, false);
heptspin hs2 = hs + wstep; heptspin hs2 = hs + wstep;
transmatrix V2 = spin(-hs2.spin*2*M_PI/S7) * invheptmove[d] * at; transmatrix V2 = spin(-hs2.spin*2*M_PI/S7) * cgi.invheptmove[d] * at;
double newz = V2[GDIM][GDIM]; double newz = V2[GDIM][GDIM];
if(newz < currz) { if(newz < currz) {
currz = newz; currz = newz;
@ -388,11 +388,11 @@ void virtualRebaseSimple(heptagon*& base, transmatrix& at) {
double cellgfxdist(cell *c, int i) { double cellgfxdist(cell *c, int i) {
if(euclid) { if(euclid) {
if(c->type == 8 && (i&1)) return crossf * sqrt(2); if(c->type == 8 && (i&1)) return cgi.crossf * sqrt(2);
return crossf; return cgi.crossf;
} }
if(NONSTDVAR || archimedean || WDIM == 3) return hdist0(tC0(calc_relative_matrix(c->move(i), c, i))); if(NONSTDVAR || archimedean || WDIM == 3) return hdist0(tC0(calc_relative_matrix(c->move(i), c, i)));
return !BITRUNCATED ? tessf : (c->type == 6 && (i&1)) ? hexhexdist : crossf; return !BITRUNCATED ? cgi.tessf : (c->type == 6 && (i&1)) ? cgi.hexhexdist : cgi.crossf;
} }
transmatrix cellrelmatrix(cell *c, int i) { transmatrix cellrelmatrix(cell *c, int i) {
@ -415,7 +415,7 @@ hyperpoint randomPointIn(int t) {
while(true) { while(true) {
hyperpoint h = xspinpush0(2*M_PI*(randd()-.5)/t, asinh(randd())); hyperpoint h = xspinpush0(2*M_PI*(randd()-.5)/t, asinh(randd()));
double d = double d =
PURE ? tessf : t == 6 ? hexhexdist : crossf; PURE ? cgi.tessf : t == 6 ? cgi.hexhexdist : cgi.crossf;
if(hdist0(h) < hdist0(xpush(-d) * h)) if(hdist0(h) < hdist0(xpush(-d) * h))
return spin(2*M_PI/t * (rand() % t)) * h; return spin(2*M_PI/t * (rand() % t)) * h;
} }
@ -462,13 +462,13 @@ hyperpoint get_corner_position(cell *c, int cid, ld cf) {
} }
#endif #endif
if(PURE) { if(PURE) {
return ddspin(c,cid,M_PI/S7) * xpush0(hcrossf * 3 / cf); return ddspin(c,cid,M_PI/S7) * xpush0(cgi.hcrossf * 3 / cf);
} }
if(BITRUNCATED) { if(BITRUNCATED) {
if(!ishept(c)) if(!ishept(c))
return ddspin(c,cid,M_PI/S6) * xpush0(hexvdist * 3 / cf); return ddspin(c,cid,M_PI/S6) * xpush0(cgi.hexvdist * 3 / cf);
else else
return ddspin(c,cid,M_PI/S7) * xpush0(rhexf * 3 / cf); return ddspin(c,cid,M_PI/S7) * xpush0(cgi.rhexf * 3 / cf);
} }
return C0; return C0;
} }
@ -613,7 +613,7 @@ hyperpoint get_warp_corner(cell *c, int cid) {
#if CAP_IRR || CAP_ARCM #if CAP_IRR || CAP_ARCM
if(IRREGULAR || archimedean) return midcorner(c, cid, .5); if(IRREGULAR || archimedean) return midcorner(c, cid, .5);
#endif #endif
return ddspin(c,cid,M_PI/S7) * xpush0(tessf/2); return ddspin(c,cid,M_PI/S7) * xpush0(cgi.tessf/2);
} }
vector<hyperpoint> hrmap::get_vertices(cell* c) { vector<hyperpoint> hrmap::get_vertices(cell* c) {

View File

@ -46,8 +46,6 @@ namespace hr { namespace gp {
loc param(1, 0); loc param(1, 0);
hyperpoint next; hyperpoint next;
ld alpha;
int area;
struct goldberg_mapping_t { struct goldberg_mapping_t {
cellwalker cw; cellwalker cw;
@ -504,22 +502,18 @@ namespace hr { namespace gp {
return normalize(spin(2*M_PI*sp/S7) * cornmul(T, corner)); return normalize(spin(2*M_PI*sp/S7) * cornmul(T, corner));
} }
transmatrix Tf[MAX_EDGE][32][32][6];
transmatrix corners;
transmatrix dir_matrix(int i) { transmatrix dir_matrix(int i) {
cell cc; cc.type = S7; cell cc; cc.type = S7;
return spin(-alpha) * build_matrix( return spin(-cgi.gpdata->alpha) * build_matrix(
C0, C0,
ddspin(&cc, i) * xpush0(tessf), ddspin(&cc, i) * xpush0(cgi.tessf),
ddspin(&cc, i+1) * xpush0(tessf), ddspin(&cc, i+1) * xpush0(cgi.tessf),
C03 C03
); );
} }
void prepare_matrices() { void prepare_matrices() {
corners = inverse(build_matrix( cgi.gpdata->corners = inverse(build_matrix(
loctoh_ort(loc(0,0)), loctoh_ort(loc(0,0)),
loctoh_ort(param), loctoh_ort(param),
loctoh_ort(param * loc(0,1)), loctoh_ort(param * loc(0,1)),
@ -532,9 +526,9 @@ namespace hr { namespace gp {
for(int d=0; d<(S3==3?6:4); d++) { for(int d=0; d<(S3==3?6:4); d++) {
loc at = loc(x, y); loc at = loc(x, y);
hyperpoint h = atz(T, corners, at, 6); hyperpoint h = atz(T, cgi.gpdata->corners, at, 6);
hyperpoint hl = atz(T, corners, at + eudir(d), 6); hyperpoint hl = atz(T, cgi.gpdata->corners, at + eudir(d), 6);
Tf[i][x&31][y&31][d] = rgpushxto0(h) * rspintox(gpushxto0(h) * hl) * spin(M_PI); cgi.gpdata->Tf[i][x&31][y&31][d] = rgpushxto0(h) * rspintox(gpushxto0(h) * hl) * spin(M_PI);
} }
} }
} }
@ -542,10 +536,10 @@ namespace hr { namespace gp {
hyperpoint get_corner_position(const local_info& li, int cid, ld cf = 3) { hyperpoint get_corner_position(const local_info& li, int cid, ld cf = 3) {
int i = li.last_dir; int i = li.last_dir;
if(i == -1) if(i == -1)
return atz(dir_matrix(cid), corners, li.relative, 0, cf); return atz(dir_matrix(cid), cgi.gpdata->corners, li.relative, 0, cf);
else { else {
auto& cellmatrix = Tf[i][li.relative.first&31][li.relative.second&31][fixg6(li.total_dir)]; auto& cellmatrix = cgi.gpdata->Tf[i][li.relative.first&31][li.relative.second&31][fixg6(li.total_dir)];
return inverse(cellmatrix) * atz(dir_matrix(i), corners, li.relative, fixg6(cid + li.total_dir), cf); return inverse(cellmatrix) * atz(dir_matrix(i), cgi.gpdata->corners, li.relative, fixg6(cid + li.total_dir), cf);
} }
} }
@ -558,36 +552,34 @@ namespace hr { namespace gp {
void compute_geometry() { void compute_geometry() {
center_locs.clear(); center_locs.clear();
if(GOLDBERG) { if(GOLDBERG) {
if(!cgi.gpdata) cgi.gpdata = make_shared<geometry_information::gpdata_t>();
int x = param.first; int x = param.first;
int y = param.second; int y = param.second;
if(S3 == 3) if(S3 == 3)
area = ((2*x+y) * (2*x+y) + y*y*3) / 4; cgi.gpdata->area = ((2*x+y) * (2*x+y) + y*y*3) / 4;
else else
area = x * x + y * y; cgi.gpdata->area = x * x + y * y;
next = point3(x+y/2., -y * sqrt(3) / 2, 0); next = point3(x+y/2., -y * sqrt(3) / 2, 0);
ld scale = 1 / hypot_d(2, next); ld scale = 1 / hypot_d(2, next);
crossf *= scale; cgi.crossf *= scale;
hepvdist *= scale; cgi.hepvdist *= scale;
hexhexdist *= scale; cgi.hexhexdist *= scale;
hexvdist *= scale; cgi.hexvdist *= scale;
rhexf *= scale; cgi.rhexf *= scale;
// spin = spintox(next); // spin = spintox(next);
// ispin = rspintox(next); // ispin = rspintox(next);
alpha = -atan2(next[1], next[0]) * 6 / S7; cgi.gpdata->alpha = -atan2(next[1], next[0]) * 6 / S7;
if(S3 == 3) if(S3 == 3)
base_distlimit = (base_distlimit + log(scale) / log(2.618)) / scale; cgi.base_distlimit = (cgi.base_distlimit + log(scale) / log(2.618)) / scale;
else else
base_distlimit = 3 * max(param.first, param.second) + 2 * min(param.first, param.second); cgi.base_distlimit = 3 * max(param.first, param.second) + 2 * min(param.first, param.second);
if(S7 == 12) if(S7 == 12)
base_distlimit = 2 * param.first + 2 * param.second + 1; cgi.base_distlimit = 2 * param.first + 2 * param.second + 1;
if(base_distlimit > SEE_ALL) if(cgi.base_distlimit > SEE_ALL)
base_distlimit = SEE_ALL; cgi.base_distlimit = SEE_ALL;
prepare_matrices(); prepare_matrices();
DEBB(DF_GEOM | DF_POLY, ("scale = ", scale)); DEBB(DF_GEOM | DF_POLY, ("scale = ", scale));
} }
else {
alpha = 0;
}
} }
loc config; loc config;
@ -625,7 +617,6 @@ namespace hr { namespace gp {
stop_game(); set_variation(eVariation::bitruncated); stop_game(); set_variation(eVariation::bitruncated);
} }
else { else {
if(param != xy) need_reset_geometry = true;
param = xy; param = xy;
stop_game(); set_variation(eVariation::goldberg); stop_game(); set_variation(eVariation::goldberg);
} }
@ -765,7 +756,7 @@ namespace hr { namespace gp {
int sp = 0; int sp = 0;
auto& at = li.relative; auto& at = li.relative;
again: again:
auto corner = corners * loctoh_ort(at); auto corner = cgi.gpdata->corners * loctoh_ort(at);
if(corner[1] < -1e-6 || corner[2] < -1e-6) { if(corner[1] < -1e-6 || corner[2] < -1e-6) {
at = at * eudir(1); at = at * eudir(1);
sp++; sp++;
@ -832,7 +823,7 @@ namespace hr { namespace gp {
hyperpoint get_master_coordinates(cell *c) { hyperpoint get_master_coordinates(cell *c) {
auto li = get_local_info(c); auto li = get_local_info(c);
be_in_triangle(li); be_in_triangle(li);
return corners * loctoh_ort(li.relative); return cgi.gpdata->corners * loctoh_ort(li.relative);
} }
int compute_dist(cell *c, int master_function(cell*)) { int compute_dist(cell *c, int master_function(cell*)) {

1897
graph.cpp

File diff suppressed because it is too large Load Diff

10
hud.cpp
View File

@ -187,9 +187,9 @@ bool displayglyph(int cx, int cy, int buttonsize, char glyph, color_t color, int
if(m == moKrakenT || m == moDragonTail) bsize /= 2; if(m == moKrakenT || m == moDragonTail) bsize /= 2;
if(m == moSlime) bsize = (2*bsize+1)/3; if(m == moSlime) bsize = (2*bsize+1)/3;
transmatrix V = atscreenpos(cx+buttonsize/2, cy, bsize*zoom); transmatrix V = atscreenpos(cx+buttonsize/2, cy, bsize*zoom);
if(isWorm(m) && wormscale != 1) if(isWorm(m) && cgi.wormscale != 1)
for(int i=0; i<DIM; i++) for(int i=0; i<DIM; i++)
V[i][i] /= wormscale; V[i][i] /= cgi.wormscale;
int mcol = color; int mcol = color;
mcol -= (color & 0xFCFCFC) >> 2; mcol -= (color & 0xFCFCFC) >> 2;
drawMonsterType(m, NULL, V, mcol, glyphphase[id]/500.0); drawMonsterType(m, NULL, V, mcol, glyphphase[id]/500.0);
@ -345,7 +345,7 @@ void drawMobileArrow(int i) {
double dx = xmove + rad*(1+SKIPFAC-.2)/2 * cos(alpha); double dx = xmove + rad*(1+SKIPFAC-.2)/2 * cos(alpha);
double dy = yb + rad*(1+SKIPFAC-.2)/2 * sin(alpha); double dy = yb + rad*(1+SKIPFAC-.2)/2 * sin(alpha);
queuepolyat(atscreenpos(dx, dy, scale) * spin(-alpha), shArrow, col, PPR::MOBILE_ARROW); queuepolyat(atscreenpos(dx, dy, scale) * spin(-alpha), cgi.shArrow, col, PPR::MOBILE_ARROW);
} }
#endif #endif
@ -403,11 +403,11 @@ void draw_radar(bool cornermode) {
if(d3) displaychr(int(cx + rad * r.h[0]), int(cy - rad * r.h[2] * si + rad * r.h[1] * co), 0, 8, r.glyph, r.color); if(d3) displaychr(int(cx + rad * r.h[0]), int(cy - rad * r.h[2] * si + rad * r.h[1] * co), 0, 8, r.glyph, r.color);
else if(sph) displaychr(int(cx + (rad-10) * r.h[0]), int(cy + (rad-10) * r.h[2] * si + (rad-10) * r.h[1] * co), 0, +r.h[1] * si > r.h[2] * co ? 8 : 16, r.glyph, r.color); else if(sph) displaychr(int(cx + (rad-10) * r.h[0]), int(cy + (rad-10) * r.h[2] * si + (rad-10) * r.h[1] * co), 0, +r.h[1] * si > r.h[2] * co ? 8 : 16, r.glyph, r.color);
else if(hyp) { else if(hyp) {
int siz = 1/(1+r.h[3]) * scalefactor * current_display->radius / (inHighQual ? 10 : 6); int siz = 1/(1+r.h[3]) * cgi.scalefactor * current_display->radius / (inHighQual ? 10 : 6);
displaychr(int(cx + rad * r.h[0]), int(cy + rad * r.h[1]), 0, siz, r.glyph, r.color); displaychr(int(cx + rad * r.h[0]), int(cy + rad * r.h[1]), 0, siz, r.glyph, r.color);
} }
else { else {
displaychr(int(cx + rad * r.h[0]), int(cy + rad * r.h[1]), 0, rad * scalefactor / (max_eu_dist + scalefactor/4) * 0.8, r.glyph, r.color); displaychr(int(cx + rad * r.h[0]), int(cy + rad * r.h[1]), 0, rad * cgi.scalefactor / (max_eu_dist + cgi.scalefactor/4) * 0.8, r.glyph, r.color);
} }
} }

396
hyper.h
View File

@ -2019,8 +2019,6 @@ void checkStunKill(cell *dest);
void clearMessages(); void clearMessages();
void resetGeometry();
namespace shot { namespace shot {
#if CAP_SHOT #if CAP_SHOT
extern int shotx, shoty, shotformat; extern int shotx, shoty, shotformat;
@ -3174,6 +3172,7 @@ namespace irr {
extern int place_attempts; extern int place_attempts;
extern int rearrange_max_attempts; extern int rearrange_max_attempts;
extern int rearrange_less; extern int rearrange_less;
extern int irrid;
void link_to_base(heptagon *h, heptspin base); void link_to_base(heptagon *h, heptspin base);
void link_start(heptagon *h); void link_start(heptagon *h);
void link_next(heptagon *h, int d); void link_next(heptagon *h, int d);
@ -3309,7 +3308,6 @@ transmatrix screenpos(ld x, ld y);
extern ld backbrightness; extern ld backbrightness;
void initcells(); void initcells();
void precalc();
extern const hyperpoint C02, C03; extern const hyperpoint C02, C03;
#define C0 (DIM == 2 ? C02 : C03) #define C0 (DIM == 2 ? C02 : C03)
@ -3336,10 +3334,6 @@ extern bool fixseed;
extern eLand firstland0; extern eLand firstland0;
extern int startseed; extern int startseed;
extern transmatrix heptmove[MAX_EDGE], hexmove[MAX_EDGE];
extern transmatrix invheptmove[MAX_EDGE], invhexmove[MAX_EDGE];
// heptspin hsstep(const heptspin &hs, int spin); // heptspin hsstep(const heptspin &hs, int spin);
extern void fixmatrix(transmatrix&); extern void fixmatrix(transmatrix&);
@ -3512,12 +3506,6 @@ dqi_line& queueline(const hyperpoint& H1, const hyperpoint& H2, color_t col, int
dqi_action& queueaction(PPR prio, const reaction_t& action); dqi_action& queueaction(PPR prio, const reaction_t& action);
void queuereset(eModel m, PPR prio); void queuereset(eModel m, PPR prio);
extern ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf;
extern ld sword_size;
extern ld scalefactor, orbsize, floorrad0, floorrad1, zhexf;
unsigned char& part(color_t& col, int i); unsigned char& part(color_t& col, int i);
transmatrix applyPatterndir(cell *c, const patterns::patterninfo& si); transmatrix applyPatterndir(cell *c, const patterns::patterninfo& si);
@ -3608,6 +3596,8 @@ struct renderbuffer {
void clear(color_t col); void clear(color_t col);
}; };
extern renderbuffer *floor_textures;
struct resetbuffer { struct resetbuffer {
GLint drawFboId, readFboId; GLint drawFboId, readFboId;
SDL_Surface *sreset; SDL_Surface *sreset;
@ -3791,12 +3781,9 @@ namespace gp {
void compute_geometry(); void compute_geometry();
void extend_map(cell *c, int d); void extend_map(cell *c, int d);
extern loc param; extern loc param;
extern int area;
extern int pseudohept_val(cell *); extern int pseudohept_val(cell *);
extern int last_dir(cell *c); extern int last_dir(cell *c);
extern void configure(); extern void configure();
extern ld alpha;
extern transmatrix Tf[MAX_EDGE][32][32][6];
struct local_info { struct local_info {
int last_dir; int last_dir;
@ -3831,8 +3818,6 @@ int gamerange();
int numplayers(); int numplayers();
extern int base_distlimit;
bool has_nice_dual(); bool has_nice_dual();
extern hyperpoint mid(const hyperpoint &h1, const hyperpoint &h2); extern hyperpoint mid(const hyperpoint &h1, const hyperpoint &h2);
@ -4055,16 +4040,6 @@ struct hpcshape {
int shs, she; int shs, she;
}; };
extern hpcshape shFullCross[2];
void bshape(hpcshape& sh, PPR prio);
void hpcpush(hyperpoint h);
void finishshape();
void extra_vertices();
extern vector<hyperpoint> hpc;
extern hpcshape *last;
extern vector<hpcshape> shPlainWall3D, shWireframe3D, shWall3D, shMiniWall3D; extern vector<hpcshape> shPlainWall3D, shWireframe3D, shWall3D, shMiniWall3D;
#endif #endif
@ -4262,20 +4237,16 @@ void set_blizzard_frame(cell *c, int frameid);
struct floorshape { struct floorshape {
bool is_plain; bool is_plain;
int shapeid; int shapeid;
int id;
int pstrength; // pattern strength in 3D int pstrength; // pattern strength in 3D
int fstrength; // frame strength in 3D int fstrength; // frame strength in 3D
PPR prio; PPR prio;
vector<hpcshape> b, shadow, side[SIDEPARS], gpside[SIDEPARS][MAX_EDGE], levels[SIDEPARS], cone[2]; vector<hpcshape> b, shadow, side[SIDEPARS], gpside[SIDEPARS][MAX_EDGE], levels[SIDEPARS], cone[2];
basic_textureinfo tinf3;
floorshape() { prio = PPR::FLOOR; pstrength = fstrength = 10; } floorshape() { prio = PPR::FLOOR; pstrength = fstrength = 10; }
}; };
extern vector<struct plain_floorshape*> all_plain_floorshapes;
extern vector<struct escher_floorshape*> all_escher_floorshapes;
struct plain_floorshape : floorshape { struct plain_floorshape : floorshape {
ld rad0, rad1; ld rad0, rad1;
plain_floorshape() { is_plain = true; all_plain_floorshapes.push_back(this); }
void configure(ld r0, ld r1) { rad0 = r0; rad1 = r1; } void configure(ld r0, ld r1) { rad0 = r0; rad1 = r1; }
}; };
@ -4283,18 +4254,311 @@ struct plain_floorshape : floorshape {
struct escher_floorshape : floorshape { struct escher_floorshape : floorshape {
int shapeid0, shapeid1, noftype, shapeid2; int shapeid0, shapeid1, noftype, shapeid2;
ld scale; ld scale;
escher_floorshape(int s0, int s1, int noft=0, int s2=0) : shapeid0(s0), shapeid1(s1), noftype(noft), shapeid2(s2) { };
all_escher_floorshapes.push_back(this); scale = 1; is_plain = false; #endif
}
struct usershapelayer {
vector<hyperpoint> list;
bool sym;
int rots;
color_t color;
hyperpoint shift, spin;
ld zlevel;
int texture_offset;
PPR prio;
}; };
extern plain_floorshape static const int USERLAYERS = 32;
shFloor,
shMFloor, shMFloor2, shMFloor3, shMFloor4, shFullFloor,
shBigTriangle, shTriheptaFloor, shBigHepta;
extern escher_floorshape shDragonFloor, shPowerFloor, shRedRockFloor[3]; struct usershape { usershapelayer d[USERLAYERS]; };
#endif
extern array<map<int, usershape*>, mapeditor::USERSHAPEGROUPS> usershapes;
void initShape(int sg, int id);
extern int usershape_changes;
struct geometry_information {
/* basic geometry parameters */
// tessf: distance from heptagon center to another heptagon center
// hexf: distance from heptagon center to small heptagon vertex
// hcrossf: distance from heptagon center to big heptagon vertex
// crossf: distance from heptagon center to adjacent cell center (either hcrossf or tessf)
// hexhexdist: distance between adjacent hexagon vertices
// hexvdist: distance between hexagon vertex and hexagon center
// hepvdist: distance between heptagon vertex and hexagon center (either hcrossf or something else)
// rhexf: distance from heptagon center to heptagon vertex (either hexf or hcrossf)
ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf;
transmatrix heptmove[MAX_EDGE], hexmove[MAX_EDGE];
transmatrix invheptmove[MAX_EDGE], invhexmove[MAX_EDGE];
int base_distlimit;
/* shape parameters */
ld sword_size;
ld scalefactor, orbsize, floorrad0, floorrad1, zhexf;
ld corner_bonus;
ld hexshift;
ld asteroid_size[8];
ld wormscale;
ld tentacle_length;
/* 3D parameters */
ld INFDEEP, BOTTOM, HELLSPIKE, LAKE, WALL, FLOOR, STUFF,
SLEV[4], FLATEYE,
LEG0, LEG1, LEG, LEG3, GROIN, GROIN1, GHOST,
BODY, BODY1, BODY2, BODY3,
NECK1, NECK, NECK3, HEAD, HEAD1, HEAD2, HEAD3,
ALEG0, ALEG, ABODY, AHEAD, BIRD, LOWSKY, SKY, HIGH, HIGH2;
ld human_height, slev;
#if CAP_SHAPES
hpcshape
shSemiFloorSide[SIDEPARS],
shBFloor[2],
shWave[8][2],
shCircleFloor,
shBarrel,
shWall[2], shMineMark[2], shBigMineMark[2], shFan,
shZebra[5],
shSwitchDisk,
shTower[11],
shEmeraldFloor[6],
shSemiFeatherFloor[2],
shSemiFloor[2], shSemiBFloor[2], shSemiFloorShadow,
shMercuryBridge[2],
shTriheptaSpecial[14],
shCross, shGiantStar[2], shLake, shMirror,
shHalfFloor[6], shHalfMirror[3],
shGem[2], shStar, shDisk, shDiskT, shDiskS, shDiskM, shDiskSq, shRing,
shTinyBird, shTinyShark,
shEgg,
shSpikedRing, shTargetRing, shSawRing, shGearRing, shPeaceRing, shHeptaRing,
shSpearRing, shLoveRing,
shDaisy, shTriangle, shNecro, shStatue, shKey, shWindArrow,
shGun,
shFigurine, shTreat,
shElementalShard,
// shBranch,
shIBranch, shTentacle, shTentacleX, shILeaf[2],
shMovestar,
shWolf, shYeti, shDemon, shGDemon, shEagle, shGargoyleWings, shGargoyleBody,
shFoxTail1, shFoxTail2,
shDogBody, shDogHead, shDogFrontLeg, shDogRearLeg, shDogFrontPaw, shDogRearPaw,
shDogTorso,
shHawk,
shCatBody, shCatLegs, shCatHead, shFamiliarHead, shFamiliarEye,
shWolf1, shWolf2, shWolf3,
shRatEye1, shRatEye2, shRatEye3,
shDogStripes,
shPBody, shPSword, shPKnife,
shFerocityM, shFerocityF,
shHumanFoot, shHumanLeg, shHumanGroin, shHumanNeck, shSkeletalFoot, shYetiFoot,
shMagicSword, shMagicShovel, shSeaTentacle, shKrakenHead, shKrakenEye, shKrakenEye2,
shArrow,
shPHead, shPFace, shGolemhead, shHood, shArmor,
shAztecHead, shAztecCap,
shSabre, shTurban1, shTurban2, shVikingHelmet, shRaiderHelmet, shRaiderArmor, shRaiderBody, shRaiderShirt,
shWestHat1, shWestHat2, shGunInHand,
shKnightArmor, shKnightCloak, shWightCloak,
shGhost, shEyes, shSlime, shJelly, shJoint, shWormHead, shTentHead, shShark, shWormSegment, shSmallWormSegment, shWormTail, shSmallWormTail,
shSlimeEyes, shDragonEyes, shWormEyes, shGhostEyes,
shMiniGhost, shMiniEyes,
shHedgehogBlade, shHedgehogBladePlayer,
shWolfBody, shWolfHead, shWolfLegs, shWolfEyes,
shWolfFrontLeg, shWolfRearLeg, shWolfFrontPaw, shWolfRearPaw,
shFemaleBody, shFemaleHair, shFemaleDress, shWitchDress,
shWitchHair, shBeautyHair, shFlowerHair, shFlowerHand, shSuspenders, shTrophy,
shBugBody, shBugArmor, shBugLeg, shBugAntenna,
shPickAxe, shPike, shFlailBall, shFlailTrunk, shFlailChain, shHammerHead,
shBook, shBookCover, shGrail,
shBoatOuter, shBoatInner, shCompass1, shCompass2, shCompass3,
shKnife, shTongue, shFlailMissile, shTrapArrow,
shPirateHook, shPirateHood, shEyepatch, shPirateX,
// shScratch,
shHeptaMarker, shSnowball, shSun, shNightStar,
shSkeletonBody, shSkull, shSkullEyes, shFatBody, shWaterElemental,
shPalaceGate, shFishTail,
shMouse, shMouseLegs, shMouseEyes,
shPrincessDress, shPrinceDress,
shWizardCape1, shWizardCape2,
shBigCarpet1, shBigCarpet2, shBigCarpet3,
shGoatHead, shRose, shRoseItem, shThorns,
shRatHead, shRatTail, shRatEyes, shRatCape1, shRatCape2,
shWizardHat1, shWizardHat2,
shTortoise[13][6],
shDragonLegs, shDragonTail, shDragonHead, shDragonSegment, shDragonNostril,
shDragonWings,
shSolidBranch, shWeakBranch, shBead0, shBead1,
shBatWings, shBatBody, shBatMouth, shBatFang, shBatEye,
shParticle[16], shAsteroid[8],
shReptile[5][4],
shReptileBody, shReptileHead, shReptileFrontFoot, shReptileRearFoot,
shReptileFrontLeg, shReptileRearLeg, shReptileTail, shReptileEye,
shTrylobite, shTrylobiteHead, shTrylobiteBody,
shTrylobiteFrontLeg, shTrylobiteRearLeg, shTrylobiteFrontClaw, shTrylobiteRearClaw,
shBullBody, shBullHead, shBullHorn, shBullRearHoof, shBullFrontHoof,
shButterflyBody, shButterflyWing, shGadflyBody, shGadflyWing, shGadflyEye,
shTerraArmor1, shTerraArmor2, shTerraArmor3, shTerraHead, shTerraFace,
shJiangShi, shJiangShiDress, shJiangShiCap1, shJiangShiCap2,
shAsymmetric,
shPBodyOnly, shPBodyArm, shPBodyHand, shPHeadOnly,
shAnimatedEagle[30], shAnimatedTinyEagle[30], shAnimatedGadfly[30], shAnimatedHawk[30], shAnimatedButterfly[30],
shAnimatedGargoyle[30], shAnimatedGargoyle2[30], shAnimatedBat[30], shAnimatedBat2[30],
shDodeca;
vector<hpcshape> shPlainWall3D, shWireframe3D, shWall3D, shMiniWall3D;
vector<plain_floorshape*> all_plain_floorshapes;
vector<escher_floorshape*> all_escher_floorshapes;
plain_floorshape
shFloor,
shMFloor, shMFloor2, shMFloor3, shMFloor4, shFullFloor,
shBigTriangle, shTriheptaFloor, shBigHepta;
escher_floorshape
shStarFloor, shCloudFloor, shCrossFloor, shChargedFloor,
shSStarFloor, shOverFloor, shTriFloor, shFeatherFloor,
shBarrowFloor, shNewFloor, shTrollFloor, shButterflyFloor,
shLavaFloor, shLavaSeabed, shSeabed, shCloudSeabed,
shCaveSeabed, shPalaceFloor, shDemonFloor, shCaveFloor,
shDesertFloor, shPowerFloor, shRoseFloor, shSwitchFloor,
shTurtleFloor, shRedRockFloor[3], shDragonFloor;
ld dlow_table[SIDEPARS], dhi_table[SIDEPARS], dfloor_table[SIDEPARS];
int prehpc;
vector<hyperpoint> hpc;
bool first;
bool validsidepar[SIDEPARS];
vector<glvertex> ourshape;
#endif
hpcshape shFullCross[2];
hpcshape *last;
int SD3, SD6, SD7, S12, S14, S21, S28, S42, S36, S84;
vector<array<int, 3>> symmetriesAt;
#ifndef SCALETUNER
static constexpr
#endif
double bscale7 = 1, brot7 = 0, bscale6 = 1, brot6 = 0;
vector<hpcshape*> allshapes;
transmatrix shadowmulmatrix;
map<usershapelayer*, hpcshape> ushr;
void prepare_basics();
void prepare_compute3();
void prepare_shapes();
void prepare_usershapes();
void hpcpush(hyperpoint h);
void chasmifyPoly(double fac, double fac2, int k);
void shift(hpcshape& sh, double dx, double dy, double dz);
void initPolyForGL();
void extra_vertices();
transmatrix ddi(int a, ld x);
void drawTentacle(hpcshape &h, ld rad, ld var, ld divby);
hyperpoint hpxyzsc(double x, double y, double z);
hyperpoint turtlevertex(int u, double x, double y, double z);
void bshape(hpcshape& sh, PPR prio);
void finishshape();
void bshape(hpcshape& sh, PPR prio, double shzoom, int shapeid, double bonus = 0, flagtype flags = 0);
void copyshape(hpcshape& sh, hpcshape& orig, PPR prio);
void zoomShape(hpcshape& old, hpcshape& newsh, double factor, PPR prio);
void pushShape(usershapelayer& ds);
void make_sidewalls();
void procedural_shapes();
void make_wall(int id, vector<hyperpoint> vertices, bool force_triangles = false);
void create_wall3d();
void configure_floorshapes();
void init_floorshapes();
void bshape2(hpcshape& sh, PPR prio, int shapeid, struct matrixlist& m);
void bshape_regular(floorshape &fsh, int id, int sides, int shift, ld size);
void generate_floorshapes_for(int id, cell *c, int siid, int sidir);
void generate_floorshapes();
void make_floor_textures_here();
vector<hyperpoint> get_shape(hpcshape sh);
void add_cone(ld z0, const vector<hyperpoint>& vh, ld z1);
void add_prism_sync(ld z0, vector<hyperpoint> vh0, ld z1, vector<hyperpoint> vh1);
void add_prism(ld z0, vector<hyperpoint> vh0, ld z1, vector<hyperpoint> vh1);
void shift_last(ld z);
void shift_shape(hpcshape& sh, ld z);
void shift_shape_orthogonally(hpcshape& sh, ld z);
void add_texture(hpcshape& sh);
void make_ha_3d(hpcshape& sh, bool isarmor, ld scale);
void make_humanoid_3d(hpcshape& sh);
void addtri(array<hyperpoint, 3> hs, int kind);
void make_armor_3d(hpcshape& sh, int kind = 1);
void make_foot_3d(hpcshape& sh);
void make_head_only();
void make_head_3d(hpcshape& sh);
void make_paw_3d(hpcshape& sh, hpcshape& legsh);
void make_abody_3d(hpcshape& sh, ld tail);
void make_ahead_3d(hpcshape& sh);
void make_skeletal(hpcshape& sh, ld push = 0);
void make_revolution(hpcshape& sh, int mx = 180, ld push = 0);
void make_revolution_cut(hpcshape &sh, int each = 180, ld push = 0, ld width = 99);
void clone_shape(hpcshape& sh, hpcshape& target);
void animate_bird(hpcshape& orig, hpcshape animated[30], ld body);
void slimetriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev);
void balltriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev);
void make_ball(hpcshape& sh, ld rad, int lev);
void adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye, ld shift_head, int q, ld zoom=1);
void shift_last_straight(ld z);
void queueball(const transmatrix& V, ld rad, color_t col, eItem what);
void make_shadow(hpcshape& sh);
void make_3d_models();
/* Goldberg parameters */
#if CAP_GP
struct gpdata_t {
transmatrix Tf[MAX_EDGE][32][32][6];
transmatrix corners;
ld alpha;
int area;
};
shared_ptr<gpdata_t> gpdata;
#endif
int state;
int usershape_state;
geometry_information() { last = NULL; state = usershape_state = 0; gpdata = NULL; }
void require_basics() { if(state & 1) return; state |= 1; prepare_basics(); }
void require_shapes() { if(state & 2) return; state |= 2; prepare_shapes(); }
void require_usershapes() { if(usershape_state == usershape_changes) return; usershape_state = usershape_state; prepare_usershapes(); }
};
void make_floor_textures();
extern map<string, geometry_information> cgis;
extern geometry_information *cgip;
void check_cgi();
#define cgi (*cgip)
#if ISMOBILE #if ISMOBILE
bool buttonclicked; bool buttonclicked;
@ -4335,7 +4599,6 @@ extern int timetowait;
extern vector<pair<cell*, int> > airmap; extern vector<pair<cell*, int> > airmap;
extern void compute_graphical_distance(); extern void compute_graphical_distance();
extern ld scalef;
struct help_extension { struct help_extension {
char key; char key;
@ -4354,7 +4617,6 @@ namespace gamestack {
} }
namespace geom3 { namespace geom3 {
extern ld BODY;
extern ld depth, camera, wall_height, creature_scale, height_width; extern ld depth, camera, wall_height, creature_scale, height_width;
void switch_always3(); void switch_always3();
void switch_fpp(); void switch_fpp();
@ -4368,23 +4630,14 @@ ld frac(ld x);
extern color_t poly_outline; extern color_t poly_outline;
#if CAP_SHAPES
extern hpcshape shDisk, shTriangle, shHeptaMarker, shSnowball, shDiskT, shDiskS, shDiskSq, shDiskM, shTinyBird, shTinyShark, shAsymmetric;
#endif
extern std::mt19937 hrngen; extern std::mt19937 hrngen;
bool anglestraight(cell *c, int d1, int d2); bool anglestraight(cell *c, int d1, int d2);
hyperpoint randomPointIn(int t); hyperpoint randomPointIn(int t);
void buildpolys();
bool compute_relamatrix(cell *src, cell *tgt, int direction_hint, transmatrix& T); bool compute_relamatrix(cell *src, cell *tgt, int direction_hint, transmatrix& T);
extern bool need_reset_geometry;
extern ld hexshift;
extern bool noshadow, bright, nohelp, dont_face_pc; extern bool noshadow, bright, nohelp, dont_face_pc;
extern void switchHardcore(); extern void switchHardcore();
@ -4403,10 +4656,10 @@ namespace ors {
bool saved_tortoise_on(cell *c); bool saved_tortoise_on(cell *c);
#define RING(i) for(double i=0; i<=S84+1e-6; i+=SD3 * pow(.5, vid.linequality)) #define RING(i) for(double i=0; i<=cgi.S84+1e-6; i+=SD3 * pow(.5, vid.linequality))
#define REVRING(i) for(double i=S84; i>=-1e-6; i-=SD3 * pow(.5, vid.linequality)) #define REVRING(i) for(double i=cgi.S84; i>=-1e-6; i-=SD3 * pow(.5, vid.linequality))
#define PRING(i) for(double i=0; i<=S84+1e-6; i+= pow(.5, vid.linequality)) #define PRING(i) for(double i=0; i<=cgi.S84+1e-6; i+= pow(.5, vid.linequality))
#define REVPRING(i) for(double i=S84; i>=-1e-6; i-=pow(.5, vid.linequality)) #define REVPRING(i) for(double i=cgi.S84; i>=-1e-6; i-=pow(.5, vid.linequality))
#if CAP_BT #if CAP_BT
namespace binary { namespace binary {
@ -4794,6 +5047,7 @@ extern void calcTidalPhase();
void curvepoint(const hyperpoint& H1); void curvepoint(const hyperpoint& H1);
dqi_poly& queuecurve(color_t linecol, color_t fillcol, PPR prio); dqi_poly& queuecurve(color_t linecol, color_t fillcol, PPR prio);
void queueball(const transmatrix& V, ld rad, color_t col, eItem what);
ld cos_auto(ld x); ld cos_auto(ld x);
ld sin_auto(ld x); ld sin_auto(ld x);
@ -5028,8 +5282,6 @@ struct bandfixer {
bandfixer(transmatrix& T) : bw(band_shift, band_shift) { fix_the_band(T); } bandfixer(transmatrix& T) : bw(band_shift, band_shift) { fix_the_band(T); }
}; };
inline void delayed_geo_reset() { need_reset_geometry = true; }
extern unordered_map<string, ld&> params; extern unordered_map<string, ld&> params;
namespace dq { namespace dq {
@ -5129,5 +5381,31 @@ inline void reset_projection() { new_projection_needed = true; }
extern ld ptick(int period, ld phase = 0); extern ld ptick(int period, ld phase = 0);
void gridline(const transmatrix& V1, const hyperpoint h1, const transmatrix& V2, const hyperpoint h2, color_t col, int prec); void gridline(const transmatrix& V1, const hyperpoint h1, const transmatrix& V2, const hyperpoint h2, color_t col, int prec);
void gridline(const transmatrix& V, const hyperpoint h1, const hyperpoint h2, color_t col, int prec); void gridline(const transmatrix& V, const hyperpoint h1, const hyperpoint h2, color_t col, int prec);
static const int POLY_DRAWLINES = 1; // draw the lines
static const int POLY_DRAWAREA = 2; // draw the area
static const int POLY_INVERSE = 4; // draw the inverse -- useful in stereographic projection
static const int POLY_ISSIDE = 8; // never draw in inverse
static const int POLY_BEHIND = 16; // there are points behind the camera
static const int POLY_TOOLARGE = 32; // some coordinates are too large -- best not to draw to avoid glitches
static const int POLY_INFRONT = 64; // on the sphere (orthogonal projection), do not draw without any points in front
static const int POLY_HASWALLS = 128; // floor shapes which have their sidewalls
static const int POLY_PLAIN = 256; // plain floors
static const int POLY_FULL = 512; // full floors
static const int POLY_HASSHADOW = 1024; // floor shapes which have their shadows, or can use shFloorShadow
static const int POLY_GP = 2048; // Goldberg shapes
static const int POLY_VCONVEX = 4096; // Convex shape (vertex)
static const int POLY_CCONVEX = 8192; // Convex shape (central)
static const int POLY_CENTERIN = 16384; // new system of side checking
static const int POLY_FORCEWIDE = (1<<15); // force wide lines
static const int POLY_NOTINFRONT = (1<<16); // points not in front
static const int POLY_NIF_ERROR = (1<<17); // points moved to the outline cross the image, disable
static const int POLY_BADCENTERIN = (1<<18); // new system of side checking
static const int POLY_PRECISE_WIDE = (1<<19); // precise width calculation
static const int POLY_FORCE_INVERTED = (1<<20); // force inverted
static const int POLY_ALWAYS_IN = (1<<21); // always draw this
static const int POLY_TRIANGLES = (1<<22); // made of TRIANGLES, not TRIANGLE_FAN
static const int POLY_INTENSE = (1<<23); // extra intense colors
} }

View File

@ -777,4 +777,21 @@ hyperpoint orthogonal_of_C0(hyperpoint h0, hyperpoint h1, hyperpoint h2) {
return normalize(h); return normalize(h);
} }
hyperpoint zshift(hyperpoint x, ld z) {
if(DIM == 3 && WDIM == 2) return orthogonal_move(x, z);
else return mscale(x, z);
}
hyperpoint hpxd(ld d, ld x, ld y, ld z) {
hyperpoint H = hpxyz(d*x, d*y, z);
H = mid(H, H);
return H;
}
ld signum(ld x) { return x<0?-1:x>0?1:0; }
bool asign(ld y1, ld y2) { return signum(y1) != signum(y2); }
ld xcross(ld x1, ld y1, ld x2, ld y2) { return x1 + (x2 - x1) * y1 / (y1 - y2); }
} }

View File

@ -672,7 +672,7 @@ bool outofmap(hyperpoint h) {
if(GDIM == 3) if(GDIM == 3)
return false; return false;
else if(euclid) else if(euclid)
return h[2] < .5; // false; // h[0] * h[0] + h[1] * h[1] > 15 * crossf; return h[2] < .5; // false; // h[0] * h[0] + h[1] * h[1] > 15 * cgi.crossf;
else if(sphere) else if(sphere)
return h[2] < .1 && h[2] > -.1 && h[1] > -.1 && h[1] < .1 && h[0] > -.1 && h[0] < .1; return h[2] < .1 && h[2] > -.1 && h[1] > -.1 && h[1] < .1 && h[0] > -.1 && h[0] < .1;
else else
@ -755,10 +755,9 @@ bool confusingGeometry() {
} }
ld master_to_c7_angle() { ld master_to_c7_angle() {
ld alpha = 0;
#if CAP_GP #if CAP_GP
auto alpha = gp::alpha; if(cgi.gpdata) alpha = cgi.gpdata->alpha;
#else
auto alpha = 0;
#endif #endif
return (!BITRUNCATED && !binarytiling && !archimedean) ? M_PI + alpha : 0; return (!BITRUNCATED && !binarytiling && !archimedean) ? M_PI + alpha : 0;
} }
@ -825,11 +824,11 @@ bool in_smart_range(const transmatrix& T) {
if(DIM == 3) { if(DIM == 3) {
if(-h1[2] + 2 * dz < conformal::clip_min || -h1[2] - 2 * dz > conformal::clip_max) return false; if(-h1[2] + 2 * dz < conformal::clip_min || -h1[2] - 2 * dz > conformal::clip_max) return false;
sort(dh, dh+DIM); sort(dh, dh+DIM);
ld scale = sqrt(dh[1] * dh[2]) * scalefactor * hcrossf7; ld scale = sqrt(dh[1] * dh[2]) * cgi.scalefactor * hcrossf7;
if(scale <= (WDIM == 2 ? vid.smart_range_detail : vid.smart_range_detail_3)) return false; if(scale <= (WDIM == 2 ? vid.smart_range_detail : vid.smart_range_detail_3)) return false;
} }
else { else {
ld scale = sqrt(dh[0] * dh[1]) * scalefactor * hcrossf7; ld scale = sqrt(dh[0] * dh[1]) * cgi.scalefactor * hcrossf7;
if(scale <= vid.smart_range_detail) return false; if(scale <= vid.smart_range_detail) return false;
} }
@ -852,7 +851,7 @@ void drawrec(cell *c, const transmatrix& V) {
if(!c2) continue; if(!c2) continue;
if(c2->move(0) != c) continue; if(c2->move(0) != c) continue;
if(c2 == c2->master->c7) continue; if(c2 == c2->master->c7) continue;
transmatrix V1 = V * ddspin(c, i) * xpush(crossf) * iddspin(c2, 0) * spin(M_PI); transmatrix V1 = V * ddspin(c, i) * xpush(cgi.crossf) * iddspin(c2, 0) * spin(M_PI);
drawrec(c2, V1); drawrec(c2, V1);
} }
} */ } */
@ -861,7 +860,7 @@ void drawrec(cell *c, const transmatrix& V) {
bool drawrec(cell *c, const transmatrix& V, gp::loc at, int dir, int maindir) { bool drawrec(cell *c, const transmatrix& V, gp::loc at, int dir, int maindir) {
bool res = false; bool res = false;
transmatrix V1 = V * Tf[draw_li.last_dir][at.first&31][at.second&31][fixg6(dir)]; transmatrix V1 = V * cgi.gpdata->Tf[draw_li.last_dir][at.first&31][at.second&31][fixg6(dir)];
if(do_draw(c, V1)) { if(do_draw(c, V1)) {
/* auto li = get_local_info(c); /* auto li = get_local_info(c);
if(fix6(dir) != fix6(li.total_dir)) printf("totaldir %d/%d\n", dir, li.total_dir); if(fix6(dir) != fix6(li.total_dir)) printf("totaldir %d/%d\n", dir, li.total_dir);
@ -985,7 +984,7 @@ void hrmap_standard::draw() {
int ds = hs.at->c.fix(hs.spin + d); int ds = hs.at->c.fix(hs.spin + d);
// createMov(c, ds); // createMov(c, ds);
if(c->move(ds) && c->c.spin(ds) == 0) { if(c->move(ds) && c->c.spin(ds) == 0) {
transmatrix V2 = V1 * hexmove[d]; transmatrix V2 = V1 * cgi.hexmove[d];
if(do_draw(c->move(ds), V2)) if(do_draw(c->move(ds), V2))
draw = true, draw = true,
drawcell(c->move(ds), V2, 0, hs.mirrored ^ c->c.mirror(ds)); drawcell(c->move(ds), V2, 0, hs.mirrored ^ c->c.mirror(ds));
@ -999,7 +998,7 @@ void hrmap_standard::draw() {
hstate s2 = transition(s, d); hstate s2 = transition(s, d);
if(s2 == hsError) continue; if(s2 == hsError) continue;
heptspin hs2 = hs + d + wstep; heptspin hs2 = hs + d + wstep;
transmatrix Vd = V * heptmove[d]; transmatrix Vd = V * cgi.heptmove[d];
bandfixer bf(Vd); bandfixer bf(Vd);
drawn_cells.emplace_back(hs2, s2, Vd, band_shift); drawn_cells.emplace_back(hs2, s2, Vd, band_shift);
} }
@ -1013,22 +1012,22 @@ transmatrix eumove(ld x, ld y) {
Mat[DIM][DIM] = 1; Mat[DIM][DIM] = 1;
if(a4) { if(a4) {
Mat[0][DIM] += x * crossf; Mat[0][DIM] += x * cgi.crossf;
Mat[1][DIM] += y * crossf; Mat[1][DIM] += y * cgi.crossf;
} }
else { else {
Mat[0][DIM] += (x + y * .5) * crossf; Mat[0][DIM] += (x + y * .5) * cgi.crossf;
// Mat[DIM][0] += (x + y * .5) * crossf; // Mat[DIM][0] += (x + y * .5) * cgi.crossf;
Mat[1][DIM] += y * q3 /2 * crossf; Mat[1][DIM] += y * q3 /2 * cgi.crossf;
// Mat[DIM][1] += y * q3 /2 * crossf; // Mat[DIM][1] += y * q3 /2 * cgi.crossf;
} }
ld v = a4 ? 1 : q3; ld v = a4 ? 1 : q3;
while(Mat[0][DIM] <= -16384 * crossf) Mat[0][DIM] += 32768 * crossf; while(Mat[0][DIM] <= -16384 * cgi.crossf) Mat[0][DIM] += 32768 * cgi.crossf;
while(Mat[0][DIM] >= 16384 * crossf) Mat[0][DIM] -= 32768 * crossf; while(Mat[0][DIM] >= 16384 * cgi.crossf) Mat[0][DIM] -= 32768 * cgi.crossf;
while(Mat[1][DIM] <= -16384 * v * crossf) Mat[1][DIM] += 32768 * v * crossf; while(Mat[1][DIM] <= -16384 * v * cgi.crossf) Mat[1][DIM] += 32768 * v * cgi.crossf;
while(Mat[1][DIM] >= 16384 * v * crossf) Mat[1][DIM] -= 32768 * v * crossf; while(Mat[1][DIM] >= 16384 * v * cgi.crossf) Mat[1][DIM] -= 32768 * v * cgi.crossf;
return Mat; return Mat;
} }
@ -1118,7 +1117,7 @@ void centerpc(ld aspd) {
transmatrix T = shmup::pc[id]->at; transmatrix T = shmup::pc[id]->at;
if(WDIM == 2 && !masterless) T = master_relative(shmup::pc[id]->base) * T; if(WDIM == 2 && !masterless) T = master_relative(shmup::pc[id]->base) * T;
int sl = snakelevel(cwt.at); int sl = snakelevel(cwt.at);
if(sl) T = T * zpush(geom3::SLEV[sl] - geom3::FLOOR); if(sl) T = T * zpush(cgi.SLEV[sl] - cgi.FLOOR);
View = inverse(T); View = inverse(T);
if(WDIM == 2) View = cspin(0, 1, M_PI) * cspin(2, 1, M_PI/2 + shmup::playerturny[id]) * spin(-M_PI/2) * View; if(WDIM == 2) View = cspin(0, 1, M_PI) * cspin(2, 1, M_PI/2 + shmup::playerturny[id]) * spin(-M_PI/2) * View;
return; return;
@ -1135,7 +1134,7 @@ void centerpc(ld aspd) {
#if MAXMDIM >= 4 #if MAXMDIM >= 4
if(GDIM == 3 && WDIM == 2) { if(GDIM == 3 && WDIM == 2) {
int sl = snakelevel(cwt.at); int sl = snakelevel(cwt.at);
if(sl) T = T * zpush(geom3::SLEV[sl] - geom3::FLOOR); if(sl) T = T * zpush(cgi.SLEV[sl] - cgi.FLOOR);
} }
#endif #endif
hyperpoint H = inverse(actual_view_transform) * tC0(T); hyperpoint H = inverse(actual_view_transform) * tC0(T);
@ -1223,7 +1222,7 @@ void optimizeview() {
for(int i=-1; i<S7; i++) { for(int i=-1; i<S7; i++) {
ld trot = -i * M_PI * 2 / (S7+.0); ld trot = -i * M_PI * 2 / (S7+.0);
transmatrix T = i < 0 ? Id : spin(trot) * xpush(tessf) * pispin; transmatrix T = i < 0 ? Id : spin(trot) * xpush(cgi.tessf) * pispin;
hyperpoint H = View * tC0(T); hyperpoint H = View * tC0(T);
if(H[DIM] < best) best = H[DIM], turn = i, TB = T; if(H[DIM] < best) best = H[DIM], turn = i, TB = T;
} }
@ -1308,14 +1307,14 @@ transmatrix atscreenpos(ld x, ld y, ld size) {
if(pmodel == mdFlatten) { if(pmodel == mdFlatten) {
V[0][3] += (x - current_display->xcenter); V[0][3] += (x - current_display->xcenter);
V[1][3] += (y - current_display->ycenter); V[1][3] += (y - current_display->ycenter);
V[0][0] = size * 2 * hcrossf / crossf; V[0][0] = size * 2 * cgi.hcrossf / cgi.crossf;
V[1][1] = size * 2 * hcrossf / crossf; V[1][1] = size * 2 * cgi.hcrossf / cgi.crossf;
} }
else { else {
V[0][2] += (x - current_display->xcenter); V[0][2] += (x - current_display->xcenter);
V[1][2] += (y - current_display->ycenter); V[1][2] += (y - current_display->ycenter);
V[0][0] = size * 2 * hcrossf / crossf; V[0][0] = size * 2 * cgi.hcrossf / cgi.crossf;
V[1][1] = size * 2 * hcrossf / crossf; V[1][1] = size * 2 * cgi.hcrossf / cgi.crossf;
V[2][2] = current_display->scrdist; V[2][2] = current_display->scrdist;
} }
@ -1718,7 +1717,7 @@ bool do_draw(cell *c, const transmatrix& T) {
} }
else { else {
ld dist = hdist0(tC0(T)); ld dist = hdist0(tC0(T));
if(dist > sightranges[geometry] + (vid.sloppy_3d ? 0 : corner_bonus)) return false; if(dist > sightranges[geometry] + (vid.sloppy_3d ? 0 : cgi.corner_bonus)) return false;
if(dist <= extra_generation_distance && !limited_generation(c)) return false; if(dist <= extra_generation_distance && !limited_generation(c)) return false;
} }
return true; return true;

View File

@ -1,5 +1,7 @@
namespace hr { namespace irr { namespace hr { namespace irr {
int irrid;
#if CAP_IRR #if CAP_IRR
ld density = 2; ld density = 2;
ld quality = .2; ld quality = .2;
@ -487,12 +489,12 @@ bool step(int delta) {
for(auto& s: cells) { for(auto& s: cells) {
int d = -1; int d = -1;
ld dist = hcrossf / 2; ld dist = cgi.hcrossf / 2;
ld dists[8]; ld dists[8];
for(int i=0; i<S7; i++) { for(int i=0; i<S7; i++) {
dists[i] = hdist(s.p, xspinpush0(hexshift - i * ALPHA, -hcrossf)); dists[i] = hdist(s.p, xspinpush0(cgi.hexshift - i * ALPHA, -cgi.hcrossf));
if(dists[i] < dist) if(dists[i] < dist)
d = i, dist = dists[i]; d = i, dist = dists[i];
} }
if(d != -1 && dists[(d+1) % S7] > dists[(d+S7-1) % S7]) if(d != -1 && dists[(d+1) % S7] > dists[(d+S7-1) % S7])
d = (d + S7 - 1) % S7; d = (d + S7 - 1) % S7;
@ -512,13 +514,13 @@ bool step(int delta) {
void compute_geometry() { void compute_geometry() {
if(IRREGULAR) { if(IRREGULAR) {
ld scale = sqrt(isize(cells_of_heptagon) * 1. / isize(cells)); ld scale = sqrt(isize(cells_of_heptagon) * 1. / isize(cells));
crossf *= scale; cgi.crossf *= scale;
hepvdist *= scale; cgi.hepvdist *= scale;
rhexf *= scale; cgi.rhexf *= scale;
hexhexdist *= scale; cgi.hexhexdist *= scale;
hexvdist *= scale; cgi.hexvdist *= scale;
base_distlimit = (base_distlimit + log(scale) / log(2.618)) / scale; cgi.base_distlimit = (cgi.base_distlimit + log(scale) / log(2.618)) / scale;
if(base_distlimit > 25) base_distlimit = 25; if(cgi.base_distlimit > 25) cgi.base_distlimit = 25;
} }
} }
@ -806,7 +808,7 @@ void start_game_on_created_map() {
stop_game(); stop_game();
geometry = orig_geometry; geometry = orig_geometry;
variation = eVariation::irregular; variation = eVariation::irregular;
need_reset_geometry = true; irrid++;
gridmaking = false; gridmaking = false;
start_game(); start_game();
} }
@ -874,7 +876,6 @@ void cancel_map_creation() {
gridmaking = false; gridmaking = false;
stop_game(); stop_game();
geometry = orig_geometry; geometry = orig_geometry;
need_reset_geometry = true;
start_game(); start_game();
} }
@ -986,7 +987,6 @@ void visual_creator() {
} }
variation = eVariation::pure; variation = eVariation::pure;
need_reset_geometry = true;
start_game(); start_game();
if(base) delete base; if(base) delete base;
base = currentmap; base = currentmap;

View File

@ -322,7 +322,7 @@ namespace mapstream {
#endif #endif
} }
need_reset_geometry = true; usershape_changes++;
initcells(); initcells();
if(shmup::on) shmup::init(); if(shmup::on) shmup::init();
@ -496,9 +496,9 @@ namespace mapstream {
} }
cellbyid.clear(); cellbyid.clear();
buildpolys(); check_cgi();
cgi.require_basics();
bfs(); bfs();
restartGraph();
return true; return true;
} }
@ -1056,7 +1056,7 @@ namespace mapeditor {
dsCur->list.clear(); dsCur->list.clear();
dsCur->sym = d==2; dsCur->sym = d==2;
for(int i=sh.s; i < sh.s + (sh.e-sh.s)/d; i++) for(int i=sh.s; i < sh.s + (sh.e-sh.s)/d; i++)
dsCur->list.push_back(hpc[i]); dsCur->list.push_back(cgi.hpc[i]);
} }
#endif #endif
@ -1121,25 +1121,25 @@ namespace mapeditor {
if(front_config == eFront::equidistants) for(int i=0; i<4; i+=2) { if(front_config == eFront::equidistants) for(int i=0; i<4; i+=2) {
for(int u=2; u<=20; u++) { for(int u=2; u<=20; u++) {
PRING(d) { PRING(d) {
curvepoint(d2 * xspinpush(M_PI*d/S42, u/20.) * zpush(front_edit) * C0); curvepoint(d2 * xspinpush(M_PI*d/cgi.S42, u/20.) * zpush(front_edit) * C0);
} }
queuecurve(cols[i + (u%5 != 0)], 0, i < 2 ? PPR::LINE : PPR::SUPERLINE); queuecurve(cols[i + (u%5 != 0)], 0, i < 2 ? PPR::LINE : PPR::SUPERLINE);
} }
for(int d=0; d<S84; d++) { for(int d=0; d<cgi.S84; d++) {
for(int u=0; u<=20; u++) curvepoint(d2 * xspinpush(M_PI*d/S42, u/20.) * zpush(front_edit) * C0); for(int u=0; u<=20; u++) curvepoint(d2 * xspinpush(M_PI*d/cgi.S42, u/20.) * zpush(front_edit) * C0);
queuecurve(cols[i + (d % (S84/drawcell->type) != 0)], 0, i < 2 ? PPR::LINE : PPR::SUPERLINE); queuecurve(cols[i + (d % (cgi.S84/drawcell->type) != 0)], 0, i < 2 ? PPR::LINE : PPR::SUPERLINE);
} }
} }
return; return;
} }
for(int d=0; d<S84; d++) { for(int d=0; d<cgi.S84; d++) {
unsigned col = (d % (S84/drawcell->type) == 0) ? gridcolor : lightgrid; unsigned col = (d % (cgi.S84/drawcell->type) == 0) ? gridcolor : lightgrid;
queueline(d2 * C0, d2 * xspinpush0(M_PI*d/S42, 1), col, 4 + vid.linequality); queueline(d2 * C0, d2 * xspinpush0(M_PI*d/cgi.S42, 1), col, 4 + vid.linequality);
} }
for(int u=2; u<=20; u++) { for(int u=2; u<=20; u++) {
PRING(d) { PRING(d) {
curvepoint(d2 * xspinpush0(M_PI*d/S42, u/20.)); curvepoint(d2 * xspinpush0(M_PI*d/cgi.S42, u/20.));
} }
queuecurve((u%5==0) ? gridcolor : lightgrid, 0, PPR::LINE); queuecurve((u%5==0) ? gridcolor : lightgrid, 0, PPR::LINE);
} }
@ -1174,8 +1174,8 @@ namespace mapeditor {
ld compute_area(hpcshape& sh) { ld compute_area(hpcshape& sh) {
ld area = 0; ld area = 0;
for(int i=sh.s; i<sh.e-1; i++) { for(int i=sh.s; i<sh.e-1; i++) {
hyperpoint h1 = hpc[i]; hyperpoint h1 = cgi.hpc[i];
hyperpoint h2 = hpc[i+1]; hyperpoint h2 = cgi.hpc[i+1];
if(euclid) if(euclid)
area += (h2[1] + h1[1]) * (h2[0] - h1[0]) / 2; area += (h2[1] + h1[1]) * (h2[0] - h1[0]) / 2;
else { else {
@ -1379,7 +1379,8 @@ namespace mapeditor {
} }
if(us) { if(us) {
auto& sh = us->d[dslayer].sh; cgi.require_usershapes();
auto& sh = cgi.ushr[&us->d[dslayer]];
if(sh.e >= sh.s + 3) if(sh.e >= sh.s + 3)
displayButton(vid.xres-8, vid.yres-8-fs*8, XLAT("area: %1", area_in_pi ? fts(compute_area(sh) / M_PI, 4) + "π" : fts(compute_area(sh), 4)), 'w', 16); displayButton(vid.xres-8, vid.yres-8-fs*8, XLAT("area: %1", area_in_pi ? fts(compute_area(sh) / M_PI, 4) + "π" : fts(compute_area(sh), 4)), 'w', 16);
} }
@ -1393,8 +1394,6 @@ namespace mapeditor {
#endif #endif
} }
bool rebuildPolys = false;
#if CAP_POLY #if CAP_POLY
void loadShapes(int sg, int id) { void loadShapes(int sg, int id) {
delete usershapes[sg][id]; delete usershapes[sg][id];
@ -1437,7 +1436,7 @@ namespace mapeditor {
dsCur->rots = 1; dsCur->rots = 1;
dsCur->zlevel = 0; dsCur->zlevel = 0;
for(auto& v: symmetriesAt) for(auto& v: cgi.symmetriesAt)
if(v[0] == ptd.offset) { if(v[0] == ptd.offset) {
dsCur->rots = v[1]; dsCur->rots = v[1];
dsCur->sym = v[2] == 2; dsCur->sym = v[2] == 2;
@ -1451,7 +1450,7 @@ namespace mapeditor {
layer++; layer++;
if(layer == USERLAYERS) break; if(layer == USERLAYERS) break;
} }
rebuildPolys = true; usershape_changes++;
} }
void applyToShape(int sg, int id, int uni, hyperpoint mh) { void applyToShape(int sg, int id, int uni, hyperpoint mh) {
@ -1477,7 +1476,7 @@ namespace mapeditor {
if(uni == 'n' || xnew) { if(uni == 'n' || xnew) {
dsCur->list.clear(); dsCur->list.clear();
dsCur->list.push_back(mh); dsCur->list.push_back(mh);
rebuildPolys = true; usershape_changes++;
} }
if(uni == 'u') if(uni == 'u')
@ -1491,7 +1490,7 @@ namespace mapeditor {
if(uni == 'a') { if(uni == 'a') {
dsCur->list.push_back(mh); dsCur->list.push_back(mh);
uni = 0; uni = 0;
rebuildPolys = true; usershape_changes++;
} }
else if(uni == 'c' || uni == 'd' || uni == 'm') { else if(uni == 'c' || uni == 'd' || uni == 'm') {
hyperpoint best = mh; hyperpoint best = mh;
@ -1521,7 +1520,7 @@ namespace mapeditor {
if(oldlist[i] != best) if(oldlist[i] != best)
dsCur->list.push_back(oldlist[i]); dsCur->list.push_back(oldlist[i]);
} }
rebuildPolys = true; usershape_changes++;
uni = 0; uni = 0;
} }
else if(uni == COLORKEY) dsCur->color = colortouse; else if(uni == COLORKEY) dsCur->color = colortouse;
@ -1537,7 +1536,7 @@ namespace mapeditor {
dsCur->list.insert(dsCur->list.begin()+ew.pointid+(ew.side?1:0), mh); dsCur->list.insert(dsCur->list.begin()+ew.pointid+(ew.side?1:0), mh);
if(ew.side) ew.pointid++; if(ew.side) ew.pointid++;
rebuildPolys = true; usershape_changes++;
} }
if(uni == 'D') { if(uni == 'D') {
@ -1561,41 +1560,41 @@ namespace mapeditor {
if(ew.side == 1 && ew.pointid >= i) ew.pointid--; if(ew.side == 1 && ew.pointid >= i) ew.pointid--;
if(ew.side == 0 && ew.pointid > i) ew.pointid--; if(ew.side == 0 && ew.pointid > i) ew.pointid--;
} }
rebuildPolys = true; usershape_changes++;
} }
if(uni == 'K') { if(uni == 'K') {
if(vid.cs.charid >= 4) { if(vid.cs.charid >= 4) {
loadShape(sg, id, shCatBody, 2, 0); loadShape(sg, id, cgi.shCatBody, 2, 0);
loadShape(sg, id, shCatHead, 2, 1); loadShape(sg, id, cgi.shCatHead, 2, 1);
} }
else { else {
if(!(vid.cs.charid&1)) loadShape(sg, id, shPBody, 2, 0); if(!(vid.cs.charid&1)) loadShape(sg, id, cgi.shPBody, 2, 0);
else loadShape(sg, id, shFemaleBody, 2, 0); else loadShape(sg, id, cgi.shFemaleBody, 2, 0);
loadShape(sg, id, shPSword, 1, 1); loadShape(sg, id, cgi.shPSword, 1, 1);
if(vid.cs.charid&1) if(vid.cs.charid&1)
loadShape(sg, id, shFemaleDress, 2, 2); loadShape(sg, id, cgi.shFemaleDress, 2, 2);
/* if(vid.cs.charid&1) /* if(vid.cs.charid&1)
loadShape(sg, id, shPrincessDress, 1, 3); loadShape(sg, id, cgi.shPrincessDress, 1, 3);
else else
loadShape(sg, id, shPrinceDress, 2, 3); */ loadShape(sg, id, cgi.shPrinceDress, 2, 3); */
loadShape(sg, id, shRatCape2, 1, 3); loadShape(sg, id, cgi.shRatCape2, 1, 3);
if(vid.cs.charid&1) if(vid.cs.charid&1)
loadShape(sg, id, shFemaleHair, 2, 4); loadShape(sg, id, cgi.shFemaleHair, 2, 4);
else else
loadShape(sg, id, shPHead, 2, 4); loadShape(sg, id, cgi.shPHead, 2, 4);
loadShape(sg, id, shPFace, 2, 5); loadShape(sg, id, cgi.shPFace, 2, 5);
} }
// loadShape(sg, id, shWolf, 2, dslayer); // loadShape(sg, id, cgi.shWolf, 2, dslayer);
rebuildPolys = true; usershape_changes++;
} }
if(uni == '+') dsCur->rots++; if(uni == '+') dsCur->rots++;
@ -1603,20 +1602,20 @@ namespace mapeditor {
if(uni >= '1' && uni <= '9') { if(uni >= '1' && uni <= '9') {
dsCur->rots = uni - '0'; dsCur->rots = uni - '0';
if(dsCur->rots == 9) dsCur->rots = 21; if(dsCur->rots == 9) dsCur->rots = 21;
rebuildPolys = true; usershape_changes++;
} }
if(uni == '0') { if(uni == '0') {
dsCur->sym = !dsCur->sym; dsCur->sym = !dsCur->sym;
rebuildPolys = true; usershape_changes++;
} }
if(uni == 't') { if(uni == 't') {
dsCur->shift = mh; dsCur->shift = mh;
rebuildPolys = true; usershape_changes++;
} }
if(uni == 'y') { if(uni == 'y') {
dsCur->spin = mh; dsCur->spin = mh;
rebuildPolys = true; usershape_changes++;
} }
if(uni == COLORKEY) dsCur->color = colortouse; if(uni == COLORKEY) dsCur->color = colortouse;
@ -1691,7 +1690,7 @@ namespace mapeditor {
} }
addMessage(XLAT("Pictures loaded from %1", picfile)); addMessage(XLAT("Pictures loaded from %1", picfile));
buildpolys(); usershape_changes++;
return true; return true;
} }
@ -1945,9 +1944,6 @@ namespace mapeditor {
} }
} }
} }
if(rebuildPolys)
add_user_shapes(), rebuildPolys = false;
} }
#endif #endif
@ -2053,10 +2049,11 @@ namespace mapeditor {
usershape *us = usershapes[group][id]; usershape *us = usershapes[group][id];
if(us) { if(us) {
cgi.require_usershapes();
for(int i=0; i<USERLAYERS; i++) { for(int i=0; i<USERLAYERS; i++) {
if(i != dslayer && onelayeronly) continue; if(i != dslayer && onelayeronly) continue;
usershapelayer& ds(us->d[i]); usershapelayer& ds(us->d[i]);
hpcshape& sh(ds.sh); hpcshape& sh(cgi.ushr[&ds]);
if(sh.s != sh.e) { if(sh.s != sh.e) {
auto& last = queuepolyat(mmscale(V, DIM == 3 ? 0 : geom3::lev_to_factor(ds.zlevel)), sh, ds.color ? ds.color : color, prio); auto& last = queuepolyat(mmscale(V, DIM == 3 ? 0 : geom3::lev_to_factor(ds.zlevel)), sh, ds.color ? ds.color : color, prio);

View File

@ -79,7 +79,7 @@ namespace hr { namespace netgen {
int hdir = displayspin(c, i) + M_PI / S7; int hdir = displayspin(c, i) + M_PI / S7;
transmatrix V2 = V * spin(hdir) * xpush(hexf); transmatrix V2 = V * spin(hdir) * xpush(cgi.hexf);
hcenter[ii][i] = V2 * C0; hcenter[ii][i] = V2 * C0;
} }
@ -91,7 +91,7 @@ namespace hr { namespace netgen {
int hdir = displayspin(c, i); int hdir = displayspin(c, i);
transmatrix V2 = transmatrix V2 =
V * spin(hdir) * xpush(crossf) * spin(M_PI+M_PI/S7) * xpush(hexf); V * spin(hdir) * xpush(cgi.crossf) * spin(M_PI+M_PI/S7) * xpush(cgi.hexf);
hcenter[ii][i] = V2 * C0; hcenter[ii][i] = V2 * C0;
} }

View File

@ -491,7 +491,7 @@ int getHemisphere(cell *c, int which) {
else if(GOLDBERG) { else if(GOLDBERG) {
auto li = gp::get_local_info(c); auto li = gp::get_local_info(c);
gp::be_in_triangle(li); gp::be_in_triangle(li);
auto corner = gp::corners * gp::loctoh_ort(li.relative); auto corner = cgi.gpdata->corners * gp::loctoh_ort(li.relative);
ld scored = ld scored =
corner[0] * getHemisphere(c->master->c7, which) corner[0] * getHemisphere(c->master->c7, which)
+ corner[1] * getHemisphere(c->master->move(li.last_dir)->c7, which) + corner[1] * getHemisphere(c->master->move(li.last_dir)->c7, which)
@ -2223,7 +2223,7 @@ namespace linepatterns {
if(fv2/4 == 4 || fv2/4 == 6 || fv2/4 == 5 || fv2/4 == 10) fv2 ^= 2; if(fv2/4 == 4 || fv2/4 == 6 || fv2/4 == 5 || fv2/4 == 10) fv2 ^= 2;
if((fv1&1) == (fv2&1)) continue; if((fv1&1) == (fv2&1)) continue;
double x = hexhexdist / 2; // sphere?.3651:euclid?.2611:.2849; double x = cgi.hexhexdist / 2; // sphere?.3651:euclid?.2611:.2849;
gridlinef(V, ddspin(c,i,-M_PI/S3) * xpush0(x), gridlinef(V, ddspin(c,i,-M_PI/S3) * xpush0(x),
ddspin(c,i,M_PI/S3) * xpush0(x), ddspin(c,i,M_PI/S3) * xpush0(x),
@ -2291,8 +2291,8 @@ namespace linepatterns {
cell *c1 = createMov(c, (i+3) % 7); cell *c1 = createMov(c, (i+3) % 7);
cell *c2 = createMov(c, (i+4) % 7); cell *c2 = createMov(c, (i+4) % 7);
if(polarb50(c1) != a && polarb50(c2) != a) if(polarb50(c1) != a && polarb50(c2) != a)
gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(tessf/2), gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(cgi.tessf/2),
ddspin(c,i,M_PI*9/7) * xpush0(tessf/2), ddspin(c,i,M_PI*9/7) * xpush0(cgi.tessf/2),
col, 1 + vid.linequality); col, 1 + vid.linequality);
} }
break; break;
@ -2300,15 +2300,15 @@ namespace linepatterns {
case patPalacelike: case patPalacelike:
if(pseudohept(c)) for(int i=0; i<7; i++) if(pseudohept(c)) for(int i=0; i<7; i++)
gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(tessf/2), gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(cgi.tessf/2),
ddspin(c,i,M_PI*9/7) * xpush0(tessf/2), ddspin(c,i,M_PI*9/7) * xpush0(cgi.tessf/2),
col, 1 + vid.linequality); col, 1 + vid.linequality);
break; break;
case patBigTriangles: { case patBigTriangles: {
if(is_master(c) && !euclid) for(int i=0; i<S7; i++) if(is_master(c) && !euclid) for(int i=0; i<S7; i++)
if(c->master->move(i) && c->master->move(i) < c->master) { if(c->master->move(i) && c->master->move(i) < c->master) {
gridlinef(V, C0, xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), tessf), col, 2 + vid.linequality); gridlinef(V, C0, xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), cgi.tessf), col, 2 + vid.linequality);
} }
break; break;
} }
@ -2316,7 +2316,7 @@ namespace linepatterns {
case patBigRings: { case patBigRings: {
if(is_master(c) && !euclid) for(int i=0; i<S7; i++) if(is_master(c) && !euclid) for(int i=0; i<S7; i++)
if(c->master->move(i) && c->master->move(i) < c->master && c->master->move(i)->dm4 == c->master->dm4) if(c->master->move(i) && c->master->move(i) < c->master && c->master->move(i)->dm4 == c->master->dm4)
gridlinef(V, C0, xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), tessf), col, 2 + vid.linequality); gridlinef(V, C0, xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), cgi.tessf), col, 2 + vid.linequality);
break; break;
} }
@ -2362,10 +2362,10 @@ namespace linepatterns {
} }
else { else {
int p = emeraldval(c); int p = emeraldval(c);
double hdist = hdist0(heptmove[0] * heptmove[2] * C0); double hdist = hdist0(cgi.heptmove[0] * cgi.heptmove[2] * C0);
if(pseudohept(c) && (p/4 == 10 || p/4 == 8)) if(pseudohept(c) && (p/4 == 10 || p/4 == 8))
for(int i=0; i<S7; i++) if(c->move(i) && emeraldval(c->move(i)) == p-4) { for(int i=0; i<S7; i++) if(c->move(i) && emeraldval(c->move(i)) == p-4) {
gridlinef(V, C0, tC0(heptmove[i]), col, 2 + vid.linequality); gridlinef(V, C0, tC0(cgi.heptmove[i]), col, 2 + vid.linequality);
gridlinef(V, C0, xspinpush0(-i * ALPHA, -hdist/2), col, 2 + vid.linequality); gridlinef(V, C0, xspinpush0(-i * ALPHA, -hdist/2), col, 2 + vid.linequality);
} }
} }
@ -2392,8 +2392,8 @@ namespace linepatterns {
heptagon *h2 = c->master->modmove(i-1); heptagon *h2 = c->master->modmove(i-1);
if(!h1 || !h2) continue; if(!h1 || !h2) continue;
if(emeraldval(h1->c7)/4 == 8 && emeraldval(h2->c7)/4 == 8) if(emeraldval(h1->c7)/4 == 8 && emeraldval(h2->c7)/4 == 8)
gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(tessf/2), gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(cgi.tessf/2),
ddspin(c,i,M_PI*9/7) * xpush0(tessf/2), ddspin(c,i,M_PI*9/7) * xpush0(cgi.tessf/2),
col, 1 + vid.linequality); col, 1 + vid.linequality);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1316,7 +1316,7 @@ void markers() {
draw_ghost(ghost); draw_ghost(ghost);
if(gmatrix.count(track[0])) { if(gmatrix.count(track[0])) {
hyperpoint h = WDIM == 2 && GDIM == 3 ? zpush(geom3::FLOOR - geom3::human_height/80) * C0 : C0; hyperpoint h = WDIM == 2 && GDIM == 3 ? zpush(cgi.FLOOR - cgi.human_height/80) * C0 : C0;
for(ld z=-start_line_width; z<=start_line_width; z+=0.1) for(ld z=-start_line_width; z<=start_line_width; z+=0.1)
curvepoint(ggmatrix(track[0]) * straight * parabolic1(z) * h); curvepoint(ggmatrix(track[0]) * straight * parabolic1(z) * h);
queuecurve(0xFFFFFFFF, 0, PPR::BFLOOR); queuecurve(0xFFFFFFFF, 0, PPR::BFLOOR);

View File

@ -476,7 +476,7 @@ void buildTorusRug() {
println(hlog, "factor = ", make_tuple(xfactor, yfactor, factor)); println(hlog, "factor = ", make_tuple(xfactor, yfactor, factor));
println(hlog, "scales = ", make_tuple(xscale, yscale)); println(hlog, "scales = ", make_tuple(xscale, yscale));
modelscale = xscale / crossf; modelscale = xscale / cgi.crossf;
} }
map<pair<int, int>, rugpoint*> glues; map<pair<int, int>, rugpoint*> glues;

View File

@ -677,7 +677,6 @@ void apply() {
} }
} }
apply_animated_parameters(); apply_animated_parameters();
if(need_reset_geometry) resetGeometry(), need_reset_geometry = false;
calcparam(); calcparam();
} }
@ -1120,12 +1119,12 @@ reaction_t add_to_frame;
#if CAP_STARTANIM #if CAP_STARTANIM
void draw_ghost(const transmatrix V, int id) { void draw_ghost(const transmatrix V, int id) {
if(id % 13 == 0) { if(id % 13 == 0) {
queuepoly(V, shMiniGhost, 0xFFFF00C0); queuepoly(V, cgi.shMiniGhost, 0xFFFF00C0);
queuepoly(V, shMiniEyes, 0xFF); queuepoly(V, cgi.shMiniEyes, 0xFF);
} }
else { else {
queuepoly(V, shMiniGhost, 0xFFFFFFC0); queuepoly(V, cgi.shMiniGhost, 0xFFFFFFC0);
queuepoly(V, shMiniEyes, 0xFF); queuepoly(V, cgi.shMiniEyes, 0xFF);
} }
} }

View File

@ -950,7 +950,7 @@ void profile(const char *buf) {
} }
*/ */
#define SCALE scalefactor #define SCALE cgi.scalefactor
#define SCALE2 (SCALE*SCALE) #define SCALE2 (SCALE*SCALE)
namespace shmup { namespace shmup {
@ -1076,7 +1076,7 @@ bool trackroute(monster *m, transmatrix goal, double spd) {
d += spd; d += spd;
transmatrix nat = m->pat * rspintox(mat * C0) * xpush(d); transmatrix nat = m->pat * rspintox(mat * C0) * xpush(d);
// queuepoly(nat, shKnife, 0xFFFFFFC0); // queuepoly(nat, cgi.shKnife, 0xFFFFFFC0);
cell *c2 = findbaseAround(nat, c); cell *c2 = findbaseAround(nat, c);
if(c2 != c && !passable_for(m->type, c2, c, P_CHAIN | P_ONPLAYER)) { if(c2 != c && !passable_for(m->type, c2, c, P_CHAIN | P_ONPLAYER)) {
@ -1418,7 +1418,7 @@ void roseCurrents(transmatrix& nat, monster *m, int delta) {
hyperpoint keytarget(int i) { hyperpoint keytarget(int i) {
double d = 2 + sin(curtime / 350.); double d = 2 + sin(curtime / 350.);
return pc[i]->pat * cpush0(WDIM == 3 ? 2 : 0, d * scalefactor); return pc[i]->pat * cpush0(WDIM == 3 ? 2 : 0, d * cgi.scalefactor);
} }
/* int charidof(int pid) { /* int charidof(int pid) {
@ -1428,8 +1428,8 @@ hyperpoint keytarget(int i) {
return 0; return 0;
} */ } */
ld getSwordSize() { return sword_size; } ld getSwordSize() { return cgi.sword_size; }
ld getHornsSize() { return scalefactor * 0.33; } ld getHornsSize() { return cgi.scalefactor * 0.33; }
// used in 3D // used in 3D
transmatrix swordmatrix[MAXPLAYER]; transmatrix swordmatrix[MAXPLAYER];
@ -1777,7 +1777,7 @@ void movePlayer(monster *m, int delta) {
if(isReptile(m->base->wall)) m->base->wparam = reptilemax(); if(isReptile(m->base->wall)) m->base->wparam = reptilemax();
int steps = 1 + abs(int(playergo[cpid] / (.2 * scalefactor))); int steps = 1 + abs(int(playergo[cpid] / (.2 * cgi.scalefactor)));
playergo[cpid] /= steps; playergo[cpid] /= steps;
@ -2385,7 +2385,7 @@ transmatrix frontpush(ld x) {
ld collision_distance(monster *bullet, monster *target) { ld collision_distance(monster *bullet, monster *target) {
if(target->type == moAsteroid) if(target->type == moAsteroid)
return SCALE * 0.15 + asteroid_size[target->hitpoints & 7]; return SCALE * 0.15 + cgi.asteroid_size[target->hitpoints & 7];
return SCALE * 0.3; return SCALE * 0.3;
} }
@ -3601,12 +3601,12 @@ bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, trans
color_t incolor = magic ? 0x0060C0FF : 0x804000FF; color_t incolor = magic ? 0x0060C0FF : 0x804000FF;
if(WDIM == 2) { if(WDIM == 2) {
queuepoly(Vboat0, shBoatOuter, outcolor); queuepoly(Vboat0, cgi.shBoatOuter, outcolor);
queuepoly(Vboat0, shBoatInner, incolor); queuepoly(Vboat0, cgi.shBoatInner, incolor);
} }
if(WDIM == 3) { if(WDIM == 3) {
queuepoly(mscale(Vboat0, scalefactor/2), shBoatOuter, outcolor); queuepoly(mscale(Vboat0, cgi.scalefactor/2), cgi.shBoatOuter, outcolor);
queuepoly(mscale(Vboat0, scalefactor/2-0.01), shBoatInner, incolor); queuepoly(mscale(Vboat0, cgi.scalefactor/2-0.01), cgi.shBoatInner, incolor);
} }
} }
@ -3651,7 +3651,7 @@ bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, trans
queuechr(h, vid.fsize, '+', iinf[keyresult[cpid]].color); queuechr(h, vid.fsize, '+', iinf[keyresult[cpid]].color);
else { else {
dynamicval<color_t> p(poly_outline, darkena(iinf[keyresult[cpid]].color, 0, 255)); dynamicval<color_t> p(poly_outline, darkena(iinf[keyresult[cpid]].color, 0, 255));
queuepoly(rgpushxto0(h) * cspin(0, 1, ticks / 140.), shGem[1], 0); queuepoly(rgpushxto0(h) * cspin(0, 1, ticks / 140.), cgi.shGem[1], 0);
} }
} }
@ -3667,39 +3667,39 @@ bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, trans
else else
col = (minf[m->parenttype].color << 8) | 0xFF; col = (minf[m->parenttype].color << 8) | 0xFF;
if(getcs().charid >= 4) { if(getcs().charid >= 4) {
queuepoly(mmscale(view, 1.15), shPHead, col); queuepoly(mmscale(view, 1.15), cgi.shPHead, col);
ShadowV(view, shPHead); ShadowV(view, cgi.shPHead);
} }
else if(peace::on) { else if(peace::on) {
queuepolyat(mmscale(view, 1.15), shDisk, col, PPR::MISSILE); queuepolyat(mmscale(view, 1.15), cgi.shDisk, col, PPR::MISSILE);
ShadowV(view, shPHead); ShadowV(view, cgi.shPHead);
} }
else { else {
transmatrix t = view * spin(curtime / 50.0); transmatrix t = view * spin(curtime / 50.0);
queuepoly(WDIM == 3 ? t : DIM == 3 ? mscale(t, geom3::BODY) : mmscale(t, 1.15), shKnife, col); queuepoly(WDIM == 3 ? t : DIM == 3 ? mscale(t, cgi.BODY) : mmscale(t, 1.15), cgi.shKnife, col);
ShadowV(t, shKnife); ShadowV(t, cgi.shKnife);
} }
break; break;
} }
case moArrowTrap: { case moArrowTrap: {
queuepoly(mmscale(view, 1.15), shTrapArrow, 0xFFFFFFFF); queuepoly(mmscale(view, 1.15), cgi.shTrapArrow, 0xFFFFFFFF);
ShadowV(view, shTrapArrow); ShadowV(view, cgi.shTrapArrow);
break; break;
} }
case moTongue: { case moTongue: {
queuepoly(mmscale(view, 1.15), shTongue, (minf[m->parenttype].color << 8) | 0xFF); queuepoly(mmscale(view, 1.15), cgi.shTongue, (minf[m->parenttype].color << 8) | 0xFF);
ShadowV(view, shTongue); ShadowV(view, cgi.shTongue);
break; break;
} }
case moFireball: case moAirball: { // case moLightningBolt: case moFireball: case moAirball: { // case moLightningBolt:
queuepoly(mmscale(view, 1.15), shPHead, (minf[m->type].color << 8) | 0xFF); queuepoly(mmscale(view, 1.15), cgi.shPHead, (minf[m->type].color << 8) | 0xFF);
ShadowV(view, shPHead); ShadowV(view, cgi.shPHead);
break; break;
} }
case moFlailBullet: case moCrushball: { case moFlailBullet: case moCrushball: {
transmatrix t = view * spin(curtime / 50.0); transmatrix t = view * spin(curtime / 50.0);
queuepoly(mmscale(t, 1.15), shFlailMissile, (minf[m->type].color << 8) | 0xFF); queuepoly(mmscale(t, 1.15), cgi.shFlailMissile, (minf[m->type].color << 8) | 0xFF);
ShadowV(view, shFlailMissile); ShadowV(view, cgi.shFlailMissile);
break; break;
} }
case moAsteroid: { case moAsteroid: {
@ -3707,11 +3707,11 @@ bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, trans
transmatrix t = view; transmatrix t = view;
if(WDIM == 3) t = face_the_player(t); if(WDIM == 3) t = face_the_player(t);
t = t * spin(curtime / 500.0); t = t * spin(curtime / 500.0);
ShadowV(t, shAsteroid[m->hitpoints & 7]); ShadowV(t, cgi.shAsteroid[m->hitpoints & 7]);
if(WDIM == 2) t = mmscale(t, 1.15); if(WDIM == 2) t = mmscale(t, 1.15);
color_t col = WDIM == 3 ? 0xFFFFFF : minf[m->type].color; color_t col = WDIM == 3 ? 0xFFFFFF : minf[m->type].color;
col <<= 8; col <<= 8;
queuepoly(t, shAsteroid[m->hitpoints & 7], col | 0xFF); queuepoly(t, cgi.shAsteroid[m->hitpoints & 7], col | 0xFF);
break; break;
} }

View File

@ -6,8 +6,6 @@
namespace hr { namespace hr {
bool need_reset_geometry = true;
bool game_active; bool game_active;
bool cblind; bool cblind;
@ -1091,39 +1089,48 @@ namespace gamestack {
eGeometry geometry; eGeometry geometry;
eVariation variation; eVariation variation;
bool shmup; bool shmup;
void store();
void restore();
}; };
vector<gamedata> gd; vector<gamedata> gd;
bool pushed() { return isize(gd); } bool pushed() { return isize(gd); }
void gamedata::store() {
hmap = currentmap;
cwt = hr::cwt;
geometry = hr::geometry;
shmup = hr::shmup::on;
variation = hr::variation;
d = *current_display;
}
void gamedata::restore() {
currentmap = hmap;
hr::cwt = cwt;
hr::geometry = geometry;
hr::variation = variation;
if(shmup::on) shmup::clearMonsters();
shmup::on = shmup;
check_cgi();
cgi.require_basics();
*current_display = d;
bfs();
}
void push() { void push() {
if(geometry) { if(geometry) {
printf("ERROR: push implemented only in non-hyperbolic geometry\n"); printf("ERROR: push implemented only in non-hyperbolic geometry\n");
exit(1); exit(1);
} }
gamedata gdn; gd.emplace_back();
gdn.hmap = currentmap; gd.back().store();
gdn.cwt = cwt;
gdn.geometry = geometry;
gdn.shmup = shmup::on;
gdn.variation = variation;
gdn.d = *current_display;
gd.push_back(gdn);
} }
void pop() { void pop() {
gamedata& gdn = gd[isize(gd)-1]; gd.back().restore();
currentmap = gdn.hmap;
cwt = gdn.cwt;
geometry = gdn.geometry;
variation = gdn.variation;
if(shmup::on) shmup::clearMonsters();
shmup::on = gdn.shmup;
resetGeometry();
*current_display = gdn.d;
gd.pop_back(); gd.pop_back();
bfs();
} }
}; };
@ -1215,8 +1222,6 @@ void set_geometry(eGeometry target) {
#endif #endif
if(DIM == 3 && old_DIM == 2 && pmodel == mdDisk) pmodel = mdPerspective; if(DIM == 3 && old_DIM == 2 && pmodel == mdDisk) pmodel = mdPerspective;
if(DIM == 2 && pmodel == mdPerspective) pmodel = mdDisk; if(DIM == 2 && pmodel == mdPerspective) pmodel = mdDisk;
need_reset_geometry = true;
} }
} }
@ -1231,7 +1236,6 @@ void set_variation(eVariation target) {
target = eVariation::pure; target = eVariation::pure;
} }
variation = target; variation = target;
need_reset_geometry = true;
} }
} }
@ -1256,7 +1260,6 @@ void switch_game_mode(char switchWhat) {
case rg::chaos: case rg::chaos:
if(tactic::on) firstland = laIce; if(tactic::on) firstland = laIce;
yendor::on = tactic::on = princess::challenge = false; yendor::on = tactic::on = princess::challenge = false;
need_reset_geometry = true;
chaosmode = !chaosmode; chaosmode = !chaosmode;
if(bounded) set_geometry(gNormal); if(bounded) set_geometry(gNormal);
racing::on = false; racing::on = false;
@ -1272,7 +1275,6 @@ void switch_game_mode(char switchWhat) {
gp::param = gp::loc(1, 1); gp::param = gp::loc(1, 1);
#endif #endif
shmup::on = false; shmup::on = false;
need_reset_geometry = true;
tour::on = !tour::on; tour::on = !tour::on;
racing::on = false; racing::on = false;
break; break;
@ -1359,7 +1361,8 @@ void start_game() {
restart: restart:
game_active = true; game_active = true;
gamegen_failure = false; gamegen_failure = false;
if(need_reset_geometry) resetGeometry(), need_reset_geometry = false; check_cgi();
cgi.require_basics();
initcells(); initcells();
expansion.reset(); expansion.reset();

View File

@ -337,7 +337,7 @@ bool texture_config::apply(cell *c, const transmatrix &V, color_t col) {
if(config.tstate == tsAdjusting) { if(config.tstate == tsAdjusting) {
dynamicval<color_t> d(poly_outline, slave_color); dynamicval<color_t> d(poly_outline, slave_color);
draw_floorshape(c, V, shFullFloor, 0, PPR::LINE); draw_floorshape(c, V, cgi.shFullFloor, 0, PPR::LINE);
curvepoint(V * C0); curvepoint(V * C0);
for(int i=0; i<c->type; i++) for(int i=0; i<c->type; i++)
@ -349,13 +349,13 @@ bool texture_config::apply(cell *c, const transmatrix &V, color_t col) {
try { try {
auto& mi = texture_map.at(si.id); auto& mi = texture_map.at(si.id);
set_floor(shFullFloor); set_floor(cgi.shFullFloor);
qfi.tinf = &mi; qfi.tinf = &mi;
qfi.spin = applyPatterndir(c, si); qfi.spin = applyPatterndir(c, si);
if(grid_color) { if(grid_color) {
dynamicval<color_t> d(poly_outline, grid_color); dynamicval<color_t> d(poly_outline, grid_color);
draw_floorshape(c, V, shFullFloor, 0, PPR::FLOOR); draw_floorshape(c, V, cgi.shFullFloor, 0, PPR::FLOOR);
} }
if(using_aura()) { if(using_aura()) {
@ -1571,7 +1571,6 @@ int textureArgs() {
else if(argis("-txcl")) { else if(argis("-txcl")) {
PHASE(3); drawscreen(); PHASE(3); drawscreen();
config.load(); config.load();
need_reset_geometry = true;
} }
else return 1; else return 1;

108
usershapes.cpp Normal file
View File

@ -0,0 +1,108 @@
#if CAP_SHAPES
// HyperRogue, some functions for user-defined shapes
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
namespace hr {
int usershape_changes;
array<map<int, usershape*>, mapeditor::USERSHAPEGROUPS> usershapes;
void initShape(int sg, int id) {
if(!usershapes[sg][id]) {
usershape *us = new usershape;
usershapes[sg][id] = us;
for(int i=0; i<USERLAYERS; i++) {
us->d[i].prio = PPR((sg == 3 ? 1:50) + i);
us->d[i].rots = 1;
us->d[i].sym = 0;
us->d[i].shift = C0;
us->d[i].spin = Cx1;
us->d[i].color = 0;
us->d[i].zlevel = 0;
}
}
}
basic_textureinfo user_triangles_texture;
void geometry_information::pushShape(usershapelayer& ds) {
if(ds.list.empty()) return;
if(DIM == 3) last->flags |= POLY_TRIANGLES;
transmatrix T = rgpushxto0(ds.shift) * rspintox(ds.spin);
int z = DIM == 3 ? 3 : 1;
for(int r=0; r<ds.rots; r++) {
for(int i=0; i<isize(ds.list)/z*z; i++)
hpcpush(T * spin(2*M_PI*r/ds.rots) * ds.list[i]);
if(ds.sym) {
transmatrix mirrortrans = Id; mirrortrans[1][1] = -1;
for(int i=isize(ds.list)-1; i>=0; i--)
hpcpush(T * spin(2*M_PI*r/ds.rots) * mirrortrans * ds.list[i]);
}
}
if(DIM == 2) hpcpush(T * ds.list[0]);
#if MAXMDIM >= 4
if(DIM == 3) {
auto& utt = user_triangles_texture;
utt.texture_id = floor_textures->renderedTexture;
ds.texture_offset = isize(utt.tvertices);
for(int i=0; i<isize(ds.list)-2; i+=3) {
hyperpoint h = orthogonal_of_C0(ds.list[i], ds.list[i+1], ds.list[i+2]);
ld rad = hypot_d(3, h);
ld factor = 0.49 + (0.17 * h[2] + 0.13 * h[1] + 0.20 * h[0]) / rad;
for(int i=0; i<3; i++)
utt.tvertices.push_back(glhr::makevertex(-1, factor, 0));
}
}
#endif
}
void geometry_information::prepare_usershapes() {
hpc.resize(prehpc);
last = NULL;
DEBB(DF_POLY, ("hpc = ", prehpc));
user_triangles_texture.tvertices.clear();
for(int i=0; i<mapeditor::USERSHAPEGROUPS; i++) for(auto usp: usershapes[i]) {
auto us = usp.second;
if(!us) continue;
for(int l=0; l<USERLAYERS; l++) {
bshape(ushr[&us->d[l]], us->d[l].prio);
pushShape(us->d[l]);
finishshape();
}
}
static int qhpc0;
int qhpc = isize(hpc);
if(qhpc != qhpc0 && (debugflags & (DF_GEOM | DF_POLY))) {
println(hlog, "qhpc = ", qhpc0=qhpc, " (", prehpc, "+", qhpc-prehpc, ")");
println(hlog, "shapes = ", isize(allshapes));
int inve=0, issi=0, vcon=0, ccon=0;
for(auto sh: allshapes) {
if(sh->flags & POLY_INVERSE) inve++;
if(sh->flags & POLY_ISSIDE) issi++;
if(sh->flags & POLY_VCONVEX) vcon++;
if(sh->flags & POLY_CCONVEX) ccon++;
}
println(hlog, format("inverse = %d isside = %d vcon = %d ccon = %d", inve, issi, vcon, ccon));
}
initPolyForGL();
}
}
#endif