Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UsdGeomPointInstancer ComputeExtents not accurate when using prototypes under an over #3395

Open
cbillingham opened this issue Nov 4, 2024 · 1 comment

Comments

@cbillingham
Copy link

Description of Issue

When setting up a UsdGeomPointInstancer with prototypes defined under an over specified prim (a structure suggested by the docs), the bounding box computed by the registered ComputExtents plugin does not correctly compute prototype bounding boxes. Similar to #1436 which fixed this issue for the usdImaging adapter, I think the compute extents plugin should be updated to allow traversal of prototypes that are under an over.

Steps to Reproduce

  1. Save the following into a pointinstancer_extents.usda layer
#usda 1.0
(
    defaultPrim = "instancer"
)

def PointInstancer "instancer"
{
    rel prototypes = [</instancer/Prototypes/sphere>]
    int[] protoIndices = [0, 0, 0, 0]
    point3f[] positions = [(2, 0, 2), (2, 0, -2), (-2, 0, 2), (-2, 0, -2)]

    over "Prototypes"
    {
        def Xform "sphere"
        {
            def Sphere "sphere_geo"
            {
                float3[] extent = [(-1, -1, -1), (1, 1, 1)]
                float radius = 1
            }
        }
    }
}
  1. Open the layer, compute the bbox, see that the bbox is infinite
from pxr import Sdf, Usd, UsdGeom

stage = Usd.Stage.Open('pointinstancer_extents.usda')
prim = stage.GetPrimAtPath('/instancer')
bboxCache = UsdGeom.BBoxCache(1.0, ['default', 'render'])
print(bboxCache.ComputeLocalBound(prim)
  1. Set the Prototypes prim to SpecifierDef and compute the bbox again, see the result is now as expected
stage.GetPrimAtPath('/instancer/Prototypes').SetSpecifier(Sdf.SpecifierDef)
bboxCache.Clear()
print(bboxCache.ComputeLocalBound(prim)

Workarounds

There's some workarounds for this that resolve the problem. You can make sure the prototypes are actually defined by defining the Prototypes parent. You can make sure there is extents authored on your UsdGeomPointInstancer prim. But it would be nice if the ComputeExtents plugin supported this suggested workflow without the need for these workarounds.

System Information (OS, Hardware)

Linux (AMD Ryzen 5 2600, NVIDIA GTX 1060)
Usd v24.11

cbillingham added a commit to cbillingham/USD that referenced this issue Nov 4, 2024
…over

Fixes PixarAnimationStudiosGH-3395. As described at
https://openusd.org/docs/api/class_usd_geom_point_instancer.html#UsdGeomPointInstancer_protoProcessing
PointInstancers can define prototypes under a parent prim specified as an over.
The ComputeExtent plugin registered for PointInstancer was not correctly computing
prototype bboxes in this case. This extends UsdGeomBBoxCache to allow for a custom
prim predicate to be passed, which the updated ComputeExtent plugin takes advantage of
to traverse prototype prims in this case.
@jesschimein
Copy link
Contributor

Filed as internal issue #USD-10391

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants