(PATCH) btScaledBvhTriangleMeshShape

Fish

25-01-2009 01:22:38

Here is a patch that makes it easy to use the bullet btScaledBvhTriangleMeshShape in OgreBullet.


Index: OgreBulletDynamicsRigidBody.h
===================================================================
--- OgreBulletDynamicsRigidBody.h (revision 2618)
+++ OgreBulletDynamicsRigidBody.h (working copy)
@@ -36,6 +36,7 @@
#include "OgreBulletDynamicsWorld.h"

#include "Constraints/OgreBulletDynamicsRaycastVehicle.h"
+#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"

namespace OgreBulletDynamics
{
@@ -72,6 +73,11 @@
const Ogre::Vector3 &pos = Ogre::Vector3::ZERO,
const Ogre::Quaternion &quat = Ogre::Quaternion::IDENTITY);

+ void setStaticShape(btScaledBvhTriangleMeshShape *shape,
+ const float bodyRestitution,
+ const float bodyFriction,
+ const Ogre::Vector3 &pos = Ogre::Vector3::ZERO,
+ const Ogre::Quaternion &quat = Ogre::Quaternion::IDENTITY);

void setLinearVelocity(const Ogre::Vector3 &vel);
void setLinearVelocity(const Ogre::Real x, const Ogre::Real y, const Ogre::Real z);


Index: OgreBulletDynamicsRigidBody.cpp
===================================================================
--- OgreBulletDynamicsRigidBody.cpp (revision 2618)
+++ OgreBulletDynamicsRigidBody.cpp (working copy)
@@ -141,6 +141,27 @@
mObject = body;
getDynamicsWorld()->addRigidBody(this, mCollisionGroup, mCollisionMask);
}
+
+ void RigidBody::setStaticShape(btScaledBvhTriangleMeshShape *shape,
+ const float bodyRestitution,
+ const float bodyFriction,
+ const Vector3 &pos,
+ const Quaternion &quat)
+ {
+ //mState = new ObjectState(this);
+
+ btRigidBody *body = new btRigidBody(0.0, 0, shape);
+
+ body->setRestitution(bodyRestitution);
+ body->setFriction(bodyFriction);
+
+ body->getWorldTransform().setOrigin(btVector3(pos.x, pos.y, pos.z));
+ body->getWorldTransform().setRotation(btQuaternion(quat.x, quat.y, quat.z, quat.w));
+
+ mObject = body;
+ getDynamicsWorld()->addRigidBody(this, mCollisionGroup, mCollisionMask);
+ }
+
// -------------------------------------------------------------------------
void RigidBody::setKinematicObject(bool isKinematic) {
if (this->isKinematicObject() != isKinematic) {


-Fish

jacmoe

25-01-2009 21:59:50

Can you post this to the tracker?
Makes it easier for Tuan to manage. :)

Fish

04-02-2009 19:28:49

I didn't realize that "add-ons" were supported via the tracker.


edit: done

tuan kuranes

05-02-2009 14:41:25

Thansk for the patch.

yes, it does have its own tracker:)
As OgreAddons has its own sourceforge page
No worry, I'll download "them" from here.
FYI Usually patch gives a single file containing all file modification.