本文整理汇总了C++中FBodyInstance::GetPxRigidActor_AssumesLocked方法的典型用法代码示例。如果您正苦于以下问题:C++ FBodyInstance::GetPxRigidActor_AssumesLocked方法的具体用法?C++ FBodyInstance::GetPxRigidActor_AssumesLocked怎么用?C++ FBodyInstance::GetPxRigidActor_AssumesLocked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FBodyInstance
的用法示例。
在下文中一共展示了FBodyInstance::GetPxRigidActor_AssumesLocked方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateKinematicBonesToAnim
//.........这里部分代码省略.........
}
#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);
ensure(PNewPose.isValid());
PxRigidActor* RigidActor = BodyInst->GetPxRigidActor_AssumesLocked(); // This should never fail because IsValidBodyInstance() passed above
RigidActor->setGlobalPose(PNewPose);
}
#endif
// now update scale
// if uniform, we'll use BoneTranform
if (MeshScale3D.IsUniform())
{
// @todo UE4 should we update scale when it's simulated?
BodyInst->UpdateBodyScale(BoneTransform.GetScale3D());
}
else
{
// @note When you have non-uniform scale on mesh base,
// hierarchical bone transform can update scale too often causing performance issue
// So we just use mesh scale for all bodies when non-uniform
// This means physics representation won't be accurate, but
// it is performance friendly by preventing too frequent physics update
BodyInst->UpdateBodyScale(MeshScale3D);
}
}
}
else
{
//make sure you have physics weight or blendphysics on, otherwise, you'll have inconsistent representation of bodies
// @todo make this to be kismet log? But can be too intrusive
if (!bBlendPhysics && BodyInst->PhysicsBlendWeight <= 0.f && BodyInst->BodySetup.IsValid())
{
//It's not clear whether this should be a warning. There are certainly cases where you interpolate the blend weight towards 0. The blend feature needs some work which will probably change this in the future.
//Making it Verbose for now
UE_LOG(LogPhysics, Verbose, TEXT("%s(Mesh %s, PhysicsAsset %s, Bone %s) is simulating, but no blending. "),
*GetName(), *GetNameSafe(SkeletalMesh), *GetNameSafe(PhysicsAsset), *BodyInst->BodySetup.Get()->BoneName.ToString());
}
}
}
#if WITH_PHYSX
// Unlock the scenes
if (bHasBodiesInSyncScene)
{
SCENE_UNLOCK_WRITE(PhysScene->GetPhysXScene(PST_Sync))
}
if (bHasBodiesInAsyncScene)
{
SCENE_UNLOCK_WRITE(PhysScene->GetPhysXScene(PST_Async))
}
#endif
}
}
else
{
//per poly update requires us to update all vertex positions
if (MeshObject)