Skip to content

Commit d13b026

Browse files
andrewkaufmanclaude
andcommitted
Cover the guide-only asset case
The empty-viewport fallback removal had no regression test: the existing collision-only case authors a default-purpose sphere, so it exercises drawability rather than the fallback. Pin the case that actually changed -- every prim guide, nothing drawn, force_show_colliders to inspect. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 6e3f17c commit d13b026

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

newton/tests/test_import_usd.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11375,6 +11375,35 @@ def Sphere "CollisionSphere" (
1137511375
self.assertTrue(collision_flags & ShapeFlags.COLLIDE_SHAPES)
1137611376
self.assertTrue(collision_flags & ShapeFlags.VISIBLE)
1137711377

11378+
@unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
11379+
def test_guide_only_asset_draws_nothing_by_default(self):
11380+
"""An asset whose every prim is guide has no render geometry.
11381+
11382+
Collision-only imports used to have all their colliders forced visible so the
11383+
viewport would not come up blank, which overrode the one thing such an asset
11384+
states. ``guide`` means the geometry is not viewport geometry; nothing visible
11385+
is the correct depiction, and ``force_show_colliders`` is how it is inspected.
11386+
"""
11387+
from pxr import Usd, UsdGeom, UsdPhysics
11388+
11389+
stage = Usd.Stage.CreateInMemory()
11390+
UsdPhysics.Scene.Define(stage, "/physicsScene")
11391+
body = UsdGeom.Xform.Define(stage, "/Body")
11392+
UsdPhysics.RigidBodyAPI.Apply(body.GetPrim())
11393+
collider = UsdGeom.Sphere.Define(stage, "/Body/Collider").GetPrim()
11394+
UsdPhysics.CollisionAPI.Apply(collider)
11395+
UsdGeom.Imageable(collider).CreatePurposeAttr().Set(UsdGeom.Tokens.guide)
11396+
11397+
builder = newton.ModelBuilder()
11398+
shape = builder.add_usd(stage)["path_shape_map"]["/Body/Collider"]
11399+
flags = builder.shape_flags[shape]
11400+
self.assertTrue(flags & ShapeFlags.COLLIDE_SHAPES)
11401+
self.assertFalse(flags & ShapeFlags.VISIBLE)
11402+
11403+
forced = newton.ModelBuilder()
11404+
forced_shape = forced.add_usd(stage, force_show_colliders=True)["path_shape_map"]["/Body/Collider"]
11405+
self.assertTrue(forced.shape_flags[forced_shape] & ShapeFlags.VISIBLE)
11406+
1137811407
@unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
1137911408
def test_guide_purpose_shapes_not_visible(self):
1138011409
"""Guide-purpose prims (e.g. collision geometry authored by MuJoCo-USD

0 commit comments

Comments
 (0)