1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

ray:: namespace and basic configurator

This commit is contained in:
Zeno Rogue 2019-10-25 14:50:48 +02:00
parent 38414c65b4
commit bd7805e68d
3 changed files with 64 additions and 17 deletions

View File

@ -1586,6 +1586,11 @@ EX void show3D() {
}); });
} }
if(GDIM == 3) {
dialog::addItem(XLAT("configure raycasting"), 'C');
dialog::add_action_push(ray::configure);
}
if(WDIM == 3 || (GDIM == 3 && euclid)) { if(WDIM == 3 || (GDIM == 3 && euclid)) {
dialog::addSelItem(XLAT("radar range"), fts(vid.radarrange), 'R'); dialog::addSelItem(XLAT("radar range"), fts(vid.radarrange), 'R');
dialog::add_action([] () { dialog::add_action([] () {

View File

@ -4399,9 +4399,7 @@ EX void precise_mouseover() {
EX transmatrix Viewbase; EX transmatrix Viewbase;
EX bool use_raycasting;
EX bool no_wall_rendering; EX bool no_wall_rendering;
EX bool ray_comparison_mode;
EX void drawthemap() { EX void drawthemap() {
check_cgi(); check_cgi();
@ -4457,16 +4455,10 @@ EX void drawthemap() {
for(int m=0; m<motypes; m++) if(isPrincess(eMonster(m))) for(int m=0; m<motypes; m++) if(isPrincess(eMonster(m)))
minf[m].name = princessgender() ? "Princess" : "Prince"; minf[m].name = princessgender() ? "Princess" : "Prince";
use_raycasting = false; ray::in_use = ray::requested();
if(WDIM == 3 && hyperbolic && pmodel == mdPerspective && !binarytiling) no_wall_rendering = ray::in_use;
use_raycasting = true; // ray::comparison_mode = true;
if(WDIM == 3 && (sol || nil) && pmodel == mdGeodesic) if(ray::comparison_mode) no_wall_rendering = false;
use_raycasting = true;
if(WDIM == 3 && euclid && pmodel == mdPerspective && !binarytiling)
use_raycasting = true;
no_wall_rendering = use_raycasting;
ray_comparison_mode = anyshiftclick;
if(ray_comparison_mode) no_wall_rendering = false;
iinf[itSavedPrincess].name = minf[moPrincess].name; iinf[itSavedPrincess].name = minf[moPrincess].name;
@ -4507,7 +4499,7 @@ EX void drawthemap() {
profile_start(1); profile_start(1);
make_actual_view(); make_actual_view();
currentmap->draw(); currentmap->draw();
if(use_raycasting && !ray_comparison_mode) do_raycast(); if(ray::in_use && !ray::comparison_mode) ray::cast();
drawWormSegments(); drawWormSegments();
drawBlizzards(); drawBlizzards();
drawArrowTraps(); drawArrowTraps();
@ -4773,11 +4765,11 @@ EX void drawfullmap() {
drawqueue(); drawqueue();
#endif #endif
if(use_raycasting && ray_comparison_mode) { if(ray::in_use && ray::comparison_mode) {
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glClearDepth(1.0f); glClearDepth(1.0f);
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
do_raycast(); ray::cast();
} }
profile_stop(2); profile_stop(2);

View File

@ -9,10 +9,39 @@
namespace hr { namespace hr {
EX namespace ray {
/** texture IDs */
GLuint txConnections = 0, txWallcolor = 0, txMatrixid = 0; GLuint txConnections = 0, txWallcolor = 0, txMatrixid = 0;
EX bool in_use;
EX bool comparison_mode;
/** 0 - never use, 2 - always use, 1 = smart selection */
EX int want_use = 1;
#define IN_ODS 0 #define IN_ODS 0
/** is the raycaster available? */
EX bool available() {
if(WDIM == 2) return false;
if(hyperbolic && pmodel == mdPerspective && !binarytiling)
return true;
if((sol || nil) && pmodel == mdGeodesic)
return true;
if(euclid && pmodel == mdPerspective && !binarytiling)
return true;
return false;
}
/** do we want to use the raycaster? */
EX bool requested() {
if(!want_use) return false;
if(!available()) return false;
if(want_use == 2) return true;
return racing::on || quotient;
}
struct raycaster : glhr::GLprogram { struct raycaster : glhr::GLprogram {
GLint uStart, uStartid, uN, uM, uLength, uFovX, uFovY, uIPD; GLint uStart, uStartid, uN, uM, uLength, uFovX, uFovY, uIPD;
GLint uWallstart, uWallX, uWallY; GLint uWallstart, uWallX, uWallY;
@ -402,10 +431,10 @@ void bind_array(vector<array<float, 4>>& v, GLint t, GLuint& tx, int id) {
GLERR("bind_array"); GLERR("bind_array");
} }
EX void do_raycast() { EX void cast() {
enable_raycaster(); enable_raycaster();
if(ray_comparison_mode) if(comparison_mode)
glColorMask( GL_TRUE,GL_FALSE,GL_FALSE,GL_TRUE ); glColorMask( GL_TRUE,GL_FALSE,GL_FALSE,GL_TRUE );
auto& o = our_raycaster; auto& o = our_raycaster;
@ -523,4 +552,25 @@ EX void do_raycast() {
glActiveTexture(GL_TEXTURE0 + 0); glActiveTexture(GL_TEXTURE0 + 0);
} }
EX void configure() {
cmode = sm::SIDE | sm::MAYDARK;
gamescreen(0);
dialog::init(XLAT("raycasting configuration"));
dialog::addBoolItem(XLAT("available in current geometry"), available(), 0);
dialog::addBoolItem(XLAT("use raycasting?"), want_use == 2 ? true : in_use, 'u');
if(want_use == 1) dialog::lastItem().value = XLAT("SMART");
dialog::add_action([] {
want_use++; want_use %= 3;
});
dialog::addBoolItem_action(XLAT("comparison mode"), comparison_mode, 'c');
dialog::addBack();
dialog::display();
}
EX }
} }