skin method

  1. @override
PathPoint skin(
  1. Mat2D world,
  2. Float32List? bones
)
override

Implementation

@override
PathPoint skin(Mat2D world, Float32List? bones) {
  StraightPathPoint point = StraightPathPoint()..radius = radius;

  double px =
      world[0] * translation[0] + world[2] * translation[1] + world[4];
  double py =
      world[1] * translation[0] + world[3] * translation[1] + world[5];

  double a = 0.0, b = 0.0, c = 0.0, d = 0.0, e = 0.0, f = 0.0;

  for (int i = 0; i < 4; i++) {
    int boneIndex = _weights![i].floor();
    double weight = _weights![i + 4];
    if (weight > 0) {
      int bb = boneIndex * 6;

      a += bones![bb] * weight;
      b += bones[bb + 1] * weight;
      c += bones[bb + 2] * weight;
      d += bones[bb + 3] * weight;
      e += bones[bb + 4] * weight;
      f += bones[bb + 5] * weight;
    }
  }

  Vec2D pos = point.translation;
  pos[0] = a * px + c * py + e;
  pos[1] = b * px + d * py + f;

  return point;
}