moved the parameters from geom3:: to videopar

This commit is contained in:
Zeno Rogue 2019-05-29 16:27:24 +02:00
parent 7ec6571a10
commit 1c6e6bafb4
11 changed files with 294 additions and 301 deletions

View File

@ -12,7 +12,7 @@ ld eyepos;
#if MAXMDIM >= 4
#define S (cgi.scalefactor / 0.805578)
#define SH (cgi.scalefactor / 0.805578 * geom3::height_width / 1.5)
#define SH (cgi.scalefactor / 0.805578 * vid.height_width / 1.5)
#define revZ (WDIM == 2 ? -1 : 1)

View File

@ -205,19 +205,20 @@ void initConfig() {
addsaver(vid.monmode, "monster display mode", DEFAULT_MONMODE);
addsaver(vid.wallmode, "wall display mode", DEFAULT_WALLMODE);
addsaver(geom3::depth, "3D depth");
addsaver(geom3::camera, "3D camera level");
addsaver(geom3::wall_height, "3D wall height");
addsaver(geom3::rock_wall_ratio, "3D rock-wall ratio");
addsaver(geom3::human_wall_ratio, "3D human-wall ratio");
addsaver(geom3::lake_top, "3D lake top");
addsaver(geom3::lake_bottom, "3D lake bottom");
addsaver(geom3::tc_depth, "3D TC depth");
addsaver(geom3::tc_camera, "3D TC camera");
addsaver(geom3::tc_alpha, "3D TC alpha");
addsaver(geom3::highdetail, "3D highdetail");
addsaver(geom3::middetail, "3D middetail");
addsaver(geom3::gp_autoscale_heights, "3D Goldberg autoscaling");
addsaver(vid.depth, "3D depth", 1);
addsaver(vid.camera, "3D camera level", 1);
addsaver(vid.wall_height, "3D wall height", .3);
addsaver(vid.rock_wall_ratio, "3D rock-wall ratio", .9);
addsaver(vid.human_wall_ratio, "3D human-wall ratio", .7);
addsaver(vid.lake_top, "3D lake top", .25);
addsaver(vid.lake_bottom, "3D lake bottom", .9);
addsaver(vid.tc_depth, "3D TC depth", 1);
addsaver(vid.tc_camera, "3D TC camera", 2);
addsaver(vid.tc_alpha, "3D TC alpha", 3);
addsaver(vid.highdetail, "3D highdetail", 8);
addsaver(vid.middetail, "3D middetail", 8);
addsaver(vid.gp_autoscale_heights, "3D Goldberg autoscaling", true);
addsaver(vid.always3, "3D always", false);
addsaver(memory_saving_mode, "memory_saving_mode", (ISMOBILE || ISPANDORA || ISWEB) ? 1 : 0);
@ -228,7 +229,7 @@ void initConfig() {
addsaver(rug::model_distance, "rug-model-distance");
#endif
addsaverenum(pmodel, "used model");
addsaverenum(pmodel, "used model", mdDisk);
addsaver(polygonal::SI, "polygon sides");
addsaver(polygonal::STAR, "polygon star factor");
addsaver(polygonal::deg, "polygonal degree");
@ -325,8 +326,8 @@ void initConfig() {
addsaver(vid.stretch, "stretch", 1);
addsaver(vid.binary_width, "binary-tiling-width", 1);
addsaver(geom3::creature_scale, "3d-creaturescale", 1);
addsaver(geom3::height_width, "3d-heightwidth", 1.5);
addsaver(vid.creature_scale, "3d-creaturescale", 1);
addsaver(vid.height_width, "3d-heightwidth", 1.5);
#if CAP_GP
addsaver(gp::param.first, "goldberg-x", gp::param.first);
@ -567,16 +568,15 @@ void saveConfig() {
{
int pt_depth = 0, pt_camera = 0, pt_alpha = 0;
using namespace geom3;
if(tc_depth > tc_camera) pt_depth++;
if(tc_depth < tc_camera) pt_camera++;
if(tc_depth > tc_alpha ) pt_depth++;
if(tc_depth < tc_alpha ) pt_alpha ++;
if(tc_alpha > tc_camera) pt_alpha++;
if(tc_alpha < tc_camera) pt_camera++;
tc_alpha = pt_alpha;
tc_camera = pt_camera;
tc_depth = pt_depth;
if(vid.tc_depth > vid.tc_camera) pt_depth++;
if(vid.tc_depth < vid.tc_camera) pt_camera++;
if(vid.tc_depth > vid.tc_alpha ) pt_depth++;
if(vid.tc_depth < vid.tc_alpha ) pt_alpha ++;
if(vid.tc_alpha > vid.tc_camera) pt_alpha++;
if(vid.tc_alpha < vid.tc_camera) pt_camera++;
vid.tc_alpha = pt_alpha;
vid.tc_camera = pt_camera;
vid.tc_depth = pt_depth;
}
for(auto s: savers) if(s->dosave())
@ -1100,7 +1100,7 @@ void showJoyConfig() {
#endif
void projectionDialog() {
geom3::tc_alpha = ticks;
vid.tc_alpha = ticks;
dialog::editNumber(vid.alpha, -5, 5, .1, 1,
XLAT("projection"),
XLAT("HyperRogue uses the Minkowski hyperboloid model internally. "
@ -1138,7 +1138,7 @@ void explain_detail() {
"Objects at distance less than %1 absolute units "
"from the center will be displayed with high "
"detail, and at distance at least %2 with low detail.",
fts(geom3::highdetail), fts(geom3::middetail)
fts(vid.highdetail), fts(vid.middetail)
));
}
@ -1159,7 +1159,6 @@ void add_edit_fov(char key = 'f') {
void showStereo() {
cmode = sm::SIDE | sm::MAYDARK;
gamescreen(0);
using namespace geom3;
dialog::init(XLAT("stereo vision config"));
string modenames[4] = { "OFF", "anaglyph", "side-by-side", "ODS" };
@ -1192,7 +1191,6 @@ void showStereo() {
dialog::display();
keyhandler = [] (int sym, int uni) {
using namespace geom3;
dialog::handleNavigation(sym, uni);
string help3 = XLAT(
@ -1268,37 +1266,36 @@ void add_edit_wall_quality(char c) {
void show3D() {
cmode = sm::SIDE | sm::MAYDARK;
gamescreen(0);
using namespace geom3;
dialog::init(XLAT("3D configuration"));
#if MAXMDIM >= 4
if(WDIM == 2) {
dialog::addBoolItem(XLAT("use the full 3D models"), geom3::always3, 'U');
dialog::addBoolItem(XLAT("use the full 3D models"), vid.always3, 'U');
dialog::add_action(geom3::switch_always3);
}
#endif
if(vid.use_smart_range == 0 && DIM == 2) {
dialog::addSelItem(XLAT("High detail range"), fts(highdetail), 'n');
dialog::addSelItem(XLAT("Mid detail range"), fts(middetail), 'm');
dialog::addSelItem(XLAT("High detail range"), fts(vid.highdetail), 'n');
dialog::addSelItem(XLAT("Mid detail range"), fts(vid.middetail), 'm');
dialog::addBreak(50);
}
if(WDIM == 2) {
dialog::addSelItem(XLAT(GDIM == 2 ? "Camera level above the plane" : "Z shift"), fts(camera), 'c');
dialog::addSelItem(XLAT("Ground level below the plane"), fts(depth), 'g');
dialog::addSelItem(XLAT(GDIM == 2 ? "Camera level above the plane" : "Z shift"), fts(vid.camera), 'c');
dialog::addSelItem(XLAT("Ground level below the plane"), fts(vid.depth), 'g');
dialog::addSelItem(XLAT("Projection at the ground level"), fts(vid.alpha), 'a');
dialog::addBreak(50);
dialog::addSelItem(XLAT("Height of walls"), fts(wall_height), 'w');
dialog::addSelItem(XLAT("Height of walls"), fts(vid.wall_height), 'w');
dialog::addSelItem(XLAT("Rock-III to wall ratio"), fts(rock_wall_ratio), 'r');
dialog::addSelItem(XLAT("Human to wall ratio"), fts(human_wall_ratio), 'h');
dialog::addSelItem(XLAT("Level of water surface"), fts(lake_top), 'l');
dialog::addSelItem(XLAT("Level of water bottom"), fts(lake_bottom), 'k');
dialog::addSelItem(XLAT("Rock-III to wall ratio"), fts(vid.rock_wall_ratio), 'r');
dialog::addSelItem(XLAT("Human to wall ratio"), fts(vid.human_wall_ratio), 'h');
dialog::addSelItem(XLAT("Level of water surface"), fts(vid.lake_top), 'l');
dialog::addSelItem(XLAT("Level of water bottom"), fts(vid.lake_bottom), 'k');
}
else {
dialog::addSelItem(XLAT("Creature scale"), fts(creature_scale), 'c');
dialog::addSelItem(XLAT("Height to width"), fts(height_width), 'h');
dialog::addSelItem(XLAT("Creature scale"), fts(vid.creature_scale), 'c');
dialog::addSelItem(XLAT("Height to width"), fts(vid.height_width), 'h');
menuitem_sightrange('s');
}
@ -1366,8 +1363,8 @@ void show3D() {
dialog::addInfo(XLAT("no 3D effects available in this projection"), 0xC00000);
else if(GDIM == 2 && !spatial_graphics)
dialog::addInfo(XLAT("set 3D monsters or walls in basic config first"));
else if(invalid != "")
dialog::addInfo(XLAT("error: "+invalid), 0xC00000);
else if(geom3::invalid != "")
dialog::addInfo(XLAT("error: "+geom3::invalid), 0xC00000);
else
dialog::addInfo(XLAT("parameters set correctly"));
dialog::addBreak(50);
@ -1380,22 +1377,22 @@ void show3D() {
dialog::handleNavigation(sym, uni);
if(uni == 'n' && DIM == 2) {
dialog::editNumber(geom3::highdetail, 0, 5, .5, 7, XLAT("High detail range"), "");
dialog::editNumber(vid.highdetail, 0, 5, .5, 7, XLAT("High detail range"), "");
dialog::extra_options = explain_detail;
dialog::reaction = [] () {
if(highdetail > middetail) middetail = highdetail;
if(vid.highdetail > vid.middetail) vid.middetail = vid.highdetail;
};
}
else if(uni == 'm' && DIM == 2) {
dialog::editNumber(geom3::middetail, 0, 5, .5, 7, XLAT("Mid detail range"), "");
dialog::editNumber(vid.middetail, 0, 5, .5, 7, XLAT("Mid detail range"), "");
dialog::extra_options = explain_detail;
dialog::reaction = [] () {
if(highdetail > middetail) highdetail = middetail;
if(vid.highdetail > vid.middetail) vid.highdetail = vid.middetail;
};
}
else if(uni == 'c' && WDIM == 2)
tc_camera = ticks,
dialog::editNumber(geom3::camera, 0, 5, .1, 1, XLAT(GDIM == 2 ? "Camera level above the plane" : "Z shift"), ""),
vid.tc_camera = ticks,
dialog::editNumber(vid.camera, 0, 5, .1, 1, XLAT(GDIM == 2 ? "Camera level above the plane" : "Z shift"), ""),
dialog::extra_options = [] {
dialog::addHelp(GDIM == 2 ? XLAT(
"Camera is placed %1 absolute units above a plane P in a three-dimensional "
@ -1404,17 +1401,17 @@ void show3D() {
"other equidistant surface below it) is viewed at an angle of %3 "
"(the tangent of the angle between the point in "
"the center of your vision and a faraway location is 1/cosh(c) = %4).",
fts(camera),
fts(depth),
fts(atan(1/cosh(camera))*2/degree),
fts(1/cosh(camera))) : XLAT("Look from behind."));
fts(vid.camera),
fts(vid.depth),
fts(atan(1/cosh(vid.camera))*2/degree),
fts(1/cosh(vid.camera))) : XLAT("Look from behind."));
if(DIM == 3 && pmodel == mdPerspective) dialog::extra_options = [] () {
dialog::addBoolItem_action(XLAT("reduce if walls on the way"), vid.use_wall_radar, 'R');
};
};
else if(uni == 'g' && WDIM == 2)
tc_depth = ticks,
dialog::editNumber(geom3::depth, 0, 5, .1, 1, XLAT("Ground level below the plane"), ""),
vid.tc_depth = ticks,
dialog::editNumber(vid.depth, 0, 5, .1, 1, XLAT("Ground level below the plane"), ""),
dialog::extra_options = [] {
dialog::addHelp(XLAT(
"Ground level is actually an equidistant surface, "
@ -1430,51 +1427,51 @@ void show3D() {
"distances.)"
,
fts(depth), fts(cosh(depth))));
fts(vid.depth), fts(cosh(vid.depth))));
// mention absolute units
};
else if(uni == 'a' && WDIM == 2)
projectionDialog();
else if(uni == 'w' && WDIM == 2) {
dialog::editNumber(geom3::wall_height, 0, 1, .1, .3, XLAT("Height of walls"), "");
dialog::editNumber(vid.wall_height, 0, 1, .1, .3, XLAT("Height of walls"), "");
dialog::extra_options = [] () {
dialog::addHelp(XLAT(
"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.",
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"), vid.gp_autoscale_heights, 'O');
dialog::add_action([] () {
geom3::gp_autoscale_heights = !geom3::gp_autoscale_heights;
vid.gp_autoscale_heights = !vid.gp_autoscale_heights;
});
};
}
else if(uni == 'l' && WDIM == 2)
dialog::editNumber(geom3::lake_top, 0, 1, .1, .25, XLAT("Level of water surface"), "");
dialog::editNumber(vid.lake_top, 0, 1, .1, .25, XLAT("Level of water surface"), "");
else if(uni == 'k' && WDIM == 2)
dialog::editNumber(geom3::lake_bottom, 0, 1, .1, .9, XLAT("Level of water bottom"), "");
dialog::editNumber(vid.lake_bottom, 0, 1, .1, .9, XLAT("Level of water bottom"), "");
else if(uni == 'r' && WDIM == 2)
dialog::editNumber(geom3::rock_wall_ratio, 0, 1, .1, .9, XLAT("Rock-III to wall ratio"), ""),
dialog::editNumber(vid.rock_wall_ratio, 0, 1, .1, .9, XLAT("Rock-III to wall ratio"), ""),
dialog::extra_options = [] { dialog::addHelp(XLAT(
"The ratio of Rock III to walls is %1, so Rock III are %2 absolute units high. "
"Length of paths on the Rock III level is %3 of the corresponding length on the "
"ground level.",
fts(rock_wall_ratio), fts(wall_height * rock_wall_ratio),
fts(cosh(depth - wall_height * rock_wall_ratio) / cosh(depth))));
fts(vid.rock_wall_ratio), fts(vid.wall_height * vid.rock_wall_ratio),
fts(cosh(vid.depth - vid.wall_height * vid.rock_wall_ratio) / cosh(vid.depth))));
};
else if(uni == 'h' && WDIM == 2)
dialog::editNumber(geom3::human_wall_ratio, 0, 1, .1, .7, XLAT("Human to wall ratio"), ""),
dialog::editNumber(vid.human_wall_ratio, 0, 1, .1, .7, XLAT("Human to wall ratio"), ""),
dialog::extra_options = [] { dialog::addHelp(XLAT(
"Humans are %1 "
"absolute units high. Your head travels %2 times the distance travelled by your "
"feet.",
fts(wall_height * human_wall_ratio),
fts(cosh(depth - wall_height * human_wall_ratio) / cosh(depth)))
fts(vid.wall_height * vid.human_wall_ratio),
fts(cosh(vid.depth - vid.wall_height * vid.human_wall_ratio) / cosh(vid.depth)))
);
};
else if(uni == 'h' && WDIM == 3)
dialog::editNumber(geom3::height_width, 0, 1, .1, .7, XLAT("Height to width"), "");
dialog::editNumber(vid.height_width, 0, 1, .1, .7, XLAT("Height to width"), "");
else if(uni == 'c' && WDIM == 3)
dialog::editNumber(geom3::creature_scale, 0, 1, .1, .7, XLAT("Creature scale"), "");
dialog::editNumber(vid.creature_scale, 0, 1, .1, .7, XLAT("Creature scale"), "");
else if(uni == 'e')
pushScreen(showStereo);
@ -2088,15 +2085,15 @@ unordered_map<string, ld&> params = {
{"ballangle", vid.ballangle},
{"yshift", vid.yshift},
{"cameraangle", vid.camera_angle},
{"depth", geom3::depth},
{"camera", geom3::camera},
{"wall_height", geom3::wall_height},
{"highdetail", geom3::highdetail},
{"middetail", geom3::middetail},
{"rock_wall_ratio", geom3::rock_wall_ratio},
{"human_wall_ratio", geom3::human_wall_ratio},
{"lake_top", geom3::lake_top},
{"lake_bottom", geom3::lake_bottom},
{"depth", vid.depth},
{"camera", vid.camera},
{"wall_height", vid.wall_height},
{"highdetail", vid.highdetail},
{"middetail", vid.middetail},
{"rock_wall_ratio", vid.rock_wall_ratio},
{"human_wall_ratio", vid.human_wall_ratio},
{"lake_top", vid.lake_top},
{"lake_bottom", vid.lake_bottom},
#if CAP_RUG
{"rug_model_distance", rug::model_distance},
#endif

View File

@ -613,7 +613,7 @@ namespace dialog {
numberEditor ne;
bool editingDetail() {
return ne.editwhat == &geom3::highdetail || ne.editwhat == &geom3::middetail;
return ne.editwhat == &vid.highdetail || ne.editwhat == &vid.middetail;
}
int ldtoint(ld x) {

View File

@ -971,11 +971,11 @@ void make_floor_textures() {
dynamicval<eGeometry> g(geometry, gEuclidSquare);
dynamicval<eModel> gm(pmodel, mdDisk);
dynamicval<eVariation> va(variation, eVariation::pure);
dynamicval<bool> a3(geom3::always3, false);
dynamicval<bool> a3(vid.always3, false);
dynamicval<bool> hq(inHighQual, true);
dynamicval<int> hd(darken, 0);
dynamicval<ld> gd(geom3::depth, 1);
dynamicval<ld> gc(geom3::camera, 1);
dynamicval<ld> gd(vid.depth, 1);
dynamicval<ld> gc(vid.camera, 1);
dynamicval<geometry_information*> dcgip(cgip, cgip);
check_cgi();
cgi.make_floor_textures_here();

View File

@ -142,10 +142,10 @@ void geometry_information::prepare_basics() {
scalefactor = crossf / hcrossf7;
orbsize = crossf;
if(WDIM == 3) scalefactor *= geom3::creature_scale;
if(WDIM == 3) scalefactor *= vid.creature_scale;
zhexf = BITRUNCATED ? hexf : crossf* .55;
if(WDIM == 3) zhexf *= geom3::creature_scale;
if(WDIM == 3) zhexf *= vid.creature_scale;
if(WDIM == 2 && GDIM == 3) zhexf *= 1.5, orbsize *= 1.2;
floorrad0 = hexvdist* (GDIM == 3 ? 1 : 0.92);
@ -176,21 +176,6 @@ transmatrix xspinpush(ld dir, ld dist) {
purehookset hooks_swapdim;
namespace geom3 {
bool always3 = false;
int tc_alpha=3, tc_depth=1, tc_camera=2;
ld depth = 1; // world below the plane
ld camera = 1; // camera above the plane
ld wall_height = .3;
ld lake_top = .25, lake_bottom = .9;
ld rock_wall_ratio = .9;
ld human_wall_ratio = .7;
bool gp_autoscale_heights = true;
ld creature_scale, height_width;
ld highdetail = 8, middetail = 8;
// Here we convert between the following parameters:
@ -200,18 +185,18 @@ namespace geom3 {
// factor: zoom factor
ld abslev_to_projection(ld abslev) {
if(sphere || euclid) return camera+abslev;
return tanh(abslev) / tanh(camera);
if(sphere || euclid) return vid.camera+abslev;
return tanh(abslev) / tanh(vid.camera);
}
ld projection_to_abslev(ld proj) {
if(sphere || euclid) return proj-camera;
if(sphere || euclid) return proj-vid.camera;
// tanh(abslev) / tanh(camera) = proj
return atanh(proj * tanh(camera));
return atanh(proj * tanh(vid.camera));
}
ld lev_to_projection(ld lev) {
return abslev_to_projection(depth - lev);
return abslev_to_projection(vid.depth - lev);
}
ld projection_to_factor(ld proj) {
@ -224,28 +209,28 @@ namespace geom3 {
ld lev_to_factor(ld lev) {
if(WDIM == 3) return lev;
if(GDIM == 3) return depth - lev;
if(GDIM == 3) return vid.depth - lev;
return projection_to_factor(lev_to_projection(lev));
}
ld factor_to_lev(ld fac) {
if(DIM == 3) return fac;
return depth - projection_to_abslev(factor_to_projection(fac));
return vid.depth - projection_to_abslev(factor_to_projection(fac));
}
// how should we scale at level lev
ld scale_at_lev(ld lev) {
if(sphere || euclid) return 1;
return cosh(depth - lev);
return cosh(vid.depth - lev);
}
string invalid;
ld actual_wall_height() {
#if CAP_GP
if(GOLDBERG && gp_autoscale_heights)
return wall_height * min<ld>(4 / hypot_d(2, gp::next), 1);
if(GOLDBERG && vid.gp_autoscale_heights)
return vid.wall_height * min<ld>(4 / hypot_d(2, gp::next), 1);
#endif
return wall_height;
return vid.wall_height;
}
}
@ -256,17 +241,17 @@ namespace geom3 {
invalid = "";
if(GDIM == 3) ;
else if(tc_alpha < tc_depth && tc_alpha < tc_camera)
vid.alpha = tan_auto(depth) / tan_auto(camera);
else if(tc_depth < tc_alpha && tc_depth < tc_camera) {
ld v = vid.alpha * tan_auto(camera);
if(hyperbolic && (v<1e-6-12 || v>1-1e-12)) invalid = "cannot adjust depth", depth = camera;
else depth = atan_auto(v);
else if(vid.tc_alpha < vid.tc_depth && vid.tc_alpha < vid.tc_camera)
vid.alpha = tan_auto(vid.depth) / tan_auto(vid.camera);
else if(vid.tc_depth < vid.tc_alpha && vid.tc_depth < vid.tc_camera) {
ld v = vid.alpha * tan_auto(vid.camera);
if(hyperbolic && (v<1e-6-12 || v>1-1e-12)) invalid = "cannot adjust depth", vid.depth = vid.camera;
else vid.depth = atan_auto(v);
}
else {
ld v = tan_auto(depth) / vid.alpha;
if(hyperbolic && (v<1e-12-1 || v>1-1e-12)) invalid = "cannot adjust camera", camera = depth;
else camera = atan_auto(v);
ld v = tan_auto(vid.depth) / vid.alpha;
if(hyperbolic && (v<1e-12-1 || v>1-1e-12)) invalid = "cannot adjust camera", vid.camera = vid.depth;
else vid.camera = atan_auto(v);
}
if(fabs(vid.alpha) < 1e-6) invalid = "does not work with perfect Klein";
@ -305,13 +290,13 @@ namespace geom3 {
BIRD = 1.20;
}
else {
INFDEEP = GDIM == 3 ? (sphere ? M_PI/2 : +5) : (euclid || sphere) ? 0.01 : lev_to_projection(0) * tanh(camera);
INFDEEP = GDIM == 3 ? (sphere ? M_PI/2 : +5) : (euclid || sphere) ? 0.01 : lev_to_projection(0) * tanh(vid.camera);
ld wh = actual_wall_height();
WALL = lev_to_factor(wh);
FLOOR = lev_to_factor(0);
human_height = human_wall_ratio * wh;
if(WDIM == 3) human_height = scalefactor * height_width / 2;
human_height = vid.human_wall_ratio * wh;
if(WDIM == 3) human_height = scalefactor * vid.height_width / 2;
ld reduce = (WDIM == 3 ? human_height / 2 : 0);
@ -341,19 +326,19 @@ namespace geom3 {
ALEG0 = lev_to_factor(human_height * .0 - reduce);
ALEG = lev_to_factor(human_height * .2 - reduce);
AHEAD = lev_to_factor(human_height * .6 - reduce);
BIRD = lev_to_factor(WDIM == 3 ? 0 : (human_wall_ratio+1)/2 * wh * .8);
BIRD = lev_to_factor(WDIM == 3 ? 0 : (vid.human_wall_ratio+1)/2 * wh * .8);
GHOST = lev_to_factor(WDIM == 3 ? 0 : human_height * .5);
FLATEYE = lev_to_factor(human_height * .15);
slev = rock_wall_ratio * wh / 3;
slev = vid.rock_wall_ratio * wh / 3;
for(int s=0; s<=3; s++)
SLEV[s] = lev_to_factor(rock_wall_ratio * wh * s/3);
LAKE = lev_to_factor(-lake_top);
HELLSPIKE = lev_to_factor(-(lake_top+lake_bottom)/2);
BOTTOM = lev_to_factor(-lake_bottom);
LOWSKY = lev_to_factor((1 + rock_wall_ratio) * wh);
SLEV[s] = lev_to_factor(vid.rock_wall_ratio * wh * s/3);
LAKE = lev_to_factor(-vid.lake_top);
HELLSPIKE = lev_to_factor(-(vid.lake_top+vid.lake_bottom)/2);
BOTTOM = lev_to_factor(-vid.lake_bottom);
LOWSKY = lev_to_factor((1 + vid.rock_wall_ratio) * wh);
HIGH = LOWSKY;
HIGH2 = lev_to_factor((2 + rock_wall_ratio) * wh);
HIGH2 = lev_to_factor((2 + vid.rock_wall_ratio) * wh);
SKY = LOWSKY - 5;
}
}
@ -363,7 +348,7 @@ namespace geom3 {
void switch_always3() {
if(dual::split(switch_always3)) return;
if(rug::rugged) rug::close();
geom3::always3 = !geom3::always3;
vid.always3 = !vid.always3;
swapmatrix(View);
callhooks(hooks_swapdim);
}
@ -395,20 +380,20 @@ void switch_always3() {
if(rug::rugged) rug::close();
if(dual::split(switch_fpp)) return;
check_cgi(); cgi.require_basics();
if(!geom3::always3) {
geom3::always3 = true;
if(!vid.always3) {
vid.always3 = true;
ld ms = min<ld>(cgi.scalefactor, 1);
geom3::wall_height = 1.5 * ms;
vid.wall_height = 1.5 * ms;
if(sphere) {
geom3::depth = M_PI / 6;
geom3::wall_height = M_PI / 3;
vid.depth = M_PI / 6;
vid.wall_height = M_PI / 3;
}
geom3::human_wall_ratio = 0.8;
vid.human_wall_ratio = 0.8;
if(euclid && allowIncreasedSight() && vid.use_smart_range == 0) {
genrange_bonus = gamerange_bonus = sightrange_bonus = cgi.base_distlimit * 3/2;
}
geom3::camera = 0;
geom3::depth = ms;
vid.camera = 0;
vid.depth = ms;
if(pmodel == mdDisk) pmodel = mdPerspective;
swapmatrix(View);
callhooks(hooks_swapdim);
@ -417,11 +402,11 @@ void switch_always3() {
#endif
}
else {
geom3::always3 = false;
geom3::wall_height = .3;
geom3::human_wall_ratio = .7;
geom3::camera = 1;
geom3::depth = 1;
vid.always3 = false;
vid.wall_height = .3;
vid.human_wall_ratio = .7;
vid.camera = 1;
vid.depth = 1;
if(pmodel == mdPerspective) pmodel = mdDisk;
swapmatrix(View);
callhooks(hooks_swapdim);
@ -452,24 +437,24 @@ void check_cgi() {
if(binarytiling) V("BT", fts(vid.binary_width));
if(GDIM == 2) {
V("CAMERA", fts(geom3::camera));
V("CAMERA", fts(vid.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("WH", fts(vid.wall_height));
V("HW", fts(vid.human_wall_ratio));
V("RW", fts(vid.rock_wall_ratio));
V("DEPTH", fts(vid.depth));
V("ASH", ONOFF(vid.gp_autoscale_heights));
V("LT", fts(vid.lake_top));
V("LB", fts(vid.lake_bottom));
}
V("3D", ONOFF(geom3::always3));
V("3D", ONOFF(vid.always3));
if(WDIM == 3) {
V("CS", fts(geom3::creature_scale));
V("HTW", fts(geom3::height_width));
V("CS", fts(vid.creature_scale));
V("HTW", fts(vid.height_width));
}
V("LQ", its(vid.linequality));

View File

@ -19,7 +19,7 @@ int detaillevel = 0;
bool first_cell_to_draw = true;
bool hide_player() {
return DIM == 3 && playermoved && vid.yshift == 0 && vid.sspeed > -5 && pmodel == mdPerspective && (first_cell_to_draw || elliptic) && (WDIM == 3 || geom3::camera == 0) && !inmirrorcount
return DIM == 3 && playermoved && vid.yshift == 0 && vid.sspeed > -5 && pmodel == mdPerspective && (first_cell_to_draw || elliptic) && (WDIM == 3 || vid.camera == 0) && !inmirrorcount
&& !(racing::on && !racing::standard_centering && !racing::player_relative);
}
@ -92,8 +92,6 @@ bool doHighlight() {
return (hiliteclick && darken < 2) ? !mmhigh : mmhigh;
}
eModel pmodel = mdDisk;
int dlit;
ld spina(cell *c, int dir) {
@ -3850,18 +3848,18 @@ void escherSidewall(cell *c, int sidepar, const transmatrix& V, color_t col) {
else if(sidepar == SIDE_LAKE) {
const int layers = 1 << (detaillevel-1);
if(detaillevel) for(int z=0; z<layers; z++)
draw_qfi(c, mscale(V, zgrad0(-geom3::lake_top, 0, z, layers)), col, PPR::FLOOR+z-layers);
draw_qfi(c, mscale(V, zgrad0(-vid.lake_top, 0, z, layers)), col, PPR::FLOOR+z-layers);
}
else if(sidepar == SIDE_LTOB) {
const int layers = 1 << (detaillevel-1);
if(detaillevel) for(int z=0; z<layers; z++)
draw_qfi(c, mscale(V, zgrad0(-geom3::lake_bottom, -geom3::lake_top, z, layers)), col, PPR::INLAKEWALL+z-layers);
draw_qfi(c, mscale(V, zgrad0(-vid.lake_bottom, -vid.lake_top, z, layers)), col, PPR::INLAKEWALL+z-layers);
}
else if(sidepar == SIDE_BTOI) {
const int layers = 1 << detaillevel;
draw_qfi(c, mscale(V, cgi.INFDEEP), col, PPR::MINUSINF);
for(int z=1; z<layers; z++)
draw_qfi(c, mscale(V, zgrad0(-geom3::lake_bottom, -geom3::lake_top, -z, 1)), col, PPR::LAKEBOTTOM+z-layers);
draw_qfi(c, mscale(V, zgrad0(-vid.lake_bottom, -vid.lake_top, -z, 1)), col, PPR::LAKEBOTTOM+z-layers);
}
}
@ -3979,12 +3977,12 @@ void pushdown(cell *c, int& q, const transmatrix &V, double down, bool rezoom, b
* inverse(V) * ptd.V;
if(!repriority) ;
else if(nlev < -geom3::lake_bottom-1e-3) {
else if(nlev < -vid.lake_bottom-1e-3) {
ptd.prio = PPR::BELOWBOTTOM_FALLANIM;
if(c->wall != waChasm)
ptd.color = 0; // disappear!
}
else if(nlev < -geom3::lake_top-1e-3)
else if(nlev < -vid.lake_top-1e-3)
ptd.prio = PPR::INLAKEWALL_FALLANIM;
else if(nlev < 0)
ptd.prio = PPR::LAKEWALL_FALLANIM;
@ -4808,8 +4806,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
ld dist0 = hdist0(tC0(V)) - 1e-6;
if(vid.use_smart_range) detaillevel = 2;
else if(dist0 < geom3::highdetail) detaillevel = 2;
else if(dist0 < geom3::middetail) detaillevel = 1;
else if(dist0 < vid.highdetail) detaillevel = 2;
else if(dist0 < vid.middetail) detaillevel = 1;
else detaillevel = 0;
#ifdef BUILDZEBRA
@ -5618,8 +5616,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if((cmode & sm::NUMBER) && (dialog::editingDetail())) {
color_t col =
dist0 < geom3::highdetail ? 0xFF80FF80 :
dist0 >= geom3::middetail ? 0xFFFF8080 :
dist0 < vid.highdetail ? 0xFF80FF80 :
dist0 >= vid.middetail ? 0xFFFF8080 :
0XFFFFFF80;
#if 1
queuepoly(V, cgi.shHeptaMarker, darkena(col & 0xFFFFFF, 0, 0xFF));
@ -5950,7 +5948,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
dynamicval<const hpcshape*> ds(qfi.shape, &cgi.shCircleFloor);
dynamicval<transmatrix> dss(qfi.spin, Id);
for(int z=1; z<layers; z++) {
double zg = zgrad0(-geom3::lake_top, geom3::actual_wall_height(), z, layers);
double zg = zgrad0(-vid.lake_top, geom3::actual_wall_height(), z, layers);
draw_qfi(c, xyzscale(V, zg*(layers-z)/layers, zg),
darkena(gradient(0, wcol, -layers, z, layers), 0, 0xFF), PPR::WALL3+z-layers+2);
}
@ -6785,7 +6783,7 @@ void make_actual_view() {
if(vid.yshift && WDIM == 2) actual_view_transform = ypush(vid.yshift) * actual_view_transform;
#if MAXMDIM >= 4
if(GDIM == 3) {
ld max = WDIM == 2 ? geom3::camera : vid.yshift;
ld max = WDIM == 2 ? vid.camera : vid.yshift;
if(max)
actual_view_transform = zpush(wall_radar(viewctr.at->c7, inverse(View), max)) * actual_view_transform;
camera_level = asin_auto(tC0(inverse(actual_view_transform * View))[2]);

View File

@ -360,7 +360,7 @@ void draw_radar(bool cornermode) {
dynamicval<eGeometry> g(geometry, gEuclid);
dynamicval<eModel> pm(pmodel, mdUnchanged);
dynamicval<bool> ga(geom3::always3, false);
dynamicval<bool> ga(vid.always3, false);
initquickqueue();
int rad = vid.radarsize;

243
hyper.h
View File

@ -190,19 +190,143 @@ typedef long double ld;
typedef complex<ld> cld;
struct charstyle {
int charid;
color_t skincolor, haircolor, dresscolor, swordcolor, dresscolor2, uicolor, eyecolor;
bool lefthanded;
};
static const int MAXPLAYER = 7;
static const int MAXJOY = 8;
static const int MAXBUTTON = 64;
static const int MAXAXE = 16;
static const int MAXHAT = 4;
namespace multi {
struct config {
char keyaction[512];
char joyaction[MAXJOY][MAXBUTTON];
char axeaction[MAXJOY][MAXAXE];
char hataction[MAXJOY][MAXHAT][4];
int deadzoneval[MAXJOY][MAXAXE];
};
}
enum eStereo { sOFF, sAnaglyph, sLR, sODS };
struct videopar {
ld scale, alpha, sspeed, mspeed, yshift, camera_angle;
ld ballangle, ballproj, euclid_to_sphere, twopoint_param, stretch, binary_width, fixed_facing_dir;
int mobilecompasssize;
int radarsize; // radar for 3D geometries
int aurastr, aurasmoothen;
bool fixed_facing;
bool fixed_yz;
bool use_wall_radar;
int linequality;
bool full;
int graphglyph; // graphical glyphs
bool darkhepta;
int shifttarget;
int xres, yres, framelimit;
int xscr, yscr;
ld xposition, yposition;
bool grid;
int particles;
int fsize;
int flashtime;
int wallmode, monmode, axes;
bool revcontrol;
int msgleft, msglimit;
bool usingGL;
int antialias;
#define AA_NOGL 1
#define AA_VERSION 2
#define AA_LINES 4
#define AA_POLY 8
#define AA_LINEWIDTH 16
#define AA_FONT 32
#define AA_MULTI 64
#define AA_MULTI16 128 // not configurable
ld linewidth;
int joyvalue, joyvalue2, joypanthreshold;
ld joypanspeed;
charstyle cs;
bool samegender; // same gender for the Princess?
int language;
bool backeffects; // background particle effects
int killreduction, itemreduction, portreduction;
multi::config scfg;
int steamscore;
bool drawmousecircle; // draw the circle around the mouse
bool skipstart; // skip the start menu
bool quickmouse; // quick mouse on the map
bool sloppy_3d; // make 3D faster but ugly
int timeformat; // time format used in the message log
int use_smart_range; // 0 = distance-based, 1 = model-based, 2 = model-based and generate
ld smart_range_detail;// minimum visible cell for modes 1 and 2
ld smart_range_detail_3;// minimum visible cell in 3D (for mode 2, there is no mode 1)
int cells_drawn_limit;
int cells_generated_limit; // limit on cells generated per frame
ld skiprope;
eStereo stereo_mode;
ld ipd;
ld lr_eyewidth, anaglyph_eyewidth;
ld fov;
bool consider_shader_projection;
int desaturate;
int texture_step;
bool always3; // always use the 3D engine
ld depth; // world level below the plane
ld camera; // camera level above the plane
ld wall_height, creature_scale, height_width;
eModel vpmodel;
ld lake_top, lake_bottom;
ld rock_wall_ratio;
ld human_wall_ratio;
int tc_alpha, tc_depth, tc_camera;
ld highdetail, middetail;
bool gp_autoscale_heights;
};
extern videopar vid;
#if MAXMDIM == 3
#define WDIM 2
#else
#define WDIM ((geometry >= gBinary3) ? 3 : 2)
#endif
#define GDIM (geom3::always3 ? 3 : WDIM)
#define GDIM (vid.always3 ? 3 : WDIM)
#define DIM GDIM
#define MDIM (DIM+1)
extern array<ld, gGUARD> sightranges;
namespace geom3 { extern bool always3; }
struct hyperpoint : array<ld, MAXMDIM> {
hyperpoint() {}
@ -831,22 +955,9 @@ void activateActiv(cell *c, bool msg);
// shmup
struct charstyle {
int charid;
color_t skincolor, haircolor, dresscolor, swordcolor, dresscolor2, uicolor, eyecolor;
bool lefthanded;
};
string csname(charstyle& cs);
void initcs(charstyle& cs);
#define MAXPLAYER 7
#define MAXJOY 8
#define MAXBUTTON 64
#define MAXAXE 16
#define MAXHAT 4
extern bool flipplayer;
namespace multi {
@ -869,14 +980,6 @@ namespace multi {
// treasure collection, kill, and death statistics
extern int treasures[MAXPLAYER], kills[MAXPLAYER], deaths[MAXPLAYER];
struct config {
char keyaction[512];
char joyaction[MAXJOY][MAXBUTTON];
char axeaction[MAXJOY][MAXAXE];
char hataction[MAXJOY][MAXHAT][4];
int deadzoneval[MAXJOY][MAXAXE];
};
void saveConfig(FILE *f);
void loadConfig(FILE *f);
void initConfig();
@ -1075,8 +1178,6 @@ extern reaction_t help_delegate;
#define HELPFUN(x) (help_delegate = x, "HELPFUN")
enum eStereo { sOFF, sAnaglyph, sLR, sODS };
struct radarpoint {
hyperpoint h;
char glyph;
@ -1086,93 +1187,6 @@ struct radarpoint {
extern vector<radarpoint> radarpoints;
struct videopar {
ld scale, alpha, sspeed, mspeed, yshift, camera_angle;
ld ballangle, ballproj, euclid_to_sphere, twopoint_param, stretch, binary_width, fixed_facing_dir;
int mobilecompasssize;
int radarsize; // radar for 3D geometries
int aurastr, aurasmoothen;
bool fixed_facing;
bool fixed_yz;
bool use_wall_radar;
int linequality;
bool full;
int graphglyph; // graphical glyphs
bool darkhepta;
int shifttarget;
int xres, yres, framelimit;
int xscr, yscr;
ld xposition, yposition;
bool grid;
int particles;
int fsize;
int flashtime;
int wallmode, monmode, axes;
bool revcontrol;
int msgleft, msglimit;
bool usingGL;
int antialias;
#define AA_NOGL 1
#define AA_VERSION 2
#define AA_LINES 4
#define AA_POLY 8
#define AA_LINEWIDTH 16
#define AA_FONT 32
#define AA_MULTI 64
#define AA_MULTI16 128 // not configurable
ld linewidth;
int joyvalue, joyvalue2, joypanthreshold;
ld joypanspeed;
charstyle cs;
bool samegender; // same gender for the Princess?
int language;
bool backeffects; // background particle effects
int killreduction, itemreduction, portreduction;
multi::config scfg;
int steamscore;
bool drawmousecircle; // draw the circle around the mouse
bool skipstart; // skip the start menu
bool quickmouse; // quick mouse on the map
bool sloppy_3d; // make 3D faster but ugly
int timeformat; // time format used in the message log
int use_smart_range; // 0 = distance-based, 1 = model-based, 2 = model-based and generate
ld smart_range_detail;// minimum visible cell for modes 1 and 2
ld smart_range_detail_3;// minimum visible cell in 3D (for mode 2, there is no mode 1)
int cells_drawn_limit;
int cells_generated_limit; // limit on cells generated per frame
ld skiprope;
eStereo stereo_mode;
ld ipd;
ld lr_eyewidth, anaglyph_eyewidth;
ld fov;
bool consider_shader_projection;
int desaturate;
int texture_step;
};
extern videopar vid;
extern vector< function<void()> > screens;
template<class T> void pushScreen(const T& x) { screens.push_back(x); }
@ -2287,7 +2301,7 @@ void setcameraangle(bool b);
void drawShape(pair<ld,ld>* coords, int qty, color_t color);
extern eModel pmodel;
#define pmodel (vid.vpmodel)
string current_proj_name();
inline bool mdAzimuthalEqui() { return among(pmodel, mdEquidistant, mdEquiarea, mdEquivolume); }
@ -4619,7 +4633,6 @@ namespace gamestack {
}
namespace geom3 {
extern ld depth, camera, wall_height, creature_scale, height_width;
void switch_always3();
void switch_fpp();
void switch_tpp();

View File

@ -94,7 +94,7 @@ hyperpoint gethyper(ld x, ld y) {
}
void ballmodel(hyperpoint& ret, double alpha, double d, double zl) {
hyperpoint H = ypush(geom3::camera) * xpush(d) * ypush(zl) * C0;
hyperpoint H = ypush(vid.camera) * xpush(d) * ypush(zl) * C0;
ld tzh = vid.ballproj + H[DIM];
ld ax = H[0] / tzh;
ld ay = H[1] / tzh;
@ -280,7 +280,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
case mdBall: {
ld zlev = find_zlev(H);
ld zl = geom3::depth-geom3::factor_to_lev(zlev);
ld zl = vid.depth-geom3::factor_to_lev(zlev);
ballmodel(ret, atan2(H), hdist0(H), zl);
break;
@ -588,14 +588,14 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
case mdRotatedHyperboles: {
// ld zlev = <- not implemented
find_zlev(H); // + geom3::depth;
find_zlev(H); // + vid.depth;
conformal::apply_orientation(H[0], H[1]);
ld y = asin_auto(H[1]);
ld x = asin_auto_clamp(H[0] / cos_auto(y));
// ld z = zlev == 1 ? 0 : geom3::factor_to_lev(zlev);
ld factor = geom3::lev_to_factor(y + geom3::depth);
ld factor = geom3::lev_to_factor(y + vid.depth);
ret[0] = sinh(x) * factor;
ret[1] = cosh(x) * factor;
@ -1263,12 +1263,12 @@ void ballgeometry() {
for(double d=10; d>=-10; d-=.2)
addball(0, d, 0);
for(double d=-10; d<=10; d+=.2)
addball(0, d, geom3::depth);
addball(0, 0, -geom3::camera);
addball(0, 0, geom3::depth);
addball(0, 0, -geom3::camera);
addball(0, d, vid.depth);
addball(0, 0, -vid.camera);
addball(0, 0, vid.depth);
addball(0, 0, -vid.camera);
addball(0, -10, 0);
addball(0, 0, -geom3::camera);
addball(0, 0, -vid.camera);
queuecurve(darkena(0xFF, 0, 0x80), 0, PPR::CIRCLE);
queuereset(pmodel, PPR::CIRCLE);
}

View File

@ -206,7 +206,7 @@ namespace mapstream {
int32_t id = cellids.count(cwt.at) ? cellids[cwt.at] : -1;
f.write(id);
f.write(geom3::always3);
f.write(vid.always3);
f.write(mutantphase);
f.write(rosewave);
f.write(rosephase);
@ -441,8 +441,8 @@ namespace mapstream {
savecount = 0; savetime = 0;
cheater = 1;
dynamicval<bool> a3(geom3::always3, geom3::always3);
if(f.vernum >= 0xA616) f.read(geom3::always3);
dynamicval<bool> a3(vid.always3, vid.always3);
if(f.vernum >= 0xA616) f.read(vid.always3);
if(f.vernum < 0xA61A) load_usershapes(f);

View File

@ -1201,7 +1201,7 @@ void fib_ghosts() {
reaction_t current = null_animation;
void pick() {
if(((gold() > 0 || tkills() > 0) && canmove) || geometry != gNormal || ISWEB || ISMOBILE || geom3::always3 || pmodel || rug::rugged) {
if(((gold() > 0 || tkills() > 0) && canmove) || geometry != gNormal || ISWEB || ISMOBILE || vid.always3 || pmodel || rug::rugged) {
current = null_animation;
return;
}