Selaa lähdekoodia

eliminate uses/overrides, deprecate implementations of cloneForSpatial()

Stephen Gold 7 vuotta sitten
vanhempi
commit
15285cc302
23 muutettua tiedostoa jossa 59 lisäystä ja 409 poistoa
  1. 10 3
      jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java
  2. 1 10
      jme3-bullet/src/common/java/com/jme3/bullet/control/BetterCharacterControl.java
  3. 3 14
      jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java
  4. 4 11
      jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java
  5. 0 12
      jme3-bullet/src/common/java/com/jme3/bullet/control/KinematicRagdollControl.java
  6. 3 25
      jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java
  7. 3 48
      jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java
  8. 2 31
      jme3-core/src/main/java/com/jme3/animation/AnimControl.java
  9. 0 15
      jme3-core/src/main/java/com/jme3/animation/EffectTrack.java
  10. 0 43
      jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java
  11. 4 3
      jme3-core/src/main/java/com/jme3/app/StatsView.java
  12. 3 16
      jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java
  13. 2 2
      jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java
  14. 4 6
      jme3-core/src/main/java/com/jme3/input/ChaseCamera.java
  15. 1 31
      jme3-core/src/main/java/com/jme3/scene/Geometry.java
  16. 5 63
      jme3-core/src/main/java/com/jme3/scene/Spatial.java
  17. 3 20
      jme3-core/src/main/java/com/jme3/scene/control/AbstractControl.java
  18. 1 11
      jme3-core/src/main/java/com/jme3/scene/control/LodControl.java
  19. 1 13
      jme3-core/src/main/java/com/jme3/scene/control/UpdateControl.java
  20. 3 5
      jme3-core/src/main/java/com/jme3/scene/instancing/InstancedNode.java
  21. 3 2
      jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java
  22. 1 11
      jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/NormalRecalcControl.java
  23. 2 14
      jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainLodControl.java

+ 10 - 3
jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,7 @@ import com.jme3.math.Vector3f;
 import com.jme3.renderer.RenderManager;
 import com.jme3.renderer.ViewPort;
 import com.jme3.scene.Spatial;
+import com.jme3.scene.control.Control;
 import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.JmeCloneable;
 import java.io.IOException;
@@ -162,8 +163,14 @@ public abstract class AbstractPhysicsControl implements PhysicsControl, JmeClone
         }
 
     }
-    
-    @Override   
+
+    @Deprecated
+    @Override
+    public Control cloneForSpatial(Spatial spatial) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override  
     public void cloneFields( Cloner cloner, Object original ) { 
         this.spatial = cloner.clone(spatial);
         createSpatialData(this.spatial);

+ 1 - 10
jme3-bullet/src/common/java/com/jme3/bullet/control/BetterCharacterControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -48,9 +48,7 @@ import com.jme3.math.Vector3f;
 import com.jme3.renderer.RenderManager;
 import com.jme3.renderer.ViewPort;
 import com.jme3.scene.Spatial;
-import com.jme3.scene.control.Control;
 import com.jme3.util.TempVars;
-import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.JmeCloneable;
 import java.io.IOException;
 import java.util.List;
@@ -665,13 +663,6 @@ public class BetterCharacterControl extends AbstractPhysicsControl implements Ph
         rigidBody.setUserObject(null);
     }
 
-    @Override
-    public Control cloneForSpatial(Spatial spatial) {
-        BetterCharacterControl control = new BetterCharacterControl(radius, height, mass);
-        control.setJumpForce(jumpForce);
-        return control;
-    }
-
     @Override
     public Object jmeClone() {
         BetterCharacterControl control = new BetterCharacterControl(radius, height, mass);

+ 3 - 14
jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -89,21 +89,10 @@ public class CharacterControl extends PhysicsCharacter implements PhysicsControl
         return spatial.getWorldTranslation();
     }
 
+    @Deprecated
     @Override
     public Control cloneForSpatial(Spatial spatial) {
-        CharacterControl control = new CharacterControl(collisionShape, stepHeight);
-        control.setCcdMotionThreshold(getCcdMotionThreshold());
-        control.setCcdSweptSphereRadius(getCcdSweptSphereRadius());
-        control.setCollideWithGroups(getCollideWithGroups());
-        control.setCollisionGroup(getCollisionGroup());
-        control.setFallSpeed(getFallSpeed());
-        control.setGravity(getGravity());
-        control.setJumpSpeed(getJumpSpeed());
-        control.setMaxSlope(getMaxSlope());
-        control.setPhysicsLocation(getPhysicsLocation());
-        control.setUpAxis(getUpAxis());
-        control.setApplyPhysicsLocal(isApplyPhysicsLocal());
-        return control;
+        throw new UnsupportedOperationException();
     }
 
     @Override

+ 4 - 11
jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -95,20 +95,13 @@ public class GhostControl extends PhysicsGhostObject implements PhysicsControl,
         return spatial.getWorldRotation();
     }
 
+    @Deprecated
     @Override
     public Control cloneForSpatial(Spatial spatial) {
-        GhostControl control = new GhostControl(collisionShape);
-        control.setCcdMotionThreshold(getCcdMotionThreshold());
-        control.setCcdSweptSphereRadius(getCcdSweptSphereRadius());
-        control.setCollideWithGroups(getCollideWithGroups());
-        control.setCollisionGroup(getCollisionGroup());
-        control.setPhysicsLocation(getPhysicsLocation());
-        control.setPhysicsRotation(getPhysicsRotationMatrix());
-        control.setApplyPhysicsLocal(isApplyPhysicsLocal());
-        return control;
+        throw new UnsupportedOperationException();
     }
 
-    @Override   
+    @Override
     public Object jmeClone() {
         GhostControl control = new GhostControl(collisionShape);
         control.setCcdMotionThreshold(getCcdMotionThreshold());

+ 0 - 12
jme3-bullet/src/common/java/com/jme3/bullet/control/KinematicRagdollControl.java

@@ -59,9 +59,7 @@ import com.jme3.renderer.RenderManager;
 import com.jme3.renderer.ViewPort;
 import com.jme3.scene.Node;
 import com.jme3.scene.Spatial;
-import com.jme3.scene.control.Control;
 import com.jme3.util.TempVars;
-import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.JmeCloneable;
 import java.io.IOException;
 import java.util.*;
@@ -912,16 +910,6 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P
     public void render(RenderManager rm, ViewPort vp) {
     }
 
-    @Override
-    public Control cloneForSpatial(Spatial spatial) {
-        KinematicRagdollControl control = new KinematicRagdollControl(preset, weightThreshold);
-        control.setMode(mode);
-        control.setRootMass(rootMass);
-        control.setWeightThreshold(weightThreshold);
-        control.setApplyPhysicsLocal(applyLocal);
-        return control;
-    }
-   
     @Override   
     public Object jmeClone() {
         KinematicRagdollControl control = new KinematicRagdollControl(preset, weightThreshold);        

+ 3 - 25
jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -53,7 +53,6 @@ import com.jme3.scene.shape.Box;
 import com.jme3.scene.shape.Sphere;
 import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.JmeCloneable;
-
 import java.io.IOException;
 
 /**
@@ -92,31 +91,10 @@ public class RigidBodyControl extends PhysicsRigidBody implements PhysicsControl
         super(shape, mass);
     }
 
+    @Deprecated
     @Override
     public Control cloneForSpatial(Spatial spatial) {
-        RigidBodyControl control = new RigidBodyControl(collisionShape, mass);
-        control.setAngularFactor(getAngularFactor());
-        control.setAngularSleepingThreshold(getAngularSleepingThreshold());
-        control.setCcdMotionThreshold(getCcdMotionThreshold());
-        control.setCcdSweptSphereRadius(getCcdSweptSphereRadius());
-        control.setCollideWithGroups(getCollideWithGroups());
-        control.setCollisionGroup(getCollisionGroup());
-        control.setDamping(getLinearDamping(), getAngularDamping());
-        control.setFriction(getFriction());
-        control.setGravity(getGravity());
-        control.setKinematic(isKinematic());
-        control.setKinematicSpatial(isKinematicSpatial());
-        control.setLinearSleepingThreshold(getLinearSleepingThreshold());
-        control.setPhysicsLocation(getPhysicsLocation(null));
-        control.setPhysicsRotation(getPhysicsRotationMatrix(null));
-        control.setRestitution(getRestitution());
-
-        if (mass > 0) {
-            control.setAngularVelocity(getAngularVelocity());
-            control.setLinearVelocity(getLinearVelocity());
-        }
-        control.setApplyPhysicsLocal(isApplyPhysicsLocal());
-        return control;
+        throw new UnsupportedOperationException();
     }
 
     @Override   

+ 3 - 48
jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,6 @@ import com.jme3.math.Quaternion;
 import com.jme3.math.Vector3f;
 import com.jme3.renderer.RenderManager;
 import com.jme3.renderer.ViewPort;
-import com.jme3.scene.Node;
 import com.jme3.scene.Spatial;
 import com.jme3.scene.control.Control;
 import com.jme3.util.clone.Cloner;
@@ -108,54 +107,10 @@ public class VehicleControl extends PhysicsVehicle implements PhysicsControl, Jm
         return spatial.getWorldRotation();
     }
 
+    @Deprecated
     @Override
     public Control cloneForSpatial(Spatial spatial) {
-        VehicleControl control = new VehicleControl(collisionShape, mass);
-        control.setAngularFactor(getAngularFactor());
-        control.setAngularSleepingThreshold(getAngularSleepingThreshold());
-        control.setAngularVelocity(getAngularVelocity());
-        control.setCcdMotionThreshold(getCcdMotionThreshold());
-        control.setCcdSweptSphereRadius(getCcdSweptSphereRadius());
-        control.setCollideWithGroups(getCollideWithGroups());
-        control.setCollisionGroup(getCollisionGroup());
-        control.setDamping(getLinearDamping(), getAngularDamping());
-        control.setFriction(getFriction());
-        control.setGravity(getGravity());
-        control.setKinematic(isKinematic());
-        control.setLinearSleepingThreshold(getLinearSleepingThreshold());
-        control.setLinearVelocity(getLinearVelocity());
-        control.setPhysicsLocation(getPhysicsLocation());
-        control.setPhysicsRotation(getPhysicsRotationMatrix());
-        control.setRestitution(getRestitution());
-
-        control.setFrictionSlip(getFrictionSlip());
-        control.setMaxSuspensionTravelCm(getMaxSuspensionTravelCm());
-        control.setSuspensionStiffness(getSuspensionStiffness());
-        control.setSuspensionCompression(tuning.suspensionCompression);
-        control.setSuspensionDamping(tuning.suspensionDamping);
-        control.setMaxSuspensionForce(getMaxSuspensionForce());
-
-        for (Iterator<VehicleWheel> it = wheels.iterator(); it.hasNext();) {
-            VehicleWheel wheel = it.next();
-            VehicleWheel newWheel = control.addWheel(wheel.getLocation(), wheel.getDirection(), wheel.getAxle(), wheel.getRestLength(), wheel.getRadius(), wheel.isFrontWheel());
-            newWheel.setFrictionSlip(wheel.getFrictionSlip());
-            newWheel.setMaxSuspensionTravelCm(wheel.getMaxSuspensionTravelCm());
-            newWheel.setSuspensionStiffness(wheel.getSuspensionStiffness());
-            newWheel.setWheelsDampingCompression(wheel.getWheelsDampingCompression());
-            newWheel.setWheelsDampingRelaxation(wheel.getWheelsDampingRelaxation());
-            newWheel.setMaxSuspensionForce(wheel.getMaxSuspensionForce());
-
-            //TODO: bad way finding children!
-            if (spatial instanceof Node) {
-                Node node = (Node) spatial;
-                Spatial wheelSpat = node.getChild(wheel.getWheelSpatial().getName());
-                if (wheelSpat != null) {
-                    newWheel.setWheelSpatial(wheelSpat);
-                }
-            }
-        }
-        control.setApplyPhysicsLocal(isApplyPhysicsLocal());
-        return control;
+        throw new UnsupportedOperationException();
     }
 
     @Override   

+ 2 - 31
jme3-core/src/main/java/com/jme3/animation/AnimControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,19 +34,16 @@ package com.jme3.animation;
 import com.jme3.export.*;
 import com.jme3.renderer.RenderManager;
 import com.jme3.renderer.ViewPort;
-import com.jme3.scene.Mesh;
 import com.jme3.scene.Spatial;
 import com.jme3.scene.control.AbstractControl;
-import com.jme3.scene.control.Control;
+import com.jme3.util.TempVars;
 import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.JmeCloneable;
-import com.jme3.util.TempVars;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Map.Entry;
 
 /**
  * <code>AnimControl</code> is a Spatial control that allows manipulation
@@ -108,32 +105,6 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
     public AnimControl() {
     }
 
-    /**
-     * Internal use only.
-     */
-    @Override
-    public Control cloneForSpatial(Spatial spatial) {
-        try {
-            AnimControl clone = (AnimControl) super.clone();
-            clone.spatial = spatial;
-            clone.channels = new ArrayList<AnimChannel>();
-            clone.listeners = new ArrayList<AnimEventListener>();
-
-            if (skeleton != null) {
-                clone.skeleton = new Skeleton(skeleton);
-            }
-
-            // animationMap is cloned, but only ClonableTracks will be cloned as they need a reference to a cloned spatial
-            for (Entry<String, Animation> animEntry : animationMap.entrySet()) {
-                clone.animationMap.put(animEntry.getKey(), animEntry.getValue().cloneForSpatial(spatial));
-            }
-            
-            return clone;
-        } catch (CloneNotSupportedException ex) {
-            throw new AssertionError();
-        }
-    }
-
     @Override   
     public Object jmeClone() {
         AnimControl clone = (AnimControl) super.jmeClone();

+ 0 - 15
jme3-core/src/main/java/com/jme3/animation/EffectTrack.java

@@ -42,10 +42,8 @@ import com.jme3.scene.Node;
 import com.jme3.scene.Spatial;
 import com.jme3.scene.Spatial.CullHint;
 import com.jme3.scene.control.AbstractControl;
-import com.jme3.scene.control.Control;
 import com.jme3.util.TempVars;
 import com.jme3.util.clone.Cloner;
-import com.jme3.util.clone.JmeCloneable;
 import java.io.IOException;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -132,19 +130,6 @@ public class EffectTrack implements ClonableTrack {
         @Override
         protected void controlRender(RenderManager rm, ViewPort vp) {
         }
-
-        @Override
-        public Control cloneForSpatial(Spatial spatial) {
-
-            KillParticleControl c = new KillParticleControl();
-            //this control should be removed as it shouldn't have been persisted in the first place
-            //In the quest to find the less hackish solution to achieve this,
-            //making it remove itself from the spatial in the first update loop when loaded was the less bad.
-            c.remove = true;
-            c.setSpatial(spatial);
-            return c;
-
-        }
     };
 
     //Anim listener that stops the Emmitter when the animation is finished or changed.

+ 0 - 43
jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java

@@ -39,14 +39,12 @@ import com.jme3.renderer.*;
 import com.jme3.scene.*;
 import com.jme3.scene.VertexBuffer.Type;
 import com.jme3.scene.control.AbstractControl;
-import com.jme3.scene.control.Control;
 import com.jme3.scene.mesh.IndexBuffer;
 import com.jme3.shader.VarType;
 import com.jme3.util.SafeArrayList;
 import com.jme3.util.TempVars;
 import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.JmeCloneable;
-
 import java.io.IOException;
 import java.nio.Buffer;
 import java.nio.FloatBuffer;
@@ -349,47 +347,6 @@ public class SkeletonControl extends AbstractControl implements Cloneable, JmeCl
         }
     }
 
-    @Override
-    public Control cloneForSpatial(Spatial spatial) {
-        Node clonedNode = (Node) spatial;
-        SkeletonControl clone = new SkeletonControl();
-
-        AnimControl ctrl = spatial.getControl(AnimControl.class);
-        if (ctrl != null) {
-            // AnimControl is responsible for cloning the skeleton, not
-            // SkeletonControl.
-            clone.skeleton = ctrl.getSkeleton();
-        } else {
-            // If there's no AnimControl, create the clone ourselves.
-            clone.skeleton = new Skeleton(skeleton);
-        }
-        clone.hwSkinningDesired = this.hwSkinningDesired;
-        clone.hwSkinningEnabled = this.hwSkinningEnabled;
-        clone.hwSkinningSupported = this.hwSkinningSupported;
-        clone.hwSkinningTested = this.hwSkinningTested;
-        
-        clone.setSpatial(clonedNode);
-
-        // Fix attachments for the cloned node
-        for (int i = 0; i < clonedNode.getQuantity(); i++) {
-            // go through attachment nodes, apply them to correct bone
-            Spatial child = clonedNode.getChild(i);
-            if (child instanceof Node) {
-                Node clonedAttachNode = (Node) child;
-                Bone originalBone = (Bone) clonedAttachNode.getUserData("AttachedBone");
-
-                if (originalBone != null) {
-                    Bone clonedBone = clone.skeleton.getBone(originalBone.getName());
-
-                    clonedAttachNode.setUserData("AttachedBone", clonedBone);
-                    clonedBone.setAttachmentsNode(clonedAttachNode);
-                }
-            }
-        }
-
-        return clone;
-    }
-
     @Override   
     public Object jmeClone() {
         return super.jmeClone();

+ 4 - 3
jme3-core/src/main/java/com/jme3/app/StatsView.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -117,11 +117,12 @@ public class StatsView extends Node implements Control, JmeCloneable {
         //statistics.clearFrame();
     }
 
+    @Deprecated
     @Override
     public Control cloneForSpatial(Spatial spatial) {
-        return (Control) spatial;
+        throw new UnsupportedOperationException();
     }
-
+    
     @Override
     public StatsView jmeClone() {
         throw new UnsupportedOperationException("Not yet implemented.");

+ 3 - 16
jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2016 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -274,23 +274,10 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC
      * @param spatial
      * @return
      */
+    @Deprecated
     @Override
     public Control cloneForSpatial(Spatial spatial) {
-        MotionEvent control = new MotionEvent();
-        control.setPath(path);
-        control.playState = playState;
-        control.currentWayPoint = currentWayPoint;
-        control.currentValue = currentValue;
-        control.direction = direction.clone();
-        control.lookAt = lookAt;
-        control.upVector = upVector.clone();
-        control.rotation = rotation;
-        control.initialDuration = initialDuration;
-        control.speed = speed;
-        control.loopMode = loopMode;
-        control.directionType = directionType;
-
-        return control;
+        throw new UnsupportedOperationException();
     }
 
     @Override   

+ 2 - 2
jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java

@@ -121,10 +121,10 @@ public class ParticleEmitter extends Geometry {
             this.parentEmitter = parentEmitter;
         }
 
+        @Deprecated
         @Override
         public Control cloneForSpatial(Spatial spatial) {
-            return this; // WARNING: Sets wrong control on spatial. Will be
-            // fixed automatically by ParticleEmitter.clone() method.
+            throw new UnsupportedOperationException();
         }
 
         @Override

+ 4 - 6
jme3-core/src/main/java/com/jme3/input/ChaseCamera.java

@@ -34,7 +34,6 @@ package com.jme3.input;
 import com.jme3.export.InputCapsule;
 import com.jme3.export.JmeExporter;
 import com.jme3.export.JmeImporter;
-import com.jme3.export.OutputCapsule;
 import com.jme3.input.controls.*;
 import com.jme3.math.FastMath;
 import com.jme3.math.Vector3f;
@@ -582,18 +581,17 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control, Jme
 
     /**
      * clone this camera for a spatial
+     *
      * @param spatial
      * @return
      */
+    @Deprecated
     @Override
     public Control cloneForSpatial(Spatial spatial) {
-        ChaseCamera cc = new ChaseCamera(cam, spatial, inputManager);
-        cc.setMaxDistance(getMaxDistance());
-        cc.setMinDistance(getMinDistance());
-        return cc;
+        throw new UnsupportedOperationException();
     }
 
-    @Override   
+    @Override
     public Object jmeClone() {
         ChaseCamera cc = new ChaseCamera(cam, inputManager);
         cc.target = target;

+ 1 - 31
jme3-core/src/main/java/com/jme3/scene/Geometry.java

@@ -43,9 +43,9 @@ import com.jme3.material.Material;
 import com.jme3.math.Matrix4f;
 import com.jme3.renderer.Camera;
 import com.jme3.scene.VertexBuffer.Type;
+import com.jme3.util.TempVars;
 import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.IdentityCloneFunction;
-import com.jme3.util.TempVars;
 import java.io.IOException;
 import java.util.Queue;
 import java.util.logging.Level;
@@ -506,36 +506,6 @@ public class Geometry extends Spatial {
         return (Geometry)super.clone(cloneMaterial);
     }
 
-    /**
-     *  The old clone() method that did not use the new Cloner utility.
-     */
-    @Override
-    public Geometry oldClone(boolean cloneMaterial) {
-        Geometry geomClone = (Geometry) super.clone(cloneMaterial);
-
-        // This geometry is managed,
-        // but the cloned one is not attached to anything, hence not managed.
-        if (geomClone.isGrouped()) {
-            geomClone.groupNode = null;
-            geomClone.startIndex = -1;
-        }
-
-        geomClone.cachedWorldMat = cachedWorldMat.clone();
-        if (material != null) {
-            if (cloneMaterial) {
-                geomClone.material = material.clone();
-            } else {
-                geomClone.material = material;
-            }
-        }
-
-        if (mesh != null && mesh.getBuffer(Type.BindPosePosition) != null) {
-            geomClone.mesh = mesh.cloneForAnim();
-        }
-
-        return geomClone;
-    }
-
     /**
      * This version of clone is a shallow clone, in other words, the
      * same mesh is referenced as the original geometry.

+ 5 - 63
jme3-core/src/main/java/com/jme3/scene/Spatial.java

@@ -48,11 +48,11 @@ import com.jme3.renderer.queue.RenderQueue;
 import com.jme3.renderer.queue.RenderQueue.Bucket;
 import com.jme3.renderer.queue.RenderQueue.ShadowMode;
 import com.jme3.scene.control.Control;
+import com.jme3.util.SafeArrayList;
+import com.jme3.util.TempVars;
 import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.IdentityCloneFunction;
 import com.jme3.util.clone.JmeCloneable;
-import com.jme3.util.SafeArrayList;
-import com.jme3.util.TempVars;
 import java.io.IOException;
 import java.util.*;
 import java.util.logging.Logger;
@@ -1367,66 +1367,11 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
     }
 
     /**
-     *  The old clone() method that did not use the new Cloner utility.
+     * The old clone() method that did not use the new Cloner utility.
      */
+    @Deprecated
     public Spatial oldClone(boolean cloneMaterial) {
-        try {
-            Spatial clone = (Spatial) super.clone();
-            if (worldBound != null) {
-                clone.worldBound = worldBound.clone();
-            }
-            clone.worldLights = worldLights.clone();
-            clone.localLights = localLights.clone();
-
-            // Set the new owner of the light lists
-            clone.localLights.setOwner(clone);
-            clone.worldLights.setOwner(clone);
-
-            clone.worldOverrides = new SafeArrayList<>(MatParamOverride.class);
-            clone.localOverrides = new SafeArrayList<>(MatParamOverride.class);
-
-            for (MatParamOverride override : localOverrides) {
-                clone.localOverrides.add((MatParamOverride) override.clone());
-            }
-
-            // No need to force cloned to update.
-            // This node already has the refresh flags
-            // set below so it will have to update anyway.
-            clone.worldTransform = worldTransform.clone();
-            clone.localTransform = localTransform.clone();
-
-            if (clone instanceof Node) {
-                Node node = (Node) this;
-                Node nodeClone = (Node) clone;
-                nodeClone.children = new SafeArrayList<Spatial>(Spatial.class);
-                for (Spatial child : node.children) {
-                    Spatial childClone = child.clone(cloneMaterial);
-                    childClone.parent = nodeClone;
-                    nodeClone.children.add(childClone);
-                }
-            }
-
-            clone.parent = null;
-            clone.setBoundRefresh();
-            clone.setTransformRefresh();
-            clone.setLightListRefresh();
-            clone.setMatParamOverrideRefresh();
-
-            clone.controls = new SafeArrayList<Control>(Control.class);
-            for (int i = 0; i < controls.size(); i++) {
-                Control newControl = controls.get(i).cloneForSpatial(clone);
-                newControl.setSpatial(clone);
-                clone.controls.add(newControl);
-            }
-
-            if (userData != null) {
-                clone.userData = (HashMap<String, Savable>) userData.clone();
-            }
-
-            return clone;
-        } catch (CloneNotSupportedException ex) {
-            throw new AssertionError();
-        }
+        throw new UnsupportedOperationException();
     }
 
     /**
@@ -1436,9 +1381,6 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
      * Note that meshes of geometries are not cloned explicitly, they
      * are shared if static, or specially cloned if animated.
      *
-     * All controls will be cloned using the Control.cloneForSpatial method
-     * on the clone.
-     *
      * @see Mesh#cloneForAnim()
      */
     @Override

+ 3 - 20
jme3-core/src/main/java/com/jme3/scene/control/AbstractControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -84,27 +84,10 @@ public abstract class AbstractControl implements Control, JmeCloneable {
      */
     protected abstract void controlRender(RenderManager rm, ViewPort vp);
 
-    /**
-     *  Default implementation of cloneForSpatial() that
-     *  simply clones the control and sets the spatial.
-     *  <pre>
-     *  AbstractControl c = clone();
-     *  c.spatial = null;
-     *  c.setSpatial(spatial);
-     *  </pre>
-     *
-     *  Controls that wish to be persisted must be Cloneable.
-     */
+    @Deprecated
     @Override
     public Control cloneForSpatial(Spatial spatial) {
-        try {
-            AbstractControl c = (AbstractControl)clone();
-            c.spatial = null; // to keep setSpatial() from throwing an exception
-            c.setSpatial(spatial);
-            return c;
-        } catch(CloneNotSupportedException e) {
-            throw new RuntimeException( "Can't clone control for spatial", e );
-        } 
+        throw new UnsupportedOperationException();
     }
 
     @Override

+ 1 - 11
jme3-core/src/main/java/com/jme3/scene/control/LodControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,6 @@ import com.jme3.renderer.ViewPort;
 import com.jme3.scene.Geometry;
 import com.jme3.scene.Mesh;
 import com.jme3.scene.Spatial;
-import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.JmeCloneable;
 import java.io.IOException;
 
@@ -141,15 +140,6 @@ public class LodControl extends AbstractControl implements Cloneable, JmeCloneab
         }
     }
 
-    @Override
-    public Control cloneForSpatial(Spatial spatial) {
-        LodControl clone = (LodControl) super.cloneForSpatial(spatial);
-        clone.lastDistance = 0;
-        clone.lastLevel = 0;
-        clone.numTris = numTris != null ? numTris.clone() : null;
-        return clone;
-    }
-
     @Override
     public Object jmeClone() {
         LodControl clone = (LodControl)super.jmeClone();

+ 1 - 13
jme3-core/src/main/java/com/jme3/scene/control/UpdateControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,9 +34,6 @@ package com.jme3.scene.control;
 import com.jme3.app.AppTask;
 import com.jme3.renderer.RenderManager;
 import com.jme3.renderer.ViewPort;
-import com.jme3.scene.Spatial;
-import com.jme3.util.clone.Cloner;
-import com.jme3.util.clone.JmeCloneable;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.Future;
@@ -87,15 +84,6 @@ public class UpdateControl extends AbstractControl {
         
     }
 
-    @Override
-    public Control cloneForSpatial(Spatial newSpatial) {
-        UpdateControl control = new UpdateControl(); 
-        control.setSpatial(newSpatial);
-        control.setEnabled(isEnabled());
-        control.taskQueue.addAll(taskQueue);
-        return control;
-    }
-    
     @Override
     public Object jmeClone() {
         UpdateControl clone = (UpdateControl)super.jmeClone();

+ 3 - 5
jme3-core/src/main/java/com/jme3/scene/instancing/InstancedNode.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 jMonkeyEngine
+ * Copyright (c) 2014-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,6 @@ import com.jme3.scene.*;
 import com.jme3.scene.control.Control;
 import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.JmeCloneable;
-
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
@@ -132,11 +131,10 @@ public class InstancedNode extends GeometryGroupNode {
             this.node = node;
         }
 
+        @Deprecated
         @Override
         public Control cloneForSpatial(Spatial spatial) {
-            return this;
-            // WARNING: Sets wrong control on spatial. Will be
-            // fixed automatically by InstancedNode.clone() method.
+            throw new UnsupportedOperationException();
         }
 
         @Override

+ 3 - 2
jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -96,9 +96,10 @@ public class PhysicsHoverControl extends PhysicsVehicle implements PhysicsContro
         createWheels();
     }
 
+    @Deprecated
     @Override
     public Control cloneForSpatial(Spatial spatial) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        throw new UnsupportedOperationException();
     }
 
     @Override   

+ 1 - 11
jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/NormalRecalcControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -39,9 +39,7 @@ import com.jme3.renderer.RenderManager;
 import com.jme3.renderer.ViewPort;
 import com.jme3.scene.Spatial;
 import com.jme3.scene.control.AbstractControl;
-import com.jme3.scene.control.Control;
 import com.jme3.util.clone.Cloner;
-import com.jme3.util.clone.JmeCloneable;
 import java.io.IOException;
 
 
@@ -88,14 +86,6 @@ public class NormalRecalcControl extends AbstractControl {
         this.terrain = cloner.clone(terrain);
     }
 
-    @Override
-    public Control cloneForSpatial(Spatial spatial) {
-        NormalRecalcControl control = new NormalRecalcControl(terrain);
-        control.setSpatial(spatial);
-        control.setEnabled(true);
-        return control;
-    }
-
     @Override
     public void setSpatial(Spatial spatial) {
         super.setSpatial(spatial);

+ 2 - 14
jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainLodControl.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
  */
 package com.jme3.terrain.geomipmap;
 
-import static java.util.Collections.singletonList;
 import com.jme3.export.InputCapsule;
 import com.jme3.export.JmeExporter;
 import com.jme3.export.JmeImporter;
@@ -43,16 +42,15 @@ import com.jme3.renderer.ViewPort;
 import com.jme3.scene.Node;
 import com.jme3.scene.Spatial;
 import com.jme3.scene.control.AbstractControl;
-import com.jme3.scene.control.Control;
 import com.jme3.terrain.Terrain;
 import com.jme3.terrain.executor.TerrainExecutorService;
 import com.jme3.terrain.geomipmap.lodcalc.DistanceLodCalculator;
 import com.jme3.terrain.geomipmap.lodcalc.LodCalculator;
 import com.jme3.util.SafeArrayList;
 import com.jme3.util.clone.Cloner;
-
 import java.io.IOException;
 import java.util.ArrayList;
+import static java.util.Collections.singletonList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.Callable;
@@ -408,16 +406,6 @@ public class TerrainLodControl extends AbstractControl {
         this.previousCameraLocation = new Vector3f();
     }
 
-    @Override
-    public Control cloneForSpatial(final Spatial spatial) {
-        if (spatial instanceof Terrain) {
-            TerrainLodControl cloned = new TerrainLodControl((Terrain) spatial, new ArrayList<>(cameras));
-            cloned.setLodCalculator(lodCalculator.clone());
-            return cloned;
-        }
-        return null;
-    }
-
     public void setCamera(final Camera camera) {
         this.cameras.clear();
         this.cameras.add(camera);