Browse Source

Introduce cachedLocalMat and update cloning logic (#2612)

* Introduce cachedLocalMat and update cloning logic

Added a cachedLocalMat field and updated cloneFields method.

* Add Cloner import to SimpleBatchNode
Wyatt Gillette 1 week ago
parent
commit
e319e2f34a
1 changed files with 10 additions and 2 deletions
  1. 10 2
      jme3-core/src/main/java/com/jme3/scene/SimpleBatchNode.java

+ 10 - 2
jme3-core/src/main/java/com/jme3/scene/SimpleBatchNode.java

@@ -33,6 +33,7 @@ package com.jme3.scene;
 
 
 import com.jme3.math.Matrix4f;
 import com.jme3.math.Matrix4f;
 import com.jme3.util.TempVars;
 import com.jme3.util.TempVars;
+import com.jme3.util.clone.Cloner;
 
 
 /**
 /**
  * 
  * 
@@ -47,6 +48,8 @@ import com.jme3.util.TempVars;
  */
  */
 public class SimpleBatchNode extends BatchNode {
 public class SimpleBatchNode extends BatchNode {
 
 
+    private Matrix4f cachedLocalMat = new Matrix4f();
+
     public SimpleBatchNode() {
     public SimpleBatchNode() {
         super();
         super();
     }
     }
@@ -73,8 +76,6 @@ public class SimpleBatchNode extends BatchNode {
             batch.geometry.setTransformRefresh();
             batch.geometry.setTransformRefresh();
         }
         }
     }
     }
-    
-    private final Matrix4f cachedLocalMat = new Matrix4f();
 
 
     @Override
     @Override
     protected Matrix4f getTransformMatrix(Geometry g){
     protected Matrix4f getTransformMatrix(Geometry g){
@@ -96,4 +97,11 @@ public class SimpleBatchNode extends BatchNode {
     public void batch() {
     public void batch() {
         doBatch();
         doBatch();
     }
     }
+
+    @Override
+    public void cloneFields(Cloner cloner, Object original) {
+        super.cloneFields(cloner, original);
+        this.cachedLocalMat = cloner.clone(cachedLocalMat);
+    }
+    
 }
 }