diff --git a/classes.cpp b/classes.cpp index 32be1090..7ac51a11 100644 --- a/classes.cpp +++ b/classes.cpp @@ -797,6 +797,8 @@ static const flagtype qSINGLE = Flag(20); static const flagtype qDEPRECATED = Flag(21); static const flagtype qINFMIXED = Flag(22); +static const flagtype qRAYONLY = Flag(23); + // note: dnext assumes that x&7 equals 7 static const int SEE_ALL = 50; static const int OINF = 100; diff --git a/hypgraph.cpp b/hypgraph.cpp index 1ab9d276..1855ed0e 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -2060,8 +2060,12 @@ EX transmatrix& get_view_orientation() { return prod ? NLP : View; } +EX hookset *hooks_rotate_view; +EX hookset *hooks_shift_view; + /** rotate the view using the given rotation matrix */ EX void rotate_view(transmatrix T) { + if(callhandlers(false, hooks_rotate_view, T)) return; transmatrix& which = get_view_orientation(); which = T * which; if(!prod && !nonisotropic) current_display->which_copy = T * current_display->which_copy; @@ -2085,6 +2089,7 @@ EX transmatrix get_shift_view_of(const hyperpoint H, const transmatrix V) { /** shift the view according to the given tangent vector */ EX void shift_view(hyperpoint H) { + if(callhandlers(false, hooks_shift_view, H)) return; auto oView = View; View = get_shift_view_of(H, View); auto& wc = current_display->which_copy; diff --git a/polygons.cpp b/polygons.cpp index c1160dcd..3ee866d9 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -1185,6 +1185,7 @@ void geometry_information::configure_floorshapes() { void geometry_information::prepare_shapes() { require_basics(); + if(cgflags & qRAYONLY) return; #if MAXMDIM >= 4 if(GDIM == 3 && !floor_textures) make_floor_textures(); #endif diff --git a/raycaster.cpp b/raycaster.cpp index d4d520f0..5475d545 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -78,6 +78,7 @@ EX bool available() { /** do we want to use the raycaster? */ EX bool requested() { + if(cgflags & qRAYONLY) return true; if(!want_use) return false; #if CAP_TEXTURE if(texture::config.tstate == texture::tsActive) return false; @@ -87,6 +88,7 @@ EX bool requested() { return racing::on || quotient; } +#if HDR struct raycaster : glhr::GLprogram { GLint uStart, uStartid, uM, uLength, uFovX, uFovY, uIPD, uShift; GLint uWallstart, uWallX, uWallY; @@ -96,7 +98,11 @@ struct raycaster : glhr::GLprogram { GLint uBLevel; GLint uPosX, uPosY; - raycaster(string vsh, string fsh) : GLprogram(vsh, fsh) { + raycaster(string vsh, string fsh); + }; +#endif + +raycaster::raycaster(string vsh, string fsh) : GLprogram(vsh, fsh) { println(hlog, "assigning"); uStart = glGetUniformLocation(_program, "uStart"); uStartid = glGetUniformLocation(_program, "uStartid"); @@ -122,8 +128,6 @@ struct raycaster : glhr::GLprogram { uExpDecay = glGetUniformLocation(_program, "uExpDecay"); uExpStart = glGetUniformLocation(_program, "uExpStart"); - uShift = glGetUniformLocation(_program, "uShift"); - uBLevel = glGetUniformLocation(_program, "uBLevel"); tConnections = glGetUniformLocation(_program, "tConnections"); @@ -133,7 +137,6 @@ struct raycaster : glhr::GLprogram { uPosX = glGetUniformLocation(_program, "uPosX"); uPosY = glGetUniformLocation(_program, "uPosY"); } - }; shared_ptr our_raycaster; @@ -166,6 +169,9 @@ string build_getter(string type, string name, int index) { #define GET(array, index) array "[" index "]" #endif +EX hookset *hooks_rayshader; +EX hookset)> *hooks_rayset; + void enable_raycaster() { if(geometry != last_geometry) reset_raycaster(); last_geometry = geometry; @@ -814,7 +820,9 @@ void enable_raycaster() { " }"; fsh += fmain; - + + callhooks(hooks_rayshader, vsh, fsh); + our_raycaster = make_shared (vsh, fsh); } full_enable(our_raycaster); @@ -879,7 +887,11 @@ EX void cast() { cd->set_mask(global_projection); glUniform1f(o->uFovX, cd->tanfov / (vid.stereo_mode == sLR ? 2 : 1)); glUniform1f(o->uFovY, cd->tanfov * cd->ysize / cd->xsize); + + glUniform1f(o->uPosX, -((cd->xcenter-cd->xtop)*2./cd->xsize - 1)); + glUniform1f(o->uPosY, -((cd->ycenter-cd->ytop)*2./cd->ysize - 1)); + if(!callhandlers(false, hooks_rayset, o)) { deg = S7; if(prod) deg += 2; @@ -934,9 +946,6 @@ EX void cast() { glUniform1f(o->uIPD, vid.ipd); GLERR("uniform mediump IPD"); - glUniform1f(o->uPosX, -((cd->xcenter-cd->xtop)*2./cd->xsize - 1)); - glUniform1f(o->uPosY, -((cd->ycenter-cd->ytop)*2./cd->ysize - 1)); - vector ms; for(int j=0; jiadj(cwt.at, j)); if(prod) ms.push_back(mscale(Id, +cgi.plevel)); @@ -1056,6 +1065,8 @@ EX void cast() { auto cols = glhr::acolor(darkena(backcolor, 0, 0xFF)); glUniform4f(o->uFogColor, cols[0], cols[1], cols[2], cols[3]); + + } glVertexAttribPointer(hr::aPosition, 4, GL_FLOAT, GL_FALSE, sizeof(glvertex), &screen[0]); if(ray::comparison_mode)