diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-01-30 16:06:48 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-01-30 16:09:32 +0400 |
commit | 2b55d7895ced2c737e827e6a808634f730d275fc (patch) | |
tree | 093b89da72bde8905281b5259168ccea7bf29b14 /source/blender/modifiers/intern/MOD_laplaciandeform.c | |
parent | 810c6d1880b9cb2944ab2bcb5eb60d8dedd97a64 (diff) |
Fix T38403: Laplacian smooth on instanced objects leads to crash.
The laplacian modifiers (smooth and deform) use the OpenNL library,
which is not threadsafe due to the use of a global context variable.
Ideally this would be changed so that an explicit context can be
created for every caller of the OpenNL functions, but since OpenNL's
most recent version is from 2010 this is unlikely to happen.
As a workaround for now just use a mutex to prevent conflicting OpenNL
calls. Eventually OpenNL can be replaced by eigen or ceres.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_laplaciandeform.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_laplaciandeform.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index defd287034e..7b5b73e0f6d 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -452,6 +452,10 @@ static void laplacianDeformPreview(LaplacianSystem *sys, float (*vertexCos)[3]) n = sys->total_verts; na = sys->total_anchors; +#ifdef OPENNL_THREADING_HACK + modifier_opennl_lock(); +#endif + if (!sys->is_matrix_computed) { nlNewContext(); sys->context = nlGetCurrent(); @@ -530,12 +534,9 @@ static void laplacianDeformPreview(LaplacianSystem *sys, float (*vertexCos)[3]) sys->has_solution = false; } sys->is_matrix_computed = true; - } - else { - if (!sys->has_solution) { - return; - } + } + else if (sys->has_solution) { nlBegin(NL_SYSTEM); nlBegin(NL_MATRIX); @@ -589,6 +590,10 @@ static void laplacianDeformPreview(LaplacianSystem *sys, float (*vertexCos)[3]) sys->has_solution = false; } } + +#ifdef OPENNL_THREADING_HACK + modifier_opennl_unlock(); +#endif } static bool isValidVertexGroup(LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm) |