From 8014f37879e1de82a443cd684fd9c1085a0adc55 Mon Sep 17 00:00:00 2001 From: Allofich Date: Wed, 6 Jul 2016 22:09:39 +0900 Subject: [PATCH] Avoid duplicate code --- apps/openmw/mwworld/worldimp.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 35749049d..c2d27e60e 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1722,25 +1722,21 @@ namespace MWWorld { maxDistance += mRendering->getCameraDistance(); MWWorld::Ptr facedObject; + MWRender::RenderingManager::RayResult rayToObject; if (MWBase::Environment::get().getWindowManager()->isGuiMode()) { float x, y; MWBase::Environment::get().getWindowManager()->getMousePosition(x, y); - MWRender::RenderingManager::RayResult rayToObject = mRendering->castCameraToViewportRay(x, y, maxDistance, ignorePlayer); - facedObject = rayToObject.mHitObject; - if (!facedObject.isEmpty()) - distance = rayToObject.mRatio * maxDistance; - return facedObject; + rayToObject = mRendering->castCameraToViewportRay(x, y, maxDistance, ignorePlayer); } else - { - MWRender::RenderingManager::RayResult rayToObject = mRendering->castCameraToViewportRay(0.5f, 0.5f, maxDistance, ignorePlayer); - facedObject = rayToObject.mHitObject; - if (!facedObject.isEmpty()) - distance = rayToObject.mRatio * maxDistance; - return facedObject; - } + rayToObject = mRendering->castCameraToViewportRay(0.5f, 0.5f, maxDistance, ignorePlayer); + + facedObject = rayToObject.mHitObject; + if (!facedObject.isEmpty()) + distance = rayToObject.mRatio * maxDistance; + return facedObject; } bool World::isCellExterior() const