1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 17:10:36 +00:00

3D:: sightranges are now configurable

This commit is contained in:
? 2019-02-25 17:21:53 +01:00 committed by Zeno Rogue
parent 46250081ec
commit fb71d4fd15
6 changed files with 35 additions and 21 deletions

View File

@ -209,6 +209,8 @@ glhr::glmatrix model_orientation_gl() {
void display_data::set_projection(int ed, bool apply_models) {
DEBB(DF_GRAPH, (debugfile,"current_display->set_projection\n"));
bool dim3 = false;
shaderside_projection = false;
glhr::new_shader_projection = glhr::shader_projection::standard;
if(vid.consider_shader_projection) {
@ -229,6 +231,7 @@ void display_data::set_projection(int ed, bool apply_models) {
if(spherephase == 2) glhr::new_shader_projection = glhr::shader_projection::standardS32;
if(spherephase == 3) glhr::new_shader_projection = glhr::shader_projection::standardS33;
}
if(DIM == 3 && apply_models) dim3 = true;
}
start_projection(ed, shaderside_projection);
@ -267,8 +270,8 @@ void display_data::set_projection(int ed, bool apply_models) {
current_display->scrdist_text = cd->ysize * sc / 2;
if(glhr::new_shader_projection == glhr::shader_projection::standardH3) {
glhr::fog_max(1/binary::btrange);
if(dim3) {
glhr::fog_max(1/sightranges[geometry]);
}
if(glhr::new_shader_projection == glhr::shader_projection::band) {

View File

@ -211,7 +211,6 @@ namespace binary {
direct_tmatrix[7] = parabolic3(0, +2);
for(int i=0; i<8; i++)
inverse_tmatrix[i] = inverse(direct_tmatrix[i]);
btrange_cosh = cosh(btrange);
}
const transmatrix& tmatrix(heptagon *h, int dir) {
@ -265,8 +264,6 @@ namespace binary {
return hr::parabolic13(y * co, z * co);
}
ld btrange = 3, btrange_cosh;
void draw() {
dq::visited.clear();
dq::enqueue(viewctr.at, cview());
@ -342,10 +339,6 @@ auto bt_config = addHook(hooks_args, 0, [] () {
shift_arg_formula(vid.binary_width, delayed_geo_reset);
return 0;
}
else if(argis("-btrange")) {
shift_arg_formula(btrange, delayed_geo_reset);
return 0;
}
return 1;
});
#endif

View File

@ -6,6 +6,8 @@ namespace hr {
const char *conffile = "hyperrogue.ini";
array<ld, gGUARD> sightranges;
videopar vid;
#define DEFAULT_WALLMODE (ISMOBILE ? 3 : 5)
@ -355,6 +357,10 @@ void initConfig() {
addsaver(conformal::formula, "formula");
addsaverenum(conformal::basic_model, "basic model");
addsaver(conformal::use_atan, "use_atan");
addsaver(sightranges[gBinary3], "sight-binary3", 3);
addsaver(sightranges[gCubeTiling], "sight-cubes", 7);
addsaver(sightranges[gCell120], "sight-120cell", 2 * M_PI);
addsaver(vid.consider_shader_projection, "shader-projection", true);
@ -733,11 +739,21 @@ void edit_sightrange() {
}
void menuitem_sightrange(char c) {
if(vid.use_smart_range)
dialog::addSelItem(XLAT("minimum visible cell in pixels"), fts(vid.smart_range_detail), c);
else
dialog::addSelItem(XLAT("sight range"), its(sightrange_bonus), c);
dialog::add_action(edit_sightrange);
if(DIM == 3) {
dialog::addSelItem(XLAT("3D sight range"), fts(sightranges[geometry]), c);
dialog::add_action([] {
dialog::editNumber(sightranges[geometry], 0, 2 * M_PI, 0.5, M_PI, XLAT("sight range"),
XLAT("Affects both the generation and the fog effect.")
);
});
}
else {
if(vid.use_smart_range)
dialog::addSelItem(XLAT("minimum visible cell in pixels"), fts(vid.smart_range_detail), c);
else
dialog::addSelItem(XLAT("sight range"), its(sightrange_bonus), c);
dialog::add_action(edit_sightrange);
}
}
void showGraphConfig() {

View File

@ -196,6 +196,8 @@ typedef complex<ld> cld;
#endif
#define MDIM (DIM+1)
extern array<ld, gGUARD> sightranges;
struct hyperpoint : array<ld, MAXDIM> {
hyperpoint() {}

View File

@ -1601,8 +1601,8 @@ bool do_draw(cell *c) {
bool do_draw(cell *c, const transmatrix& T) {
if(DIM == 3) {
if(hyperbolic && T[DIM][DIM] > binary::btrange_cosh) return false;
if(euclid && hypot_d(tC0(T), 3) > 7) return false;
if(hyperbolic && T[DIM][DIM] > cosh(sightranges[geometry])) return false;
if(euclid && hypot_d(tC0(T), 3) > sightranges[geometry]) return false;
setdist(c, 7, c);
return true;
}

View File

@ -564,12 +564,12 @@ void init() {
s3, "vec4 t = uMV * aPosition;",
sh3, "vColor.xyz = vColor.xyz * (1.0 - acosh(t[3]) / uFog);",
sr3, "vColor.xyz = vColor.xyz * (1.0 - sqrt(t[0]*t[0] + t[1]*t[1] + t[2]*t[2]) / 7.);",
sr3, "vColor.xyz = vColor.xyz * (1.0 - sqrt(t[0]*t[0] + t[1]*t[1] + t[2]*t[2]) / uFog);",
ss30, "vColor.xyz = vColor.xyz * (acos(t[3]) / 6.3); t = -t; ",
ss31, "vColor.xyz = vColor.xyz * (acos(t[3]) / 6.3); t.xyz = -t.xyz; ",
ss32, "vColor.xyz = vColor.xyz * (1.0 - acos(t[3]) / 6.3); t.w = -t.w; ",
ss33, "vColor.xyz = vColor.xyz * (1.0 - acos(t[3]) / 6.3); ",
ss30, "vColor.xyz = vColor.xyz * (1 - (6.284 - acos(t[3])) / uFog); t = -t; ",
ss31, "vColor.xyz = vColor.xyz * (1 - (6.284 - acos(t[3])) / uFog); t.xyz = -t.xyz; ",
ss32, "vColor.xyz = vColor.xyz * (1 - acos(t[3]) / uFog); t.w = -t.w; ", // 2pi
ss33, "vColor.xyz = vColor.xyz * (1 - acos(t[3]) / uFog); ",
sh3 || sr3,"t[3] = 1.0;",
band || hp || s3,"gl_Position = uP * t;",