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

Unauthored attrs changes #2414

Merged
merged 27 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
724267c
LOOKDEVX-642 | Initial commit for unauthored attribute support.
feldstj Apr 1, 2022
41df474
LOOKDEVX-642 | Some more unauthored attribute changes.
feldstj Apr 8, 2022
addab49
LOOKDEVX-642 | Some more unauthored attribute changes.
feldstj Apr 20, 2022
8ec8d8d
LOOKDEVX-642 | Fixed build issue.
feldstj Apr 25, 2022
dbfd087
LOOKDEVX-642 | Some more unauthored attribute changes.
feldstj Apr 28, 2022
5204830
LOOKDEVX-642 | Some unauthored attribute test related changes.
feldstj May 6, 2022
0337f7f
LOOKDEVX-642 | Merged attribute handle classes.
feldstj May 11, 2022
e6fb201
Merge branch 'dev' into feldstj/unauthored_attrs
feldstj May 11, 2022
cb23500
LOOKDEVX-642 | Unauthored attribute changes.
feldstj May 17, 2022
42a95ea
LOOKDEVX-642 | Some minor cleanup.
feldstj May 17, 2022
ff2994e
LOOKDEVX-642 | Some more code cleanup.
feldstj May 18, 2022
b787491
LOOKDEVX-642 | Axed the AttrHandle class and moved the relevent members
feldstj May 20, 2022
b5d0a3f
LOOKDEVX-642 | Applied code review feedback.
feldstj May 27, 2022
452125f
LOOKDEVX-642 | Merge branch 'dev' into unauthored_attrs_changes
feldstj May 31, 2022
ace6d19
LOOKDEVX-642 | Applied code review feedback and fixed some tests.
feldstj Jun 1, 2022
d6754e9
LOOKDEVX-642 | Applied code review feedback.
feldstj Jun 9, 2022
99f545f
LOOKDEVX-642 | Applied code review feedback.
feldstj Jun 9, 2022
f21a718
Merge branch 'dev' into unauthored_attrs_changes
feldstj Jun 13, 2022
d8c3833
LOOKDEVX-642 | Attempt to fix preflight.
feldstj Jun 13, 2022
2207c28
LOOKDEVX-642 | Second attempt at fixing preflight.
feldstj Jun 13, 2022
89d6159
LOOKDEVX-642 | Third attempt at fixing preflight.
feldstj Jun 14, 2022
0ad7dd2
LOOKDEVX-642 | Forth attempt at fixing preflight.
feldstj Jun 14, 2022
3c42920
LOOKDEVX-642 | Applied code review feedback.
feldstj Jun 15, 2022
1297807
Fix macOS build
hodoulp Jun 14, 2022
ae7a0f3
LOOKDEVX-642 | Clang-format fix.
feldstj Jun 15, 2022
5bb12a8
LOOKDEVX-642 | Fifth attempt at fixing preflight.
feldstj Jun 15, 2022
ba0000c
LOOKDEVX-642 | Minor cleanup.
feldstj Jun 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
784 changes: 615 additions & 169 deletions lib/mayaUsd/ufe/UsdAttribute.cpp

Large diffs are not rendered by default.

224 changes: 206 additions & 18 deletions lib/mayaUsd/ufe/UsdAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@

#include <mayaUsd/ufe/UsdSceneItem.h>

#include <pxr/usd/sdf/types.h>
#include <pxr/usd/usd/attribute.h>
#include <pxr/usd/usd/prim.h>

#include <ufe/attribute.h>
#ifdef UFE_V4_FEATURES_AVAILABLE
#include <ufe/attributeDef.h>
#endif

// Ufe::Attribute overrides (minus the type method)
#ifdef UFE_V3_FEATURES_AVAILABLE
Expand Down Expand Up @@ -71,8 +75,20 @@ namespace ufe {
class UsdAttribute
{
public:
UsdAttribute(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
~UsdAttribute();
#ifdef UFE_V4_FEATURES_AVAILABLE
UsdAttribute(const PXR_NS::UsdPrim& prim, const Ufe::AttributeDef::ConstPtr& attrDef);
#endif
UsdAttribute(const PXR_NS::UsdAttribute& usdAttr);
~UsdAttribute() = default;

inline bool isAuthored() const { return isValid() && fUsdAttr.IsAuthored(); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should all the following methods be defined in UFE_ATTRIBUTE_OVERRIDES ?

inline bool isValid() const { return fUsdAttr.IsValid(); }
std::string isEditAllowedMsg() const;
inline bool isEditAllowed() const { return isEditAllowedMsg().empty(); }
std::string typeName() const;
std::string defaultValue() const;
bool get(PXR_NS::VtValue& value, PXR_NS::UsdTimeCode time) const;
bool set(const PXR_NS::VtValue& value, PXR_NS::UsdTimeCode time);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should all these new methods be protected by UFE_V4_FEATURES_AVAILABLE?


// Ufe::Attribute override methods that we've mimic'd here.
bool hasValue() const;
Expand All @@ -88,7 +104,10 @@ class UsdAttribute
#endif

protected:
PXR_NS::UsdPrim fPrim;
PXR_NS::UsdPrim fPrim;
#ifdef UFE_V4_FEATURES_AVAILABLE
const Ufe::AttributeDef::ConstPtr fAttrDef;
#endif
PXR_NS::UsdAttribute fUsdAttr;
}; // UsdAttribute

Expand All @@ -100,9 +119,24 @@ class UsdAttributeGeneric
public:
typedef std::shared_ptr<UsdAttributeGeneric> Ptr;

#ifdef UFE_V4_FEATURES_AVAILABLE
UsdAttributeGeneric(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

UsdAttributeGeneric(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);

//! Create a UsdAttributeGeneric.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeGeneric with a scene item, prim and attribute definition.
static UsdAttributeGeneric::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeGeneric with a scene item and USD attribute
static UsdAttributeGeneric::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);

Expand All @@ -122,9 +156,24 @@ class UsdAttributeFilename
public:
typedef std::shared_ptr<UsdAttributeFilename> Ptr;

#ifdef UFE_V4_FEATURES_AVAILABLE
UsdAttributeFilename(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

UsdAttributeFilename(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);

//! Create a UsdAttributeFilename.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeFilename with a scene item, prim and attribute definition.
static UsdAttributeFilename::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeFilename with a scene item and USD attribute
static UsdAttributeFilename::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);

Expand All @@ -146,9 +195,24 @@ class UsdAttributeEnumString
public:
typedef std::shared_ptr<UsdAttributeEnumString> Ptr;

#ifdef UFE_V4_FEATURES_AVAILABLE
UsdAttributeEnumString(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

UsdAttributeEnumString(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);

//! Create a UsdAttributeEnumString.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeEnumString with a scene item, prim and attribute definition.
static UsdAttributeEnumString::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeEnumString with a scene item and USD attribute
static UsdAttributeEnumString::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);

Expand All @@ -169,6 +233,15 @@ class TypedUsdAttribute
, private UsdAttribute
{
public:
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a TypedUsdAttribute with a scene item, prim and attribute definition.
TypedUsdAttribute(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a TypedUsdAttribute with a scene item and USD attribute
TypedUsdAttribute(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);

// Ufe::Attribute overrides
Expand All @@ -188,7 +261,15 @@ class UsdAttributeBool : public TypedUsdAttribute<bool>

using TypedUsdAttribute<bool>::TypedUsdAttribute;

//! Create a UsdAttributeBool.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeBool with a scene item, prim and attribute definition.
static UsdAttributeBool::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeBool with a scene item and USD attribute
static UsdAttributeBool::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeBool
Expand All @@ -201,7 +282,15 @@ class UsdAttributeInt : public TypedUsdAttribute<int>

using TypedUsdAttribute<int>::TypedUsdAttribute;

//! Create a UsdAttributeInt.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeInt with a scene item, prim and attribute definition.
static UsdAttributeInt::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeInt with a scene item and USD attribute
static UsdAttributeInt::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeInt
Expand All @@ -214,7 +303,15 @@ class UsdAttributeFloat : public TypedUsdAttribute<float>

using TypedUsdAttribute<float>::TypedUsdAttribute;

//! Create a UsdAttributeFloat.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeFloat with a scene item, prim and attribute definition.
static UsdAttributeFloat::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeFloat with a scene item and USD attribute
static UsdAttributeFloat::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeFloat
Expand All @@ -227,9 +324,18 @@ class UsdAttributeDouble : public TypedUsdAttribute<double>

using TypedUsdAttribute<double>::TypedUsdAttribute;

//! Create a UsdAttributeDouble.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeDouble with a scene item, prim and attribute definition.
static UsdAttributeDouble::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeDouble with a scene item and USD attribute
static UsdAttributeDouble::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);

}; // UsdAttributeDouble

//! \brief Interface for USD string/token attributes.
Expand All @@ -240,7 +346,15 @@ class UsdAttributeString : public TypedUsdAttribute<std::string>

using TypedUsdAttribute<std::string>::TypedUsdAttribute;

//! Create a UsdAttributeString.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeString with a scene item, prim and attribute definition.
static UsdAttributeString::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeString with a scene item and USD attribute
static UsdAttributeString::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeString
Expand All @@ -253,7 +367,15 @@ class UsdAttributeColorFloat3 : public TypedUsdAttribute<Ufe::Color3f>

using TypedUsdAttribute<Ufe::Color3f>::TypedUsdAttribute;

//! Create a UsdAttributeColorFloat3.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeColorFloat3 with a scene item, prim and attribute definition.
static UsdAttributeColorFloat3::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeColorFloat3 with a scene item and USD attribute
static UsdAttributeColorFloat3::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeColorFloat3
Expand All @@ -267,7 +389,15 @@ class UsdAttributeColorFloat4 : public TypedUsdAttribute<Ufe::Color4f>

using TypedUsdAttribute<Ufe::Color4f>::TypedUsdAttribute;

//! Create a UsdAttributeColorFloat4.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeColorFloat4 with a scene item, prim and attribute definition.
static UsdAttributeColorFloat4::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeColorFloat4 with a scene item and USD attribute
static UsdAttributeColorFloat4::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeColorFloat4
Expand All @@ -281,7 +411,15 @@ class UsdAttributeInt3 : public TypedUsdAttribute<Ufe::Vector3i>

using TypedUsdAttribute<Ufe::Vector3i>::TypedUsdAttribute;

//! Create a UsdAttributeInt3.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeInt3 with a scene item, prim and attribute definition.
static UsdAttributeInt3::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeInt3 with a scene item and USD attribute
static UsdAttributeInt3::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeInt3
Expand All @@ -295,7 +433,15 @@ class UsdAttributeFloat2 : public TypedUsdAttribute<Ufe::Vector2f>

using TypedUsdAttribute<Ufe::Vector2f>::TypedUsdAttribute;

//! Create a UsdAttributeFloat2.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeFloat2 with a scene item, prim and attribute definition.
static UsdAttributeFloat2::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeFloat2 with a scene item and USD attribute
static UsdAttributeFloat2::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeFloat2
Expand All @@ -309,7 +455,15 @@ class UsdAttributeFloat3 : public TypedUsdAttribute<Ufe::Vector3f>

using TypedUsdAttribute<Ufe::Vector3f>::TypedUsdAttribute;

//! Create a UsdAttributeFloat3.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeFloat3 with a scene item, prim and attribute definition.
static UsdAttributeFloat3::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeFloat3 with a scene item and USD attribute
static UsdAttributeFloat3::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeFloat3
Expand All @@ -323,7 +477,15 @@ class UsdAttributeFloat4 : public TypedUsdAttribute<Ufe::Vector4f>

using TypedUsdAttribute<Ufe::Vector4f>::TypedUsdAttribute;

//! Create a UsdAttributeFloat4.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeFloat4 with a scene item, prim and attribute definition.
static UsdAttributeFloat4::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeFloat4 with a scene item and USD attribute
static UsdAttributeFloat4::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeFloat4
Expand All @@ -337,7 +499,15 @@ class UsdAttributeDouble3 : public TypedUsdAttribute<Ufe::Vector3d>

using TypedUsdAttribute<Ufe::Vector3d>::TypedUsdAttribute;

//! Create a UsdAttributeDouble3.
#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeDouble3 with a scene item, prim and attribute definition.
static UsdAttributeDouble3::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeDouble3 with a scene item and USD attribute
static UsdAttributeDouble3::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
}; // UsdAttributeDouble3
Expand All @@ -351,6 +521,15 @@ class UsdAttributeMatrix3d : public TypedUsdAttribute<Ufe::Matrix3d>

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

#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeMatrix3d with a scene item, prim and attribute definition.
static UsdAttributeMatrix3d::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeMatrix3d with a scene item and USD attribute
static UsdAttributeMatrix3d::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
};
Expand All @@ -363,6 +542,15 @@ class UsdAttributeMatrix4d : public TypedUsdAttribute<Ufe::Matrix4d>

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

#ifdef UFE_V4_FEATURES_AVAILABLE
//! Create a UsdAttributeMatrix4d with a scene item, prim and attribute definition.
static UsdAttributeMatrix4d::Ptr create(
const UsdSceneItem::Ptr& item,
const PXR_NS::UsdPrim& prim,
const Ufe::AttributeDef::ConstPtr& attrDef);
#endif

//! Create a UsdAttributeMatrix4d with a scene item and USD attribute
static UsdAttributeMatrix4d::Ptr
create(const UsdSceneItem::Ptr& item, const PXR_NS::UsdAttribute& usdAttr);
};
Expand Down
Loading