From 0c154d6751aa3c1e27a9dffef5b60156a29a8c27 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 9 Oct 2017 11:46:49 +0200 Subject: [PATCH] improved display in Halloween --- blizzard.cpp | 6 ++++++ graph.cpp | 35 ++++++++++++++++++++++++++++++++--- hyper.h | 2 ++ hypgraph.cpp | 24 ++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/blizzard.cpp b/blizzard.cpp index b4bb51df..6ad558b8 100644 --- a/blizzard.cpp +++ b/blizzard.cpp @@ -1,5 +1,11 @@ double randd() { return (rand() % 1000000) / 1000000. + .0000005; } +transmatrix cellrelmatrix(cell *c, int i) { + double d = + purehepta ? tessf : c->type == 6 ? hexhexdist : crossf; + return ddspin(c, i) * xpush(d) * iddspin(c->mov[i], c->spin(i), euclid ? 0 : S42); + } + hyperpoint randomPointIn(int t) { while(true) { hyperpoint h = spin(2*M_PI*(randd()-.5)/t) * tC0(xpush(asinh(randd()))); diff --git a/graph.cpp b/graph.cpp index 4de43630..658a30a8 100644 --- a/graph.cpp +++ b/graph.cpp @@ -219,6 +219,11 @@ transmatrix ddspin(cell *c, int d, int bonus) { return getspinmatrix(hdir); } +transmatrix iddspin(cell *c, int d, int bonus = 0) { + int hdir = displaydir(c, d) + bonus; + return getspinmatrix(-hdir); + } + void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) { if(!onplayer && !items[itOrbEmpathy]) return; if(items[itOrbShield] > (shmup::on ? 0 : ORBBASE)) drawShield(V, itOrbShield); @@ -4056,21 +4061,25 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { bool w = isWarped(c); int col = (highwall(c) || c->wall == waTower) ? wcol : fcol; if(!chasmg) { + +#define D(v) darkena(gradient(0, col, 0, v * (sphere ? spherity(V * cellrelmatrix(c,i)) : 1), 1), fd, 0xFF) + if(sha & 1) { forCellIdEx(c2, i, c) if(chasmgraph(c2)) - placeSidewallX(c, i, SIDE_LAKE, V, w, false, darkena(gradient(0, col, 0, .8, 1), fd, 0xFF)); + placeSidewallX(c, i, SIDE_LAKE, V, w, false, D(.8)); } if(sha & 2) { forCellIdEx(c2, i, c) if(chasmgraph(c2)) - placeSidewallX(c, i, SIDE_LTOB, V, w, false, darkena(gradient(0, col, 0, .7, 1), fd, 0xFF)); + placeSidewallX(c, i, SIDE_LTOB, V, w, false, D(.7)); } if(sha & 4) { bool dbot = true; forCellIdEx(c2, i, c) if(chasmgraph(c2) == 2) { if(dbot) dbot = false, warpfloor(c, mscale(V, geom3::BOTTOM), 0x080808FF, PPR_LAKEBOTTOM, isWarped(c)); - placeSidewallX(c, i, SIDE_BTOI, V, w, false, darkena(gradient(0, col, 0, .6, 1), fd, 0xFF)); + placeSidewallX(c, i, SIDE_BTOI, V, w, false, D(.6)); } +#undef D } } // wall between lake and chasm -- no Escher here @@ -4081,6 +4090,26 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } } + if(chasmg == 2 && wmspatial && sphere) { + forCellIdEx(c2, i, c) if(chasmgraph(c2) == 0) { + transmatrix V2 = V * cellrelmatrix(c, i); + if(!behindsphere(V2)) continue; + bool w = isWarped(c2); + int wcol2, fcol2; + setcolors(c2, wcol2, fcol2); + int col = (highwall(c2) || c->wall == waTower) ? wcol2 : fcol2; + col = gradient(0, col, 0, spherity(V), 1); + int j = c->spin(i); + if(ticks % 500 < -250) { + V2 = V2 * ddspin(c2, j); + j = 0; + } + placeSidewall(c2, j, SIDE_LAKE, V2, w, false, darkena(gradient(0, col, 0, .8, 1), fd, 0xFF)); + placeSidewall(c2, j, SIDE_LTOB, V2, w, false, darkena(gradient(0, col, 0, .7, 1), fd, 0xFF)); + placeSidewall(c2, j, SIDE_BTOI, V2, w, false, darkena(gradient(0, col, 0, .6, 1), fd, 0xFF)); + } + } + if(chasmg == 1 && wmspatial) { int fd0 = fd ? fd-1 : 0; diff --git a/hyper.h b/hyper.h index 643bf483..b6bec0d5 100644 --- a/hyper.h +++ b/hyper.h @@ -1592,3 +1592,5 @@ void showMessageLog(); int getgametime(); string getgametime_s(int timespent = getgametime()); extern int stampbase; + +transmatrix cellrelmatrix(cell *c, int i); diff --git a/hypgraph.cpp b/hypgraph.cpp index 39d48fa1..0df2e5b9 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -291,10 +291,34 @@ bool behindsphere(const hyperpoint& h) { return false; } +ld to01(ld a0, ld a1, ld x) { + if(x < a0) return 0; + if(x > a1) return 1; + return (x-a0) / (a1-a0); + } + +ld spherity(const hyperpoint& h) { + if(!sphere) return 1; + + if(vid.alpha > 1) { + return to01(1/vid.alpha, 1, -h[2]); + } + + if(vid.alpha <= 1) { + return to01(-.8, 1, h[2]); + } + + return 1; + } + bool behindsphere(const transmatrix& V) { return behindsphere(tC0(V)); } +ld spherity(const transmatrix& V) { + return spherity(tC0(V)); + } + bool confusingGeometry() { return elliptic || quotient == 1 || torus; }