Skip to content

Commit

Permalink
Expose default value to VtValueGet functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienblor committed Nov 16, 2023
1 parent c0da9ad commit 0d66c22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
32 changes: 16 additions & 16 deletions libs/translator/reader/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>())
return value.UncheckedGet<bool>();
Expand All @@ -425,10 +425,10 @@ static inline bool VtValueGetBool(const VtValue& value)
VtArray<long> array = value.UncheckedGet<VtArray<long>>();
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<float>())
return value.UncheckedGet<float>();
Expand All @@ -451,10 +451,10 @@ static inline float VtValueGetFloat(const VtValue& value)
VtArray<GfHalf> array = value.UncheckedGet<VtArray<GfHalf>>();
return array.empty() ? 0.f : static_cast<float>(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<int>())
return static_cast<unsigned char>(value.UncheckedGet<int>());
Expand All @@ -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<int>())
return value.UncheckedGet<int>();
Expand All @@ -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<unsigned int>()) {
return value.UncheckedGet<unsigned int>();
Expand All @@ -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<GfVec2f>())
return value.UncheckedGet<GfVec2f>();
Expand Down Expand Up @@ -543,10 +543,10 @@ static inline GfVec2f VtValueGetVec2f(const VtValue& value)
return array.empty() ? GfVec2f(0.f, 0.f) :
GfVec2f(static_cast<float>(array[0][0]), static_cast<float>(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<GfVec3f>())
return value.UncheckedGet<GfVec3f>();
Expand Down Expand Up @@ -578,10 +578,10 @@ static inline GfVec3f VtValueGetVec3f(const VtValue& value)
GfVec3f(static_cast<float>(array[0][0]),
static_cast<float>(array[0][1]), static_cast<float>(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<GfVec4f>())
return value.UncheckedGet<GfVec4f>();
Expand Down Expand Up @@ -613,7 +613,7 @@ static inline GfVec4f VtValueGetVec4f(const VtValue& value)
GfVec4f(static_cast<float>(array[0][0]), static_cast<float>(array[0][1]),
static_cast<float>(array[0][2]), static_cast<float>(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)
Expand Down

0 comments on commit 0d66c22

Please sign in to comment.