From 4043dba74c77d68457c90bb9be32e2f2c39a2758 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sat, 18 Jun 2011 16:47:47 +0100 Subject: [PATCH] Small fixes for liquids in radial/Newtonian gravity --- src/powder.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/powder.c b/src/powder.c index 917f9bf17..e6e9e7652 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2154,7 +2154,7 @@ killed: parts[i].vx *= ptypes[t].collision; parts[i].vy *= ptypes[t].collision; } - else if (ptypes[t].falldown>1 && fabsf(pGravX*parts[i].vx+pGravY*parts[i].vy)>fabsf(pGravY*parts[i].vx+pGravX*parts[i].vy)) + else if (ptypes[t].falldown>1 && fabsf(pGravX*parts[i].vx+pGravY*parts[i].vy)>fabsf(pGravY*parts[i].vx-pGravX*parts[i].vy)) { float nxf, nyf, ptGrav = ptypes[t].gravity; s = 0; @@ -2191,8 +2191,8 @@ killed: if (mv<0.0001f) break; pGravX /= mv; pGravY /= mv; - nxf += r*pGravY; - nyf -= r*pGravX; + nxf += r*pGravY + 0.1f*pGravX; + nyf += -r*pGravX + 0.1f*pGravY; nx = (int)(nxf+0.5f); ny = (int)(nyf+0.5f); if (nx<0 || ny<0 || nx>=XRES || ny >=YRES) @@ -2200,7 +2200,13 @@ killed: if ((pmap[ny][nx]&0xFF)!=t || bmap[ny/CELL][nx/CELL]) { s = do_move(i, x, y, nxf, nyf); - if (s || bmap[ny/CELL][nx/CELL]!=WL_STREAM) + if (s) + { + nx = (int)(parts[i].x+0.5f); + ny = (int)(parts[i].y+0.5f); + break; + } + if (bmap[ny/CELL][nx/CELL]!=WL_STREAM) break; } }