From 14f62c132136ba8696cf204fb421ba4f10414a6a Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Thu, 8 Oct 2009 10:18:14 +0000 Subject: Smoke: * Enable external forces like e.g. wind --- intern/smoke/extern/smoke_API.h | 4 ++++ intern/smoke/intern/FLUID_3D.cpp | 14 +++++++------- intern/smoke/intern/smoke_API.cpp | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) (limited to 'intern/smoke') diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h index 5607df70cf3..ea106c81303 100644 --- a/intern/smoke/extern/smoke_API.h +++ b/intern/smoke/extern/smoke_API.h @@ -50,6 +50,10 @@ float *smoke_get_velocity_x(struct FLUID_3D *fluid); float *smoke_get_velocity_y(struct FLUID_3D *fluid); float *smoke_get_velocity_z(struct FLUID_3D *fluid); +float *smoke_get_force_x(struct FLUID_3D *fluid); +float *smoke_get_force_y(struct FLUID_3D *fluid); +float *smoke_get_force_z(struct FLUID_3D *fluid); + unsigned char *smoke_get_obstacle(struct FLUID_3D *fluid); size_t smoke_get_index(int x, int max_x, int y, int max_y, int z); diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp index bb2227801c7..729d73bb4f3 100644 --- a/intern/smoke/intern/FLUID_3D.cpp +++ b/intern/smoke/intern/FLUID_3D.cpp @@ -184,13 +184,6 @@ void FLUID_3D::step() { // addSmokeTestCase(_density, _res); // addSmokeTestCase(_heat, _res); - - // wipe forces - for (int i = 0; i < _totalCells; i++) - { - _xForce[i] = _yForce[i] = _zForce[i] = 0.0f; - // _obstacles[i] &= ~2; - } wipeBoundaries(); @@ -232,6 +225,13 @@ void FLUID_3D::step() // todo xxx dg: only clear obstacles, not boundaries // memset(_obstacles, 0, sizeof(unsigned char)*_xRes*_yRes*_zRes); + + // wipe forces + // for external forces we can't do it at the beginning of this function but at the end + for (int i = 0; i < _totalCells; i++) + { + _xForce[i] = _yForce[i] = _zForce[i] = 0.0f; + } } ////////////////////////////////////////////////////////////////////// diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp index 67df6e805d8..2d1d590fcc0 100644 --- a/intern/smoke/intern/smoke_API.cpp +++ b/intern/smoke/intern/smoke_API.cpp @@ -235,6 +235,21 @@ extern "C" float *smoke_get_velocity_z(FLUID_3D *fluid) return fluid->_zVelocity; } +extern "C" float *smoke_get_force_x(FLUID_3D *fluid) +{ + return fluid->_xForce; +} + +extern "C" float *smoke_get_force_y(FLUID_3D *fluid) +{ + return fluid->_yForce; +} + +extern "C" float *smoke_get_force_z(FLUID_3D *fluid) +{ + return fluid->_zForce; +} + extern "C" float *smoke_turbulence_get_density(WTURBULENCE *wt) { return wt ? wt->getDensityBig() : NULL; -- cgit v1.2.3