mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 22:45:33 +00:00
Update doors objects in navigator
This commit is contained in:
parent
661da42bd2
commit
f8dbd5902f
2 changed files with 33 additions and 8 deletions
|
@ -1543,21 +1543,34 @@ namespace MWWorld
|
|||
}
|
||||
if(player != results.end())
|
||||
moveObjectImp(player->first, player->second.x(), player->second.y(), player->second.z(), false);
|
||||
}
|
||||
|
||||
void World::updateNavigator()
|
||||
{
|
||||
bool updated = false;
|
||||
|
||||
bool navigatorObjectsUpdated = false;
|
||||
mPhysics->forEachAnimatedObject([&] (const MWPhysics::Object* object)
|
||||
{
|
||||
const DetourNavigator::ObjectShapes shapes {
|
||||
*object->getShapeInstance()->getCollisionShape(),
|
||||
object->getShapeInstance()->getAvoidCollisionShape()
|
||||
};
|
||||
navigatorObjectsUpdated = mNavigator->updateObject(std::size_t(object), shapes,
|
||||
object->getCollisionObject()->getWorldTransform()) || navigatorObjectsUpdated;
|
||||
updated = updateNavigatorObject(object) || updated;
|
||||
});
|
||||
if (navigatorObjectsUpdated)
|
||||
|
||||
for (const auto& door : mDoorStates)
|
||||
if (const auto object = mPhysics->getObject(door.first))
|
||||
updated = updateNavigatorObject(object) || updated;
|
||||
|
||||
if (updated)
|
||||
mNavigator->update(getPlayerPtr().getRefData().getPosition().asVec3());
|
||||
}
|
||||
|
||||
bool World::updateNavigatorObject(const MWPhysics::Object* object)
|
||||
{
|
||||
const DetourNavigator::ObjectShapes shapes {
|
||||
*object->getShapeInstance()->getCollisionShape(),
|
||||
object->getShapeInstance()->getAvoidCollisionShape()
|
||||
};
|
||||
return mNavigator->updateObject(std::size_t(object), shapes, object->getCollisionObject()->getWorldTransform());
|
||||
}
|
||||
|
||||
bool World::castRay (float x1, float y1, float z1, float x2, float y2, float z2, bool ignoreDoors)
|
||||
{
|
||||
osg::Vec3f a(x1,y1,z1);
|
||||
|
@ -1747,7 +1760,10 @@ namespace MWWorld
|
|||
updateWeather(duration, paused);
|
||||
|
||||
if (!paused)
|
||||
{
|
||||
doPhysics (duration);
|
||||
updateNavigator();
|
||||
}
|
||||
|
||||
updatePlayer();
|
||||
|
||||
|
|
|
@ -61,6 +61,11 @@ namespace ToUTF8
|
|||
|
||||
struct ContentLoader;
|
||||
|
||||
namespace MWPhysics
|
||||
{
|
||||
class Object;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class WeatherManager;
|
||||
|
@ -148,6 +153,10 @@ namespace MWWorld
|
|||
void doPhysics(float duration);
|
||||
///< Run physics simulation and modify \a world accordingly.
|
||||
|
||||
void updateNavigator();
|
||||
|
||||
bool updateNavigatorObject(const MWPhysics::Object* object);
|
||||
|
||||
void ensureNeededRecords();
|
||||
|
||||
void fillGlobalVariables();
|
||||
|
|
Loading…
Reference in a new issue