mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 21:45:33 +00:00
animateCollisionShape checks if the shape is really animated
This commit is contained in:
parent
894477849a
commit
cbf344663f
1 changed files with 21 additions and 1 deletions
|
@ -563,7 +563,7 @@ namespace MWPhysics
|
||||||
|
|
||||||
btCompoundShape* compound = dynamic_cast<btCompoundShape*>(mShapeInstance->getCollisionShape());
|
btCompoundShape* compound = dynamic_cast<btCompoundShape*>(mShapeInstance->getCollisionShape());
|
||||||
|
|
||||||
for (std::map<int, int>::const_iterator it = mShapeInstance->mAnimatedShapes.begin(); it != mShapeInstance->mAnimatedShapes.end(); ++it)
|
for (std::map<int, int>::iterator it = mShapeInstance->mAnimatedShapes.begin(); it != mShapeInstance->mAnimatedShapes.end();)
|
||||||
{
|
{
|
||||||
int recIndex = it->first;
|
int recIndex = it->first;
|
||||||
int shapeIndex = it->second;
|
int shapeIndex = it->second;
|
||||||
|
@ -578,6 +578,24 @@ namespace MWPhysics
|
||||||
|
|
||||||
osg::NodePath path = visitor.mFoundPath;
|
osg::NodePath path = visitor.mFoundPath;
|
||||||
path.erase(path.begin());
|
path.erase(path.begin());
|
||||||
|
|
||||||
|
// Attempt to remove "animated" shapes that are not actually animated
|
||||||
|
// We may get these because the BulletNifLoader does not know if a .kf file with additional controllers will be attached later on.
|
||||||
|
// On the first animateCollisionShapes call, we'll consider the graph completely loaded (with extra controllers and what not),
|
||||||
|
// so now we can better decide if the shape is really animated.
|
||||||
|
bool animated = false;
|
||||||
|
for (osg::NodePath::iterator nodePathIt = path.begin(); nodePathIt != path.end(); ++nodePathIt)
|
||||||
|
{
|
||||||
|
osg::Node* node = *nodePathIt;
|
||||||
|
if (node->getUpdateCallback())
|
||||||
|
animated = true;
|
||||||
|
}
|
||||||
|
if (!animated)
|
||||||
|
{
|
||||||
|
mShapeInstance->mAnimatedShapes.erase(it++);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
osg::Matrixf matrix = osg::computeLocalToWorld(path);
|
osg::Matrixf matrix = osg::computeLocalToWorld(path);
|
||||||
osg::Vec3f scale = matrix.getScale();
|
osg::Vec3f scale = matrix.getScale();
|
||||||
matrix.orthoNormalize(matrix);
|
matrix.orthoNormalize(matrix);
|
||||||
|
@ -590,6 +608,8 @@ namespace MWPhysics
|
||||||
|
|
||||||
compound->getChildShape(shapeIndex)->setLocalScaling(compound->getLocalScaling() * toBullet(scale));
|
compound->getChildShape(shapeIndex)->setLocalScaling(compound->getLocalScaling() * toBullet(scale));
|
||||||
compound->updateChildTransform(shapeIndex, transform);
|
compound->updateChildTransform(shapeIndex, transform);
|
||||||
|
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
collisionWorld->updateSingleAabb(mCollisionObject.get());
|
collisionWorld->updateSingleAabb(mCollisionObject.get());
|
||||||
|
|
Loading…
Reference in a new issue