Shape casts correctly report positions of colliders that intersect or in contact of the initial pose (#1848)

Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
main
amzn-sean 5 years ago committed by GitHub
parent 049469463e
commit 636ff587c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -188,7 +188,7 @@ namespace AzPhysics
AZ::Transform m_start = AZ::Transform::CreateIdentity(); //!< World space start position. Assumes only rotation + translation (no scaling). AZ::Transform m_start = AZ::Transform::CreateIdentity(); //!< World space start position. Assumes only rotation + translation (no scaling).
AZ::Vector3 m_direction = AZ::Vector3::CreateZero(); //!< World space direction (Should be normalized) AZ::Vector3 m_direction = AZ::Vector3::CreateZero(); //!< World space direction (Should be normalized)
AZStd::shared_ptr<Physics::ShapeConfiguration> m_shapeConfiguration; //!< Shape information. AZStd::shared_ptr<Physics::ShapeConfiguration> m_shapeConfiguration; //!< Shape information.
SceneQuery::HitFlags m_hitFlags = SceneQuery::HitFlags::Default; //!< Query behavior flags SceneQuery::HitFlags m_hitFlags = SceneQuery::HitFlags::Default | SceneQuery::HitFlags::MTD; //!< Query behavior flags. MTD Is On by default to correctly report objects that are initially in contact with the start pose.
SceneQuery::FilterCallback m_filterCallback = nullptr; //!< Hit filtering function SceneQuery::FilterCallback m_filterCallback = nullptr; //!< Hit filtering function
bool m_reportMultipleHits = false; //!< flag to have the cast stop after the first hit or return all hits along the query. bool m_reportMultipleHits = false; //!< flag to have the cast stop after the first hit or return all hits along the query.
}; };

@ -45,11 +45,17 @@ namespace PhysX
hit.m_distance = pxHit.distance; hit.m_distance = pxHit.distance;
hit.m_resultFlags |= AzPhysics::SceneQuery::ResultFlags::Distance; hit.m_resultFlags |= AzPhysics::SceneQuery::ResultFlags::Distance;
hit.m_position = PxMathConvert(pxHit.position); if (pxHit.flags & physx::PxHitFlag::ePOSITION)
hit.m_resultFlags |= AzPhysics::SceneQuery::ResultFlags::Position; {
hit.m_position = PxMathConvert(pxHit.position);
hit.m_resultFlags |= AzPhysics::SceneQuery::ResultFlags::Position;
}
hit.m_normal = PxMathConvert(pxHit.normal); if (pxHit.flags & physx::PxHitFlag::eNORMAL)
hit.m_resultFlags |= AzPhysics::SceneQuery::ResultFlags::Normal; {
hit.m_normal = PxMathConvert(pxHit.normal);
hit.m_resultFlags |= AzPhysics::SceneQuery::ResultFlags::Normal;
}
const ActorData* actorData = Utils::GetUserData(pxHit.actor); const ActorData* actorData = Utils::GetUserData(pxHit.actor);
hit.m_bodyHandle = actorData->GetBodyHandle(); hit.m_bodyHandle = actorData->GetBodyHandle();

@ -334,6 +334,8 @@ namespace PhysX
{ {
const physx::PxTransform pose = PxMathConvert(shapecastRequest->m_start); const physx::PxTransform pose = PxMathConvert(shapecastRequest->m_start);
const physx::PxVec3 dir = PxMathConvert(shapecastRequest->m_direction.GetNormalized()); const physx::PxVec3 dir = PxMathConvert(shapecastRequest->m_direction.GetNormalized());
AZ_Warning("PhysXScene", (static_cast<AZ::u16>(shapecastRequest->m_hitFlags & AzPhysics::SceneQuery::HitFlags::MTD) != 0),
"Not having MTD set for shape scene queries may result in incorrect reporting of colliders that are in contact or intersect the initial pose of the sweep.");
const physx::PxHitFlags hitFlags = SceneQueryHelpers::GetPxHitFlags(shapecastRequest->m_hitFlags); const physx::PxHitFlags hitFlags = SceneQueryHelpers::GetPxHitFlags(shapecastRequest->m_hitFlags);
bool status = false; bool status = false;

Loading…
Cancel
Save