mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
added a separate activation distance for NPCs
This commit is contained in:
parent
b9fbd6ae4b
commit
b3932e3dea
@ -573,24 +573,46 @@ namespace MWWorld
|
||||
return mWorldScene->markCellAsUnchanged();
|
||||
}
|
||||
|
||||
float World::getMaxActivationDistance ()
|
||||
{
|
||||
return (std::max) (getNpcActivationDistance (), getObjectActivationDistance ());
|
||||
}
|
||||
|
||||
float World::getNpcActivationDistance ()
|
||||
{
|
||||
return getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt()*5/4;
|
||||
}
|
||||
|
||||
float World::getObjectActivationDistance ()
|
||||
{
|
||||
return getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt();
|
||||
}
|
||||
|
||||
MWWorld::Ptr World::getFacedObject()
|
||||
{
|
||||
std::pair<float, std::string> result;
|
||||
|
||||
if (!mRendering->occlusionQuerySupported())
|
||||
result = mPhysics->getFacedHandle (*this, 500);
|
||||
result = mPhysics->getFacedHandle (*this, getMaxActivationDistance ());
|
||||
else
|
||||
result = std::make_pair (mFacedDistance, mFacedHandle);
|
||||
|
||||
if (result.second.empty())
|
||||
return MWWorld::Ptr ();
|
||||
|
||||
float ActivationDistance = getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt();
|
||||
MWWorld::Ptr object = searchPtrViaHandle (result.second);
|
||||
|
||||
float ActivationDistance;
|
||||
|
||||
if (object.getTypeName ().find("NPC") != std::string::npos)
|
||||
ActivationDistance = getNpcActivationDistance ();
|
||||
else
|
||||
ActivationDistance = getObjectActivationDistance ();
|
||||
|
||||
if (result.first > ActivationDistance)
|
||||
return MWWorld::Ptr ();
|
||||
|
||||
return searchPtrViaHandle (result.second);
|
||||
return object;
|
||||
}
|
||||
|
||||
void World::deleteObject (const Ptr& ptr)
|
||||
@ -983,11 +1005,11 @@ namespace MWWorld
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
results = mPhysics->getFacedHandles(x, y, 500);
|
||||
results = mPhysics->getFacedHandles(x, y, getMaxActivationDistance ());
|
||||
}
|
||||
else
|
||||
{
|
||||
results = mPhysics->getFacedHandles(500);
|
||||
results = mPhysics->getFacedHandles(getMaxActivationDistance ());
|
||||
}
|
||||
|
||||
// ignore the player and other things we're not interested in
|
||||
|
@ -100,6 +100,10 @@ namespace MWWorld
|
||||
void beginSingleFacedQueryProcess (MWRender::OcclusionQuery* query, std::vector < std::pair < float, std::string > > const & results);
|
||||
void beginDoubleFacedQueryProcess (MWRender::OcclusionQuery* query, std::vector < std::pair < float, std::string > > const & results);
|
||||
|
||||
float getMaxActivationDistance ();
|
||||
float getNpcActivationDistance ();
|
||||
float getObjectActivationDistance ();
|
||||
|
||||
public:
|
||||
|
||||
World (OEngine::Render::OgreRenderer& renderer,
|
||||
|
Loading…
x
Reference in New Issue
Block a user