本文整理汇总了C++中PxVec3::normalizeSafe方法的典型用法代码示例。如果您正苦于以下问题:C++ PxVec3::normalizeSafe方法的具体用法?C++ PxVec3::normalizeSafe怎么用?C++ PxVec3::normalizeSafe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PxVec3
的用法示例。
在下文中一共展示了PxVec3::normalizeSafe方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeInflatedMTD
// Compute depenetration vector and distance if possible with a slightly larger geometry
static bool ComputeInflatedMTD(const float MtdInflation, const PxLocationHit& PHit, FHitResult& OutResult, const PxTransform& QueryTM, const PxGeometry& Geom, const PxTransform& PShapeWorldPose)
{
switch(Geom.getType())
{
case PxGeometryType::eCAPSULE:
{
const PxCapsuleGeometry* InCapsule = static_cast<const PxCapsuleGeometry*>(&Geom);
PxCapsuleGeometry InflatedCapsule(InCapsule->radius + MtdInflation, InCapsule->halfHeight); // don't inflate halfHeight, radius is added all around.
return ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, QueryTM, InflatedCapsule, PShapeWorldPose);
}
case PxGeometryType::eBOX:
{
const PxBoxGeometry* InBox = static_cast<const PxBoxGeometry*>(&Geom);
PxBoxGeometry InflatedBox(InBox->halfExtents + PxVec3(MtdInflation));
return ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, QueryTM, InflatedBox, PShapeWorldPose);
}
case PxGeometryType::eSPHERE:
{
const PxSphereGeometry* InSphere = static_cast<const PxSphereGeometry*>(&Geom);
PxSphereGeometry InflatedSphere(InSphere->radius + MtdInflation);
return ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, QueryTM, InflatedSphere, PShapeWorldPose);
}
case PxGeometryType::eCONVEXMESH:
{
// We can't exactly inflate the mesh (not easily), so try jittering it a bit to get an MTD result.
PxVec3 TraceDir = U2PVector(OutResult.TraceEnd - OutResult.TraceStart);
TraceDir.normalizeSafe();
// Try forward (in trace direction)
PxTransform JitteredTM = PxTransform(QueryTM.p + (TraceDir * MtdInflation), QueryTM.q);
if (ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, JitteredTM, Geom, PShapeWorldPose))
{
return true;
}
// Try backward (opposite trace direction)
JitteredTM = PxTransform(QueryTM.p - (TraceDir * MtdInflation), QueryTM.q);
if (ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, JitteredTM, Geom, PShapeWorldPose))
{
return true;
}
// Try axial directions.
// Start with -Z because this is the most common case (objects on the floor).
for (int32 i=2; i >= 0; i--)
{
PxVec3 Jitter(0.f);
Jitter[i] = MtdInflation;
JitteredTM = PxTransform(QueryTM.p - Jitter, QueryTM.q);
if (ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, JitteredTM, Geom, PShapeWorldPose))
{
return true;
}
JitteredTM = PxTransform(QueryTM.p + Jitter, QueryTM.q);
if (ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, JitteredTM, Geom, PShapeWorldPose))
{
return true;
}
}
return false;
}
default:
{
return false;
}
}
}