-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return a zero value when an attribute type is not recognized #1758
Conversation
libs/translator/reader/utils.h
Outdated
@@ -425,7 +425,7 @@ static inline bool VtValueGetBool(const VtValue& value) | |||
VtArray<long> array = value.UncheckedGet<VtArray<long>>(); | |||
return array.empty() ? false : (array[0] != 0); | |||
} | |||
return value.Get<bool>(); | |||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something that would be great is to pass the default value as an argument:
VtValueGetBool(const VtValue &value, bool default=false)
{
...
return default;
}
This has the benefit of exposing the fact that the function returns a default if the value is not found ... and later on be able to change the default, as sometimes we might want true and other times false. Same for the other similar functions.
What do you think ?
CHANGELOG.md
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now it is returning a default value not necessarily zero, so may be this could be updated ?
Crashes where reported in ARNOLD-14028, which happen when we try to get the value of an attribute which type isn't supported.
At the moment, after testing specific attribute types in VtValueGet* functions, we do a blind value.Get with the type that we want to convert it to.
But apparently, this can sometimes crash in USD when the types don't match. Now, we're instead returning a 0-value when the value doesn't hold any of the types that are supported