@@ -67,6 +67,7 @@ public interface IAnimationSampler<T>
6767 /// </remarks>
6868 sealed partial class AnimationSampler :
6969 IChildOfList < Animation > ,
70+ IAnimationSampler < Boolean > ,
7071 IAnimationSampler < Single > ,
7172 IAnimationSampler < Vector2 > ,
7273 IAnimationSampler < Vector3 > ,
@@ -148,7 +149,29 @@ private Accessor _CreateInputAccessor(ROLIST input)
148149 return accessor ;
149150 }
150151
151- private Accessor _CreateOutputAccessor ( ROLIST output )
152+ private Accessor _CreateOutputAccessor ( IReadOnlyList < Boolean > output )
153+ {
154+ Guard . NotNull ( output , nameof ( output ) ) ;
155+ Guard . MustBeGreaterThan ( output . Count , 0 , nameof ( output . Count ) ) ;
156+
157+ var root = LogicalParent . LogicalParent ;
158+
159+ var buffer = root . CreateBufferView ( output . Count * 1 * 1 ) ;
160+
161+ System . Diagnostics . Debug . Assert ( buffer . ByteStride == 0 ) ;
162+
163+ var accessor = root . CreateAccessor ( "Animation.Output" ) ;
164+
165+ accessor . SetData ( buffer , 0 , output . Count , AttributeFormat . Byte1 ) ;
166+
167+ Memory . EncodedArrayUtils . _CopyTo ( output , accessor . AsArrayOf < UInt32 > ( ) ) ;
168+
169+ accessor . UpdateBounds ( ) ;
170+
171+ return accessor ;
172+ }
173+
174+ private Accessor _CreateOutputAccessor ( IReadOnlyList < Single > output )
152175 {
153176 Guard . NotNull ( output , nameof ( output ) ) ;
154177 Guard . MustBeGreaterThan ( output . Count , 0 , nameof ( output . Count ) ) ;
@@ -344,6 +367,15 @@ private static (Single[] Keys, TValue[] Values) _Split<TValue>(IReadOnlyDictiona
344367 return ( keys , vals ) ;
345368 }
346369
370+ internal void SetKeys ( IReadOnlyDictionary < Single , Boolean > keyframes )
371+ {
372+ Guard . NotNullOrEmpty ( keyframes , nameof ( keyframes ) ) ;
373+
374+ var ( keys , values ) = _Split ( keyframes ) ;
375+ _input = this . _CreateInputAccessor ( keys ) . LogicalIndex ;
376+ _output = this . _CreateOutputAccessor ( values ) . LogicalIndex ;
377+ }
378+
347379 internal void SetKeys ( IReadOnlyDictionary < Single , Single > keyframes )
348380 {
349381 Guard . NotNullOrEmpty ( keyframes , nameof ( keyframes ) ) ;
@@ -533,6 +565,20 @@ internal void SetCubicKeys(IReadOnlyDictionary<Single, (SPARSE8 TangentIn, SPARS
533565 _output = this . _CreateOutputAccessor ( values , expandedCount ) . LogicalIndex ;
534566 }
535567
568+ /// <inheritdoc/>
569+ IEnumerable < ( Single , Boolean ) > IAnimationSampler < Boolean > . GetLinearKeys ( )
570+ {
571+ Guard . IsTrue ( this . InterpolationMode == AnimationInterpolationMode . STEP , nameof ( InterpolationMode ) ) ;
572+
573+ var keys = this . Input . AsScalarArray ( ) ;
574+ var frames = this . Output . AsIndexArray ( ) ;
575+ var boolFrames = new BooleanArrayOverIntegerArray ( frames ) ;
576+ System . Diagnostics . Debug . Assert ( frames . Count == boolFrames . Count ) ;
577+ System . Diagnostics . Debug . Assert ( frames . Count ( ) == boolFrames . Count ( ) ) ;
578+
579+ return keys . Zip ( boolFrames , ( key , val ) => ( key , val ) ) ;
580+ }
581+
536582 /// <inheritdoc/>
537583 IEnumerable < ( Single , Single ) > IAnimationSampler < Single > . GetLinearKeys ( )
538584 {
@@ -627,6 +673,12 @@ internal void SetCubicKeys(IReadOnlyDictionary<Single, (SPARSE8 TangentIn, SPARS
627673 return keys . Zip ( frames , ( key , val ) => ( key , val ) ) ;
628674 }
629675
676+ /// <inheritdoc/>
677+ IEnumerable < ( Single , ( Boolean , Boolean , Boolean ) ) > IAnimationSampler < Boolean > . GetCubicKeys ( )
678+ {
679+ throw new NotSupportedException ( ) ;
680+ }
681+
630682 /// <inheritdoc/>
631683 IEnumerable < ( Single , ( Single , Single , Single ) ) > IAnimationSampler < Single > . GetCubicKeys ( )
632684 {
@@ -720,6 +772,19 @@ internal void SetCubicKeys(IReadOnlyDictionary<Single, (SPARSE8 TangentIn, SPARS
720772 return keys . Zip ( frames , ( key , val ) => ( key , SPARSE8 . AsTuple ( val . TangentIn , val . Value , val . TangentOut ) ) ) ;
721773 }
722774
775+ /// <inheritdoc/>
776+ ICurveSampler < Boolean > IAnimationSampler < Boolean > . CreateCurveSampler ( bool isolateMemory )
777+ {
778+ var xsampler = this as IAnimationSampler < Boolean > ;
779+
780+ switch ( this . InterpolationMode )
781+ {
782+ case AnimationInterpolationMode . STEP : return xsampler . GetLinearKeys ( ) . CreateSampler ( isolateMemory ) ;
783+ }
784+
785+ throw new NotImplementedException ( ) ;
786+ }
787+
723788 /// <inheritdoc/>
724789 ICurveSampler < Single > IAnimationSampler < Single > . CreateCurveSampler ( bool isolateMemory )
725790 {
0 commit comments