@@ -281,8 +281,8 @@ def _kernel_radix_sort_morton_codes_one_round(self, i: int):
281281
282282 # Reorder morton codes
283283 for i_b , i_a in ti .ndrange (self .n_batches , self .n_aabbs ):
284- code = ( self .morton_codes [i_b , i_a ][1 - (i // 4 )] >> ((i % 4 ) * 8 )) & 0xFF
285- idx = ti .i32 (self .offset [i_b , i_a ] + self .prefix_sum [i_b , ti . i32 ( code ) ])
284+ code = ti . i32 (( self .morton_codes [i_b , i_a ][1 - (i // 4 )] >> ((i % 4 ) * 8 )) & 0xFF )
285+ idx = ti .i32 (self .offset [i_b , i_a ] + self .prefix_sum [i_b , code ])
286286 self .tmp_morton_codes [i_b , idx ] = self .morton_codes [i_b , i_a ]
287287
288288 # Swap the temporary and original morton codes
@@ -445,14 +445,15 @@ def _kernel_compute_bounds_one_layer(self) -> ti.i32:
445445
446446 return is_done
447447
448- @ti .kernel
448+ @ti .func
449449 def query (self , aabbs : ti .template ()):
450450 """
451451 Query the BVH for intersections with the given AABBs.
452452
453453 The results are stored in the query_result field.
454454 """
455455 self .query_result_count [None ] = 0
456+ overflow = False
456457
457458 n_querys = aabbs .shape [1 ]
458459 for i_b , i_q in ti .ndrange (self .n_batches , n_querys ):
@@ -474,6 +475,8 @@ def query(self, aabbs: ti.template()):
474475 idx = ti .atomic_add (self .query_result_count [None ], 1 )
475476 if idx < self .max_n_query_results :
476477 self .query_result [idx ] = gs .ti_ivec3 (i_b , i_a , i_q ) # Store the AABB index
478+ else :
479+ overflow = True
477480 else :
478481 # Push children onto the stack
479482 if node .right != - 1 :
@@ -483,6 +486,8 @@ def query(self, aabbs: ti.template()):
483486 query_stack [stack_depth ] = node .left
484487 stack_depth += 1
485488
489+ return overflow
490+
486491
487492@ti .data_oriented
488493class FEMSurfaceTetLBVH (LBVH ):
@@ -503,10 +508,13 @@ def filter(self, i_a, i_q):
503508
504509 This is used to avoid self-collisions in FEM surface tets.
505510
506- i_a: index of the found AABB
507- i_q: index of the query AABB
511+ Parameters
512+ ----------
513+ i_a:
514+ index of the found AABB
515+ i_q:
516+ index of the query AABB
508517 """
509-
510518 result = i_a >= i_q
511519 i_av = self .fem_solver .elements_i [self .fem_solver .surface_elements [i_a ]].el2v
512520 i_qv = self .fem_solver .elements_i [self .fem_solver .surface_elements [i_q ]].el2v
0 commit comments