Skip to content

feat(core): support dynamic dt by reading from scene config live - #455

Merged
MuGdxy merged 2 commits into
mainfrom
feat/issue-451-dynamic-dt
May 10, 2026
Merged

feat(core): support dynamic dt by reading from scene config live#455
MuGdxy merged 2 commits into
mainfrom
feat/issue-451-dynamic-dt

Conversation

@MuGdxy

@MuGdxy MuGdxy commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

Replace all cached Float dt members across ~25 CUDA backend systems with live attribute slot references (S<const geometry::AttributeSlot<Float>> dt_attr), enabling users to change the simulation timestep at runtime via scene.config().find<Float>("dt").

Previously, each system copied dt from the scene config once during do_build() or init(), making it impossible to change dt dynamically. Now every system reads dt from the scene config attribute on each use, following the same pattern already established by SimEngine for other config values like m_newton_velocity_tol.

Changes

  • SceneVisitor: Add dt() convenience accessor delegating to internal::Scene::dt()
  • 25 backend systems: Replace Float dt member with S<const geometry::AttributeSlot<Float>> dt_attr in Impl structs (time integrator, linear subsystems, line search, contact system, active set, animators, constitution managers, diff reporters)
  • Tolerance checkers: MaxTranslationChecker and ABDToleranceChecker now recompute abs_tol = factor * dt dynamically in do_check() instead of caching it in do_build()
  • Assertions: UIPC_ASSERT after every dt_attr assignment to verify the attribute exists
  • Performance: Cache dt_attr->view()[0] into a local Float before entering loops
  • Tests: Unit test verifying config read-back via SceneVisitor::dt(), and sim_case test (93_dynamic_dt) verifying end-to-end that changing dt at runtime affects simulation behavior

Fixes #451

MuGdxy and others added 2 commits May 9, 2026 22:20
Replace all cached `Float dt` members in ~25 backend systems with
`S<const geometry::AttributeSlot<Float>> dt_attr` so every system reads
dt from the scene config attribute on each use. This allows users to
change dt at runtime via `scene.config().find<Float>("dt")`.

- Add `SceneVisitor::dt()` convenience accessor
- Tolerance checkers now recompute abs_tol dynamically
- Add unit test and sim_case test verifying dynamic dt

Fixes #451

Co-authored-by: Cursor <cursoragent@cursor.com>
Address review feedback:
- Cache dt_attr->view()[0] into a local Float before entering
  loops to avoid redundant attribute lookups per iteration
- Add UIPC_ASSERT after every dt_attr assignment to verify
  the attribute was found in the scene config

Co-authored-by: Cursor <cursoragent@cursor.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements support for dynamic time steps (dt) by refactoring backend systems to access the dt value directly from the scene configuration's attribute slot at runtime. Previously, many systems cached a static copy of dt during initialization; this change ensures that any runtime modifications to the timestep are correctly propagated through the simulation pipeline, including contact systems, animators, and time integrators. New unit and simulation tests have been added to verify that changes to dt are correctly reflected in the simulation results. I have no feedback to provide as the review comments were purely explanatory and did not identify any issues.

@MuGdxy
MuGdxy merged commit 7979ac3 into main May 10, 2026
14 checks passed
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.

dynamic dt

1 participant