Skip to content

Commit

Permalink
fix(DLR-RM#910): hiding instead of deleting objects in sample_objects…
Browse files Browse the repository at this point in the history
…_on_surface

DLR-RM#910
  • Loading branch information
MartinSmeyer authored Jun 1, 2023
1 parent f406f60 commit 3626e18
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions blenderproc/python/object/OnSurfaceSampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def sample_poses_on_surface(objects_to_sample: List[MeshObject], surface: MeshOb
and possible non-alignment of the sampling surface (i.e. on the X-Y hyperplane, can be somewhat mitigated with
precise "up_direction" value), which leads to the objects hovering slightly above the surface. So it is
recommended to use the PhysicsPositioning module afterwards for realistically looking placements of objects on
the sampling surface.
the sampling surface. If placing fails due to collisions, the object will be moved back to the intial pose
and hidden from rendering.
:param objects_to_sample: A list of objects that should be sampled above the surface.
:param surface: Object to place objects_to_sample on.
Expand All @@ -47,7 +48,7 @@ def sample_poses_on_surface(objects_to_sample: List[MeshObject], surface: MeshOb
placed_objects: List[MeshObject] = []
for obj in objects_to_sample:
print(f"Trying to put {obj.get_name()}")

initial_pose = obj.get_local2world_mat()
placed_successfully = False

for i in range(max_tries):
Expand Down Expand Up @@ -88,8 +89,9 @@ def sample_poses_on_surface(objects_to_sample: List[MeshObject], surface: MeshOb
break

if not placed_successfully:
print(f"Giving up on {obj.get_name()}, deleting...")
obj.delete()
print(f"Giving up on {obj.get_name()}, hiding...")
obj.hide(True)
obj.set_local2world_mat(initial_pose)

return placed_objects

Expand Down

0 comments on commit 3626e18

Please sign in to comment.