Beispiel #1
0
  /**
   * <code>checkCulling</code> checks the spatial with the camera to see if it should be culled.
   *
   * <p>This method is called by the renderer. Usually it should not be called directly.
   *
   * @param cam The camera to check against.
   * @return true if inside or intersecting camera frustum (should be rendered), false if outside.
   */
  public boolean checkCulling(Camera cam) {
    if (refreshFlags != 0) {
      throw new IllegalStateException(
          "Scene graph is not properly updated for rendering.\n"
              + "State was changed after rootNode.updateGeometricState() call. \n"
              + "Make sure you do not modify the scene from another thread!\n"
              + "Problem spatial name: "
              + getName());
    }

    CullHint cm = getCullHint();
    assert cm != CullHint.Inherit;
    if (cm == Spatial.CullHint.Always) {
      setLastFrustumIntersection(Camera.FrustumIntersect.Outside);
      return false;
    } else if (cm == Spatial.CullHint.Never) {
      setLastFrustumIntersection(Camera.FrustumIntersect.Intersects);
      return true;
    }

    // check to see if we can cull this node
    frustrumIntersects =
        (parent != null ? parent.frustrumIntersects : Camera.FrustumIntersect.Intersects);

    if (frustrumIntersects == Camera.FrustumIntersect.Intersects) {
      if (getQueueBucket() == Bucket.Gui) {
        return cam.containsGui(getWorldBound());
      } else {
        frustrumIntersects = cam.contains(getWorldBound());
      }
    }

    return frustrumIntersects != Camera.FrustumIntersect.Outside;
  }