Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

BeardedMath.Lerp appears incorrect for generic types #384

Open
NoTuxNoBux opened this issue Nov 30, 2020 · 0 comments
Open

BeardedMath.Lerp appears incorrect for generic types #384

NoTuxNoBux opened this issue Nov 30, 2020 · 0 comments

Comments

@NoTuxNoBux
Copy link

NoTuxNoBux commented Nov 30, 2020

Version Number and Operating System(s):

Windows 10, Forge Network Alloy at da8e129 (but the same problem appears to exist in Remastered).

Expected behavior:

BeardedMath.Lerp with some generic type, such as int, eventually reaches the target.

Actual behavior:

The target is never reached.

Steps to reproduce:

Call BeardedMath.Lerp(1, 2, 1), but the original value is always returned.

Context

This may not pose a problem in practice most of the time, because float and double have specific overrides that do work. The generic implementation however always returns a0, which means that the promise of a1 being returned when t = 1 never holds true.

If lerping is not supported for a type, the generic implementation should probably always return a1 instead, immediately reaching the destination. Otherwise, interpolating values gradually over the network will keep trying to get closer to the destination value in YourGeneratedNetworkObject.InterpolateUpdate, but will never reach its destination.

I encountered this for Float3 and Float4 in #310, but noticed this behavior also exists on master and develop, hence this report.

(It is not clear to me how lerping currently works for Unity's Vector3 and friends, as it's not handled here either, but IsInterpolatable claims it is supposedly interpolatable. EDIT: Nevermind, it's InterpolateVector3 and friends.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant