Skip to content

Commit b8b0219

Browse files
committed
Get around MacOS Metal GPU taichi compiler bug (again!).
1 parent 2af9fc2 commit b8b0219

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

genesis/engine/solvers/rigid/collider_decomp.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -889,22 +889,27 @@ def _func_narrow_phase_convex_vs_convex(self):
889889
i_ga = self.broad_collision_pairs[i_pair, i_b][0]
890890
i_gb = self.broad_collision_pairs[i_pair, i_b][1]
891891

892+
if self._solver.geoms_info[i_ga].type > self._solver.geoms_info[i_gb].type:
893+
i_ga, i_gb = i_gb, i_ga
894+
892895
if (
893896
self._solver.geoms_info[i_ga].is_convex
894897
and self._solver.geoms_info[i_gb].is_convex
895898
and not self._solver.geoms_info[i_gb].type == gs.GEOM_TYPE.TERRAIN
896-
and not (
897-
self._solver._enable_multi_contact
898-
and self._solver.geoms_info[i_ga].type == gs.GEOM_TYPE.PLANE
899-
and self._solver.geoms_info[i_gb].type == gs.GEOM_TYPE.BOX
900-
)
901899
and not (
902900
self._solver._box_box_detection
903901
and self._solver.geoms_info[i_ga].type == gs.GEOM_TYPE.BOX
904902
and self._solver.geoms_info[i_gb].type == gs.GEOM_TYPE.BOX
905903
)
906904
):
907-
self._func_convex_convex_contact(i_ga, i_gb, i_b)
905+
if ti.static(sys.platform == "darwin"):
906+
self._func_convex_convex_contact(i_ga, i_gb, i_b)
907+
else:
908+
if not (
909+
self._solver.geoms_info[i_ga].type == gs.GEOM_TYPE.PLANE
910+
and self._solver.geoms_info[i_gb].type == gs.GEOM_TYPE.BOX
911+
):
912+
self._func_convex_convex_contact(i_ga, i_gb, i_b)
908913

909914
@ti.kernel
910915
def _func_narrow_phase_convex_specializations(self):
@@ -917,15 +922,11 @@ def _func_narrow_phase_convex_specializations(self):
917922
if self._solver.geoms_info[i_ga].type > self._solver.geoms_info[i_gb].type:
918923
i_ga, i_gb = i_gb, i_ga
919924

920-
if (
921-
self._solver.geoms_info[i_ga].type == gs.GEOM_TYPE.PLANE
922-
and self._solver.geoms_info[i_gb].type == gs.GEOM_TYPE.BOX
923-
):
924-
if ti.static(sys.platform == "darwin"):
925-
# FIXME: It seems redundant, why don't we just call _func_plane_box_contact directly?
926-
# Anyway in this function, we will call _func_plane_box_contact.
927-
self._func_convex_convex_contact(i_ga, i_gb, i_b)
928-
else:
925+
if ti.static(sys.platform != "darwin"):
926+
if (
927+
self._solver.geoms_info[i_ga].type == gs.GEOM_TYPE.PLANE
928+
and self._solver.geoms_info[i_gb].type == gs.GEOM_TYPE.BOX
929+
):
929930
self._func_plane_box_contact(i_ga, i_gb, i_b)
930931

931932
if ti.static(self._solver._box_box_detection):
@@ -1199,9 +1200,6 @@ def _func_contact_orthogonals(self, i_ga, i_gb, normal, i_b):
11991200

12001201
@ti.func
12011202
def _func_convex_convex_contact(self, i_ga, i_gb, i_b):
1202-
if self._solver.geoms_info[i_ga].type > self._solver.geoms_info[i_gb].type:
1203-
i_ga, i_gb = i_gb, i_ga
1204-
12051203
if (
12061204
self._solver.geoms_info[i_ga].type == gs.GEOM_TYPE.PLANE
12071205
and self._solver.geoms_info[i_gb].type == gs.GEOM_TYPE.BOX

0 commit comments

Comments
 (0)