Problems/Understanding contactTest

Post Reply
domleo
Posts: 1
Joined: Fri May 13, 2016 6:13 pm

Problems/Understanding contactTest

Post by domleo »

So I was looking to implement a kinda of 'wide raycast' using contactTest by creating a triangle collision object from my camera to detect which objects are present between two points.

I start by creating an instance of a btConvexTriangleMeshShape and confirmed is was created where intended by creating a triangle between where 2 rayCasts would of been.
Then I created my ContactResultCallback and implemented my addSingleResult. And so far that work's fine with btBoxShape and even a more irregular object like a cube missing a side.
But what I don't understand is why when I try contactTest with a btSphereShape nearby, the ContactResultCallback returns manifold points before the triangle and the sphere actually do touch. And what's even more bizarre is that if I half the radius of the btSphereShape, then the contactTest reacts as I would expect, returning a manifold only when the triangle and the sphere are actually touching. It's as if the radius is double when checking if there's a contact.

Here are some pictures to help explain:
ss-1.png
ss-1.png (53.4 KiB) Viewed 4886 times
ss-2.png
ss-2.png (138.36 KiB) Viewed 4886 times
with aabb activated
ss-3.png
ss-3.png (84.81 KiB) Viewed 4886 times

I would remake my triangle every time I press a button (kinda like doing a scan) and then print the results. I did this going left to right and up to down.
The result was always the same, I would always get the sphere way before the triangle would touch the sphere and I would only get the box when the triangle actually is on the box (+ the margin).

I managed to filter out this problem by only recording the results from the ContactResultCallback where "btManifoldPoint.getDistance() < -0.04" (0.04 is to ignore the margin, figured that out thanks to this post: http://bulletphysics.org/Bullet/phpBB3/ ... ontactTest)

So my question is, why do a get a contact from a contactTest when a btConvexTriangleMeshShape is within 2 * radius of a btSphereShape? If that's what's really going on.
kermado
Posts: 20
Joined: Tue Jan 12, 2016 11:20 am

Re: Problems/Understanding contactTest

Post by kermado »

Have you tried using btTriangleShape rather than btConvexTriangleMeshShape?
Using btConvexTriangleMeshShape will cause the Convex-Convex collision algorithm to be used. I don't know the inner workings of the GJK-EPA algorithm and so I don't know whether it supports zero volume convex shapes. But if you use the btTriangleShape then the btSphereTriangleCollisionAlgorithm should be used (unless you're using a custom collision configuration).
Post Reply