Skip to content

Commit 2486d3e

Browse files
committed
Clear out unset fields if attribute does not exists.
1 parent e75a1cc commit 2486d3e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Plugins/HoudiniEngineUnity/Scripts/Utility/HEU_GeneralUtility.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ public static bool GetAttribute<T>(HEU_SessionBase session, HAPI_NodeId geoID, H
411411

412412
if (!bResult || !info.exists)
413413
{
414+
info.exists = false;
415+
info.count = 0;
416+
info.tupleSize = 0;
414417
return false;
415418
}
416419

Plugins/HoudiniEngineUnity/Scripts/Utility/HEU_GenerateGeoCache.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,19 @@ public void GetStringAttributes(HEU_SessionBase session, HAPI_NodeId geoID, HAPI
251251
// which returns the strings in stringTable and an array stringIndices which reference these strings.
252252
// This is safer than storing HAPI string handles which can be transient in nature.
253253

254-
var stringHandles = new HAPI_StringHandle[0];
255-
HEU_GeneralUtility.GetAttribute(session, GeoID, PartID, name, ref info, ref stringHandles, session.GetAttributeStringData);
256-
254+
var stringHandles = new HAPI_StringHandle[0];
257255
var stringLookup = new Dictionary<HAPI_StringHandle, int>();
258256

257+
bool bResult = HEU_GeneralUtility.GetAttribute(session, GeoID, PartID, name, ref info, ref stringHandles, session.GetAttributeStringData);
258+
if (!bResult)
259+
{
260+
stringIndices = new int[0];
261+
info.exists = false;
262+
return;
263+
264+
}
265+
266+
259267
stringIndices = new int[info.count * info.tupleSize];
260268

261269
for (int index = 0; index < stringHandles.Length; index++)

0 commit comments

Comments
 (0)