]> git.mxchange.org Git - flightgear.git/commitdiff
Protect against divide-by-zero in setCameraParameters
authortimoore <timoore>
Sat, 3 Jan 2009 00:15:58 +0000 (00:15 +0000)
committerTim Moore <timoore@redhat.com>
Sat, 3 Jan 2009 23:24:49 +0000 (00:24 +0100)
Found by Csaba Halász

src/Main/CameraGroup.cxx

index 2ff1bb16921b4ecdf66a8f575f94cb35ef812f8a..c8e23c2293b721ada0adf5e33bbcb83ed3908f34 100644 (file)
@@ -219,9 +219,11 @@ void CameraGroup::update(const osg::Vec3d& position,
 
 void CameraGroup::setCameraParameters(float vfov, float aspectRatio)
 {
-    _viewer->getCamera()->setProjectionMatrixAsPerspective(vfov,
-                                                           1.0f / aspectRatio,
-                                                           _zNear, _zFar);
+    if (vfov != 0.0f && aspectRatio != 0.0f)
+        _viewer->getCamera()
+            ->setProjectionMatrixAsPerspective(vfov,
+                                               1.0f / aspectRatio,
+                                               _zNear, _zFar);
 }
 }