本文整理汇总了C++中USceneComponent类的典型用法代码示例。如果您正苦于以下问题:C++ USceneComponent类的具体用法?C++ USceneComponent怎么用?C++ USceneComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了USceneComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindClosestParentInList
USceneComponent* FComponentEditorUtils::FindClosestParentInList(UActorComponent* ChildComponent, const TArray<UActorComponent*>& ComponentList)
{
USceneComponent* ClosestParentComponent = nullptr;
for (auto Component : ComponentList)
{
auto ChildAsScene = Cast<USceneComponent>(ChildComponent);
auto SceneComponent = Cast<USceneComponent>(Component);
if (ChildAsScene && SceneComponent)
{
// Check to see if any parent is also in the list
USceneComponent* Parent = ChildAsScene->GetAttachParent();
while (Parent != nullptr)
{
if (ComponentList.Contains(Parent))
{
ClosestParentComponent = SceneComponent;
break;
}
Parent = Parent->GetAttachParent();
}
}
}
return ClosestParentComponent;
}
示例2: GetActorsToIgnore
static void GetActorsToIgnore( AActor* Actor, TSet< TWeakObjectPtr<AActor> >& ActorsToIgnore )
{
if( !ActorsToIgnore.Contains( Actor ) )
{
ActorsToIgnore.Add( Actor );
// We cannot snap to any attached children or actors in the same group as moving this actor will also move the children as we are snapping to them,
// causing a cascading effect and unexpected results
TArray<USceneComponent*>& AttachedChildren = Actor->GetRootComponent()->AttachChildren;
for( int32 ChildIndex = 0; ChildIndex < AttachedChildren.Num(); ++ChildIndex )
{
USceneComponent* Child = AttachedChildren[ChildIndex];
if( Child && Child->GetOwner() )
{
ActorsToIgnore.Add( Child->GetOwner() );
}
}
AGroupActor* ParentGroup = AGroupActor::GetRootForActor(Actor, true, true);
if( ParentGroup )
{
TArray<AActor*> GroupActors;
ParentGroup->GetGroupActors(GroupActors, true);
for( int32 GroupActorIndex = 0; GroupActorIndex < GroupActors.Num(); ++GroupActorIndex )
{
ActorsToIgnore.Add( GroupActors[GroupActorIndex] );
}
}
}
}
示例3: GetPreviewActor
FVector FSCSEditorViewportClient::GetWidgetLocation() const
{
FVector Location = FVector::ZeroVector;
AActor* PreviewActor = GetPreviewActor();
if(PreviewActor)
{
TArray<FSCSEditorTreeNodePtrType> SelectedNodes = BlueprintEditorPtr.Pin()->GetSelectedSCSEditorTreeNodes();
if(SelectedNodes.Num() > 0)
{
// Use the last selected item for the widget location
USceneComponent* SceneComp = Cast<USceneComponent>(SelectedNodes.Last().Get()->FindComponentInstanceInActor(PreviewActor));
if( SceneComp )
{
TSharedPtr<ISCSEditorCustomization> Customization = BlueprintEditorPtr.Pin()->CustomizeSCSEditor(SceneComp);
FVector CustomLocation;
if(Customization.IsValid() && Customization->HandleGetWidgetLocation(SceneComp, CustomLocation))
{
Location = CustomLocation;
}
else
{
Location = SceneComp->GetComponentLocation();
}
}
}
}
return Location;
}
示例4: EditorErrors
void FActorDropTarget::OnDrop(FDragDropPayload& DraggedObjects, UWorld& World, const FDragValidationInfo& ValidationInfo, TSharedRef<SWidget> DroppedOnWidget)
{
AActor* DropActor = Actor.Get();
if (!DropActor)
{
return;
}
FActorArray DraggedActors = DraggedObjects.Actors.GetValue();
FMessageLog EditorErrors("EditorErrors");
EditorErrors.NewPage(LOCTEXT("ActorAttachmentsPageLabel", "Actor attachment"));
if (ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleMultipleDetach || ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleDetach)
{
const FScopedTransaction Transaction( LOCTEXT("UndoAction_DetachActors", "Detach actors") );
for (const auto& WeakActor : DraggedActors)
{
if (auto* DragActor = WeakActor.Get())
{
DetachActorFromParent(DragActor);
}
}
}
else if (ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleMultipleAttach || ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleAttach)
{
// Show socket chooser if we have sockets to select
//@TODO: Should create a menu for each component that contains sockets, or have some form of disambiguation within the menu (like a fully qualified path)
// Instead, we currently only display the sockets on the root component
USceneComponent* Component = DropActor->GetRootComponent();
if ((Component != NULL) && (Component->HasAnySockets()))
{
// Create the popup
FSlateApplication::Get().PushMenu(
DroppedOnWidget,
SNew(SSocketChooserPopup)
.SceneComponent( Component )
.OnSocketChosen_Static(&FActorDropTarget::PerformAttachment, Actor, MoveTemp(DraggedActors) ),
FSlateApplication::Get().GetCursorPos(),
FPopupTransitionEffect( FPopupTransitionEffect::TypeInPopup )
);
}
else
{
PerformAttachment(NAME_None, Actor, MoveTemp(DraggedActors));
}
}
// Report errors
EditorErrors.Notify(NSLOCTEXT("ActorAttachmentError", "AttachmentsFailed", "Attachments Failed!"));
}
示例5: GetWorld
AActor* UVREditorMode::SpawnTransientSceneActor(TSubclassOf<AActor> ActorClass, const FString& ActorName, const bool bWithSceneComponent) const
{
const bool bWasWorldPackageDirty = GetWorld()->GetOutermost()->IsDirty();
// @todo vreditor: Needs respawn if world changes (map load, etc.) Will that always restart the editor mode anyway?
FActorSpawnParameters ActorSpawnParameters;
ActorSpawnParameters.Name = MakeUniqueObjectName( GetWorld(), ActorClass, *ActorName ); // @todo vreditor: Without this, SpawnActor() can return us an existing PendingKill actor of the same name! WTF?
ActorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
ActorSpawnParameters.ObjectFlags = EObjectFlags::RF_Transient;
check( ActorClass != nullptr );
AActor* NewActor = GetWorld()->SpawnActor< AActor >( ActorClass, ActorSpawnParameters );
NewActor->SetActorLabel( ActorName );
if( bWithSceneComponent )
{
// Give the new actor a root scene component, so we can attach multiple sibling components to it
USceneComponent* SceneComponent = NewObject<USceneComponent>( NewActor );
NewActor->AddOwnedComponent( SceneComponent );
NewActor->SetRootComponent( SceneComponent );
SceneComponent->RegisterComponent();
}
// Don't dirty the level file after spawning a transient actor
if( !bWasWorldPackageDirty )
{
GetWorld()->GetOutermost()->SetDirtyFlag( false );
}
return NewActor;
}
示例6: DestroyChildActor
void UChildActorComponent::OnRegister()
{
Super::OnRegister();
if (ChildActor)
{
if (ChildActor->GetClass() != ChildActorClass)
{
DestroyChildActor();
CreateChildActor();
}
else
{
ChildActorName = ChildActor->GetFName();
USceneComponent* ChildRoot = ChildActor->GetRootComponent();
if (ChildRoot && ChildRoot->GetAttachParent() != this)
{
// attach new actor to this component
// we can't attach in CreateChildActor since it has intermediate Mobility set up
// causing spam with inconsistent mobility set up
// so moving Attach to happen in Register
ChildRoot->AttachTo(this, NAME_None, EAttachLocation::SnapToTarget);
}
}
}
else if (ChildActorClass)
{
CreateChildActor();
}
}
示例7: AttachComponentOfClass
UActorComponent* UActorBlueprintLibrary::AttachComponentOfClass(UObject* WorldContextObject, TSubclassOf<UActorComponent> ComponentClass, AActor* Owner, FName ComponentName, USceneComponent* AttachTo, FName SocketName)
{
if (!Owner)
{
return nullptr;
}
UActorComponent* Component = NewObject<UActorComponent>(Owner, *ComponentClass, ComponentName);
if (!Component)
{
return nullptr;
}
Component->RegisterComponent();
Component->OnComponentCreated();
USceneComponent* SceneComponent = Cast<USceneComponent>(Component);
if (SceneComponent)
{
SceneComponent->SetWorldLocation(Owner->GetActorLocation());
SceneComponent->SetWorldRotation(Owner->GetActorRotation());
USceneComponent* AttachToComponent = AttachTo ? AttachTo : Owner->GetRootComponent();
SceneComponent->AttachToComponent(AttachToComponent, FAttachmentTransformRules::KeepWorldTransform, SocketName);
}
return Component;
}
示例8: DestroyChildActor
void UChildActorComponent::OnRegister()
{
Super::OnRegister();
if (ChildActor)
{
if (ChildActor->GetClass() != ChildActorClass)
{
DestroyChildActor();
CreateChildActor();
}
else
{
ChildActorName = ChildActor->GetFName();
USceneComponent* ChildRoot = ChildActor->GetRootComponent();
if (ChildRoot && ChildRoot->GetAttachParent() != this)
{
// attach new actor to this component
// we can't attach in CreateChildActor since it has intermediate Mobility set up
// causing spam with inconsistent mobility set up
// so moving Attach to happen in Register
ChildRoot->AttachToComponent(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
}
// Ensure the components replication is correctly initialized
SetIsReplicated(ChildActor->GetIsReplicated());
}
}
else if (ChildActorClass)
{
CreateChildActor();
}
}
示例9: if
FTransform FMovieScene3DTransformSectionRecorder::GetTransformToRecord()
{
if(USceneComponent* SceneComponent = Cast<USceneComponent>(ObjectToRecord.Get()))
{
return SceneComponent->GetRelativeTransform();
}
else if(AActor* Actor = Cast<AActor>(ObjectToRecord.Get()))
{
bool bCaptureWorldSpaceTransform = false;
USceneComponent* RootComponent = Actor->GetRootComponent();
USceneComponent* AttachParent = RootComponent ? RootComponent->GetAttachParent() : nullptr;
bWasAttached = AttachParent != nullptr;
if (AttachParent)
{
// We capture world space transforms for actors if they're attached, but we're not recording the attachment parent
bCaptureWorldSpaceTransform = !FSequenceRecorder::Get().FindRecording(AttachParent->GetOwner());
}
return (bCaptureWorldSpaceTransform || !RootComponent) ? Actor->ActorToWorld() : RootComponent->GetRelativeTransform();
}
return FTransform::Identity;
}
示例10: GetClass
UActorComponent* AActor::AddComponent(FName TemplateName, bool bManualAttachment, const FTransform& RelativeTransform, const UObject* ComponentTemplateContext)
{
UActorComponent* Template = nullptr;
UBlueprintGeneratedClass* BlueprintGeneratedClass = Cast<UBlueprintGeneratedClass>((ComponentTemplateContext != nullptr) ? ComponentTemplateContext->GetClass() : GetClass());
while(BlueprintGeneratedClass != nullptr)
{
Template = BlueprintGeneratedClass->FindComponentTemplateByName(TemplateName);
if(nullptr != Template)
{
break;
}
BlueprintGeneratedClass = Cast<UBlueprintGeneratedClass>(BlueprintGeneratedClass->GetSuperClass());
}
bool bIsSceneComponent = false;
UActorComponent* NewActorComp = CreateComponentFromTemplate(Template);
if(NewActorComp != nullptr)
{
// Call function to notify component it has been created
NewActorComp->OnComponentCreated();
// The user has the option of doing attachment manually where they have complete control or via the automatic rule
// that the first component added becomes the root component, with subsequent components attached to the root.
USceneComponent* NewSceneComp = Cast<USceneComponent>(NewActorComp);
if(NewSceneComp != nullptr)
{
if (!bManualAttachment)
{
if (RootComponent == nullptr)
{
RootComponent = NewSceneComp;
}
else
{
NewSceneComp->AttachTo(RootComponent);
}
}
NewSceneComp->SetRelativeTransform(RelativeTransform);
bIsSceneComponent = true;
}
// Register component, which will create physics/rendering state, now component is in correct position
NewActorComp->RegisterComponent();
UWorld* World = GetWorld();
if (!bRunningUserConstructionScript && World && bIsSceneComponent)
{
UPrimitiveComponent* NewPrimitiveComponent = Cast<UPrimitiveComponent>(NewActorComp);
if (NewPrimitiveComponent && ACullDistanceVolume::CanBeAffectedByVolumes(NewPrimitiveComponent))
{
World->UpdateCullDistanceVolumes(this, NewPrimitiveComponent);
}
}
}
return NewActorComp;
}
示例11: check
UActorComponent* FComponentEditorUtils::DuplicateComponent(UActorComponent* TemplateComponent)
{
check(TemplateComponent);
UActorComponent* NewCloneComponent = nullptr;
AActor* Actor = TemplateComponent->GetOwner();
if (!TemplateComponent->IsEditorOnly() && Actor)
{
Actor->Modify();
UClass* ComponentClass = TemplateComponent->GetClass();
FName NewComponentName = *FComponentEditorUtils::GenerateValidVariableName(ComponentClass, Actor);
bool bKeepWorldLocationOnAttach = false;
const bool bTemplateTransactional = TemplateComponent->HasAllFlags(RF_Transactional);
TemplateComponent->SetFlags(RF_Transactional);
NewCloneComponent = DuplicateObject<UActorComponent>(TemplateComponent, Actor, NewComponentName );
if (!bTemplateTransactional)
{
TemplateComponent->ClearFlags(RF_Transactional);
}
USceneComponent* NewSceneComponent = Cast<USceneComponent>(NewCloneComponent);
if (NewSceneComponent)
{
// Ensure the clone doesn't think it has children
NewSceneComponent->AttachChildren.Empty();
// If the clone is a scene component without an attach parent, attach it to the root (can happen when duplicating the root component)
if (!NewSceneComponent->GetAttachParent())
{
USceneComponent* RootComponent = Actor->GetRootComponent();
check(RootComponent);
// ComponentToWorld is not a UPROPERTY, so make sure the clone has calculated it properly before attachment
NewSceneComponent->UpdateComponentToWorld();
NewSceneComponent->AttachTo(RootComponent, NAME_None, EAttachLocation::KeepWorldPosition);
}
}
NewCloneComponent->OnComponentCreated();
// Add to SerializedComponents array so it gets saved
Actor->AddInstanceComponent(NewCloneComponent);
// Register the new component
NewCloneComponent->RegisterComponent();
// Rerun construction scripts
Actor->RerunConstructionScripts();
}
return NewCloneComponent;
}
示例12: DetachActorFromParent
void FActorDropTarget::DetachActorFromParent(AActor* ChildActor)
{
USceneComponent* RootComp = ChildActor->GetRootComponent();
if (RootComp && RootComp->AttachParent)
{
AActor* OldParent = RootComp->AttachParent->GetOwner();
OldParent->Modify();
RootComp->DetachFromParent(true);
ChildActor->SetFolderPath(OldParent->GetFolderPath());
}
}
示例13: GetAttachmentDepth
int32 GetAttachmentDepth(USceneComponent* Component)
{
int32 Depth = 0;
USceneComponent* Parent = Component->GetAttachParent();
while (Parent)
{
++Depth;
Parent = Parent->GetAttachParent();
}
return Depth;
}
示例14: GetActorToRecord
void UActorRecording::GetSceneComponents(TArray<USceneComponent*>& OutArray, bool bIncludeNonCDO/*=true*/)
{
// it is not enough to just go through the owned components array here
// we need to traverse the scene component hierarchy as well, as some components may be
// owned by other actors (e.g. for pooling) and some may not be part of the hierarchy
if(GetActorToRecord() != nullptr)
{
USceneComponent* RootComponent = GetActorToRecord()->GetRootComponent();
if(RootComponent)
{
// note: GetChildrenComponents clears array!
RootComponent->GetChildrenComponents(true, OutArray);
OutArray.Add(RootComponent);
}
// add owned components that are *not* part of the hierarchy
TInlineComponentArray<USceneComponent*> OwnedComponents(GetActorToRecord());
for(USceneComponent* OwnedComponent : OwnedComponents)
{
check(OwnedComponent);
if(OwnedComponent->GetAttachParent() == nullptr && OwnedComponent != RootComponent)
{
OutArray.Add(OwnedComponent);
}
}
if(!bIncludeNonCDO)
{
AActor* CDO = Cast<AActor>(GetActorToRecord()->GetClass()->GetDefaultObject());
auto ShouldRemovePredicate = [&](UActorComponent* PossiblyRemovedComponent)
{
// try to find a component with this name in the CDO
for (UActorComponent* SearchComponent : CDO->GetComponents())
{
if (SearchComponent->GetClass() == PossiblyRemovedComponent->GetClass() &&
SearchComponent->GetFName() == PossiblyRemovedComponent->GetFName())
{
return false;
}
}
// remove if its not found
return true;
};
OutArray.RemoveAllSwap(ShouldRemovePredicate);
}
}
}
示例15:
void FMovieScene3DConstraintTrackInstance::SaveState(const TArray<UObject*>& RuntimeObjects, IMovieScenePlayer& Player, FMovieSceneSequenceInstance& SequenceInstance)
{
for (int32 ObjIndex = 0; ObjIndex < RuntimeObjects.Num(); ++ObjIndex)
{
USceneComponent* SceneComponent = MovieSceneHelpers::SceneComponentFromRuntimeObject(RuntimeObjects[ObjIndex]);
if (SceneComponent != nullptr)
{
if (InitTransformMap.Find(RuntimeObjects[ObjIndex]) == nullptr)
{
InitTransformMap.Add(RuntimeObjects[ObjIndex], SceneComponent->GetRelativeTransform());
}
}
}
}