@@ -2913,53 +2913,43 @@ def test_mesh_primitive_COM(show_viewer, tol):
29132913
29142914
29152915@pytest .mark .required
2916- @pytest .mark .parametrize ("backend" , [gs .cpu ])
2917- def test_batched_aabb (show_viewer , tol ):
2918- scene = gs .Scene (
2919- sim_options = gs .options .SimOptions (gravity = (0.0 , 0.0 , - 10.0 )),
2920- show_viewer = show_viewer ,
2921- )
2922-
2916+ def test_batched_aabb (tol ):
2917+ scene = gs .Scene ()
29232918 plane = scene .add_entity (
2924- gs .morphs .Plane (normal = (0 , 0 , 1 ), pos = (0 , 0 , 0 )),
2925- material = gs .materials .Rigid (),
2919+ gs .morphs .Plane (
2920+ normal = (0 , 0 , 1 ),
2921+ pos = (0 , 0 , 0 ),
2922+ ),
29262923 )
29272924 box = scene .add_entity (
2928- gs .morphs .Box (size = (0.1 , 0.1 , 0.1 ), pos = (0.5 , 0 , 0.05 )),
2929- material = gs .materials .Rigid (),
2925+ gs .morphs .Box (
2926+ size = (0.1 , 0.1 , 0.1 ),
2927+ pos = (0.5 , 0 , 0.05 ),
2928+ ),
29302929 )
29312930 sphere = scene .add_entity (
2932- gs .morphs .Sphere (radius = 0.05 , pos = (- 0.5 , 0 , 0.05 )),
2933- material = gs .materials .Rigid (),
2931+ gs .morphs .Sphere (
2932+ radius = 0.05 ,
2933+ pos = (- 0.5 , 0 , 0.05 ),
2934+ ),
29342935 )
2935-
29362936 scene .build ()
29372937
29382938 all_aabbs = scene .sim .rigid_solver .get_aabb ()
2939- assert_allclose (torch .tensor (all_aabbs .shape ), torch .tensor ([3 , 2 , 3 ]), atol = tol )
2940-
29412939 plane_aabb = plane .get_aabb ()
29422940 box_aabb = box .get_aabb ()
29432941 sphere_aabb = sphere .get_aabb ()
29442942
2945- assert_allclose (torch .tensor (plane_aabb .shape [- 1 ]), torch .tensor (3 ), atol = tol )
2946- assert_allclose (torch .tensor (box_aabb .shape [- 1 ]), torch .tensor (3 ), atol = tol )
2947- assert_allclose (torch .tensor (sphere_aabb .shape [- 1 ]), torch .tensor (3 ), atol = tol )
2948-
2949- plane_aabb_squeezed = plane_aabb .squeeze () if plane_aabb .ndim == 3 else plane_aabb
2950- box_aabb_squeezed = box_aabb .squeeze () if box_aabb .ndim == 3 else box_aabb
2951- sphere_aabb_squeezed = sphere_aabb .squeeze () if sphere_aabb .ndim == 3 else sphere_aabb
2952-
2953- assert_allclose (plane_aabb_squeezed , all_aabbs [0 ], atol = tol )
2954- assert_allclose (box_aabb_squeezed , all_aabbs [1 ], atol = tol )
2955- assert_allclose (sphere_aabb_squeezed , all_aabbs [2 ], atol = tol )
2943+ assert_allclose (all_aabbs .shape , (3 , 2 , 3 ), atol = 0 )
2944+ assert_allclose (plane_aabb .shape [- 1 ], 3 , atol = 0 )
2945+ assert_allclose (box_aabb .shape [- 1 ], 3 , atol = 0 )
2946+ assert_allclose (sphere_aabb .shape [- 1 ], 3 , atol = 0 )
2947+ assert_allclose ((plane_aabb , box_aabb , sphere_aabb ), all_aabbs , atol = tol )
29562948
2957- expected_box_min = torch .tensor ([0.45 , - 0.05 , 0.0 ])
2958- expected_box_max = torch .tensor ([0.55 , 0.05 , 0.1 ])
2959- assert_allclose (box_aabb_squeezed [0 ], expected_box_min , atol = tol )
2960- assert_allclose (box_aabb_squeezed [1 ], expected_box_max , atol = tol )
2949+ box_aabb_min , box_aabb_max = box_aabb
2950+ assert_allclose (box_aabb_min , (0.45 , - 0.05 , 0.0 ), atol = tol )
2951+ assert_allclose (box_aabb_max , (0.55 , 0.05 , 0.1 ), atol = tol )
29612952
2962- expected_sphere_min = torch .tensor ([- 0.55 , - 0.05 , 0.0 ])
2963- expected_sphere_max = torch .tensor ([- 0.45 , 0.05 , 0.1 ])
2964- assert_allclose (sphere_aabb_squeezed [0 ], expected_sphere_min , atol = tol )
2965- assert_allclose (sphere_aabb_squeezed [1 ], expected_sphere_max , atol = tol )
2953+ sphere_aabb_min , sphere_aabb_max = sphere_aabb
2954+ assert_allclose (sphere_aabb_min , (- 0.55 , - 0.05 , 0.0 ), atol = tol )
2955+ assert_allclose (sphere_aabb_max , (- 0.45 , 0.05 , 0.1 ), atol = tol )
0 commit comments