Change variable to mRatio and initialize it

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

@ -668,6 +668,7 @@ namespace MWRender
{ {
RenderingManager::RayResult result; RenderingManager::RayResult result;
result.mHit = false; result.mHit = false;
result.mRatio = 0;
if (intersector->containsIntersections()) if (intersector->containsIntersections())
{ {
result.mHit = true; result.mHit = true;
@ -675,6 +676,7 @@ namespace MWRender
result.mHitPointWorld = intersection.getWorldIntersectPoint(); result.mHitPointWorld = intersection.getWorldIntersectPoint();
result.mHitNormalWorld = intersection.getWorldIntersectNormal(); result.mHitNormalWorld = intersection.getWorldIntersectNormal();
result.mRatio = intersection.ratio;
PtrHolder* ptrHolder = NULL; PtrHolder* ptrHolder = NULL;
for (osg::NodePath::const_iterator it = intersection.nodePath.begin(); it != intersection.nodePath.end(); ++it) for (osg::NodePath::const_iterator it = intersection.nodePath.begin(); it != intersection.nodePath.end(); ++it)
@ -738,9 +740,7 @@ namespace MWRender
mViewer->getCamera()->accept(*createIntersectionVisitor(intersector, ignorePlayer, ignoreActors)); mViewer->getCamera()->accept(*createIntersectionVisitor(intersector, ignorePlayer, ignoreActors));
RayResult result = getIntersectionResult(intersector); return getIntersectionResult(intersector);
result.mDistanceToFirstIntersection = maxDistance * intersector->getFirstIntersection().ratio;
return result;
} }
void RenderingManager::updatePtr(const MWWorld::Ptr &old, const MWWorld::Ptr &updated) void RenderingManager::updatePtr(const MWWorld::Ptr &old, const MWWorld::Ptr &updated)

@ -120,7 +120,7 @@ namespace MWRender
osg::Vec3f mHitNormalWorld; osg::Vec3f mHitNormalWorld;
osg::Vec3f mHitPointWorld; osg::Vec3f mHitPointWorld;
MWWorld::Ptr mHitObject; MWWorld::Ptr mHitObject;
float mDistanceToFirstIntersection; float mRatio;
}; };
RayResult castRay(const osg::Vec3f& origin, const osg::Vec3f& dest, bool ignorePlayer, bool ignoreActors=false); RayResult castRay(const osg::Vec3f& origin, const osg::Vec3f& dest, bool ignorePlayer, bool ignoreActors=false);

@ -1730,7 +1730,7 @@ namespace MWWorld
MWRender::RenderingManager::RayResult rayToObject = mRendering->castCameraToViewportRay(x, y, maxDistance, ignorePlayer); MWRender::RenderingManager::RayResult rayToObject = mRendering->castCameraToViewportRay(x, y, maxDistance, ignorePlayer);
facedObject = rayToObject.mHitObject; facedObject = rayToObject.mHitObject;
if (!facedObject.isEmpty()) if (!facedObject.isEmpty())
distance = rayToObject.mDistanceToFirstIntersection; distance = rayToObject.mRatio * maxDistance;
return facedObject; return facedObject;
} }
else else
@ -1738,7 +1738,7 @@ namespace MWWorld
MWRender::RenderingManager::RayResult 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.mDistanceToFirstIntersection; distance = rayToObject.mRatio * maxDistance;
return facedObject; return facedObject;
} }
} }

Loading…
Cancel
Save