1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-20 23:50:27 +00:00

solv:: removed ILP for simplicity and better performance

This commit is contained in:
Zeno Rogue 2019-07-31 11:07:36 +02:00
parent 5c42c2f8e5
commit 90aa7b5c02
6 changed files with 9 additions and 11 deletions

View File

@ -290,7 +290,6 @@ void display_data::set_projection(int ed) {
} }
glUniformMatrix4fv(glhr::current->uILP, 1, 0, glhr::tmtogl_transpose(solv::ilocal_perspective).as_array());
glUniform1i(glhr::current->tInvExpTable, glhr::INVERSE_EXP_BINDING); glUniform1i(glhr::current->tInvExpTable, glhr::INVERSE_EXP_BINDING);
glActiveTexture(GL_TEXTURE0 + glhr::INVERSE_EXP_BINDING); glActiveTexture(GL_TEXTURE0 + glhr::INVERSE_EXP_BINDING);
glBindTexture(GL_TEXTURE_3D, invexpid); glBindTexture(GL_TEXTURE_3D, invexpid);

View File

@ -64,6 +64,7 @@ movedir vectodir(const hyperpoint& P) {
transmatrix U = ggmatrix(cwt.at); transmatrix U = ggmatrix(cwt.at);
if(GDIM == 3 && WDIM == 2) U = radar_transform * U; if(GDIM == 3 && WDIM == 2) U = radar_transform * U;
if(pmodel == mdSolPerspective) U = solv::local_perspective * U;
hyperpoint H = sphereflip * tC0(U); hyperpoint H = sphereflip * tC0(U);
transmatrix Centered = sphereflip * rgpushxto0(H); transmatrix Centered = sphereflip * rgpushxto0(H);

View File

@ -5629,7 +5629,7 @@ namespace kite {
#endif #endif
namespace solv { namespace solv {
extern transmatrix local_perspective, ilocal_perspective; extern transmatrix local_perspective;
hrmap *new_map(); hrmap *new_map();
hyperpoint inverse_exp(hyperpoint h); hyperpoint inverse_exp(hyperpoint h);

View File

@ -906,7 +906,7 @@ bool invalid_point(const transmatrix T) {
bool in_smart_range(const transmatrix& T) { bool in_smart_range(const transmatrix& T) {
if(invalid_point(T)) return false; if(invalid_point(T)) return false;
if(pmodel == mdSolPerspective) return solv::in_table_range(solv::ilocal_perspective * tC0(T)); if(pmodel == mdSolPerspective) return solv::in_table_range(tC0(T));
hyperpoint h1; hyperpoint h1;
applymodel(tC0(T), h1); applymodel(tC0(T), h1);
for(int i=0; i<DIM; i++) for(int i=0; i<DIM; i++)
@ -1261,6 +1261,7 @@ void centerpc(ld aspd) {
transmatrix T = cwtV; transmatrix T = cwtV;
#if MAXMDIM >= 4 #if MAXMDIM >= 4
if(pmodel == mdSolPerspective) T = solv::local_perspective * T;
if(GDIM == 3 && WDIM == 2) { if(GDIM == 3 && WDIM == 2) {
geom3::do_auto_eye(); geom3::do_auto_eye();
int sl = snakelevel(cwt.at); int sl = snakelevel(cwt.at);
@ -1877,7 +1878,7 @@ bool do_draw(cell *c, const transmatrix& T) {
if(WDIM == 3) { if(WDIM == 3) {
if(cells_drawn > vid.cells_drawn_limit) return false; if(cells_drawn > vid.cells_drawn_limit) return false;
if(pmodel == mdSolPerspective) { if(pmodel == mdSolPerspective) {
if(!solv::in_table_range(solv::ilocal_perspective * tC0(T))) return false; if(!solv::in_table_range(tC0(T))) return false;
if(!limited_generation(c)) return false; if(!limited_generation(c)) return false;
} }
else if(vid.use_smart_range) { else if(vid.use_smart_range) {

View File

@ -218,7 +218,7 @@ struct GLprogram {
GLuint _program; GLuint _program;
GLuint vertShader, fragShader; GLuint vertShader, fragShader;
GLint uMVP, uFog, uFogColor, uColor, tTexture, tInvExpTable, uMV, uProjection, uAlpha, uFogBase, uILP, uPRECX, uPRECY, uPRECZ; GLint uMVP, uFog, uFogColor, uColor, tTexture, tInvExpTable, uMV, uProjection, uAlpha, uFogBase, uPRECX, uPRECY, uPRECZ;
GLprogram(string vsh, string fsh) { GLprogram(string vsh, string fsh) {
_program = glCreateProgram(); _program = glCreateProgram();
@ -273,7 +273,6 @@ struct GLprogram {
uFogBase = glGetUniformLocation(_program, "uFogBase"); uFogBase = glGetUniformLocation(_program, "uFogBase");
uAlpha = glGetUniformLocation(_program, "uAlpha"); uAlpha = glGetUniformLocation(_program, "uAlpha");
uColor = glGetUniformLocation(_program, "uColor"); uColor = glGetUniformLocation(_program, "uColor");
uILP = glGetUniformLocation(_program, "uILP");
tTexture = glGetUniformLocation(_program, "tTexture"); tTexture = glGetUniformLocation(_program, "tTexture");
tInvExpTable = glGetUniformLocation(_program, "tInvExpTable"); tInvExpTable = glGetUniformLocation(_program, "tInvExpTable");
@ -656,7 +655,7 @@ void init() {
hp && dim3, "t.x /= -rads; t.y /= -rads; t.z /= -rads; t[3] = 1.0;", hp && dim3, "t.x /= -rads; t.y /= -rads; t.z /= -rads; t[3] = 1.0;",
s3, "vec4 t = uMV * aPosition;", s3, "vec4 t = uMV * aPosition;",
ssol, "t = inverse_exp(uILP * t);", ssol, "t = inverse_exp(t);",
ssol, "float d = sqrt(t[0] * t[0] + t[1] * t[1] + t[2] * t[2]);", ssol, "float d = sqrt(t[0] * t[0] + t[1] * t[1] + t[2] * t[2]);",
ssol, "float ad = (d == 0.) ? 0. : (d < 1.) ? min(atanh(d), 10.) : 10.; ", ssol, "float ad = (d == 0.) ? 0. : (d < 1.) ? min(atanh(d), 10.) : 10.; ",
ssol, "float m = ad / d / 11.; t[0] *= m; t[1] *= m; t[2] *= m; ", ssol, "float m = ad / d / 11.; t[0] *= m; t[1] *= m; t[2] *= m; ",

View File

@ -155,7 +155,7 @@ namespace solv {
return res * atanh(r) / r; */ return res * atanh(r) / r; */
} }
transmatrix local_perspective, ilocal_perspective; transmatrix local_perspective;
bool geodesic_movement = true; bool geodesic_movement = true;
@ -274,9 +274,8 @@ namespace solv {
transmatrix T = eupush( tC0(inverse(View)) ); transmatrix T = eupush( tC0(inverse(View)) );
local_perspective = View * T; local_perspective = View * T;
ilocal_perspective = inverse(local_perspective);
dq::enqueue(viewctr.at, cview()); dq::enqueue(viewctr.at, inverse(local_perspective) * cview());
while(!dq::drawqueue.empty()) { while(!dq::drawqueue.empty()) {
auto& p = dq::drawqueue.front(); auto& p = dq::drawqueue.front();
@ -378,7 +377,6 @@ namespace solv {
string solshader = string solshader =
"uniform mediump sampler3D tInvExpTable;" "uniform mediump sampler3D tInvExpTable;"
"uniform mediump mat4 uILP;"
"uniform mediump float PRECX, PRECY, PRECZ;" "uniform mediump float PRECX, PRECY, PRECZ;"
"float x_to_ix(float u) {" "float x_to_ix(float u) {"