From 78e5a299900233aa8779f87947edb9f37f9336bf Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Tue, 27 Jul 2010 15:33:21 +0000 Subject: Smoke: - Fix typo in tooltip - Add timeframe independand timesteps --- intern/smoke/extern/smoke_API.h | 2 +- intern/smoke/intern/smoke_API.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'intern/smoke') diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h index d1012eef76e..b340c914519 100644 --- a/intern/smoke/extern/smoke_API.h +++ b/intern/smoke/extern/smoke_API.h @@ -42,7 +42,7 @@ struct FLUID_3D *smoke_init(int *res, float *p0); void smoke_free(struct FLUID_3D *fluid); void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta, float *dt_factor, float *vorticity, int *border_colli); -void smoke_step(struct FLUID_3D *fluid, size_t framenr); +void smoke_step(struct FLUID_3D *fluid, size_t framenr, float fps); float *smoke_get_density(struct FLUID_3D *fluid); float *smoke_get_heat(struct FLUID_3D *fluid); diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp index 23c12c17014..168395f370d 100644 --- a/intern/smoke/intern/smoke_API.cpp +++ b/intern/smoke/intern/smoke_API.cpp @@ -75,13 +75,13 @@ extern "C" size_t smoke_get_index2d(int x, int max_x, int y /*, int max_y, int z return x + y * max_x; } -extern "C" void smoke_step(FLUID_3D *fluid, size_t framenr) +extern "C" void smoke_step(FLUID_3D *fluid, size_t framenr, float fps) { /* stability values copied from wturbulence.cpp */ const int maxSubSteps = 25; const float maxVel = 0.5f; /* TODO: maybe 0.5 is still too high, please confirm! -dg */ - const float dt = DT_DEFAULT; + float dt = DT_DEFAULT; float maxVelMag = 0.0f; int totalSubsteps; int substep = 0; @@ -97,6 +97,9 @@ extern "C" void smoke_step(FLUID_3D *fluid, size_t framenr) maxVelMag = vtemp; } + /* adapt timestep for different framerates, dt = 0.1 is at 25fps */ + dt *= (25.0f / fps); + maxVelMag = sqrt(maxVelMag) * dt * (*(fluid->_dtFactor)); totalSubsteps = (int)((maxVelMag / maxVel) + 1.0f); /* always round up */ totalSubsteps = (totalSubsteps < 1) ? 1 : totalSubsteps; -- cgit v1.2.3