solv:: behind-camera optimization

This commit is contained in:
Zeno Rogue 2019-07-31 13:21:33 +02:00
parent 3ae542b241
commit 03119d0dd5
1 changed files with 12 additions and 2 deletions

View File

@ -4490,7 +4490,7 @@ int noclipped;
void make_clipping_planes() {
#if MAXMDIM >= 4
clipping_planes.clear();
if(sphere || sol) return;
if(sphere) return;
auto add_clipping_plane = [] (ld x1, ld y1, ld x2, ld y2) {
using namespace hyperpoint_vec;
ld z1 = 1, z2 = 1;
@ -5041,7 +5041,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
if(just_gmatrix) return;
#if MAXMDIM >= 4
if(WDIM == 3 && pmodel == mdPerspective) {
if(pmodel == mdPerspective) {
using namespace hyperpoint_vec;
hyperpoint H = tC0(V);
for(hyperpoint& cpoint: clipping_planes) if((H|cpoint) < -sin_auto(cgi.corner_bonus)) {
@ -5050,6 +5050,16 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
noclipped++;
}
if(pmodel == mdSolPerspective) {
using namespace hyperpoint_vec;
hyperpoint H = tC0(V);
if(abs(H[0]) <= 1 && abs(H[1]) <= 1 && abs(H[2]) <= 1) ;
else {
hyperpoint H2 = solv::local_perspective * solv::inverse_exp(H, true);
for(hyperpoint& cpoint: clipping_planes) if((H2|cpoint) < -.2) return;
}
noclipped++;
}
#endif
#if CAP_SHAPES