mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Fixed fast moving items interpolation
This commit is contained in:
parent
66f5f67620
commit
61ca421fb8
1 changed files with 11 additions and 6 deletions
|
@ -451,7 +451,11 @@ namespace TEN::Renderer
|
|||
// Renderer slot has no interpolation flag set in case it is fetched for first time (e.g. item first time in frustum).
|
||||
newItem.DisableInterpolation = item.DisableInterpolation || newItem.DisableInterpolation;
|
||||
|
||||
if (newItem.DisableInterpolation)
|
||||
// Disable interpolation when object has traveled significant distance.
|
||||
// It's needed because when object gets out of frustum, its previous position doesn't update.
|
||||
bool positionChanged = Vector3::Distance(newItem.PrevPosition, newItem.Position) > BLOCK(1);
|
||||
|
||||
if (newItem.DisableInterpolation || positionChanged)
|
||||
{
|
||||
// NOTE: Interpolation always returns same result.
|
||||
newItem.PrevPosition = newItem.Position;
|
||||
|
@ -469,12 +473,13 @@ namespace TEN::Renderer
|
|||
|
||||
// Force interpolation only for player in player freeze mode.
|
||||
bool forceValue = g_GameFlow->CurrentFreezeMode == FreezeMode::Player && item.ObjectNumber == ID_LARA;
|
||||
float interpFactor = GetInterpolationFactor(forceValue);
|
||||
|
||||
newItem.InterpolatedPosition = Vector3::Lerp(newItem.PrevPosition, newItem.Position, GetInterpolationFactor(forceValue));
|
||||
newItem.InterpolatedTranslation = Matrix::Lerp(newItem.PrevTranslation, newItem.Translation, GetInterpolationFactor(forceValue));
|
||||
newItem.InterpolatedRotation = Matrix::Lerp(newItem.InterpolatedRotation, newItem.Rotation, GetInterpolationFactor(forceValue));
|
||||
newItem.InterpolatedScale = Matrix::Lerp(newItem.InterpolatedScale, newItem.Scale, GetInterpolationFactor(forceValue));
|
||||
newItem.InterpolatedWorld = Matrix::Lerp(newItem.PrevWorld, newItem.World, GetInterpolationFactor(forceValue));
|
||||
newItem.InterpolatedPosition = Vector3::Lerp(newItem.PrevPosition, newItem.Position, interpFactor);
|
||||
newItem.InterpolatedTranslation = Matrix::Lerp(newItem.PrevTranslation, newItem.Translation, interpFactor);
|
||||
newItem.InterpolatedRotation = Matrix::Lerp(newItem.InterpolatedRotation, newItem.Rotation, interpFactor);
|
||||
newItem.InterpolatedScale = Matrix::Lerp(newItem.InterpolatedScale, newItem.Scale, interpFactor);
|
||||
newItem.InterpolatedWorld = Matrix::Lerp(newItem.PrevWorld, newItem.World, interpFactor);
|
||||
|
||||
for (int j = 0; j < MAX_BONES; j++)
|
||||
newItem.InterpolatedAnimTransforms[j] = Matrix::Lerp(newItem.PrevAnimTransforms[j], newItem.AnimTransforms[j], GetInterpolationFactor(forceValue));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue