flat and invert are now separate flags

This commit is contained in:
Zeno Rogue 2022-12-15 13:11:23 +01:00
parent 9498a1de03
commit 91ac8a600b
2 changed files with 43 additions and 48 deletions

View File

@ -840,6 +840,14 @@ EX void initConfig() {
param_b(geom3::auto_configure, "auto_configure_3d", "auto_configure_3d")
-> editable("set 3D settings automatically", 'A');
param_b(geom3::inverted_embedding, "inverted_3d", "inverted_3d")
-> editable("invert convex/concave", 'I')
-> set_reaction([] { geom3::switch_fpp(); geom3::switch_fpp(); });
param_b(geom3::flat_embedding, "flat_3d", "flat_3d")
-> editable("flat, not equidistant", 'F')
-> set_reaction([] { geom3::switch_fpp(); geom3::switch_fpp(); });
param_enum(geom3::spatial_embedding, "spatial_embedding", "spatial_embedding", geom3::seDefault)
->editable(geom3::spatial_embedding_options, "3D embedding method", 'E')
->set_reaction([] {
@ -2207,15 +2215,12 @@ EX void edit_levellines(char c) {
}
EX geom3::eSpatialEmbedding shown_spatial_embedding() {
if(GDIM == 2) {
if(pmodel == mdDisk && pconf.camera_angle)
return geom3::seTPP;
else
return geom3::seNone;
}
if(GDIM == 2) return geom3::seNone;
return geom3::spatial_embedding;
}
EX bool in_tpp() { return pmodel == mdDisk && pconf.camera_angle; }
EX void show_spatial_embedding() {
cmode = sm::SIDE | sm::MAYDARK | sm::CENTER | sm::PANNING | sm::SHOWCURSOR;
gamescreen();
@ -2229,14 +2234,11 @@ EX void show_spatial_embedding() {
for(int i=0; i<isize(seo); i++) {
auto se = geom3::eSpatialEmbedding(i);
if(!geom3::auto_configure && geom3::is_suboption(se)) continue;
dialog::addBoolItem(XLAT(seo[i].first), emb == i, 'a' + i);
dialog::add_action([se, emb] {
if(GDIM == 3) { if(geom3::auto_configure) geom3::switch_fpp(); else geom3::switch_always3(); }
if(se == geom3::seNone && emb == geom3::seTPP) geom3::switch_tpp();
if(se == geom3::seTPP && emb == geom3::seNone) geom3::switch_tpp();
if(se != geom3::seNone && se != geom3::seTPP) {
println(hlog, "set spatial_embedding to ", int(se));
if(in_tpp()) geom3::switch_tpp();
if(se != geom3::seNone) {
geom3::spatial_embedding = se;
if(geom3::auto_configure) geom3::switch_fpp(); else geom3::switch_always3();
delete_sky();
@ -2248,6 +2250,22 @@ EX void show_spatial_embedding() {
dialog::addBreak(100);
dialog::addHelp(XLAT(seo[emb].second));
dialog::addBreak(100);
if(geom3::auto_configure) {
if(emb == geom3::seNone) {
dialog::addBoolItem(XLAT("third-person perspective"), in_tpp(), 'T');
dialog::add_action(geom3::switch_tpp);
dialog::addBreak(100);
}
else {
if(geom3::supports_flat()) add_edit(geom3::flat_embedding);
else dialog::addBreak(100);
if(geom3::supports_invert()) add_edit(geom3::inverted_embedding);
else dialog::addBreak(100);
}
}
dialog::addBreak(100);
dialog::addBack();
dialog::display();

View File

@ -1074,14 +1074,9 @@ EX namespace geom3 {
#if HDR
enum eSpatialEmbedding {
seNone,
seTPP,
seDefault,
seFlat,
seInverted,
seLowerCurvature,
seLowerCurvatureInverted,
seMuchLowerCurvature,
seMuchLowerCurvatureInverted,
seProduct,
seNil,
seSol, seNIH, seSolN,
@ -1090,30 +1085,25 @@ EX namespace geom3 {
#endif
EX vector<pair<string, string>> spatial_embedding_options = {
{"2D engine", "Use HyperRogue's 2D engine to simulate 'default 3D' top-down."},
{"2D engine in TPP","HyperRogue's 2D engine, but using third-person perspective."},
{"default 3D", "Embed as a equidistant surface in the 3D version of the same geometry."},
{"flat", "Embed as a flat surface in the 3D version of the same geometry."},
{"inverted", "Embed as a equidistant surface, but this time it is inverted."},
{"lower curvature", "Embed as a convex surface in a space of lower curvature."},
{"lower curvature inverted", "Embed as a concave surface in a space of lower curvature."},
{"much lower curvature", "Embed sphere as a convex sphere in hyperbolic space."},
{"much lower curvature inverted", "Embed sphere as a concave sphere in hyperbolic space."},
{"2D engine", "Use HyperRogue's 2D engine to simulate same curvature. Works well in top-down and third-person perspective."},
{"same curvature", "Embed as an equidistant surface in the 3D version of the same geometry."},
{"lower curvature", "Embed as a surface in a space of lower curvature."},
{"much lower curvature", "Embed sphere as a sphere in hyperbolic space."},
{"product", "Add one extra dimension in the Euclidean way."},
{"Nil", "Embed into Nil. Works only with Euclidean. You need to set the variation to Pure."},
{"Sol", "Embed into Sol. Works only with Euclidean. You need to set the variation to Pure."},
{"stretched hyperbolic", "Embed into stretched hyperbolic geometry. Works only with Euclidean. You need to set the variation to Pure."},
{"stretched Sol", "Embed into stretched Sol geometry. Works only with Euclidean. You need to set the variation to Pure."},
{"stretched hyperbolic inverted", "Embed into stretched hyperbolic geometry as a concave horosphere. Works only with Euclidean. You need to set the variation to Pure."},
};
EX eSpatialEmbedding spatial_embedding = seDefault;
EX ld euclid_embed_scale = 1;
EX bool auto_configure = true;
EX bool flat_embedding = false;
EX bool inverted_embedding = false;
EX bool is_suboption(eSpatialEmbedding se) {
return among(se, seTPP, seInverted, seFlat, seLowerCurvatureInverted, seMuchLowerCurvatureInverted, seNIH_inv);
}
EX bool supports_flat() { return spatial_embedding == seDefault; }
EX bool supports_invert() { return among(spatial_embedding, seDefault, seLowerCurvature, seMuchLowerCurvature, seNil, seSol, seNIH, seSolN); }
EX vector<geometryinfo> ginf_backup;
@ -1202,13 +1192,13 @@ EX namespace geom3 {
g.sig[2] = g.sig[3];
}
if(among(spatial_embedding, seLowerCurvature, seLowerCurvatureInverted)) {
if(spatial_embedding == seLowerCurvature) {
if(g.kind == gcEuclid) g = ginf[gSpace534].g;
if(g.kind == gcSphere) g = ginf[gCubeTiling].g;
g.gameplay_dimension = 2;
}
if(among(spatial_embedding, seMuchLowerCurvature, seMuchLowerCurvatureInverted)) {
if(spatial_embedding == seMuchLowerCurvature) {
g = ginf[gSpace534].g;
g.gameplay_dimension = 2;
}
@ -1232,11 +1222,6 @@ EX namespace geom3 {
g.gameplay_dimension = 2;
}
if(spatial_embedding == seNIH_inv && ieuc_or_binary) {
g = ginf[gNIH].g;
g.gameplay_dimension = 2;
}
if(spatial_embedding == seSolN && ieuc_or_binary) {
g = ginf[gSolN].g;
g.gameplay_dimension = 2;
@ -1308,29 +1293,21 @@ EX void switch_always3() {
vid.depth = 0;
vid.wall_height = -1;
vid.eye = 0.5;
if(among(spatial_embedding, seLowerCurvatureInverted, seMuchLowerCurvatureInverted)) {
if(inverted_embedding) {
vid.wall_height = 1.4;
vid.eye = -0.2;
vid.depth = 0.5;
}
}
if(spatial_embedding == seFlat) {
if(spatial_embedding == seDefault && flat_embedding) {
vid.eye -= vid.depth / 2;
vid.depth = 0;
}
if(spatial_embedding == seInverted) {
if(spatial_embedding == seDefault && !flat_embedding && inverted_embedding) {
vid.eye -= vid.depth * 1.5;
vid.depth *= -1;
}
if(euc_in_hyp() && spatial_embedding == seLowerCurvatureInverted) {
vid.wall_height *= -1;
vid.eye = 2 * vid.depth;
}
if(euc_in_hyp() && spatial_embedding == seMuchLowerCurvatureInverted) {
vid.wall_height *= -1;
vid.eye = 2 * vid.depth;
}
if(euc_in_noniso() && spatial_embedding == seNIH_inv) {
if((euc_in_hyp() || euc_in_noniso()) && inverted_embedding) {
vid.wall_height *= -1;
vid.eye = 2 * vid.depth;
}