Proposed change to ChaseCamera

One issue with ChaseCamera is that it claims to implement Savable, yet its read() method hasn’t worked for some time, if ever.

Short of a complete rewrite, I think the best solution for now is to raise exceptions in read() and write(). Here is my proposed patch to /trunk/engine/src/core/com/jme3/input/ChaseCamera.java and /branches/gradle-restructure/jme3-core/src/main/java/com/jme3/input/ChaseCamera.java :

--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -31,10 +31,8 @@
  */
 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;
@@ -581,9 +579,8 @@
      * @throws IOException
      */
     public void write(JmeExporter ex) throws IOException {
-        OutputCapsule capsule = ex.getCapsule(this);
-        capsule.write(maxDistance, "maxDistance", 40);
-        capsule.write(minDistance, "minDistance", 1);
+        throw new UnsupportedOperationException(
+                "remove ChaseCamera before saving");
     }
 
     /**
@@ -592,9 +589,7 @@
      * @throws IOException
      */
     public void read(JmeImporter im) throws IOException {
-        InputCapsule ic = im.getCapsule(this);
-        maxDistance = ic.readFloat("maxDistance", 40);
-        minDistance = ic.readFloat("minDistance", 1);
+        throw new UnsupportedOperationException("can't read ChaseCamera");
     }
 
     /**
1 Like

Shall I commit this?

mhh…I don’t really like this…
Maybe I should make this work, I mean the savable part…
I’m gonna take care of this.

1 Like

Thanks, @nehon !

@nehon said: mhh....I don't really like this... Maybe I should make this work, I mean the savable part... I'm gonna take care of this.

I think perhaps you are too optimistic. :slight_smile:

Yeah. I can’t figure out how to get the cam and the inputManager out of nowhere when reading the control.
Make the change Stephen.
I’m gonna go the appstate route and make something better. Then I’ll deprecate the chaseCam

@nehon Make the change Stephen.
Actually don't, I'm making some changes so I'll do it while I'm at it.
1 Like
@nehon said: Actually don't, I'm making some changes so I'll do it while I'm at it.

OK!