Geometry : fixed an issue where batching information were copied over cloning causing problem because the cloned geometry was marked as batched but was not.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9731 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent 2577485727
commit 5635bc2ff1
  1. 23
      engine/src/core/com/jme3/scene/Geometry.java

@ -62,7 +62,6 @@ public class Geometry extends Spatial {
// Version #1: removed shared meshes. // Version #1: removed shared meshes.
// models loaded with shared mesh will be automatically fixed. // models loaded with shared mesh will be automatically fixed.
public static final int SAVABLE_VERSION = 1; public static final int SAVABLE_VERSION = 1;
private static final Logger logger = Logger.getLogger(Geometry.class.getName()); private static final Logger logger = Logger.getLogger(Geometry.class.getName());
protected Mesh mesh; protected Mesh mesh;
protected transient int lodLevel = 0; protected transient int lodLevel = 0;
@ -323,8 +322,10 @@ public class Geometry extends Spatial {
prevBatchTransforms = null; prevBatchTransforms = null;
cachedOffsetMat = null; cachedOffsetMat = null;
//once the geometry is removed from the screnegraph the batchNode needs to be rebatched. //once the geometry is removed from the screnegraph the batchNode needs to be rebatched.
this.batchNode.setNeedsFullRebatch(true); if (batchNode != null) {
this.batchNode = null; this.batchNode.setNeedsFullRebatch(true);
this.batchNode = null;
}
setCullHint(CullHint.Dynamic); setCullHint(CullHint.Dynamic);
} }
@ -336,9 +337,9 @@ public class Geometry extends Spatial {
@Override @Override
protected void setParent(Node parent) { protected void setParent(Node parent) {
super.setParent(parent); super.setParent(parent);
//if the geometry is batched we also have to unbatch it //if the geometry is batched we also have to unbatch it
if(parent==null && isBatched()){ if (parent == null && isBatched()) {
unBatch(); unBatch();
} }
} }
@ -384,7 +385,6 @@ public class Geometry extends Spatial {
// refreshFlags |= RF_TRANSFORM; // refreshFlags |= RF_TRANSFORM;
// setBoundRefresh(); // setBoundRefresh();
// } // }
/** /**
* Recomputes the matrix returned by {@link Geometry#getWorldMatrix() }. * Recomputes the matrix returned by {@link Geometry#getWorldMatrix() }.
* This will require a localized transform update for this geometry. * This will require a localized transform update for this geometry.
@ -484,6 +484,11 @@ public class Geometry extends Spatial {
@Override @Override
public Geometry clone(boolean cloneMaterial) { public Geometry clone(boolean cloneMaterial) {
Geometry geomClone = (Geometry) super.clone(cloneMaterial); Geometry geomClone = (Geometry) super.clone(cloneMaterial);
//this geometry is batched but the clonned one should not be
if (isBatched()) {
geomClone.batchNode = null;
geomClone.unBatch();
}
geomClone.cachedWorldMat = cachedWorldMat.clone(); geomClone.cachedWorldMat = cachedWorldMat.clone();
if (material != null) { if (material != null) {
if (cloneMaterial) { if (cloneMaterial) {
@ -560,10 +565,10 @@ public class Geometry extends Spatial {
} }
ignoreTransform = ic.readBoolean("ignoreTransform", false); ignoreTransform = ic.readBoolean("ignoreTransform", false);
if (ic.getSavableVersion(Geometry.class) == 0){ if (ic.getSavableVersion(Geometry.class) == 0) {
// Fix shared mesh (if set) // Fix shared mesh (if set)
Mesh sharedMesh = getUserData(UserData.JME_SHAREDMESH); Mesh sharedMesh = getUserData(UserData.JME_SHAREDMESH);
if (sharedMesh != null){ if (sharedMesh != null) {
getMesh().extractVertexData(sharedMesh); getMesh().extractVertexData(sharedMesh);
} }
} }

Loading…
Cancel
Save