1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

2d3d:: textures on sidewalls

This commit is contained in:
Zeno Rogue 2019-05-09 17:54:30 +02:00
parent d89fb49e13
commit da49e6c8de
4 changed files with 67 additions and 34 deletions

View File

@ -1179,6 +1179,31 @@ void config_camera_rotation() {
); );
} }
void add_edit_wall_quality(char c) {
dialog::addSelItem(XLAT("wall quality"), its(vid.texture_step), c);
dialog::add_action([] {
dialog::editNumber(vid.texture_step, 1, 16, 1, 1, XLAT("wall quality"),
XLAT(
"Controls the number of triangles used for wall surfaces. "
"Higher numbers reduce the performance. "
"This has a strong effect when the walls are curved indeed "
"(honeycombs based on horospheres, and projections other than native perspective), "
"but otherwise, usually it can be set to 1 without significant adverse effects other "
"than slightly incorrect texturing."
)
);
dialog::bound_low(1);
dialog::bound_up(128);
dialog::reaction = [] {
if(floor_textures) {
delete floor_textures;
floor_textures = NULL;
}
need_reset_geometry = true;
};
});
}
void show3D() { void show3D() {
cmode = sm::SIDE | sm::MAYDARK; cmode = sm::SIDE | sm::MAYDARK;
gamescreen(0); gamescreen(0);
@ -1245,30 +1270,7 @@ void show3D() {
dialog::editNumber(vid.radarsize, 0, 360, 15, 90, "", "set to 0 to disable"); dialog::editNumber(vid.radarsize, 0, 360, 15, 90, "", "set to 0 to disable");
}); });
} }
if(DIM == 3) { if(DIM == 3) add_edit_wall_quality('W');
dialog::addSelItem(XLAT("wall quality"), its(vid.texture_step), 'W');
dialog::add_action([] {
dialog::editNumber(vid.texture_step, 1, 16, 1, 1, XLAT("wall quality"),
XLAT(
"Controls the number of triangles used for wall surfaces. "
"Higher numbers reduce the performance. "
"This has a strong effect when the walls are curved indeed "
"(honeycombs based on horospheres, and projections other than native perspective), "
"but otherwise, usually it can be set to 1 without significant adverse effects other "
"than slightly incorrect texturing."
)
);
dialog::bound_low(1);
dialog::bound_up(128);
dialog::reaction = [] {
if(floor_textures) {
delete floor_textures;
floor_textures = NULL;
}
need_reset_geometry = true;
};
});
}
#endif #endif
dialog::addBreak(50); dialog::addBreak(50);

View File

@ -464,6 +464,7 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
} }
} }
#if MAXMDIM >= 4
if(WDIM == 2 && GDIM == 3) { if(WDIM == 2 && GDIM == 3) {
finishshape(); finishshape();
for(auto pfsh: all_plain_floorshapes) { for(auto pfsh: all_plain_floorshapes) {
@ -499,6 +500,12 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
} }
} }
} }
for(int l=0; l<SIDEPARS; l++) {
for(auto& li: fsh.side[l]) li.tinf = &fsh.tinf3;
for(int e=0; e<MAX_EDGE; e++)
for(auto& li: fsh.gpside[l][e]) li.tinf = &fsh.tinf3;
}
} }
for(auto pfsh: all_escher_floorshapes) { for(auto pfsh: all_escher_floorshapes) {
@ -506,17 +513,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];
for(auto& li: fsh.levels[l]) li.tinf = &fsh.tinf3;
fsh.side[l] = shFullFloor.side[l]; fsh.side[l] = shFullFloor.side[l];
for(int e=0; e<MAX_EDGE; e++) for(auto& li: fsh.side[l]) li.tinf = &fsh.tinf3;
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& l: fsh.levels)
for(auto& li: l)
li.tinf = &fsh.tinf3;
} }
finishshape(); finishshape();
} }
#endif
} }
void generate_floorshapes() { void generate_floorshapes() {

View File

@ -631,6 +631,8 @@ void showEuclideanMenu() {
#endif #endif
}; };
}); });
extern void add_edit_wall_quality(char);
add_edit_wall_quality('W');
} }
else if(WDIM == 3) dialog::addBreak(100); else if(WDIM == 3) dialog::addBreak(100);
else { else {

View File

@ -138,12 +138,33 @@ hyperpoint zshift(hyperpoint x, ld z) {
} }
void chasmifyPoly(double fac, double fac2, int k) { void chasmifyPoly(double fac, double fac2, int k) {
for(int i=isize(hpc)-1; i >= last->s; i--) { if(GDIM == 2) {
hpc.push_back(zshift(hpc[i], fac)); for(int i=isize(hpc)-1; i >= last->s; i--) {
hpc[i] = zshift(hpc[i], fac2); hpc.push_back(mscale(hpc[i], fac));
hpc[i] = mscale(hpc[i], fac2);
}
hpc.push_back(hpc[last->s]);
last->flags |= POLY_ISSIDE;
}
else {
vector<hyperpoint> points;
for(int s = last->s; s<isize(hpc); s++) points.push_back(hpc[s]);
hpc.resize(last->s);
last->flags |= POLY_TRIANGLES;
last->texture_offset = 0;
last->s = isize(hpc);
using namespace hyperpoint_vec;
auto at = [&] (ld x, ld y) {
x *= (isize(points) - 1);
int zf = int(x);
x -= zf;
hpcpush(zshift(points[zf] + (points[zf+1] - points[zf]) * x, fac + (fac2-fac) * y));
};
texture_order([&] (ld x, ld y) { at((1-x+y)/2, (1-x-y)/2); });
texture_order([&] (ld x, ld y) { at((1-x-y)/2, (1+x-y)/2); });
texture_order([&] (ld x, ld y) { at((1+x-y)/2, (1+x+y)/2); });
texture_order([&] (ld x, ld y) { at((1+x+y)/2, (1-x+y)/2); });
} }
hpc.push_back(hpc[last->s]);
last->flags |= POLY_ISSIDE;
} }
#endif #endif