From 7d9dddfa38112bfb6c4ec35bec45e1a70af209a2 Mon Sep 17 00:00:00 2001 From: Aesylwinn Date: Thu, 31 Mar 2016 23:34:47 -0400 Subject: [PATCH] Place camera farther away, improves preview camera placement. --- apps/opencs/view/render/cameracontroller.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/render/cameracontroller.cpp b/apps/opencs/view/render/cameracontroller.cpp index bfff161544..d3e1fa53b6 100644 --- a/apps/opencs/view/render/cameracontroller.cpp +++ b/apps/opencs/view/render/cameracontroller.cpp @@ -94,7 +94,13 @@ namespace CSVRender void CameraController::setSceneBounds(const osg::BoundingBox& bounds, const osg::Vec3d& up) { - osg::Vec3d eye = osg::Vec3d(bounds.xMax(), bounds.yMax(), bounds.zMax()); + osg::Vec3d minBounds = bounds.corner(0) - bounds.center(); + osg::Vec3d maxBounds = bounds.corner(7) - bounds.center(); + + osg::Vec3d camOffset = up * maxBounds > 0 ? maxBounds : minBounds; + camOffset *= 2; + + osg::Vec3d eye = camOffset + bounds.center(); osg::Vec3d center = bounds.center(); getCamera()->setViewMatrixAsLookAt(eye, center, up);