本文整理汇总了C++中FBodyInstance::GetUnrealWorldTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ FBodyInstance::GetUnrealWorldTransform方法的具体用法?C++ FBodyInstance::GetUnrealWorldTransform怎么用?C++ FBodyInstance::GetUnrealWorldTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FBodyInstance
的用法示例。
在下文中一共展示了FBodyInstance::GetUnrealWorldTransform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetClosestCollidingRigidBodyLocation
FVector USkeletalMeshComponent::GetClosestCollidingRigidBodyLocation(const FVector& TestLocation) const
{
float BestDistSq = BIG_NUMBER;
FVector Best = TestLocation;
UPhysicsAsset* PhysicsAsset = GetPhysicsAsset();
if( PhysicsAsset )
{
for (int32 i=0; i<Bodies.Num(); i++)
{
FBodyInstance* BodyInstance = Bodies[i];
if( BodyInstance && BodyInstance->IsValidBodyInstance() && (BodyInstance->GetCollisionEnabled() != ECollisionEnabled::NoCollision) )
{
const FVector BodyLocation = BodyInstance->GetUnrealWorldTransform().GetTranslation();
const float DistSq = (BodyLocation - TestLocation).SizeSquared();
if( DistSq < BestDistSq )
{
Best = BodyLocation;
BestDistSq = DistSq;
}
}
}
}
return Best;
}
示例2: SyncComponentsToBodies
void FPhysScene::SyncComponentsToBodies(uint32 SceneType)
{
#if WITH_PHYSX
PxScene* PScene = GetPhysXScene(SceneType);
check(PScene);
SCENE_LOCK_READ(PScene);
PxU32 NumTransforms = 0;
const PxActiveTransform* PActiveTransforms = PScene->getActiveTransforms(NumTransforms);
SCENE_UNLOCK_READ(PScene);
for(PxU32 TransformIdx=0; TransformIdx<NumTransforms; TransformIdx++)
{
const PxActiveTransform& PActiveTransform = PActiveTransforms[TransformIdx];
FBodyInstance* BodyInst = FPhysxUserData::Get<FBodyInstance>(PActiveTransform.userData);
if( BodyInst != NULL &&
BodyInst->InstanceBodyIndex == INDEX_NONE &&
BodyInst->OwnerComponent != NULL &&
BodyInst->IsInstanceSimulatingPhysics() )
{
check(BodyInst->OwnerComponent->IsRegistered()); // shouldn't have a physics body for a non-registered component!
AActor* Owner = BodyInst->OwnerComponent->GetOwner();
// See if the transform is actually different, and if so, move the component to match physics
const FTransform NewTransform = BodyInst->GetUnrealWorldTransform();
if(!NewTransform.EqualsNoScale(BodyInst->OwnerComponent->ComponentToWorld))
{
const FVector MoveBy = NewTransform.GetLocation() - BodyInst->OwnerComponent->ComponentToWorld.GetLocation();
const FRotator NewRotation = NewTransform.Rotator();
//UE_LOG(LogTemp, Log, TEXT("MOVING: %s"), *BodyInst->OwnerComponent->GetPathName());
//@warning: do not reference BodyInstance again after calling MoveComponent() - events from the move could have made it unusable (destroying the actor, SetPhysics(), etc)
BodyInst->OwnerComponent->MoveComponent(MoveBy, NewRotation, false, NULL, MOVECOMP_SkipPhysicsMove);
}
// Check if we didn't fall out of the world
if(Owner != NULL && !Owner->IsPendingKill())
{
Owner->CheckStillInWorld();
}
}
}
#endif
}
示例3: GetRigidBodyState
bool UPrimitiveComponent::GetRigidBodyState(FRigidBodyState& OutState, FName BoneName)
{
FBodyInstance* BI = GetBodyInstance(BoneName);
if (BI && BI->IsInstanceSimulatingPhysics())
{
FTransform BodyTM = BI->GetUnrealWorldTransform();
OutState.Position = BodyTM.GetTranslation();
OutState.Quaternion = BodyTM.GetRotation();
OutState.LinVel = BI->GetUnrealWorldVelocity();
OutState.AngVel = BI->GetUnrealWorldAngularVelocity();
OutState.Flags = (BI->IsInstanceAwake() ? ERigidBodyFlags::None : ERigidBodyFlags::Sleeping);
return true;
}
return false;
}