本文整理汇总了C++中FTransform::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ FTransform::IsValid方法的具体用法?C++ FTransform::IsValid怎么用?C++ FTransform::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FTransform
的用法示例。
在下文中一共展示了FTransform::IsValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddBoxesToRigidActor_AssumesLocked
void AddBoxesToRigidActor_AssumesLocked() const
{
float ContactOffsetFactor, MaxContactOffset;
GetContactOffsetParams(ContactOffsetFactor, MaxContactOffset);
for (int32 i = 0; i < BodySetup->AggGeom.BoxElems.Num(); i++)
{
const FKBoxElem& BoxElem = BodySetup->AggGeom.BoxElems[i];
PxBoxGeometry PBoxGeom;
PBoxGeom.halfExtents.x = (0.5f * BoxElem.X * Scale3DAbs.X);
PBoxGeom.halfExtents.y = (0.5f * BoxElem.Y * Scale3DAbs.Y);
PBoxGeom.halfExtents.z = (0.5f * BoxElem.Z * Scale3DAbs.Z);
FTransform BoxTransform = BoxElem.GetTransform() * RelativeTM;
if (PBoxGeom.isValid() && BoxTransform.IsValid())
{
PxTransform PLocalPose(U2PTransform(BoxTransform));
PLocalPose.p.x *= Scale3D.X;
PLocalPose.p.y *= Scale3D.Y;
PLocalPose.p.z *= Scale3D.Z;
ensure(PLocalPose.isValid());
{
const float ContactOffset = FMath::Min(MaxContactOffset, ContactOffsetFactor * PBoxGeom.halfExtents.minElement());
AttachShape_AssumesLocked(PBoxGeom, PLocalPose, ContactOffset);
}
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddBoxesToRigidActor: [%s] BoxElems[%d] invalid or has invalid transform"), *GetPathNameSafe(BodySetup->GetOuter()), i);
}
}
}
示例2: AddConvexElemsToRigidActor_AssumesLocked
void AddConvexElemsToRigidActor_AssumesLocked() const
{
float ContactOffsetFactor, MaxContactOffset;
GetContactOffsetParams(ContactOffsetFactor, MaxContactOffset);
for (int32 i = 0; i < BodySetup->AggGeom.ConvexElems.Num(); i++)
{
const FKConvexElem& ConvexElem = BodySetup->AggGeom.ConvexElems[i];
if (ConvexElem.ConvexMesh)
{
PxTransform PLocalPose;
bool bUseNegX = CalcMeshNegScaleCompensation(Scale3D, PLocalPose);
PxConvexMeshGeometry PConvexGeom;
PConvexGeom.convexMesh = bUseNegX ? ConvexElem.ConvexMeshNegX : ConvexElem.ConvexMesh;
PConvexGeom.scale.scale = U2PVector(Scale3DAbs * ConvexElem.GetTransform().GetScale3D().GetAbs());
FTransform ConvexTransform = ConvexElem.GetTransform();
if (ConvexTransform.GetScale3D().X < 0 || ConvexTransform.GetScale3D().Y < 0 || ConvexTransform.GetScale3D().Z < 0)
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: [%s] ConvexElem[%d] has negative scale. Not currently supported"), *GetPathNameSafe(BodySetup->GetOuter()), i);
}
if (ConvexTransform.IsValid())
{
PxTransform PElementTransform = U2PTransform(ConvexTransform * RelativeTM);
PLocalPose.q *= PElementTransform.q;
PLocalPose.p = PElementTransform.p;
PLocalPose.p.x *= Scale3D.X;
PLocalPose.p.y *= Scale3D.Y;
PLocalPose.p.z *= Scale3D.Z;
if (PConvexGeom.isValid())
{
PxVec3 PBoundsExtents = PConvexGeom.convexMesh->getLocalBounds().getExtents();
ensure(PLocalPose.isValid());
{
const float ContactOffset = FMath::Min(MaxContactOffset, ContactOffsetFactor * PBoundsExtents.minElement());
AttachShape_AssumesLocked(PConvexGeom, PLocalPose, ContactOffset);
}
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: [%s] ConvexElem[%d] invalid"), *GetPathNameSafe(BodySetup->GetOuter()), i);
}
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: [%s] ConvexElem[%d] has invalid transform"), *GetPathNameSafe(BodySetup->GetOuter()), i);
}
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: ConvexElem is missing ConvexMesh (%d: %s)"), i, *BodySetup->GetPathName());
}
}
}
示例3: AddBoxesToRigidActor
void UBodySetup::AddBoxesToRigidActor(PxRigidActor* PDestActor, const FTransform& RelativeTM, const FVector& Scale3D, const FVector& Scale3DAbs, TArray<PxShape*>* NewShapes) const
{
float ContactOffsetFactor, MaxContactOffset;
GetContactOffsetParams(ContactOffsetFactor, MaxContactOffset);
PxMaterial* PDefaultMat = GetDefaultPhysMaterial();
for (int32 i = 0; i < AggGeom.BoxElems.Num(); i++)
{
const FKBoxElem& BoxElem = AggGeom.BoxElems[i];
PxBoxGeometry PBoxGeom;
PBoxGeom.halfExtents.x = (0.5f * BoxElem.X * Scale3DAbs.X);
PBoxGeom.halfExtents.y = (0.5f * BoxElem.Y * Scale3DAbs.Y);
PBoxGeom.halfExtents.z = (0.5f * BoxElem.Z * Scale3DAbs.Z);
FTransform BoxTransform = BoxElem.GetTransform() * RelativeTM;
if (PBoxGeom.isValid() && BoxTransform.IsValid())
{
PxTransform PLocalPose(U2PTransform(BoxTransform));
PLocalPose.p.x *= Scale3D.X;
PLocalPose.p.y *= Scale3D.Y;
PLocalPose.p.z *= Scale3D.Z;
ensure(PLocalPose.isValid());
PxShape* NewShape = PDestActor->createShape(PBoxGeom, *PDefaultMat, PLocalPose);
if (NewShapes)
{
NewShapes->Add(NewShape);
}
const float ContactOffset = FMath::Min(MaxContactOffset, ContactOffsetFactor * PBoxGeom.halfExtents.minElement());
NewShape->setContactOffset(ContactOffset);
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddBoxesToRigidActor: [%s] BoxElems[%d] invalid or has invalid transform"), *GetPathNameSafe(GetOuter()), i);
}
}
}
示例4: AddConvexElemsToRigidActor
void UBodySetup::AddConvexElemsToRigidActor(PxRigidActor* PDestActor, const FTransform& RelativeTM, const FVector& Scale3D, const FVector& Scale3DAbs, TArray<PxShape*>* NewShapes) const
{
float ContactOffsetFactor, MaxContactOffset;
GetContactOffsetParams(ContactOffsetFactor, MaxContactOffset);
PxMaterial* PDefaultMat = GetDefaultPhysMaterial();
for (int32 i = 0; i < AggGeom.ConvexElems.Num(); i++)
{
const FKConvexElem& ConvexElem = AggGeom.ConvexElems[i];
if (ConvexElem.ConvexMesh)
{
PxTransform PLocalPose;
bool bUseNegX = CalcMeshNegScaleCompensation(Scale3D, PLocalPose);
PxConvexMeshGeometry PConvexGeom;
PConvexGeom.convexMesh = bUseNegX ? ConvexElem.ConvexMeshNegX : ConvexElem.ConvexMesh;
PConvexGeom.scale.scale = U2PVector(Scale3DAbs * ConvexElem.GetTransform().GetScale3D().GetAbs());
FTransform ConvexTransform = ConvexElem.GetTransform();
if (ConvexTransform.GetScale3D().X < 0 || ConvexTransform.GetScale3D().Y < 0 || ConvexTransform.GetScale3D().Z < 0)
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: [%s] ConvexElem[%d] has negative scale. Not currently supported"), *GetPathNameSafe(GetOuter()), i);
}
if (ConvexTransform.IsValid())
{
PxTransform PElementTransform = U2PTransform(ConvexTransform * RelativeTM);
PLocalPose.q *= PElementTransform.q;
PLocalPose.p = PElementTransform.p;
PLocalPose.p.x *= Scale3D.X;
PLocalPose.p.y *= Scale3D.Y;
PLocalPose.p.z *= Scale3D.Z;
if (PConvexGeom.isValid())
{
PxVec3 PBoundsExtents = PConvexGeom.convexMesh->getLocalBounds().getExtents();
ensure(PLocalPose.isValid());
PxShape* NewShape = PDestActor->createShape(PConvexGeom, *PDefaultMat, PLocalPose);
if (NewShapes)
{
NewShapes->Add(NewShape);
}
const float ContactOffset = FMath::Min(MaxContactOffset, ContactOffsetFactor * PBoundsExtents.minElement());
NewShape->setContactOffset(ContactOffset);
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: [%s] ConvexElem[%d] invalid"), *GetPathNameSafe(GetOuter()), i);
}
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: [%s] ConvexElem[%d] has invalid transform"), *GetPathNameSafe(GetOuter()), i);
}
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: ConvexElem is missing ConvexMesh (%d: %s)"), i, *GetPathName());
}
}
}
示例5: UpdateKinematicBonesToAnim
//.........这里部分代码省略.........
const UPhysicsAsset* const PhysicsAsset = GetPhysicsAsset();
if (PhysicsAsset && SkeletalMesh && Bodies.Num() > 0)
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if (!ensure(PhysicsAsset->BodySetup.Num() == Bodies.Num()))
{
// related to TTP 280315
UE_LOG(LogPhysics, Warning, TEXT("Mesh (%s) has PhysicsAsset(%s), and BodySetup(%d) and Bodies(%d) don't match"),
*SkeletalMesh->GetName(), *PhysicsAsset->GetName(), PhysicsAsset->BodySetup.Num(), Bodies.Num());
return;
}
#endif
#if WITH_PHYSX
// Lock the scenes we need (flags set in InitArticulated)
if(bHasBodiesInSyncScene)
{
SCENE_LOCK_WRITE(PhysScene->GetPhysXScene(PST_Sync))
}
if (bHasBodiesInAsyncScene)
{
SCENE_LOCK_WRITE(PhysScene->GetPhysXScene(PST_Async))
}
#endif
// Iterate over each body
for (int32 i = 0; i < Bodies.Num(); i++)
{
// If we have a physics body, and its kinematic...
FBodyInstance* BodyInst = Bodies[i];
check(BodyInst);
if (BodyInst->IsValidBodyInstance() && (bTeleport || !BodyInst->IsInstanceSimulatingPhysics()))
{
const int32 BoneIndex = BodyInst->InstanceBoneIndex;
// If we could not find it - warn.
if (BoneIndex == INDEX_NONE || BoneIndex >= GetNumSpaceBases())
{
const FName BodyName = PhysicsAsset->BodySetup[i]->BoneName;
UE_LOG(LogPhysics, Log, TEXT("UpdateRBBones: WARNING: Failed to find bone '%s' need by PhysicsAsset '%s' in SkeletalMesh '%s'."), *BodyName.ToString(), *PhysicsAsset->GetName(), *SkeletalMesh->GetName());
}
else
{
#if WITH_PHYSX
// update bone transform to world
const FTransform BoneTransform = InSpaceBases[BoneIndex] * CurrentLocalToWorld;
if(!BoneTransform.IsValid())
{
const FName BodyName = PhysicsAsset->BodySetup[i]->BoneName;
UE_LOG(LogPhysics, Warning, TEXT("UpdateKinematicBonesToAnim: Trying to set transform with bad data %s on PhysicsAsset '%s' in SkeletalMesh '%s' for bone '%s'"), *BoneTransform.ToHumanReadableString(), *PhysicsAsset->GetName(), *SkeletalMesh->GetName(), *BodyName.ToString());
BoneTransform.DiagnosticCheck_IsValid(); //In special nan mode we want to actually ensure
continue;
}
// If kinematic and not teleporting, set kinematic target
if (!BodyInst->IsInstanceSimulatingPhysics() && !bTeleport)
{
PhysScene->SetKinematicTarget_AssumesLocked(BodyInst, BoneTransform, true);
}
// Otherwise, set global pose
else
{
const PxTransform PNewPose = U2PTransform(BoneTransform);