From a9b94e5f81ced89381033fd8d13ef6e3489e2665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Thu, 14 Apr 2022 15:11:58 +0200 Subject: Fix T95700: Oject Info node does not work with GPU subdivided meshes When GPU subdivision is enabled the mesh objects remain unsubdivided on the CPU side, and subdivision should be requested somewhat manually (via `BKE_object_get_evaluated_mesh`). When referencing an object, the Object Info node calls `bke::object_get_evaluated_geometry_set` which first checks if a Geometry Set is present on the object (unless we have a mesh in edit mode). If so it will return it, if not, the object type is discriminated, which will return a properly subdivided mesh object via `add_final_mesh_as_geometry_component`. The unsubdivided mesh is returned because apparently the check on the Geometry Set always succeeds (as it is always set in `mesh_build_data`). However, the mesh inside this Geometry Set is not subdivided. This adds a check for a MeshComponent in this Geometry Set, and if one exists, calls `add_final_mesh_as_geometry_component` which will ensure that the mesh is subdivided on the CPU side as well. Differential Revision: https://developer.blender.org/D14643 --- source/blender/blenkernel/intern/geometry_set_instances.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc index 44ffd64e475..d3c3f41779a 100644 --- a/source/blender/blenkernel/intern/geometry_set_instances.cc +++ b/source/blender/blenkernel/intern/geometry_set_instances.cc @@ -50,7 +50,12 @@ GeometrySet object_get_evaluated_geometry_set(const Object &object) return geometry_set; } if (object.runtime.geometry_set_eval != nullptr) { - return *object.runtime.geometry_set_eval; + GeometrySet geometry_set = *object.runtime.geometry_set_eval; + /* Ensure that subdivision is performed on the CPU. */ + if (geometry_set.has_mesh()) { + add_final_mesh_as_geometry_component(object, geometry_set); + } + return geometry_set; } /* Otherwise, construct a new geometry set with the component based on the object type. */ -- cgit v1.2.3