Skip to content

Return a zero value when an attribute type is not recognized#1758

Merged
sebastienblor merged 4 commits intoAutodesk:masterfrom
sebastienblor:14028_b
Nov 17, 2023
Merged

Return a zero value when an attribute type is not recognized#1758
sebastienblor merged 4 commits intoAutodesk:masterfrom
sebastienblor:14028_b

Conversation

@sebastienblor
Copy link
Copy Markdown
Collaborator

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

Comment thread libs/translator/reader/utils.h Outdated
return array.empty() ? false : (array[0] != 0);
}
return value.Get<bool>();
return false;
Copy link
Copy Markdown
Collaborator

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 ?

Comment thread CHANGELOG.md Outdated
- [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
Copy link
Copy Markdown
Collaborator

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 ?

cpichard
cpichard previously approved these changes Nov 16, 2023
@sebastienblor sebastienblor merged commit 09279f3 into Autodesk:master Nov 17, 2023
@sebastienblor sebastienblor deleted the 14028_b branch November 17, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants