From afe35312e1cb32fbfb7d53e75db8dd71eb3d89ee Mon Sep 17 00:00:00 2001 From: Saveliy Skresanov Date: Sat, 19 Apr 2025 11:13:44 +0700 Subject: [PATCH] Reduce gravity effects on ambient heat. --- src/simulation/Air.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/simulation/Air.cpp b/src/simulation/Air.cpp index c1be186b4..475e33614 100644 --- a/src/simulation/Air.cpp +++ b/src/simulation/Air.cpp @@ -153,18 +153,40 @@ void Air::update_airh(void) // We use the Boussinesq approximation, i.e. we assume density to be nonconstant only // near the gravity term of the fluid equation, and we suppose that it depends linearly on the // difference between the current temperature (hv[y][x]) and some "stationary" temperature (ambientAirTemp). + float dvx, dvy; + dvx = vx[y][x]; + dvy = vy[y][x]; + if (x>=2 && x=2 && y 10.0f) + { + convGravX /= 0.1f*gravMagn; + convGravY /= 0.1f*gravMagn; + } + auto weight = (hv[y][x] - ambientAirTemp) / 10000.0f; // Our approximation works best when the temperature difference is small, so we cap it from above. if (weight > 0.01f) weight = 0.01f; - vx[y][x] += weight * convGravX; - vy[y][x] += weight * convGravY; + dvx += weight * convGravX; + dvy += weight * convGravY; } + + // Velocity cap + if (dvx > MAX_PRESSURE) dvx = MAX_PRESSURE; + if (dvx < MIN_PRESSURE) dvx = MIN_PRESSURE; + if (dvy > MAX_PRESSURE) dvy = MAX_PRESSURE; + if (dvy < MIN_PRESSURE) dvy = MIN_PRESSURE; + + vx[y][x] = dvx; + vy[y][x] = dvy; } } memcpy(hv, ohv, sizeof(hv));