diff options
author | Hans Goudey <h.goudey@me.com> | 2022-02-08 03:42:31 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-02-08 03:42:31 +0300 |
commit | b76918717dbfd8363f4cf114619861dac0110e52 (patch) | |
tree | b12c4fd5c41a2b8629e54a2954c786b924df2fa1 | |
parent | 229d0ace026ffb3591fdad4c5a6e0530c1243025 (diff) |
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.
-rw-r--r-- | source/blender/blenkernel/intern/curve.cc | 18 |
1 files changed, 17 insertions, 1 deletions
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); |