From 8d09378c526d891eded46daa9a425ec2ac83285a Mon Sep 17 00:00:00 2001 From: Sebastien Blaineau-Ortega Date: Wed, 15 Nov 2023 19:18:58 +0100 Subject: [PATCH 1/4] Return a zero value when an attribute type is not recognized ARNOLD-14028 --- libs/translator/reader/utils.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/translator/reader/utils.h b/libs/translator/reader/utils.h index 8bb7d2b7fe..7656e7e9b6 100644 --- a/libs/translator/reader/utils.h +++ b/libs/translator/reader/utils.h @@ -425,7 +425,7 @@ static inline bool VtValueGetBool(const VtValue& value) VtArray array = value.UncheckedGet>(); return array.empty() ? false : (array[0] != 0); } - return value.Get(); + return false; } static inline float VtValueGetFloat(const VtValue& value) @@ -451,7 +451,7 @@ static inline float VtValueGetFloat(const VtValue& value) VtArray array = value.UncheckedGet>(); return array.empty() ? 0.f : static_cast(array[0]); } - return value.Get(); + return 0.f; } static inline unsigned char VtValueGetByte(const VtValue& value) @@ -475,7 +475,7 @@ static inline unsigned char VtValueGetByte(const VtValue& value) return array.empty() ? 0 : array[0]; } - return value.Get(); + return 0; } static inline int VtValueGetInt(const VtValue& value) @@ -493,7 +493,7 @@ static inline int VtValueGetInt(const VtValue& value) return array.empty() ? 0 : (int) array[0]; } - return value.Get(); + return 0; } static inline unsigned int VtValueGetUInt(const VtValue& value) @@ -512,7 +512,7 @@ static inline unsigned int VtValueGetUInt(const VtValue& value) return array.empty() ? 0 : array[0]; } - return value.Get(); + return 0; } static inline GfVec2f VtValueGetVec2f(const VtValue& value) @@ -543,7 +543,7 @@ static inline GfVec2f VtValueGetVec2f(const VtValue& value) return array.empty() ? GfVec2f(0.f, 0.f) : GfVec2f(static_cast(array[0][0]), static_cast(array[0][1])); } - return value.Get(); + return GfVec2f(0.f, 0.f); } static inline GfVec3f VtValueGetVec3f(const VtValue& value) @@ -578,7 +578,7 @@ static inline GfVec3f VtValueGetVec3f(const VtValue& value) GfVec3f(static_cast(array[0][0]), static_cast(array[0][1]), static_cast(array[0][2])); } - return value.Get(); + return GfVec3f(0.f, 0.f, 0.f); } static inline GfVec4f VtValueGetVec4f(const VtValue& value) @@ -613,7 +613,7 @@ static inline GfVec4f VtValueGetVec4f(const VtValue& value) GfVec4f(static_cast(array[0][0]), static_cast(array[0][1]), static_cast(array[0][2]), static_cast(array[0][3])); } - return value.Get(); + return GfVec4f(0.f, 0.f, 0.f, 0.f); } static inline std::string _VtValueResolvePath(const SdfAssetPath& assetPath, const UsdAttribute* attr = nullptr) @@ -686,7 +686,7 @@ static inline std::string VtValueGetString(const VtValue& value, const UsdAttrib return _VtValueResolvePath(assetPath, attr); } - return value.Get(); + return std::string(); } static inline bool VtValueGetMatrix(const VtValue& value, AtMatrix& matrix) From c0da9ad9557595abb134dbcae11801a26eec6f64 Mon Sep 17 00:00:00 2001 From: Sebastien Blaineau-Ortega Date: Wed, 15 Nov 2023 19:30:44 +0100 Subject: [PATCH 2/4] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 811ff8f644..077ee684e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - [usd#1735](https://github.com/Autodesk/arnold-usd/issues/1735) - Fix usdskel geometry and motion blur interpolation outside the keyframe boundaries. - [usd#1524](https://github.com/Autodesk/arnold-usd/issues/1524) - Fix material binding on instances under a SkelRoot - [usd#1718](https://github.com/Autodesk/arnold-usd/issues/1718) - Support primvars:arnold attributes in Arnold typed schemas +- [usd#1758](https://github.com/Autodesk/arnold-usd/issues/1758) - Return a zero value when an attribute type is not recognized ## [7.2.4.1] - 2023-10-18 From 0d66c226915b581d60a7a592db4bacf988269d8d Mon Sep 17 00:00:00 2001 From: Sebastien Blaineau-Ortega Date: Thu, 16 Nov 2023 10:16:57 +0100 Subject: [PATCH 3/4] Expose default value to VtValueGet functions --- CHANGELOG.md | 2 +- libs/translator/reader/utils.h | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 077ee684e0..947df259fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - [usd#1077](https://github.com/Autodesk/arnold-usd/issues/1077) - Support --threads / -j argument in husk to control the amount of render threads - [usd#658](https://github.com/Autodesk/arnold-usd/issues/658) - Support pixel aspect ratio in Hydra - [usd#1746](https://github.com/Autodesk/arnold-usd/issues/1746) - Made the behaviour for doubleSided gprims consistent between USD and Hydra +- [usd#1758](https://github.com/Autodesk/arnold-usd/issues/1758) - Return a zero value when an attribute type is not recognized ### Bug fixes - [usd#1709](https://github.com/Autodesk/arnold-usd/issues/1709) - Procedural failures if schemas are present @@ -17,7 +18,6 @@ - [usd#1735](https://github.com/Autodesk/arnold-usd/issues/1735) - Fix usdskel geometry and motion blur interpolation outside the keyframe boundaries. - [usd#1524](https://github.com/Autodesk/arnold-usd/issues/1524) - Fix material binding on instances under a SkelRoot - [usd#1718](https://github.com/Autodesk/arnold-usd/issues/1718) - Support primvars:arnold attributes in Arnold typed schemas -- [usd#1758](https://github.com/Autodesk/arnold-usd/issues/1758) - Return a zero value when an attribute type is not recognized ## [7.2.4.1] - 2023-10-18 diff --git a/libs/translator/reader/utils.h b/libs/translator/reader/utils.h index 7656e7e9b6..2a6b335065 100644 --- a/libs/translator/reader/utils.h +++ b/libs/translator/reader/utils.h @@ -405,7 +405,7 @@ void ReadSubsetsMaterialBinding( unsigned int elementCount, bool assignDefault = true); -static inline bool VtValueGetBool(const VtValue& value) +static inline bool VtValueGetBool(const VtValue& value, bool defaultValue = false) { if (value.IsHolding()) return value.UncheckedGet(); @@ -425,10 +425,10 @@ static inline bool VtValueGetBool(const VtValue& value) VtArray array = value.UncheckedGet>(); return array.empty() ? false : (array[0] != 0); } - return false; + return defaultValue; } -static inline float VtValueGetFloat(const VtValue& value) +static inline float VtValueGetFloat(const VtValue& value, float defaultValue = 0.f) { if (value.IsHolding()) return value.UncheckedGet(); @@ -451,10 +451,10 @@ static inline float VtValueGetFloat(const VtValue& value) VtArray array = value.UncheckedGet>(); return array.empty() ? 0.f : static_cast(array[0]); } - return 0.f; + return defaultValue; } -static inline unsigned char VtValueGetByte(const VtValue& value) +static inline unsigned char VtValueGetByte(const VtValue& value, unsigned char defaultValue = 0) { if (value.IsHolding()) return static_cast(value.UncheckedGet()); @@ -475,10 +475,10 @@ static inline unsigned char VtValueGetByte(const VtValue& value) return array.empty() ? 0 : array[0]; } - return 0; + return defaultValue; } -static inline int VtValueGetInt(const VtValue& value) +static inline int VtValueGetInt(const VtValue& value, int defaultValue = 0) { if (value.IsHolding()) return value.UncheckedGet(); @@ -493,10 +493,10 @@ static inline int VtValueGetInt(const VtValue& value) return array.empty() ? 0 : (int) array[0]; } - return 0; + return defaultValue; } -static inline unsigned int VtValueGetUInt(const VtValue& value) +static inline unsigned int VtValueGetUInt(const VtValue& value, unsigned int defaultValue = 0) { if (value.IsHolding()) { return value.UncheckedGet(); @@ -512,10 +512,10 @@ static inline unsigned int VtValueGetUInt(const VtValue& value) return array.empty() ? 0 : array[0]; } - return 0; + return defaultValue; } -static inline GfVec2f VtValueGetVec2f(const VtValue& value) +static inline GfVec2f VtValueGetVec2f(const VtValue& value, GfVec2f defaultValue = GfVec2f(0.f)) { if (value.IsHolding()) return value.UncheckedGet(); @@ -543,10 +543,10 @@ static inline GfVec2f VtValueGetVec2f(const VtValue& value) return array.empty() ? GfVec2f(0.f, 0.f) : GfVec2f(static_cast(array[0][0]), static_cast(array[0][1])); } - return GfVec2f(0.f, 0.f); + return defaultValue; } -static inline GfVec3f VtValueGetVec3f(const VtValue& value) +static inline GfVec3f VtValueGetVec3f(const VtValue& value, const GfVec3f defaultValue = GfVec3f(0.f)) { if (value.IsHolding()) return value.UncheckedGet(); @@ -578,10 +578,10 @@ static inline GfVec3f VtValueGetVec3f(const VtValue& value) GfVec3f(static_cast(array[0][0]), static_cast(array[0][1]), static_cast(array[0][2])); } - return GfVec3f(0.f, 0.f, 0.f); + return defaultValue; } -static inline GfVec4f VtValueGetVec4f(const VtValue& value) +static inline GfVec4f VtValueGetVec4f(const VtValue& value, const GfVec4f defaultValue = GfVec4f(0.f)) { if (value.IsHolding()) return value.UncheckedGet(); @@ -613,7 +613,7 @@ static inline GfVec4f VtValueGetVec4f(const VtValue& value) GfVec4f(static_cast(array[0][0]), static_cast(array[0][1]), static_cast(array[0][2]), static_cast(array[0][3])); } - return GfVec4f(0.f, 0.f, 0.f, 0.f); + return defaultValue; } static inline std::string _VtValueResolvePath(const SdfAssetPath& assetPath, const UsdAttribute* attr = nullptr) From 019e4e783bf1a7b35cec355bd2b756bbf4e58cd7 Mon Sep 17 00:00:00 2001 From: Sebastien Blaineau-Ortega Date: Fri, 17 Nov 2023 14:38:41 +0100 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 947df259fd..1f57346926 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ - [usd#1077](https://github.com/Autodesk/arnold-usd/issues/1077) - Support --threads / -j argument in husk to control the amount of render threads - [usd#658](https://github.com/Autodesk/arnold-usd/issues/658) - Support pixel aspect ratio in Hydra - [usd#1746](https://github.com/Autodesk/arnold-usd/issues/1746) - Made the behaviour for doubleSided gprims consistent between USD and Hydra -- [usd#1758](https://github.com/Autodesk/arnold-usd/issues/1758) - Return a zero value when an attribute type is not recognized +- [usd#1758](https://github.com/Autodesk/arnold-usd/issues/1758) - Return a default value when an attribute type is not recognized ### Bug fixes - [usd#1709](https://github.com/Autodesk/arnold-usd/issues/1709) - Procedural failures if schemas are present