update method

void update(
  1. Skeleton skeleton,
  2. bool updateAabb
)

Implementation

void update(Skeleton skeleton, bool updateAabb) {
  final List<BoundingBoxAttachment> boundingBoxes = this.boundingBoxes;
  final List<Float32List> polygons = this.polygons;
  final Pool<Float32List> polygonPool = this.polygonPool;
  final List<Slot> slots = skeleton.slots;
  final int slotCount = slots.length;

  boundingBoxes.length = 0;
  polygonPool.freeAll(polygons);
  polygons.length = 0;

  for (int i = 0; i < slotCount; i++) {
    final Slot slot = slots[i];
    final Attachment? attachment = slot.getAttachment();
    if (attachment is BoundingBoxAttachment) {
      boundingBoxes.add(attachment);

      Float32List polygon = polygonPool.obtain();
      if (polygon.length != attachment.worldVerticesLength) {
        polygon = Float32List(attachment.worldVerticesLength);
      }
      polygons.add(polygon);
      attachment.computeWorldVertices(
          slot, 0, attachment.worldVerticesLength, polygon, 0, 2);
    }
  }

  if (updateAabb) {
    aabbCompute();
  } else {
    minX = double.infinity;
    minY = double.infinity;
    maxX = double.negativeInfinity;
    maxY = double.negativeInfinity;
  }
}