Why no collisions?

javadlux
Posts: 1
Joined: Tue Jun 03, 2008 12:33 am

Why no collisions?

Post by javadlux »

Hi. I'm hoping to use bullet for some swept convex -> trimesh collisions, but I can't seem to get it working (I'm not using dynamics). Here is the code from a simple project I put together:

Code: Select all

#include <windows.h>
#include <iostream>
#include "btBulletCollisionCommon.h"

int main(int argc, char** argv) {
	btCollisionConfiguration* pConfig = new btDefaultCollisionConfiguration();
	btDispatcher* pDispatch = new btCollisionDispatcher(pConfig);
	btBroadphaseInterface* pBroadInterface = new btSimpleBroadphase();
	btCollisionWorld* pWorld = new btCollisionWorld(pDispatch, pBroadInterface, pConfig);
	btCollisionObject* pObj = new btCollisionObject();
	btConvexShape* pCone = new btConeShape(1.0f, 1.0f);
	pObj->setCollisionShape(pCone);
	pWorld->addCollisionObject(pObj, 1, 1);
	btMatrix3x3 iden;
	iden.setIdentity();
	btCollisionWorld::ClosestConvexResultCallback ret(btVector3(-5, 0, 0), btVector3(5, 0, 0));
	pWorld->convexSweepTest(pCone, btTransform(iden, btVector3(-5, 0, 0)), btTransform(iden, btVector3(5, 0, 0)), ret, 1);
	std::cout << ret.HasHit() << "   " << ret.m_closestHitFraction << std::endl;
	std::cin.get();
	return 0;
}
I tried to use default and simple values for all things. This code should try and collide 1 cone with another static cone. Am I doing this right? (PS... what are the values passed to ClosestConvexResultCallback used for? As far as I can see they are only referenced in the constructor)

Thanks in advance,
javadlux

EDIT: PSS: I forgot to mention... this code as it is gives an assert error, apparently it's trying to take the acos of a number greater than 1!)