readVertices method

void readVertices(
  1. Map<String, dynamic> map,
  2. VertexAttachment attachment,
  3. int verticesLength
)

Implementation

void readVertices(Map<String, dynamic> map, VertexAttachment attachment,
    int verticesLength) {
  final double scale = this.scale;
  attachment.worldVerticesLength = verticesLength;
  final Float32List vertices = _getFloat32List(map, 'vertices')!;
  if (verticesLength == vertices.length) {
    if (scale != 1) {
      final int n = vertices.length;
      for (int i = 0; i < n; i++) {
        vertices[i] *= scale;
      }
    }

    attachment.vertices = vertices;
    return;
  }
  final List<double> weights = <double>[];
  final List<int> bones = <int>[];
  final int n = vertices.length;
  for (int i = 0; i < n;) {
    final int boneCount = vertices[i++].toInt();
    bones.add(boneCount);
    final int nn = i + boneCount * 4;
    for (; i < nn; i += 4) {
      bones.add(vertices[i].toInt());
      weights
        ..add(vertices[i + 1] * scale)
        ..add(vertices[i + 2] * scale)
        ..add(vertices[i + 3]);
    }
  }
  attachment
    ..bones = Int32List.fromList(bones)
    ..vertices = Float32List.fromList(weights);
}