Problem with simple collision tests

User avatar
kripken
Posts: 2
Joined: Wed Feb 24, 2010 9:44 am

Problem with simple collision tests

Post by kripken »

Hello, I've been working on integrating Bullet into my open source 3D game engine, the Intensity Engine, here is what I have so far: http://www.youtube.com/watch?v=1vvsVkdJiSQ. Basically the game engine had a very simple internal physics system, and I am replacing that with Bullet. Just getting started, but I am very enthusiastic about the possibilities :)

I am having a problem with collision tests though. Basically I need to check if there is anything in a certain area in space, and get a yes/no answer. I have this code, which does a convex sweep test with a sphere:

Code: Select all

    btSphereShape sphere(radius);
    btTransform from;
    from.setIdentity();
    from.setOrigin(position);
    btCollisionWorld::ClosestConvexResultCallback cb(from.getOrigin(), from.getOrigin() );
    m_dynamicsWorld->convexSweepTest(&sphere, from, from, cb);
    return cb.hasHit();
This seems to almost always return 'no collision', even when there is something there (I am using the Bullet debug drawer for testing). Oddly though, it does detect collisions with a capsule shape representing other players in the game, so I thought it might have something to do with sleep/activation, but that doesn't seem to be it either.

Is there something obvious I am missing in the above code? The only thing different from the Bullet examples is that I am using the same position as the start and end-points of the sweep - is that wrong? If so, is there a better way to do a simple test of collisions with a sphere shape at some location in space?

(edit: typo)
David20321
Posts: 17
Joined: Sat Mar 13, 2010 10:08 pm

Re: Problem with simple collision tests

Post by David20321 »

You probably want to use contactTest() instead of convexSweepTest() -- I am new to Bullet, but I wouldn't be surprised if convexSweepTest() only works correctly over a non-zero distance.
User avatar
kripken
Posts: 2
Joined: Wed Feb 24, 2010 9:44 am

Re: Problem with simple collision tests

Post by kripken »

David20321 wrote:You probably want to use contactTest() instead of convexSweepTest() -- I am new to Bullet, but I wouldn't be surprised if convexSweepTest() only works correctly over a non-zero distance.
Thanks, that works!

EDIT: btw, here is the latest progress with Bullet in the Intensity Engine: http://www.youtube.com/watch?v=L02dNMDKGok