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);
}