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.
This commit is contained in:
parent
229d0ace02
commit
b76918717d
Notes:
blender-bot
2023-02-13 16:17:33 +01:00
Referenced by commit d1202bd641
, Fix T95620: Crash When Entering Edit Mode on a Curve
Referenced by issue #95620, Crash When Entering Edit Mode on a Curve
Referenced by issue #95573, GeoNodes with curve on the output is screwing up Frame Selected (Numpad.)
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue