Combine LinearVelocity and AngularVelocity under Velocity (and similarly with MaxSpeed and Damping)#958
Open
Jondolf wants to merge 9 commits into
Open
Combine LinearVelocity and AngularVelocity under Velocity (and similarly with MaxSpeed and Damping)#958Jondolf wants to merge 9 commits into
LinearVelocity and AngularVelocity under Velocity (and similarly with MaxSpeed and Damping)#958Jondolf wants to merge 9 commits into
Conversation
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.
Objective
Currently, velocity is split into
LinearVelocityandAngularVelocity:This has some nice aspects:
x,y, andzdirectly.However, there are also some prominent downsides:
.0is "ugly" and doesn't feel like a polished official API (subjectively speaking).at_pointhelper method, since point velocity needs both linear and angular velocity. This is something users have frequently complained about!Solution
Replace
LinearVelocityandAngularVelocitywith a singleVelocitycomponent:I suspect that this will be somewhat contentious, but let's take a look at some examples of what the API looks like.
The earlier example would look like this:
There are several helpers for constructing
Velocity:Point velocity can be computed using
at_point:I believe this kind of combined API has several benefits:
.0.TransformAPIs (translation and rotation on the same component).I think the main downside is that systems operating on linear and angular velocity separately cannot run in parallel, but IME this is not really a problem in practice, and Avian itself doesn't currently benefit from that kind of parallelism.
Similarly, I combined
MaxLinearSpeedandMaxAngularSpeedasMaxSpeed, andLinearDampingandAngularDampingasDamping:This makes the API more consistent and again focuses documentation for concepts like "maximum speed" and "damping" under a single component instead of spreading it out over multiple types.
I recommend looking at the PR code diff to get a better idea of what the APIs look like in practice.
Follow-Up Work
PositionandRotationunderPhysicsTransform