TArray<FPropertySoftPath> DiffUtils::GetVisiblePropertiesInOrderDeclared(const UObject* ForObj, const TArray<FName>& Scope /*= TArray<FName>()*/) { TArray<FPropertySoftPath> Ret; if (ForObj) { const UClass* Class = ForObj->GetClass(); TSet<FString> HiddenCategories = FEditorCategoryUtils::GetHiddenCategories(Class); for (TFieldIterator<UProperty> PropertyIt(Class); PropertyIt; ++PropertyIt) { FName CategoryName = FObjectEditorUtils::GetCategoryFName(*PropertyIt); if (!HiddenCategories.Contains(CategoryName.ToString())) { if (PropertyIt->PropertyFlags&CPF_Edit) { TArray<FName> NewPath(Scope); NewPath.Push(PropertyIt->GetFName()); if (const UObjectProperty* ObjectProperty = Cast<UObjectProperty>(*PropertyIt)) { const UObject* const* BaseObject = reinterpret_cast<const UObject* const*>( ObjectProperty->ContainerPtrToValuePtr<void>(ForObj) ); if (BaseObject && *BaseObject) { Ret.Append( GetVisiblePropertiesInOrderDeclared(*BaseObject, NewPath) ); } } else { Ret.Push(NewPath); } } } } } return Ret; }
void FBlueprintNativeCodeGenModule::Convert(UPackage* Package, ESavePackageResult CookResult, const TCHAR* PlatformName) { // Find the struct/enum to convert: UStruct* Struct = nullptr; UEnum* Enum = nullptr; GetFieldFormPackage(Package, Struct, Enum); // First we gather information about bound functions. UClass* AsClass = Cast<UClass>(Struct); UBlueprint* BP = AsClass ? Cast<UBlueprint>(AsClass->ClassGeneratedBy) : nullptr; if (BP) { CollectBoundFunctions(BP); } if (CookResult != ESavePackageResult::ReplaceCompletely && CookResult != ESavePackageResult::GenerateStub) { // nothing to convert return; } if (Struct == nullptr && Enum == nullptr) { ensure(false); return; } if (CookResult == ESavePackageResult::GenerateStub) { if (ensure(BP)) { ensure(!ToGenerate.Contains(BP)); AllPotentialStubs.Add(BP); } } else { check(CookResult == ESavePackageResult::ReplaceCompletely); if (AsClass) { if (ensure(BP)) { ensure(!AllPotentialStubs.Contains(BP)); ToGenerate.Add(BP); } } else { UField* ForConversion = Struct ? (UField*)Struct : (UField*)Enum; GenerateSingleAsset(ForConversion, PlatformName); } } }
FText STileLayerList::GenerateDuplicatedLayerName(const FString& InputNameRaw, UPaperTileMap* TileMap) { // Create a set of existing names TSet<FString> ExistingNames; for (UPaperTileLayer* ExistingLayer : TileMap->TileLayers) { ExistingNames.Add(ExistingLayer->LayerName.ToString()); } FString BaseName = InputNameRaw; int32 TestIndex = 0; bool bAddNumber = false; // See if this is the result of a previous duplication operation, and change the desired name accordingly int32 SpaceIndex; if (InputNameRaw.FindLastChar(' ', /*out*/ SpaceIndex)) { FString PossibleDuplicationSuffix = InputNameRaw.Mid(SpaceIndex + 1); if (PossibleDuplicationSuffix == TEXT("copy")) { bAddNumber = true; BaseName = InputNameRaw.Left(SpaceIndex); TestIndex = 2; } else { int32 ExistingIndex = FCString::Atoi(*PossibleDuplicationSuffix); const FString TestSuffix = FString::Printf(TEXT(" copy %d"), ExistingIndex); if (InputNameRaw.EndsWith(TestSuffix)) { bAddNumber = true; BaseName = InputNameRaw.Left(InputNameRaw.Len() - TestSuffix.Len()); TestIndex = ExistingIndex + 1; } } } // Find a good name FString TestLayerName = BaseName + TEXT(" copy"); if (bAddNumber || ExistingNames.Contains(TestLayerName)) { do { TestLayerName = FString::Printf(TEXT("%s copy %d"), *BaseName, TestIndex++); } while (ExistingNames.Contains(TestLayerName)); } return FText::FromString(TestLayerName); }
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] ); } } } }
void FComponentEditorUtils::PropagateTransformPropertyChange( class USceneComponent* InSceneComponentTemplate, const FTransformData& OldDefaultTransform, const FTransformData& NewDefaultTransform, TSet<class USceneComponent*>& UpdatedComponents) { check(InSceneComponentTemplate != nullptr); TArray<UObject*> ArchetypeInstances; FComponentEditorUtils::GetArchetypeInstances(InSceneComponentTemplate, ArchetypeInstances); for(int32 InstanceIndex = 0; InstanceIndex < ArchetypeInstances.Num(); ++InstanceIndex) { USceneComponent* InstancedSceneComponent = FComponentEditorUtils::GetSceneComponent(ArchetypeInstances[InstanceIndex], InSceneComponentTemplate); if(InstancedSceneComponent != nullptr && !UpdatedComponents.Contains(InstancedSceneComponent)) { static const UProperty* RelativeLocationProperty = FindFieldChecked<UProperty>( USceneComponent::StaticClass(), "RelativeLocation" ); if(RelativeLocationProperty != nullptr) { PropagateTransformPropertyChange(InstancedSceneComponent, RelativeLocationProperty, OldDefaultTransform.Trans, NewDefaultTransform.Trans, UpdatedComponents); } static const UProperty* RelativeRotationProperty = FindFieldChecked<UProperty>( USceneComponent::StaticClass(), "RelativeRotation" ); if(RelativeRotationProperty != nullptr) { PropagateTransformPropertyChange(InstancedSceneComponent, RelativeRotationProperty, OldDefaultTransform.Rot, NewDefaultTransform.Rot, UpdatedComponents); } static const UProperty* RelativeScale3DProperty = FindFieldChecked<UProperty>( USceneComponent::StaticClass(), "RelativeScale3D" ); if(RelativeScale3DProperty != nullptr) { PropagateTransformPropertyChange(InstancedSceneComponent, RelativeScale3DProperty, OldDefaultTransform.Scale, NewDefaultTransform.Scale, UpdatedComponents); } } } }
void SWidget::FindChildGeometries_Helper( const FGeometry& MyGeometry, const TSet< TSharedRef<SWidget> >& WidgetsToFind, TMap<TSharedRef<SWidget>, FArrangedWidget>& OutResult ) const { // Perform a breadth first search! FArrangedChildren ArrangedChildren(EVisibility::Visible); this->ArrangeChildren( MyGeometry, ArrangedChildren ); const int32 NumChildren = ArrangedChildren.Num(); // See if we found any of the widgets on this level. for(int32 ChildIndex=0; ChildIndex < NumChildren; ++ChildIndex ) { const FArrangedWidget& CurChild = ArrangedChildren[ ChildIndex ]; if ( WidgetsToFind.Contains(CurChild.Widget) ) { // We found one of the widgets for which we need geometry! OutResult.Add( CurChild.Widget, CurChild ); } } // If we have not found all the widgets that we were looking for, descend. if ( OutResult.Num() != WidgetsToFind.Num() ) { // Look for widgets among the children. for( int32 ChildIndex=0; ChildIndex < NumChildren; ++ChildIndex ) { const FArrangedWidget& CurChild = ArrangedChildren[ ChildIndex ]; CurChild.Widget->FindChildGeometries_Helper( CurChild.Geometry, WidgetsToFind, OutResult ); } } }
bool FName::IsValidXName( FString InvalidChars/*=INVALID_NAME_CHARACTERS*/, FText* Reason/*=NULL*/ ) const { FString Name = ToString(); // See if the name contains invalid characters. TCHAR CharString[] = { '\0', '\0' }; FString MatchedInvalidChars; TSet<TCHAR> AlreadyMatchedInvalidChars; for( int32 x = 0; x < InvalidChars.Len() ; ++x ) { TCHAR CharToTest = InvalidChars[x]; CharString[0] = CharToTest; if( !AlreadyMatchedInvalidChars.Contains( CharToTest ) && Name.Contains( CharString ) ) { MatchedInvalidChars += CharString; AlreadyMatchedInvalidChars.Add( CharToTest ); } } if ( MatchedInvalidChars.Len() ) { if ( Reason ) { FFormatNamedArguments Args; Args.Add(TEXT("IllegalNameCharacters"), FText::FromString(MatchedInvalidChars)); *Reason = FText::Format( NSLOCTEXT("Core", "NameContainsInvalidCharacters", "Name may not contain the following characters: {IllegalNameCharacters}"), Args ); } return false; } return true; }
void FMoveKeys::OnBeginDrag(const FVector2D& LocalMousePos, TSharedPtr<FTrackNode> SequencerNode) { check( SelectedKeys.Num() > 0 ) // Begin an editor transaction and mark the section as transactional so it's state will be saved GEditor->BeginTransaction( NSLOCTEXT("Sequencer", "MoveKeysTransaction", "Move Keys") ); TSet<UMovieSceneSection*> ModifiedSections; for( FSelectedKey SelectedKey : SelectedKeys ) { UMovieSceneSection* OwningSection = SelectedKey.Section; // Only modify sections once if( !ModifiedSections.Contains( OwningSection ) ) { OwningSection->SetFlags( RF_Transactional ); // Save the current state of the section OwningSection->Modify(); // Section has been modified ModifiedSections.Add( OwningSection ); } } }
void FBlueprintNativeCodeGenModule::GenerateStubs() { TSet<TAssetPtr<UBlueprint>> AlreadyGenerated; while (AlreadyGenerated.Num() < StubsRequiredByGeneratedCode.Num()) { const int32 OldGeneratedNum = AlreadyGenerated.Num(); for (TAssetPtr<UBlueprint>& BPPtr : StubsRequiredByGeneratedCode) { bool bAlreadyGenerated = false; AlreadyGenerated.Add(BPPtr, &bAlreadyGenerated); if (bAlreadyGenerated) { continue; } ensureMsgf(AllPotentialStubs.Contains(BPPtr), TEXT("A required blueprint doesn't generate stub: %s"), *BPPtr.ToString()); for (auto& PlatformName : TargetPlatformNames) { GenerateSingleStub(BPPtr.LoadSynchronous(), *PlatformName); } } if (!ensure(OldGeneratedNum != AlreadyGenerated.Num())) { break; } } UE_LOG(LogBlueprintCodeGen, Log, TEXT("GenerateStubs - all unconverted bp: %d, generated wrapers: %d"), AllPotentialStubs.Num(), StubsRequiredByGeneratedCode.Num()); }
static bool ParseFramesFromSpriteArray(const TArray<TSharedPtr<FJsonValue>>& ArrayBlock, TArray<FSpriteFrame>& OutSpriteFrames, TSet<FName>& FrameNames) { GWarn->BeginSlowTask(NSLOCTEXT("Paper2D", "PaperJsonImporterFactory_ParsingSprites", "Parsing Sprite Frame"), true, true); bool bLoadedSuccessfully = true; // Parse all of the frames for (int32 FrameCount = 0; FrameCount < ArrayBlock.Num(); ++FrameCount) { GWarn->StatusUpdate(FrameCount, ArrayBlock.Num(), NSLOCTEXT("Paper2D", "PaperJsonImporterFactory_ParsingSprites", "Parsing Sprite Frames")); bool bReadFrameSuccessfully = true; FSpriteFrame Frame; const TSharedPtr<FJsonValue>& FrameDataAsValue = ArrayBlock[FrameCount]; if (FrameDataAsValue->Type == EJson::Object) { TSharedPtr<FJsonObject> FrameData; FrameData = FrameDataAsValue->AsObject(); FString FrameFilename = FPaperJSONHelpers::ReadString(FrameData, TEXT("filename"), TEXT("")); if (!FrameFilename.IsEmpty()) { Frame.FrameName = FName(*FrameFilename); // case insensitive if (FrameNames.Contains(Frame.FrameName)) { bReadFrameSuccessfully = false; } else { FrameNames.Add(Frame.FrameName); } bReadFrameSuccessfully = bReadFrameSuccessfully && ParseFrame(FrameData, /*out*/Frame); } else { bReadFrameSuccessfully = false; } } else { bReadFrameSuccessfully = false; } if (bReadFrameSuccessfully) { OutSpriteFrames.Add(Frame); } else { UE_LOG(LogPaperSpriteSheetImporter, Warning, TEXT("Frame %s is in an unexpected format"), *Frame.FrameName.ToString()); bLoadedSuccessfully = false; } } GWarn->EndSlowTask(); return bLoadedSuccessfully; }
// Reconcile other pin links: // - Links between nodes within the copied set are fine // - Links to nodes that were not copied need to be fixed up if the copy-paste was in the same graph or broken completely // Call PostPasteNode on each node void FEdGraphUtilities::PostProcessPastedNodes(TSet<UEdGraphNode*>& SpawnedNodes) { // Run thru and fix up the node's pin links; they may point to invalid pins if the paste was to another graph for (TSet<UEdGraphNode*>::TIterator It(SpawnedNodes); It; ++It) { UEdGraphNode* Node = *It; UEdGraph* CurrentGraph = Node->GetGraph(); for (int32 PinIndex = 0; PinIndex < Node->Pins.Num(); ++PinIndex) { UEdGraphPin* ThisPin = Node->Pins[PinIndex]; for (int32 LinkIndex = 0; LinkIndex < ThisPin->LinkedTo.Num(); ) { UEdGraphPin* OtherPin = ThisPin->LinkedTo[LinkIndex]; if (OtherPin == NULL) { // Totally bogus link ThisPin->LinkedTo.RemoveAtSwap(LinkIndex); } else if (!SpawnedNodes.Contains(OtherPin->GetOwningNode())) { // It's a link across the selection set, so it should be broken OtherPin->LinkedTo.RemoveSwap(ThisPin); ThisPin->LinkedTo.RemoveAtSwap(LinkIndex); } else if (!OtherPin->LinkedTo.Contains(ThisPin)) { // The link needs to be reciprocal check(OtherPin->GetOwningNode()->GetGraph() == CurrentGraph); OtherPin->LinkedTo.Add(ThisPin); ++LinkIndex; } else { // Everything seems fine but sanity check the graph check(OtherPin->GetOwningNode()->GetGraph() == CurrentGraph); ++LinkIndex; } } } } // Give every node a chance to deep copy associated resources, etc... for (TSet<UEdGraphNode*>::TIterator It(SpawnedNodes); It; ++It) { UEdGraphNode* Node = *It; Node->PostPasteNode(); Node->ReconstructNode(); // Ensure we have RF_Transactional set on all pasted nodes, as its not copied in the T3D format Node->SetFlags(RF_Transactional); } }
void FRichCurve::ScaleCurve(float ScaleOrigin, float ScaleFactor, TSet<FKeyHandle>& KeyHandles) { for (auto It = KeyHandlesToIndices.CreateIterator(); It; ++It) { const FKeyHandle& KeyHandle = It.Key(); if (KeyHandles.Num() != 0 && KeyHandles.Contains(KeyHandle)) { SetKeyTime(KeyHandle, (GetKeyTime(KeyHandle) - ScaleOrigin) * ScaleFactor + ScaleOrigin); } } }
void FRichCurve::ShiftCurve(float DeltaTime, TSet<FKeyHandle>& KeyHandles) { for (auto It = KeyHandlesToIndices.CreateIterator(); It; ++It) { const FKeyHandle& KeyHandle = It.Key(); if (KeyHandles.Num() != 0 && KeyHandles.Contains(KeyHandle)) { SetKeyTime(KeyHandle, GetKeyTime(KeyHandle)+DeltaTime); } } }
static bool ParseFramesFromSpriteHash(TSharedPtr<FJsonObject> ObjectBlock, TArray<FSpriteFrame>& OutSpriteFrames, TSet<FName>& FrameNames) { GWarn->BeginSlowTask(NSLOCTEXT("Paper2D", "PaperJsonImporterFactory_ParsingSprites", "Parsing Sprite Frame"), true, true); bool bLoadedSuccessfully = true; // Parse all of the frames int32 FrameCount = 0; for (auto FrameIt = ObjectBlock->Values.CreateIterator(); FrameIt; ++FrameIt) { GWarn->StatusUpdate(FrameCount, ObjectBlock->Values.Num(), NSLOCTEXT("Paper2D", "PaperJsonImporterFactory_ParsingSprites", "Parsing Sprite Frames")); bool bReadFrameSuccessfully = true; FSpriteFrame Frame; Frame.FrameName = *FrameIt.Key(); if (FrameNames.Contains(Frame.FrameName)) { bReadFrameSuccessfully = false; } else { FrameNames.Add(Frame.FrameName); } TSharedPtr<FJsonValue> FrameDataAsValue = FrameIt.Value(); TSharedPtr<FJsonObject> FrameData; if (FrameDataAsValue->Type == EJson::Object) { FrameData = FrameDataAsValue->AsObject(); bReadFrameSuccessfully = bReadFrameSuccessfully && ParseFrame(FrameData, /*out*/Frame); } else { bReadFrameSuccessfully = false; } if (bReadFrameSuccessfully) { OutSpriteFrames.Add(Frame); } else { UE_LOG(LogPaperSpriteSheetImporter, Warning, TEXT("Frame %s is in an unexpected format"), *Frame.FrameName.ToString()); bLoadedSuccessfully = false; } FrameCount++; } GWarn->EndSlowTask(); return bLoadedSuccessfully; }
void FMovieSceneSequenceInstance::RefreshInstanceMap( const TArray<UMovieSceneTrack*>& Tracks, const TArray<TWeakObjectPtr<UObject>>& RuntimeObjects, FMovieSceneInstanceMap& TrackInstances, IMovieScenePlayer& Player ) { // All the tracks we found during this pass TSet< UMovieSceneTrack* > FoundTracks; // For every track, check if it has an instance, if not create one, otherwise refresh that instance for( int32 TrackIndex = 0; TrackIndex < Tracks.Num(); ++TrackIndex ) { UMovieSceneTrack* Track = Tracks[TrackIndex]; // A new track has been encountered FoundTracks.Add( Track ); // See if the track has an instance TSharedPtr<IMovieSceneTrackInstance> Instance = TrackInstances.FindRef( Track ); if ( !Instance.IsValid() ) { // The track does not have an instance, create one Instance = Track->CreateInstance(); Instance->RefreshInstance( RuntimeObjects, Player, *this ); Instance->SaveState(RuntimeObjects, Player, *this); TrackInstances.Add( Track, Instance ); } else { // The track has an instance, refresh it Instance->RefreshInstance( RuntimeObjects, Player, *this ); Instance->SaveState(RuntimeObjects, Player, *this); } } // Remove entries which no longer have a track associated with them FMovieSceneInstanceMap::TIterator It = TrackInstances.CreateIterator(); for( ; It; ++It ) { if( !FoundTracks.Contains( It.Key().Get() ) ) { It.Value()->ClearInstance( Player, *this ); // This track was not found in the moviescene's track list so it was removed. It.RemoveCurrent(); } } // Sort based on evaluation order TrackInstances.ValueSort(FTrackInstanceEvalSorter()); }
bool FChunkManifestGenerator::SaveAssetRegistry(const FString& SandboxPath, const TArray<FName>* IgnorePackageList) { UE_LOG(LogChunkManifestGenerator, Display, TEXT("Saving asset registry.")); TSet<FName> IgnorePackageSet; if (IgnorePackageList != nullptr) { for (const auto& IgnorePackage : *IgnorePackageList) { IgnorePackageSet.Add(IgnorePackage); } } // Create asset registry data FArrayWriter SerializedAssetRegistry; SerializedAssetRegistry.SetFilterEditorOnly(true); TMap<FName, FAssetData*> GeneratedAssetRegistryData; for (auto& AssetData : AssetRegistryData) { if (IgnorePackageSet.Contains(AssetData.PackageName)) { continue; } // Add only assets that have actually been cooked and belong to any chunk if (AssetData.ChunkIDs.Num() > 0) { GeneratedAssetRegistryData.Add(AssetData.ObjectPath, &AssetData); } } AssetRegistry.SaveRegistryData(SerializedAssetRegistry, GeneratedAssetRegistryData); UE_LOG(LogChunkManifestGenerator, Display, TEXT("Generated asset registry num assets %d, size is %5.2fkb"), GeneratedAssetRegistryData.Num(), (float)SerializedAssetRegistry.Num() / 1024.f); // Save the generated registry for each platform for (auto Platform : Platforms) { FString PlatformSandboxPath = SandboxPath.Replace(TEXT("[Platform]"), *Platform->PlatformName()); FFileHelper::SaveArrayToFile(SerializedAssetRegistry, *PlatformSandboxPath); } UE_LOG(LogChunkManifestGenerator, Display, TEXT("Done saving asset registry.")); return true; }
void FShaderPipelineType::Initialize() { check(!bInitialized); TSet<FName> UsedNames; for (TLinkedList<FShaderPipelineType*>::TIterator It(FShaderPipelineType::GetTypeList()); It; It.Next()) { const auto* PipelineType = *It; // Validate stages for (int32 Index = 0; Index < SF_NumFrequencies; ++Index) { check(!PipelineType->AllStages[Index] || PipelineType->AllStages[Index]->GetFrequency() == (EShaderFrequency)Index); } auto& Stages = PipelineType->GetStages(); // #todo-rco: Do we allow mix/match of global/mesh/material stages? // Check all shaders are the same type, start from the top-most stage const FGlobalShaderType* GlobalType = Stages[0]->GetGlobalShaderType(); const FMeshMaterialShaderType* MeshType = Stages[0]->GetMeshMaterialShaderType(); const FMaterialShaderType* MateriallType = Stages[0]->GetMaterialShaderType(); for (int32 Index = 1; Index < Stages.Num(); ++Index) { if (GlobalType) { checkf(Stages[Index]->GetGlobalShaderType(), TEXT("Invalid combination of Shader types on Pipeline %s"), PipelineType->Name); } else if (MeshType) { checkf(Stages[Index]->GetMeshMaterialShaderType(), TEXT("Invalid combination of Shader types on Pipeline %s"), PipelineType->Name); } else if (MateriallType) { checkf(Stages[Index]->GetMaterialShaderType(), TEXT("Invalid combination of Shader types on Pipeline %s"), PipelineType->Name); } } FName PipelineName = PipelineType->GetFName(); checkf(!UsedNames.Contains(PipelineName), TEXT("Two Pipelines with the same name %s found!"), PipelineType->Name); UsedNames.Add(PipelineName); } bInitialized = true; }
void UEnvironmentQueryGraph::SpawnMissingSubNodes(UEnvQueryOption* Option, TSet<UEnvQueryTest*> ExistingTests, UEnvironmentQueryGraphNode* OptionNode) { TArray<UEnvQueryTest*> TestsCopy = Option->Tests; for (int32 SubIdx = 0; SubIdx < TestsCopy.Num(); SubIdx++) { if (ExistingTests.Contains(TestsCopy[SubIdx]) || (TestsCopy[SubIdx] == nullptr)) { continue; } UEnvironmentQueryGraphNode_Test* TestNode = NewObject<UEnvironmentQueryGraphNode_Test>(this); TestNode->NodeInstance = TestsCopy[SubIdx]; TestNode->UpdateNodeClassData(); OptionNode->AddSubNode(TestNode, this); TestNode->NodeInstance = TestsCopy[SubIdx]; } }
void FSubMovieSceneTrackInstance::RefreshInstance( const TArray<UObject*>& RuntimeObjects, class IMovieScenePlayer& Player ) { const TArray<UMovieSceneSection*>& AllSections = SubMovieSceneTrack->GetAllSections(); // Sections we encountered TSet<UMovieSceneSection*> FoundSections; // Iterate through each section and create an instance for it if it doesn't exist for( int32 SectionIndex = 0; SectionIndex < AllSections.Num(); ++SectionIndex ) { USubMovieSceneSection* Section = CastChecked<USubMovieSceneSection>( AllSections[SectionIndex] ); // If the section doesn't have a valid movie scene or no longer has one // (e.g user deleted it) then skip adding an instance for it if( Section->GetMovieSceneAnimation() ) { FoundSections.Add(Section); TSharedPtr<FMovieSceneSequenceInstance> Instance = SubMovieSceneInstances.FindRef(Section); if (!Instance.IsValid()) { Instance = MakeShareable(new FMovieSceneSequenceInstance(*Section->GetMovieSceneAnimation())); SubMovieSceneInstances.Add(Section, Instance.ToSharedRef()); } Player.AddOrUpdateMovieSceneInstance(*Section, Instance.ToSharedRef()); // Refresh the existing instance Instance->RefreshInstance(Player); } } TMap< TWeakObjectPtr<USubMovieSceneSection>, TSharedPtr<FMovieSceneSequenceInstance> >::TIterator It = SubMovieSceneInstances.CreateIterator(); for( ; It; ++It ) { // Remove any sections that no longer exist if( !FoundSections.Contains( It.Key().Get() ) ) { Player.RemoveMovieSceneInstance( *It.Key().Get(), It.Value().ToSharedRef() ); It.RemoveCurrent(); } } }
FText UPaperTileMap::GenerateNewLayerName(UPaperTileMap* TileMap) { // Create a set of existing names TSet<FString> ExistingNames; for (UPaperTileLayer* ExistingLayer : TileMap->TileLayers) { ExistingNames.Add(ExistingLayer->LayerName.ToString()); } // Find a good name FText TestLayerName; do { TileMap->LayerNameIndex++; TestLayerName = FText::Format(LOCTEXT("NewLayerNameFormatString", "Layer {0}"), FText::AsNumber(TileMap->LayerNameIndex, &FNumberFormattingOptions::DefaultNoGrouping())); } while (ExistingNames.Contains(TestLayerName.ToString())); return TestLayerName; }
void FContentBrowserSingleton::SummonNewBrowser(bool bAllowLockedBrowsers) { TSet<FName> OpenBrowserIDs; // Find all currently open browsers to help find the first open slot for (int32 BrowserIdx = AllContentBrowsers.Num() - 1; BrowserIdx >= 0; --BrowserIdx) { const TWeakPtr<SContentBrowser>& Browser = AllContentBrowsers[BrowserIdx]; if ( Browser.IsValid() ) { OpenBrowserIDs.Add(Browser.Pin()->GetInstanceName()); } } FName NewTabName; for ( int32 BrowserIdx = 0; BrowserIdx < ARRAY_COUNT(ContentBrowserTabIDs); BrowserIdx++ ) { FName TestTabID = ContentBrowserTabIDs[BrowserIdx]; if ( !OpenBrowserIDs.Contains(TestTabID) && (bAllowLockedBrowsers || !IsLocked(TestTabID)) ) { // Found the first index that is not currently open NewTabName = TestTabID; break; } } if ( NewTabName != NAME_None ) { const TWeakPtr<FTabManager>& TabManagerToInvoke = BrowserToLastKnownTabManagerMap.FindRef(NewTabName); if ( TabManagerToInvoke.IsValid() ) { TabManagerToInvoke.Pin()->InvokeTab(NewTabName); } else { FGlobalTabmanager::Get()->InvokeTab(NewTabName); } } else { // No available slots... don't summon anything } }
FName FNativeClassHierarchy::GetClassPathRootForModule(const FName& InModuleName, const TSet<FName>& InGameModules, const TMap<FName, FName>& InPluginModules) { static const FName EngineRootNodeName = "Classes_Engine"; static const FName GameRootNodeName = "Classes_Game"; // Work out which root this class should go under (anything that isn't a game or plugin module goes under engine) FName RootNodeName = EngineRootNodeName; if(InGameModules.Contains(InModuleName)) { RootNodeName = GameRootNodeName; } else if(InPluginModules.Contains(InModuleName)) { const FName PluginName = InPluginModules.FindRef(InModuleName); RootNodeName = FName(*(FString(TEXT("Classes_")) + PluginName.ToString())); } return RootNodeName; }
void FVertexSnappingImpl::GetActorsInsideBox( const FBox& Box, UWorld* World, TArray<FSnapActor>& OutActorsInBox, const TSet< TWeakObjectPtr<AActor> >& ActorsToIgnore, const FSceneView* View ) { for( FActorIterator It(World); It; ++It ) { AActor* Actor = *It; // Ignore the builder brush, hidden actors and forcefully ignored actors (actors being moved) if( Actor != World->GetDefaultBrush() && It->IsHiddenEd() == false && !ActorsToIgnore.Contains( Actor ) ) { const bool bNonColliding = true; FBox ActorBoundingBox = Actor->GetComponentsBoundingBox(true); // Actors must be within the bounding box and within the view frustum if( Box.Intersect( ActorBoundingBox ) && View->ViewFrustum.IntersectBox( ActorBoundingBox.GetCenter(), ActorBoundingBox.GetExtent() ) ) { OutActorsInBox.Add( FSnapActor( Actor, Box ) ); } } } }
void RecursivelyCreateOriginalPath(UnFbx::FFbxImporter* FbxImporter, TSharedPtr<FFbxNodeInfo> NodeInfo, FString AssetPath, TSet<uint64> &AssetPathDone) { if (NodeInfo->AttributeInfo.IsValid() && !AssetPathDone.Contains(NodeInfo->AttributeInfo->UniqueId)) { FString AssetName = AssetPath + TEXT("/") + NodeInfo->AttributeInfo->Name; NodeInfo->AttributeInfo->SetOriginalImportPath(AssetName); FString OriginalFullImportName = PackageTools::SanitizePackageName(AssetName); OriginalFullImportName = OriginalFullImportName + TEXT(".") + PackageTools::SanitizePackageName(NodeInfo->AttributeInfo->Name); NodeInfo->AttributeInfo->SetOriginalFullImportName(OriginalFullImportName); AssetPathDone.Add(NodeInfo->AttributeInfo->UniqueId); } if (NodeInfo->NodeName.Compare("RootNode") != 0) { AssetPath += TEXT("/") + NodeInfo->NodeName; } for (TSharedPtr<FFbxNodeInfo> Child : NodeInfo->Childrens) { RecursivelyCreateOriginalPath(FbxImporter, Child, AssetPath, AssetPathDone); } }
/** * Recursively sets expanded items for a node * * @param InNode The node to set expanded items on * @param OutExpandedItems List of expanded items to set */ void SetExpandedItems(TSharedPtr<FPropertyNode> InPropertyNode, const TSet<FString>& InExpandedItems) { if (InExpandedItems.Num() > 0) { const bool bWithArrayIndex = true; FString Path; Path.Empty(128); InPropertyNode->GetQualifiedName(Path, bWithArrayIndex); if (InExpandedItems.Contains(Path)) { InPropertyNode->SetNodeFlags(EPropertyNodeFlags::Expanded, true); } for (int32 NodeIndex = 0; NodeIndex < InPropertyNode->GetNumChildNodes(); ++NodeIndex) { SetExpandedItems(InPropertyNode->GetChildNode(NodeIndex), InExpandedItems); } } }
void FDependsNode::PrintReferencersRecursive(const FString& Indent, TSet<const FDependsNode*>& VisitedNodes) const { if ( this == NULL ) { UE_LOG(LogAssetRegistry, Log, TEXT("%sNULL"), *Indent); } else if ( VisitedNodes.Contains(this) ) { UE_LOG(LogAssetRegistry, Log, TEXT("%s[CircularReferenceTo]%s"), *Indent, *PackageName.ToString()); } else { UE_LOG(LogAssetRegistry, Log, TEXT("%s%s"), *Indent, *PackageName.ToString()); VisitedNodes.Add(this); for (auto ReferencerIt = Referencers.CreateConstIterator(); ReferencerIt; ++ReferencerIt) { (*ReferencerIt)->PrintReferencersRecursive(Indent + TEXT(" "), VisitedNodes); } } }
FReply FProceduralFoliageComponentDetails::OnResimulateClicked() { TSet<UProceduralFoliage*> UniqueProceduralFoliages; for( TWeakObjectPtr<UProceduralFoliageComponent>& Component : SelectedComponents ) { if( Component.IsValid() && Component->ProceduralFoliage ) { if( !UniqueProceduralFoliages.Contains( Component->ProceduralFoliage ) ) { UniqueProceduralFoliages.Add( Component->ProceduralFoliage ); } TArray <FDesiredFoliageInstance> DesiredFoliageInstances; if (Component->SpawnProceduralContent(DesiredFoliageInstances)) { FEdModeFoliage::AddInstances(Component->GetWorld(), DesiredFoliageInstances); } } } return FReply::Handled(); }
void FVertexSnappingImpl::GetPossibleSnapActors( const FBox& AllowedBox, FIntPoint MouseLocation, FLevelEditorViewportClient* ViewportClient, const FSceneView* View, EAxisList::Type CurrentAxis, TSet< TWeakObjectPtr<AActor> >& ActorsToIgnore, TArray<FSnapActor>& OutActorsInBox ) { if( CurrentAxis == EAxisList::Screen && !ViewportClient->IsOrtho() ) { HHitProxy* HitProxy = ViewportClient->Viewport->GetHitProxy( MouseLocation.X, MouseLocation.Y ); if( HitProxy && HitProxy->IsA(HActor::StaticGetType()) ) { AActor* HitProxyActor = static_cast<HActor*>(HitProxy)->Actor ; if( HitProxyActor && !ActorsToIgnore.Contains(HitProxyActor) ) { ActorsToIgnore.Add( HitProxyActor ); OutActorsInBox.Add( FSnapActor( HitProxyActor, HitProxyActor->GetComponentsBoundingBox(true) ) ); } } } if( OutActorsInBox.Num() == 0 ) { GetActorsInsideBox( AllowedBox, ViewportClient->GetWorld(), OutActorsInBox, ActorsToIgnore, View ); } }
void UAIGraph::RemoveOrphanedNodes() { TSet<UObject*> NodeInstances; CollectAllNodeInstances(NodeInstances); NodeInstances.Remove(nullptr); // Obtain a list of all nodes actually in the asset and discard unused nodes TArray<UObject*> AllInners; const bool bIncludeNestedObjects = false; GetObjectsWithOuter(GetOuter(), AllInners, bIncludeNestedObjects); for (auto InnerIt = AllInners.CreateConstIterator(); InnerIt; ++InnerIt) { UObject* TestObject = *InnerIt; if (!NodeInstances.Contains(TestObject) && CanRemoveNestedObject(TestObject)) { TestObject->SetFlags(RF_Transient); TestObject->Rename(NULL, GetTransientPackage(), REN_DontCreateRedirectors | REN_NonTransactional | REN_ForceNoResetLoaders); } } }
void UEnvironmentQueryGraph::RemoveOrphanedNodes() { UEnvQuery* QueryAsset = CastChecked<UEnvQuery>(GetOuter()); // Obtain a list of all nodes that should be in the asset TSet<UObject*> AllNodes; for (int32 Index = 0; Index < Nodes.Num(); ++Index) { UEnvironmentQueryGraphNode_Option* OptionNode = Cast<UEnvironmentQueryGraphNode_Option>(Nodes[Index]); if (OptionNode) { UEnvQueryOption* OptionInstance = Cast<UEnvQueryOption>(OptionNode->NodeInstance); if (OptionInstance) { AllNodes.Add(OptionInstance); if (OptionInstance->Generator) { AllNodes.Add(OptionInstance->Generator); } } for (int32 SubIdx = 0; SubIdx < OptionNode->Tests.Num(); SubIdx++) { if (OptionNode->Tests[SubIdx] && OptionNode->Tests[SubIdx]->NodeInstance) { AllNodes.Add(OptionNode->Tests[SubIdx]->NodeInstance); } } } } // Obtain a list of all nodes actually in the asset and discard unused nodes TArray<UObject*> AllInners; const bool bIncludeNestedObjects = false; GetObjectsWithOuter(QueryAsset, AllInners, bIncludeNestedObjects); for (auto InnerIt = AllInners.CreateConstIterator(); InnerIt; ++InnerIt) { UObject* Node = *InnerIt; const bool bEQSNode = Node->IsA(UEnvQueryGenerator::StaticClass()) || Node->IsA(UEnvQueryTest::StaticClass()) || Node->IsA(UEnvQueryOption::StaticClass()); if (bEQSNode && !AllNodes.Contains(Node)) { Node->SetFlags(RF_Transient); Node->Rename(NULL, GetTransientPackage(), REN_DontCreateRedirectors | REN_NonTransactional | REN_ForceNoResetLoaders); } } }