Class GraphicalSmoothingUtility
Utility functions for smoothing the motion of rigid bodies' graphical representations when physics steps at a lower frequency than rendering.
Inheritance
GraphicalSmoothingUtility
Assembly: solution.dll
Syntax
public static class GraphicalSmoothingUtility
Methods
Name |
Description |
BuildLocalToWorld(int, RigidTransform, float, bool, NativeArray<PostTransformMatrix>)
|
Construct a LocalToWorld matrix for a rigid body's graphical representation.
|
Compute a simple extrapolated transform for the graphical representation of a rigid body using its currentTransform and currentVelocity .
Because bodies' motion may change the next time physics steps (e.g., as the result of a collision), using this method can mis-predict their future locations, causing them to appear to snap into place the next time physics steps.
It generally results in a solid contact and kick from collisions, albeit with some interpenetration, as well as slight jitter on small, smooth velocity changes (e.g., the top of a parabolic arc).
Simulation: Graphical Extrapolation:
O (t=2) O (t=2)
(t=0) O / (t=0) O o
\ / o o
\ O (t=1) o O (t=1)
_________\/_________ ___________o________
o
|
Interpolate(in RigidTransform, in RigidTransform, float)
|
Compute a simple interpolated transform for the graphical representation of a rigid body between previousTransform and currentTransform .
Because bodies' motion is often deflected during a physics step when there is a contact event, using this method can make bodies appear to change direction before a collision is actually visible.
Simulation: Graphical Interpolation:
O (t=2) O (t=2)
(t=0) O / (t=0) O o
\ / o o
\ O (t=1) O (t=1)
_________\/_________ ____________________
(Note that for cartoons, an animator would use squash and stretch to force a body to make contact even if it is technically not hitting on a specific frame.)
See InterpolateUsingVelocity(in RigidTransform, in PhysicsVelocity, in PhysicsVelocity, in PhysicsMass, float, float) for an alternative approach.
|
InterpolateUsingVelocity(in RigidTransform, in PhysicsVelocity, in PhysicsVelocity, in PhysicsMass, float, float)
|
Compute an interpolated transform for the graphical representation of a rigid body between its previous transform and current transform, integrating forward using an interpolated velocity value.
This method tries to achieve a compromise between the visual artifacts of Interpolate(in RigidTransform, in RigidTransform, float) and Extrapolate(in RigidTransform, in PhysicsVelocity, in PhysicsMass, float).
While integrating forward using previousVelocity alone would exhibit behavior similar to Extrapolate(in RigidTransform, in PhysicsVelocity, in PhysicsMass, float), doing so in conjunction with previousTransform results in smoother motion for small velocity changes.
Collisions can still appear premature when physics has a low tick rate, however, as when using Interpolate(in RigidTransform, in RigidTransform, float).
|
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.