本文整理汇总了C++中FTransform::ContainsNaN方法的典型用法代码示例。如果您正苦于以下问题:C++ FTransform::ContainsNaN方法的具体用法?C++ FTransform::ContainsNaN怎么用?C++ FTransform::ContainsNaN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FTransform
的用法示例。
在下文中一共展示了FTransform::ContainsNaN方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateKinematicBonesToAnim
void USkeletalMeshComponent::UpdateKinematicBonesToAnim(const TArray<FTransform>& InSpaceBases, ETeleportType Teleport, bool bNeedsSkinning)
{
SCOPE_CYCLE_COUNTER(STAT_UpdateRBBones);
// This below code produces some interesting result here
// - below codes update physics data, so if you don't update pose, the physics won't have the right result
// - but if we just update physics bone without update current pose, it will have stale data
// If desired, pass the animation data to the physics joints so they can be used by motors.
// See if we are going to need to update kinematics
const bool bUpdateKinematics = (KinematicBonesUpdateType != EKinematicBonesUpdateToPhysics::SkipAllBones);
const bool bTeleport = Teleport == ETeleportType::TeleportPhysics;
// If desired, update physics bodies associated with skeletal mesh component to match.
if(!bUpdateKinematics && !(bTeleport && IsAnySimulatingPhysics()))
{
// nothing to do
return;
}
// Get the scene, and do nothing if we can't get one.
FPhysScene* PhysScene = nullptr;
if (GetWorld() != nullptr)
{
PhysScene = GetWorld()->GetPhysicsScene();
}
if(PhysScene == nullptr)
{
return;
}
const FTransform& CurrentLocalToWorld = ComponentToWorld;
// Gracefully handle NaN
if(CurrentLocalToWorld.ContainsNaN())
{
return;
}
// If desired, draw the skeleton at the point where we pass it to the physics.
if (bShowPrePhysBones && SkeletalMesh && InSpaceBases.Num() == SkeletalMesh->RefSkeleton.GetNum())
{
for (int32 i = 1; i<InSpaceBases.Num(); i++)
{
FVector ThisPos = CurrentLocalToWorld.TransformPosition(InSpaceBases[i].GetLocation());
int32 ParentIndex = SkeletalMesh->RefSkeleton.GetParentIndex(i);
FVector ParentPos = CurrentLocalToWorld.TransformPosition(InSpaceBases[ParentIndex].GetLocation());
GetWorld()->LineBatcher->DrawLine(ThisPos, ParentPos, AnimSkelDrawColor, SDPG_Foreground);
}
}
// warn if it has non-uniform scale
const FVector& MeshScale3D = CurrentLocalToWorld.GetScale3D();
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if( !MeshScale3D.IsUniform() )
{
UE_LOG(LogPhysics, Log, TEXT("USkeletalMeshComponent::UpdateKinematicBonesToAnim : Non-uniform scale factor (%s) can cause physics to mismatch for %s SkelMesh: %s"), *MeshScale3D.ToString(), *GetFullName(), SkeletalMesh ? *SkeletalMesh->GetFullName() : TEXT("NULL"));
}
#endif
if (bEnablePerPolyCollision == false)
{
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 (bTeleport || (BodyInst->IsValidBodyInstance() && !BodyInst->IsInstanceSimulatingPhysics()))
{
const int32 BoneIndex = BodyInst->InstanceBoneIndex;
//.........这里部分代码省略.........
示例2: AddedTransform
//.........这里部分代码省略.........
FName BoneName = FbxRawBoneNames[SourceTrackIdx];
int32 BoneTreeIndex = RefSkeleton.FindBoneIndex(BoneName);
// update status
FFormatNamedArguments Args;
Args.Add(TEXT("TrackName"), FText::FromName(BoneName));
Args.Add(TEXT("TotalKey"), FText::AsNumber(NumSamplingKeys));
Args.Add(TEXT("TrackIndex"), FText::AsNumber(SourceTrackIdx+1));
Args.Add(TEXT("TotalTracks"), FText::AsNumber(FbxRawBoneNames.Num()));
const FText StatusUpate = FText::Format(LOCTEXT("ImportingAnimTrackDetail", "Importing Animation Track [{TrackName}] ({TrackIndex}/{TotalTracks}) - TotalKey {TotalKey}"), Args);
GWarn->StatusForceUpdate(SourceTrackIdx + 1, FbxRawBoneNames.Num(), StatusUpate);
if (BoneTreeIndex!=INDEX_NONE)
{
bool bSuccess = true;
FRawAnimSequenceTrack RawTrack;
RawTrack.PosKeys.Empty();
RawTrack.RotKeys.Empty();
RawTrack.ScaleKeys.Empty();
AnimationTransformDebug::FAnimationTransformDebugData NewDebugData;
FbxNode* Link = SortedLinks[SourceTrackIdx];
FbxNode * LinkParent = Link->GetParent();
for(FbxTime CurTime = AnimTimeSpan.GetStart(); CurTime <= AnimTimeSpan.GetStop(); CurTime += TimeIncrement)
{
// save global trasnform
FbxAMatrix GlobalMatrix = Link->EvaluateGlobalTransform(CurTime);
// we'd like to verify this before going to Transform.
// currently transform has tons of NaN check, so it will crash there
FMatrix GlobalUEMatrix = Converter.ConvertMatrix(GlobalMatrix);
if (GlobalUEMatrix.ContainsNaN())
{
bSuccess = false;
AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Error, FText::Format(LOCTEXT("Error_InvalidTransform",
"Track {0} contains invalid transform. Could not import the track."), FText::FromName(BoneName))), FFbxErrors::Animation_TransformError);
break;
}
FTransform GlobalTransform = Converter.ConvertTransform(GlobalMatrix);
if (GlobalTransform.ContainsNaN())
{
bSuccess = false;
AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Error, FText::Format(LOCTEXT("Error_InvalidUnrealTransform",
"Track {0} did not yeild valid transform. Please report this to animation team."), FText::FromName(BoneName))), FFbxErrors::Animation_TransformError);
break;
}
// debug data, including import transformation
FTransform AddedTransform(AddedMatrix);
NewDebugData.SourceGlobalTransform.Add(GlobalTransform * AddedTransform);
FTransform LocalTransform;
if( !bPreserveLocalTransform && LinkParent)
{
// I can't rely on LocalMatrix. I need to recalculate quaternion/scale based on global transform if Parent exists
FbxAMatrix ParentGlobalMatrix = Link->GetParent()->EvaluateGlobalTransform(CurTime);
FTransform ParentGlobalTransform = Converter.ConvertTransform(ParentGlobalMatrix);
LocalTransform = GlobalTransform.GetRelativeTransform(ParentGlobalTransform);
NewDebugData.SourceParentGlobalTransform.Add(ParentGlobalTransform);
}
else
{
示例3: ProcessAnimationTracks
//.........这里部分代码省略.........
Key = AlignedKey;
}
}
}
}
}
}
if (NumPosKeys > 0 && ParentBoneIndex != INDEX_NONE)
{
// update our bone table from the current bone through the last end effector we need to test
UpdateWorldBoneTransformRange(
AnimSeq,
BoneData,
RefPose,
PositionTracks,
RotationTracks,
ScaleTracks,
BoneIndex,
HighestTargetBoneIndex,
false,
NewWorldBones);
// adjust all translation keys to align better with the destination
for ( int32 KeyIndex = 0; KeyIndex < NumPosKeys; ++KeyIndex )
{
FVector& Key= TransTrack.PosKeys[KeyIndex];
const int32 FrameIndex= FMath::Clamp(KeyIndex, 0, LastFrame);
FTransform NewWorldParent = NewWorldBones[(ParentBoneIndex*NumFrames) + FrameIndex];
FTransform RawWorldChild = RawWorldBones[(BoneIndex*NumFrames) + FrameIndex];
const FTransform& RelTM = RawWorldChild.GetRelativeTransform(NewWorldParent);
const FTransform Delta = FTransform(RelTM);
ensure (!Delta.ContainsNaN());
Key = Delta.GetTranslation();
}
}
}
// look for a parent track to reference as a guide
int32 GuideTrackIndex = INDEX_NONE;
if (ParentKeyScale > 1.0f)
{
for (long FamilyIndex=0; (FamilyIndex < Bone.BonesToRoot.Num()) && (GuideTrackIndex == INDEX_NONE); ++FamilyIndex)
{
const int32 NextParentBoneIndex= Bone.BonesToRoot[FamilyIndex];
GuideTrackIndex = AnimSeq->GetSkeleton()->GetAnimationTrackIndex(NextParentBoneIndex, AnimSeq);
}
}
// update our bone table from the current bone through the last end effector we need to test
UpdateWorldBoneTransformRange(
AnimSeq,
BoneData,
RefPose,
PositionTracks,
RotationTracks,
ScaleTracks,
BoneIndex,
HighestTargetBoneIndex,
false,
NewWorldBones);