Skip to content

Commit 0523094

Browse files
committed
- Added missing includes
- Fixed issues that could cause parameters/inputs to not be properly set after rebuilding/recooking/on first cook after load. - Added new setting, "UsePresetsForParameters" that disables setting parameters in bulk with presets - this is to be used for troubleshooting only.
1 parent e68eddd commit 0523094

File tree

8 files changed

+85
-35
lines changed

8 files changed

+85
-35
lines changed

Source/HoudiniEngine/Private/HoudiniEngineManager.cpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -831,13 +831,23 @@ FHoudiniEngineManager::ProcessComponent(UHoudiniAssetComponent* HAC)
831831
if (!bIsNodeSyncComponent && HAC->AssetId != INDEX_NONE)
832832
{
833833
// Make sure no parameters are changed before getting the preset
834-
FHoudiniParameterTranslator::UploadChangedParameters(HAC);
835-
836-
if (!FHoudiniEngineUtils::GetAssetPreset(HAC->AssetId, HAC->ParameterPresetBuffer))
834+
bool bCleanParamPreset = false;
835+
if (FHoudiniParameterTranslator::UploadChangedParameters(HAC))
837836
{
838-
HOUDINI_LOG_WARNING(TEXT("Failed to get the asset's parameter preset, rebuilt asset may have lost its parameters."));
839-
HAC->ParameterPresetBuffer.Empty();
837+
if (!FHoudiniEngineUtils::GetAssetPreset(HAC->AssetId, HAC->ParameterPresetBuffer))
838+
{
839+
HOUDINI_LOG_WARNING(TEXT("Failed to get the asset's parameter preset, rebuilt asset may have lost its parameters."));
840+
bCleanParamPreset = true;
841+
}
840842
}
843+
else
844+
{
845+
bCleanParamPreset = true;
846+
}
847+
848+
// If we failed to update params or get the preset buffer, dont use it
849+
if(bCleanParamPreset)
850+
HAC->ParameterPresetBuffer.Empty();
841851

842852
// Do not delete nodes for NodeSync components!
843853
StartTaskAssetRebuild(HAC->AssetId, HAC->HapiGUID);
@@ -1266,15 +1276,7 @@ FHoudiniEngineManager::PreCook(UHoudiniAssetComponent* HAC)
12661276
TRACE_CPUPROFILER_EVENT_SCOPE(FHoudiniEngineManager::PreCook-SetPreset);
12671277

12681278
// If we have stored parameter preset - restore them
1269-
HAPI_Result Res = FHoudiniApi::SetPreset(
1270-
FHoudiniEngine::Get().GetSession(),
1271-
HAC->AssetId,
1272-
HAPI_PRESETTYPE_BINARY,
1273-
"hapi",
1274-
(char *)(HAC->ParameterPresetBuffer.GetData()),
1275-
HAC->ParameterPresetBuffer.Num());
1276-
1277-
if (Res == HAPI_RESULT_SUCCESS)
1279+
if(FHoudiniEngineUtils::SetAssetPreset(HAC->GetAssetId(), HAC->ParameterPresetBuffer))
12781280
bPresetSuccess = true;
12791281
}
12801282

Source/HoudiniEngine/Private/HoudiniEngineUtils.cpp

+45-11
Original file line numberDiff line numberDiff line change
@@ -1978,15 +1978,15 @@ FHoudiniEngineUtils::IsValidNodeId(HAPI_NodeId NodeId)
19781978
*/
19791979

19801980
bool
1981-
FHoudiniEngineUtils::GetHoudiniAssetName(const HAPI_NodeId& AssetNodeId, FString& NameString)
1981+
FHoudiniEngineUtils::GetHoudiniAssetName(HAPI_NodeId InNodeId, FString& NameString)
19821982
{
19831983
TRACE_CPUPROFILER_EVENT_SCOPE(FHoudiniEngineUtils::GetHoudiniAssetName);
19841984

1985-
if (AssetNodeId < 0)
1985+
if (InNodeId < 0)
19861986
return false;
19871987

19881988
HAPI_AssetInfo AssetInfo;
1989-
if (FHoudiniApi::GetAssetInfo(FHoudiniEngine::Get().GetSession(), AssetNodeId, &AssetInfo) == HAPI_RESULT_SUCCESS)
1989+
if (FHoudiniApi::GetAssetInfo(FHoudiniEngine::Get().GetSession(), InNodeId, &AssetInfo) == HAPI_RESULT_SUCCESS)
19901990
{
19911991
FHoudiniEngineString HoudiniEngineString(AssetInfo.nameSH);
19921992
return HoudiniEngineString.ToFString(NameString);
@@ -1995,7 +1995,7 @@ FHoudiniEngineUtils::GetHoudiniAssetName(const HAPI_NodeId& AssetNodeId, FString
19951995
{
19961996
// If the node is not an asset, return the node name
19971997
HAPI_NodeInfo NodeInfo;
1998-
if (FHoudiniApi::GetNodeInfo(FHoudiniEngine::Get().GetSession(), AssetNodeId, &NodeInfo) == HAPI_RESULT_SUCCESS)
1998+
if (FHoudiniApi::GetNodeInfo(FHoudiniEngine::Get().GetSession(), InNodeId, &NodeInfo) == HAPI_RESULT_SUCCESS)
19991999
{
20002000
FHoudiniEngineString HoudiniEngineString(NodeInfo.nameSH);
20012001
return HoudiniEngineString.ToFString(NameString);
@@ -2006,20 +2006,26 @@ FHoudiniEngineUtils::GetHoudiniAssetName(const HAPI_NodeId& AssetNodeId, FString
20062006
}
20072007

20082008
bool
2009-
FHoudiniEngineUtils::GetAssetPreset(const HAPI_NodeId& AssetNodeId, TArray<int8>& PresetBuffer)
2009+
FHoudiniEngineUtils::GetAssetPreset(HAPI_NodeId InNodeId, TArray<int8>& PresetBuffer)
20102010
{
20112011
TRACE_CPUPROFILER_EVENT_SCOPE(FHoudiniEngineUtils::GetAssetPreset);
20122012
PresetBuffer.Empty();
20132013

2014+
// See if param presets usage is disabled
2015+
const UHoudiniRuntimeSettings* HoudiniRuntimeSettings = GetDefault<UHoudiniRuntimeSettings>();
2016+
bool bEnabled = HoudiniRuntimeSettings ? HoudiniRuntimeSettings->bUsePresetsForParameters : true;
2017+
if (!bEnabled)
2018+
return false;
2019+
20142020
HAPI_NodeId NodeId;
20152021
HAPI_AssetInfo AssetInfo;
20162022
if (HAPI_RESULT_SUCCESS == FHoudiniApi::GetAssetInfo(
2017-
FHoudiniEngine::Get().GetSession(), AssetNodeId, &AssetInfo))
2023+
FHoudiniEngine::Get().GetSession(), InNodeId, &AssetInfo))
20182024
{
20192025
NodeId = AssetInfo.nodeId;
20202026
}
20212027
else
2022-
NodeId = AssetNodeId;
2028+
NodeId = InNodeId;
20232029

20242030
if (NodeId < 0)
20252031
return false;
@@ -2037,6 +2043,34 @@ FHoudiniEngineUtils::GetAssetPreset(const HAPI_NodeId& AssetNodeId, TArray<int8>
20372043
return true;
20382044
}
20392045

2046+
bool
2047+
FHoudiniEngineUtils::SetAssetPreset(HAPI_NodeId InNodeId, const TArray<int8>& PresetBuffer)
2048+
{
2049+
TRACE_CPUPROFILER_EVENT_SCOPE(FHoudiniEngineUtils::SetAssetPreset);
2050+
if (InNodeId < 0)
2051+
return false;
2052+
2053+
// See if param presets usage is disabled
2054+
const UHoudiniRuntimeSettings* HoudiniRuntimeSettings = GetDefault<UHoudiniRuntimeSettings>();
2055+
bool bEnabled = HoudiniRuntimeSettings ? HoudiniRuntimeSettings->bUsePresetsForParameters : true;
2056+
if (!bEnabled)
2057+
return false;
2058+
2059+
// If we have stored parameter preset - restore them
2060+
HAPI_Result Res = FHoudiniApi::SetPreset(
2061+
FHoudiniEngine::Get().GetSession(),
2062+
InNodeId,
2063+
HAPI_PRESETTYPE_BINARY,
2064+
"hapi",
2065+
(char*)(PresetBuffer.GetData()),
2066+
PresetBuffer.Num());
2067+
2068+
if (Res != HAPI_RESULT_SUCCESS)
2069+
return false;
2070+
2071+
return true;
2072+
}
2073+
20402074
bool
20412075
FHoudiniEngineUtils::HapiGetAbsNodePath(const HAPI_NodeId& InNodeId, FString& OutPath)
20422076
{
@@ -2096,7 +2130,7 @@ FHoudiniEngineUtils::HapiGetNodePath(const FHoudiniGeoPartObject& InHGPO, FStrin
20962130
FString NodePathTemp;
20972131
if (InHGPO.AssetId == InHGPO.GeoId)
20982132
{
2099-
HAPI_NodeId AssetNodeId = -1;
2133+
HAPI_NodeId NodeId = -1;
21002134

21012135
// This is a SOP asset, just return the asset name in this case
21022136
HAPI_AssetInfo AssetInfo;
@@ -2105,18 +2139,18 @@ FHoudiniEngineUtils::HapiGetNodePath(const FHoudiniGeoPartObject& InHGPO, FStrin
21052139
FHoudiniEngine::Get().GetSession(), InHGPO.AssetId, &AssetInfo))
21062140
{
21072141
// Get the asset info node id
2108-
AssetNodeId = AssetInfo.nodeId;
2142+
NodeId = AssetInfo.nodeId;
21092143
}
21102144
else
21112145
{
21122146
// Not an asset, just use the node id directly
2113-
AssetNodeId = InHGPO.AssetId;
2147+
NodeId = InHGPO.AssetId;
21142148
}
21152149

21162150
HAPI_NodeInfo AssetNodeInfo;
21172151
FHoudiniApi::NodeInfo_Init(&AssetNodeInfo);
21182152
if (HAPI_RESULT_SUCCESS == FHoudiniApi::GetNodeInfo(
2119-
FHoudiniEngine::Get().GetSession(), AssetNodeId, &AssetNodeInfo))
2153+
FHoudiniEngine::Get().GetSession(), NodeId, &AssetNodeInfo))
21202154
{
21212155
if (FHoudiniEngineString::ToFString(AssetNodeInfo.nameSH, NodePathTemp))
21222156
{

Source/HoudiniEngine/Private/HoudiniEngineUtils.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,13 @@ struct HOUDINIENGINE_API FHoudiniEngineUtils
423423
TArray<HAPI_StringHandle>& AssetNames, HAPI_StringHandle& OutPickedAssetName );
424424

425425
// Returns the name of a Houdini asset.
426-
static bool GetHoudiniAssetName(const HAPI_NodeId& AssetNodeId, FString & NameString);
426+
static bool GetHoudiniAssetName(HAPI_NodeId InNodeId, FString & NameString);
427427

428-
// Gets preset data for a given asset.
429-
static bool GetAssetPreset(const HAPI_NodeId& AssetNodeId, TArray<int8>& PresetBuffer);
428+
// Gets preset data for a given node.
429+
static bool GetAssetPreset(HAPI_NodeId InNodeId, TArray<int8>& PresetBuffer);
430+
431+
// Sets preset data for a given node.
432+
static bool SetAssetPreset(HAPI_NodeId InNodeId, const TArray<int8>& PresetBuffer);
430433

431434
// HAPI : Set asset transform.
432435
static bool HapiSetAssetTransform(const HAPI_NodeId& AssetNodeId, const FTransform & Transform);

Source/HoudiniEngine/Private/HoudiniParameterTranslator.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -2628,14 +2628,14 @@ FHoudiniParameterTranslator::UploadChangedParameters( UHoudiniAssetComponent * H
26282628
if (HAC->IsA<UHoudiniNodeSyncComponent>())
26292629
return true;
26302630

2631+
bool bResult = true;
26312632
TMap<FString, UHoudiniParameter*> RampsToRevert;
26322633
// First upload all parameters, including the current child parameters/points of ramps, and then process
26332634
// the ramp parameters themselves (delete and insert operations of ramp points)
26342635
// This is so that the initial upload of parameter values use the correct parameter value/tuple array indices
26352636
// (which will change after potential insert/delete operations). Insert operations will upload their new
26362637
// parameter values after the insert.
26372638
TArray<UHoudiniParameter*> RampsToUpload;
2638-
26392639
for (int32 ParmIdx = 0; ParmIdx < HAC->GetNumParameters(); ParmIdx++)
26402640
{
26412641
TObjectPtr<UHoudiniParameter>& CurrentParm = HAC->Parameters[ParmIdx];
@@ -2678,10 +2678,12 @@ FHoudiniParameterTranslator::UploadChangedParameters( UHoudiniAssetComponent * H
26782678
{
26792679
// Keep this param marked as changed but prevent it from generating updates
26802680
CurrentParm->SetNeedsToTriggerUpdate(false);
2681+
bResult = false;
26812682
}
26822683
}
26832684

2684-
FHoudiniParameterTranslator::RevertRampParameters(RampsToRevert, HAC->GetAssetId());
2685+
if (!FHoudiniParameterTranslator::RevertRampParameters(RampsToRevert, HAC->GetAssetId()))
2686+
bResult = false;
26852687

26862688
for (UHoudiniParameter* const RampParam : RampsToUpload)
26872689
{
@@ -2690,9 +2692,11 @@ FHoudiniParameterTranslator::UploadChangedParameters( UHoudiniAssetComponent * H
26902692

26912693
if (UploadParameterValue(RampParam))
26922694
RampParam->MarkChanged(false);
2695+
else
2696+
bResult = false;
26932697
}
26942698

2695-
return true;
2699+
return bResult;
26962700
}
26972701

26982702
bool
@@ -2932,7 +2936,7 @@ FHoudiniParameterTranslator::UploadParameterValue(UHoudiniParameter* InParam)
29322936
default:
29332937
{
29342938
// TODO: implement other parameter types!
2935-
return false;
2939+
return true;
29362940
}
29372941
break;
29382942
}
@@ -3473,7 +3477,6 @@ bool
34733477
FHoudiniParameterTranslator::RevertRampParameters(TMap<FString, UHoudiniParameter*> & InRampParams, const int32 & AssetId)
34743478
{
34753479
TRACE_CPUPROFILER_EVENT_SCOPE(FHoudiniParameterTranslator::RevertRampParameters);
3476-
34773480
if (InRampParams.Num() <= 0)
34783481
return true;
34793482

Source/HoudiniEngine/Private/SAssetSelectionWidget.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626

2727
#include "SAssetSelectionWidget.h"
2828

29+
#include "HoudiniEnginePrivatePCH.h"
2930
#include "HoudiniEngineString.h"
3031

3132
#if WITH_EDITOR
3233

33-
#include "../../Launch/Resources/Version.h"
34+
#include "Runtime/Launch/Resources/Version.h"
3435

3536
#include "EditorStyleSet.h"
3637
#include "Internationalization/Internationalization.h"

Source/HoudiniEngineEditor/Private/SNewFilePathPicker.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
#include "SNewFilePathPicker.h"
2828

2929
#include "HoudiniApi.h"
30+
3031
#include "DesktopPlatformModule.h"
31-
#include "Widgets/SBoxPanel.h"
3232
#include "Framework/Application/SlateApplication.h"
33+
#include "Runtime/Launch/Resources/Version.h"
3334
#include "Widgets/Images/SImage.h"
3435
#include "Widgets/Input/SEditableTextBox.h"
3536
#include "Widgets/Input/SButton.h"
37+
#include "Widgets/SBoxPanel.h"
3638

3739
#define LOCTEXT_NAMESPACE "SNewFilePathPicker"
3840

Source/HoudiniEngineRuntime/Private/HoudiniRuntimeSettings.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ UHoudiniRuntimeSettings::UHoudiniRuntimeSettings( const FObjectInitializer & Obj
8383
bDisplaySlateCookingNotifications = true;
8484
DefaultTemporaryCookFolder = HAPI_UNREAL_DEFAULT_TEMP_COOK_FOLDER;
8585
DefaultBakeFolder = HAPI_UNREAL_DEFAULT_BAKE_FOLDER;
86+
bUsePresetsForParameters = true;
8687

8788
// Instances
8889
bEnableDeprecatedInstanceVariations = false;

Source/HoudiniEngineRuntime/Private/HoudiniRuntimeSettings.h

+4
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ class HOUDINIENGINERUNTIME_API UHoudiniRuntimeSettings : public UObject
272272
UPROPERTY(GlobalConfig, EditAnywhere, Category = Cooking)
273273
FString DefaultBakeFolder;
274274

275+
// Whether Houdini Engine can store/set multiple parameters via presets
276+
UPROPERTY(GlobalConfig, EditAnywhere, Category = Cooking)
277+
bool bUsePresetsForParameters;
278+
275279
//-------------------------------------------------------------------------------------------------------------
276280
// Deprecated instance settings.
277281
//-------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)