I've been reading through documentation and forum posts, and am having trouble figuring out how to do this:
some of my units (turrets), have a cylinderShape ghost object around them that I'm using as a trigger to start targeting enemies inside of it
This works perfectly, however now when I do a rayTest() for the user right-clicking on the terrain, instead of the terrain I get the ghost object as the result
Is there a way to just ignore ghost objects in rayTest() ?
FYI I've tried setting the ghost object's collision filter group to "sensorTrigger" but then it started detecting everything (even mass 0) as a hit!
This is how I'm doing it:
Code: Select all
btCollisionWorld::ClosestRayResultCallback RayCallback(
btVector3(out_origin.x, out_origin.y, out_origin.z),
btVector3(out_end.x, out_end.y, out_end.z)
);
world->physicsModule->dynamicsWorld->rayTest(
btVector3(out_origin.x, out_origin.y, out_origin.z),
btVector3(out_end.x, out_end.y, out_end.z),
RayCallback
);
if (RayCallback.hasHit()) {
//std::cout << "mesh " << (int)RayCallback.m_collisionObject->getUserPointer();
mouseRaycastHasHit = true;
btVector3 hitPointWorld = RayCallback.m_hitPointWorld;
mouseHitPointWorld = glm::vec3(hitPointWorld.getX(), hitPointWorld.getY(), hitPointWorld.getZ());
mouseHitObjectUserIndex1 = (int)RayCallback.m_collisionObject->getUserIndex();
mouseHitObjectUserIndex2 = (int)RayCallback.m_collisionObject->getUserIndex2();
}
else {
mouseRaycastHasHit = false;
}