|
|
@@ -487,27 +487,31 @@ namespace SharpGLTF.Schema2
|
|
|
_output = this._CreateOutputAccessor(kv.Item2).LogicalIndex;
|
|
|
}
|
|
|
|
|
|
- IEnumerable<(Single, Vector3)> IAnimationSampler<Vector3>.GetLinearKeys()
|
|
|
+ IEnumerable<(Single, Vector3)> IAnimationSampler<Vector3>.GetLinearKeys(bool isolateMemory)
|
|
|
{
|
|
|
Guard.IsFalse(this.InterpolationMode == AnimationInterpolationMode.CUBICSPLINE, nameof(InterpolationMode));
|
|
|
|
|
|
var keys = this.Input.AsScalarArray();
|
|
|
var frames = this.Output.AsVector3Array();
|
|
|
|
|
|
- return keys.Zip(frames, (key, val) => (key, val));
|
|
|
+ return keys
|
|
|
+ .Zip(frames, (key, val) => (key, val))
|
|
|
+ .Isolate(isolateMemory);
|
|
|
}
|
|
|
|
|
|
- IEnumerable<(Single, Quaternion)> IAnimationSampler<Quaternion>.GetLinearKeys()
|
|
|
+ IEnumerable<(Single, Quaternion)> IAnimationSampler<Quaternion>.GetLinearKeys(bool isolateMemory)
|
|
|
{
|
|
|
Guard.IsFalse(this.InterpolationMode == AnimationInterpolationMode.CUBICSPLINE, nameof(InterpolationMode));
|
|
|
|
|
|
var keys = this.Input.AsScalarArray();
|
|
|
var frames = this.Output.AsQuaternionArray();
|
|
|
|
|
|
- return keys.Zip(frames, (key, val) => (key, val));
|
|
|
+ return keys
|
|
|
+ .Zip(frames, (key, val) => (key, val))
|
|
|
+ .Isolate(isolateMemory);
|
|
|
}
|
|
|
|
|
|
- IEnumerable<(Single, SparseWeight8)> IAnimationSampler<SparseWeight8>.GetLinearKeys()
|
|
|
+ IEnumerable<(Single, SparseWeight8)> IAnimationSampler<SparseWeight8>.GetLinearKeys(bool isolateMemory)
|
|
|
{
|
|
|
Guard.IsFalse(this.InterpolationMode == AnimationInterpolationMode.CUBICSPLINE, nameof(InterpolationMode));
|
|
|
|
|
|
@@ -516,10 +520,12 @@ namespace SharpGLTF.Schema2
|
|
|
var keys = this.Input.AsScalarArray();
|
|
|
var frames = this.Output.AsMultiArray(dimensions);
|
|
|
|
|
|
- return keys.Zip(frames, (key, val) => (key, SparseWeight8.Create(val)));
|
|
|
+ return keys
|
|
|
+ .Zip(frames, (key, val) => (key, SparseWeight8.Create(val)))
|
|
|
+ .Isolate(isolateMemory);
|
|
|
}
|
|
|
|
|
|
- IEnumerable<(Single, Single[])> IAnimationSampler<Single[]>.GetLinearKeys()
|
|
|
+ IEnumerable<(Single, Single[])> IAnimationSampler<Single[]>.GetLinearKeys(bool isolateMemory)
|
|
|
{
|
|
|
Guard.IsFalse(this.InterpolationMode == AnimationInterpolationMode.CUBICSPLINE, nameof(InterpolationMode));
|
|
|
|
|
|
@@ -528,30 +534,36 @@ namespace SharpGLTF.Schema2
|
|
|
var keys = this.Input.AsScalarArray();
|
|
|
var frames = this.Output.AsMultiArray(dimensions);
|
|
|
|
|
|
- return keys.Zip(frames, (key, val) => (key, val));
|
|
|
+ return keys
|
|
|
+ .Zip(frames, (key, val) => (key, val))
|
|
|
+ .Isolate(isolateMemory);
|
|
|
}
|
|
|
|
|
|
- IEnumerable<(Single, (Vector3, Vector3, Vector3))> IAnimationSampler<Vector3>.GetCubicKeys()
|
|
|
+ IEnumerable<(Single, (Vector3, Vector3, Vector3))> IAnimationSampler<Vector3>.GetCubicKeys(bool isolateMemory)
|
|
|
{
|
|
|
Guard.IsFalse(this.InterpolationMode != AnimationInterpolationMode.CUBICSPLINE, nameof(InterpolationMode));
|
|
|
|
|
|
var keys = this.Input.AsScalarArray();
|
|
|
var frames = _GroupByThree(this.Output.AsVector3Array());
|
|
|
|
|
|
- return keys.Zip(frames, (key, val) => (key, val));
|
|
|
+ return keys
|
|
|
+ .Zip(frames, (key, val) => (key, val))
|
|
|
+ .Isolate(isolateMemory);
|
|
|
}
|
|
|
|
|
|
- IEnumerable<(Single, (Quaternion, Quaternion, Quaternion))> IAnimationSampler<Quaternion>.GetCubicKeys()
|
|
|
+ IEnumerable<(Single, (Quaternion, Quaternion, Quaternion))> IAnimationSampler<Quaternion>.GetCubicKeys(bool isolateMemory)
|
|
|
{
|
|
|
Guard.IsFalse(this.InterpolationMode != AnimationInterpolationMode.CUBICSPLINE, nameof(InterpolationMode));
|
|
|
|
|
|
var keys = this.Input.AsScalarArray();
|
|
|
var frames = _GroupByThree(this.Output.AsQuaternionArray());
|
|
|
|
|
|
- return keys.Zip(frames, (key, val) => (key, val));
|
|
|
+ return keys
|
|
|
+ .Zip(frames, (key, val) => (key, val))
|
|
|
+ .Isolate(isolateMemory);
|
|
|
}
|
|
|
|
|
|
- IEnumerable<(Single, (Single[], Single[], Single[]))> IAnimationSampler<Single[]>.GetCubicKeys()
|
|
|
+ IEnumerable<(Single, (Single[], Single[], Single[]))> IAnimationSampler<Single[]>.GetCubicKeys(bool isolateMemory)
|
|
|
{
|
|
|
Guard.IsFalse(this.InterpolationMode != AnimationInterpolationMode.CUBICSPLINE, nameof(InterpolationMode));
|
|
|
|
|
|
@@ -560,10 +572,12 @@ namespace SharpGLTF.Schema2
|
|
|
var keys = this.Input.AsScalarArray();
|
|
|
var frames = _GroupByThree(this.Output.AsMultiArray(dimensions));
|
|
|
|
|
|
- return keys.Zip(frames, (key, val) => (key, val));
|
|
|
+ return keys
|
|
|
+ .Zip(frames, (key, val) => (key, val))
|
|
|
+ .Isolate(isolateMemory);
|
|
|
}
|
|
|
|
|
|
- IEnumerable<(Single, (SparseWeight8, SparseWeight8, SparseWeight8))> IAnimationSampler<SparseWeight8>.GetCubicKeys()
|
|
|
+ IEnumerable<(Single, (SparseWeight8, SparseWeight8, SparseWeight8))> IAnimationSampler<SparseWeight8>.GetCubicKeys(bool isolateMemory)
|
|
|
{
|
|
|
Guard.IsFalse(this.InterpolationMode != AnimationInterpolationMode.CUBICSPLINE, nameof(InterpolationMode));
|
|
|
|
|
|
@@ -572,7 +586,9 @@ namespace SharpGLTF.Schema2
|
|
|
var keys = this.Input.AsScalarArray();
|
|
|
var frames = _GroupByThree(this.Output.AsMultiArray(dimensions));
|
|
|
|
|
|
- return keys.Zip(frames, (key, val) => (key, (SparseWeight8.Create(val.Item1), SparseWeight8.Create(val.Item2), SparseWeight8.Create(val.Item3))));
|
|
|
+ return keys
|
|
|
+ .Zip(frames, (key, val) => (key, (SparseWeight8.Create(val.Item1), SparseWeight8.Create(val.Item2), SparseWeight8.Create(val.Item3))))
|
|
|
+ .Isolate(isolateMemory);
|
|
|
}
|
|
|
|
|
|
private static IEnumerable<(T, T, T)> _GroupByThree<T>(IEnumerable<T> collection)
|
|
|
@@ -593,57 +609,57 @@ namespace SharpGLTF.Schema2
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ICurveSampler<Vector3> IAnimationSampler<Vector3>.CreateCurveSampler()
|
|
|
+ ICurveSampler<Vector3> IAnimationSampler<Vector3>.CreateCurveSampler(bool isolateMemory)
|
|
|
{
|
|
|
var xsampler = this as IAnimationSampler<Vector3>;
|
|
|
|
|
|
switch (this.InterpolationMode)
|
|
|
{
|
|
|
- case AnimationInterpolationMode.STEP: return xsampler.GetLinearKeys().CreateSampler(false);
|
|
|
- case AnimationInterpolationMode.LINEAR: return xsampler.GetLinearKeys().CreateSampler();
|
|
|
- case AnimationInterpolationMode.CUBICSPLINE: return xsampler.GetCubicKeys().CreateSampler();
|
|
|
+ case AnimationInterpolationMode.STEP: return xsampler.GetLinearKeys(isolateMemory).CreateSampler(false);
|
|
|
+ case AnimationInterpolationMode.LINEAR: return xsampler.GetLinearKeys(isolateMemory).CreateSampler();
|
|
|
+ case AnimationInterpolationMode.CUBICSPLINE: return xsampler.GetCubicKeys(isolateMemory).CreateSampler();
|
|
|
}
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- ICurveSampler<Quaternion> IAnimationSampler<Quaternion>.CreateCurveSampler()
|
|
|
+ ICurveSampler<Quaternion> IAnimationSampler<Quaternion>.CreateCurveSampler(bool isolateMemory)
|
|
|
{
|
|
|
var xsampler = this as IAnimationSampler<Quaternion>;
|
|
|
|
|
|
switch (this.InterpolationMode)
|
|
|
{
|
|
|
- case AnimationInterpolationMode.STEP: return xsampler.GetLinearKeys().CreateSampler(false);
|
|
|
- case AnimationInterpolationMode.LINEAR: return xsampler.GetLinearKeys().CreateSampler();
|
|
|
- case AnimationInterpolationMode.CUBICSPLINE: return xsampler.GetCubicKeys().CreateSampler();
|
|
|
+ case AnimationInterpolationMode.STEP: return xsampler.GetLinearKeys(isolateMemory).CreateSampler(false);
|
|
|
+ case AnimationInterpolationMode.LINEAR: return xsampler.GetLinearKeys(isolateMemory).CreateSampler();
|
|
|
+ case AnimationInterpolationMode.CUBICSPLINE: return xsampler.GetCubicKeys(isolateMemory).CreateSampler();
|
|
|
}
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- ICurveSampler<Single[]> IAnimationSampler<Single[]>.CreateCurveSampler()
|
|
|
+ ICurveSampler<Single[]> IAnimationSampler<Single[]>.CreateCurveSampler(bool isolateMemory)
|
|
|
{
|
|
|
var xsampler = this as IAnimationSampler<Single[]>;
|
|
|
|
|
|
switch (this.InterpolationMode)
|
|
|
{
|
|
|
- case AnimationInterpolationMode.STEP: return xsampler.GetLinearKeys().CreateSampler(false);
|
|
|
- case AnimationInterpolationMode.LINEAR: return xsampler.GetLinearKeys().CreateSampler();
|
|
|
- case AnimationInterpolationMode.CUBICSPLINE: return xsampler.GetCubicKeys().CreateSampler();
|
|
|
+ case AnimationInterpolationMode.STEP: return xsampler.GetLinearKeys(isolateMemory).CreateSampler(false);
|
|
|
+ case AnimationInterpolationMode.LINEAR: return xsampler.GetLinearKeys(isolateMemory).CreateSampler();
|
|
|
+ case AnimationInterpolationMode.CUBICSPLINE: return xsampler.GetCubicKeys(isolateMemory).CreateSampler();
|
|
|
}
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- ICurveSampler<SparseWeight8> IAnimationSampler<SparseWeight8>.CreateCurveSampler()
|
|
|
+ ICurveSampler<SparseWeight8> IAnimationSampler<SparseWeight8>.CreateCurveSampler(bool isolateMemory)
|
|
|
{
|
|
|
var xsampler = this as IAnimationSampler<SparseWeight8>;
|
|
|
|
|
|
switch (this.InterpolationMode)
|
|
|
{
|
|
|
- case AnimationInterpolationMode.STEP: return xsampler.GetLinearKeys().CreateSampler(false);
|
|
|
- case AnimationInterpolationMode.LINEAR: return xsampler.GetLinearKeys().CreateSampler();
|
|
|
- case AnimationInterpolationMode.CUBICSPLINE: return xsampler.GetCubicKeys().CreateSampler();
|
|
|
+ case AnimationInterpolationMode.STEP: return xsampler.GetLinearKeys(isolateMemory).CreateSampler(false);
|
|
|
+ case AnimationInterpolationMode.LINEAR: return xsampler.GetLinearKeys(isolateMemory).CreateSampler();
|
|
|
+ case AnimationInterpolationMode.CUBICSPLINE: return xsampler.GetCubicKeys(isolateMemory).CreateSampler();
|
|
|
}
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
@@ -656,11 +672,11 @@ namespace SharpGLTF.Schema2
|
|
|
{
|
|
|
AnimationInterpolationMode InterpolationMode { get; }
|
|
|
|
|
|
- IEnumerable<(Single, T)> GetLinearKeys();
|
|
|
+ IEnumerable<(Single, T)> GetLinearKeys(bool isolateMemory = false);
|
|
|
|
|
|
- IEnumerable<(Single, (T, T, T))> GetCubicKeys();
|
|
|
+ IEnumerable<(Single, (T, T, T))> GetCubicKeys(bool isolateMemory = false);
|
|
|
|
|
|
- ICurveSampler<T> CreateCurveSampler();
|
|
|
+ ICurveSampler<T> CreateCurveSampler(bool isolateMemory = false);
|
|
|
}
|
|
|
|
|
|
public sealed partial class ModelRoot
|