forked from mirror/openmw-tes3mp
Autogenerated collision should only be disabled if RootCollisionNode is a child of the root node (Fixes #2133)
This commit is contained in:
parent
82eaa9f1bc
commit
04d6cead3b
5 changed files with 13 additions and 18 deletions
|
@ -95,7 +95,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
|
|||
return;
|
||||
}
|
||||
|
||||
mShape->mHasCollisionNode = hasRootCollisionNode(node);
|
||||
mShape->mAutogenerated = hasAutoGeneratedCollision(node);
|
||||
|
||||
//do a first pass
|
||||
handleNode(node,0,false,false,false);
|
||||
|
@ -152,12 +152,9 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
|
|||
mShape->mRaycastingShape = new TriangleMeshShape(mStaticMesh,true);
|
||||
}
|
||||
|
||||
bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node const * node)
|
||||
bool ManualBulletShapeLoader::hasAutoGeneratedCollision(Nif::Node const * rootNode)
|
||||
{
|
||||
if(node->recType == Nif::RC_RootCollisionNode)
|
||||
return true;
|
||||
|
||||
const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(node);
|
||||
const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(rootNode);
|
||||
if(ninode)
|
||||
{
|
||||
const Nif::NodeList &list = ninode->children;
|
||||
|
@ -165,14 +162,13 @@ bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node const * node)
|
|||
{
|
||||
if(!list[i].empty())
|
||||
{
|
||||
if(hasRootCollisionNode(list[i].getPtr()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(list[i].getPtr()->recType == Nif::RC_RootCollisionNode)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ManualBulletShapeLoader::handleNode(const Nif::Node *node, int flags,
|
||||
bool isCollisionNode,
|
||||
|
@ -230,8 +226,8 @@ void ManualBulletShapeLoader::handleNode(const Nif::Node *node, int flags,
|
|||
}
|
||||
}
|
||||
|
||||
if ( (isCollisionNode || (!mShape->mHasCollisionNode && !raycasting))
|
||||
&& (!isMarker || (mShape->mHasCollisionNode && !raycasting)))
|
||||
if ( (isCollisionNode || (mShape->mAutogenerated && !raycasting))
|
||||
&& (!isMarker || (!mShape->mAutogenerated && !raycasting)))
|
||||
{
|
||||
// NOTE: a trishape with hasBounds=true, but no BBoxCollision flag should NOT go through handleNiTriShape!
|
||||
// It must be ignored completely.
|
||||
|
|
|
@ -112,7 +112,7 @@ private:
|
|||
/**
|
||||
*Helper function
|
||||
*/
|
||||
bool hasRootCollisionNode(const Nif::Node *node);
|
||||
bool hasAutoGeneratedCollision(const Nif::Node *rootNode);
|
||||
|
||||
/**
|
||||
*convert a NiTriShape to a bullet trishape.
|
||||
|
|
|
@ -19,7 +19,7 @@ Ogre::Resource(creator, name, handle, group, isManual, loader)
|
|||
*/
|
||||
mCollisionShape = NULL;
|
||||
mRaycastingShape = NULL;
|
||||
mHasCollisionNode = false;
|
||||
mAutogenerated = true;
|
||||
mCollide = true;
|
||||
createParamDictionary("BulletShape");
|
||||
}
|
||||
|
|
|
@ -41,9 +41,8 @@ public:
|
|||
btCollisionShape* mCollisionShape;
|
||||
btCollisionShape* mRaycastingShape;
|
||||
|
||||
// Whether or not a NiRootCollisionNode was present in the .nif. If there is none, the collision behaviour
|
||||
// depends on object type, so we need to expose this variable.
|
||||
bool mHasCollisionNode;
|
||||
// Does this .nif have an autogenerated collision mesh?
|
||||
bool mAutogenerated;
|
||||
|
||||
Ogre::Vector3 mBoxTranslation;
|
||||
Ogre::Quaternion mBoxRotation;
|
||||
|
|
|
@ -456,7 +456,7 @@ namespace Physic
|
|||
BulletShapeManager::getSingletonPtr()->load(outputstring,"General");
|
||||
BulletShapePtr shape = BulletShapeManager::getSingleton().getByName(outputstring,"General");
|
||||
|
||||
if (placeable && !raycasting && shape->mCollisionShape && !shape->mHasCollisionNode)
|
||||
if (placeable && !raycasting && shape->mCollisionShape && shape->mAutogenerated)
|
||||
return NULL;
|
||||
|
||||
if (!shape->mCollisionShape && !raycasting)
|
||||
|
|
Loading…
Reference in a new issue