selectActiveTargets static method
List<({int index, double weight})>
selectActiveTargets(
- Float32List weights, {
- int cap = kMaxGpuMorphTargets,
Picks the morph targets to evaluate on the GPU: the nonzero entries of
weights with the largest magnitudes, at most cap of them, ordered
by descending magnitude (ties keep the lower index first).
Implementation
static List<({int index, double weight})> selectActiveTargets(
Float32List weights, {
int cap = kMaxGpuMorphTargets,
}) {
final active = <({int index, double weight})>[
for (var i = 0; i < weights.length; i++)
if (weights[i] != 0.0) (index: i, weight: weights[i]),
];
active.sort((a, b) {
final byMagnitude = b.weight.abs().compareTo(a.weight.abs());
if (byMagnitude != 0) return byMagnitude;
return a.index.compareTo(b.index);
});
return active.length > cap ? active.sublist(0, cap) : active;
}