Skip to content

Commit

Permalink
backport of r435905. r435906
Browse files Browse the repository at this point in the history
- Data Table Input: by popular demand, enum values are now sent as strings, not ints.
  This used to be the previous behaviour DT inputs had.
  • Loading branch information
dpernuit committed Jan 19, 2023
1 parent 7943a7c commit 829604a
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Source/HoudiniEngine/Private/HoudiniInputTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4207,8 +4207,21 @@ FHoudiniInputTranslator::HapiCreateInputNodeForDataTable(const FString& InNodeNa
uint32 Offset = ColumnProp->GetOffset_ForInternal();
TMap<FName, uint8*>::TConstIterator It = DataTable->GetRowMap().CreateConstIterator();

// Identify the type of the Property
bool bIsBoolProperty = ColumnProp->IsA<FBoolProperty>();
bool bIsTextProperty = ColumnProp->IsA<FTextProperty>();

// For numeric properties, we want to treat enum separately to send them as string and not ints
FNumericProperty* NumProp = CastField<FNumericProperty>(ColumnProp);
bool bIsNumericProperty = NumProp != nullptr ? !NumProp->IsEnum() : false;
bool bIsEnumProperty = NumProp != nullptr ? NumProp->IsEnum() : false;

// Struct props
FStructProperty* StructProp = CastField<FStructProperty>(ColumnProp);
bool bIsStructProperty = StructProp != nullptr;

// We need to get all values for that attribute
if (ColumnProp->IsA<FBoolProperty>())
if (bIsBoolProperty)
{
AttributeInfo.tupleSize = 1;
AttributeInfo.storage = HAPI_STORAGETYPE_INT8;
Expand All @@ -4224,7 +4237,7 @@ FHoudiniInputTranslator::HapiCreateInputNodeForDataTable(const FString& InNodeNa
}
// Text treated separately because the method used for string fallback
// doesn't cleanly convert this
else if (ColumnProp->IsA<FTextProperty>())
else if (bIsTextProperty)
{
AttributeInfo.tupleSize = 1;
AttributeInfo.storage = HAPI_STORAGETYPE_STRING;
Expand All @@ -4249,7 +4262,7 @@ FHoudiniInputTranslator::HapiCreateInputNodeForDataTable(const FString& InNodeNa
Col, InputNodeId, 0,
CurAttrName, AttributeInfo), false);
}
else if (FNumericProperty* NumProp = CastField<FNumericProperty>(ColumnProp))
else if (bIsNumericProperty && !bIsEnumProperty)
{
AttributeInfo.tupleSize = 1;
if (NumProp->IsInteger())
Expand Down Expand Up @@ -4404,7 +4417,7 @@ FHoudiniInputTranslator::HapiCreateInputNodeForDataTable(const FString& InNodeNa
}
else
{
if (FStructProperty* StructProp = CastField<FStructProperty>(ColumnProp))
if (bIsStructProperty)
{
FName StructName = StructProp->Struct->GetFName();

Expand Down Expand Up @@ -4660,7 +4673,6 @@ FHoudiniInputTranslator::HapiCreateInputNodeForDataTable(const FString& InNodeNa
HOUDINI_CHECK_ERROR_RETURN(FHoudiniEngineUtils::HapiSetAttributeStringData(Col, InputNodeId, 0,
CurAttrName, AttributeInfo), false);
}

}

// Commit the geo.
Expand Down

0 comments on commit 829604a

Please sign in to comment.