Browse Source

* Geometry will now automatically de-share VertexBuffers if it detects it

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9004 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Sha..rd 13 years ago
parent
commit
77252b4304
1 changed files with 12 additions and 0 deletions
  1. 12 0
      engine/src/core/com/jme3/scene/Geometry.java

+ 12 - 0
engine/src/core/com/jme3/scene/Geometry.java

@@ -59,6 +59,10 @@ import java.util.logging.Logger;
  */
 public class Geometry extends Spatial {
 
+    // Version #1: removed shared meshes. 
+    // models loaded with shared mesh will be automatically fixed.
+    public static final int SAVABLE_VERSION = 1;
+    
     private static final Logger logger = Logger.getLogger(Geometry.class.getName());
     protected Mesh mesh;
     protected transient int lodLevel = 0;
@@ -549,5 +553,13 @@ public class Geometry extends Spatial {
             material = (Material) ic.readSavable("material", null);
         }
         ignoreTransform = ic.readBoolean("ignoreTransform", false);
+        
+        if (ic.getSavableVersion(Geometry.class) == 0){
+            // Fix shared mesh (if set)
+            Mesh sharedMesh = getUserData(UserData.JME_SHAREDMESH);
+            if (sharedMesh != null){
+                getMesh().extractVertexData(sharedMesh);
+            }
+        }
     }
 }