Fix: Crash during USD import of an instanced point-instancer

Found while trying to import an instanced point-instancer with the
operator setting `support_scene_instancing=false`.

The point-instancer Prototype would be partially processed but not
completely since the option was disabled. This caused a discrepancy
during the final portion of import where the view layer was synced and
we attempted to query for an object that was not present.

Pull Request: https://projects.blender.org/blender/blender/pulls/144845
This commit is contained in:
Jesse Yurkovich
2025-08-22 22:22:47 +02:00
committed by Jesse Yurkovich
parent ae26bc82b0
commit bd6c4d73a0
4 changed files with 195 additions and 0 deletions

View File

@@ -928,6 +928,12 @@ void USDStageReader::collect_point_instancer_proto_paths(const pxr::UsdPrim &pri
}
}
/* We should only consider potential point instancers if they would be included by the scene
* instancing flags. */
if (!params_.support_scene_instancing && child_prim.IsInPrototype()) {
continue;
}
if (pxr::UsdGeomPointInstancer instancer = pxr::UsdGeomPointInstancer(child_prim)) {
pxr::SdfPathVector paths;
instancer.GetPrototypesRel().GetTargets(&paths);

View File

@@ -0,0 +1,98 @@
==== Meshes: 3
- Mesh 'A' vtx:4 face:1 loop:4 edge:4
- 0 1 3 2
- 0/2 0/1 1/3 2/3
- attr 'position' FLOAT_VECTOR POINT
- (-0.500, -0.500, 0.000)
- (0.500, -0.500, 0.000)
- (-0.500, 0.500, 0.000)
- (0.500, 0.500, 0.000)
- attr 'sharp_edge' BOOLEAN EDGE
- 0 0 0 0
- attr 'material_index' INT FACE
- 0
- attr 'custom_normal' INT16_2D CORNER
- (0, 0)
- (0, 0)
- (0, 0)
- (0, 0)
- attr 'st' FLOAT2 CORNER
- (0.000, 0.000)
- (1.000, 0.000)
- (1.000, 1.000)
- (0.000, 1.000)
- Mesh 'A.001' vtx:4 face:1 loop:4 edge:4
- 0 1 3 2
- 0/2 0/1 1/3 2/3
- attr 'position' FLOAT_VECTOR POINT
- (-0.500, -0.500, 0.000)
- (0.500, -0.500, 0.000)
- (-0.500, 0.500, 0.000)
- (0.500, 0.500, 0.000)
- attr 'sharp_edge' BOOLEAN EDGE
- 0 0 0 0
- attr 'material_index' INT FACE
- 0
- attr 'custom_normal' INT16_2D CORNER
- (0, 0)
- (0, 0)
- (0, 0)
- (0, 0)
- attr 'st' FLOAT2 CORNER
- (0.000, 0.000)
- (1.000, 0.000)
- (1.000, 1.000)
- (0.000, 1.000)
- Mesh 'A.002' vtx:4 face:1 loop:4 edge:4
- 0 1 3 2
- 0/2 0/1 1/3 2/3
- attr 'position' FLOAT_VECTOR POINT
- (-0.500, -0.500, 0.000)
- (0.500, -0.500, 0.000)
- (-0.500, 0.500, 0.000)
- (0.500, 0.500, 0.000)
- attr 'sharp_edge' BOOLEAN EDGE
- 0 0 0 0
- attr 'material_index' INT FACE
- 0
- attr 'custom_normal' INT16_2D CORNER
- (0, 0)
- (0, 0)
- (0, 0)
- (0, 0)
- attr 'st' FLOAT2 CORNER
- (0.000, 0.000)
- (1.000, 0.000)
- (1.000, 1.000)
- (0.000, 1.000)
==== Objects: 6
- Obj 'A' MESH data:'A'
- pos 0.000, 0.000, 0.000
- rot 0.000, 0.000, 0.000 (XYZ)
- scl 1.000, 1.000, 1.000
- Obj 'A.001' MESH data:'A.001'
- pos 0.000, 0.000, 0.000
- rot 0.000, 0.000, 0.000 (XYZ)
- scl 1.000, 1.000, 1.000
- Obj 'A.002' MESH data:'A.002' par:'main_inst1'
- pos 0.000, 0.000, 0.000
- rot 0.627, 0.435, 0.000 (XYZ)
- scl 1.000, 1.000, 1.000
- Obj 'main_inst1' EMPTY par:'root'
- pos -2.680, -1.249, -0.181
- rot 0.000, 0.000, 0.000 (XYZ)
- scl 1.000, 1.000, 1.000
- Obj 'point_instancer' POINTCLOUD data:'point_instancer' par:'main_inst1'
- pos 0.000, 0.000, 0.000
- rot 0.000, 0.000, 0.000 (XYZ)
- scl 1.000, 1.000, 1.000
- 1 modifiers
- NODES 'GeometryNodes'
- Obj 'root' EMPTY
- pos 0.000, 0.000, 0.000
- rot 0.000, 0.000, 0.000 (XYZ)
- scl 1.000, 1.000, 1.000

View File

@@ -0,0 +1,3 @@
{
"support_scene_instancing": false
}

View File

@@ -0,0 +1,88 @@
#usda 1.0
(
defaultPrim = "root"
doc = "HAND CRAFTED!"
metersPerUnit = 1
upAxis = "Z"
)
def Xform "root"
{
def Xform "main_inst1"
{
float3 xformOp:rotateXYZ = (0, -0, 0)
float3 xformOp:scale = (1, 1, 1)
double3 xformOp:translate = (-2.6795833110809326, -1.2492483854293823, -0.18081282079219818)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
def Xform "point_instancer_0" (
instanceable = true
prepend references = </root/prototypes/point_instancer>
)
{
}
def Xform "A_0_0_0_0" (
instanceable = true
prepend references = </root/prototypes/A_0_0_0>
)
{
float3 xformOp:rotateXYZ = (35.899998, 24.899998, 0.0000011150067)
float3 xformOp:scale = (1, 1, 1)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
}
}
class "prototypes"
{
def Xform "point_instancer"
{
def PointInstancer "point_instancer"
{
quath[] orientations = [(0.928711, 0.301025, 0.205078, -0.0664673)]
point3f[] positions = [(0, 0, 0)]
int[] protoIndices = [0]
rel prototypes = </root/prototypes/point_instancer/point_instancer/Prototypes/Prototype_0>
float3[] scales = [(1, 1, 1)]
def "Prototypes"
{
def "Prototype_0" (
prepend references = </root/prototypes/point_instancer/A_0_0_0>
)
{
}
}
}
def "A_0_0_0" (
instanceable = true
prepend references = </root/prototypes/A_0_0_0>
)
{
}
}
def "A_0_0_0"
{
def Mesh "A" (
active = true
)
{
float3[] extent = [(-0.5, -0.5, 0), (0.5, 0.5, 0)]
int[] faceVertexCounts = [4]
int[] faceVertexIndices = [0, 1, 3, 2]
normal3f[] normals = [(0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1)] (
interpolation = "faceVarying"
)
point3f[] points = [(-0.5, -0.5, 0), (0.5, -0.5, 0), (-0.5, 0.5, 0), (0.5, 0.5, 0)]
texCoord2f[] primvars:st = [(0, 0), (1, 0), (1, 1), (0, 1)] (
interpolation = "faceVarying"
)
uniform token subdivisionScheme = "none"
}
}
}
}