Add ExternalImpulse
and ExternalAngularImpulse
#95
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.
Adds the
ExternalImpulse
andExternalAngularImpulse
components. They are like external forces and torque, but they are instant instead of being applied over time, and they are cleared every physics frame by default.I tested the behaviour against Unity's impulses, and it looks correct with a similar configuration where an impulse is applied upwards at the right side of the cube, which also applies an angular impulse.
Impulse.comparison.mp4
Naming
I considered naming the positional impulse
ExternalLinearImpulse
for consistency (e.g.LinearVelocity
andAngularVelocity
), but "linear impulse" might not be a very common term so I named it justExternalImpulse
for now.Some engines also call the angular impulse a "torque impulse", but physically it's called an angular impulse afaik, so I named it that.
I'm also wondering if we should maybe remove or replace the "External" from the component names at some point, since
Force
andImpulse
look much nicer in my opinion, and I haven't seen many engines other than Rapier use the word external before. It does make it a bit clearer that it doesn't include e.g. contact forces, but I still kinda like the ergonomics of justForce
, and we could technically even add atotal_force
property that actually does contain gravity and constraint forces as well. That's something to consider in a future PR though.