[Bf-blender-cvs] [b76918717db] blender-v3.1-release: Fix T95573: Incorrect bounding box of evaluated curve

Hans Goudey noreply at git.blender.org
Tue Feb 8 01:42:42 CET 2022


Commit: b76918717dbfd8363f4cf114619861dac0110e52
Author: Hans Goudey
Date:   Mon Feb 7 18:42:31 2022 -0600
Branches: blender-v3.1-release
https://developer.blender.org/rBb76918717dbfd8363f4cf114619861dac0110e52

Fix T95573: Incorrect bounding box of evaluated curve

Account for `CurveEval`, which stores the proper deformed and
procedurally created data, unlike the `nurb` list, which has always
just meant a copy of the original curve.

Also account for the case when the curve is empty by using a -1, 1,
fallback bounding box in that case, just like mesh objects.

===================================================================

M	source/blender/blenkernel/intern/curve.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc
index dda2b5076a8..f83a672b2ee 100644
--- a/source/blender/blenkernel/intern/curve.cc
+++ b/source/blender/blenkernel/intern/curve.cc
@@ -32,6 +32,7 @@
 #include "BLI_ghash.h"
 #include "BLI_index_range.hh"
 #include "BLI_math.h"
+#include "BLI_math_vec_types.hh"
 #include "BLI_utildefines.h"
 
 #include "BLT_translation.h"
@@ -59,6 +60,7 @@
 #include "BKE_lib_query.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
+#include "BKE_spline.hh"
 #include "BKE_vfont.h"
 
 #include "DEG_depsgraph.h"
@@ -68,6 +70,7 @@
 
 #include "BLO_read_write.h"
 
+using blender::float3;
 using blender::IndexRange;
 
 /* globals */
@@ -503,7 +506,10 @@ BoundBox *BKE_curve_boundbox_get(Object *ob)
     float min[3], max[3];
 
     INIT_MINMAX(min, max);
-    BKE_curve_minmax(cu, true, min, max);
+    if (!BKE_curve_minmax(cu, true, min, max)) {
+      copy_v3_fl(min, -1.0f);
+      copy_v3_fl(max, 1.0f);
+    }
 
     if (ob->runtime.bb == nullptr) {
       ob->runtime.bb = (BoundBox *)MEM_mallocN(sizeof(*ob->runtime.bb), __func__);
@@ -5066,6 +5072,16 @@ void BKE_curve_nurb_vert_active_validate(Curve *cu)
 
 bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3])
 {
+  if (cu->curve_eval != nullptr) {
+    float3 eval_min(FLT_MAX);
+    float3 eval_max(-FLT_MAX);
+    if (cu->curve_eval->bounds_min_max(eval_min, eval_max, false)) {
+      copy_v3_v3(min, eval_min);
+      copy_v3_v3(max, eval_max);
+      return true;
+    }
+  }
+
   ListBase *nurb_lb = BKE_curve_nurbs_get(cu);
   ListBase temp_nurb_lb = {nullptr, nullptr};
   const bool is_font = (BLI_listbase_is_empty(nurb_lb)) && (cu->len != 0);



More information about the Bf-blender-cvs mailing list