Skip to content

FlyCam shouldn't zoom out past 180-degree field-of-view #2939

Description

@stephengold

For perspective cameras, there is a check in FlyByCamera.zoomCamera() to prevent the field-of-view angle from going negative or "too close" to zero, which is considered an invalid state:

} else { // perspective projection
float newFov = cam.getFov() + value * 0.1F * zoomSpeed;
// Use a small epsilon to prevent near-zero FoV issues
if (newFov > 0.01f) {
cam.setFov(newFov);
}
}

However, there's nothing to prevent the angle from exceeding 180 degrees. This puts the camera in an invalid state where, for instance, getFrustumTop() < cam.getFrustumBottom().

For reasonable values of zoomSpeed (such as 20) it's easy to zoom out a perspective camera until the field-of-view exceeds 180 degrees.

To prevent this, the check in zoomCamera() should be changed to something like:

if (newFov > 0.01f && newFov < 179f) {

Testing suggests this is not a new issue. It was present in JME v3.2.4-stable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions