mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 14:02:59 +00:00 
			
		
		
		
	3D:: sightranges are now configurable
This commit is contained in:
		| @@ -209,6 +209,8 @@ glhr::glmatrix model_orientation_gl() { | |||||||
| void display_data::set_projection(int ed, bool apply_models) { | void display_data::set_projection(int ed, bool apply_models) { | ||||||
|   DEBB(DF_GRAPH, (debugfile,"current_display->set_projection\n")); |   DEBB(DF_GRAPH, (debugfile,"current_display->set_projection\n")); | ||||||
|    |    | ||||||
|  |   bool dim3 = false; | ||||||
|  |    | ||||||
|   shaderside_projection = false; |   shaderside_projection = false; | ||||||
|   glhr::new_shader_projection = glhr::shader_projection::standard; |   glhr::new_shader_projection = glhr::shader_projection::standard; | ||||||
|   if(vid.consider_shader_projection) { |   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 == 2) glhr::new_shader_projection = glhr::shader_projection::standardS32; | ||||||
|       if(spherephase == 3) glhr::new_shader_projection = glhr::shader_projection::standardS33; |       if(spherephase == 3) glhr::new_shader_projection = glhr::shader_projection::standardS33; | ||||||
|       } |       } | ||||||
|  |     if(DIM == 3 && apply_models) dim3 = true; | ||||||
|     } |     } | ||||||
|    |    | ||||||
|   start_projection(ed, shaderside_projection); |   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; |     current_display->scrdist_text = cd->ysize * sc / 2; | ||||||
|  |  | ||||||
|     if(glhr::new_shader_projection == glhr::shader_projection::standardH3) { |     if(dim3) { | ||||||
|       glhr::fog_max(1/binary::btrange); |       glhr::fog_max(1/sightranges[geometry]); | ||||||
|       } |       } | ||||||
|      |      | ||||||
|     if(glhr::new_shader_projection == glhr::shader_projection::band) { |     if(glhr::new_shader_projection == glhr::shader_projection::band) { | ||||||
|   | |||||||
| @@ -211,7 +211,6 @@ namespace binary { | |||||||
|     direct_tmatrix[7] = parabolic3(0, +2); |     direct_tmatrix[7] = parabolic3(0, +2); | ||||||
|     for(int i=0; i<8; i++) |     for(int i=0; i<8; i++) | ||||||
|       inverse_tmatrix[i] = inverse(direct_tmatrix[i]); |       inverse_tmatrix[i] = inverse(direct_tmatrix[i]); | ||||||
|     btrange_cosh = cosh(btrange); |  | ||||||
|     } |     } | ||||||
|    |    | ||||||
|   const transmatrix& tmatrix(heptagon *h, int dir) { |   const transmatrix& tmatrix(heptagon *h, int dir) { | ||||||
| @@ -265,8 +264,6 @@ namespace binary { | |||||||
|     return hr::parabolic13(y * co, z * co); |     return hr::parabolic13(y * co, z * co); | ||||||
|     } |     } | ||||||
|    |    | ||||||
|   ld btrange = 3, btrange_cosh; |  | ||||||
|  |  | ||||||
|   void draw() { |   void draw() { | ||||||
|     dq::visited.clear(); |     dq::visited.clear(); | ||||||
|     dq::enqueue(viewctr.at, cview()); |     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); |     shift_arg_formula(vid.binary_width, delayed_geo_reset); | ||||||
|     return 0; |     return 0; | ||||||
|     } |     } | ||||||
|   else if(argis("-btrange")) { |  | ||||||
|     shift_arg_formula(btrange, delayed_geo_reset); |  | ||||||
|     return 0; |  | ||||||
|     } |  | ||||||
|   return 1; |   return 1; | ||||||
|   }); |   }); | ||||||
| #endif | #endif | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								config.cpp
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								config.cpp
									
									
									
									
									
								
							| @@ -6,6 +6,8 @@ namespace hr { | |||||||
|  |  | ||||||
| const char *conffile = "hyperrogue.ini"; | const char *conffile = "hyperrogue.ini"; | ||||||
|  |  | ||||||
|  | array<ld, gGUARD> sightranges; | ||||||
|  |  | ||||||
| videopar vid; | videopar vid; | ||||||
|  |  | ||||||
| #define DEFAULT_WALLMODE (ISMOBILE ? 3 : 5) | #define DEFAULT_WALLMODE (ISMOBILE ? 3 : 5) | ||||||
| @@ -356,6 +358,10 @@ void initConfig() { | |||||||
|   addsaverenum(conformal::basic_model, "basic model"); |   addsaverenum(conformal::basic_model, "basic model"); | ||||||
|   addsaver(conformal::use_atan, "use_atan"); |   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); |   addsaver(vid.consider_shader_projection, "shader-projection", true); | ||||||
|    |    | ||||||
| #if CAP_RACING | #if CAP_RACING | ||||||
| @@ -733,12 +739,22 @@ void edit_sightrange() { | |||||||
|   } |   } | ||||||
|  |  | ||||||
| void menuitem_sightrange(char c) { | void menuitem_sightrange(char c) { | ||||||
|  |   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) |     if(vid.use_smart_range) | ||||||
|       dialog::addSelItem(XLAT("minimum visible cell in pixels"), fts(vid.smart_range_detail), c); |       dialog::addSelItem(XLAT("minimum visible cell in pixels"), fts(vid.smart_range_detail), c); | ||||||
|     else |     else | ||||||
|       dialog::addSelItem(XLAT("sight range"), its(sightrange_bonus), c); |       dialog::addSelItem(XLAT("sight range"), its(sightrange_bonus), c); | ||||||
|     dialog::add_action(edit_sightrange); |     dialog::add_action(edit_sightrange); | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|    |    | ||||||
| void showGraphConfig() { | void showGraphConfig() { | ||||||
|   cmode = vid.xres > vid.yres * 1.4 ? sm::SIDE : sm::MAYDARK; |   cmode = vid.xres > vid.yres * 1.4 ? sm::SIDE : sm::MAYDARK; | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								hyper.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								hyper.h
									
									
									
									
									
								
							| @@ -196,6 +196,8 @@ typedef complex<ld> cld; | |||||||
| #endif | #endif | ||||||
| #define MDIM (DIM+1) | #define MDIM (DIM+1) | ||||||
|  |  | ||||||
|  | extern array<ld, gGUARD> sightranges; | ||||||
|  |  | ||||||
| struct hyperpoint : array<ld, MAXDIM> { | struct hyperpoint : array<ld, MAXDIM> { | ||||||
|   hyperpoint() {} |   hyperpoint() {} | ||||||
|    |    | ||||||
|   | |||||||
| @@ -1601,8 +1601,8 @@ bool do_draw(cell *c) { | |||||||
|  |  | ||||||
| bool do_draw(cell *c, const transmatrix& T) { | bool do_draw(cell *c, const transmatrix& T) { | ||||||
|   if(DIM == 3) { |   if(DIM == 3) { | ||||||
|     if(hyperbolic && T[DIM][DIM] > binary::btrange_cosh) return false; |     if(hyperbolic && T[DIM][DIM] > cosh(sightranges[geometry])) return false; | ||||||
|     if(euclid && hypot_d(tC0(T), 3) > 7) return false; |     if(euclid && hypot_d(tC0(T), 3) > sightranges[geometry]) return false; | ||||||
|     setdist(c, 7, c); |     setdist(c, 7, c); | ||||||
|     return true; |     return true; | ||||||
|     } |     } | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								shaders.cpp
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								shaders.cpp
									
									
									
									
									
								
							| @@ -564,12 +564,12 @@ void init() { | |||||||
|        |        | ||||||
|       s3,        "vec4 t = uMV * aPosition;", |       s3,        "vec4 t = uMV * aPosition;", | ||||||
|       sh3,       "vColor.xyz = vColor.xyz * (1.0 - acosh(t[3]) / uFog);", |       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; ", |       ss30,      "vColor.xyz = vColor.xyz * (1 - (6.284 - acos(t[3])) / uFog); t = -t; ", | ||||||
|       ss31,      "vColor.xyz = vColor.xyz * (acos(t[3]) / 6.3); t.xyz = -t.xyz; ", |       ss31,      "vColor.xyz = vColor.xyz * (1 - (6.284 - acos(t[3])) / uFog); t.xyz = -t.xyz; ", | ||||||
|       ss32,      "vColor.xyz = vColor.xyz * (1.0 - acos(t[3]) / 6.3); t.w = -t.w; ", |       ss32,      "vColor.xyz = vColor.xyz * (1 - acos(t[3]) / uFog); t.w = -t.w; ", // 2pi | ||||||
|       ss33,      "vColor.xyz = vColor.xyz * (1.0 - acos(t[3]) / 6.3); ", |       ss33,      "vColor.xyz = vColor.xyz * (1 - acos(t[3]) / uFog); ", | ||||||
|       sh3 || sr3,"t[3] = 1.0;", |       sh3 || sr3,"t[3] = 1.0;", | ||||||
|        |        | ||||||
|       band || hp || s3,"gl_Position = uP * t;", |       band || hp || s3,"gl_Position = uP * t;", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ?
					?