Vixen
dd8b0a81
csharp
public sealed class MorphWeightBuffer

Where a frame's blend-shape weights are collected, by shape name.

Read the guide page for this →

Remarks

The same shape as AnimationEventBuffer and ConstraintTagBuffer, and for the same reason: a weight is produced in the middle of evaluating a blend tree, at a point where the pose is half-built and the layer stack is mid-flight. Collecting here and reading afterwards is the only ordering something outside the animator can work with.

⚠ Weights add across clips, which is what makes a blend continuous. A tree mixing a neutral and a smile at 0.6/0.4 contributes 0.6 and 0.4 of each clip's curves, and because a tree's own child weights sum to one the result is exactly the linear blend of the two curves. A clip that says nothing about a shape contributes nothing to it and the shape simply weakens rather than snapping, which is the argument ConstraintTagBuffer makes about a hand goal holding through a transition.

⚠ Across layers the sum is additive and not an override, and that is a real limitation rather than a rounding of one. A facial layer is normally additive, so a sum is what it wants; two layers that both drive jawOpen as an override will produce their sum rather than the upper one's value. Nothing here models an override, because the pose machinery that does — Apply — works on joints, and a shape is not one.

A shape is in the buffer because a clip drove it, not because its weight is non-zero. Zero is a face at rest and is a value a curve returns to on purpose, so the membership and the value are separate facts — see TryGet, whose return value is the first and whose out parameter is the second.

Fields and properties (4)

  • public int Count

    How many shapes were driven this frame.

  • public float this[int index]

    One of them, by position.

  • public ReadOnlySpan<string> Shapes

    The shapes driven this frame, in the order they were first collected.

  • public ReadOnlySpan<float> Weights

    Their weights, in the same order.

Methods (4)

  • public void Add(string shape, float weight)

    Adds a contribution to one shape.

  • public void Collect(AnimationClip? clip, float time, float weight)

    Adds every shape a clip drives, scaled by how much the clip is contributing.

  • public bool TryGet(string shape, out float weight)

    One shape's accumulated weight, if anything drove it.

  • public void Clear()

    Empties the buffer, keeping its capacity.

Used by (6)

  • AnimatorVixen.Animation
  • BlendShapeAnimationSystemVixen.Animation
  • BlendShapeTrackTestsVixen.Animation.Tests
  • ClipMotionVixen.Animation
  • MotionContextVixen.Animation
  • StateMachineInstanceVixen.Animation