本文整理汇总了C++中FBodyInstance::InitBody方法的典型用法代码示例。如果您正苦于以下问题:C++ FBodyInstance::InitBody方法的具体用法?C++ FBodyInstance::InitBody怎么用?C++ FBodyInstance::InitBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FBodyInstance
的用法示例。
在下文中一共展示了FBodyInstance::InitBody方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnWeldFromParent
void UPrimitiveComponent::UnWeldFromParent()
{
FBodyInstance* NewRootBI = GetBodyInstance(NAME_None, false);
UWorld* CurrentWorld = GetWorld();
if (NewRootBI == NULL || NewRootBI->bWelded == false || CurrentWorld == nullptr || IsPendingKill())
{
return;
}
FName SocketName;
UPrimitiveComponent * RootComponent = GetRootWelded(this, AttachSocketName, &SocketName);
if (RootComponent)
{
if (FBodyInstance* RootBI = RootComponent->GetBodyInstance(SocketName, false))
{
bool bRootIsBeingDeleted = RootComponent->HasAnyFlags(RF_PendingKill) || RootComponent->HasAnyFlags(RF_Unreachable);
if (!bRootIsBeingDeleted)
{
//create new root
RootBI->UnWeld(NewRootBI); //don't bother fixing up shapes if RootComponent is about to be deleted
}
NewRootBI->bWelded = false;
const FBodyInstance* PrevWeldParent = NewRootBI->WeldParent;
NewRootBI->WeldParent = nullptr;
bool bHasBodySetup = GetBodySetup() != nullptr;
//if BodyInstance hasn't already been created we need to initialize it
if (bHasBodySetup && NewRootBI->IsValidBodyInstance() == false)
{
bool bPrevAutoWeld = NewRootBI->bAutoWeld;
NewRootBI->bAutoWeld = false;
NewRootBI->InitBody(GetBodySetup(), GetComponentToWorld(), this, CurrentWorld->GetPhysicsScene());
NewRootBI->bAutoWeld = bPrevAutoWeld;
}
if(PrevWeldParent == nullptr) //our parent is kinematic so no need to do any unwelding/rewelding of children
{
return;
}
//now weld its children to it
TArray<FBodyInstance*> ChildrenBodies;
TArray<FName> ChildrenLabels;
GetWeldedBodies(ChildrenBodies, ChildrenLabels);
for (int32 ChildIdx = 0; ChildIdx < ChildrenBodies.Num(); ++ChildIdx)
{
FBodyInstance* ChildBI = ChildrenBodies[ChildIdx];
if (ChildBI != NewRootBI)
{
if (!bRootIsBeingDeleted)
{
RootBI->UnWeld(ChildBI);
}
//At this point, NewRootBI must be kinematic because it's being unwelded. It's up to the code that simulates to call Weld on the children as needed
ChildBI->WeldParent = nullptr; //null because we are currently kinematic
}
}
}
}
}