Update scaled objects in navigator

pull/541/head
elsid 6 years ago
parent 1f41d5721d
commit 133d7447f3
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -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…
Cancel
Save