@@ -435,7 +435,7 @@ def _create_sdf_collision_from_visual(
435435 density = 0.0 ,
436436 has_shape_collision = True ,
437437 has_particle_collision = True ,
438- is_visible = True ,
438+ is_visible = False ,
439439 )
440440 if sdf_cfg .margin is not None :
441441 shape_cfg_kwargs ["margin" ] = sdf_cfg .margin
@@ -504,18 +504,22 @@ def _apply_sdf_config(cls, builder: ModelBuilder):
504504 hydro_patterns = [re .compile (p ) for p in hydro_cfg .shape_patterns ]
505505
506506 # --- Collect shape indices that should get SDF ---
507+ # Build reverse map once: body_idx -> [mesh shape indices]
508+ body_to_shapes : dict [int , list [int ]] = {}
509+ for si in range (builder .shape_count ):
510+ if builder .shape_type [si ] == GeoType .MESH :
511+ body_to_shapes .setdefault (builder .shape_body [si ], []).append (si )
512+
507513 sdf_shape_indices : set [int ] = set ()
508514
509515 if body_patterns is not None :
510516 for body_idx in range (len (builder .body_label )):
511517 if any (p .search (builder .body_label [body_idx ]) for p in body_patterns ):
512- for si in range (builder .shape_count ):
513- if builder .shape_body [si ] == body_idx and builder .shape_type [si ] == GeoType .MESH :
514- sdf_shape_indices .add (si )
518+ sdf_shape_indices .update (body_to_shapes .get (body_idx , []))
515519
516520 if shape_patterns is not None :
517- for si in range ( builder . shape_count ):
518- if builder . shape_type [ si ] == GeoType . MESH :
521+ for shape_indices in body_to_shapes . values ( ):
522+ for si in shape_indices :
519523 if any (p .search (builder .shape_label [si ]) for p in shape_patterns ):
520524 sdf_shape_indices .add (si )
521525
0 commit comments