Skip to content

Commit

Permalink
Revert "Use btScaledBvhTriangleMeshShape, bump required bullet versio…
Browse files Browse the repository at this point in the history
…n to 2.83"

This reverts commit 27751db.

Conflicts:

	libs/openengine/bullet/physic.cpp
  • Loading branch information
zinnschlag committed May 10, 2015
1 parent e4ffb98 commit 107bf81
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
4 changes: 2 additions & 2 deletions components/nifbullet/bulletnifloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
mCompoundShape = NULL;
mStaticMesh = NULL;

Nif::NIFFilePtr pnif (Nif::Cache::getInstance().load(mResourceName));
Nif::NIFFilePtr pnif (Nif::Cache::getInstance().load(mResourceName.substr(0, mResourceName.length()-7)));
Nif::NIFFile & nif = *pnif.get ();
if (nif.numRoots() < 1)
{
Expand All @@ -134,7 +134,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
// Have to load controlled nodes from the .kf
// FIXME: the .kf has to be loaded both for rendering and physics, ideally it should be opened once and then reused
mControlledNodes.clear();
std::string kfname = mResourceName;
std::string kfname = mResourceName.substr(0, mResourceName.length()-7);
Misc::StringUtils::toLower(kfname);
if(kfname.size() > 4 && kfname.compare(kfname.size()-4, 4, ".nif") == 0)
kfname.replace(kfname.size()-4, 4, ".kf");
Expand Down
32 changes: 9 additions & 23 deletions libs/openengine/bullet/physic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,8 @@ namespace Physic
float scale, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation,
Ogre::Vector3* scaledBoxTranslation, Ogre::Quaternion* boxRotation, bool raycasting, bool placeable)
{
std::string outputstring = mesh;
std::string sid = (boost::format("%07.3f") % scale).str();
std::string outputstring = mesh + sid;

//get the shape from the .nif
mShapeLoader->load(outputstring,"General");
Expand All @@ -474,35 +475,20 @@ namespace Physic

btCollisionShape* collisionShape = raycasting ? shape->mRaycastingShape : shape->mCollisionShape;

// TODO: check this from cmake?
//#if BT_BULLET_VERSION < 283
//#error "Bullet version 2.83 or later required"
//#endif
// If this is an animated compound shape, we must duplicate it so we can animate
// multiple instances independently.
if (!raycasting && !shape->mAnimatedShapes.empty())
collisionShape = duplicateCollisionShape(collisionShape);
if (raycasting && !shape->mAnimatedRaycastingShapes.empty())
collisionShape = duplicateCollisionShape(collisionShape);

bool needDelete = false;
if (btBvhTriangleMeshShape* triangleShape = dynamic_cast<btBvhTriangleMeshShape*>(shape->mCollisionShape))
{
btScaledBvhTriangleMeshShape* scaled = new btScaledBvhTriangleMeshShape(triangleShape, btVector3(scale,scale,scale));
collisionShape = scaled;
needDelete = true;
}
else
{
// If this is an animated compound shape, we must duplicate it so we can animate
// multiple instances independently.
if (!raycasting && !shape->mAnimatedShapes.empty())
collisionShape = duplicateCollisionShape(collisionShape);
if (raycasting && !shape->mAnimatedRaycastingShapes.empty())
collisionShape = duplicateCollisionShape(collisionShape);
}
collisionShape->setLocalScaling( btVector3(scale,scale,scale));

//create the real body
btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo
(0,0, collisionShape);
RigidBody* body = new RigidBody(CI,name);
body->mPlaceable = placeable;
if (needDelete)
body->mCollisionShape.reset(collisionShape);

if (!raycasting && !shape->mAnimatedShapes.empty())
{
Expand Down
3 changes: 0 additions & 3 deletions libs/openengine/bullet/physic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ namespace Physic
virtual ~RigidBody();
std::string mName;

// May be empty if the collision shape is a shared resource
std::auto_ptr<btCollisionShape> mCollisionShape;

// Hack: placeable objects (that can be picked up by the player) have different collision behaviour.
// This variable needs to be passed to BulletNifLoader.
bool mPlaceable;
Expand Down

0 comments on commit 107bf81

Please sign in to comment.