Bug on raytest?

Post Reply
StephenLynx
Posts: 9
Joined: Tue May 10, 2016 1:42 am

Bug on raytest?

Post by StephenLynx »

I have two main types of rigid bodies on my world: walls and objects.

Walls might collide with objects or with walls and both collide with attacks.

Walls use btBox2dShape for the collision shape and objects use btCompoundShape with a btConvex2dShape created from a btConvexHullShape as its only child shape.

These are set using collision masks and groups.

And when I perform a test using contactTest the collision masks and filters work as intended.

However when I perform a raytest, the ray will not hit the objects ever.

Any idea?

Here is my project: https://gitgud.io/LynxVania/LynxVania

Relevant code:
https://gitgud.io/LynxVania/LynxVania/b ... ck.cpp#L56 its where I set the collision flags for walls.
https://gitgud.io/LynxVania/LynxVania/b ... ck.cpp#L23 is where I create collision shape for walls.

https://gitgud.io/LynxVania/LynxVania/b ... wn.cpp#L22 its where I set collision flags for objects.
https://gitgud.io/LynxVania/LynxVania/b ... wn.cpp#L42 is where I create the collision shape for objects.

https://gitgud.io/LynxVania/LynxVania/b ... g.cpp#L711 is where I perform the raycast.

Note that walls might be set to use the collisiontype::dynamic and collide with walls instead of colliding with objects.
These dynamic walls can be hit with by the raycast if the condition described here is true https://gitgud.io/LynxVania/LynxVania/b ... g.cpp#L736
However the objects are NEVER hit. Maybe there is something up with the fact I use a compound shape and its 2d physics?

PS: I checked the depth, everything is at 0z.
StephenLynx
Posts: 9
Joined: Tue May 10, 2016 1:42 am

Re: Bug on raytest?

Post by StephenLynx »

It turns out its caused by the object's shape being entirely flat. I added a second set of points at a different depth and now the raycast hits it.

Is this intended behavior? Am I using 2d physics wrong?
Post Reply