Skip to content

Commit

Permalink
Fix a crash when AutoJCM sets the PostProcessAnimation
Browse files Browse the repository at this point in the history
Fix a crash when AutoJCM sets the PostProcessAnimation.
First the old style PostProcessAnimation would get set, then the AutoJCM.  This could crash if the animation was updating during this.
  • Loading branch information
David-Vodhanel committed Apr 28, 2022
1 parent 8aee84b commit e2a1d84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,8 @@ UObject* FDazToUnrealModule::ImportFromDaz(TSharedPtr<FJsonObject> JsonObject)
}

// Import FBX
UObject* NewObject = ImportFBXAsset(UpdatedFBXFile, CharacterFolder, AssetType, CharacterType, CharacterTypeName);
bool bSetPostProcessAnimation = !FDazToUnrealMorphs::IsAutoJCMImport(JsonObject);
UObject* NewObject = ImportFBXAsset(UpdatedFBXFile, CharacterFolder, AssetType, CharacterType, CharacterTypeName, bSetPostProcessAnimation);

// If this is a Pose transfer, an AnimSequence was created. Make a PoseAsset from it.
if (AssetType == DazAssetType::Pose)
Expand Down Expand Up @@ -1237,7 +1238,7 @@ bool FDazToUnrealModule::ImportTextureAssets(TArray<FString>& SourcePaths, FStri
return false;
}

UObject* FDazToUnrealModule::ImportFBXAsset(const FString& SourcePath, const FString& ImportLocation, const DazAssetType& AssetType, const DazCharacterType& CharacterType, const FString& CharacterTypeName)
UObject* FDazToUnrealModule::ImportFBXAsset(const FString& SourcePath, const FString& ImportLocation, const DazAssetType& AssetType, const DazCharacterType& CharacterType, const FString& CharacterTypeName, const bool bSetPostProcessAnimation)
{
FAssetToolsModule& AssetToolsModule = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools");
UDazToUnrealSettings* CachedSettings = GetMutableDefault<UDazToUnrealSettings>();
Expand Down Expand Up @@ -1349,7 +1350,7 @@ UObject* FDazToUnrealModule::ImportFBXAsset(const FString& SourcePath, const FSt
{
if (USkeletalMesh* SkeletalMesh = Cast<USkeletalMesh>(ImportedAsset))
{
if (CachedSettings->SkeletonPostProcessAnimation.Contains(SkeletonPath))
if (bSetPostProcessAnimation && CachedSettings->SkeletonPostProcessAnimation.Contains(SkeletonPath))
{
#if ENGINE_MAJOR_VERSION > 4
SkeletalMesh->SetPostProcessAnimBlueprint(CachedSettings->SkeletonPostProcessAnimation[SkeletonPath].TryLoadClass<UAnimInstance>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class FDazToUnrealModule : public IModuleInterface
bool ImportTextureAssets(TArray<FString>& SourcePaths, FString& ImportLocation);

/** Imports the modified FBX file*/
UObject* ImportFBXAsset(const FString& SourcePath, const FString& ImportLocation, const DazAssetType& AssetType, const DazCharacterType& CharacterType, const FString& CharacterTypeName);
UObject* ImportFBXAsset(const FString& SourcePath, const FString& ImportLocation, const DazAssetType& AssetType, const DazCharacterType& CharacterType, const FString& CharacterTypeName, const bool bSetPostProcessAnimation);

/** Function for creating the Material Instances for the model*/
//bool CreateMaterials(const FString CharacterMaterialFolder, const FString CharacterTexturesFolder, const TArray<FString>& MaterialNames, TMap<FString, TArray<FDUFTextureProperty>> MaterialProperties, const DazCharacterType CharacterType);
Expand Down

0 comments on commit e2a1d84

Please sign in to comment.