Avoid duplicate code

pull/1/head
Allofich 9 years ago
parent 538209b0a2
commit 8014f37879

@ -1722,25 +1722,21 @@ namespace MWWorld
{ {
maxDistance += mRendering->getCameraDistance(); maxDistance += mRendering->getCameraDistance();
MWWorld::Ptr facedObject; MWWorld::Ptr facedObject;
MWRender::RenderingManager::RayResult rayToObject;
if (MWBase::Environment::get().getWindowManager()->isGuiMode()) if (MWBase::Environment::get().getWindowManager()->isGuiMode())
{ {
float x, y; float x, y;
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y); MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
MWRender::RenderingManager::RayResult rayToObject = mRendering->castCameraToViewportRay(x, y, maxDistance, ignorePlayer); rayToObject = mRendering->castCameraToViewportRay(x, y, maxDistance, ignorePlayer);
facedObject = rayToObject.mHitObject;
if (!facedObject.isEmpty())
distance = rayToObject.mRatio * maxDistance;
return facedObject;
} }
else else
{ rayToObject = mRendering->castCameraToViewportRay(0.5f, 0.5f, maxDistance, ignorePlayer);
MWRender::RenderingManager::RayResult rayToObject = mRendering->castCameraToViewportRay(0.5f, 0.5f, maxDistance, ignorePlayer);
facedObject = rayToObject.mHitObject; facedObject = rayToObject.mHitObject;
if (!facedObject.isEmpty()) if (!facedObject.isEmpty())
distance = rayToObject.mRatio * maxDistance; distance = rayToObject.mRatio * maxDistance;
return facedObject; return facedObject;
}
} }
bool World::isCellExterior() const bool World::isCellExterior() const

Loading…
Cancel
Save