0030440: Visualization - Graphic3d_Camera::Frustum() returns wrong planes in portrait...
authorkgv <kgv@opencascade.com>
Thu, 23 May 2019 09:02:29 +0000 (12:02 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 23 May 2019 12:46:47 +0000 (15:46 +0300)
Graphic3d_Camera::Frustum() now handles window Aspect Ratio < 1.0.

src/Graphic3d/Graphic3d_Camera.cxx

index 9525141..9c45596 100644 (file)
@@ -696,8 +696,17 @@ void Graphic3d_Camera::Frustum (gp_Pln& theLeft,
   theNear = gp_Pln (Eye().Translated (aProjection * ZNear()), aProjection);
   theFar  = gp_Pln (Eye().Translated (aProjection * ZFar()), -aProjection);
 
-  Standard_Real aHScaleHor = Scale() * 0.5 * Aspect();
-  Standard_Real aHScaleVer = Scale() * 0.5;
+  Standard_Real aHScaleHor = 0.0, aHScaleVer = 0.0;
+  if (Aspect() >= 1.0)
+  {
+    aHScaleHor = Scale() * 0.5 * Aspect();
+    aHScaleVer = Scale() * 0.5;
+  }
+  else
+  {
+    aHScaleHor = Scale() * 0.5;
+    aHScaleVer = Scale() * 0.5 / Aspect();
+  }
 
   gp_Pnt aPntLeft   = Center().Translated (aHScaleHor * -aSide);
   gp_Pnt aPntRight  = Center().Translated (aHScaleHor *  aSide);