From d8c256da2cfa60675d273333fd558d665a0f6c27 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 23 Jul 2025 14:24:35 +0200 Subject: [PATCH] Fix #142399: Object dimensions with GPU subdivision off are inaccurate They are already known not to take into account the subdivision when GPU subdivision is on, see #96598. When GPU subdivision is off we can keep them accurate though. Pull Request: https://projects.blender.org/blender/blender/pulls/142729 --- source/blender/blenkernel/BKE_geometry_set.hh | 3 ++- source/blender/blenkernel/intern/geometry_set.cc | 10 ++++++++-- source/blender/blenkernel/intern/object.cc | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 1adb327730e..fe3c97827f2 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -224,7 +224,8 @@ struct GeometrySet { */ Vector get_components() const; - std::optional> compute_boundbox_without_instances(bool use_radius = true) const; + std::optional> compute_boundbox_without_instances(bool use_radius = true, + bool use_subdiv = false) const; friend std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set); diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 0b5699d3ab0..22bd4bdbd8d 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -197,14 +197,20 @@ Vector GeometrySet::get_components() const } std::optional> GeometrySet::compute_boundbox_without_instances( - const bool use_radius) const + const bool use_radius, const bool use_subdiv) const { std::optional> bounds; if (const PointCloud *pointcloud = this->get_pointcloud()) { bounds = bounds::merge(bounds, pointcloud->bounds_min_max(use_radius)); } if (const Mesh *mesh = this->get_mesh()) { - bounds = bounds::merge(bounds, mesh->bounds_min_max()); + /* Use tessellated subdivision mesh if it exists. */ + if (use_subdiv && mesh->runtime->mesh_eval) { + bounds = bounds::merge(bounds, mesh->runtime->mesh_eval->bounds_min_max()); + } + else { + bounds = bounds::merge(bounds, mesh->bounds_min_max()); + } } if (const Volume *volume = this->get_volume()) { bounds = bounds::merge(bounds, BKE_volume_min_max(volume)); diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 3c1c670a7ae..2f862e1d310 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -3553,7 +3553,8 @@ std::optional> BKE_object_evaluated_geometry_bounds(const Object { if (const blender::bke::GeometrySet *geometry = ob->runtime->geometry_set_eval) { const bool use_radius = ob->type != OB_CURVES_LEGACY; - return geometry->compute_boundbox_without_instances(use_radius); + const bool use_subdiv = true; + return geometry->compute_boundbox_without_instances(use_radius, use_subdiv); } if (const CurveCache *curve_cache = ob->runtime->curve_cache) { float3 min(std::numeric_limits::max());