From 42f96b768cbf2b82db82f0af7982fdce4ea5ca1d Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 4 Dec 2022 14:48:12 +0100 Subject: [PATCH] improvements to sphere flipping --- basegraph.cpp | 2 +- drawing.cpp | 6 +++--- graph.cpp | 3 ++- hypgraph.cpp | 8 +++++--- vr.cpp | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/basegraph.cpp b/basegraph.cpp index 0b4ba2ae..de13a17a 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -927,7 +927,7 @@ EX int rhypot(int a, int b) { return (int) sqrt(a*a - b*b); } EX ld realradius() { ld vradius = current_display->radius; if(sphere) { - if(sphereflipped()) + if(flip_sphere()) vradius /= sqrt(pconf.alpha*pconf.alpha - 1); else vradius = 1e12; // use the following diff --git a/drawing.cpp b/drawing.cpp index 84081eb5..6bd48f90 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -2184,7 +2184,7 @@ EX void quickqueue() { /* todo */ ld xintval(const shiftpoint& h) { - if(sphereflipped()) return -h.h[2]; + if(sphere_flipped) return -h.h[2]; if(hyperbolic) return -h.h[2]; return -intval(h.h, C0); } @@ -2198,7 +2198,7 @@ int qp[PMAX], qp0[PMAX]; color_t darken_color(color_t& color, bool outline) { int alpha = color & 255; - if(sphere && pmodel == mdDisk && pconf.alpha <= 1) + if(sphere && pmodel == mdDisk && pconf.alpha <= 0.99) return 0; else { if(outline && alpha < 255) @@ -2279,7 +2279,7 @@ EX void draw_backside() { ptd->draw(); } - spherespecial = sphereflipped() ? 1 : -1; + spherespecial = sphere_flipped ? 1 : -1; reset_projection(); if(pmodel == mdRotatedHyperboles) { diff --git a/graph.cpp b/graph.cpp index 9db5f0c8..343aab1e 100644 --- a/graph.cpp +++ b/graph.cpp @@ -5030,7 +5030,8 @@ EX bool nonisotropic_weird_transforms; EX void make_actual_view() { sphereflip = Id; - if(sphereflipped()) sphereflip[LDIM][LDIM] = -1; + sphere_flipped = flip_sphere(); + if(sphere_flipped) sphereflip[LDIM][LDIM] = -1; actual_view_transform = sphereflip; if(vid.yshift && WDIM == 2) actual_view_transform = ypush(vid.yshift) * actual_view_transform; #if MAXMDIM >= 4 diff --git a/hypgraph.cpp b/hypgraph.cpp index b961c405..ba6b93cb 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -11,9 +11,11 @@ namespace hr { hyperpoint ghxy, ghgxy; shiftpoint ghpm = shiftless(C02); -#if HDR -inline bool sphereflipped() { return sphere && pconf.alpha > 1.1; } -#endif +EX ld flip_limit = 1.1; + +EX bool flip_sphere() { return sphere && pconf.alpha > flip_limit; } + +EX bool sphere_flipped; void ghcheck(hyperpoint &ret, const shiftpoint &H) { if(hypot_d(2, ret-ghxy) < hypot_d(2, ghgxy-ghxy)) { diff --git a/vr.cpp b/vr.cpp index 0ae46b8e..455003e7 100644 --- a/vr.cpp +++ b/vr.cpp @@ -577,7 +577,7 @@ EX hyperpoint model_location(shiftpoint h, bool& bad) { h.h = hmd_pre_for[2] * h.h; eModel md = pmodel_3d_version(); apply_other_model(h, hscr, md); - bad = in_vr_sphere && get_side(hscr) == (sphereflipped() ? -1 : 1); + bad = in_vr_sphere && get_side(hscr) == (sphere_flipped ? -1 : 1); hscr[3] = 1; return hscr;