|
32 | 32 | SOLREF_MODE_RAW, |
33 | 33 | ) |
34 | 34 | from newton._src.solvers.mujoco.utils import MjcEqualityTargetKind |
| 35 | +from newton._src.usd import utils as usd_utils |
35 | 36 | from newton._src.utils.color import color_linear_to_srgb |
36 | 37 | from newton._src.utils.import_usd import _is_uniform_scale |
37 | 38 | from newton.math import quat_between_axes |
|
47 | 48 | def _expect_jointless_articulation_warning(test): |
48 | 49 | """Require the benign jointless-articulation warning on OpenUSD < 26.0. |
49 | 50 |
|
50 | | - ``UsdPhysics.LoadUsdPhysicsFromRange`` in OpenUSD < 26.0 (e.g. the |
| 51 | + ``UsdPhysics``'s native physics parser in OpenUSD < 26.0 (e.g. the |
51 | 52 | ``usd-exchange`` build resolved on ``aarch64``) reports an articulation root |
52 | 53 | that has no joints as an invalid ``ArticulationDesc``, which |
53 | 54 | :func:`~newton.utils.parse_usd` surfaces as a ``UserWarning``; usd-core |
@@ -4897,7 +4898,7 @@ def verify_usdphysics_parser(test, file, model, compare_min_max_coords, floating |
4897 | 4898 | from pxr import Gf, Sdf, Usd, UsdPhysics |
4898 | 4899 |
|
4899 | 4900 | stage = Usd.Stage.Open(file) |
4900 | | - parsed = UsdPhysics.LoadUsdPhysicsFromRange(stage, ["/"]) |
| 4901 | + parsed = usd_utils.load_physics_from_range(stage, ["/"]) |
4901 | 4902 | # since the key is generated from USD paths we can assume that keys are unique |
4902 | 4903 | body_key_to_idx = dict(zip(model.body_label, range(model.body_count), strict=False)) |
4903 | 4904 | shape_key_to_idx = dict(zip(model.shape_label, range(model.shape_count), strict=False)) |
@@ -10547,8 +10548,10 @@ def test_scene_path(self): |
10547 | 10548 | scene = UsdPhysics.Scene.Define(stage, "/Scene") |
10548 | 10549 | scene.CreateGravityMagnitudeAttr(2.0) |
10549 | 10550 |
|
10550 | | - load_physics = UsdPhysics.LoadUsdPhysicsFromRange |
10551 | | - with mock.patch.object(UsdPhysics, "LoadUsdPhysicsFromRange", wraps=load_physics) as load_physics_mock: |
| 10551 | + # Patch Newton's compat wrapper rather than the OpenUSD entry point, whose name |
| 10552 | + # differs across OpenUSD versions. |
| 10553 | + load_physics = usd_utils.load_physics_from_range |
| 10554 | + with mock.patch.object(usd_utils, "load_physics_from_range", wraps=load_physics) as load_physics_mock: |
10552 | 10555 | result = newton.ModelBuilder().add_usd(stage) |
10553 | 10556 |
|
10554 | 10557 | load_physics_mock.assert_called_once() |
@@ -13197,8 +13200,8 @@ def test_scenes(self): |
13197 | 13200 | first.CreateGravityMagnitudeAttr(2.0) |
13198 | 13201 | second = UsdPhysics.Scene.Define(stage, "/World/SecondScene") |
13199 | 13202 |
|
13200 | | - load_physics = UsdPhysics.LoadUsdPhysicsFromRange |
13201 | | - with mock.patch.object(UsdPhysics, "LoadUsdPhysicsFromRange", wraps=load_physics) as load_physics_mock: |
| 13203 | + load_physics = usd_utils.load_physics_from_range |
| 13204 | + with mock.patch.object(usd_utils, "load_physics_from_range", wraps=load_physics) as load_physics_mock: |
13202 | 13205 | scenes = usd.get_physics_scenes(stage) |
13203 | 13206 |
|
13204 | 13207 | load_physics_mock.assert_called_once() |
|
0 commit comments