Autogenerated collision should only be disabled if RootCollisionNode is a child of the root node (Fixes #2133)

openmw-35
scrawl 10 years ago
parent 82eaa9f1bc
commit 04d6cead3b

@ -95,7 +95,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
return; return;
} }
mShape->mHasCollisionNode = hasRootCollisionNode(node); mShape->mAutogenerated = hasAutoGeneratedCollision(node);
//do a first pass //do a first pass
handleNode(node,0,false,false,false); handleNode(node,0,false,false,false);
@ -152,12 +152,9 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
mShape->mRaycastingShape = new TriangleMeshShape(mStaticMesh,true); 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) const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(rootNode);
return true;
const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(node);
if(ninode) if(ninode)
{ {
const Nif::NodeList &list = ninode->children; const Nif::NodeList &list = ninode->children;
@ -165,13 +162,12 @@ bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node const * node)
{ {
if(!list[i].empty()) if(!list[i].empty())
{ {
if(hasRootCollisionNode(list[i].getPtr())) if(list[i].getPtr()->recType == Nif::RC_RootCollisionNode)
return true; return false;
} }
} }
} }
return true;
return false;
} }
void ManualBulletShapeLoader::handleNode(const Nif::Node *node, int flags, void ManualBulletShapeLoader::handleNode(const Nif::Node *node, int flags,
@ -230,8 +226,8 @@ void ManualBulletShapeLoader::handleNode(const Nif::Node *node, int flags,
} }
} }
if ( (isCollisionNode || (!mShape->mHasCollisionNode && !raycasting)) if ( (isCollisionNode || (mShape->mAutogenerated && !raycasting))
&& (!isMarker || (mShape->mHasCollisionNode && !raycasting))) && (!isMarker || (!mShape->mAutogenerated && !raycasting)))
{ {
// NOTE: a trishape with hasBounds=true, but no BBoxCollision flag should NOT go through handleNiTriShape! // NOTE: a trishape with hasBounds=true, but no BBoxCollision flag should NOT go through handleNiTriShape!
// It must be ignored completely. // It must be ignored completely.

@ -112,7 +112,7 @@ private:
/** /**
*Helper function *Helper function
*/ */
bool hasRootCollisionNode(const Nif::Node *node); bool hasAutoGeneratedCollision(const Nif::Node *rootNode);
/** /**
*convert a NiTriShape to a bullet trishape. *convert a NiTriShape to a bullet trishape.

@ -19,7 +19,7 @@ Ogre::Resource(creator, name, handle, group, isManual, loader)
*/ */
mCollisionShape = NULL; mCollisionShape = NULL;
mRaycastingShape = NULL; mRaycastingShape = NULL;
mHasCollisionNode = false; mAutogenerated = true;
mCollide = true; mCollide = true;
createParamDictionary("BulletShape"); createParamDictionary("BulletShape");
} }

@ -41,9 +41,8 @@ public:
btCollisionShape* mCollisionShape; btCollisionShape* mCollisionShape;
btCollisionShape* mRaycastingShape; btCollisionShape* mRaycastingShape;
// Whether or not a NiRootCollisionNode was present in the .nif. If there is none, the collision behaviour // Does this .nif have an autogenerated collision mesh?
// depends on object type, so we need to expose this variable. bool mAutogenerated;
bool mHasCollisionNode;
Ogre::Vector3 mBoxTranslation; Ogre::Vector3 mBoxTranslation;
Ogre::Quaternion mBoxRotation; Ogre::Quaternion mBoxRotation;

@ -456,7 +456,7 @@ namespace Physic
BulletShapeManager::getSingletonPtr()->load(outputstring,"General"); BulletShapeManager::getSingletonPtr()->load(outputstring,"General");
BulletShapePtr shape = BulletShapeManager::getSingleton().getByName(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; return NULL;
if (!shape->mCollisionShape && !raycasting) if (!shape->mCollisionShape && !raycasting)

Loading…
Cancel
Save