Skip to content
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
90da431
[BUG FIX] Preserve external forces across sub-steps. (#1290)
LeonLiu4 Jun 20, 2025
0864103
[MISC] Reduce warning messages. (#1294)
YilingQiao Jun 20, 2025
8d07248
[MISC] Update default FEM damping 45.0 -> 0.0 (#1288)
Milotrince Jun 20, 2025
6d9f319
bvh query
Libero0809 Jun 4, 2025
197453b
Wrap aabb with python AABB class
Libero0809 Jun 5, 2025
bf0ee25
move query result batch dim
Libero0809 Jun 6, 2025
d385da6
init
Libero0809 Jun 10, 2025
fe432f0
Update bvh.py
duburcqa Jun 10, 2025
b1a7d2d
tet plane detection
Libero0809 Jun 11, 2025
82ffb7e
worked but far from good
Libero0809 Jun 14, 2025
0d564a2
add damping
Libero0809 Jun 16, 2025
1241c5b
add test
Libero0809 Jun 16, 2025
bd5aa0f
change test fem to sapcoupler
Libero0809 Jun 18, 2025
122e221
change test name
Libero0809 Jun 18, 2025
2778529
code cleanup & bug fix
Libero0809 Jun 18, 2025
54d5646
fix test
Libero0809 Jun 19, 2025
e74be79
fix test
Libero0809 Jun 20, 2025
bf60281
update doc for sap
Libero0809 Jun 20, 2025
604aef5
corotated
Libero0809 Jun 19, 2025
3845104
init
Libero0809 Jun 20, 2025
5cc72a0
fix bug in bvh
Libero0809 Jun 21, 2025
281dac3
debugging
Libero0809 Jun 24, 2025
2d38888
tet tet intersection
Libero0809 Jun 25, 2025
d5208f8
framework for ipc
Libero0809 Jun 25, 2025
f498d0f
remove the ipc part for cleaness
Libero0809 Jun 25, 2025
07e2112
Merge branch 'main' into bvh
Libero0809 Jun 25, 2025
d6ca8e0
pair detect ready
Libero0809 Jun 26, 2025
2c24e59
add gpu test
Libero0809 Jun 26, 2025
d7889fd
change compute bound to layered reduction
Libero0809 Jun 26, 2025
593892b
Merge branch 'main' into bvh
Libero0809 Jun 26, 2025
d33f8dc
make tests faster
Libero0809 Jun 26, 2025
624eed4
code clean up
Libero0809 Jun 26, 2025
98d30ab
removed unused field
Libero0809 Jun 26, 2025
d701966
Merge branch 'bvh' into self_collision
Libero0809 Jun 26, 2025
1d14882
refactor
Libero0809 Jun 27, 2025
bf3e08a
optimize performance
Libero0809 Jun 28, 2025
ed4c241
exact linesearch
Libero0809 Jul 4, 2025
83374ff
refactor
Libero0809 Jul 8, 2025
5013d26
add tests
Libero0809 Jul 8, 2025
94b84ba
Merge branch 'main' into self_collision
Libero0809 Jul 8, 2025
35dc136
small bug
Libero0809 Jul 8, 2025
c5f8320
init
Libero0809 Jul 9, 2025
995cb7c
code cleanup
Libero0809 Jul 10, 2025
7a9697d
Merge branch 'self_collision_debug' into fem_rigid
Libero0809 Jul 10, 2025
d2344bc
fix merge
Libero0809 Jul 10, 2025
8774db2
refactor
Libero0809 Jul 10, 2025
8897550
debug pcg
Libero0809 Jul 10, 2025
75df4e5
remove_debug
Libero0809 Jul 10, 2025
9d00be9
fix bug
Libero0809 Jul 10, 2025
b783e1f
merge kernels
Libero0809 Jul 11, 2025
03e0d93
working on linesearch
Libero0809 Jul 12, 2025
8859d24
rigid vert floor contact
Libero0809 Jul 14, 2025
247ea84
debugging
Libero0809 Jul 16, 2025
a8b2c69
debug
Libero0809 Jul 16, 2025
bb1bad3
change rigid
Libero0809 Jul 17, 2025
e0b7fc2
add rigid coupling
Libero0809 Jul 24, 2025
17baa9f
remove debug
Libero0809 Jul 24, 2025
5833ede
Merge branch 'main' into fem_rigid_debug
Libero0809 Jul 24, 2025
ea65d89
add tests
Libero0809 Jul 25, 2025
4c06b6b
fix import
Libero0809 Jul 25, 2025
8c8f466
Merge branch 'main' into fem_rigid_debug
Libero0809 Jul 29, 2025
14aa259
clean up
Libero0809 Aug 13, 2025
33d9eac
Merge branch 'main' into fem_rigid_debug
Libero0809 Aug 13, 2025
7316c04
cleanup
Libero0809 Aug 13, 2025
b46500d
Merge branch 'main' into fem_rigid_debug
Libero0809 Aug 13, 2025
0e6e688
code cleanup
Libero0809 Aug 13, 2025
016390b
Merge branch 'main' into fem_rigid_debug
Libero0809 Aug 13, 2025
62f38ea
fix test query
Libero0809 Aug 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions genesis/engine/bvh.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ def _kernel_radix_sort_morton_codes_one_round(self, i: int):

# Reorder morton codes
for i_b, i_a in ti.ndrange(self.n_batches, self.n_aabbs):
code = (self.morton_codes[i_b, i_a][1 - (i // 4)] >> ((i % 4) * 8)) & 0xFF
idx = ti.i32(self.offset[i_b, i_a] + self.prefix_sum[i_b, ti.i32(code)])
code = ti.i32((self.morton_codes[i_b, i_a][1 - (i // 4)] >> ((i % 4) * 8)) & 0xFF)
idx = ti.i32(self.offset[i_b, i_a] + self.prefix_sum[i_b, code])
self.tmp_morton_codes[i_b, idx] = self.morton_codes[i_b, i_a]

# Swap the temporary and original morton codes
Expand All @@ -299,7 +299,7 @@ def _kernel_radix_sort_morton_codes_one_round_group(self, i: int):
(i_g + 1) * self.group_size,
)
for i_a in range(start, end):
code = (self.morton_codes[i_b, i_a][1 - (i // 4)] >> ((i % 4) * 8)) & 0xFF
code = ti.i32((self.morton_codes[i_b, i_a][1 - (i // 4)] >> ((i % 4) * 8)) & 0xFF)
self.offset[i_b, i_a] = self.hist_group[i_b, i_g, code]
self.hist_group[i_b, i_g, code] = self.hist_group[i_b, i_g, code] + 1

Expand All @@ -319,7 +319,7 @@ def _kernel_radix_sort_morton_codes_one_round_group(self, i: int):

# Reorder morton codes
for i_b, i_a in ti.ndrange(self.n_batches, self.n_aabbs):
code = (self.morton_codes[i_b, i_a][1 - (i // 4)] >> ((i % 4) * 8)) & 0xFF
code = ti.i32((self.morton_codes[i_b, i_a][1 - (i // 4)] >> ((i % 4) * 8)) & 0xFF)
i_g = ti.min(i_a // self.group_size, self.n_radix_sort_groups - 1)
idx = ti.i32(self.prefix_sum[i_b, code] + self.prefix_sum_group[i_b, i_g, code] + self.offset[i_b, i_a])
# Use the group prefix sum to find the correct index
Expand Down Expand Up @@ -441,14 +441,15 @@ def _kernel_compute_bounds_one_layer(self) -> ti.i32:

return is_done

@ti.kernel
@ti.func
def query(self, aabbs: ti.template()):
"""
Query the BVH for intersections with the given AABBs.

The results are stored in the query_result field.
"""
self.query_result_count[None] = 0
overflow = False

n_querys = aabbs.shape[1]
for i_b, i_q in ti.ndrange(self.n_batches, n_querys):
Expand All @@ -470,6 +471,8 @@ def query(self, aabbs: ti.template()):
idx = ti.atomic_add(self.query_result_count[None], 1)
if idx < self.max_n_query_results:
self.query_result[idx] = gs.ti_ivec3(i_b, i_a, i_q) # Store the AABB index
else:
overflow = True
else:
# Push children onto the stack
if node.right != -1:
Expand All @@ -479,12 +482,13 @@ def query(self, aabbs: ti.template()):
query_stack[stack_depth] = node.left
stack_depth += 1

return overflow


@ti.data_oriented
class FEMSurfaceTetLBVH(LBVH):
"""
FEMSurfaceTetLBVH is a specialized Linear BVH for FEM surface tetrahedrals.

It extends the LBVH class to support filtering based on FEM surface tetrahedral elements.
"""

Expand All @@ -495,14 +499,11 @@ def __init__(self, fem_solver, aabb: AABB, max_n_query_result_per_aabb: int = 8,
@ti.func
def filter(self, i_a, i_q):
"""
Filter function for FEM surface tets. Filter out tet that share vertices.

Filter function for FEM surface tets. Filter out tet that share vertices.\
This is used to avoid self-collisions in FEM surface tets.

i_a: index of the found AABB
i_q: index of the query AABB
"""

result = i_a >= i_q
i_av = self.fem_solver.elements_i[self.fem_solver.surface_elements[i_a]].el2v
i_qv = self.fem_solver.elements_i[self.fem_solver.surface_elements[i_q]].el2v
Expand Down
Loading