Proposed fix for issue #622

I opened this issue back in January.

I’ve written and tested the following patch. May I commit it to /branches/gradle-restructure/jme3-core/src/main/java/com/jme3/input/FlyByCamera.java and /trunk/engine/src/core/com/jme3/input/FlyByCamera.java
?

--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -341,7 +341,11 @@
 
         float fovY = FastMath.atan(h / near)
                   / (FastMath.DEG_TO_RAD * .5f);
-        fovY += value * 0.1f * zoomSpeed;
+        float newFovY = fovY + value * 0.1f * zoomSpeed;
+        if (newFovY > 0f) {
+            // Don't let the FOV go zero or negative.
+            fovY = newFovY;
+        }
 
         h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near;
         w = h * aspect;
2 Likes

You can… I’d suggest making it optional but I already want to cut FlyByCam out of the engine with a rusty spoon. So I’m not sure I care which way we beat this particular dead horse. :wink:

Though adding features to this class is a slippery slope. To make it useful for any game at all it needs about a half dozen more features… so any real game will end up writing their own. I’d rename it to DemoCam but it would break everything.

Edit: nevermind about the optional part. I thought this was the pitch lock thing. Yes, the fix is good. I should sleep soon, I think.

1 Like

@pspeed Yeah, I would think twice before adding features to FlyByCamera. But this fix seems worthwhile to me.

@sgold said: @pspeed Yeah, I would think twice before adding features to FlyByCamera. But this fix seems worthwhile to me.

Agreed… sorry I misread it at first.

I’ve committed the fix with revs 11081/11082 and closed the issue. Not necessarily in that order :slight_smile: