Esempio n. 1
0
  /**
   * When you call methods like for example {@link #setHalfWidth(float)} or {@link
   * #updateVertex(int, float, float)} work is being queued up. Before each draw call this method is
   * automatically called to do all this work.
   *
   * <p>It can be smart to call this method after you are done configuring your OutlinePolygon, but
   * before you exit your loading screen. This way you do more work during the loading screen and
   * get less initial lag.
   */
  public void updateStripAndCulling() {
    if (!changesToStripOrCulling) return;

    updateAllBoxIndices();

    boolean clockwiseUpdated = false;

    for (int i = 0; i < needsUpdate.size; i++) {
      boolean update = needsUpdate.items[i];
      if (update) {
        if (!clockwiseUpdated) {
          clockwiseUpdated = true;
          updateAuxVertexFinderClockwise();
        }
        if (drawInside) {
          updateVertex(i, true);
        }
        if (drawOutside) {
          updateVertex(i, false);
        }

        needsUpdate.items[i] = false;
      }
    }

    for (BoundingBox box : boundingBoxes) {
      if (box.needsCullingUpdate) {
        updateBoxCulling(box);
        box.needsCullingUpdate = false;
      }
    }
  }
Esempio n. 2
0
  public Rectangle getBoundingRectangle() {
    Rectangle rectangle = new Rectangle();
    boolean initialized = false;

    for (BoundingBox boundingBox : boundingBoxes) {
      updateBoxCulling(boundingBox);

      Rectangle cullingArea =
          getCullingArea(tmpRectangle, boundingBox.rectangle, angleRad, position, scale);

      if (!initialized) {
        rectangle.set(cullingArea);
        initialized = true;
      } else rectangle.merge(cullingArea);
    }

    return rectangle;
  }