Skip to content

Commit efe58ec

Browse files
committed
- Fixed various issues with texture asset support in geometry input.
Updating the export options or resending the same texture now behaves properly. - Added the mandatory category specifier for Cookable properties that could cause issues when building the plugin as an engine plugin. - "Export Main Geo" is now properly taken into account for node name suffixes in the input system. This avoids bugs when two inputs points to the same asset with different value for that option.
1 parent e5e8285 commit efe58ec

File tree

5 files changed

+62
-42
lines changed

5 files changed

+62
-42
lines changed

Source/HoudiniEngine/Private/HoudiniEngineManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ FHoudiniEngineManager::StopHoudiniTicking()
119119
{
120120
if (IsInGameThread())
121121
{
122-
FTSTicker::GetCoreTicker().RemoveTicker(TickerHandle);
122+
FTSTicker::GetCoreTicker().RemoveTicker(TickerHandle);
123123
TickerHandle.Reset();
124124

125125
// Reset time for delayed notification.
@@ -628,7 +628,7 @@ FHoudiniEngineManager::ProcessCookable(UHoudiniCookable* HC)
628628
}
629629
else
630630
{
631-
// TODO COOKABLE: UPDATE ME! this only suppoRts Cookable with assets...
631+
// TODO COOKABLE: UPDATE ME! this only supports Cookable with assets...
632632
if (HC->IsHoudiniAssetSupported())
633633
{
634634
FGuid TaskGuid;

Source/HoudiniEngine/Private/HoudiniInputTranslator.cpp

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4902,22 +4902,26 @@ FHoudiniInputTranslator::HapiCreateInputNodeForTexture2D(
49024902
FString TextureName = InObjNodeName + TEXT("_") + InputTexture->GetName();
49034903
FHoudiniEngineUtils::SanitizeHAPIVariableName(TextureName);
49044904

4905+
// Only the ExportMainGeo and ImportAsRef options matter for Textures
4906+
FUnrealObjectInputOptions Options;
4907+
Options.bExportMainGeometry = InInputSettings.bExportMainGeometry;
4908+
Options.bImportAsReference = InInputSettings.bImportAsReference;
4909+
49054910
FUnrealObjectInputIdentifier Identifier;
4911+
Identifier = FUnrealObjectInputIdentifier(InputTexture, Options, true);
4912+
4913+
FUnrealObjectInputHandle InputNodeHandle;
49064914
FUnrealObjectInputHandle ParentHandle;
4907-
{
4908-
const FUnrealObjectInputOptions Options;
4909-
Identifier = FUnrealObjectInputIdentifier(InputTexture, Options, true);
4910-
4911-
FUnrealObjectInputHandle Handle;
4912-
if (FUnrealObjectInputUtils::NodeExistsAndIsNotDirty(Identifier, Handle))
4915+
{
4916+
if (FUnrealObjectInputUtils::NodeExistsAndIsNotDirty(Identifier, InputNodeHandle))
49134917
{
49144918
HAPI_NodeId NodeId = -1;
4915-
if (FUnrealObjectInputUtils::GetHAPINodeId(Handle, NodeId))
4919+
if (FUnrealObjectInputUtils::GetHAPINodeId(InputNodeHandle, NodeId))
49164920
{
49174921
if (!bInputNodesCanBeDeleted)
4918-
FUnrealObjectInputUtils::UpdateInputNodeCanBeDeleted(Handle, bInputNodesCanBeDeleted);
4922+
FUnrealObjectInputUtils::UpdateInputNodeCanBeDeleted(InputNodeHandle, bInputNodesCanBeDeleted);
49194923

4920-
InObject->InputNodeHandle = Handle;
4924+
InObject->InputNodeHandle = InputNodeHandle;
49214925
CreatedNodeId = NodeId;
49224926
return true;
49234927
}
@@ -4930,9 +4934,9 @@ FHoudiniInputTranslator::HapiCreateInputNodeForTexture2D(
49304934
// Set InputNodeId to the current NodeId associated with Handle, since that is what we are replacing.
49314935
// (Option changes could mean that InputNodeId is associated with a completely different entry, albeit for
49324936
// the same asset, in the manager)
4933-
if (Handle.IsValid())
4937+
if (InputNodeHandle.IsValid())
49344938
{
4935-
if (!FUnrealObjectInputUtils::GetHAPINodeId(Handle, CreatedNodeId))
4939+
if (!FUnrealObjectInputUtils::GetHAPINodeId(InputNodeHandle, CreatedNodeId))
49364940
CreatedNodeId = -1;
49374941
}
49384942
else
@@ -4942,7 +4946,6 @@ FHoudiniInputTranslator::HapiCreateInputNodeForTexture2D(
49424946
}
49434947

49444948
HAPI_NodeId GeoOutId = -1;
4945-
FUnrealObjectInputHandle InputNodeHandle;
49464949
bool bSuccess = true;
49474950
if (InInputSettings.bImportAsReference)
49484951
{
@@ -4966,36 +4969,51 @@ FHoudiniInputTranslator::HapiCreateInputNodeForTexture2D(
49664969
ParentNodeId = FHoudiniEngineUtils::HapiGetParentNodeId(CreatedNodeId);
49674970
}
49684971
else
4969-
{
4970-
if (CreatedNodeId < 0)
4972+
{
4973+
// Clean previously created nodes if needed
4974+
HAPI_NodeId PreviousInputNodeId = CreatedNodeId;
4975+
if (PreviousInputNodeId >= 0)
49714976
{
4972-
HAPI_Result Result = FHoudiniEngineUtils::CreateNode(ParentNodeId, TEXT("geo"), TextureName, true, &CreatedNodeId);
4973-
if (Result != HAPI_RESULT_SUCCESS)
4974-
{
4975-
HOUDINI_LOG_WARNING(TEXT("[FHoudiniEngineUtils::CreateInputNode]: CreateNode failed: %s"), *FHoudiniEngineUtils::GetErrorDescription());
4976-
return false;
4977-
}
4977+
HAPI_NodeId PreviousInputObjectNodeId = FHoudiniEngineUtils::HapiGetParentNodeId(PreviousInputNodeId);
4978+
if (FHoudiniApi::DeleteNode(FHoudiniEngine::Get().GetSession(), PreviousInputNodeId) != HAPI_RESULT_SUCCESS)
4979+
HOUDINI_LOG_WARNING(TEXT("Failed to cleanup the previous input node for %s."), *TextureName);
49784980

4979-
if (InInputSettings.bExportMainGeometry)
4980-
{
4981-
if (FUnrealTextureTranslator::CreateGeometryForTexture(CreatedNodeId, GeoOutId))
4982-
{
4983-
ParentNodeId = CreatedNodeId;
4984-
}
4985-
}
4986-
else
4981+
if (FHoudiniApi::DeleteNode(FHoudiniEngine::Get().GetSession(), PreviousInputObjectNodeId) != HAPI_RESULT_SUCCESS)
4982+
HOUDINI_LOG_WARNING(TEXT("Failed to cleanup the previous input object node for %s."), *TextureName);
4983+
4984+
// We've deleted the parent - make sure it exists and updates its ID
4985+
if (FUnrealObjectInputUtils::EnsureParentsExist(Identifier, ParentHandle, bInputNodesCanBeDeleted) && ParentHandle.IsValid())
4986+
FUnrealObjectInputUtils::GetHAPINodeId(ParentHandle, ParentNodeId);
4987+
}
4988+
4989+
4990+
// Create the geo node that will hold the COPnet and the quad geometry (if needed)
4991+
HAPI_Result Result = FHoudiniEngineUtils::CreateNode(ParentNodeId, TEXT("geo"), TextureName, true, &CreatedNodeId);
4992+
if (Result != HAPI_RESULT_SUCCESS)
4993+
{
4994+
HOUDINI_LOG_WARNING(TEXT("[FHoudiniEngineUtils::CreateInputNode]: CreateNode failed: %s"), *FHoudiniEngineUtils::GetErrorDescription());
4995+
return false;
4996+
}
4997+
4998+
if (InInputSettings.bExportMainGeometry)
4999+
{
5000+
// Create a quad with uvs and a coppreview material to "hold" the texture
5001+
if (FUnrealTextureTranslator::CreateGeometryForTexture(CreatedNodeId, GeoOutId))
49875002
{
49885003
ParentNodeId = CreatedNodeId;
49895004
}
49905005
}
49915006
else
49925007
{
4993-
ParentNodeId = FHoudiniEngineUtils::HapiGetParentNodeId(CreatedNodeId);
5008+
ParentNodeId = CreatedNodeId;
49945009
}
4995-
5010+
}
5011+
// Send the texture to COPs
49965012
bSuccess = FUnrealTextureTranslator::HapiCreateCOPTexture(
49975013
InputTexture, CreatedNodeId);
49985014

5015+
// Now that the textures has been created, cook the grid
5016+
// (this helps with visual issues when using session sync)
49995017
if (GeoOutId >= 0)
50005018
{
50015019
FHoudiniEngineUtils::HapiCookNode(GeoOutId);

Source/HoudiniEngine/Private/HoudiniPCGCookable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class HOUDINIENGINE_API UHoudiniPCGCookable : public UObject
119119
UPROPERTY(EditAnywhere, Category = Settings)
120120
bool bAutomaticallyDeleteAssets = true;
121121

122-
UPROPERTY(BlueprintReadWrite, EditAnywhere)
122+
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Houdini Cookable")
123123
TObjectPtr<UHoudiniCookable> Cookable;
124124

125125
UPROPERTY()

Source/HoudiniEngineRuntime/Private/HoudiniCookable.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class HOUDINIENGINERUNTIME_API UCookableComponentData : public UObject
335335

336336
UCookableComponentData();
337337

338-
UPROPERTY(VisibleAnywhere)
338+
UPROPERTY(VisibleAnywhere, Category = "Houdini Cookable")
339339
TWeakObjectPtr<USceneComponent> Component;
340340

341341
// Used to compare transform changes and whether we need to
@@ -912,7 +912,7 @@ class HOUDINIENGINERUNTIME_API UHoudiniCookable : public UObject, public IHoudin
912912
bool bHasHoudiniAsset;
913913

914914
// Structure containing the HDA data
915-
UPROPERTY(EditAnywhere)
915+
UPROPERTY(EditAnywhere, Category = "Houdini Cookable")
916916
TObjectPtr<UCookableHoudiniAssetData> HoudiniAssetData;
917917

918918
// PARAMETERS
@@ -921,7 +921,7 @@ class HOUDINIENGINERUNTIME_API UHoudiniCookable : public UObject, public IHoudin
921921
bool bHasParameters;
922922

923923
// Structure containing the parameter data
924-
UPROPERTY(EditAnywhere)
924+
UPROPERTY(EditAnywhere, Category = "Houdini Cookable")
925925
TObjectPtr<UCookableParameterData> ParameterData;
926926

927927
// INPUTS
@@ -930,7 +930,7 @@ class HOUDINIENGINERUNTIME_API UHoudiniCookable : public UObject, public IHoudin
930930
bool bHasInputs;
931931

932932
// Structure containing the input data
933-
UPROPERTY(EditAnywhere)
933+
UPROPERTY(EditAnywhere, Category = "Houdini Cookable")
934934
TObjectPtr<UCookableInputData> InputData;
935935

936936
// OUTPUTS
@@ -939,7 +939,7 @@ class HOUDINIENGINERUNTIME_API UHoudiniCookable : public UObject, public IHoudin
939939
bool bHasOutputs;
940940

941941
// Structure containing the output data
942-
UPROPERTY(EditAnywhere)
942+
UPROPERTY(EditAnywhere, Category = "Houdini Cookable")
943943
TObjectPtr<UCookableOutputData> OutputData;
944944

945945
// COMPONENTS / TRANSFORM
@@ -948,7 +948,7 @@ class HOUDINIENGINERUNTIME_API UHoudiniCookable : public UObject, public IHoudin
948948
bool bHasComponent; // bIsInWorld?
949949

950950
// Structure containing the component's data
951-
UPROPERTY(EditAnywhere)
951+
UPROPERTY(EditAnywhere, Category = "Houdini Cookable")
952952
TObjectPtr<UCookableComponentData> ComponentData;
953953

954954
// PDG
@@ -957,23 +957,23 @@ class HOUDINIENGINERUNTIME_API UHoudiniCookable : public UObject, public IHoudin
957957
bool bHasPDG;
958958

959959
// Structure containing the PDG data
960-
UPROPERTY(EditAnywhere)
960+
UPROPERTY(EditAnywhere, Category = "Houdini Cookable")
961961
TObjectPtr<UCookablePDGData> PDGData;
962962

963963
// Baking
964964
// Indicates if this cookable has access to baking
965965
UPROPERTY()
966966
bool bHasBaking;
967967
// Structure containing the Baking data
968-
UPROPERTY(EditAnywhere)
968+
UPROPERTY(EditAnywhere, Category = "Houdini Cookable")
969969
TObjectPtr<UCookableBakingData> BakingData;
970970

971971
// Proxy
972972
// Indicates if this cookable canm use proxy meshes
973973
UPROPERTY()
974974
bool bHasProxy;
975975
// Structure containing the Proxy data
976-
UPROPERTY(EditAnywhere)
976+
UPROPERTY(EditAnywhere, Category = "Houdini Cookable")
977977
TObjectPtr<UCookableProxyData> ProxyData;
978978

979979
//

Source/HoudiniEngineRuntime/Private/UnrealObjectInputRuntimeTypes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ FUnrealObjectInputOptions::GenerateNodeNameSuffix() const
373373
NameParts.Add(TEXT("landscape_edit_layers"));
374374
if (!bExportLevelInstanceContent)
375375
NameParts.Add(TEXT("level_instance_ref"));
376+
if(!bExportMainGeometry)
377+
NameParts.Add(TEXT("no_main_geo"));
376378
if (BoolOptions.Num() > 0)
377379
{
378380
for (const auto& BoolOption : BoolOptions)

0 commit comments

Comments
 (0)