@@ -604,6 +604,44 @@ def test_rigid_body_set_material_properties(num_cubes, device):
604604 torch .testing .assert_close (materials_to_check .reshape (num_cubes , 3 ), materials )
605605
606606
607+ @pytest .mark .parametrize ("num_cubes" , [1 , 2 ])
608+ @pytest .mark .parametrize ("device" , ["cuda:0" , "cpu" ])
609+ @pytest .mark .isaacsim_ci
610+ def test_set_material_properties_index (num_cubes , device ):
611+ """Test setting material properties using the set_material_properties_index API."""
612+ with build_simulation_context (
613+ device = device , gravity_enabled = True , add_ground_plane = True , auto_add_lighting = True
614+ ) as sim :
615+ sim ._app_control_on_stop_handle = None
616+ # Generate cubes scene
617+ cube_object , _ = generate_cubes_scene (num_cubes = num_cubes , device = device )
618+
619+ # Play sim
620+ sim .reset ()
621+
622+ # Get number of shapes
623+ max_shapes = cube_object .root_view .max_shapes
624+
625+ # Generate random material properties: (static_friction, dynamic_friction, restitution)
626+ materials = torch .empty (num_cubes , max_shapes , 3 , device = "cpu" ).uniform_ (0.0 , 1.0 )
627+ # Ensure dynamic friction <= static friction
628+ materials [..., 1 ] = torch .min (materials [..., 0 ], materials [..., 1 ])
629+
630+ # Use the new set_material_properties_index API
631+ env_ids = torch .arange (num_cubes , dtype = torch .int32 )
632+ cube_object .set_material_properties_index (materials = materials , env_ids = env_ids )
633+
634+ # Simulate physics
635+ sim .step ()
636+ cube_object .update (sim .cfg .dt )
637+
638+ # Get material properties from simulation
639+ materials_check = wp .to_torch (cube_object .root_view .get_material_properties ())
640+
641+ # Check if material properties are set correctly
642+ torch .testing .assert_close (materials_check , materials )
643+
644+
607645@pytest .mark .parametrize ("num_cubes" , [1 , 2 ])
608646@pytest .mark .parametrize ("device" , ["cuda:0" , "cpu" ])
609647@pytest .mark .isaacsim_ci
0 commit comments