Skip to content

Commit

Permalink
Update to work with UnrealEngine 4.22
Browse files Browse the repository at this point in the history
v1.2: Update code re UnrealEngine 4.22 + respective documentation update.
  • Loading branch information
Sserpenthraxus-nv committed Jun 4, 2019
1 parent 9419d63 commit da217fe
Show file tree
Hide file tree
Showing 16 changed files with 170 additions and 146 deletions.
5 changes: 3 additions & 2 deletions Source/Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ r.CustomDepthTemporalAAJitter=False
r.CustomDepth=0

[/Script/LinuxTargetPlatform.LinuxTargetSettings]
; [NVIDIA]
; Using VULKAN RHI cause the Depth and ClassSegmentation feature extractor to be black
; We should just use OpenGL 4.30 for now
-TargetedRHIs=SF_VULKAN_SM5
Expand Down Expand Up @@ -46,7 +47,6 @@ DefaultFluidFriction=0.300000
SimulateScratchMemorySize=262144
RagdollAggregateThreshold=4
TriangleMeshTriangleMinAreaThreshold=5.000000
bEnableAsyncScene=False
bEnableShapeSharing=False
bEnablePCM=True
bEnableStabilization=False
Expand Down Expand Up @@ -79,7 +79,8 @@ bSubsteppingAsync=False
MaxSubstepDeltaTime=0.016667
MaxSubsteps=6
SyncSceneSmoothingFactor=0.000000
AsyncSceneSmoothingFactor=0.990000
InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10
DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)


2 changes: 1 addition & 1 deletion Source/NDDS.uproject
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"FileVersion": 3,
"EngineAssociation": "4.21",
"EngineAssociation": "4.22",
"Category": "",
"Description": "",
"Modules": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public DomainRandomizationDNN(ReadOnlyTargetRules Target) : base(Target)
"Engine",
"RHI",
"RenderCore",
"ShaderCore",
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ void URandomMaterialComponent::BeginPlay()
MaterialStreamer.Init(MaterialDirectories, UMaterialInterface::StaticClass());
}

// NOTE: Only randomize once if there's only 1 material to choose from
if (bUseAllMaterialInDirectories)
{
if (MaterialStreamer.GetAssetsCount() <= 1)
{
bOnlyRandomizeOnce = true;
}
}
else if (MaterialList.Num() <= 1)
{
bOnlyRandomizeOnce = true;
}

Super::BeginPlay();
}

Expand All @@ -59,6 +72,16 @@ void URandomMaterialComponent::OnRandomization_Implementation()

bool bActorMaterialChanged = false;

// Update the owner's mesh components list if it's not initialized
if (OwnerMeshComponents.Num() == 0)
{
AActor* OwnerActor = GetOwner();
if (OwnerActor)
{
OwnerMeshComponents = DRUtils::GetValidChildMeshComponents(OwnerActor);
}
}

if (bAffectMeshComponents && (OwnerMeshComponents.Num() > 0))
{
// TODO: Add option to use the same material to all the material slots or not
Expand Down Expand Up @@ -135,9 +158,7 @@ void URandomMaterialComponent::PostEditChangeProperty(struct FPropertyChangedEve
bool URandomMaterialComponent::HasMaterialToRandomize() const
{
#if WITH_EDITORONLY_DATA
return bUseAllMaterialInDirectories?
MaterialStreamer.HasAssets() :
(MaterialList.Num() > 0);
return bUseAllMaterialInDirectories ? MaterialStreamer.HasAssets() : (MaterialList.Num() > 0);
#else
return false;
#endif //WITH_EDITORONLY_DATA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ void URandomMeshComponent::OnRandomization_Implementation()
OwnerActor->GetComponents(RandomMatCompList);
for (auto RandMatComp : RandomMatCompList)
{
if (RandMatComp && RandMatComp->ShouldRandomize())
if (RandMatComp)
{
RandMatComp->Randomize();
RandMatComp->Randomize(true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,11 @@ void FRandomAssetStreamer::ScanPath()
#endif // WITH_EDITORONLY_DATA
}

int FRandomAssetStreamer::GetAssetsCount() const
{
return AllAssetReferences.Num();
}

bool FRandomAssetStreamer::HasAssets() const
{
return (AllAssetReferences.Num() > 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ struct DOMAINRANDOMIZATIONDNN_API FRandomAssetStreamer
void Init(const TArray<FDirectoryPath>& InAssetDirectories, UClass* InAssetClass);
void ScanPath();

int GetAssetsCount() const;
bool HasAssets() const;
FSoftObjectPath GetNextAssetReference();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ void URandomComponentBase::StopRandomizing()
bShouldRandomize = false;
}

void URandomComponentBase::Randomize()
void URandomComponentBase::Randomize(bool bForce)
{
if (ShouldRandomize())
if (bForce || ShouldRandomize())
{
OnRandomization();
bAlreadyRandomized = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DOMAINRANDOMIZATIONDNN_API URandomComponentBase : public UActorComponent
URandomComponentBase();

bool ShouldRandomize() const;
void Randomize();
void Randomize(bool bForce = false);
void StartRandomizing();
void StopRandomizing();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ void FNVDataObjectEditorToolkit::InitEditor(const EToolkitMode::Type Mode, const
const bool bAllowFavorites = true;
const bool bIsLockable = false;

FEditorDelegates::OnAssetPostImport.AddRaw(this, &FNVDataObjectEditorToolkit::HandleAssetPostImport);
FEditorDelegates::OnAssetReimport.AddRaw(this, &FNVDataObjectEditorToolkit::HandleAssetReimport);
GEditor->GetEditorSubsystem<UImportSubsystem>()->OnAssetPostImport.AddRaw(this, &FNVDataObjectEditorToolkit::HandleAssetPostImport);
GEditor->GetEditorSubsystem<UImportSubsystem>()->OnAssetReimport.AddRaw(this, &FNVDataObjectEditorToolkit::HandleAssetReimport);

FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
const FDetailsViewArgs DetailsViewArgs(bIsUpdatable, bIsLockable, true, FDetailsViewArgs::ObjectsUseNameArea, false);
Expand Down Expand Up @@ -96,9 +96,8 @@ void FNVDataObjectEditorToolkit::InitEditor(const EToolkitMode::Type Mode, const

const bool bCreateDefaultStandaloneMenu = true;
const bool bCreateDefaultToolbar = true;
const bool bIsToolbarFocusable = true;
FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, DataObjectEditorAppIdentifier,
StandaloneDefaultLayout, bCreateDefaultStandaloneMenu, bCreateDefaultToolbar, EditingAssets, bIsToolbarFocusable);
StandaloneDefaultLayout, bCreateDefaultStandaloneMenu, bCreateDefaultToolbar, EditingAssets, true);

// @todo toolkit world centric editing
// Setup our tool's layout
Expand Down Expand Up @@ -129,7 +128,8 @@ void FNVDataObjectEditorToolkit::InitEditor(const EToolkitMode::Type Mode, const

FNVDataObjectEditorToolkit::~FNVDataObjectEditorToolkit()
{
FEditorDelegates::OnAssetPostImport.RemoveAll(this);
GEditor->GetEditorSubsystem<UImportSubsystem>()->OnAssetPostImport.RemoveAll(this);
GEditor->GetEditorSubsystem<UImportSubsystem>()->OnAssetReimport.RemoveAll(this);

DetailsView.Reset();
PropertiesTab.Reset();
Expand Down Expand Up @@ -267,21 +267,21 @@ FLinearColor FNVDataObjectEditorToolkit::GetWorldCentricTabColorScale() const
return FLinearColor(0.0f, 0.0f, 1.0f, 0.5f);
}

void FNVDataObjectEditorToolkit::RegisterTabSpawners(const TSharedRef<class FTabManager>& TabManager)
void FNVDataObjectEditorToolkit::RegisterTabSpawners(const TSharedRef<class FTabManager>& NewTabManager)
{
WorkspaceMenuCategory = TabManager->AddLocalWorkspaceMenuCategory(LOCTEXT("WorkspaceMenu_GenericAssetEditor", "Asset Editor"));
WorkspaceMenuCategory = NewTabManager->AddLocalWorkspaceMenuCategory(LOCTEXT("WorkspaceMenu_GenericAssetEditor", "Asset Editor"));

FAssetEditorToolkit::RegisterTabSpawners(TabManager);
FAssetEditorToolkit::RegisterTabSpawners(NewTabManager);

TabManager->RegisterTabSpawner(PropertiesTabId, FOnSpawnTab::CreateSP(this, &FNVDataObjectEditorToolkit::SpawnPropertiesTab))
NewTabManager->RegisterTabSpawner(PropertiesTabId, FOnSpawnTab::CreateSP(this, &FNVDataObjectEditorToolkit::SpawnPropertiesTab))
.SetDisplayName(LOCTEXT("PropertiesTab", "Details"))
.SetGroup(WorkspaceMenuCategory.ToSharedRef())
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.Details"));
}

void FNVDataObjectEditorToolkit::UnregisterTabSpawners(const TSharedRef<class FTabManager>& TabManager)
void FNVDataObjectEditorToolkit::UnregisterTabSpawners(const TSharedRef<class FTabManager>& OldTabManager)
{
FAssetEditorToolkit::UnregisterTabSpawners(TabManager);
FAssetEditorToolkit::UnregisterTabSpawners(OldTabManager);

TabManager->UnregisterTabSpawner(PropertiesTabId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ UObject* UNVDataObjectFactory::FactoryCreateText(UClass* InClass, UObject* InPar
}
else
{
FEditorDelegates::OnAssetPreImport.Broadcast(this, InClass, InParent, InName, Type);
GEditor->GetEditorSubsystem<UImportSubsystem>()->BroadcastAssetPreImport(this, InClass, InParent, InName, Type);

// Get the string from the input buffer
FString TextDataString;
Expand Down Expand Up @@ -219,8 +219,8 @@ EReimportResult::Type UNVDataObjectFactory::Reimport(UObject* Obj)
}
const FString SourceFilePath = DataObjectAsset->AssetImportData->GetFirstFilename();
const FString SourceFileName = FPaths::GetBaseFilename(SourceFilePath, true);
EObjectFlags ObjectFlags = RF_Public | RF_Standalone | RF_Transactional;
UNVDataObject* ImportedDataObject = UNVDataObject::DeserializeFromJsonFile(SourceFilePath, DataObjectAsset, *SourceFileName, ObjectFlags);
EObjectFlags DataObjectFlags = RF_Public | RF_Standalone | RF_Transactional;
UNVDataObject* ImportedDataObject = UNVDataObject::DeserializeFromJsonFile(SourceFilePath, DataObjectAsset, *SourceFileName, DataObjectFlags);
if (ImportedDataObject)
{
DataObjectAsset->DataObject = ImportedDataObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public NVSceneCapturer(ReadOnlyTargetRules Target) : base(Target)
{
PrivateIncludePaths.AddRange(new string[] { "NVSceneCapturer/Private" });

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "Json", "JsonUtilities", "InputCore", "RHI", "RenderCore", "ShaderCore"});
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "Json", "JsonUtilities", "InputCore", "RHI", "RenderCore"});
PublicDependencyModuleNames.AddRange(new string[] { "MovieSceneCapture", "ImageWrapper" });

PrivateDependencyModuleNames.AddRange(new string[] { "zlib", "UElibPNG" } );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ void FNVImageExporter_Thread::Stop()
{
// Trigger the event so the thread doesn't wait anymore
HavePendingImageEvent->Trigger();
// HavePendingImageEvent->Reset();
}
}

Expand Down
Loading

0 comments on commit da217fe

Please sign in to comment.