computeWorldVertices method
void
computeWorldVertices()
Implementation
void computeWorldVertices(Slot slot, int start, int count,
Float32List worldVertices, int offset, int stride) {
count = offset + (count >> 1) * stride;
final Skeleton skeleton = slot.bone.skeleton;
final Float32List deformArray = slot.attachmentVertices;
Float32List? vertices = this.vertices;
final Int32List? bones = this.bones;
if (bones == null) {
if (deformArray.isNotEmpty) vertices = deformArray;
final Bone bone = slot.bone;
final double x = bone.worldX;
final double y = bone.worldY;
final double a = bone.a, b = bone.b, c = bone.c, d = bone.d;
for (int v = start, w = offset; w < count; v += 2, w += stride) {
final double vx = vertices![v], vy = vertices[v + 1];
worldVertices[w] = vx * a + vy * b + x;
worldVertices[w + 1] = vx * c + vy * d + y;
}
return;
}
int v = 0, skip = 0;
for (int i = 0; i < start; i += 2) {
final int n = bones[v];
v += n + 1;
skip += n;
}
final List<Bone> skeletonBones = skeleton.bones;
if (deformArray.isEmpty) {
for (int w = offset, b = skip * 3; w < count; w += stride) {
double wx = 0.0, wy = 0.0;
int n = bones[v++];
n += v;
for (; v < n; v++, b += 3) {
final Bone bone = skeletonBones[bones[v]];
final double vx = vertices![b],
vy = vertices[b + 1],
weight = vertices[b + 2];
wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
}
worldVertices[w] = wx;
worldVertices[w + 1] = wy;
}
} else {
final Float32List deform = deformArray;
for (int w = offset, b = skip * 3, f = skip << 1;
w < count;
w += stride) {
double wx = 0.0, wy = 0.0;
int n = bones[v++];
n += v;
for (; v < n; v++, b += 3, f += 2) {
final Bone bone = skeletonBones[bones[v]];
final double vx = vertices![b] + deform[f],
vy = vertices[b + 1] + deform[f + 1],
weight = vertices[b + 2];
wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
}
worldVertices[w] = wx;
worldVertices[w + 1] = wy;
}
}
}