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

EMSUSD-751 - UsdUfe: Move Ufe::Attributes interface implementation #3737

Merged
merged 9 commits into from
May 2, 2024
Merged
14 changes: 0 additions & 14 deletions lib/mayaUsd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,13 @@ if(DEFINED UFE_PREVIEW_VERSION_NUM)
)
endif()

if (UFE_HAS_DISPLAY_NAME)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
UFE_HAS_DISPLAY_NAME=1
)
endif()

if (UFE_DEFAULT_VALUE_SUPPORT)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
UFE_DEFAULT_VALUE_SUPPORT=1
)
endif()

if (UFE_HAS_NATIVE_TYPE_METADATA)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
UFE_HAS_NATIVE_TYPE_METADATA=1
)
endif()

message(STATUS "MAYA_HAS_DEFAULT_MATERIAL_API is ${MAYA_HAS_DEFAULT_MATERIAL_API}")
if (MAYA_HAS_DEFAULT_MATERIAL_API)
target_compile_definitions(${PROJECT_NAME}
Expand Down
12 changes: 12 additions & 0 deletions lib/mayaUsd/base/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,15 @@
// Convenience symbol versioning include: because api.h is widely
// included, this reduces the need to explicitly include mayaUsd.h.
#include <mayaUsd/mayaUsd.h>

// TEMP (UsdUfe)
//
// As the work-in-progress to move the UsdUfe code to a separate folder
// (and shared library) continues the namespace of the moved classes will
// be changed from MayaUsd::ufe -> UsdUfe.
//
// So temporarily add a using statement for this new namespace until the move
// is complete. At that the bulk of the files will have been moved and this
// using statement should be removed and any namespace cleanup done at that time.
#include <usdUfe/usdUfe.h>
using namespace UsdUfe;
1 change: 0 additions & 1 deletion lib/mayaUsd/base/tokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ PXR_NAMESPACE_OPEN_SCOPE

TF_DEFINE_PUBLIC_TOKENS(MayaUsdOptionVars, MAYA_USD_OPTIONVAR_TOKENS);
TF_DEFINE_PUBLIC_TOKENS(MayaUsdMetadata, MAYA_USD_METADATA_TOKENS);
TF_DEFINE_PUBLIC_TOKENS(MayaUsdTokens, MAYA_USD_GENERIC_TOKENS);
TF_DEFINE_PUBLIC_TOKENS(MayaUsdEditRoutingTokens, MAYA_USD_EDIT_ROUTING_TOKENS);

PXR_NAMESPACE_CLOSE_SCOPE
27 changes: 1 addition & 26 deletions lib/mayaUsd/base/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,46 +82,21 @@ TF_DECLARE_PUBLIC_TOKENS(MayaUsdOptionVars, MAYAUSD_CORE_PUBLIC, MAYA_USD_OPTION
// - All words following "maya" are capitalized. This falls in line
// with how Maya convert the metadata names to UI labels in the
// attribute editor: spaces are inserted before isolated capital
// letters, tjhen everything is lower-cases, then the whole label
// letters, then everything is lower-cases, then the whole label
// is title-case. So, for example, "mayaLock" becomes "Maya lock".
//
// clang-format off
#define MAYA_USD_METADATA_TOKENS \
/* Selectability metadata to be used on prims */ \
((Selectability, "mayaSelectability")) \
/* Locking attribute metadata. A locked attribute */ \
/* value cannot be changed. */ \
((Lock, "mayaLock")) \
/* Referenced layers. */ \
((ReferencedLayers, "mayaSharedLayers")) \
/* Export file path. */ \
((ExportFilePathToken, "mayaExportFilePath")) \
/* Metadata for UI queries */ \
((UIName, "uiname")) \
((UIFolder, "uifolder")) \
((UIMin, "uimin")) \
((UIMax, "uimax")) \
((UISoftMin, "uisoftmin")) \
((UISoftMax, "uisoftmax")) \
// clang-format on

TF_DECLARE_PUBLIC_TOKENS(MayaUsdMetadata, MAYAUSD_CORE_PUBLIC, MAYA_USD_METADATA_TOKENS);

// generic tokens in MayaUSD
//
// clang-format off
#define MAYA_USD_GENERIC_TOKENS \
/* Metadata value to inherit the value from a */ \
/* parent prim. Used in selectability. */ \
((Inherit, "inherit")) \
/* Metadata value to turn on or off a feature. */ \
/* Used in selectability and lock, for example. */ \
((On, "on")) \
((Off, "off")) \
// clang-format on

TF_DECLARE_PUBLIC_TOKENS(MayaUsdTokens, MAYAUSD_CORE_PUBLIC, MAYA_USD_GENERIC_TOKENS);

// Tokens for edit routing in MayaUSD
//
// clang-format off
Expand Down
4 changes: 3 additions & 1 deletion lib/mayaUsd/fileio/shading/shadingModeExporterContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <mayaUsd/utils/json.h>
#include <mayaUsd/utils/util.h>

#include <usdUfe/utils/Utils.h>

#include <pxr/base/tf/diagnostic.h>
#include <pxr/base/tf/envSetting.h>
#include <pxr/base/tf/iterator.h>
Expand Down Expand Up @@ -495,7 +497,7 @@ UsdPrim UsdMayaShadingModeExportContext::MakeStandardMaterialPrim(
materialName = sgName.c_str();
}

materialName = UsdMayaUtil::SanitizeName(materialName);
materialName = UsdUfe::sanitizeName(materialName);
UsdStageRefPtr stage = GetUsdStage();
if (UsdPrim materialParent
= _GetMaterialParent(stage, GetExportArgs().materialsScopeName, assignmentsToBind)) {
Expand Down
4 changes: 3 additions & 1 deletion lib/mayaUsd/fileio/shading/shadingModeImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
//
#include "shadingModeImporter.h"

#include <usdUfe/utils/Utils.h>

#include <pxr/base/tf/diagnostic.h>
#include <pxr/base/tf/staticTokens.h>
#include <pxr/base/tf/stringUtils.h>
Expand Down Expand Up @@ -100,7 +102,7 @@ UsdMayaShadingModeImportContext::GetShadingEngineName(const std::string& surface
shadingEngineName = _shadeMaterial.GetPrim().GetName();
} else if (_boundPrim) {
// We have no material, so we definitely want to use the surfaceNodeName here:
shadingEngineName = TfToken(UsdMayaUtil::SanitizeName(surfaceNodeName + "SG").c_str());
shadingEngineName = TfToken(UsdUfe::sanitizeName(surfaceNodeName + "SG").c_str());
}

return shadingEngineName;
Expand Down
4 changes: 3 additions & 1 deletion lib/mayaUsd/fileio/shading/shadingModePxrRis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <mayaUsd/utils/converter.h>
#include <mayaUsd/utils/util.h>

#include <usdUfe/utils/Utils.h>

#include <pxr/base/tf/diagnostic.h>
#include <pxr/base/tf/staticTokens.h>
#include <pxr/base/tf/stringUtils.h>
Expand Down Expand Up @@ -138,7 +140,7 @@ class PxrRisShadingModeExporter : public UsdMayaShadingModeExporter
// well. currently, when we re-import, we don't get the display color so
// it shows up as black.

const TfToken shaderPrimName(UsdMayaUtil::SanitizeName(depNode.name().asChar()));
const TfToken shaderPrimName(UsdUfe::sanitizeName(depNode.name().asChar()));
const SdfPath shaderPath = materialPrim.GetPath().AppendChild(shaderPrimName);
if (processedPaths->count(shaderPath) == 1u) {
return stage->GetPrimAtPath(shaderPath);
Expand Down
4 changes: 3 additions & 1 deletion lib/mayaUsd/fileio/shading/shadingModeUseRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <mayaUsd/utils/converter.h>
#include <mayaUsd/utils/util.h>

#include <usdUfe/utils/Utils.h>

#include <pxr/base/tf/diagnostic.h>
#include <pxr/base/tf/token.h>
#include <pxr/pxr.h>
Expand Down Expand Up @@ -121,7 +123,7 @@ class UseRegistryShadingModeExporter : public UsdMayaShadingModeExporter
return nullptr;
}

const TfToken shaderUsdPrimName(UsdMayaUtil::SanitizeName(depNodeFn.name().asChar()));
const TfToken shaderUsdPrimName(UsdUfe::sanitizeName(depNodeFn.name().asChar()));

const SdfPath shaderUsdPath = parentPath.AppendChild(shaderUsdPrimName);

Expand Down
11 changes: 6 additions & 5 deletions lib/mayaUsd/nodes/proxyAccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void ProxyAccessor::collectAccessorItems(MObject node)

item.converter = Converter::find(typeName, false);
} else {
UsdAttribute attribute = prim.GetAttribute(item.property);
PXR_NS::UsdAttribute attribute = prim.GetAttribute(item.property);

if (!attribute.IsDefined()) {
TF_DEBUG(USDMAYA_PROXYACCESSOR)
Expand Down Expand Up @@ -532,7 +532,7 @@ MStatus ProxyAccessor::computeInput(
if (item.property.IsEmpty() || !item.converter)
return MS::kFailure;

UsdAttribute itemAttribute = itemPrim.GetAttribute(item.property);
PXR_NS::UsdAttribute itemAttribute = itemPrim.GetAttribute(item.property);

if (!itemAttribute.IsDefined()) {
TF_CODING_ERROR(
Expand Down Expand Up @@ -615,7 +615,7 @@ MStatus ProxyAccessor::computeOutput(

itemDataHandle.set(visible ? 1 : 0);
} else if (item.converter) {
UsdAttribute itemAttribute = itemPrim.GetAttribute(item.property);
PXR_NS::UsdAttribute itemAttribute = itemPrim.GetAttribute(item.property);

// cache this! expensive call
if (!itemAttribute.IsDefined()) {
Expand Down Expand Up @@ -714,8 +714,9 @@ MStatus ProxyAccessor::stageChanged(const MObject& node, const UsdNotice::Object
SdfPath changedPrimPath = changedPath.GetAbsoluteRootOrPrimPath();
const UsdPrim& changedPrim = stage->GetPrimAtPath(changedPrimPath);

const TfToken& changedPropertyToken = changedPath.GetNameToken();
UsdAttribute changedAttribute = changedPrim.GetAttribute(changedPropertyToken);
const TfToken& changedPropertyToken = changedPath.GetNameToken();
PXR_NS::UsdAttribute changedAttribute
= changedPrim.GetAttribute(changedPropertyToken);

converter->convert(changedAttribute, changedPlug, args);

Expand Down
1 change: 0 additions & 1 deletion lib/mayaUsd/python/wrapTokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void wrapTokens()
{
TF_PY_WRAP_PUBLIC_TOKENS("OptionVarTokens", MayaUsdOptionVars, MAYA_USD_OPTIONVAR_TOKENS);
TF_PY_WRAP_PUBLIC_TOKENS("MetadataTokens", MayaUsdMetadata, MAYA_USD_METADATA_TOKENS);
TF_PY_WRAP_PUBLIC_TOKENS("Tokens", MayaUsdTokens, MAYA_USD_GENERIC_TOKENS);
TF_PY_WRAP_PUBLIC_TOKENS(
"EditRoutingTokens", MayaUsdEditRoutingTokens, MAYA_USD_EDIT_ROUTING_TOKENS);
}
2 changes: 0 additions & 2 deletions lib/mayaUsd/python/wrapUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ void wrapUtil()
scope s
= class_<UsdMayaUtilScope>("Util", no_init)
.def("IsAuthored", UsdMayaUtil::IsAuthored)
.def("prettifyName", &UsdMayaUtil::prettifyName)
.staticmethod("prettifyName")
.def("getDictionaryFromEncodedOptions", getDictionaryFromEncodedOptions)
.def(
"getPathRelativeToMayaSceneFile",
Expand Down
6 changes: 3 additions & 3 deletions lib/mayaUsd/resources/ae/usdschemabase/ae_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def onCreate(self, *args):
for k in allMetadata:
# All extra metadata is for display purposes only - it is not editable, but we
# allow keyboard focus so you copy the value.
mdLabel = mayaUsdLib.Util.prettifyName(k) if self.useNiceName else k
mdLabel = mayaUsdUfe.prettifyName(k) if self.useNiceName else k
self.extraMetadata[k] = cmds.textFieldGrp(label=mdLabel, editable=False, enableKeyboardFocus=True)

# Update all metadata values.
Expand Down Expand Up @@ -552,7 +552,7 @@ def parseShaderAttributes(self):
if not label:
label = nodeDef.GetFamily()

self._attributeLayout = AEShaderLayout.Group(self._attributeLayout.name + ": " + mayaUsdLib.Util.prettifyName(label))
self._attributeLayout = AEShaderLayout.Group(self._attributeLayout.name + ": " + mayaUsdUfe.prettifyName(label))

# Best option: Use ordering metadata found the Sdr properties:
hasMetadataOrdering = False
Expand Down Expand Up @@ -769,7 +769,7 @@ def sectionNameFromSchema(self, schemaTypeName):
schemaTypeName = schemaTypeName.replace(p, r, 1)
break

schemaTypeName = mayaUsdLib.Util.prettifyName(schemaTypeName)
schemaTypeName = mayaUsdUfe.prettifyName(schemaTypeName)

# if the schema name ends with "api" or "API", trim it.
if schemaTypeName.endswith("api") or schemaTypeName.endswith("API"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#

import mayaUsd.lib
from mayaUsd import ufe as mayaUsdUfe

from maya.OpenMaya import MGlobal

Expand All @@ -30,7 +31,7 @@ def getNiceAttributeName(ufeAttr, attrName):
attrName = ufeAttr.displayName
elif hasattr(ufeAttr, "hasMetadata") and ufeAttr.hasMetadata("uiname"):
attrName = str(ufeAttr.getMetadata("uiname"))
return mayaUsd.lib.Util.prettifyName(attrName)
return mayaUsdUfe.prettifyName(attrName)

def cleanAndFormatTooltip(s):
if not s:
Expand Down
30 changes: 0 additions & 30 deletions lib/mayaUsd/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ target_sources(${PROJECT_NAME}
ProxyShapeHierarchy.cpp
ProxyShapeHierarchyHandler.cpp
RotationUtils.cpp
UsdAttribute.cpp
UsdAttributeHolder.cpp
UsdAttributes.cpp
UsdAttributesHandler.cpp
UsdPointInstanceOrientationModifier.cpp
UsdPointInstancePositionModifier.cpp
UsdPointInstanceScaleModifier.cpp
Expand Down Expand Up @@ -124,22 +120,6 @@ if (UFE_UINODEGRAPHNODE_HAS_DISPLAYCOLOR)
)
endif()


if (UFE_ATTRIBUTES_GET_ENUMS)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
UFE_ATTRIBUTES_GET_ENUMS=1
)
endif()


if (UFE_SCENEITEM_HAS_METADATA)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
UFE_SCENEITEM_HAS_METADATA=1
)
endif()

if (UFE_CONTEXTOPS_HAS_OPTIONBOX)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
Expand Down Expand Up @@ -179,15 +159,12 @@ if(CMAKE_UFE_V4_FEATURES_AVAILABLE)
PRIVATE
UsdShaderNodeDef.cpp
UsdShaderNodeDefHandler.cpp
UsdShaderAttributeDef.cpp
UsdShaderAttributeHolder.cpp
UsdUndoCreateFromNodeDefCommand.cpp
ProxyShapeCameraHandler.cpp
UsdConnections.cpp
UsdConnectionHandler.cpp
UsdUINodeGraphNode.cpp
UsdUINodeGraphNodeHandler.cpp
UsdUndoAttributesCommands.cpp
UsdTransform3dRead.cpp
UsdUndoConnectionCommands.cpp
UsdUndoCreateStageWithNewLayerCommand.cpp
Expand All @@ -207,10 +184,6 @@ set(HEADERS
ProxyShapeHierarchy.h
ProxyShapeHierarchyHandler.h
RotationUtils.h
UsdAttribute.h
UsdAttributeHolder.h
UsdAttributes.h
UsdAttributesHandler.h
UsdPointInstanceModifierBase.h
UsdPointInstanceOrientationModifier.h
UsdPointInstancePositionModifier.h
Expand Down Expand Up @@ -295,15 +268,12 @@ if(CMAKE_UFE_V4_FEATURES_AVAILABLE)
list(APPEND HEADERS
UsdShaderNodeDef.h
UsdShaderNodeDefHandler.h
UsdShaderAttributeDef.h
UsdShaderAttributeHolder.h
UsdUndoCreateFromNodeDefCommand.h
ProxyShapeCameraHandler.h
UsdConnections.h
UsdConnectionHandler.h
UsdUINodeGraphNode.h
UsdUINodeGraphNodeHandler.h
UsdUndoAttributesCommands.h
UsdTransform3dRead.h
UsdUndoConnectionCommands.h
UsdUndoCreateStageWithNewLayerCommand.h
Expand Down
Loading
Loading