From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/mecanim/animation/denseclip.cpp | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Runtime/mecanim/animation/denseclip.cpp (limited to 'Runtime/mecanim/animation/denseclip.cpp') diff --git a/Runtime/mecanim/animation/denseclip.cpp b/Runtime/mecanim/animation/denseclip.cpp new file mode 100644 index 0000000..3c19e47 --- /dev/null +++ b/Runtime/mecanim/animation/denseclip.cpp @@ -0,0 +1,63 @@ +#include "UnityPrefix.h" +#include "denseclip.h" +#include "Runtime/Math/Simd/math.h" +namespace mecanim +{ +namespace animation +{ + +static void BlendArray(const float* lhs, const float* rhs, size_t size, float t, float* output) +{ + for (int i=0;i (&clip.m_SampleArray[lhsIndex * clip.m_CurveCount]); + rhs = const_cast (&clip.m_SampleArray[rhsIndex * clip.m_CurveCount]); +} + +void SampleClip (const DenseClip& clip, float time, float* output) +{ + float u; + float* lhsPtr; + float* rhsPtr; + PrepareBlendValues(clip, time, lhsPtr, rhsPtr, u); + + BlendArray(lhsPtr, rhsPtr, clip.m_CurveCount, u, output); +} + +float SampleClipAtIndex (const DenseClip& clip, int curveIndex, float time) +{ + float u; + float* lhsPtr; + float* rhsPtr; + PrepareBlendValues(clip, time, lhsPtr, rhsPtr, u); + + return math::lerp(lhsPtr[curveIndex], rhsPtr[curveIndex], u); +} + + +// Creation & Destruction +void DestroyDenseClip (DenseClip& clip, memory::Allocator& alloc) +{ + alloc.Deallocate(clip.m_SampleArray); +} + +} +} -- cgit v1.1-26-g67d0