feat(core): support dynamic dt by reading from scene config live - #453
Closed
MuGdxy wants to merge 1 commit into
Closed
feat(core): support dynamic dt by reading from scene config live#453MuGdxy wants to merge 1 commit into
MuGdxy wants to merge 1 commit into
Conversation
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 spiriMirror#451
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements support for dynamic time step (dt) updates by replacing cached dt values with references to the underlying attribute slot across various CUDA backend systems, including affine body dynamics, FEM, and contact systems. This change allows the simulation to respond to dt modifications mid-run. Corresponding tests were added to verify the functionality. Feedback focuses on performance optimizations, specifically suggesting that the dt value be cached in a local variable before entering loops in several animator and constitution manager implementations to avoid redundant attribute slot lookups.
| { | ||
| ComputeEnergyInfo this_info{&m_impl, constraint->m_index, m_impl.dt, info.energies()}; | ||
| ComputeEnergyInfo this_info{ | ||
| &m_impl, constraint->m_index, m_impl.dt_attr->view()[0], info.energies()}; |
Contributor
| { | ||
| ComputeEnergyInfo this_info{&m_impl, constraint->m_index, m_impl.dt, info.energies()}; | ||
| ComputeEnergyInfo this_info{ | ||
| &m_impl, constraint->m_index, m_impl.dt_attr->view()[0], info.energies()}; |
Contributor
| for(auto&& [i, c] : enumerate(constitution_view)) | ||
| { | ||
| EnergyInfo this_info{this, c->m_index, dt, info.energies()}; | ||
| EnergyInfo this_info{this, c->m_index, dt_attr->view()[0], info.energies()}; |
Contributor
| for(auto&& [i, c] : enumerate(constitution_view)) | ||
| { | ||
| EnergyInfo this_info{this, c->m_index, dt, info.energies()}; | ||
| EnergyInfo this_info{this, c->m_index, dt_attr->view()[0], info.energies()}; |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace all cached
Float dtmembers 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 viascene.config().find<Float>("dt").Previously, each system copied
dtfrom the scene config once duringdo_build()orinit(), 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 bySimEnginefor other config values likem_newton_velocity_tol.Changes
dt()convenience accessor delegating tointernal::Scene::dt()Float dtmember withS<const geometry::AttributeSlot<Float>> dt_attrin Impl structs (time integrator, linear subsystems, line search, contact system, active set, animators, constitution managers, diff reporters)MaxTranslationCheckerandABDToleranceCheckernow recomputeabs_tol = factor * dtdynamically indo_check()instead of caching it indo_build()SceneVisitor::dt(), and sim_case test (93_dynamic_dt) verifying end-to-end that changing dt at runtime affects simulation behaviorFixes #451