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

BeardedMath.Lerp appears incorrect for generic types #384

@NoTuxNoBux

Description

@NoTuxNoBux

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions