Skip to content

Commit

Permalink
Fix memory access issues in particle-shape collisions (NVIDIAGH-362)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-heiden authored and mmacklin committed Nov 24, 2024
1 parent 1ea7b9a commit 454fbea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- Fix error when reading multi-volume, BLOSC-compressed `.nvdb` files.
- Fix `wp.printf()` erroring out when no variadic arguments are passed ([GH-333](https://github.com/NVIDIA/warp/issues/333)).
- Fix custom colors being ignored when rendering meshes in OpenGL ([GH-343](https://github.com/NVIDIA/warp/issues/343)).
- Fix memory access issues in soft-rigid contact collisions ([GH-362](https://github.com/NVIDIA/warp/issues/362)).

## [1.4.2] - 2024-11-13

Expand Down
2 changes: 1 addition & 1 deletion warp/sim/integrator_euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def eval_particle_contacts(
r = bx - wp.transform_point(X_wb, X_com)

n = contact_normal[tid]
c = wp.dot(n, px - bx) - particle_radius[tid]
c = wp.dot(n, px - bx) - particle_radius[particle_index]

if c > particle_ka:
return
Expand Down
13 changes: 10 additions & 3 deletions warp/sim/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def _allocate_soft_contacts(self, target, count, requires_grad=False):
target.soft_contact_body_pos = wp.zeros(count, dtype=wp.vec3, requires_grad=requires_grad)
target.soft_contact_body_vel = wp.zeros(count, dtype=wp.vec3, requires_grad=requires_grad)
target.soft_contact_normal = wp.zeros(count, dtype=wp.vec3, requires_grad=requires_grad)
target.soft_contact_tids = wp.zeros(count, dtype=int)
target.soft_contact_tids = wp.zeros(self.particle_count * (self.shape_count - 1), dtype=int)

def allocate_soft_contacts(self, count, requires_grad=False):
self._allocate_soft_contacts(self, count, requires_grad)
Expand Down Expand Up @@ -3429,7 +3429,12 @@ def _add_shape(

# particles
def add_particle(
self, pos: Vec3, vel: Vec3, mass: float, radius: float = None, flags: wp.uint32 = PARTICLE_FLAG_ACTIVE
self,
pos: Vec3,
vel: Vec3,
mass: float,
radius: float = None,
flags: wp.uint32 = PARTICLE_FLAG_ACTIVE,
) -> int:
"""Adds a single particle to the model
Expand All @@ -3454,7 +3459,9 @@ def add_particle(
self.particle_radius.append(radius)
self.particle_flags.append(flags)

return len(self.particle_q) - 1
particle_id = self.particle_count - 1

return particle_id

def add_spring(self, i: int, j, ke: float, kd: float, control: float):
"""Adds a spring between two particles in the system
Expand Down

0 comments on commit 454fbea

Please sign in to comment.