* Made Geometry.associate/unassociate To/From GroupNode methods public so they can be GeometryGroupNode implementations outside the com.jme3.scene package

* Added ability to get the geometry start index for GeometryGroupNode implementations
experimental
shadowislord 11 years ago
parent 5b7a408bcc
commit 52b93ba933
  1. 12
      jme3-core/src/main/java/com/jme3/scene/Geometry.java
  2. 14
      jme3-core/src/main/java/com/jme3/scene/GeometryGroupNode.java

@ -81,7 +81,7 @@ public class Geometry extends Spatial {
* The start index of this <code>Geometry's</code> inside
* the {@link GeometryGroupNode}.
*/
protected int startIndex;
protected int startIndex = -1;
/**
* Serialization only. Do not use.
*/
@ -316,7 +316,7 @@ public class Geometry extends Spatial {
* @param node Which {@link GeometryGroupNode} to associate with.
* @param startIndex The starting index of this geometry in the group.
*/
protected void associateWithGroupNode(GeometryGroupNode node, int startIndex) {
public void associateWithGroupNode(GeometryGroupNode node, int startIndex) {
if (isGrouped()) {
unassociateFromGroupNode();
}
@ -331,13 +331,15 @@ public class Geometry extends Spatial {
*
* Should only be called by the parent {@link GeometryGroupNode}.
*/
protected void unassociateFromGroupNode() {
public void unassociateFromGroupNode() {
if (groupNode != null) {
// Once the geometry is removed
// from the parent, the group node needs to be updated.
groupNode.onGeoemtryUnassociated(this);
groupNode = null;
startIndex = 0;
// change the default to -1 to make error detection easier
startIndex = -1;
}
}
@ -486,7 +488,7 @@ public class Geometry extends Spatial {
// but the cloned one is not attached to anything, hence not managed.
if (isGrouped()) {
groupNode = null;
startIndex = 0;
startIndex = -1;
}
geomClone.cachedWorldMat = cachedWorldMat.clone();

@ -8,6 +8,20 @@ package com.jme3.scene;
*/
public abstract class GeometryGroupNode extends Node {
protected static int getGeometryStartIndex(Geometry geom) {
if (geom.startIndex == -1) {
throw new AssertionError();
}
return geom.startIndex;
}
protected static void setGeometryStartIndex(Geometry geom, int startIndex) {
if (startIndex < -1) {
throw new AssertionError();
}
geom.startIndex = startIndex;
}
/**
* Construct a <code>GeometryGroupNode</code>
*/

Loading…
Cancel
Save