floor tiles are now constructed based on logical coordinates

This commit is contained in:
Zeno Rogue 2023-01-29 14:14:58 +01:00
parent 1e6e75c7d4
commit 31a5a9e5c7
1 changed files with 32 additions and 43 deletions

View File

@ -288,20 +288,23 @@ void geometry_information::bshape_regular(floorshape &fsh, int id, int sides, ld
if(bt::in()) {
const int STEP = vid.texture_step;
for(int t=0; t<2; t++) {
if(t == 0)
bshape(fsh.b[id], fsh.prio);
if(t == 1)
bshape(fsh.shadow[id], fsh.prio);
int STEP1 = STEP;
if((embedded_plane || geom3::flipped) && t == 0) STEP1 = 1;
for(int i=0; i<sides; i++) {
hyperpoint h0 = bt::get_corner_horo_coordinates(c, i) * size;
hyperpoint h1 = bt::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++) {
hyperpoint hd = (h1 - h0) / STEP1;
for(int j=0; j<STEP1; j++) {
hpcpush(bt::get_horopoint(h0 + hd * j));
if(geometry == gBinary4 && among(i, 2, 4)) break;
if(geometry == gBinaryTiling && among(i, 0, 4)) break;
@ -679,38 +682,32 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
last->tinf = &floor_texture_vertices[fsh.id];
last->texture_offset = 0;
#if CAP_BT
if(bt::in())
for(int t=0; t<c->type; t++)
texture_order([&] (ld x, ld y) {
hyperpoint left = bt::get_corner_horo_coordinates(c, t);
hyperpoint right = bt::get_corner_horo_coordinates(c, t+1);
hpcpush(orthogonal_move(bt::get_horopoint(left * x + right * y), dfloor_table[k]));
});
else
#endif
if(1) {
int s = fsh.b[id].s;
int e = fsh.b[id].e-1;
hyperpoint ctr = Hypc;
for(int t=0; t<e-s; t++)
ctr += orthogonal_move(may_kleinize(hpc[s+t]), dfloor_table[k]);
ctr = normalize(ctr);
if(vid.pseudohedral) for(int t=0; t<e-s; t++) {
hyperpoint v1 = orthogonal_move(may_kleinize(hpc[s+t]), dfloor_table[k]) - ctr;
hyperpoint v2 = orthogonal_move(may_kleinize(hpc[s+t+1]), dfloor_table[k]) - ctr;
texture_order([&] (ld x, ld y) {
hpcpush(normalize(ctr + v1 * x + v2 * y));
});
if(vid.pseudohedral) {
hyperpoint ctr = Hypc;
for(int t=0; t<e-s; t++)
ctr += kleinize(cgi.emb->orthogonal_move(hpc[s+t], dfloor_table[k]));
ctr = normalize(ctr);
for(int t=0; t<e-s; t++) {
hyperpoint v1 = kleinize(cgi.emb->orthogonal_move(hpc[s+t], dfloor_table[k])) - ctr;
hyperpoint v2 = kleinize(cgi.emb->orthogonal_move(hpc[s+t+1], dfloor_table[k])) - ctr;
texture_order([&] (ld x, ld y) {
hpcpush(normalize(ctr + v1 * x + v2 * y));
});
}
}
if(!vid.pseudohedral) for(int t=0; t<e-s; t++) {
hyperpoint fctr = may_kleinize(tile_center());
hyperpoint v1 = may_kleinize(hpc[s+t]) - fctr;
hyperpoint v2 = may_kleinize(hpc[s+t+1]) - fctr;
hyperpoint v1 = cgi.emb->actual_to_logical(hpc[s+t]);
hyperpoint v2 = cgi.emb->actual_to_logical(hpc[s+t+1]);
texture_order([&] (ld x, ld y) {
hyperpoint a = fctr + v1 * x + v2 * y;
hyperpoint b = cgi.emb->normalize_flat(a);
hyperpoint c = orthogonal_move(b, dfloor_table[k]);
hyperpoint a = v1 * x + v2 * y;
a[2] = dfloor_table[k];
auto c = cgi.emb->logical_to_actual(a);
cgi.hpcpush(c);
});
}
@ -728,24 +725,16 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
last->texture_offset = 0;
ld h = (FLOOR - WALL) / (co+1);
ld top = co ? (FLOOR + WALL) / 2 : WALL;
#if CAP_BT
if(bt::in())
for(int t=0; t<c->type; t++)
texture_order([&] (ld x, ld y) {
hyperpoint left = bt::get_corner_horo_coordinates(c, t);
hyperpoint right = bt::get_corner_horo_coordinates(c, t+1);
hpcpush(orthogonal_move(bt::get_horopoint(left * x + right * y), top + h * (x+y)));
});
else
#endif
if(1) {
int s = fsh.b[id].s;
int e = fsh.b[id].e-1;
for(int t=0; t<e-s; t++) {
auto TC0 = tile_center();
hyperpoint v1 = may_kleinize(hpc[s+t]) - TC0;
hyperpoint v2 = may_kleinize(hpc[s+t+1]) - TC0;
texture_order([&] (ld x, ld y) { hpcpush(orthogonal_move(cgi.emb->normalize_flat(TC0 + v1 * x + v2 * y), top + h * (x+y))); });
hyperpoint v1 = cgi.emb->actual_to_logical(hpc[s+t]);
hyperpoint v2 = cgi.emb->actual_to_logical(hpc[s+t+1]);
texture_order([&] (ld x, ld y) {
hyperpoint a = v1 * x + v2 * y; a[2] = top + h * (x+y);
hpcpush(cgi.emb->logical_to_actual(a));
});
}
}