public sealed class AnimationClipA clip as the runtime plays it: keys resolved to joint indices, sampled by time, with events and a root joint.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
AnimationClipData is what an import writes — channels addressed by joint name, because an importer has no skeleton to resolve them against and no guarantee the skeleton it would resolve against is the one the clip will be played on. This is the resolution: a clip is baked against a skeleton once, at load, and the names never appear again. A frame does array indexing.
A clip is shared and immutable. A hundred enemies playing the same run cycle hold one of these between them and a playback time each, so nothing about sampling may depend on who is sampling — which is why Sample takes a time and a destination and keeps nothing.
Keys are found in constant time, through an index and not a cursor. The usual optimisation is a cursor — remember where the last sample landed and step forward from there — and it cannot live here, because a clip is shared by every instance playing it; living on the player means a hint per track per clip per instance, over a set of clips that changes as a blend tree's parameter moves. The index is the same win without the state: each long track carries a table of one entry per key, mapping a uniform slice of the clip's duration to the key at or before it, so a lookup is one multiply, one array read and — because there is on average one key per slice — about one comparison. It is O(1) rather than the cursor's amortised O(1), it is correct for a random seek as well as for forward playback, and being immutable it is safe to sample from several threads at once. It costs four bytes a key against the twelve to sixteen the key itself takes, and short tracks (eight keys or fewer) skip it and binary-search instead. Measured, a random seek costs what a forward step costs and thirty times the keys costs fifteen percent more — see Benchmarks/Vixen.Benchmarks.Animation, where the residual growth is the working set rather than the search.
Rotations are packed into eight bytes. See PackedQuaternion — half the memory and half the cache traffic on the tracks that dominate a skeletal clip, for an angular error five orders of magnitude below what blending them in float preserves.
Fields and properties (8)
public string NameWhat the clip is called.
public float DurationHow long it plays for, in seconds. Never zero — a zero-length clip is one frame long.
public Skeleton SkeletonThe skeleton it was baked against, and the only one it may be sampled onto.
public int RootJointWhich joint carries the character's motion through the world, or −1 if none does.
public int TrackCountHow many joints it actually drives.
public int UnresolvedChannelsHow many of the imported channels named a joint this skeleton does not have.
public ReadOnlySpan<AnimationEvent> EventsThe events authored on it, ordered by time.
public ConstraintTrack? ConstraintsThe constraints authored on it, or if it carries none.
Methods (7)
public void Sample(float time, Span<BoneTransform> destination)Poses a skeleton at a moment in the clip.
public BoneTransform SampleRoot(float time)Where the root joint is at a moment in the clip.
public RootMotionDelta ExtractRootMotion(float from, float to, int loops = 0)How far the root moved between two times, across any number of whole loops.
public void CollectEvents(float from, float to, int loops, AnimationEventBuffer sink, int layer, string state, float weight)Reports the events crossed by advancing from one time to another.
public float Advance(float time, float delta, WrapMode mode, out int loops)Advances a playback time and reports how the clip's end was dealt with.
public static float Advance(float time, float delta, WrapMode mode, float length, out int loops)Advances a playback time over a given length.
public static AnimationClip Create(AnimationClipData data, Skeleton skeleton, IEnumerable<AnimationEvent>? events = null, string? rootJoint = null, ConstraintTrack? constraints = null)Bakes an imported clip against a skeleton.
Used by (32)
- ConstraintStageBenchmarksVixen.Benchmarks.Animation
- CrowdBenchmarksVixen.Benchmarks.Animation
- MoveSelectionBenchmarksVixen.Benchmarks.Animation
- RigsVixen.Benchmarks.Animation
- SamplingBenchmarksVixen.Benchmarks.Animation
- AnimationClipCacheVixen.Animation
- AnimationClipContentVixen.Animation
- AnimationClipTestsVixen.Animation.Tests
- AnimatorTestsVixen.Animation.Tests
- AuthoringTestsVixen.Animation.Tests
- BakedVixen.Animation
- BlendTreeTestsVixen.Animation.Tests
- ClipMotionVixen.Animation
- CompressionTestsVixen.Animation.Tests
- ConstraintProposalsVixen.Animation
- ConstraintStageTestsVixen.Animation.Tests
- ConstraintTestsVixen.Animation.Tests
- EcsIntegrationTestsVixen.Animation.Tests
- LoadPathTestsVixen.Animation.Tests
- MoveSetTestsVixen.Animation.Tests
- MoveTransitionTestsVixen.Animation.Tests
- ProxyShapeAuditVixen.Animation
- RetargetingTestsVixen.Animation.Tests
- RootMotionTestsVixen.Animation.Tests
- SkeletonRetargetVixen.Animation
- StateMachineInstanceVixen.Animation
- StateMachineTestsVixen.Animation.Tests
- VariationHarnessVixen.Animation
- AnimationClipImporterTestsVixen.Editor.Assets.Tests
- AnimationGraphCompilerVixen.Editor.AnimationGraph
- AuthoringContextTestsVixen.Editor.AssetEditors.Tests
- ProxyShapeDocumentVixen.Editor.AssetEditors