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

Tremblp/maya 112824/pull push 01 to dev #1789

Merged
merged 12 commits into from
Nov 5, 2021
3 changes: 1 addition & 2 deletions lib/mayaUsd/commands/baseExportCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ MStatus MayaUSDExportCommand::doIt(const MArgList& args)
std::string rootPath = tmpArgList.asString(0).asChar();

if (!rootPath.empty()) {
MDagPath rootDagPath;
UsdMayaUtil::GetDagPathByName(rootPath, rootDagPath);
MDagPath rootDagPath = UsdMayaUtil::nameToDagPath(rootPath);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed duplicate name to Dag path utility and its uses.

if (!rootDagPath.isValid()) {
MGlobal::displayError(
MString("Invalid dag path provided for exportRoot: ")
Expand Down
30 changes: 24 additions & 6 deletions lib/mayaUsd/fileio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ target_sources(${PROJECT_NAME}
primReaderArgs.cpp
primReaderContext.cpp
primReaderRegistry.cpp
primUpdater.cpp
primUpdaterContext.cpp
primUpdaterRegistry.cpp
primWriter.cpp
primWriterArgs.cpp
primWriterContext.cpp
Expand All @@ -28,6 +25,19 @@ target_sources(${PROJECT_NAME}
writeJobContext.cpp
)

# Edit as Maya requires UFE path mapping.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently, edit as Maya is conditional on UFE v3, because it requires UFE path mapping for proper Outliner support. However, it would theoretically be possible to back-port the UFE path mapping interface to UFE v2, as it is a purely additive interface change to UFE. This will be for future consideration.

if(CMAKE_UFE_V3_FEATURES_AVAILABLE)
target_sources(${PROJECT_NAME}
PRIVATE
fallbackPrimUpdater.cpp
primUpdater.cpp
primUpdaterArgs.cpp
primUpdaterContext.cpp
primUpdaterRegistry.cpp
primUpdaterManager.cpp
)
endif()

set(HEADERS
fallbackPrimReader.h
functorPrimReader.h
Expand All @@ -38,9 +48,6 @@ set(HEADERS
primReaderArgs.h
primReaderContext.h
primReaderRegistry.h
primUpdater.h
primUpdaterContext.h
primUpdaterRegistry.h
primWriter.h
primWriterArgs.h
primWriterContext.h
Expand All @@ -54,6 +61,17 @@ set(HEADERS
writeJobContext.h
)

if(CMAKE_UFE_V3_FEATURES_AVAILABLE)
list(APPEND HEADERS
fallbackPrimUpdater.h
primUpdater.h
primUpdaterArgs.h
primUpdaterContext.h
primUpdaterRegistry.h
primUpdaterManager.h
)
endif()

# -----------------------------------------------------------------------------
# promoted headers
# -----------------------------------------------------------------------------
Expand Down
25 changes: 25 additions & 0 deletions lib/mayaUsd/fileio/fallbackPrimUpdater.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Copyright 2021 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "fallbackPrimUpdater.h"

PXR_NAMESPACE_OPEN_SCOPE

FallbackPrimUpdater::FallbackPrimUpdater(const MFnDependencyNode& depNodeFn, const Ufe::Path& path)
: UsdMayaPrimUpdater(depNodeFn, path)
{
}

PXR_NAMESPACE_CLOSE_SCOPE
42 changes: 42 additions & 0 deletions lib/mayaUsd/fileio/fallbackPrimUpdater.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// Copyright 2021 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef PXRUSDMAYA_FALLBACK_PRIMUPDATER_H
#define PXRUSDMAYA_FALLBACK_PRIMUPDATER_H

#include <mayaUsd/base/api.h>
#include <mayaUsd/fileio/primUpdater.h>

PXR_NAMESPACE_OPEN_SCOPE

class FallbackPrimUpdater : public UsdMayaPrimUpdater
{
public:
MAYAUSD_CORE_PUBLIC
FallbackPrimUpdater(const MFnDependencyNode& depNodeFn, const Ufe::Path& path);

// clang errors if you use "= default" here, due to const SdfPath member
// see: http://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#253
// ...which it seems clang only implements if using newer version + cpp std
FallbackPrimUpdater() { }

virtual ~FallbackPrimUpdater() = default;

private:
};

PXR_NAMESPACE_CLOSE_SCOPE

#endif
3 changes: 1 addition & 2 deletions lib/mayaUsd/fileio/jobs/jobArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,7 @@ static PcpMapFunction::PathMap _ExportRootsMap(
const std::vector<std::string> exportRoots = _Vector<std::string>(userArgs, key);
for (const std::string& rootPath : exportRoots) {
if (!rootPath.empty()) {
MDagPath rootDagPath;
UsdMayaUtil::GetDagPathByName(rootPath, rootDagPath);
MDagPath rootDagPath = UsdMayaUtil::nameToDagPath(rootPath);
addExportRootPathPairFn(rootDagPath);
} else {
includeEntireSelection = true;
Expand Down
5 changes: 5 additions & 0 deletions lib/mayaUsd/fileio/jobs/readJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ const MDagPath& UsdMaya_ReadJob::GetMayaRootDagPath() const { return mMayaRootDa

double UsdMaya_ReadJob::timeSampleMultiplier() const { return mTimeSampleMultiplier; }

const UsdMayaPrimReaderContext::ObjectRegistry& UsdMaya_ReadJob::GetNewNodeRegistry() const
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Provide access to the import new Maya node registry, so that the edit as Maya code can be run on them.

Choose a reason for hiding this comment

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

Should it be available in python?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds potentially useful, but I could not find a Python wrapper wrapper for a UsdMaya_ReadJob.

{
return mNewNodeRegistry;
}

double UsdMaya_ReadJob::_setTimeSampleMultiplierFrom(const double layerFPS)
{
double sceneFPS = UsdMayaUtil::GetSceneMTimeUnitAsDouble();
Expand Down
3 changes: 3 additions & 0 deletions lib/mayaUsd/fileio/jobs/readJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class UsdMaya_ReadJob
MAYAUSD_CORE_PUBLIC
double timeSampleMultiplier() const;

MAYAUSD_CORE_PUBLIC
const UsdMayaPrimReaderContext::ObjectRegistry& GetNewNodeRegistry() const;

protected:
// Types
using _PrimReaderMap = std::unordered_map<SdfPath, UsdMayaPrimReaderSharedPtr, SdfPath::Hash>;
Expand Down
13 changes: 13 additions & 0 deletions lib/mayaUsd/fileio/jobs/writeJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ UsdMaya_WriteJob::UsdMaya_WriteJob(const UsdMayaJobExportArgs& iArgs)

UsdMaya_WriteJob::~UsdMaya_WriteJob() { }

SdfPath UsdMaya_WriteJob::MapDagPathToSdfPath(const MDagPath& dagPath) const
{
SdfPath usdPrimPath;
TfMapLookup(mDagPathToUsdPathMap, dagPath, &usdPrimPath);

return usdPrimPath;
}

/// Generates a name for a temporary usdc file in \p dir.
/// Unless you are very, very unlucky, the stage name is unique because it's
/// generated from a UUID.
Expand Down Expand Up @@ -819,4 +827,9 @@ bool UsdMaya_WriteJob::_CheckNameClashes(const SdfPath& path, const MDagPath& da
return true;
}

const UsdMayaUtil::MDagPathMap<SdfPath>& UsdMaya_WriteJob::GetDagPathToUsdPathMap() const
{
return mDagPathToUsdPathMap;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Provide access to the export Dag path to USD path map, so the merge to USD code can access it.

}

PXR_NAMESPACE_CLOSE_SCOPE
6 changes: 6 additions & 0 deletions lib/mayaUsd/fileio/jobs/writeJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class UsdMaya_WriteJob
MAYAUSD_CORE_PUBLIC
bool Write(const std::string& fileName, bool append);

MAYAUSD_CORE_PUBLIC
SdfPath MapDagPathToSdfPath(const MDagPath& dagPath) const;

MAYAUSD_CORE_PUBLIC
const UsdMayaUtil::MDagPathMap<SdfPath>& GetDagPathToUsdPathMap() const;

private:
/// Begins constructing the USD stage, writing out the values at the default
/// time. Returns \c true if the stage can be created successfully.
Expand Down
Loading