Irrlicht and Bullet Physics Help

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
GameDude
Posts: 498
Joined: Thu May 24, 2007 12:24 am

Irrlicht and Bullet Physics Help

Post by GameDude »

Hello,

I am trying to compile Irrlicht with Bullet Physics, but I keep getting this error.

Error C2664 'void CreateBox(const btVector3 &,const irr::core::vector3df *,btScalar)': cannot convert argument 2 from 'irr::core::vector3df' to 'const irr::core::vector3df *'

I'm using Irrlicht 1.8.4 and Bullet Physics 2.86

EDIT: I figured it out. I need to put &Tscale instead of*TScale

Code: Select all

 
void CreateBox(const btVector3 &TPosition, const vector3df *TScale, btScalar TMass);
 
CreateBox(btVector3(0.0f, 0.0f, 0.0f), vector3df(10.0f, 0.5f, 10.0f), 0.0f); //error is coming from the vector3df part of this line of code.
 
void CreateBox(const btVector3 &TPosition, const vector3df &TScale, btScalar TMass)
{
    ISceneNode* Node = Smgr->addCubeSceneNode(1.0f);
    Node->setScale(TScale);
    Node->setMaterialFlag(EMF_LIGHTING, 1);
    Node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
 
    btTransform Transform;
    Transform.setIdentity();
    Transform.setOrigin(TPosition);
 
    btDefaultMotionState* MotionState = new btDefaultMotionState(Transform);
 
    btVector3 HalfExtents(TScale.X * 0.5f, TScale.Y * 0.5f, TScale.Z * 0.5f);
    btCollisionShape* Shape = new btBoxShape(HalfExtents);
 
    btVector3 LocalInertia;
    Shape->calculateLocalInertia(TMass, LocalInertia);
 
    btRigidBody* RigidBody = new btRigidBody(TMass, MotionState, Shape, LocalInertia);
 
    RigidBody->setUserPointer((void*)(Node));
 
    World->addRigidBody(RigidBody);
    Objects.push_back(RigidBody);
}
 
void UpdateRender(btRigidBody* TObject)
{
    ISceneNode* Node = static_cast<ISceneNode*>(TObject->getUserPointer());
 
    btVector3 Point = TObject->getCenterOfMassPosition();
    Node->setPosition(vector3df((f32)Point[0], (f32)Point[1], (f32)Point[2]));
 
    vector3df Euler;
    const btQuaternion& TQuat = TObject->getOrientation();
    quaternion q(TQuat.getX(), TQuat.getY(), TQuat.getZ(), TQuat.getW());
    q.toEuler(Euler);
    Euler *= RADTODEG;
    Node->setRotation(Euler);
}
 
Note: I've only posted part of the code as what I think needs to be looked at. Any help is appericated.
realmsinthemists
Posts: 28
Joined: Mon Mar 27, 2017 7:29 am

Re: Irrlicht and Bullet Physics Help

Post by realmsinthemists »

Why are you mixing Irrlicht and Bullet types in one function declaration. Isn't it a better practice to use only one type type <- you see the double word <- and there the cynical one.

If I were you I would choose either btVector3 or vector3df and convert it where needed. It is less prone to unexpected errors and behaviours.

Also I notice your forwarding declaration has a pointer to vector3df while the definition has a reference to it.

r,
For my end result I am working on:
- Volume Voxel System
- Simple light weight physics engine
Post Reply