mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-23 15:36:59 +00:00
standard binary tiling, also improved the looks of variant binary tiling, and optimized shvid for pure
This commit is contained in:
parent
2598bbcdd5
commit
2d30f3830c
@ -210,18 +210,16 @@ namespace binary {
|
||||
case gBinary4: {
|
||||
switch(d) {
|
||||
case 0: case 1:
|
||||
return build(parent, d, 3, 5, 0, 1);
|
||||
return build(parent, d, 3, 5, d, 1);
|
||||
case 3:
|
||||
return build(parent, 3, nextdir(2), 5, 0, -1);
|
||||
return build(parent, 3, parent->zebraval, 5, nextdir(2), -1);
|
||||
case 2:
|
||||
parent->cmove(3);
|
||||
if(parent->c.spin(3) == 0)
|
||||
if(parent->zebraval == 0)
|
||||
return path(h, 2, 4, {3, 1});
|
||||
else
|
||||
return path(h, 2, 4, {3, 2, 0});
|
||||
case 4:
|
||||
parent->cmove(3);
|
||||
if(parent->c.spin(3) == 1)
|
||||
if(parent->zebraval == 1)
|
||||
return path(h, 4, 2, {3, 0});
|
||||
else
|
||||
return path(h, 4, 2, {3, 4, 1});
|
||||
@ -481,13 +479,14 @@ namespace binary {
|
||||
}
|
||||
|
||||
void build_tmatrix() {
|
||||
if(geometry == gBinaryTiling) return; // unused
|
||||
use_direct = (1 << S7) - 1;
|
||||
if(geometry == gBinary4) {
|
||||
use_direct = 3;
|
||||
direct_tmatrix[0] = xpush(-log(2)) * parabolic(-1);
|
||||
direct_tmatrix[1] = xpush(-log(2)) * parabolic(+1);
|
||||
direct_tmatrix[2] = parabolic(2);
|
||||
direct_tmatrix[4] = parabolic(-2);
|
||||
direct_tmatrix[0] = xpush(-log(2)) * parabolic(-0.5);
|
||||
direct_tmatrix[1] = xpush(-log(2)) * parabolic(+0.5);
|
||||
direct_tmatrix[2] = parabolic(1);
|
||||
direct_tmatrix[4] = parabolic(-1);
|
||||
use_direct = 1+2+4+16;
|
||||
}
|
||||
if(geometry == gBinary3) {
|
||||
@ -840,7 +839,7 @@ hyperpoint get_corner_horo_coordinates(cell *c, int i) {
|
||||
ld yx = log(2) / 2;
|
||||
ld yy = yx;
|
||||
ld xx = 1 / sqrt(2)/2;
|
||||
switch(gmod(i, c->type)) {
|
||||
if(geometry == gBinaryTiling) switch(gmod(i, c->type)) {
|
||||
case 0: return point2(-yy, xx);
|
||||
case 1: return point2(yy, 2*xx);
|
||||
case 2: return point2(yy, xx);
|
||||
@ -850,8 +849,20 @@ hyperpoint get_corner_horo_coordinates(cell *c, int i) {
|
||||
case 6: return point2(-yy, 0);
|
||||
default: return point2(0, 0);
|
||||
}
|
||||
else switch(gmod(i, c->type)) {
|
||||
case 0: return point2(yy, -2*xx);
|
||||
case 1: return point2(yy, +0*xx);
|
||||
case 2: return point2(yy, +2*xx);
|
||||
case 3: return point2(-yy, xx);
|
||||
case 4: return point2(-yy, -xx);
|
||||
default: return point2(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto hooksw = addHook(hooks_swapdim, 100, [] {
|
||||
if(binarytiling) build_tmatrix();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
2
cell.cpp
2
cell.cpp
@ -41,7 +41,7 @@ hrmap_hyperbolic::hrmap_hyperbolic(heptagon *o) { origin = o; }
|
||||
|
||||
hrmap_hyperbolic::hrmap_hyperbolic() {
|
||||
// printf("Creating hyperbolic map: %p\n", this);
|
||||
int odegree = (WDIM == 2 && binarytiling) ? 6 : S7;
|
||||
int odegree = geometry == gBinaryTiling ? 6 : S7;
|
||||
origin = tailored_alloc<heptagon> (odegree);
|
||||
heptagon& h = *origin;
|
||||
h.s = hsOrigin;
|
||||
|
@ -558,7 +558,7 @@ vector<geometryinfo> ginf = {
|
||||
{"bin{6,3}", "none", "{6,3} on horospheres", "bin63", 14, 3, qBINARY, gcHyperbolic, 0x40400, {{7, 3}}, eVariation::pure},
|
||||
{"{4,3,5}","field", "{4,3,5} field quotient space", "f435", 6, 5, qsSMALLBF, gcHyperbolic, 0x40600, {{SEE_ALL, SEE_ALL}}, eVariation::pure},
|
||||
{"{5,3,4}","field", "{5,3,4} field quotient space", "f435", 12, 4, qsSMALLBF, gcHyperbolic, 0x40800, {{SEE_ALL, SEE_ALL}}, eVariation::pure},
|
||||
{"binary4","none", "standard binary tiling", "binary4", 5, 4, qBINARY, gcHyperbolic, 0, {{6, 4}}, eVariation::pure},
|
||||
{"binary4","none", "standard binary tiling", "binary4", 5, 4, qBINARY, gcHyperbolic, 0, {{7, 5}}, eVariation::pure},
|
||||
};
|
||||
|
||||
// bits: 9, 10, 15, 16, (reserved for later) 17, 18
|
||||
|
@ -217,7 +217,7 @@ void geometry_information::bshape2(hpcshape& sh, PPR prio, int shapeid, matrixli
|
||||
hpcpush(hpc[last->s]);
|
||||
}
|
||||
|
||||
void geometry_information::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, cell *c) {
|
||||
|
||||
fsh.b.resize(2);
|
||||
fsh.shadow.resize(2);
|
||||
@ -225,8 +225,6 @@ void geometry_information::bshape_regular(floorshape &fsh, int id, int sides, in
|
||||
#if CAP_BT
|
||||
if(binarytiling) {
|
||||
|
||||
cell fc;
|
||||
fc.type = 6+id;
|
||||
const int STEP = vid.texture_step;
|
||||
using namespace hyperpoint_vec;
|
||||
|
||||
@ -238,8 +236,8 @@ void geometry_information::bshape_regular(floorshape &fsh, int id, int sides, in
|
||||
bshape(fsh.shadow[id], fsh.prio);
|
||||
|
||||
for(int i=0; i<sides; i++) {
|
||||
hyperpoint h0 = binary::get_corner_horo_coordinates(&fc, i) * size;
|
||||
hyperpoint h1 = binary::get_corner_horo_coordinates(&fc, i+1) * size;
|
||||
hyperpoint h0 = binary::get_corner_horo_coordinates(c, i) * size;
|
||||
hyperpoint h1 = binary::get_corner_horo_coordinates(c, i+1) * size;
|
||||
if(t) h0 *= SHADMUL, h1 *= SHADMUL;
|
||||
hyperpoint hd = (h1 - h0) / STEP;
|
||||
for(int j=0; j<STEP; j++)
|
||||
@ -250,14 +248,14 @@ void geometry_information::bshape_regular(floorshape &fsh, int id, int sides, in
|
||||
}
|
||||
|
||||
for(int k=0; k<SIDEPARS; k++) {
|
||||
for(int i=0; i<fc.type; i++) {
|
||||
for(int i=0; i<c->type; i++) {
|
||||
fsh.gpside[k][i].resize(2);
|
||||
bshape(fsh.gpside[k][i][id], PPR::LAKEWALL);
|
||||
hyperpoint h0 = binary::get_corner_horo_coordinates(&fc, i) * size;
|
||||
hyperpoint h1 = binary::get_corner_horo_coordinates(&fc, i+1) * size;
|
||||
hyperpoint h0 = binary::get_corner_horo_coordinates(c, i) * size;
|
||||
hyperpoint h1 = binary::get_corner_horo_coordinates(c, i+1) * size;
|
||||
hyperpoint hd = (h1 - h0) / STEP;
|
||||
for(int j=0; j<=STEP; j++)
|
||||
hpcpush(iddspin(&fc, i) * binary::get_horopoint(h0 + hd * j));
|
||||
hpcpush(iddspin(c, i) * binary::get_horopoint(h0 + hd * j));
|
||||
chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
}
|
||||
}
|
||||
@ -313,22 +311,22 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
|
||||
if(S3 == 4 && BITRUNCATED) b += S14;
|
||||
|
||||
if(id == 1)
|
||||
bshape_regular(fsh, 1, S7, td, heptside);
|
||||
bshape_regular(fsh, 1, S7, td, heptside, c);
|
||||
|
||||
else if(PURE) {
|
||||
if(&fsh == &shTriheptaFloor)
|
||||
bshape_regular(fsh, 0, S7/2, 0, hexside);
|
||||
bshape_regular(fsh, 0, S7/2, 0, hexside, c);
|
||||
else if(&fsh == &shBigTriangle)
|
||||
bshape_regular(fsh, 0, S7/2, S12, hexside);
|
||||
bshape_regular(fsh, 0, S7/2, S12, hexside, c);
|
||||
else
|
||||
bshape_regular(fsh, 0, S7, td, heptside);
|
||||
bshape_regular(fsh, 0, S7, td, heptside, c);
|
||||
}
|
||||
else if(&fsh == &shBigTriangle)
|
||||
bshape_regular(fsh, 0, S3, b+S14, hexside);
|
||||
bshape_regular(fsh, 0, S3, b+S14, hexside, c);
|
||||
else if(&fsh == &shTriheptaFloor)
|
||||
bshape_regular(fsh, 0, S3, b, hexside);
|
||||
bshape_regular(fsh, 0, S3, b, hexside, c);
|
||||
else
|
||||
bshape_regular(fsh, 0, S6, S7, hexside);
|
||||
bshape_regular(fsh, 0, S6, S7, hexside, c);
|
||||
|
||||
|
||||
continue;
|
||||
@ -426,18 +424,16 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
|
||||
|
||||
if(STDVAR && !binarytiling && !archimedean) {
|
||||
generate_matrices_scale(fsh.scale, fsh.noftype);
|
||||
if(PURE && geosupport_football() < 2 && fsh.shapeid2) {
|
||||
if(id == 0) bshape2(fsh.b[0], fsh.prio, fsh.shapeid2, hept_matrices);
|
||||
if(id == 1) bshape2(fsh.b[1], fsh.prio, fsh.shapeid2, hept_matrices);
|
||||
if(PURE && geosupport_football() < 2) {
|
||||
bshape2(fsh.b[id], fsh.prio, fsh.shapeid2 ? fsh.shapeid2 : fsh.shapeid1, hept_matrices);
|
||||
}
|
||||
else {
|
||||
if(id == 0) bshape2(fsh.b[0], fsh.prio, fsh.shapeid0, hex_matrices);
|
||||
if(id == 1) bshape2(fsh.b[1], fsh.prio, fsh.shapeid1, hept_matrices);
|
||||
}
|
||||
generate_matrices_scale(fsh.scale * SHADMUL, fsh.noftype);
|
||||
if(PURE && geosupport_football() < 2 && fsh.shapeid2) {
|
||||
if(id == 0) bshape2(fsh.shadow[0], fsh.prio, fsh.shapeid2, hept_matrices);
|
||||
if(id == 1) bshape2(fsh.shadow[1], fsh.prio, fsh.shapeid2, hept_matrices);
|
||||
if(PURE && geosupport_football() < 2) {
|
||||
bshape2(fsh.shadow[id], fsh.prio, fsh.shapeid2 ? fsh.shapeid2 : fsh.shapeid1, hept_matrices);
|
||||
}
|
||||
else {
|
||||
if(id == 0) bshape2(fsh.shadow[0], fsh.prio, fsh.shapeid0, hex_matrices);
|
||||
@ -637,6 +633,23 @@ void geometry_information::generate_floorshapes() {
|
||||
}
|
||||
#endif
|
||||
|
||||
else if(geometry == gBinary4) {
|
||||
heptagon modelh;
|
||||
cell model;
|
||||
model.master = &modelh;
|
||||
model.type = S7;
|
||||
for(int i: {0,1}) {
|
||||
modelh.zebraval = i;
|
||||
generate_floorshapes_for(i, &model, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
else if(PURE && geometry != gBinaryTiling && geosupport_football() < 2) {
|
||||
cell model;
|
||||
model.type = S7;
|
||||
generate_floorshapes_for(0, &model, 1, 0);
|
||||
}
|
||||
|
||||
else {
|
||||
cell model;
|
||||
model.type = S6; generate_floorshapes_for(0, &model, 0, 0);
|
||||
@ -732,6 +745,19 @@ void set_floor(const transmatrix& spin, hpcshape& sh) {
|
||||
qfi.usershape = -1;
|
||||
}
|
||||
|
||||
int shvid(cell *c) {
|
||||
if(geosupport_football() == 2)
|
||||
return pseudohept(c);
|
||||
else if(geometry == gBinaryTiling)
|
||||
return c->type-6;
|
||||
else if(geometry == gBinary4)
|
||||
return c->master->zebraval;
|
||||
else if(PURE)
|
||||
return 0;
|
||||
else
|
||||
return ctof(c);
|
||||
}
|
||||
|
||||
dqi_poly *draw_shapevec(cell *c, const transmatrix& V, const vector<hpcshape> &shv, color_t col, PPR prio = PPR::DEFAULT) {
|
||||
if(!c) return &queuepolyat(V, shv[0], col, prio);
|
||||
else if(WDIM == 3) return NULL;
|
||||
@ -764,12 +790,8 @@ dqi_poly *draw_shapevec(cell *c, const transmatrix& V, const vector<hpcshape> &s
|
||||
transmatrix D = applyPatterndir(c, si);
|
||||
return &queuepolyat(V*D, shv[pseudohept(c)], col, prio);
|
||||
}
|
||||
else if(geosupport_threecolor() == 2)
|
||||
return &queuepolyat(V, shv[pseudohept(c)], col, prio);
|
||||
else if(binarytiling)
|
||||
return &queuepolyat(V, shv[c->type-6], col, prio);
|
||||
else
|
||||
return &queuepolyat(V, shv[ctof(c)], col, prio);
|
||||
return &queuepolyat(V, shv[shvid(c)], col, prio);
|
||||
}
|
||||
|
||||
void draw_floorshape(cell *c, const transmatrix& V, const floorshape &fsh, color_t col, PPR prio = PPR::DEFAULT) {
|
||||
|
@ -373,7 +373,7 @@ void ge_land_selection() {
|
||||
vector<eGeometry> tilinglist = {
|
||||
gTinySphere, gSmallSphere, gSphere, gEuclid, gNormal, gOctagon,
|
||||
gOctahedron, gEuclidSquare, g45, g46, g47,
|
||||
gArchimedean, gBinaryTiling
|
||||
gArchimedean, gBinary4, gBinaryTiling
|
||||
};
|
||||
|
||||
vector<eGeometry> quotientlist = {
|
||||
|
@ -138,7 +138,7 @@ void geometry_information::prepare_basics() {
|
||||
if(geometry == gHoroRec) hexvdist = rhexf = .5, tessf = .5, scalefactor = .5, crossf = hcrossf7/2;
|
||||
#endif
|
||||
#if CAP_BT && MAXMDIM >= 4
|
||||
if(binarytiling && WDIM == 3) binary::build_tmatrix();
|
||||
if(binarytiling) binary::build_tmatrix();
|
||||
#endif
|
||||
|
||||
scalefactor = crossf / hcrossf7;
|
||||
|
@ -391,7 +391,7 @@ double cellgfxdist(cell *c, int i) {
|
||||
if(c->type == 8 && (i&1)) return cgi.crossf * sqrt(2);
|
||||
return cgi.crossf;
|
||||
}
|
||||
if(NONSTDVAR || archimedean || WDIM == 3) return hdist0(tC0(calc_relative_matrix(c->move(i), c, i)));
|
||||
if(NONSTDVAR || archimedean || WDIM == 3 || binarytiling) return hdist0(tC0(calc_relative_matrix(c->move(i), c, i)));
|
||||
return !BITRUNCATED ? cgi.tessf : (c->type == 6 && (i&1)) ? cgi.hexhexdist : cgi.crossf;
|
||||
}
|
||||
|
||||
@ -510,6 +510,17 @@ hyperpoint nearcorner(cell *c, int i) {
|
||||
}
|
||||
#endif
|
||||
#if CAP_BT
|
||||
if(geometry == gBinary4) {
|
||||
ld yx = log(2) / 2;
|
||||
ld yy = yx;
|
||||
hyperpoint neis[5];
|
||||
neis[0] = binary::get_horopoint(2*yy, -0.5);
|
||||
neis[1] = binary::get_horopoint(2*yy, +0.5);
|
||||
neis[2] = binary::get_horopoint(0, 1);
|
||||
neis[3] = binary::get_horopoint(-2*yy, c->master->zebraval ? -0.25 : +0.25);
|
||||
neis[4] = binary::get_horopoint(0, -1);
|
||||
return neis[i];
|
||||
}
|
||||
if(binarytiling) {
|
||||
if(WDIM == 3) {
|
||||
println(hlog, "nearcorner called");
|
||||
|
@ -361,11 +361,13 @@ double hexshiftat(cell *c) {
|
||||
|
||||
transmatrix ddspin(cell *c, int d, ld bonus) {
|
||||
if(WDIM == 3 && d < c->type) return rspintox(tC0(calc_relative_matrix(c->move(d), c, C0))) * cspin(2, 0, bonus);
|
||||
if(WDIM == 2 && binarytiling) return spin(bonus) * rspintox(nearcorner(c, d));
|
||||
return spin(displayspin(c, d) + bonus - hexshiftat(c));
|
||||
}
|
||||
|
||||
transmatrix iddspin(cell *c, int d, ld bonus) {
|
||||
if(WDIM == 3 && d < c->type) return cspin(0, 2, bonus) * spintox(tC0(calc_relative_matrix(c->move(d), c, C0)));
|
||||
if(WDIM == 2 && binarytiling) return spin(bonus) * spintox(nearcorner(c, d));
|
||||
return spin(hexshiftat(c) - displayspin(c, d) + bonus);
|
||||
}
|
||||
|
||||
@ -3965,7 +3967,7 @@ bool placeSidewall(cell *c, int i, int sidepar, const transmatrix& V, color_t co
|
||||
return false;
|
||||
}
|
||||
|
||||
queuepolyat(V2, qfi.fshape->side[sidepar][pseudohept(c)], col, prio);
|
||||
queuepolyat(V2, qfi.fshape->side[sidepar][shvid(c)], col, prio);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
2
hyper.h
2
hyper.h
@ -4581,7 +4581,7 @@ hpcshape
|
||||
|
||||
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 bshape_regular(floorshape &fsh, int id, int sides, int shift, ld size, cell *model);
|
||||
void generate_floorshapes_for(int id, cell *c, int siid, int sidir);
|
||||
void generate_floorshapes();
|
||||
void make_floor_textures_here();
|
||||
|
@ -88,6 +88,8 @@ transmatrix geometry_information::ddi(int a, ld x) { return xspinpush(a * M_PI /
|
||||
|
||||
void geometry_information::drawTentacle(hpcshape &h, ld rad, ld var, ld divby) {
|
||||
double tlength = max(crossf, hexhexdist);
|
||||
if(geometry == gBinaryTiling) tlength *= 0.7;
|
||||
if(geometry == gBinary4) tlength *= 0.45;
|
||||
#if CAP_ARCM
|
||||
if(archimedean) tlength = arcm::current.scale();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user