Skip to content

Add masked particle resets to SolverVBD - #1

Draft
mmichelis wants to merge 1 commit into
jumyungc:vbd-support-resetfrom
mmichelis:mmichelis/vbd-reset-deformables
Draft

Add masked particle resets to SolverVBD#1
mmichelis wants to merge 1 commit into
jumyungc:vbd-support-resetfrom
mmichelis:mmichelis/vbd-reset-deformables

Conversation

@mmichelis

@mmichelis mmichelis commented Jul 3, 2026

Copy link
Copy Markdown

Description

Add masked deformable (cloth and volumetric soft body) reset support to SolverVBD.reset(), addressing the particle half of newton-physics#3256 (the rigid half is newton-physics#3316).

Note

Stacked on newton-physics#3316 — this branch contains the rigid-reset commits; only the final commit (Fix: Reset particles in VBD solver) belongs to this PR. Review that commit's diff, and merge after newton-physics#3316 lands.

reset() now honors StateFlags.PARTICLE_Q / StateFlags.PARTICLE_QD: a new reset_particle_state kernel copies model.particle_q / model.particle_qd into the state for particles in worlds selected by world_mask, with the same semantics as the rigid path (world_mask=None also resets global world == -1 particles; an explicit mask excludes them). The particle reset also runs when an external solver integrates the bodies, and for particle-only models.

No solver history plumbing is needed on the particle side: particle_q_prev is rebaselined from the incoming state at the start of every step(), self-contact and body-particle contact buffers are rebuilt per step (init_body_particle_contacts cold-starts body_particle_contact_penalty_k on every contact refresh, with no match-index warm-start path), and tet/cloth elasticity is stateless. Cloth and volumetric deformables therefore share this single reset path. The previous "particle resets are not supported" warning is removed and the docstring documents the particle behavior, including regenerating contacts after moving particles and rebuild_bvh for large displacements with self-contact.

Checklist

  • New or existing tests cover these changes
  • The documentation is up to date with these changes
  • CHANGELOG.md has been updated (if user-facing change)

Test plan

uv run --extra dev -m newton.tests -k particle_reset
  • test_particle_reset_state_flags_and_masks: two-world cloth plus a global particle; verifies masked restore of the selected world only, PARTICLE_Q-only / PARTICLE_QD-only / flags=0 selectivity, that an explicit all-true mask excludes global particles while world_mask=None includes them, and that a post-reset step stays finite.
  • test_particle_reset_soft_body: two-world tet soft grid; masked restore and post-reset step with tet elasticity.

Tests were verified to fail without the implementation (TDD), pass on CPU and CUDA, and the full VBD suite (60 tests) passes. Pre-commit is clean.

New feature / API change

import warp as wp

import newton

solver = newton.solvers.SolverVBD(model)

# Reset cloth/soft-body particles of selected worlds to the model defaults.
world_mask = wp.array([True, False], dtype=wp.bool)
solver.reset(state, world_mask=world_mask)

# Positions only, keep velocities.
solver.reset(state, world_mask=world_mask, flags=newton.StateFlags.PARTICLE_Q)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant