BKE object: Correct bound box of bezier curve objects not matching the object viewed.
authormano-wii <germano.costa@ig.com.br>
Mon, 19 Nov 2018 10:54:49 +0000 (08:54 -0200)
committermano-wii <germano.costa@ig.com.br>
Mon, 19 Nov 2018 11:05:20 +0000 (09:05 -0200)
source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/object.c

index 02c86642b11d76f7e5e091092df2b70691e75138..b7e0e28d9f0e5dcc46e1a063d36efe71325cd50a 100644 (file)
@@ -108,5 +108,6 @@ void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, const flo
 float BKE_displist_calc_taper(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *taperobj, int cur, int tot);
 
 void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);
+struct BoundBox *BKE_displist_boundbox_get(struct Object *ob);
 
 #endif
index 8d49521831f9f5cdb633fdb06c2c0f352ff588dc..3339118f8e3d09356e3ce7de73e6bead14c5a299 100644 (file)
 #include "BKE_modifier.h"
 
 #include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_threads.h"
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_query.h"
 
+static ThreadRWMutex cache_rwlock = BLI_RWLOCK_INITIALIZER;
+
 static void boundbox_displist_object(Object *ob);
 
 void BKE_displist_elem_free(DispList *dl)
@@ -1798,6 +1801,7 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, Scene *scene, Object *ob
        if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT))
                return;
 
+       BLI_rw_mutex_lock(&cache_rwlock, THREAD_LOCK_WRITE);
        BKE_object_free_derived_caches(ob);
 
        if (!ob->runtime.curve_cache) {
@@ -1809,6 +1813,7 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, Scene *scene, Object *ob
        do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, &ob->runtime.mesh_eval, 0, for_orco, 0);
 
        boundbox_displist_object(ob);
+       BLI_rw_mutex_unlock(&cache_rwlock);
 }
 
 void BKE_displist_make_curveTypes_forRender(
@@ -1882,3 +1887,16 @@ static void boundbox_displist_object(Object *ob)
                }
        }
 }
+
+BoundBox *BKE_displist_boundbox_get(struct Object *ob)
+{
+       BLI_rw_mutex_lock(&cache_rwlock, THREAD_LOCK_READ);
+       if ((ob->bb == NULL) || (ob->bb->flag & BOUNDBOX_DIRTY)) {
+               /* This should always only be called with evaluated objects, but currently RNA is a problem here... */
+               if (ob->runtime.curve_cache != NULL) {
+                       boundbox_displist_object(ob);
+               }
+       }
+       BLI_rw_mutex_unlock(&cache_rwlock);
+       return ob->bb;
+}
index d36a583863061a8e60e75ece803c738289eb6d79..3e2367aed1be7d980d81801571e658669b54df0a 100644 (file)
@@ -2515,7 +2515,7 @@ BoundBox *BKE_object_boundbox_get(Object *ob)
                case OB_CURVE:
                case OB_SURF:
                case OB_FONT:
-                       bb = BKE_curve_boundbox_get(ob);
+                       bb = BKE_displist_boundbox_get(ob);
                        break;
                case OB_MBALL:
                        bb = BKE_mball_boundbox_get(ob);