Factored faced object lookups into MWRender::World

* Renamed MWWorld::World::getFacedHandle to getFacedObject.
 * Changed it to return an object pointer
 * Updated clients to use return object directly.
actorid
Nathan Jeffords 12 years ago
parent 05dad29005
commit b9fbd6ae4b

@ -427,12 +427,7 @@ void OMW::Engine::activate()
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
return;
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
if (handle.empty())
return;
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaHandle (handle);
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getFacedObject();
if (ptr.isEmpty())
return;

@ -199,8 +199,8 @@ namespace MWBase
virtual void markCellAsUnchanged() = 0;
virtual std::string getFacedHandle() = 0;
///< Return handle of the object the player is looking at
virtual MWWorld::Ptr getFacedObject() = 0;
///< Return pointer to the object the player is looking at, if it is within activation range
virtual void deleteObject (const MWWorld::Ptr& ptr) = 0;

@ -244,8 +244,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
if ( (mode != GM_Console) && (mode != GM_Container) && (mode != GM_Inventory) )
return;
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
MWWorld::Ptr object = MWBase::Environment::get().getWorld()->searchPtrViaHandle(handle);
MWWorld::Ptr object = MWBase::Environment::get().getWorld()->getFacedObject();
if (mode == GM_Console)
MWBase::Environment::get().getWindowManager()->getConsole()->setSelectedObject(object);

@ -80,9 +80,8 @@ void ToolTips::onFrame(float frameDuration)
|| (mWindowManager->getMode() == GM_Container)
|| (mWindowManager->getMode() == GM_Inventory)))
{
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
mFocusObject = MWBase::Environment::get().getWorld()->getFacedObject();
mFocusObject = MWBase::Environment::get().getWorld()->searchPtrViaHandle(handle);
if (mFocusObject.isEmpty ())
return;

@ -573,26 +573,24 @@ namespace MWWorld
return mWorldScene->markCellAsUnchanged();
}
std::string World::getFacedHandle()
MWWorld::Ptr World::getFacedObject()
{
std::pair<float, std::string> result;
if (!mRendering->occlusionQuerySupported())
{
std::pair<float, std::string> result = mPhysics->getFacedHandle (*this, 500);
result = mPhysics->getFacedHandle (*this, 500);
else
result = std::make_pair (mFacedDistance, mFacedHandle);
if (result.second.empty() ||
result.first>getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt())
return "";
if (result.second.empty())
return MWWorld::Ptr ();
return result.second;
}
else
{
if (mFacedDistance > result.first>getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt())
return "";
float ActivationDistance = getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt();
// updated every few frames in update()
return mFacedHandle;
}
if (result.first > ActivationDistance)
return MWWorld::Ptr ();
return searchPtrViaHandle (result.second);
}
void World::deleteObject (const Ptr& ptr)
@ -904,7 +902,7 @@ namespace MWWorld
void World::updateWindowManager ()
{
// inform the GUI about focused object
MWWorld::Ptr object = searchPtrViaHandle(mFacedHandle);
MWWorld::Ptr object = getFacedObject ();
MWBase::Environment::get().getWindowManager()->setFocusObject(object);

@ -227,8 +227,8 @@ namespace MWWorld
virtual void markCellAsUnchanged();
virtual std::string getFacedHandle();
///< Return handle of the object the player is looking at
virtual MWWorld::Ptr getFacedObject();
///< Return pointer to the object the player is looking at, if it is within activation range
virtual void deleteObject (const Ptr& ptr);

Loading…
Cancel
Save