Example #1
0
  /**
   * <code>updateGeometricState</code> updates the lightlist, computes the world transforms, and
   * computes the world bounds for this Spatial. Calling this when the Spatial is attached to a node
   * will cause undefined results. User code should only call this method on Spatials having no
   * parent.
   *
   * @see Spatial#getWorldLightList()
   * @see Spatial#getWorldTransform()
   * @see Spatial#getWorldBound()
   */
  public void updateGeometricState() {
    // assume that this Spatial is a leaf, a proper implementation
    // for this method should be provided by Node.

    // NOTE: Update world transforms first because
    // bound transform depends on them.
    if ((refreshFlags & RF_LIGHTLIST) != 0) {
      updateWorldLightList();
    }
    if ((refreshFlags & RF_TRANSFORM) != 0) {
      updateWorldTransforms();
    }
    if ((refreshFlags & RF_BOUND) != 0) {
      updateWorldBound();
    }

    assert refreshFlags == 0;
  }
Example #2
0
  /** Computes the world transform of this Spatial in the most efficient manner possible. */
  void checkDoTransformUpdate() {
    if ((refreshFlags & RF_TRANSFORM) == 0) {
      return;
    }

    if (parent == null) {
      worldTransform.set(localTransform);
      refreshFlags &= ~RF_TRANSFORM;
    } else {
      TempVars vars = TempVars.get();

      Spatial[] stack = vars.spatialStack;
      Spatial rootNode = this;
      int i = 0;
      while (true) {
        Spatial hisParent = rootNode.parent;
        if (hisParent == null) {
          rootNode.worldTransform.set(rootNode.localTransform);
          rootNode.refreshFlags &= ~RF_TRANSFORM;
          i--;
          break;
        }

        stack[i] = rootNode;

        if ((hisParent.refreshFlags & RF_TRANSFORM) == 0) {
          break;
        }

        rootNode = hisParent;
        i++;
      }

      vars.release();

      for (int j = i; j >= 0; j--) {
        rootNode = stack[j];
        // rootNode.worldTransform.set(rootNode.localTransform);
        // rootNode.worldTransform.combineWithParent(rootNode.parent.worldTransform);
        // rootNode.refreshFlags &= ~RF_TRANSFORM;
        rootNode.updateWorldTransforms();
      }
    }
  }