Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/smoke.c')
-rw-r--r--source/blender/blenkernel/intern/smoke.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 009112be2c9..f31a672c664 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -50,6 +50,7 @@
#include "BLI_edgehash.h"
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
+#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLI_voxel.h"
@@ -365,6 +366,9 @@ static void smokeModifier_freeDomain(SmokeModifierData *smd)
if (smd->domain->fluid)
smoke_free(smd->domain->fluid);
+ if (smd->domain->fluid_mutex)
+ BLI_rw_mutex_free(smd->domain->fluid_mutex);
+
if (smd->domain->wt)
smoke_turbulence_free(smd->domain->wt);
@@ -436,8 +440,12 @@ void smokeModifier_reset(struct SmokeModifierData *smd)
if (smd->domain->fluid)
{
+ BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE);
+
smoke_free(smd->domain->fluid);
smd->domain->fluid = NULL;
+
+ BLI_rw_mutex_unlock(smd->domain->fluid_mutex);
}
smokeModifier_reset_turbulence(smd);
@@ -497,6 +505,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->ptcaches[1].first = smd->domain->ptcaches[1].last = NULL;
/* set some standard values */
smd->domain->fluid = NULL;
+ smd->domain->fluid_mutex = BLI_rw_mutex_alloc();
smd->domain->wt = NULL;
smd->domain->eff_group = NULL;
smd->domain->fluid_group = NULL;
@@ -2316,8 +2325,15 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
{
+ /* lock so preview render does not read smoke data while it gets modified */
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
+ BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE);
+
smokeModifier_process(smd, scene, ob, dm);
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
+ BLI_rw_mutex_unlock(smd->domain->fluid_mutex);
+
/* return generated geometry for adaptive domain */
if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain &&
smd->domain->flags & MOD_SMOKE_ADAPTIVE_DOMAIN &&