From 5cdd88714bad7ba8bd3f776b9b544e090109b958 Mon Sep 17 00:00:00 2001 From: Fanbo Xiang Date: Wed, 1 Nov 2023 13:13:15 -0700 Subject: [PATCH] fix add_ground visual --- python/py_package/utils/viewer/viewer.py | 11 +++++++++++ python/py_package/wrapper/scene.py | 19 +++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/python/py_package/utils/viewer/viewer.py b/python/py_package/utils/viewer/viewer.py index c765e07f..8a1aa062 100644 --- a/python/py_package/utils/viewer/viewer.py +++ b/python/py_package/utils/viewer/viewer.py @@ -264,3 +264,14 @@ def control_window(self) -> ControlWindow: if isinstance(plugin, ControlWindow): return plugin return None + + def loop(self, physx_steps=0): + """ + A convenience method for opening a temporary viewer for a scene. + Simply call scene.create_viewer().loop() + """ + while not self.closed: + for _ in range(physx_steps): + self.scene.physx_system.step() + self.scene.update_render() + self.render() diff --git a/python/py_package/wrapper/scene.py b/python/py_package/wrapper/scene.py index ef6c48e8..ad2571d2 100644 --- a/python/py_package/wrapper/scene.py +++ b/python/py_package/wrapper/scene.py @@ -122,22 +122,21 @@ def add_ground( ): from .actor_builder import ActorBuilder - ground = ( - ActorBuilder() - .set_scene(self) - .add_plane_visual( + builder = self.create_actor_builder() + if render: + builder.add_plane_visual( sapien.Pose(p=[0, 0, altitude], q=[0.7071068, 0, -0.7071068, 0]), [10, *render_half_size], render_material, "", ) - .add_plane_collision( - sapien.Pose(p=[0, 0, altitude], q=[0.7071068, 0, -0.7071068, 0]), - material, - ) - .set_physx_body_type("static") - .build() + + builder.add_plane_collision( + sapien.Pose(p=[0, 0, altitude], q=[0.7071068, 0, -0.7071068, 0]), + material, ) + builder.set_physx_body_type("static") + ground = builder.build() ground.name = "ground" return ground