I’ve taken the bit and parts and ported them over one by one. If I remember correctly, very few, if any, changes are needed to make it work.
In the castRay function of your raycaster, you simply put:
rayCallback.m_collisionFilterMask = collisionFilterMask;
rayCallback.m_collisionFilterGroup = collisionFilterGroup;
Before you do the rayTest.
So between setting the result callback and calling the rayTest function. Then it’s automatically handled.
Then you just need a way of setting your mask and group. The best way of doing this is to create a function that takes two ints, one for the mask and one for the group, and do collisionFilterMask = BIT(int)
Then export this function in the idl.
A cool feature of the SuperTuxKart project as well is auto-stabilization of the vehicle when airborne.
You can give it a Vector3 telling it which direction is up (0,1,0), and an int or float as an impulse to automatically stabilize the vehicle, so it hits the ground correctly.
btVector3 kart_up = getChassisWorldTransform().getBasis().getColumn(1);
//btVector3 terrain_up = btVector3(0, 1, 0);
// Length of axis depends on the angle - i.e. the further awat
// the kart is from being upright, the larger the applied impulse
// will be, resulting in fast changes when the kart is on its
// side, but not overcompensating (and therefore shaking) when
// the kart is not much away from being upright.
btVector3 axis = kart_up.cross(terrain_up);
// To avoid the kart going backwards/forwards (or rolling sideways),
// set the pitch/roll to 0 before applying the 'straightening' impulse.
// TODO: make this works if gravity is changed.
btVector3 av = m_chassisBody->getAngularVelocity();
av.setX(0);
av.setZ(0);
m_chassisBody->setAngularVelocity(av);
// Give a nicely balanced feeling for rebalancing the kart
m_chassisBody->applyTorqueImpulse(axis * stabImpulse);