@@ -153,6 +153,12 @@ def _init_collision_fields(self) -> None:
153153 self ._max_collision_pairs = min (n_possible_pairs , self ._solver ._max_collision_pairs )
154154 self ._max_contact_pairs = self ._max_collision_pairs * self ._n_contacts_per_pair
155155
156+ self ._warn_msg_max_collision_pairs = (
157+ f"{ colors .YELLOW } [Genesis] [00:00:00] [WARNING] Ignoring contact pair to avoid exceeding max "
158+ f"({ self ._max_contact_pairs } ). Please increase the value of RigidSolver's option "
159+ f"'max_collision_pairs'.{ formats .RESET } "
160+ )
161+
156162 ############## broad phase SAP ##############
157163 # This buffer stores the AABBs along the search axis of all geoms
158164 struct_sort_buffer = ti .types .struct (value = gs .ti_float , i_g = gs .ti_int , is_max = gs .ti_int )
@@ -299,23 +305,23 @@ def _kernel_clear(
299305 self .n_contacts [i_b ] = 0
300306
301307 def detection (self ) -> None :
302- from genesis .utils .tools import create_timer
308+ # from genesis.utils.tools import create_timer
303309
304310 self ._contacts_info_cache = {}
305- timer = create_timer (name = "69477ab0-5e75-47cb-a4a5-d4eebd9336ca" , level = 3 , ti_sync = True , skip_first_call = True )
311+ # timer = create_timer(name="69477ab0-5e75-47cb-a4a5-d4eebd9336ca", level=3, ti_sync=True, skip_first_call=True)
306312 self ._func_update_aabbs ()
307- timer .stamp ("func_update_aabbs" )
313+ # timer.stamp("func_update_aabbs")
308314 self ._func_broad_phase ()
309- timer .stamp ("func_broad_phase" )
315+ # timer.stamp("func_broad_phase")
310316 self ._func_narrow_phase_convex_vs_convex ()
311317 self ._func_narrow_phase_convex_specializations ()
312- timer .stamp ("func_narrow_phase" )
318+ # timer.stamp("func_narrow_phase")
313319 if self ._has_terrain :
314320 self ._func_narrow_phase_any_vs_terrain ()
315- timer .stamp ("_func_narrow_phase_any_vs_terrain" )
321+ # timer.stamp("_func_narrow_phase_any_vs_terrain")
316322 if self ._has_nonconvex_nonterrain :
317323 self ._func_narrow_phase_nonconvex_vs_nonterrain ()
318- timer .stamp ("_func_narrow_phase_nonconvex_vs_nonterrain" )
324+ # timer.stamp("_func_narrow_phase_nonconvex_vs_nonterrain")
319325
320326 @ti .func
321327 def _func_point_in_geom_aabb (self , point , i_g , i_b ):
@@ -770,11 +776,7 @@ def _func_broad_phase(self):
770776 continue
771777
772778 if self .n_broad_pairs [i_b ] == self ._max_collision_pairs :
773- # print(
774- # f"{colors.YELLOW}[Genesis] [00:00:00] [WARNING] Ignoring collision pair to avoid "
775- # f"exceeding max ({self._max_collision_pairs}). Please increase the value of "
776- # f"RigidSolver's option 'max_collision_pairs'.{formats.RESET}"
777- # )
779+ ti .static_print (self ._warn_msg_max_collision_pairs )
778780 break
779781 self .broad_collision_pairs [self .n_broad_pairs [i_b ], i_b ][0 ] = i_ga
780782 self .broad_collision_pairs [self .n_broad_pairs [i_b ], i_b ][1 ] = i_gb
@@ -1107,12 +1109,7 @@ def _func_add_contact(self, i_ga, i_gb, normal, contact_pos, penetration, i_b):
11071109 i_col = self .n_contacts [i_b ]
11081110
11091111 if i_col == self ._max_contact_pairs :
1110- # print(
1111- # f"{colors.YELLOW}[Genesis] [00:00:00] [WARNING] Ignoring contact pair to avoid exceeding max "
1112- # f"({self._max_contact_pairs}). Please increase the value of RigidSolver's option "
1113- # f"'max_collision_pairs'.{formats.RESET}"
1114- # )
1115- pass
1112+ ti .static_print (self ._warn_msg_max_collision_pairs )
11161113 else :
11171114 ga_info = self ._solver .geoms_info [i_ga ]
11181115 gb_info = self ._solver .geoms_info [i_gb ]
@@ -1299,6 +1296,7 @@ def _func_convex_convex_contact(self, i_ga, i_gb, i_b):
12991296 # Because of this, it is necessary to run it twice and take the contact information
13001297 # associated with the point of deepest penetration.
13011298 try_sdf = True
1299+
13021300 ### GJK
13031301 elif ti .static (self .ccd_algorithm == CCD_ALGORITHM_CODE .GJK ):
13041302 # If it was not the first detection, only detect single contact point.
@@ -1313,12 +1311,11 @@ def _func_convex_convex_contact(self, i_ga, i_gb, i_b):
13131311 # Used MuJoCo's multi-contact algorithm to find multiple contact points. Therefore,
13141312 # add the discovered contact points and stop multi-contact search.
13151313 for i_c in range (n_contacts ):
1316- if i_c >= self ._n_contacts_per_pair :
1317- # Ignore contact points if the number of contacts exceeds the limit.
1318- break
1319- contact_pos = self ._gjk .contact_pos [i_b , i_c ]
1320- normal = self ._gjk .normal [i_b , i_c ]
1321- self ._func_add_contact (i_ga , i_gb , normal , contact_pos , penetration , i_b )
1314+ # Ignore contact points if the number of contacts exceeds the limit.
1315+ if i_c < self ._n_contacts_per_pair :
1316+ contact_pos = self ._gjk .contact_pos [i_b , i_c ]
1317+ normal = self ._gjk .normal [i_b , i_c ]
1318+ self ._func_add_contact (i_ga , i_gb , normal , contact_pos , penetration , i_b )
13221319
13231320 break
13241321 else :
0 commit comments