1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 15:09:39 +00:00

Remove redundant BulletShape getters

This commit is contained in:
elsid 2021-10-30 03:30:38 +02:00
parent fc9a405dc5
commit 8e71c246bf
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
8 changed files with 11 additions and 25 deletions

View file

@ -24,7 +24,7 @@ namespace MWPhysics
, mTaskScheduler(scheduler) , mTaskScheduler(scheduler)
{ {
mPtr = ptr; mPtr = ptr;
mCollisionObject = BulletHelpers::makeCollisionObject(mShapeInstance->getCollisionShape(), mCollisionObject = BulletHelpers::makeCollisionObject(mShapeInstance->mCollisionShape.get(),
Misc::Convert::toBullet(mPosition), Misc::Convert::toBullet(rotation)); Misc::Convert::toBullet(mPosition), Misc::Convert::toBullet(rotation));
mCollisionObject->setUserPointer(this); mCollisionObject->setUserPointer(this);
mShapeInstance->setLocalScaling(mScale); mShapeInstance->setLocalScaling(mScale);
@ -109,9 +109,9 @@ namespace MWPhysics
if (mShapeInstance->mAnimatedShapes.empty()) if (mShapeInstance->mAnimatedShapes.empty())
return false; return false;
assert (mShapeInstance->getCollisionShape()->isCompound()); assert (mShapeInstance->mCollisionShape->isCompound());
btCompoundShape* compound = static_cast<btCompoundShape*>(mShapeInstance->getCollisionShape()); btCompoundShape* compound = static_cast<btCompoundShape*>(mShapeInstance->mCollisionShape.get());
for (const auto& [recIndex, shapeIndex] : mShapeInstance->mAnimatedShapes) for (const auto& [recIndex, shapeIndex] : mShapeInstance->mAnimatedShapes)
{ {
auto nodePathFound = mRecIndexToNodePath.find(recIndex); auto nodePathFound = mRecIndexToNodePath.find(recIndex);

View file

@ -481,7 +481,7 @@ namespace MWPhysics
if (ptr.mRef->mData.mPhysicsPostponed) if (ptr.mRef->mData.mPhysicsPostponed)
return; return;
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(mesh); osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(mesh);
if (!shapeInstance || !shapeInstance->getCollisionShape()) if (!shapeInstance || !shapeInstance->mCollisionShape)
return; return;
assert(!getObject(ptr)); assert(!getObject(ptr));

View file

@ -132,7 +132,7 @@ namespace
{ {
btVector3 aabbMin; btVector3 aabbMin;
btVector3 aabbMax; btVector3 aabbMax;
object->getShapeInstance()->getCollisionShape()->getAabb(btTransform::getIdentity(), aabbMin, aabbMax); object->getShapeInstance()->mCollisionShape->getAabb(btTransform::getIdentity(), aabbMin, aabbMax);
const auto center = (aabbMax + aabbMin) * 0.5f; const auto center = (aabbMax + aabbMin) * 0.5f;

View file

@ -3948,7 +3948,7 @@ namespace MWWorld
btVector3 aabbMin; btVector3 aabbMin;
btVector3 aabbMax; btVector3 aabbMax;
object->getShapeInstance()->getCollisionShape()->getAabb(btTransform::getIdentity(), aabbMin, aabbMax); object->getShapeInstance()->mCollisionShape->getAabb(btTransform::getIdentity(), aabbMin, aabbMax);
const auto toLocal = object->getTransform().inverse(); const auto toLocal = object->getTransform().inverse();
const auto localFrom = toLocal(Misc::Convert::toBullet(position)); const auto localFrom = toLocal(Misc::Convert::toBullet(position));

View file

@ -482,7 +482,7 @@ namespace
osg::ref_ptr<const Resource::BulletShapeInstance> instance(new Resource::BulletShapeInstance(bulletShape)); osg::ref_ptr<const Resource::BulletShapeInstance> instance(new Resource::BulletShapeInstance(bulletShape));
mNavigator->addAgent(mAgentHalfExtents); mNavigator->addAgent(mAgentHalfExtents);
mNavigator->addObject(ObjectId(instance->getCollisionShape()), ObjectShapes(instance), btTransform::getIdentity()); mNavigator->addObject(ObjectId(instance->mCollisionShape.get()), ObjectShapes(instance), btTransform::getIdentity());
mNavigator->update(mPlayerPosition); mNavigator->update(mPlayerPosition);
mNavigator->wait(mListener, WaitConditionType::allJobsDone); mNavigator->wait(mListener, WaitConditionType::allJobsDone);

View file

@ -34,9 +34,9 @@ namespace DetourNavigator
bool NavigatorImpl::addObject(const ObjectId id, const ObjectShapes& shapes, const btTransform& transform) bool NavigatorImpl::addObject(const ObjectId id, const ObjectShapes& shapes, const btTransform& transform)
{ {
CollisionShape collisionShape {shapes.mShapeInstance, *shapes.mShapeInstance->getCollisionShape()}; CollisionShape collisionShape {shapes.mShapeInstance, *shapes.mShapeInstance->mCollisionShape};
bool result = mNavMeshManager.addObject(id, collisionShape, transform, AreaType_ground); bool result = mNavMeshManager.addObject(id, collisionShape, transform, AreaType_ground);
if (const btCollisionShape* const avoidShape = shapes.mShapeInstance->getAvoidCollisionShape()) if (const btCollisionShape* const avoidShape = shapes.mShapeInstance->mAvoidCollisionShape.get())
{ {
const ObjectId avoidId(avoidShape); const ObjectId avoidId(avoidShape);
CollisionShape avoidCollisionShape {shapes.mShapeInstance, *avoidShape}; CollisionShape avoidCollisionShape {shapes.mShapeInstance, *avoidShape};
@ -64,9 +64,9 @@ namespace DetourNavigator
bool NavigatorImpl::updateObject(const ObjectId id, const ObjectShapes& shapes, const btTransform& transform) bool NavigatorImpl::updateObject(const ObjectId id, const ObjectShapes& shapes, const btTransform& transform)
{ {
const CollisionShape collisionShape {shapes.mShapeInstance, *shapes.mShapeInstance->getCollisionShape()}; const CollisionShape collisionShape {shapes.mShapeInstance, *shapes.mShapeInstance->mCollisionShape};
bool result = mNavMeshManager.updateObject(id, collisionShape, transform, AreaType_ground); bool result = mNavMeshManager.updateObject(id, collisionShape, transform, AreaType_ground);
if (const btCollisionShape* const avoidShape = shapes.mShapeInstance->getAvoidCollisionShape()) if (const btCollisionShape* const avoidShape = shapes.mShapeInstance->mAvoidCollisionShape.get())
{ {
const ObjectId avoidId(avoidShape); const ObjectId avoidId(avoidShape);
const CollisionShape avoidCollisionShape {shapes.mShapeInstance, *avoidShape}; const CollisionShape avoidCollisionShape {shapes.mShapeInstance, *avoidShape};

View file

@ -77,16 +77,6 @@ BulletShape::BulletShape(const BulletShape &copy, const osg::CopyOp &copyop)
{ {
} }
btCollisionShape *BulletShape::getCollisionShape() const
{
return mCollisionShape.get();
}
btCollisionShape *BulletShape::getAvoidCollisionShape() const
{
return mAvoidCollisionShape.get();
}
void BulletShape::setLocalScaling(const btVector3& scale) void BulletShape::setLocalScaling(const btVector3& scale)
{ {
mCollisionShape->setLocalScaling(scale); mCollisionShape->setLocalScaling(scale);

View file

@ -47,10 +47,6 @@ namespace Resource
// we store the node's record index mapped to the child index of the shape in the btCompoundShape. // we store the node's record index mapped to the child index of the shape in the btCompoundShape.
std::map<int, int> mAnimatedShapes; std::map<int, int> mAnimatedShapes;
btCollisionShape* getCollisionShape() const;
btCollisionShape* getAvoidCollisionShape() const;
void setLocalScaling(const btVector3& scale); void setLocalScaling(const btVector3& scale);
bool isAnimated() const; bool isAnimated() const;