update method

  1. @override
void update(
  1. int dirt
)
override

Implementation

@override
void update(int dirt) {
  ActorSkinnable? skinnable = parent as ActorSkinnable?;
  if (skinnable == null) {
    return;
  }

  if (skinnable.isConnectedToBones) {
    List<SkinnedBone> connectedBones = skinnable.connectedBones!;
    int length = (connectedBones.length + 1) * 6;
    if (_boneMatrices.length != length) {
      _boneMatrices = Float32List(length);
      // First bone transform is always identity.
      _boneMatrices[0] = 1.0;
      _boneMatrices[1] = 0.0;
      _boneMatrices[2] = 0.0;
      _boneMatrices[3] = 1.0;
      _boneMatrices[4] = 0.0;
      _boneMatrices[5] = 0.0;
    }

    int bidx = 6; // Start after first identity.

    Mat2D mat = Mat2D();

    for (final SkinnedBone cb in connectedBones) {
      Mat2D.multiply(mat, cb.node.worldTransform, cb.inverseBind);

      _boneMatrices[bidx++] = mat[0];
      _boneMatrices[bidx++] = mat[1];
      _boneMatrices[bidx++] = mat[2];
      _boneMatrices[bidx++] = mat[3];
      _boneMatrices[bidx++] = mat[4];
      _boneMatrices[bidx++] = mat[5];
    }
  }

  skinnable.invalidateDrawable();
}