本文整理汇总了C++中FPhysScene::MarkForPreSimKinematicUpdate方法的典型用法代码示例。如果您正苦于以下问题:C++ FPhysScene::MarkForPreSimKinematicUpdate方法的具体用法?C++ FPhysScene::MarkForPreSimKinematicUpdate怎么用?C++ FPhysScene::MarkForPreSimKinematicUpdate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPhysScene
的用法示例。
在下文中一共展示了FPhysScene::MarkForPreSimKinematicUpdate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateKinematicBonesToAnim
void USkeletalMeshComponent::UpdateKinematicBonesToAnim(const TArray<FTransform>& InSpaceBases, ETeleportType Teleport, bool bNeedsSkinning, EAllowKinematicDeferral DeferralAllowed)
{
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 we are only using bodies for physics, don't need to move them right away, can defer until simulation (unless told not to)
if(BodyInstance.GetCollisionEnabled() == ECollisionEnabled::PhysicsOnly && DeferralAllowed == EAllowKinematicDeferral::AllowDeferral)
{
PhysScene->MarkForPreSimKinematicUpdate(this, Teleport, bNeedsSkinning);
return;
}
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
// 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);
}
}
#endif
// 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
//.........这里部分代码省略.........