FPreviewScene::~FPreviewScene() { // Stop any audio components playing in this scene if( GEngine && GEngine->GetAudioDevice() ) { GEngine->GetAudioDevice()->Flush( GetWorld(), false ); } // Remove all the attached components for( int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++ ) { UActorComponent* Component = Components[ ComponentIndex ]; if (bForceAllUsedMipsResident) { // Remove the mip streaming override on the mesh to be removed UMeshComponent* pMesh = Cast<UMeshComponent>(Component); if (pMesh != NULL) { pMesh->SetTextureForceResidentFlag(false); } } Component->UnregisterComponent(); } PreviewWorld->CleanupWorld(); GEngine->DestroyWorldContext(GetWorld()); }
void FPreviewScene::RemoveComponent(UActorComponent* Component) { Component->UnregisterComponent(); Components.Remove(Component); if (bForceAllUsedMipsResident) { // Remove the mip streaming override on the old mesh UMeshComponent* pMesh = Cast<UMeshComponent>(Component); if (pMesh != NULL) { pMesh->SetTextureForceResidentFlag(false); } } }
void FJavascriptInGameScene::Destroy() { if (bDestroyed) return; // Stop any audio components playing in this scene if (GEngine) { UWorld* World = GetWorld(); if (World) { if (FAudioDevice* AudioDevice = World->GetAudioDevice()) { AudioDevice->Flush(GetWorld(), false); } } } // Remove all the attached components for (int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++) { UActorComponent* Component = Components[ComponentIndex]; if (bForceAllUsedMipsResident) { // Remove the mip streaming override on the mesh to be removed UMeshComponent* pMesh = Cast<UMeshComponent>(Component); if (pMesh != NULL) { pMesh->SetTextureForceResidentFlag(false); } } Component->UnregisterComponent(); } if (GEngine) { PreviewWorld->CleanupWorld(); GEngine->DestroyWorldContext(GetWorld()); } bDestroyed = true; }
void FPreviewScene::AddComponent(UActorComponent* Component,const FTransform& LocalToWorld) { Components.AddUnique(Component); USceneComponent* SceneComp = Cast<USceneComponent>(Component); if(SceneComp && SceneComp->GetAttachParent() == NULL) { SceneComp->SetRelativeTransform(LocalToWorld); } Component->RegisterComponentWithWorld(GetWorld()); if (bForceAllUsedMipsResident) { // Add a mip streaming override to the new mesh UMeshComponent* pMesh = Cast<UMeshComponent>(Component); if (pMesh != NULL) { pMesh->SetTextureForceResidentFlag(true); } } GetScene()->UpdateSpeedTreeWind(0.0); }