mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-20 15:40:32 +00:00
Update scaled objects in navigator
This commit is contained in:
parent
2e063d59ce
commit
27d7452267
@ -1337,6 +1337,8 @@ namespace MWWorld
|
||||
|
||||
if (mPhysics->getActor(ptr))
|
||||
mNavigator->addAgent(getPathfindingHalfExtents(ptr));
|
||||
else if (const auto object = mPhysics->getObject(ptr))
|
||||
mShouldUpdateNavigator = updateNavigatorObject(object) || mShouldUpdateNavigator;
|
||||
}
|
||||
|
||||
void World::rotateObjectImp (const Ptr& ptr, const osg::Vec3f& rot, bool adjust)
|
||||
@ -1570,19 +1572,20 @@ namespace MWWorld
|
||||
|
||||
void World::updateNavigator()
|
||||
{
|
||||
bool updated = false;
|
||||
|
||||
mPhysics->forEachAnimatedObject([&] (const MWPhysics::Object* object)
|
||||
{
|
||||
updated = updateNavigatorObject(object) || updated;
|
||||
mShouldUpdateNavigator = updateNavigatorObject(object) || mShouldUpdateNavigator;
|
||||
});
|
||||
|
||||
for (const auto& door : mDoorStates)
|
||||
if (const auto object = mPhysics->getObject(door.first))
|
||||
updated = updateNavigatorObject(object) || updated;
|
||||
mShouldUpdateNavigator = updateNavigatorObject(object) || mShouldUpdateNavigator;
|
||||
|
||||
if (updated)
|
||||
if (mShouldUpdateNavigator)
|
||||
{
|
||||
mNavigator->update(getPlayerPtr().getRefData().getPosition().asVec3());
|
||||
mShouldUpdateNavigator = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool World::updateNavigatorObject(const MWPhysics::Object* object)
|
||||
|
@ -112,6 +112,7 @@ namespace MWWorld
|
||||
std::string mUserDataPath;
|
||||
|
||||
osg::Vec3f mDefaultHalfExtents;
|
||||
bool mShouldUpdateNavigator = false;
|
||||
|
||||
// not implemented
|
||||
World (const World&);
|
||||
|
@ -69,4 +69,11 @@ namespace
|
||||
object.update(mTransform, AreaType_ground);
|
||||
EXPECT_FALSE(object.update(mTransform, AreaType_ground));
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorRecastMeshObjectTest, update_for_changed_local_scaling_should_return_true)
|
||||
{
|
||||
RecastMeshObject object(mBoxShape, mTransform, AreaType_ground);
|
||||
mBoxShape.setLocalScaling(btVector3(2, 2, 2));
|
||||
EXPECT_TRUE(object.update(mTransform, AreaType_ground));
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace DetourNavigator
|
||||
: mShape(shape)
|
||||
, mTransform(transform)
|
||||
, mAreaType(areaType)
|
||||
, mLocalScaling(shape.getLocalScaling())
|
||||
, mChildren(makeChildrenObjects(shape, mAreaType))
|
||||
{
|
||||
}
|
||||
@ -30,6 +31,11 @@ namespace DetourNavigator
|
||||
mAreaType = areaType;
|
||||
result = true;
|
||||
}
|
||||
if (!(mLocalScaling == mShape.get().getLocalScaling()))
|
||||
{
|
||||
mLocalScaling = mShape.get().getLocalScaling();
|
||||
result = true;
|
||||
}
|
||||
if (mShape.get().isCompound())
|
||||
result = updateCompoundObject(static_cast<const btCompoundShape&>(mShape.get()), mAreaType, mChildren)
|
||||
|| result;
|
||||
|
@ -39,6 +39,7 @@ namespace DetourNavigator
|
||||
std::reference_wrapper<const btCollisionShape> mShape;
|
||||
btTransform mTransform;
|
||||
AreaType mAreaType;
|
||||
btVector3 mLocalScaling;
|
||||
std::vector<RecastMeshObject> mChildren;
|
||||
|
||||
static bool updateCompoundObject(const btCompoundShape& shape, const AreaType areaType,
|
||||
|
Loading…
x
Reference in New Issue
Block a user