Table of Contents

Namespace Coherence.Interpolation

Classes

DiffingExtensions

Methods duplicated from Coherence.Toolkit.CoherenceToUnityConverters to prevent cyclic package dependencies.

InterpolationSettings

Interpolation is a ScriptableObject used to smoothly interpolate between samples received over the network. It contains the settings and current state of the interpolation (including the SampleBuffer<T>) and an Interpolator that performs blending between samples. Each networked binding holds a separate ScriptableObject instance which is automatically instantiated at runtime. This allows each binding to operate independently from one-another. The following types are supported for interpolation: float, bool, int, long, Vector2, Vector3, Quaternion, Color, string and EntityReferences. Additional smoothing (using SmoothDamp) is supported for types: float, Vector2, Vector3 and Quaternion.

InterpolationUtils
Interpolator

Base class used for blending between sample points. The base implementation simply provides latest data sampling so that values "snap" to the sample that is latest. By sub-classing and overriding these methods, more refined interpolation can be achieved (see LinearInterpolator and SplineInterpolator). Interpolation can be implemented either using 2 samples or 4 samples. Methods are specified for all supported types, taking sample values as parameters together with the time t that is expressed as a fraction between value1 and value2. Unless the 4 sample methods are overriden, they will simply call the corresponding 2 sample methods that will suffice for most types of interpolation.

LinearInterpolator

The LinearInterpolator performs a linear blend between two adjacent samples. The LinearInterpolator is defined for types int, long, float, Vector2, Vector3, Color and Quaternion (using UnityEngine.Quaternion.Slerp(UnityEngine.Quaternion,UnityEngine.Quaternion,System.Single)).

SampleBuffer<T>

SampleBuffer stores sample points in a circular buffer. The buffer is backed by an array that currently cannot be resized. The buffer is guaranteed to be ever increasing, i.e. this[n].Time > this[n-1].

SplineInterpolator

The SplineInterpolator blends sample values smoothly using a Catmull-Rom curve. The SplineInterpolator is defined for types float, Vector2 and Vector3.

Structs

InterpolationResult<T>
LatencySettings
SampleBuffer<T>.AdjecentSamplesResult
Sample<T>
Smoothing

Provides smoothing using SmoothDamp for types: float, Vector2, Vector3 and Quaternion. Smoothing unlike ordinary interpolation, cannot be rewinded, so keep smoothing at a minimum for accurate hitbox rewind. Quaternion smoothing uses SmoothDampAngle for its three euler angles, which may cause a performance hit for large number of objects.