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
This commit is contained in:
Brecht Van Lommel
2025-07-23 14:24:35 +02:00
committed by Brecht Van Lommel
parent 7f0f8d4e94
commit d8c256da2c
3 changed files with 12 additions and 4 deletions

View File

@@ -224,7 +224,8 @@ struct GeometrySet {
*/
Vector<const GeometryComponent *> get_components() const;
std::optional<Bounds<float3>> compute_boundbox_without_instances(bool use_radius = true) const;
std::optional<Bounds<float3>> compute_boundbox_without_instances(bool use_radius = true,
bool use_subdiv = false) const;
friend std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set);

View File

@@ -197,14 +197,20 @@ Vector<const GeometryComponent *> GeometrySet::get_components() const
}
std::optional<Bounds<float3>> GeometrySet::compute_boundbox_without_instances(
const bool use_radius) const
const bool use_radius, const bool use_subdiv) const
{
std::optional<Bounds<float3>> 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));

View File

@@ -3553,7 +3553,8 @@ std::optional<Bounds<float3>> 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<float>::max());