Skip to content
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

LOOKDEVX-670 Improved USD type support #2364

Merged
merged 4 commits into from
May 19, 2022

Conversation

JGamache-autodesk
Copy link
Collaborator

We added new types in Ufe 0.4.15. This updates maps them to their
corresponding USD types.

We added new types in Ufe 0.4.15. This updates maps them to their
corresponding USD types.
@autodesk-chorus
Copy link

Chorus detected one or more security issues with this pull request. See the Checks tab for more details.

As a reminder, please follow the secure code review process as part of the Secure Coding Non-Negotiable requirement.

@JGamache-autodesk JGamache-autodesk added ufe Related to UFE component in Maya ufe-usd Related to UFE-USD plugin in Maya-Usd labels May 18, 2022
T gfVec = vt.UncheckedGet<T>();
U ret;
constexpr size_t num = ret.vector.size();
std::copy(gfVec.data(), gfVec.data() + num, ret.vector.data());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support 2 and 4 component vectors. Still works pre-0.4.15.


template <typename T, typename U>
U getUsdAttributeColorAsUfe(const PXR_NS::UsdAttribute& attr, const PXR_NS::UsdTimeCode& time)
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But since we are accessing the inner class, we must create a specialization for colors because the name of the inner class is different.

@@ -160,8 +176,17 @@ def runUndoRedoUsingMayaSetAttr(self, attr, newVal, decimalPlaces=None):
setAttrPath = self.getMayaAttrStr(attr)
if isinstance(newVal, (ufe.Vector3i, ufe.Vector3f, ufe.Vector3d)):
cmds.setAttr(setAttrPath, newVal.x(), newVal.y(), newVal.z())
elif isinstance(newVal, ufe.Vector2f):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could support all vector types with a single:
cmds.setAttr(setAttrPath, *newVal.vector)
If we want to sinplify this a little.

# Pre Ufe 0.4.15: Maya might return the result as a string for colors. Fixed to always
# return a vector post 0.4.15.
if isinstance(getAttrValue, str):
getAttrValue = eval(getAttrValue)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will replace with ast.literal_eval as this will work fine and be safer.

ppt-adsk
ppt-adsk previously approved these changes May 19, 2022
@JGamache-autodesk
Copy link
Collaborator Author

Ready for merge. Preflight succeeded except for one machine experiencing technical difficulties.

@JGamache-autodesk JGamache-autodesk added the ready-for-merge Development process is finished, PR is ready for merge label May 19, 2022
Copy link
Collaborator

@feldstj feldstj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two minor comment changes.


using TypedUsdAttribute<Ufe::Matrix3d>::TypedUsdAttribute;

//! Create a UsdAttributeDouble3.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should be UsdAttributeMatrix3d

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not provide any extra information. Removed since reading the function signature is sufficient.


using TypedUsdAttribute<Ufe::Matrix4d>::TypedUsdAttribute;

//! Create a UsdAttributeDouble4.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should be UsdAttributeMatrix4d

@seando-adsk seando-adsk merged commit dd195b4 into dev May 19, 2022
@seando-adsk seando-adsk deleted the t_gamaj/LOOKDEVX-670/translate_new_types_from_usd branch May 19, 2022 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge ufe Related to UFE component in Maya ufe-usd Related to UFE-USD plugin in Maya-Usd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants