void FLayers::UpdateActorAllViewsVisibility( const TWeakObjectPtr< AActor >& Actor ) { uint64 OriginalHiddenViews = Actor->HiddenEditorViews; for ( int32 ViewIndex = 0; ViewIndex < Editor->LevelViewportClients.Num(); ++ViewIndex ) { // don't have this reattach, as we can do it once for all views UpdateActorViewVisibility(Editor->LevelViewportClients[ViewIndex], Actor, false); } // reregister if we changed the visibility bits, as the rendering thread needs them if (OriginalHiddenViews != Actor->HiddenEditorViews) { return; } Actor->MarkComponentsRenderStateDirty(); // redraw all viewports if the actor for (int32 ViewIndex = 0; ViewIndex < Editor->LevelViewportClients.Num(); ViewIndex++) { // make sure we redraw all viewports Editor->LevelViewportClients[ViewIndex]->Invalidate(); } }
void FLightingBuildInfoStatsPage::Generate( TArray< TWeakObjectPtr<UObject> >& OutObjects ) const { if(Entries.Num()) { for( auto It = Entries.CreateConstIterator(); It; ++It ) { TWeakObjectPtr<ULightingBuildInfo> Entry = *It; if(Entry.IsValid()) { ULightingBuildInfo* NewObject = DuplicateObject<ULightingBuildInfo>(Entry.Get(), Entry->GetOuter()); NewObject->AddToRoot(); OutObjects.Add( NewObject ); } } } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Operations on selected actors. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TArray< TWeakObjectPtr< AActor > > FLayers::GetSelectedActors() const { // Unfortunately, the batch selection operation is not entirely effective // and the result can be that the iterator becomes invalid when adding an actor to a layer // due to unintended selection change notifications being fired. TArray< TWeakObjectPtr< AActor > > CurrentlySelectedActors; for( FSelectionIterator It( Editor->GetSelectedActorIterator() ); It; ++It ) { const TWeakObjectPtr< AActor > Actor = static_cast< AActor* >( *It ); checkSlow( Actor->IsA(AActor::StaticClass()) ); CurrentlySelectedActors.Add( Actor ); } return CurrentlySelectedActors; }
FName FClassIconFinder::FindIconNameForActor( const TWeakObjectPtr<AActor>& InActor ) { // Actor specific overrides to normal per-class icons AActor* Actor = InActor.Get(); FName BrushName = NAME_None; if ( Actor ) { ABrush* Brush = Cast< ABrush >( Actor ); if ( Brush ) { if (Brush_Add == Brush->BrushType) { BrushName = TEXT( "ClassIcon.BrushAdditive" ); } else if (Brush_Subtract == Brush->BrushType) { BrushName = TEXT( "ClassIcon.BrushSubtractive" ); } } // Actor didn't specify an icon - fallback on the class icon if ( BrushName.IsNone() ) { BrushName = FindIconNameForClass( Actor->GetClass() ); } } else { // If the actor reference is NULL it must have been deleted BrushName = TEXT( "ClassIcon.Deleted" ); } return BrushName; }
/** Called to get the name of a curve back from the animation skeleton */ virtual FText GetCurveName(USkeleton::AnimCurveUID Uid) const { if(BaseSequence.IsValid()) { FSmartNameMapping* NameMapping = BaseSequence.Get()->GetSkeleton()->SmartNames.GetContainer(USkeleton::AnimCurveMappingName); if(NameMapping) { FName CurveName; if(NameMapping->GetName(Uid, CurveName)) { return FText::FromName(CurveName); } } } return FText::GetEmpty(); }
//------------------------------------------------------------------------------ int32 FLinkerPlaceholderBase::ResolvePlaceholderPropertyValues(UObject* NewObjectValue) { int32 ResolvedTotal = 0; UObject* ThisAsUObject = GetPlaceholderAsUObject(); for (auto& ReferencingPair : ReferencingContainers) { TWeakObjectPtr<UObject> ContainerPtr = ReferencingPair.Key; if (!ContainerPtr.IsValid()) { continue; } UObject* Container = ContainerPtr.Get(); for (const UObjectProperty* Property : ReferencingPair.Value) { #if USE_DEFERRED_DEPENDENCY_CHECK_VERIFICATION_TESTS check(Property->GetOwnerClass() == Container->GetClass()); #endif // USE_DEFERRED_DEPENDENCY_CHECK_VERIFICATION_TESTS TArray<const UProperty*> PropertyChain; LinkerPlaceholderObjectImpl::BuildPropertyChain(Property, PropertyChain); const UProperty* OutermostProperty = PropertyChain.Last(); uint8* OutermostAddress = OutermostProperty->ContainerPtrToValuePtr<uint8>((uint8*)Container, /*ArrayIndex =*/0); int32 ResolvedCount = LinkerPlaceholderObjectImpl::ResolvePlaceholderValues(PropertyChain, PropertyChain.Num() - 1, OutermostAddress, ThisAsUObject, NewObjectValue); ResolvedTotal += ResolvedCount; #if USE_DEFERRED_DEPENDENCY_CHECK_VERIFICATION_TESTS // we expect that (because we have had ReferencingProperties added) // there should be at least one reference that is resolved... if // there were none, then a property could have changed its value // after it was set to this // // NOTE: this may seem it can be resolved by properties removing // themselves from ReferencingProperties, but certain // properties may be the inner of a UArrayProperty (meaning // there could be multiple references per property)... we'd // have to inc/decrement a property ref-count to resolve that // scenario check(ResolvedCount > 0); #endif // USE_DEFERRED_DEPENDENCY_CHECK_VERIFICATION_TESTS } } return ResolvedTotal; }
// Purges any objects marked pending kill from the object list void FObjectPropertyNode::PurgeKilledObjects() { // Purge any objects that are marked pending kill from the object list for (int32 Index = 0; Index < Objects.Num(); ) { TWeakObjectPtr<UObject> Object = Objects[Index]; if ( !Object.IsValid() || Object->HasAnyFlags(RF_PendingKill) ) { Objects.RemoveAt(Index, 1); } else { ++Index; } } }
FAnimCurveBaseInterface(UAnimSequenceBase * BaseSeq, FAnimCurveBase* InData) : BaseSequence(BaseSeq) , CurveData(InData) { // they should be valid check (BaseSequence.IsValid()); check (CurveData); }
//------------------------------------------------------------------------------ bool FDeferredScriptLoader::Resolve(FArchive& Ar) { if (UStruct* Target = TargetScriptContainerPtr.Get()) { return LoadStructWithScript(Target, Ar); } return false; }
void UAblAbilityTaskDependencyValidator::Validate(const TWeakObjectPtr<UAblAbilityTaskValidatorContext>& Context, const TWeakObjectPtr<const UAblAbilityTask>& Task) const { const TArray<UAblAbilityTask*>& AllTasks = Context->GetAbility()->GetTasks(); for (const UAblAbilityTask* CurrentTask : AllTasks) { HasCircularDependency(Context, CurrentTask, CurrentTask); } }
void UK2Node_MacroInstance::FindInContentBrowser(TWeakObjectPtr<UK2Node_MacroInstance> MacroInstance) { if ( MacroInstance.IsValid() ) { UEdGraph* InstanceMacroGraph = MacroInstance.Get()->MacroGraphReference.GetGraph(); if ( InstanceMacroGraph ) { UBlueprint* BlueprintToSync = FBlueprintEditorUtils::FindBlueprintForGraph(InstanceMacroGraph); if ( BlueprintToSync ) { TArray<UObject*> ObjectsToSync; ObjectsToSync.Add( BlueprintToSync ); GEditor->SyncBrowserToObjects(ObjectsToSync); } } } }
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) { SCOPE_CYCLE_COUNTER(STAT_AnimGameThreadTime); if (USkeletalMeshComponent* Comp = SkeletalMeshComponent.Get()) { Comp->CompleteParallelBlendPhysics(); } }
// Called by the EditableText widget to get the current comment for the node static FString GetNodeComment(TWeakObjectPtr<UEdGraphNode> NodeWeakPtr) { if (UEdGraphNode* SelectedNode = NodeWeakPtr.Get()) { return SelectedNode->NodeComment; } return FString(); }
void FAssetTypeActions_Texture::ExecuteFindMaterials(TWeakObjectPtr<UTexture> Object) { auto Texture = Object.Get(); if ( Texture ) { // @todo AssetTypeActions Implement FindMaterials using the asset registry. } }
void FMovieSceneActorReferenceTrackInstance::Update(EMovieSceneUpdateData& UpdateData, const TArray<TWeakObjectPtr<UObject>>& RuntimeObjects, class IMovieScenePlayer& Player, FMovieSceneSequenceInstance& SequenceInstance ) { // TODO: Support default values. FGuid ActorReferenceGuid; if( ActorReferenceTrack->Eval( UpdateData.Position, UpdateData.LastPosition, ActorReferenceGuid ) ) { AActor* CurrentActor = nullptr; if (GuidToActorCache.Contains(ActorReferenceGuid)) { TWeakObjectPtr<AActor> CachedActor = *GuidToActorCache.Find(ActorReferenceGuid); if (CachedActor.IsValid()) { CurrentActor = CachedActor.Get(); } } if (CurrentActor == nullptr) { TArray<TWeakObjectPtr<UObject>> RuntimeObjectsForGuid; Player.GetRuntimeObjects(SequenceInstance.AsShared(), ActorReferenceGuid, RuntimeObjectsForGuid); if (RuntimeObjectsForGuid.Num() == 1) { AActor* ActorForGuid = Cast<AActor>(RuntimeObjectsForGuid[0].Get()); if (ActorForGuid != nullptr) { CurrentActor = ActorForGuid; if (CurrentActor != nullptr) { GuidToActorCache.Add(ActorReferenceGuid, CurrentActor); } } } } if (CurrentActor != nullptr) { for (auto ObjectPtr : RuntimeObjects) { UObject* Object = ObjectPtr.Get(); PropertyBindings->CallFunction<AActor*>(Object, &CurrentActor); } } } }
float UPhysicalMaterial::GetTireFrictionScale( TWeakObjectPtr<UTireType> TireType ) { float Scale = (TireType != NULL) ? TireType->GetFrictionScale() : 1.0f; Scale *= TireFrictionScale; for ( int32 i = TireFrictionScales.Num() - 1; i >= 0; --i ) { if ( TireFrictionScales[i].TireType == TireType.Get() ) { Scale *= TireFrictionScales[i].FrictionScale; break; } } return Scale; }
FString SObjectNameEditableTextBox::GetObjectDisplayName(TWeakObjectPtr<UObject> Object) { FString Result; if(Object.IsValid()) { UObject* ObjectPtr = Object.Get(); if (ObjectPtr->IsA(AActor::StaticClass())) { Result = ((AActor*)ObjectPtr)->GetActorLabel(); } else { Result = ObjectPtr->GetName(); } } return Result; }
virtual bool IsValidCurve( FRichCurveEditInfo CurveInfo ) override { // Get the curve with the ID directly from the sequence and compare it since undo/redo can cause previously // used curves to become invalid. FAnimCurveBase* CurrentCurveData = BaseSequence.Get()->RawCurveData.GetCurveData( CurveUID ); return CurrentCurveData != nullptr && CurveInfo.CurveToEdit == &((FFloatCurve*)CurrentCurveData)->FloatCurve; }
UExporter::UExporter(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) { if ( HasAnyFlags(RF_ClassDefaultObject) ) { TWeakObjectPtr<UExporter> DefaultExporterObj(this); TWeakObjectPtr<UExporter>* PreviousObj = RegisteredExporters.Find(DefaultExporterObj); if(!PreviousObj) { RegisteredExporters.Add(DefaultExporterObj); } else if(!PreviousObj->IsValid()) { RegisteredExporters.Remove(*PreviousObj); RegisteredExporters.Add(DefaultExporterObj); } } }
bool FLayers::InitializeNewActorLayers( const TWeakObjectPtr< AActor >& Actor ) { if( !IsActorValidForLayer( Actor ) ) { return false; } for( auto LayerNameIt = Actor->Layers.CreateConstIterator(); LayerNameIt; ++LayerNameIt ) { const FName LayerName = *LayerNameIt; TWeakObjectPtr< ULayer > Layer = EnsureLayerExists( LayerName ); Layer->Modify(); AddActorToStats( Layer, Actor); } return Actor->Layers.Num() > 0; }
UExporter::UExporter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { if ( HasAnyFlags(RF_ClassDefaultObject) ) { TWeakObjectPtr<UExporter> DefaultExporterObj(this); TWeakObjectPtr<UExporter>* PreviousObj = RegisteredExporters.Find(DefaultExporterObj); if(!PreviousObj) { RegisteredExporters.Add(DefaultExporterObj); } else if(!PreviousObj->IsValid()) { RegisteredExporters.Remove(*PreviousObj); RegisteredExporters.Add(DefaultExporterObj); } } }
void FLayers::MakeAllLayersVisible() { TArray< FName > AllLayerNames; FLayers::AddAllLayerNamesTo( AllLayerNames ); for( auto LayerIt = GetWorld()->Layers.CreateIterator(); LayerIt; ++LayerIt ) { TWeakObjectPtr< ULayer > Layer = *LayerIt; if( !Layer->bIsVisible ) { Layer->Modify(); Layer->bIsVisible = true; LayersChanged.Broadcast( ELayersAction::Modify, Layer, "bIsVisible" ); } } UpdateAllActorsVisibility( true, true ); }
FAnimTrackCurveBaseInterface(UAnimSequence * BaseSeq, USkeleton::AnimCurveUID InCurveUID, ETransformCurve::Type InCurveType) : BaseSequence(BaseSeq) , CurveUID(InCurveUID) , CurveType(InCurveType) { CurveData = GetCurveDataFromSequence(); // they should be valid check (BaseSequence.IsValid()); check (CurveData); }
void FLayers::ToggleLayersVisibility( const TArray< FName >& LayerNames ) { if( LayerNames.Num() == 0 ) { return; } for( auto LayerNameIt = LayerNames.CreateConstIterator(); LayerNameIt; ++LayerNameIt ) { const TWeakObjectPtr< ULayer > Layer = EnsureLayerExists( *LayerNameIt ); check( Layer != NULL ); Layer->Modify(); Layer->bIsVisible = !Layer->bIsVisible; LayersChanged.Broadcast( ELayersAction::Modify, Layer, "bIsVisible" ); } UpdateAllActorsVisibility( true, true ); }
/** Called to get the name of a curve back from the animation skeleton */ virtual FText GetCurveName(USkeleton::AnimCurveUID Uid) const { if(BaseSequence.IsValid()) { FSmartNameMapping* NameMapping = BaseSequence.Get()->GetSkeleton()->SmartNames.GetContainer(USkeleton::AnimTrackCurveMappingName); if(NameMapping) { FName CurveName; if(NameMapping->GetName(Uid, CurveName)) { FName DisplayName = CurveName; return FText::FromString(FString::Printf(TEXT("%s(%c)"), *DisplayName.ToString(), GetCurveTypeCharacter())); } } } return FText::GetEmpty(); }
virtual void DrawCanvas(FViewport& InViewport, FSceneView& View, FCanvas& Canvas) override { FEditorViewportClient::DrawCanvas(InViewport, View, Canvas); if (Widget.IsValid() && Widget->OnDrawCanvas.IsBound()) { if(CanvasOwner.Canvas == nullptr){ CanvasOwner.Canvas = NewObject<UCanvas>(Widget.Get()); } CanvasOwner.Canvas->Canvas = &Canvas; CanvasOwner.Canvas->Init(View.UnscaledViewRect.Width(), View.UnscaledViewRect.Height(), const_cast<FSceneView*>(&View)); CanvasOwner.Canvas->ApplySafeZoneTransform(); Widget->OnDrawCanvas.Execute(CanvasOwner.Canvas, Widget.Get()); CanvasOwner.Canvas->PopSafeZoneTransform(); } }
bool FLayers::DisassociateActorFromLayers( const TWeakObjectPtr< AActor >& Actor ) { if( !IsActorValidForLayer( Actor ) ) { return false; } bool bChangeOccurred = false; for( auto LayerNameIt = Actor->Layers.CreateConstIterator(); LayerNameIt; ++LayerNameIt ) { const FName LayerName = *LayerNameIt; TWeakObjectPtr< ULayer > Layer = EnsureLayerExists( LayerName ); Layer->Modify(); RemoveActorFromStats( Layer, Actor); bChangeOccurred = true; } return bChangeOccurred; }
void UAblAbilityTaskOrderValidator::Validate(const TWeakObjectPtr<UAblAbilityTaskValidatorContext>& Context, const TWeakObjectPtr<const UAblAbilityTask>& Task) const { const float AbilityLength = Context->GetAbility()->GetLength(); const TArray<UAblAbilityTask*>& AllTasks = Context->GetAbility()->GetTasks(); int j = 0; float TimeDifference = 0.0f; for (int i = 0; i < AllTasks.Num() - 1; ++i) { for (j = i + 1; j < AllTasks.Num(); ++j) { TimeDifference = AllTasks[j]->GetStartTime() - AllTasks[i]->GetStartTime(); // The 0.0 check is just there to catch any constants people may be using. if (TimeDifference != 0.0f && TimeDifference < KINDA_SMALL_NUMBER) { Context->AddError(LOCTEXT("AbilityValidatorTasksOutOfOrder", "Tasks aren't in sequential order. Please resave the ability.")); return; // We can early out. } } } }
void FPropertyTable::PurgeInvalidObjectNodes() { TArray< TSharedRef< FObjectPropertyNode > > ValidNodes; for( auto NodeIter = SourceObjectPropertyNodes.CreateIterator(); NodeIter; ++NodeIter ) { const TWeakObjectPtr< UObject > Object = NodeIter.Key(); if ( !Object.IsValid() ) { ValidNodes.Add( NodeIter.Value() ); } } SourceObjectPropertyNodes.Empty(); for( auto NodeIter = ValidNodes.CreateIterator(); NodeIter; ++NodeIter ) { const TSharedRef< FObjectPropertyNode >& CurrentNode = *NodeIter; SourceObjectPropertyNodes.Add( CurrentNode->GetUObject( 0 ), CurrentNode ); } }
void FBPProfilerBranchStat::CreateChildrenForPins() { TWeakObjectPtr<const UObject> ObjectPtr = ObjectContext.GetObjectPtr(); bAreExecutionPathsSequential = IsBranchSequential(); if (const UEdGraphNode* GraphNode = Cast<const UEdGraphNode>(ObjectPtr.Get())) { for (auto Pin : GraphNode->Pins) { if (Pin->Direction == EGPD_Output && Pin->PinType.PinCategory == UEdGraphSchema_K2::PC_Exec) { FBPProfilerStatPtr& Result = CachedChildren.FindOrAdd(Pin); if (!Result.IsValid()) { FScriptExecEvent NewExitPin(Pin, ObjectContext); Result = MakeShareable(new FBPProfilerStat(AsShared(), NewExitPin)); } } } } }