From 1769f65ddbe30ae9c52db56fbd66ba78e359b8cf Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 15 May 2019 10:51:46 +0200 Subject: [PATCH] 2D3D:: gravity particles --- graph.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/graph.cpp b/graph.cpp index 430d1a9c..5f087545 100644 --- a/graph.cpp +++ b/graph.cpp @@ -240,9 +240,13 @@ void drawFlash(const transmatrix& V) { #endif } +ld cheilevel(ld v) { + return geom3::FLOOR + (geom3::HEAD - geom3::FLOOR) * v; + } + transmatrix chei(const transmatrix V, int a, int b) { if(DIM == 2) return V; - return V * zpush(geom3::FLOOR + (geom3::HEAD - geom3::FLOOR) * (a+.5) / b); + return V * zpush(cheilevel((a+.5) / b)); } void drawLove(const transmatrix& V, int hdir) { @@ -4119,22 +4123,24 @@ void draw_gravity_particles(cell *c, const transmatrix V) { const color_t antigrav_color = 0xF04040FF; const color_t levitate_color = 0x40F040FF; - ld lev = 2; + auto levf = [] (ld l) { + return DIM == 3 ? cheilevel(l) : 1 + (1-l) * 1; + }; - if(spatial_graphics) { + if(spatial_graphics || (WDIM == 2 && GDIM == 3)) { switch(gravity_state) { case gsNormal: for(int i=0; i<6; i++) { transmatrix T = V * spin(i*degree*60) * xpush(crossf/3); - queueline(mmscale(T, 1 + (1-r0) * (lev-1)) * C0, mmscale(T, 1 + (1-r1) * (lev - 1)) * C0, grav_normal_color); + queueline(mmscale(T, levf(r0)) * C0, mmscale(T, levf(r1)) * C0, grav_normal_color); } break; case gsAnti: for(int i=0; i<6; i++) { transmatrix T = V * spin(i*degree*60) * xpush(crossf/3); - queueline(mmscale(T, 1 + r0 * (lev-1)) * C0, mmscale(T, 1 + r1 * (lev-1)) * C0, antigrav_color); + queueline(mmscale(T, levf(r0)) * C0, mmscale(T, levf(r1)) * C0, antigrav_color); } break; @@ -4142,7 +4148,8 @@ void draw_gravity_particles(cell *c, const transmatrix V) { for(int i=0; i<6; i++) { transmatrix T0 = V * spin(i*degree*60 + tt/60. * degree) * xpush(crossf/3); transmatrix T1 = V * spin(i*degree*60 + (tt/60. + 30) * degree) * xpush(crossf/3); - queueline(mmscale(T0, (lev+1)/2) * C0, mmscale(T1, (lev+1)/2) * C0, levitate_color); + ld lv = levf(DIM == 3 ? (i+0.5)/6 : 0.5); + queueline(mmscale(T0, lv) * C0, mmscale(T1, lv) * C0, levitate_color); } break; }