void FGameLiveStreaming::StopBroadcastingGame()
{
	if( bIsBroadcasting )
	{
		if( LiveStreamer != nullptr )
		{
			if( LiveStreamer->IsBroadcasting() )
			{
				LiveStreamer->StopWebCam();
				LiveStreamer->StopBroadcasting();
			}
		}
		if( FSlateApplication::IsInitialized() )	// During shutdown, Slate may have already been destroyed by the time our viewport gets cleaned up
		{
			FSlateRenderer* SlateRenderer = FSlateApplication::Get().GetRenderer().Get();
			SlateRenderer->OnSlateWindowRendered().RemoveAll( this );
		}

		// Cleanup readback buffer textures
		{
			FlushRenderingCommands();

			ReadbackTextures[0].SafeRelease();
			ReadbackTextures[1].SafeRelease();
			ReadbackTextureIndex = 0;
			ReadbackBuffers[0] = nullptr;
			ReadbackBuffers[1] = nullptr;
			ReadbackBufferIndex = 0;
		}
	}
}
Example #2
0
void UMediaTexture::PreEditChange( UProperty* PropertyAboutToChange )
{
	// this will release the FMediaTextureResource
	Super::PreEditChange(PropertyAboutToChange);

	FlushRenderingCommands();
}
Example #3
0
void UStaticMeshComponent::InvalidateLightingCacheDetailed(bool bInvalidateBuildEnqueuedLighting, bool bTranslationOnly)
{
	if(bHasCachedStaticLighting)
	{
		// Save the static mesh state for transactions, force it to be marked dirty if we are going to discard any static lighting data.
		Modify(true);

		// Detach the component from the scene for the duration of this function.
		FComponentReregisterContext ReregisterContext(this);

		// Block until the RT processes the unregister before modifying variables that it may need to access
		FlushRenderingCommands();

		Super::InvalidateLightingCacheDetailed(bInvalidateBuildEnqueuedLighting, bTranslationOnly);

		// Discard all cached lighting.
		check(AttachmentCounter.GetValue() == 0);
		IrrelevantLights.Empty();
		for(int32 i = 0; i < LODData.Num(); i++)
		{
			FStaticMeshComponentLODInfo& LODDataElement = LODData[i];
			LODDataElement.LightMap = NULL;
			LODDataElement.ShadowMap = NULL;
		}
	}
	
	if (bInvalidateBuildEnqueuedLighting)
	{
		bStaticLightingBuildEnqueued = false;
	}
}
Example #4
0
FGlobalComponentReregisterContext::FGlobalComponentReregisterContext(const TArray<AActor*>& InParentActors)
{
	ActiveGlobalReregisterContextCount++;

	// wait until resources are released
	FlushRenderingCommands();
}
/**
 * Exec handler implementation.
 *
 * @param InWorld World context
 * @param Cmd	Command to parse
 * @param Ar	Output device to log to
 *
 * @return true if command was handled, false otherwise
 */
bool FSystemSettings::Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar )
{
	FSystemSettingsData OldSystemSettings = *this;

	// Keep track whether the command was handled or not.
	bool bHandledCommand = false;

	if( FParse::Command(&Cmd,TEXT("SCALE")) )
	{
		// Some of these settings are used in both threads so we need to stop the rendering thread before changing them.
		FlushRenderingCommands();

		if( FParse::Command(&Cmd,TEXT("LOWEND")) )
		{
			bHandledCommand	= HandleLowendCommand( Cmd, Ar );
		}
		else if( FParse::Command(&Cmd,TEXT("HIGHEND")) )
		{
			bHandledCommand	= HandleHighendCommand( Cmd, Ar );	
		}

		if (!bHandledCommand)
		{
			Ar.Logf(TEXT("Unrecognized system setting (note that console variables can be set much easier)"));
		}
		else
		{
			// Write the new settings to the INI.
			SaveToIni();
		}
	}

	return bHandledCommand;
}
Example #6
0
FGlobalComponentReregisterContext::FGlobalComponentReregisterContext(const TArray<UClass*>& ExcludeComponents)
{
	ActiveGlobalReregisterContextCount++;

	// wait until resources are released
	FlushRenderingCommands();

	// Detach only actor components that are not in the excluded list
	for (auto* Component : TObjectRange<UActorComponent>())
	{
		bool bShouldReregister=true;
		for (UClass* ExcludeClass : ExcludeComponents)
		{
			if( ExcludeClass &&
				Component->IsA(ExcludeClass) )
			{
				bShouldReregister = false;
				break;
			}
		}
		if( bShouldReregister )
		{
			new(ComponentContexts) FComponentReregisterContext(Component);		
		}
	}
}
FGlobalComponentReregisterContext::FGlobalComponentReregisterContext(const TArray<AActor*>& InParentActors)
{
	ActiveGlobalReregisterContextCount++;

	// wait until resources are released
	FlushRenderingCommands();

	// Detach only actor components that are children of the actors list provided
	for(TObjectIterator<UActorComponent> ComponentIt;ComponentIt;++ComponentIt)
	{
		bool bShouldReregister=false;
		UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(*ComponentIt);
		if (PrimitiveComponent && PrimitiveComponent->ReplacementPrimitive.Get())
		{
			UPrimitiveComponent* ReplacementPrimitive = PrimitiveComponent->ReplacementPrimitive.Get();
			AActor* ParentActor = Cast<AActor>(ReplacementPrimitive->GetOuter());
			if (ParentActor && InParentActors.Contains(ParentActor))
			{
				bShouldReregister = true;
			}
		}
		if( bShouldReregister )
		{
			new(ComponentContexts) FComponentReregisterContext(*ComponentIt);		
		}
	}
}
void FD3D11Viewport::ConditionalResetSwapChain(bool bIgnoreFocus)
{
	if(!bIsValid)
	{
		// Check if the viewport's window is focused before resetting the swap chain's fullscreen state.
		HWND FocusWindow = ::GetFocus();
		const bool bIsFocused = FocusWindow == WindowHandle;
		const bool bIsIconic = !!::IsIconic( WindowHandle );
		if(bIgnoreFocus || (bIsFocused && !bIsIconic) )
		{
			FlushRenderingCommands();

			// Store the current cursor clip rectangle as it can be lost when fullscreen is reset.
			RECT OriginalCursorRect;
			GetClipCursor(&OriginalCursorRect);

			HRESULT Result = SwapChain->SetFullscreenState(bIsFullscreen,NULL);
			if(SUCCEEDED(Result))
			{
				ClipCursor(&OriginalCursorRect);
				bIsValid = true;
			}
			else
			{
				// Even though the docs say SetFullscreenState always returns S_OK, that doesn't always seem to be the case.
				UE_LOG(LogD3D11RHI, Log, TEXT("IDXGISwapChain::SetFullscreenState returned %08x; waiting for the next frame to try again."),Result);
			}
		}
	}
}
void FDebugViewModeMaterialProxy::ValidateAllShaders(OUT FTexCoordScaleMap& TexCoordScales)
{
	FlushRenderingCommands();

	for (TMap<const FMaterial*, FDebugViewModeMaterialProxy*>::TIterator It(DebugMaterialShaderMap); It; ++It)
	{
		const FMaterial* OriginalMaterial = It.Key();
		FDebugViewModeMaterialProxy* DebugMaterial = It.Value();

		if (OriginalMaterial && DebugMaterial && OriginalMaterial->GetGameThreadShaderMap() && DebugMaterial->GetGameThreadShaderMap())
		{
			const FUniformExpressionSet& DebugViewUniformExpressionSet = DebugMaterial->GetGameThreadShaderMap()->GetUniformExpressionSet();
			const FUniformExpressionSet& OrignialUniformExpressionSet = OriginalMaterial->GetGameThreadShaderMap()->GetUniformExpressionSet();

			if (!(DebugViewUniformExpressionSet == OrignialUniformExpressionSet))
			{
				// This will happen when the debug shader compiled misses logic. Usually caused by custom features in the original shader compilation not implemented in FDebugViewModeMaterialProxy.
				UE_LOG(TextureStreamingBuild, Verbose, TEXT("Uniform expression set mismatch for %s, skipping shader"), *DebugMaterial->GetMaterialInterface()->GetName());

				// Here we can't destroy the invalid material because it would trigger ClearAllShaders.
				DebugMaterial->MarkAsInvalid();
				TexCoordScales.Remove(DebugMaterial->GetMaterialInterface());
			}
		}
		else if (DebugMaterial)
		{
			UE_LOG(TextureStreamingBuild, Verbose, TEXT("Can't get valid shadermap for %s, skipping shader"), *DebugMaterial->GetMaterialInterface()->GetName());

			// Here we can't destroy the invalid material because it would trigger ClearAllShaders.
			DebugMaterial->MarkAsInvalid();
			TexCoordScales.Remove(DebugMaterial->GetMaterialInterface());
		}
	}
}
	/** Initialization constructor. */
	FNiagaraScriptCompileContext(UNiagaraScript* Script)
	{
		// wait until resources are released
		FlushRenderingCommands();

		// Reregister all components usimg Script.
		for (TObjectIterator<UNiagaraComponent> ComponentIt; ComponentIt; ++ComponentIt)
		{
			UNiagaraComponent* Comp = *ComponentIt;
			TSharedPtr<FNiagaraEffectInstance> Inst = Comp->GetEffectInstance();
			if (Inst.IsValid())
			{
				TArray<TSharedPtr<FNiagaraSimulation>>& Emitters = Inst->GetEmitters();
				for (TSharedPtr<FNiagaraSimulation> Sim : Emitters)
				{
					if (Sim.IsValid())
					{
						if (UNiagaraEmitterProperties* Props = Sim->GetProperties().Get())
						{
							if (Props->UpdateScriptProps.Script == Script)
							{
								new(ComponentContexts)FNiagaraComponentReregisterContext(Comp, &Props->UpdateScriptProps, Props);
							}
							else if (Props->SpawnScriptProps.Script == Script)
							{
								new(ComponentContexts)FNiagaraComponentReregisterContext(Comp, &Props->SpawnScriptProps, Props);
							}
						}						
					}
				}
			}
		}
	}
UDestructibleMesh* ImportDestructibleMeshFromApexDestructibleAsset(UObject* InParent, NxDestructibleAsset& ApexDestructibleAsset, FName Name, EObjectFlags Flags, FSkeletalMeshImportData* OutData, EDestructibleImportOptions::Type Options)
{
	// The APEX Destructible Asset contains an APEX Render Mesh Asset, get a pointer to this
	const physx::NxRenderMeshAsset* ApexRenderMesh = ApexDestructibleAsset.getRenderMeshAsset();
	if (ApexRenderMesh == NULL)
	{
		return NULL;
	}

	// Number of submeshes (aka "elements" in Unreal)
	const physx::PxU32 SubmeshCount = ApexRenderMesh->getSubmeshCount();
	if (SubmeshCount == 0)
	{
		return NULL;
	}

	// Make sure rendering is done - so we are not changing data being used by collision drawing.
	FlushRenderingCommands();

	UDestructibleMesh* DestructibleMesh = FindObject<UDestructibleMesh>(InParent, *Name.ToString());
	if (DestructibleMesh == NULL)
	{
		// Create the new UDestructibleMesh object if the one with the same name does not exist
		DestructibleMesh = NewObject<UDestructibleMesh>(InParent, Name, Flags);
	}
	
	if (!(Options & EDestructibleImportOptions::PreserveSettings))
	{
		// Store the current file path and timestamp for re-import purposes
		// @todo AssetImportData make a data class for Apex destructible assets
		DestructibleMesh->AssetImportData = NewObject<UAssetImportData>(DestructibleMesh);
		DestructibleMesh->AssetImportData->Update(UFactory::CurrentFilename);
		DestructibleMesh->AssetImportData->bDirty = false;
	}

	DestructibleMesh->PreEditChange(NULL);

	// Build FractureSettings from ApexDestructibleAsset in case we want to re-fracture
#if WITH_EDITORONLY_DATA
	DestructibleMesh->CreateFractureSettings();
	DestructibleMesh->FractureSettings->BuildRootMeshFromApexDestructibleAsset(ApexDestructibleAsset, Options);
	// Fill materials
	DestructibleMesh->FractureSettings->Materials.Reset(DestructibleMesh->Materials.Num());
	for (int32 MaterialIndex = 0; MaterialIndex < DestructibleMesh->Materials.Num(); ++MaterialIndex)
	{
		DestructibleMesh->FractureSettings->Materials.Insert(DestructibleMesh->Materials[MaterialIndex].MaterialInterface, MaterialIndex);
	}
#endif	// WITH_EDITORONLY_DATA

	if (!SetApexDestructibleAsset(*DestructibleMesh, ApexDestructibleAsset, OutData, Options))
	{
		// should remove this destructible mesh. if not, this object causes a crash when ticking because it doesn't have proper rendering resources
		// @TODO : creates this destructible mesh after loading data completely
		DestructibleMesh->PostEditChange();
		DestructibleMesh->ConditionalBeginDestroy();
		return NULL;
	}

	return DestructibleMesh;
}
void UNiagaraComponent::OnRegister()
{
	Super::OnRegister();
	if (Asset)
	{
		if (!EffectInstance)
		{
			EffectInstance = new FNiagaraEffectInstance(Asset, this);
		}
		{
			EffectInstance->Init(this);

			// initialize all render modules
			ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
				FChangeNiagaraRenderModule,
				FNiagaraEffectInstance*, InEffect, this->EffectInstance,
				UNiagaraComponent*, InComponent, this,
				{
					for (TSharedPtr<FNiagaraSimulation> Emitter : InEffect->GetEmitters())
					{
						Emitter->SetRenderModuleType(Emitter->GetProperties()->RenderModuleType, InComponent->GetWorld()->FeatureLevel);
					}
					InEffect->RenderModuleupdate();
				}
			);
			FlushRenderingCommands();
		}
		VectorVM::Init();
	}
Example #13
0
/** Invalidates the light's cached lighting with the option to recreate the light Guids. */
void ULightComponent::InvalidateLightingCacheInner(bool bRecreateLightGuids)
{
	// Save the light state for transactions.
	Modify();

	// Detach the component from the scene for the duration of this function.
	FComponentReregisterContext ReregisterContext(this);

	// Block until the RT processes the unregister before modifying variables that it may need to access
	FlushRenderingCommands();

	StaticShadowDepthMap.Empty();
	BeginReleaseResource(&StaticShadowDepthMap);

	bPrecomputedLightingIsValid = false;

	if (bRecreateLightGuids)
	{
		// Create new guids for light.
		UpdateLightGUIDs();
	}
	else
	{
		ValidateLightGUIDs();
		ShadowMapChannel = INDEX_NONE;
	}
	
	// Send to render thread
	MarkRenderStateDirty();
}
FGlobalComponentReregisterContext::FGlobalComponentReregisterContext(const TArray<UClass*>& ExcludeComponents)
{
	ActiveGlobalReregisterContextCount++;

	// wait until resources are released
	FlushRenderingCommands();

	// Detach only actor components that are not in the excluded list
	for(TObjectIterator<UActorComponent> ComponentIt;ComponentIt;++ComponentIt)
	{
		bool bShouldReregister=true;
		for( int32 Idx=0; Idx < ExcludeComponents.Num(); Idx++ )
		{
			UClass* ExcludeClass = ExcludeComponents[Idx];
			if( ExcludeClass &&
				ComponentIt->IsA(ExcludeClass) )
			{
				bShouldReregister = false;
				break;
			}
		}
		if( bShouldReregister )
		{
			new(ComponentContexts) FComponentReregisterContext(*ComponentIt);		
		}
	}
}
Example #15
0
void BeginRecompileGlobalShaders(const TArray<FShaderType*>& OutdatedShaderTypes, EShaderPlatform ShaderPlatform)
{
	if( !FPlatformProperties::RequiresCookedData() )
	{
		// Flush pending accesses to the existing global shaders.
		FlushRenderingCommands();

		TShaderMap<FGlobalShaderType>* GlobalShaderMap = GetGlobalShaderMap(ShaderPlatform);

		for (int32 TypeIndex = 0; TypeIndex < OutdatedShaderTypes.Num(); TypeIndex++)
		{
			FGlobalShaderType* CurrentGlobalShaderType = OutdatedShaderTypes[TypeIndex]->GetGlobalShaderType();
			if (CurrentGlobalShaderType)
			{
				UE_LOG(LogShaders, Log, TEXT("Flushing Global Shader %s"), CurrentGlobalShaderType->GetName());
				GlobalShaderMap->RemoveShaderType(CurrentGlobalShaderType);
				
				//invalidate global bound shader states so they will be created with the new shaders the next time they are set (in SetGlobalBoundShaderState)
				for(TLinkedList<FGlobalBoundShaderStateResource*>::TIterator It(FGlobalBoundShaderStateResource::GetGlobalBoundShaderStateList());It;It.Next())
				{
					BeginUpdateResourceRHI(*It);
				}
			}
		}

		VerifyGlobalShaders(ShaderPlatform, false);
	}
}
FMediaFoundationMovieStreamer::~FMediaFoundationMovieStreamer()
{
    CloseMovie();
    CleanupRenderingResources();

    FlushRenderingCommands();
    TextureFreeList.Empty();
}
void FLODUtilities::RemoveLOD(FSkeletalMeshUpdateContext& UpdateContext, int32 DesiredLOD )
{
	USkeletalMesh* SkeletalMesh = UpdateContext.SkeletalMesh;
	FSkeletalMeshResource* SkelMeshResource = SkeletalMesh->GetImportedResource();

	if( SkelMeshResource->LODModels.Num() == 1 )
	{
		FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "NoLODToRemove", "No LODs to remove!") );
		return;
	}

	// Now display combo to choose which LOD to remove.
	TArray<FString> LODStrings;
	LODStrings.AddZeroed( SkelMeshResource->LODModels.Num()-1 );
	for(int32 i=0; i<SkelMeshResource->LODModels.Num()-1; i++)
	{
		LODStrings[i] = FString::Printf( TEXT("%d"), i+1 );
	}

	check( SkeletalMesh->LODInfo.Num() == SkelMeshResource->LODModels.Num() );

	// If its a valid LOD, kill it.
	if( DesiredLOD > 0 && DesiredLOD < SkelMeshResource->LODModels.Num() )
	{
		//We'll be modifying the skel mesh data so reregister

		//TODO - do we need to reregister something else instead?
		FMultiComponentReregisterContext ReregisterContext(UpdateContext.AssociatedComponents);

		// Release rendering resources before deleting LOD
		SkelMeshResource->ReleaseResources();

		// Block until this is done
		FlushRenderingCommands();

		SkelMeshResource->LODModels.RemoveAt(DesiredLOD);
		SkeletalMesh->LODInfo.RemoveAt(DesiredLOD);
		SkeletalMesh->InitResources();

		RefreshLODChange(SkeletalMesh);

		// Set the forced LOD to Auto.
		for(auto Iter = UpdateContext.AssociatedComponents.CreateIterator(); Iter; ++Iter)
		{
			USkinnedMeshComponent* SkinnedComponent = Cast<USkinnedMeshComponent>(*Iter);
			if(SkinnedComponent)
			{
				SkinnedComponent->ForcedLodModel = 0;
			}
		}
		
		//Notify calling system of change
		UpdateContext.OnLODChanged.ExecuteIfBound();

		// Mark things for saving.
		SkeletalMesh->MarkPackageDirty();
	}
}
FDefaultGameMoviePlayer::~FDefaultGameMoviePlayer()
{
	if( bInitialized )
	{
		// This should not happen if initialize was called correctly.  This is a fallback to ensure that the movie player rendering tickable gets unregistered on the rendering thread correctly
		Shutdown();
		FlushRenderingCommands();
	}
}
Example #19
0
FTileItemThumbnail::~FTileItemThumbnail()
{
	BeginReleaseResource(ThumbnailTexture);
	
	// Wait for all resources to be released
	FlushRenderingCommands();
	delete ThumbnailTexture;
	ThumbnailTexture = NULL;
}
	virtual void StartupModule() override
	{
		// register settings detail panel customization
		FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
		PropertyModule.RegisterCustomClassLayout(
			"IOSRuntimeSettings",
			FOnGetDetailCustomizationInstance::CreateStatic(&FIOSTargetSettingsCustomization::MakeInstance)
		);

		FOnUpdateMaterialShaderQuality UpdateMaterials = FOnUpdateMaterialShaderQuality::CreateLambda([]()
		{
			FGlobalComponentRecreateRenderStateContext Recreate;
			FlushRenderingCommands();
			UMaterial::AllMaterialsCacheResourceShadersForRendering();
			UMaterialInstance::AllMaterialsCacheResourceShadersForRendering();
		});

		PropertyModule.RegisterCustomClassLayout(
			UShaderPlatformQualitySettings::StaticClass()->GetFName(),
			FOnGetDetailCustomizationInstance::CreateStatic(&FMaterialShaderQualitySettingsCustomization::MakeInstance, UpdateMaterials)
			);

		PropertyModule.NotifyCustomizationModuleChanged();

		// register settings
		ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");

		if (SettingsModule != nullptr)
		{
			SettingsModule->RegisterSettings("Project", "Platforms", "iOS",
				LOCTEXT("RuntimeSettingsName", "iOS"),
				LOCTEXT("RuntimeSettingsDescription", "Settings and resources for the iOS platform"),
				GetMutableDefault<UIOSRuntimeSettings>()
			);

			{
				static FName NAME_OPENGL_ES2_IOS(TEXT("GLSL_ES2_IOS"));
				const UShaderPlatformQualitySettings* IOSMaterialQualitySettings = UMaterialShaderQualitySettings::Get()->GetShaderPlatformQualitySettings(NAME_OPENGL_ES2_IOS);
				SettingsModule->RegisterSettings("Project", "Platforms", "iOSES2Quality",
					LOCTEXT("IOSES2QualitySettingsName", "iOS Material Quality - ES2"),
					LOCTEXT("IOSES2QualitySettingsDescription", "Settings for iOS ES2 material quality"),
					IOSMaterialQualitySettings
					);
			}

			{
				static FName NAME_SF_METAL(TEXT("SF_METAL"));
				const UShaderPlatformQualitySettings* IOSMaterialQualitySettings = UMaterialShaderQualitySettings::Get()->GetShaderPlatformQualitySettings(NAME_SF_METAL);
				SettingsModule->RegisterSettings("Project", "Platforms", "iOSMetalQuality",
					LOCTEXT("IOSMetalQualitySettingsName", "iOS Material Quality - Metal"),
					LOCTEXT("IOSMetalQualitySettingsDescription", "Settings for iOS Metal material quality"),
					IOSMaterialQualitySettings
				);
			}
		}
	}
UDestructibleMesh* ImportDestructibleMeshFromApexDestructibleAsset(UObject* InParent, NxDestructibleAsset& ApexDestructibleAsset, FName Name, EObjectFlags Flags, FSkeletalMeshImportData* OutData, EImportOptions::Type Options)
{
	// The APEX Destructible Asset contains an APEX Render Mesh Asset, get a pointer to this
	const physx::NxRenderMeshAsset* ApexRenderMesh = ApexDestructibleAsset.getRenderMeshAsset();
	if (ApexRenderMesh == NULL)
	{
		return NULL;
	}

	// Number of submeshes (aka "elements" in Unreal)
	const physx::PxU32 SubmeshCount = ApexRenderMesh->getSubmeshCount();
	if (SubmeshCount == 0)
	{
		return NULL;
	}

	// Make sure rendering is done - so we are not changing data being used by collision drawing.
	FlushRenderingCommands();

	UDestructibleMesh* DestructibleMesh = FindObject<UDestructibleMesh>(InParent, *Name.ToString());
	if (DestructibleMesh == NULL)
	{
		// Create the new UDestructibleMesh object if the one with the same name does not exist
		DestructibleMesh = CastChecked<UDestructibleMesh>(StaticConstructObject(UDestructibleMesh::StaticClass(), InParent, Name, Flags));
	}
	
	if (!(Options & EImportOptions::PreserveSettings))
	{
		// Store the current file path and timestamp for re-import purposes
		// @todo AssetImportData make a data class for Apex destructible assets
		DestructibleMesh->AssetImportData = ConstructObject<UAssetImportData>(UAssetImportData::StaticClass(), DestructibleMesh);
		DestructibleMesh->AssetImportData->SourceFilePath = FReimportManager::SanitizeImportFilename(UFactory::CurrentFilename, DestructibleMesh);
		DestructibleMesh->AssetImportData->SourceFileTimestamp = IFileManager::Get().GetTimeStamp(*UFactory::CurrentFilename).ToString();
	}

	DestructibleMesh->PreEditChange(NULL);

	// Build FractureSettings from ApexDestructibleAsset in case we want to re-fracture
#if WITH_EDITORONLY_DATA
	DestructibleMesh->CreateFractureSettings();
	DestructibleMesh->FractureSettings->BuildRootMeshFromApexDestructibleAsset(ApexDestructibleAsset, Options);
	// Fill materials
	DestructibleMesh->FractureSettings->Materials.Reset(DestructibleMesh->Materials.Num());
	for (int32 MaterialIndex = 0; MaterialIndex < DestructibleMesh->Materials.Num(); ++MaterialIndex)
	{
		DestructibleMesh->FractureSettings->Materials.Insert(DestructibleMesh->Materials[MaterialIndex].MaterialInterface, MaterialIndex);
	}
#endif	// WITH_EDITORONLY_DATA

	if (!SetApexDestructibleAsset(*DestructibleMesh, ApexDestructibleAsset, OutData, Options))
	{
		return NULL;
	}

	return DestructibleMesh;
}
Example #22
0
	void AddComponentToRefresh(UActorComponent* Component)
	{
		if (ComponentContexts.Num() == 0)
		{
			// wait until resources are released
			FlushRenderingCommands();
		}

		new (ComponentContexts) FComponentReregisterContext(Component);
	}
void FVulkanPipelineStateCache::RebuildCache()
{
	UE_LOG(LogVulkanRHI, Warning, TEXT("Rebuilding pipeline cache; ditching %d entries"), DiskEntries.Num());

	if (IsInGameThread())
	{
		FlushRenderingCommands();
	}
	DestroyCache();
}
Example #24
0
FGlobalComponentRecreateRenderStateContext::FGlobalComponentRecreateRenderStateContext()
{
	// wait until resources are released
	FlushRenderingCommands();

	// recreate render state for all components.
	for (auto* Component : TObjectRange<UActorComponent>())
	{
		new(ComponentContexts) FComponentRecreateRenderStateContext(Component);
	}
}
FShotThumbnail::~FShotThumbnail()
{
	BeginReleaseResource( Texture );

	FlushRenderingCommands();

	if (Texture) 
	{
		delete Texture;
	}
}
FGlobalComponentReregisterContext::FGlobalComponentReregisterContext()
{
	ActiveGlobalReregisterContextCount++;

	// wait until resources are released
	FlushRenderingCommands();

	// Detach all actor components.
	for(TObjectIterator<UActorComponent> ComponentIt;ComponentIt;++ComponentIt)
	{
		new(ComponentContexts) FComponentReregisterContext(*ComponentIt);		
	}
}
Example #27
0
FGlobalComponentReregisterContext::FGlobalComponentReregisterContext()
{
	ActiveGlobalReregisterContextCount++;

	// wait until resources are released
	FlushRenderingCommands();

	// Detach all actor components.
	for(auto* Component : TObjectRange<UActorComponent>())
	{
		new(ComponentContexts) FComponentReregisterContext(Component);
	}
}
void FDebugViewModeMaterialProxy::ClearAllShaders()
{
	if (bReentrantCall || DebugMaterialShaderMap.Num() == 0) return;

	FlushRenderingCommands();

	bReentrantCall = true;
	for (TMap<const FMaterial*, FDebugViewModeMaterialProxy*>::TIterator It(DebugMaterialShaderMap); It; ++It)
	{
		FDebugViewModeMaterialProxy* Proxy = It.Value();
		delete Proxy;
	}
	DebugMaterialShaderMap.Empty();

	bReentrantCall = false;
}
/**
 * Helper for ApplyNewSettings when the engine is running. Applies the changes needed for the runtime system.
 *
 * We can assume the game is running if this code is called.
 */
void FSystemSettings::ApplySettingsAtRuntime(const FSystemSettingsData& NewSettings, bool bWriteToIni)
{
	// Some of these settings are shared between threads, so we
	// must flush the rendering thread before changing anything.
	FlushRenderingCommands();

	// Track settings we might have to put back
	FExposedTextureLODSettings InMemoryTextureLODSettings = TextureLODSettings;

	// Read settings from .ini.  This is necessary because settings which need to wait for a restart
	// will be on disk but may not be in memory.  Therefore, we read from disk before capturing old
	// values to revert to.
	LoadFromIni();

	// see what settings are actually changing.
	// Ugly casts because system settings is multi-inherited from all the consituent classes for backwards compatibility

	// Texture Detail
	bool bTextureDetailChanged = (const FSystemSettingsDataTextureDetail&)(*this) != (const FSystemSettingsDataTextureDetail&)NewSettings;

	// Make a copy of the existing settings so we can compare for changes
	FSystemSettingsData OldData = *this;

	// Set new settings. Would look prettier if we didn't derive from the Data class...
	(FSystemSettingsData&)(*this) = NewSettings;

	// apply any runtime changes that need to be made
	bool bUpdateTextureStreamingSucceeded = false;
	if (bTextureDetailChanged)
	{
		bUpdateTextureStreamingSucceeded = UTexture::ForceUpdateTextureStreaming();
	}

	// If requested, save the settings to ini.
	if ( bWriteToIni )
	{
		SaveToIni();
	}

	// If texture detail settings couldn't be applied because we're loading seekfree,
	// revert the new settings to their previous in-memory values.
	if ( bTextureDetailChanged && !bUpdateTextureStreamingSucceeded )
	{
		TextureLODSettings = InMemoryTextureLODSettings;
	}
}
void UVaQuoleUIComponent::DestroyUITexture()
{
	if (Texture)
	{
		Texture->RemoveFromRoot();

		if (Texture->Resource)
		{
			BeginReleaseResource(Texture->Resource);

			FlushRenderingCommands();
		}

		Texture->MarkPendingKill();
		Texture = nullptr;
	}
}