mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 21:40:03 +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();
|
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()
|
MWWorld::Ptr World::getFacedObject()
|
||||||
{
|
{
|
||||||
std::pair<float, std::string> result;
|
std::pair<float, std::string> result;
|
||||||
|
|
||||||
if (!mRendering->occlusionQuerySupported())
|
if (!mRendering->occlusionQuerySupported())
|
||||||
result = mPhysics->getFacedHandle (*this, 500);
|
result = mPhysics->getFacedHandle (*this, getMaxActivationDistance ());
|
||||||
else
|
else
|
||||||
result = std::make_pair (mFacedDistance, mFacedHandle);
|
result = std::make_pair (mFacedDistance, mFacedHandle);
|
||||||
|
|
||||||
if (result.second.empty())
|
if (result.second.empty())
|
||||||
return MWWorld::Ptr ();
|
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)
|
if (result.first > ActivationDistance)
|
||||||
return MWWorld::Ptr ();
|
return MWWorld::Ptr ();
|
||||||
|
|
||||||
return searchPtrViaHandle (result.second);
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::deleteObject (const Ptr& ptr)
|
void World::deleteObject (const Ptr& ptr)
|
||||||
@ -983,11 +1005,11 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
float x, y;
|
float x, y;
|
||||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||||
results = mPhysics->getFacedHandles(x, y, 500);
|
results = mPhysics->getFacedHandles(x, y, getMaxActivationDistance ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
results = mPhysics->getFacedHandles(500);
|
results = mPhysics->getFacedHandles(getMaxActivationDistance ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore the player and other things we're not interested in
|
// 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 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);
|
void beginDoubleFacedQueryProcess (MWRender::OcclusionQuery* query, std::vector < std::pair < float, std::string > > const & results);
|
||||||
|
|
||||||
|
float getMaxActivationDistance ();
|
||||||
|
float getNpcActivationDistance ();
|
||||||
|
float getObjectActivationDistance ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
World (OEngine::Render::OgreRenderer& renderer,
|
World (OEngine::Render::OgreRenderer& renderer,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user