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

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

View File

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

View File

@ -9,10 +9,39 @@
namespace hr {
EX namespace ray {
/** texture IDs */
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
/** 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 {
GLint uStart, uStartid, uN, uM, uLength, uFovX, uFovY, uIPD;
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");
}
EX void do_raycast() {
EX void cast() {
enable_raycaster();
if(ray_comparison_mode)
if(comparison_mode)
glColorMask( GL_TRUE,GL_FALSE,GL_FALSE,GL_TRUE );
auto& o = our_raycaster;
@ -523,4 +552,25 @@ EX void do_raycast() {
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 }
}