Skip to content

Per-body gravity #214

Answered by RossNordby
Grimelios asked this question in Q&A
May 2, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Just added a PerBodyGravityDemo in a703e19.

Feels more correct to use an array, but then I'm unsure how to actually build that mapping.
...
How do I keep my mapping accurate as bodies are added and removed to/from the simulation?

It's pretty annoying to try to keep an active set aligned data store up to date with potential memory moves caused by removals or sleeping. I usually just recommend instead storing data aligned with the internal values of the BodyHandle, like in the CollidableProperty<T>. The demo above uses the active body index to look up the handle, and from there, the per-body gravity value.

Explicitly looping over bodyIndices feels like I'll wreck that performance gain.

Y…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Grimelios
Comment options

Answer selected by Grimelios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants