rayTest() false hits

Post Reply
ca$per
Posts: 35
Joined: Fri May 21, 2010 2:48 pm

rayTest() false hits

Post by ca$per »

Hi!
As you can see from this video (http://www.youtube.com/watch?v=plSRY7jDbxY), rayTest() returns false hit in some cases.
The ray itself is ok, because i tested it with calculating hits by hands (checking for collisions without bullet). So it is built correctly.
In video, white lines are convex hull collision objects and red lines - their AABBs. All drawing is from debugDrawWorld().
What can be wrong? The only thing i thought about is center of mass. It's positioned incorrectly in collision objects, but since i do not use them as rigid bodies, i thought to leave them like that. Can this lead to incorrect behaviour? Or maybe something else?
ca$per
Posts: 35
Joined: Fri May 21, 2010 2:48 pm

Re: rayTest() false hits

Post by ca$per »

Looks like i found root of the problem. Some objects are not convex. But how do i make them so? I mean i just load them from file and it seems that i can't be sure, that a convex mesh will be generated properly. What can i do in this case?
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: rayTest() false hits

Post by Dirk Gregorius »

IIRC Bullet has a convex hull tool (StanHull). You can send you nearly convexes through it. I had a similar problem where I exported convex geometry and it wasn't. You can also write a simple test to verify whether an object is convex. For each face make sure that the vertices of the adjacent faces are behind the face plane.
ca$per
Posts: 35
Joined: Fri May 21, 2010 2:48 pm

Re: rayTest() false hits

Post by ca$per »

Thanks for this tip. Looks like this plugin is an amazing thing!
Unfortunatelly, in my case it changed the shape really much, loosing it's form:
hull_angle.jpg
hull_angle.jpg (53.51 KiB) Viewed 7340 times
The one to the right - is the initial mesh.

Perhaps there might be some parameters, that can help or changing the mesh is the only way in this case?
Attachments
hull_side.jpg
hull_side.jpg (33.05 KiB) Viewed 7340 times
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: rayTest() false hits

Post by Dirk Gregorius »

You need to decompose your original shape into convex pieces. This is called "convex decomposition". I don't know if Bullet has support for this yet, but I would search the forum and google for it. If the object is static you could alternatively make it a triangle mesh. Bullet also supports dynamic triangle meshes utilizing GImpact. So maybe look at the GImpactShape as well. I am no expert on GImpact and what it supports though.
ca$per
Posts: 35
Joined: Fri May 21, 2010 2:48 pm

Re: rayTest() false hits

Post by ca$per »

Thank you!
But the problem is, that i have no clue on which of methods to use.
Can you suggest one? What is best in terms of performance? In a scene, there might be 100+ of these objects.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: rayTest() false hits

Post by Dirk Gregorius »

Maybe try GImpact first. It should get you up and running quickly. If this doesn't work you need to decompose. This is obviously more work on the authoring site.
ca$per
Posts: 35
Joined: Fri May 21, 2010 2:48 pm

Re: rayTest() false hits

Post by ca$per »

Thanks! So i'll take a look at it.
Post Reply