[Bf-blender-cvs] [e6954a5a7cd] master: Fix race condition invalidating object data's bounding box
Sergey Sharybin
noreply at git.blender.org
Wed Apr 26 16:00:22 CEST 2017
Commit: e6954a5a7cd9439787c3b0bf04e8970962eb6315
Author: Sergey Sharybin
Date: Wed Apr 26 15:40:32 2017 +0200
Branches: master
https://developer.blender.org/rBe6954a5a7cd9439787c3b0bf04e8970962eb6315
Fix race condition invalidating object data's bounding box
===================================================================
M source/blender/blenkernel/intern/object.c
===================================================================
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 6e754755cf3..fbca03c1e07 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -127,6 +127,7 @@
#endif
#include "CCGSubSurf.h"
+#include "atomic_ops.h"
#include "GPU_material.h"
@@ -319,19 +320,24 @@ void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_sr
/* free data derived from mesh, called when mesh changes or is freed */
void BKE_object_free_derived_caches(Object *ob)
{
- /* also serves as signal to remake texspace */
+ /* Also serves as signal to remake texspace.
+ *
+ * NOTE: This function can be called from threads on different objects
+ * sharing same data datablock. So we need to ensure atomic nature of
+ * data modification here.
+ */
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
if (me && me->bb) {
- me->bb->flag |= BOUNDBOX_DIRTY;
+ atomic_fetch_and_or_uint32((uint*)&me->bb->flag, BOUNDBOX_DIRTY);
}
}
else if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
Curve *cu = ob->data;
if (cu && cu->bb) {
- cu->bb->flag |= BOUNDBOX_DIRTY;
+ atomic_fetch_and_or_uint32((uint*)&cu->bb->flag, BOUNDBOX_DIRTY);
}
}
More information about the Bf-blender-cvs
mailing list