MorphBlend class final
Blends a mesh's morph targets into a copy of its vertices.
On the CPU, and that is a decision with a cost worth naming. The vertex
layout in this engine is structural — the in declarations of mesh.vert
are the layout, and one layout serves every model so that a lighting model
does not need a pipeline per attribute set. Morphing on the GPU means either
a second layout, and with it a second vertex shader per lighting model, or
the deltas in a texture the vertex stage samples by vertex id. No vertex
stage in this engine samples anything today, and whether flutter_gpu binds a
texture to one is unmeasured rather than known.
So this blends where every backend can already draw the result: into the vertex buffer, which is then uploaded like any other. What it costs is a pass over the mesh and an upload on every frame the weights change, which is affordable for the thing morph targets are actually for — a face, a few thousand vertices, one of them on screen — and is not affordable for a crowd. A GPU path would replace this for the two hardware backends and leave it here for the software one, which has no other way to do it.
Nothing is recomputed when nothing moved. blend returns false when the weights it was handed are the ones already applied, so a face holding an expression costs one comparison a frame rather than a pass and an upload.
Constructors
- MorphBlend(MeshData mesh)
Properties
-
appliedWeights
→ List<
double> -
What the weights were when the vertices were last written.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- mesh → MeshData
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- vertices → Float32List
-
The blended vertices, in the mesh's own layout and stride.
no setter
Methods
-
blend(
List< double> weights) → bool -
Blends
weightsinto vertices, and says whether anything changed. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited