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

MAYA-125378 Implementation batched duplication #2687

Merged
10 changes: 10 additions & 0 deletions cmake/modules/FindUFE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# UFE_VERSION UFE version (major.minor.patch) from ufe.h
# UFE_LIGHTS_SUPPORT Presence of UFE lights support
# UFE_SCENE_SEGMENT_SUPPORT Presence of UFE scene segment support
# UFE_PREVIEW_FEATURES List of all features introduced gradually in the UFE preview version
#

find_path(UFE_INCLUDE_DIR
Expand Down Expand Up @@ -82,6 +83,13 @@ find_library(UFE_LIBRARY
NO_DEFAULT_PATH
)

# Gather all preview features that might be there or not into a single list:
list(APPEND UFE_PREVIEW_FEATURES ufe)

if (UFE_INCLUDE_DIR AND EXISTS "${UFE_INCLUDE_DIR}/ufe/batchOpsHandler.h")
list(APPEND UFE_PREVIEW_FEATURES v4_BatchOps)
endif()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using a list to store keys looks like a viable solution to handle progressively added features.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like it, but I'm not a CMake expert.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think each feature added to UFE_PREVIEW_FEATURES should be tagged with the version first. So "v4_BatchOps". This would make them easier to find and remove/modify to normal ufe ifdef once Ufe v4 is released.

Copy link
Collaborator Author

@JGamache-autodesk JGamache-autodesk Nov 7, 2022

Choose a reason for hiding this comment

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

What happens when we backport v5_WorkflowX into v4 for an hypothetical Maya dot release?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Once Ufe v4 is released we remove all these "preview" checks and replace them with just "ufe v4" check.


# Handle the QUIETLY and REQUIRED arguments and set UFE_FOUND to TRUE if
# all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
Expand All @@ -90,6 +98,7 @@ find_package_handle_standard_args(UFE
REQUIRED_VARS
UFE_INCLUDE_DIR
UFE_LIBRARY
UFE_PREVIEW_FEATURES
VERSION_VAR
UFE_VERSION
)
Expand All @@ -98,6 +107,7 @@ if(UFE_FOUND)
message(STATUS "UFE include dir: ${UFE_INCLUDE_DIR}")
message(STATUS "UFE library: ${UFE_LIBRARY}")
message(STATUS "UFE version: ${UFE_VERSION}")
message(STATUS "UFE preview features: ${UFE_PREVIEW_FEATURES}")
endif()

set(UFE_LIGHTS_SUPPORT FALSE CACHE INTERNAL "ufeLights")
Expand Down
5 changes: 3 additions & 2 deletions lib/mayaUsd/render/vp2RenderDelegate/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ const std::set<std::string> _mtlxTopoNodeSet = {
// Conversion nodes:
"convert",
// Constants: they get inlined in the source.
"constant"

"constant",
// Switch, unless all inputs are connected.
"switch"
};

// Maps from a known Maya target color space name to the corresponding color correct category.
Expand Down
21 changes: 21 additions & 0 deletions lib/mayaUsd/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ if (UFE_SCENE_SEGMENT_SUPPORT)
)
endif()

if (v4_BatchOps IN_LIST UFE_PREVIEW_FEATURES)
message(STATUS "UFE_PREVIEW has V4 BatchOps support")
target_sources(${PROJECT_NAME}
PRIVATE
UsdBatchOpsHandler.cpp
UsdUndoDuplicateSelectionCommand.cpp
)

target_compile_definitions(${PROJECT_NAME}
PRIVATE
UFE_PREVIEW_BATCHOPS_SUPPORT=1
)
endif()

if(CMAKE_UFE_V4_FEATURES_AVAILABLE)
if (${UFE_PREVIEW_VERSION_NUM} GREATER_EQUAL 4001)
target_sources(${PROJECT_NAME}
Expand Down Expand Up @@ -266,6 +280,13 @@ if (UFE_SCENE_SEGMENT_SUPPORT)
)
endif()

if (v4_BatchOps IN_LIST UFE_PREVIEW_FEATURES)
list(APPEND HEADERS
UsdBatchOpsHandler.h
UsdUndoDuplicateSelectionCommand.h
)
endif()

if(CMAKE_UFE_V4_FEATURES_AVAILABLE)
if (${UFE_PREVIEW_VERSION_NUM} GREATER_EQUAL 4001)
list(APPEND HEADERS
Expand Down
6 changes: 6 additions & 0 deletions lib/mayaUsd/ufe/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
#if (UFE_PREVIEW_VERSION_NUM >= 4023)
#include <mayaUsd/ufe/UsdUINodeGraphNodeHandler.h>
#endif
#if UFE_PREVIEW_BATCHOPS_SUPPORT
#include <mayaUsd/ufe/UsdBatchOpsHandler.h>
#endif
#if (UFE_PREVIEW_VERSION_NUM >= 4001)
#include <mayaUsd/ufe/UsdShaderNodeDefHandler.h>
#endif
Expand Down Expand Up @@ -201,6 +204,9 @@ MStatus initialize()
#if (UFE_PREVIEW_VERSION_NUM >= 4023)
handlers.uiNodeGraphNodeHandler = UsdUINodeGraphNodeHandler::create();
#endif
#if UFE_PREVIEW_BATCHOPS_SUPPORT
handlers.batchOpsHandler = UsdBatchOpsHandler::create();
#endif
#if (UFE_PREVIEW_VERSION_NUM >= 4001)
handlers.nodeDefHandler = UsdShaderNodeDefHandler::create();
#endif
Expand Down
50 changes: 50 additions & 0 deletions lib/mayaUsd/ufe/UsdBatchOpsHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Copyright 2022 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 "UsdBatchOpsHandler.h"

#include <mayaUsd/ufe/UsdUndoDuplicateSelectionCommand.h>

PXR_NAMESPACE_USING_DIRECTIVE
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need this? All new code should use the fully qualified namespace name. But I don't see any USD code here.


namespace MAYAUSD_NS_DEF {
namespace ufe {

UsdBatchOpsHandler::UsdBatchOpsHandler()
: Ufe::BatchOpsHandler()
{
}

UsdBatchOpsHandler::~UsdBatchOpsHandler() { }

/*static*/
UsdBatchOpsHandler::Ptr UsdBatchOpsHandler::create()
{
return std::make_shared<UsdBatchOpsHandler>();
}

//------------------------------------------------------------------------------
// Ufe::BatchOpsHandler overrides
//------------------------------------------------------------------------------

Ufe::SelectionUndoableCommand::Ptr UsdBatchOpsHandler::duplicateSelectionCmd_(
const Ufe::Selection& selection,
const Ufe::ValueDictionary& duplicateOptions)
{
return UsdUndoDuplicateSelectionCommand::create(selection, duplicateOptions);
}

} // namespace ufe
} // namespace MAYAUSD_NS_DEF
58 changes: 58 additions & 0 deletions lib/mayaUsd/ufe/UsdBatchOpsHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef USDBATCHOPSHANDLER_H
#define USDBATCHOPSHANDLER_H

//
// Copyright 2022 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 <mayaUsd/base/api.h>

#include <pxr/usd/sdf/path.h>
#include <pxr/usd/sdf/types.h>
#include <pxr/usd/usd/stage.h>

#include <ufe/batchOpsHandler.h>

namespace MAYAUSD_NS_DEF {
namespace ufe {

//! \brief Interface to create a UsdBatchOpsHandler interface object.
class MAYAUSD_CORE_PUBLIC UsdBatchOpsHandler : public Ufe::BatchOpsHandler
{
public:
typedef std::shared_ptr<UsdBatchOpsHandler> Ptr;

UsdBatchOpsHandler();
~UsdBatchOpsHandler() override;

// Delete the copy/move constructors assignment operators.
UsdBatchOpsHandler(const UsdBatchOpsHandler&) = delete;
UsdBatchOpsHandler& operator=(const UsdBatchOpsHandler&) = delete;
UsdBatchOpsHandler(UsdBatchOpsHandler&&) = delete;
UsdBatchOpsHandler& operator=(UsdBatchOpsHandler&&) = delete;

//! Create a UsdBatchOpsHandler.
static UsdBatchOpsHandler::Ptr create();

// Ufe::BatchOpsHandler overrides.
Ufe::SelectionUndoableCommand::Ptr duplicateSelectionCmd_(
const Ufe::Selection& selection,
const Ufe::ValueDictionary& duplicateOptions) override;
}; // UsdBatchOpsHandler

} // namespace ufe
} // namespace MAYAUSD_NS_DEF

#endif // USDBATCHOPSHANDLER_H
Loading