From fe0aa375accab2a4b0d4af06f2c960ec0e2aa3db Mon Sep 17 00:00:00 2001 From: Jesse Yurkovich Date: Thu, 12 Jun 2025 00:52:07 +0200 Subject: [PATCH] Fix: USD: Correctly process point instancers using overs for the prototypes The canonical way to define Point Instancers in USD is to use "overs" for the prototype instances[1]. However, our current support was coded and tested against setups using Scope prims to contain the prototypes instead. Both approaches are valid USD, but we need to support the canonical way which we so far did not; the overs were incorrectly excluded from processing. Original patch from Michael Kowalski [1] https://openusd.org/release/api/class_usd_geom_point_instancer.html#UsdGeomPointInstancer_protoProcessing Pull Request: https://projects.blender.org/blender/blender/pulls/140232 --- .../blender/io/usd/intern/usd_reader_stage.cc | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc b/source/blender/io/usd/intern/usd_reader_stage.cc index e8f7b8ee890..2bccbaa75d2 100644 --- a/source/blender/io/usd/intern/usd_reader_stage.cc +++ b/source/blender/io/usd/intern/usd_reader_stage.cc @@ -907,19 +907,25 @@ void USDStageReader::collect_point_instancer_proto_paths(const pxr::UsdPrim &pri pxr::UsdPrimSiblingRange children = prim.GetFilteredChildren(filter_flags); for (const auto &child_prim : children) { - const pxr::UsdGeomImageable imageable = pxr::UsdGeomImageable(child_prim); - if (!imageable) { - continue; - } - /* We should only traverse through a hierarchy, and any potential instancers, if they would be - * included by our purpose and visibility checks, matching what is inside #collect_readers. */ - if (!include_by_purpose(imageable)) { - continue; - } + /* Note we allow undefined prims in case prototypes are defined as overs. + * If the prim is defined, we apply additional checks for inclusion. */ + if (child_prim.IsDefined()) { + const pxr::UsdGeomImageable imageable = pxr::UsdGeomImageable(child_prim); + if (!imageable) { + continue; + } - if (!include_by_visibility(imageable)) { - continue; + /* We should only traverse through a hierarchy, and any potential instancers, if they would + * be included by our purpose and visibility checks, matching what is inside + * #collect_readers. */ + if (!include_by_purpose(imageable)) { + continue; + } + + if (!include_by_visibility(imageable)) { + continue; + } } if (pxr::UsdGeomPointInstancer instancer = pxr::UsdGeomPointInstancer(child_prim)) {