Return a zero value when an attribute type is not recognized#1758
Merged
sebastienblor merged 4 commits intoAutodesk:masterfrom Nov 17, 2023
Merged
Return a zero value when an attribute type is not recognized#1758sebastienblor merged 4 commits intoAutodesk:masterfrom
sebastienblor merged 4 commits intoAutodesk:masterfrom
Conversation
cpichard
reviewed
Nov 16, 2023
| return array.empty() ? false : (array[0] != 0); | ||
| } | ||
| return value.Get<bool>(); | ||
| return false; |
Collaborator
There was a problem hiding this comment.
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 ?
cpichard
reviewed
Nov 16, 2023
| - [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 |
Collaborator
There was a problem hiding this comment.
now it is returning a default value not necessarily zero, so may be this could be updated ?
cpichard
previously approved these changes
Nov 16, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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