(C++) Simple Bullet Physics Class/Manager

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Zurzaza
Posts: 153
Joined: Fri Mar 26, 2010 9:41 pm
Location: Filo (FE), Italy
Contact:

Post by Zurzaza »

Hi buck, i think you done a great work!
But i saw that there are a lot of memory leaks...
After some hours spent on your code, i find the definitive (i think) solution to the memory problems.
I rewrote some of your function in order to delete memory leaks.
Remember to call the destructor (or remove function) before exiting the program!

CPhysics.h

Code: Select all

#ifndef _CPHYSICS_H
#define _CPHYSICS_H

#include <btBulletCollisionCommon.h>
#include <btBulletDynamicsCommon.h>
#include <BulletCollision\CollisionDispatch\btGhostObject.h>

#include <irrlicht.h>
#include <iostream>
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace io;
using namespace gui;
using namespace video;
class CPhysics
{
    public:
	
    CPhysics(ISceneManager* smgr, IVideoDriver* driver, ITimer* Timer, const vector3df & Gravity, IMeshSceneNode* Map);
	~CPhysics();

    btTriangleMesh* ConvertIrrMeshToBulletTriangleMesh(IMesh* pMesh,const vector3df& scaling);
    void QuaternionToEuler(const btQuaternion &TQuat, btVector3 &TEuler);
    void getConvexHull(IMesh *collMesh, btConvexHullShape *hullShape, IAnimatedMeshSceneNode* node);
    list<btRigidBody *> getObjectList();
	void remove();

	/*Create a new box to the specified position*/
    btRigidBody* CreateBox(const vector3df &TPosition, const vector3df &TScale, btScalar TMass);

    btRigidBody* loadConvex(std::string filename, const btVector3 &TPosition, const vector3df &TScale, btScalar TMass);

	/*Get Bullet World Pointer*/
    btDiscreteDynamicsWorld* getWorld();

	/*Converts irrlicht's vector3df type into Bullet Vector3 format*/
	btVector3 ConvertIrrVectorToBulletVector(const vector3df & toConvert);

	/*Get gravity Vector*/
	vector3df getGravity();

	/*Main function of the wrapper. You need to call this function in the rendering loop*/
    void Update();
    bool UpdateRender(btRigidBody* TObject);

    private:
	btDefaultCollisionConfiguration* CollisionConfiguration;
	btBroadphaseInterface* BroadPhase;
	btCollisionDispatcher* Dispatcher;
	btSequentialImpulseConstraintSolver* Solver;
	btDiscreteDynamicsWorld* World;
	btBvhTriangleMeshShape* trimeshShape;
	btTriangleMesh* indexVertexArrays;
	btGhostPairCallback * ghostPair;

    ISceneManager* smgr;
    IVideoDriver* driver;
    ITimer* Timer;
   
    list<btRigidBody *> Objects;


	/*Array only for memory clean purpose*/
	array<btDefaultMotionState * > m_motionStates;
	array<btCollisionShape * > m_collisionShapes;
	array<btRigidBody *> m_bodyPtrs;
	array<btTriangleMesh *> m_triangleMeshes;

    btVector3 Gravity;
    u32 TimeStamp;
    u32 DeltaTime;

	bool initialized;
};

#endif
CPhysics.cpp

Code: Select all

#include "CPhysics.h"

CPhysics::~CPhysics()
{
	if(initialized)
		this->remove();
}

void CPhysics::remove()
{
    for(list<btRigidBody *>::Iterator Iterator = CPhysics::Objects.begin(); Iterator != CPhysics::Objects.end();)
    {
        CPhysics::World->removeRigidBody((*Iterator));
		/*Deletes all irrlicht nodes*/
        if((*Iterator)->getUserPointer()!=NULL)
            static_cast<ISceneNode *>((*Iterator)->getUserPointer())->remove();
        Iterator = CPhysics::Objects.erase(Iterator);
    }

	delete CPhysics::World;

	for(irr::u32 i =0; i<this->m_bodyPtrs.size();i++)
		delete this->m_bodyPtrs[i];
	for(irr::u32 i =0; i<this->m_collisionShapes.size();i++)
		delete this->m_collisionShapes[i];
	for(irr::u32 i =0; i<this->m_motionStates.size();i++)
		delete this->m_motionStates[i];
	for(irr::u32 i =0; i<this->m_triangleMeshes.size();i++)
		delete this->m_triangleMeshes[i];

	delete CollisionConfiguration;
	delete BroadPhase;
	delete Dispatcher;
	delete Solver;
	delete trimeshShape;

	delete ghostPair;
	initialized = false;
/*    if(DEBUG_CONSOLE)
        cout<<"Cleaned Physics World"<<endl;*/
}
btVector3 CPhysics::ConvertIrrVectorToBulletVector(const vector3df & toConvert)
{
	return btVector3(toConvert.X,toConvert.Y,toConvert.Z);
}
CPhysics::CPhysics(ISceneManager* smgr, IVideoDriver* driver, ITimer* Timer, const vector3df & Gravity, IMeshSceneNode* Map)
{
   CollisionConfiguration = new btDefaultCollisionConfiguration();
   BroadPhase = new btAxisSweep3(btVector3(-100000, -100000, -100000), btVector3(100000, 100000, 100000));
   ghostPair = new btGhostPairCallback();
   BroadPhase->getOverlappingPairCache()->setInternalGhostPairCallback(ghostPair);
   Dispatcher = new btCollisionDispatcher(CollisionConfiguration);
   Solver = new btSequentialImpulseConstraintSolver();
   CPhysics::World = new btDiscreteDynamicsWorld(Dispatcher, BroadPhase, Solver, CollisionConfiguration);
   this->Gravity = ConvertIrrVectorToBulletVector(Gravity);
   CPhysics::World->setGravity(this->Gravity);
  
   
   CPhysics::smgr = smgr;
   CPhysics::driver = driver;
   CPhysics::Timer = Timer;
   CPhysics::TimeStamp = Timer->getTime();
   CPhysics::DeltaTime = 0;

   indexVertexArrays = CPhysics::ConvertIrrMeshToBulletTriangleMesh(Map->getMesh(),Map->getScale());
   trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays, true);
   
   btQuaternion quat;
   quat.setEulerZYX(0,0,0);
   btTransform Transform2;
   Transform2.setIdentity();
   Transform2.setOrigin(ConvertIrrVectorToBulletVector(Map->getPosition()));
   Transform2.setRotation(quat);
   
   btDefaultMotionState *MotionState2 = new btDefaultMotionState(Transform2);
   this->m_motionStates.push_back(MotionState2);
   btRigidBody *RigidBody = new btRigidBody(0, MotionState2, trimeshShape);
   this->m_bodyPtrs.push_back(RigidBody);
   RigidBody->setUserPointer(Map);

   CPhysics::World->addRigidBody(RigidBody);
   CPhysics::Objects.push_back(RigidBody);

   RigidBody->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT);
   initialized = true;
}

void CPhysics::Update()
{
    CPhysics::DeltaTime = CPhysics::Timer->getTime() - CPhysics::TimeStamp;
    CPhysics::TimeStamp = CPhysics::Timer->getTime();
    CPhysics::World->stepSimulation(CPhysics::DeltaTime * 0.001f, 2);
    for(list<btRigidBody *>::Iterator Iterator = CPhysics::Objects.begin(); Iterator != CPhysics::Objects.end();)
        if(!CPhysics::UpdateRender(*Iterator))
        {
            Iterator = CPhysics::Objects.erase(Iterator);
        }
        else
        {
            Iterator++;
        }
}

bool CPhysics::UpdateRender(btRigidBody* TObject)
{
    ISceneNode* Node = static_cast<ISceneNode *>(TObject->getUserPointer());

    if(Node == NULL)
    {
        return false;
    }
    const btVector3& Point = TObject->getCenterOfMassPosition();
    Node->setPosition(vector3df((f32)Point[0], (f32)Point[1], (f32)Point[2]));

    btVector3 EulerRotation;
    CPhysics::QuaternionToEuler(TObject->getOrientation(), EulerRotation);
    Node->setRotation(vector3df(EulerRotation[0], EulerRotation[1], EulerRotation[2]));
    return true;
}

btRigidBody* CPhysics::CreateBox(const vector3df &TPosition, const vector3df &TScale, btScalar TMass)
{
   ISceneNode* Node = CPhysics::smgr->addCubeSceneNode(1.0f);
   Node->setScale(TScale);
   Node->setMaterialFlag(EMF_LIGHTING, true);
   Node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
   //Node->setMaterialTexture(0, driver->getTexture("rust0.jpg"));

   btTransform Transform;
   Transform.setIdentity();
   Transform.setOrigin(ConvertIrrVectorToBulletVector(TPosition));

   btDefaultMotionState *MotionState = new btDefaultMotionState(Transform);
   m_motionStates.push_back(MotionState);
   btVector3 HalfExtents(TScale.X * 0.5f, TScale.Y * 0.5f, TScale.Z * 0.5f);
   
   btCollisionShape *Shape = new btBoxShape(HalfExtents);
   m_collisionShapes.push_back(Shape);
  
   btVector3 LocalInertia;
   Shape->calculateLocalInertia(TMass, LocalInertia);

   btRigidBody *RigidBody = new btRigidBody(TMass, MotionState, Shape, LocalInertia);
   m_bodyPtrs.push_back(RigidBody);

   RigidBody->setUserPointer((void *)(Node));
   RigidBody->setActivationState(DISABLE_DEACTIVATION);
   
   CPhysics::World->addRigidBody(RigidBody);
   CPhysics::Objects.push_back(RigidBody);
   return RigidBody;
}

btTriangleMesh* CPhysics::ConvertIrrMeshToBulletTriangleMesh(IMesh* pMesh,const vector3df& scaling)
{
  btVector3 vertices[3];
  u32 i,j,k,index,numVertices,numIndices;
  u16* mb_indices;
  btTriangleMesh *pTriMesh = new btTriangleMesh();
  this->m_triangleMeshes.push_back(pTriMesh);
  for (i=0; i<pMesh->getMeshBufferCount(); i++)
  {
    IMeshBuffer* mb=pMesh->getMeshBuffer(i);
    if(mb->getVertexType()==EVT_STANDARD)
    {
      S3DVertex* mb_vertices=(S3DVertex*)mb->getVertices();
      mb_indices = mb->getIndices();
      numVertices = mb->getVertexCount();
      numIndices = mb->getIndexCount();
      for(j=0;j<numIndices;j+=3)
      {
        for (k=0;k<3;k++)
        {
          index = mb_indices[j+k];
          vertices[k] = btVector3(mb_vertices[index].Pos.X*scaling.X, mb_vertices[index].Pos.Y*scaling.Y, mb_vertices[index].Pos.Z*scaling.Z);
        }
        pTriMesh->addTriangle(vertices[0], vertices[1], vertices[2]);
      }
    }
    else if(mb->getVertexType()==EVT_2TCOORDS)
    {
      S3DVertex2TCoords* mb_vertices=(S3DVertex2TCoords*)mb->getVertices();
      mb_indices = mb->getIndices();
      numVertices = mb->getVertexCount();
      numIndices = mb->getIndexCount();
      for(j=0;j<numIndices;j+=3)
      {
        for (k=0;k<3;k++)
        {
          index = mb_indices[j+k];
          vertices[k] = btVector3(mb_vertices[index].Pos.X*scaling.X, mb_vertices[index].Pos.Y*scaling.Y, mb_vertices[index].Pos.Z*scaling.Z);
        }
        pTriMesh->addTriangle(vertices[0], vertices[1], vertices[2]);
      }
    }
  }
  return pTriMesh;
};

void CPhysics::QuaternionToEuler(const btQuaternion &TQuat, btVector3 &TEuler)
{
   btScalar W = TQuat.getW();
   btScalar X = TQuat.getX();
   btScalar Y = TQuat.getY();
   btScalar Z = TQuat.getZ();
   float WSquared = W * W;
   float XSquared = X * X;
   float YSquared = Y * Y;
   float ZSquared = Z * Z;
   TEuler.setX(atan2f(2.0f * (Y * Z + X * W), -XSquared - YSquared + ZSquared + WSquared));
   TEuler.setY(asinf(-2.0f * (X * Z - Y * W)));
   TEuler.setZ(atan2f(2.0f * (X * Y + Z * W), XSquared - YSquared - ZSquared + WSquared));
   TEuler *= RADTODEG;
};

btRigidBody* CPhysics::loadConvex(std::string filename, const btVector3 &TPosition, const vector3df &TScale, btScalar TMass)
{
    IAnimatedMeshSceneNode* Node = CPhysics::smgr->addAnimatedMeshSceneNode((IAnimatedMesh*)CPhysics::smgr->getMesh(filename.c_str()));
    btTriangleMesh* trimesh = CPhysics::ConvertIrrMeshToBulletTriangleMesh(Node->getMesh(), Node->getScale());

    btConvexShape* hull = new btConvexTriangleMeshShape(trimesh);
    hull->setUserPointer(hull);

    btVector3 localInertia(0,0,0);
    hull->calculateLocalInertia(TMass, localInertia);

   btQuaternion quat;
   quat.setEulerZYX(Node->getRotation().X,Node->getRotation().Y,Node->getRotation().Z);
   btTransform Transform2;
   Transform2.setIdentity();
   Transform2.setOrigin(TPosition);
   Transform2.setRotation(quat);

   btDefaultMotionState *MotionState2 = new btDefaultMotionState(Transform2);
   this->m_motionStates.push_back(MotionState2);

   btRigidBody* RigidBody = new btRigidBody(TMass, MotionState2, hull, localInertia);
   this->m_bodyPtrs.push_back(RigidBody);
   RigidBody->setUserPointer((void *)(Node));
   RigidBody->setActivationState(DISABLE_DEACTIVATION);

   CPhysics::World->addRigidBody(RigidBody);
   CPhysics::Objects.push_back(RigidBody);

   return RigidBody;
}

list<btRigidBody *> CPhysics::getObjectList()
{
    return CPhysics::Objects;
}

btDiscreteDynamicsWorld* CPhysics::getWorld()
{
    return CPhysics::World;
} 
I hope that this can help you to improve your source!
Thank you again...
Buck1000
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Post by Buck1000 »

Hey guys! I've been on vacation for the past 2 weeks~ish, and I haven't had any time to visit the forums. I just wanted to let you all know that I'll improve the source, and become much more active on this thread as soon as I get back home. I love how so many people are finding this usefull :D :D :D

I'll implement the changes you guys have made, and maybe post a .zip with a demo when I get back home. If you guys want me too, I can also implement some more complex features, like vehicles and such. I also have explosions/implosions working, but they aren't part of the physics framework. I can add them in there if anyone is interested. Something along the lines of createExplosion(btRigidBody* source, float radius, float force)

And, I implemented a character controller. As soon as I get jumping to work properly, I'll add it to the framework. (Now its in CPlayer.h). The only problem with it currently is that jumps always last a constant time, before gravity takes over, and the controller returns to it's original "Kinematic" mode. If anyone can code an isOnGround() function, I'd be very grateful :lol:

Yet again, I thank you for using my framework :D I really wasn't expecting it too be this popular :D As I said before, feature requests are welcome.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

@Zurzaza:
There's no need to create arrays for collision shapes, motion states as you can access from Collision body class using get methods.
Tough trimesh pointer gets lost in his code after conversion as I said before.
Working on game: Marrbles (Currently stopped).
Dareltibus
Posts: 115
Joined: Mon May 17, 2010 7:42 am

1 q

Post by Dareltibus »

are collisions, octree optimized?

ex. every item check if it collide with all others items or just with the items in the same/adiacent nodes?.
Buck1000
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Post by Buck1000 »

@Dareltibus - Collisions are handled by Bullet, so yes, I assume so.

@serengeor - Why not add code that keeps track of all created objects in lists (btTriangleMesh* ), and then deletes them all when the physics world is destroyed?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

@Buck1000 Well yes that's my point, tough if the level is the only triangle mesh in the scene I don't see a point of holding it in a list :)
Other Rigid body stuff such as motion states and collision shapes can be accessed trough btRigidBody interface ( if that's the correct word to use).
Working on game: Marrbles (Currently stopped).
Buck1000
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Post by Buck1000 »

Well, I'll add a pointer too it in the CPhysics class. Of course, since I'm planning on adding functions to create static objects/triangle mesh rigid bodies, a list would be useful in the future.

And yes, it is. I had trouble with directly setting the rotation of kinematic rigid bodies. They spun wildly out of control, and it appeared as if the values for rotation where being randomized. I think I asked about it on the Bullet forums, and never got a response. It was awhile ago anyways. Think you can help me out with that little problem? I was trying to set the rotation of a turret, that was being simulated as a kinematic rigid body (or was it a static triangle mesh? I don't remember).

I realize that was a bit off-topic, but you reminded me of it when you mentioned motion-states :D
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

You should show the code and we'll see what we can help :wink:
Working on game: Marrbles (Currently stopped).
Buck1000
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Post by Buck1000 »

Well, I'm away from home at the moment, so I don't have access to any of my documents, but I posted this awhile ago on the Bullet forums -

http://bulletphysics.org/Bullet/phpBB3/ ... 160#p18160

<--------------------- Start

I'm trying to get a rigid body to rotate around the Y access by a set amount every frame. What I've achieved instead, is a rigid body that spins insanely. I've been messing around with the code for over an hour now, and thought I'd ask you guys for help.

Heres the code -

Code: Select all

         btVector3 EulerRotation;
         QuaternionToEuler(TurretPhysics->getOrientation(), EulerRotation);
         vector3df Rotation = vector3df(EulerRotation[0], EulerRotation[1], EulerRotation[2]);
         float rotValue=2;

         Rotation = vector3df(0,Rotation.Y+rotValue,0);
         
         btTransform transform;
         transform.setIdentity();
         transform.setOrigin(TurretPhysics->getWorldTransform().getOrigin());

         btQuaternion quat;
         quat.setEuler(Rotation.Y,Rotation.X,Rotation.Z);

         transform.setRotation(quat);

         TurretPhysics->setWorldTransform(transform);

And QuaternionToEuler() -

Code: Select all

void QuaternionToEuler(const btQuaternion &TQuat, btVector3 &TEuler)
{
   btScalar W = TQuat.getW();
   btScalar X = TQuat.getX();
   btScalar Y = TQuat.getY();
   btScalar Z = TQuat.getZ();
   float WSquared = W * W;
   float XSquared = X * X;
   float YSquared = Y * Y;
   float ZSquared = Z * Z;
   TEuler.setX(atan2f(2.0f * (Y * Z + X * W), -XSquared - YSquared + ZSquared + WSquared));
   TEuler.setY(asinf(-2.0f * (X * Z - Y * W)));
   TEuler.setZ(atan2f(2.0f * (X * Y + Z * W), XSquared - YSquared - ZSquared + WSquared));
   TEuler *= RADTODEG;
};

Whats supposed to happen, is the rigidbody (TurretPhysics) is supposed to rotate by 2 degrees every frame. The body is made from a btBvhTriangleMeshShape, so its static. When the simulation is run, the body spins wildly. I checked it's angle at runtime, and it jumps from somewhere around 1, to anywhere from 0-100, and sometimes goes negative. What am I doing wrong?

<--------------------- End

And heres the response - (Which I don't remember seeing before, so I'm not sure I tried the solutions mentioned by Mattg)

<--------------------- Start

btQuaternion::setEuler() expects radians as far as I know.

Also if your program run at a high framerate adding 2 degrees each time might still be very fast, I suggest you multiply with the deltatime to get the rotation to be frame rate independent.

Lastly is that a dynamic rigid body? It's not a good idea to set the position or orientation of a simulated body each frame since it override whatever state the physics calculated.

<--------------------- End

I've changed the code since then, but the concept and problem remains the same.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

First of all, I think It should be

Code: Select all

 Rotation = vector3df(Rotation.X,Rotation.Y+rotValue,Rotation.Z); 
Secondly you should not rotate it every frame, bad for different frame rates, even if you get a fixed frame rate, there can be slower machines that could not run that fast and the speed of the turret would differ.
I would also like to see it in action to better understand whats happening :)
Edit:
Ive dug trough irrlicht sources and looked at Rotation animator and found this:

Code: Select all

if (rot.Y>360.f)
	rot.Y=fmodf(rot.Y, 360.f);
Working on game: Marrbles (Currently stopped).
Buck1000
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Post by Buck1000 »

First of all, I think It should be

Code: Select all

Rotation = vector3df(Rotation.X,Rotation.Y+rotValue,Rotation.Z);
The turret can only rotate on the Y axis, which is why the other two were 0 :)
Secondly you should not rotate it every frame, bad for different frame rates, even if you get a fixed frame rate, there can be slower machines that could not run that fast and the speed of the turret would differ.
I agree, and the Bullet forum guy said the same thing. I'll make the rotValue affected by Deltatime when I get to fixing it.
Ive dug trough irrlicht sources and looked at Rotation animator and found this:

Code: Select all

if (rot.Y>360.f)
   rot.Y=fmodf(rot.Y, 360.f); 
That code puts rot.Y back within the range of 0-360 (mod 360). I don't think I need it though, since rot.Y will never exceed 360 (that'd be a full rotation in a frame), and if the final Rotation vector's y-value is over 360, I'm assuming it gets normalized automatically by Irrlicht.

What would be awesome, is if you could code up a tiny demo, in which the user can manually rotate a bullet rigid body =] Use my framework, and see if you can get it working.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

I'll try to do that right after I come back to PC and Edit this post :wink:
Edit: Bad luck didn't have much time to code I also got weird rotations, tough rotating just irrlicht node works like a charm :?
Edit 2: Yea it just spins wildly tough now it only rotates on Y axis :lol:
Maybe it is better to animate, or to add constraint don't know really, I haven't dug so deep into physics :P
Working on game: Marrbles (Currently stopped).
dylanwinn
Posts: 1
Joined: Sun Sep 19, 2010 5:52 pm

Post by dylanwinn »

Hello, I'm new to C++ (but not to programming), and I'm having trouble getting this to work. I'm using Zurzaza's source and I have Bullet in the build path, but I get the following errors when I try to compile:

Code: Select all

obj\Debug\main.o||In function `main':|
C:\Users\Dylan\Desktop\Test\main.cpp|82|undefined reference to `CPhysics::CPhysics(irr::scene::ISceneManager*, irr::video::IVideoDriver*, irr::ITimer*, irr::core::vector3d<float> const&, irr::scene::IMeshSceneNode*)'|
C:\Users\Dylan\Desktop\Test\main.cpp|88|undefined reference to `CPhysics::CreateBox(irr::core::vector3d<float> const&, irr::core::vector3d<float> const&, float)'|
C:\Users\Dylan\Desktop\Test\main.cpp|93|undefined reference to `CPhysics::Update()'|
obj\Debug\main.o:C:\bullet\LinearMath\btAlignedAllocator.h|90|undefined reference to `btAlignedFreeInternal(void*)'|
obj\Debug\main.o:C:\bullet\LinearMath\btAlignedAllocator.h|90|undefined reference to `btAlignedFreeInternal(void*)'|
obj\Debug\main.o:C:\bullet\LinearMath\btAlignedAllocator.h|90|undefined reference to `btAlignedFreeInternal(void*)'|
obj\Debug\main.o:main.cpp:(.rdata$_ZTV17btTypedConstraint[vtable for btTypedConstraint]+0x30)||undefined reference to `btTypedConstraint::serialize(void*, btSerializer*) const'|
||=== Build finished: 7 errors, 0 warnings ===|
Any ideas what I'm doing wrong? I believe the problem has to do with library linking, but here are the problem lines of code if it helps:

Code: Select all

CPhysics* Physics = new CPhysics(smgr, driver, m_device->getTimer(), vector3df(0,0,-500), mapNode);

Code: Select all

Physics->CreateBox(vector3df((100+(50*xshift)),10+(50*yshift),1500),vector3df(50,50,50),40);

Code: Select all

Physics->Update();
Also, for whatever reason, bullet\LinearMath\btAlignedAllocator.h appears to be blank. (!?)
jorgerosa
Competition winner
Posts: 117
Joined: Wed Jun 30, 2010 8:44 am
Location: Portugal
Contact:

Re: (C++) Simple Bullet Physics Class/Manager

Post by jorgerosa »

Great work Buck1000, and the rest of the "team" too. Any improvements to this code? (I´m using it, cause it´s simple)
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: (C++) Simple Bullet Physics Class/Manager

Post by serengeor »

jorgerosa wrote:Great work Buck1000, and the rest of the "team" too. Any improvements to this code? (I´m using it, cause it´s simple)
Well, I have my own version of this wrapper (most of the stuff is rewritten though), but it's a bit restricted to my own framework so I doubt you could use it without modifications. (I have soft body ropes implemented)
Working on game: Marrbles (Currently stopped).
Post Reply