|
|
|
@ -8,6 +8,7 @@
|
|
|
|
|
|
|
|
|
|
#include <BulletCollision/CollisionShapes/btTriangleMesh.h>
|
|
|
|
|
|
|
|
|
|
#include <components/sceneutil/visitor.hpp>
|
|
|
|
|
#include <components/vfs/manager.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/nifbullet/bulletnifloader.hpp>
|
|
|
|
@ -145,11 +146,34 @@ osg::ref_ptr<const BulletShape> BulletShapeManager::getShape(const std::string &
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<const osg::Node> constNode (mSceneManager->getTemplate(normalized));
|
|
|
|
|
osg::ref_ptr<osg::Node> node (const_cast<osg::Node*>(constNode.get())); // const-trickery required because there is no const version of NodeVisitor
|
|
|
|
|
NodeToShapeVisitor visitor;
|
|
|
|
|
node->accept(visitor);
|
|
|
|
|
shape = visitor.getShape();
|
|
|
|
|
|
|
|
|
|
// Check first if there's a custom collision node
|
|
|
|
|
SceneUtil::FindByNameVisitor nameFinder("Collision");
|
|
|
|
|
node->accept(nameFinder);
|
|
|
|
|
if (nameFinder.mFoundNode)
|
|
|
|
|
{
|
|
|
|
|
NodeToShapeVisitor visitor;
|
|
|
|
|
nameFinder.mFoundNode->accept(visitor);
|
|
|
|
|
shape = visitor.getShape();
|
|
|
|
|
for (unsigned int i = 0; i < nameFinder.mFoundNode->getNumParents(); ++i)
|
|
|
|
|
{
|
|
|
|
|
nameFinder.mFoundNode->getParent(i)->removeChild(nameFinder.mFoundNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* // CleanObjectRootVisitor is an alternative method
|
|
|
|
|
SceneUtil::CleanObjectRootVisitor cleanerVisitor;
|
|
|
|
|
nameFinder.mFoundNode->accept(cleanerVisitor);*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generate a collision shape from the mesh
|
|
|
|
|
if (!shape)
|
|
|
|
|
return osg::ref_ptr<BulletShape>();
|
|
|
|
|
{
|
|
|
|
|
NodeToShapeVisitor visitor;
|
|
|
|
|
node->accept(visitor);
|
|
|
|
|
shape = visitor.getShape();
|
|
|
|
|
if (!shape)
|
|
|
|
|
return osg::ref_ptr<BulletShape>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mCache->addEntryToObjectCache(normalized, shape);
|
|
|
|
|