I am trying to do a scene query using Capsule colliders and for some reason the overlap function I had returns true even though in the PVD, the capsule are definitely not colliding (they are quite close together though). This is weird because my OnTrigger/onContact functions were called correctly only after an actual collision which means that I set my PxGeometry right but for some reason my overlap() calls independently from onTrigger/onContact.
Here is an extract of my code:
for (auto& collider2 : actor2->m_colliders)
{
bool isOverlapping = physx::PxGeometryQuery::overlap(collider->GetPhysXShape()->getGeometry().any(), actor1->GetPhysXActor().getGlobalPose(), collider2->GetPhysXShape()->getGeometry().any(), actor2->GetPhysXActor().getGlobalPose());
if (isOverlapping)
return true;
}
I have tried using both scene and geometric overlap queries but for some reason, there is a strange offset for only my capsule colliders (box, sphere works fine). It isn't that big of an issue as the strange offset is quite small but I do not want it register as colliding when 2 colliders are not really colliding.
I discovered the issue, turns out, the overlap queries do not consider the local transform of the PxShape, thus I solved it using:
physx::PxGeometryQuery::overlap(collider->GetPhysXShape()->getGeometry().any(), actor1->GetPhysXActor().getGlobalPose() * collider->GetPhysXShape()->getLocalPose(), collider2->GetPhysXShape()->getGeometry().any(), actor2->GetPhysXActor().getGlobalPose());