I’m getting some crazy stuff happening when I tried to introduce Foot IK (using sourcecode borrowed from our IK Sample). I get “crazy legs” !!
When I started debugging the relevant code, I noticed something strange.
Just like our sample, I begin by casting a ray down from each foot to the ground.
In my case, the ground in question is a static plane pointing directly up (0,1,0).
I cast a ray directly down onto it, and I get a collision result, but the normal in the result is not pointing directly straight up! Close, but not quite.
Nevertheless, I now cast a second ray from each foot, back along the resulting normal (as per the Sample code). This time, the collision result is something like (0,0.5,0.89) - what the hell?
I’m using collision layers and masks appropriately, although I’m yet to check for absolutely certain that I am indeed hitting the ground, and not something else.
Firstly - why is the result of the first raycast not EXACTLY (0,1,0) ?
Secondly - why is the result of the second raycast (almost straight down) not even CLOSE to (0,1,0)?
It’s much closer to (0,0,1) which absolutely makes no sense to me…
Bullet physics provides for a maximum of 16 collision filter layers (16 bit layer and mask values).
I currently define 7 bits - the default bullet ones, plus a couple more.
My ray (cast from one unit up from the foot position) is hitting the Left Upper Leg body, which has specifically been assigned to the “64” layer (non player character), with a collision mask of “34” (player character=32 | static=2)
My physics query is using a mask to query only objects in the static layer (2).
Yet, I am getting a collision of the query ray, with the Upper Leg of my character.
It appears there is a bug in the RaycastSingle code - either in our current urho master, or in Bullet itself.
Our physicsworld.cpp contains the following code in RaycastSingle:
rayCallback.m_collisionFilterGroup = (short)0xffff; rayCallback.m_collisionFilterMask = (short)collisionMask;
It appears that the Group flag is not being double-checked against the Mask in Bullet’s ray query.
I’d like to confirm this before I go crying to Erwin, what version of Bullet are we on?
I failed to mention that I am creating this scene in code, saving it, then loading it back in.
It could be a failure of our scene loader to set the mask correctly on physics bodies.
Since I am saving the scene to XML, I can confirm that the layer and mask are being serialized correctly, but I can’t be sure yet that deserializing in Urho is not the culprit.