Skip to content

Commit

Permalink
Merge branch 'dev' into debloip/HYDRA-686/fix-adapters-manual-lifetim…
Browse files Browse the repository at this point in the history
…e-management
  • Loading branch information
debloip-adsk committed Sep 3, 2024
2 parents 831d967 + d13ba28 commit cc115d3
Show file tree
Hide file tree
Showing 42 changed files with 1,939 additions and 144 deletions.
117 changes: 117 additions & 0 deletions doc/mayaHydraCommands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Maya command plugins used in MayaHydra

# MayaHydra Command Plugin

The `MayaHydra` command plugin provides a set of utilities for interacting with the Hydra rendering framework within Maya. Below are the available flags and their descriptions.

## Basic Usage

```bash
mayaHydra [flags]
```
Available Flags
```
-listDelegates / -ld:
```
Returns the names of available scene delegates.
```
-listRenderers / -lr:
```
Returns the names of available render delegates.
```
-listActiveRenderers / -lar:
```
Returns the names of render delegates that are in use in at least one viewport.

Renderer-Specific Commands
```
-renderer / -r [RENDERER]:
```
Specifies the renderer to target for the commands below.
```
-getRendererDisplayName / -gn:
```
Returns the display name for the given render delegate.
```
-createRenderGlobals / -crg:
```
Creates the render globals, optionally targeting a specific renderer.
```
-userDefaults / -ud:
```
A flag for -createRenderGlobals to restore user defaults on create.
```
-updateRenderGlobals / -urg [ATTRIBUTE]:
```
Forces the update of the render globals for the viewport, optionally targeting a specific renderer or setting.

Advanced / Debugging Flags
To access advanced and debugging flags, use the -verbose / -v flag.

Debug Flags
```
-listRenderIndex / -lri -r [RENDERER]:
```
Returns a list of all the rprims in the render index for the given render delegate.
```
-visibleOnly / -vo:
```
Affects the behavior of -listRenderIndex. If provided, only visible items in the render index are returned.
```
-sceneDelegateId / -sid [SCENE_DELEGATE] -r [RENDERER]:
```
Returns the path ID corresponding to the given render delegate and scene delegate pair.

# MayaHydra Versioning and Build Information Flags

The following flags are used to retrieve versioning and build information for the `MayaHydra` plugin. Each flag has both a short and a long form.

## Usage Example

To retrieve the full version of the `MayaHydra` plugin, use the following command:

```bash
mayaHydraBuildInfo [-flags]
```
## Version Information

- **`-mjv` / `-majorVersion`**:
Returns the major version number of the plugin.

- **`-mnv` / `-minorVersion`**:
Returns the minor version number of the plugin.

- **`-pv` / `-patchVersion`**:
Returns the patch version number of the plugin.

- **`-v` / `-version`**:
Returns the full version string of the plugin, which may include major, minor, and patch version numbers.

## Build Information

This information is expected to be set by a parent build system that has access and/or generates the following information.

- **`-c` / `-cutIdentifier`**:
Returns the cut identifier associated with this build of the plugin.

- **`-bn` / `-buildNumber`**:
Returns the build number for the plugin, typically representing the incremental number assigned during the build process.

- **`-gc` / `-gitCommit`**:
Returns the Git commit hash that the build is based on, useful for tracing the exact source code used.

- **`-gb` / `-gitBranch`**:
Returns the Git branch name that the build was created from.

- **`-bd` / `-buildDate`**:
Returns the date on which the plugin was built.


### Summary
- **Version Information Flags**: Cover major, minor, and patch version details, as well as the full version string.
- **Build Information Flags**: Include cut identifier, build number, Git commit, Git branch, and build date.
- **Usage Examples**: Show how to retrieve specific pieces of information using the provided flags.

This Markdown document provides a clear and concise reference for users who need to access versioning and build information for the `MayaHydra` plugin.


Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "flowViewport/API/interfacesImp/fvpDataProducerSceneIndexInterfaceImp.h"
#include "flowViewport/API/interfacesImp/fvpInformationInterfaceImp.h"
#include "flowViewport/sceneIndex/fvpRenderIndexProxy.h"
#include "flowViewport/selection/fvpSelection.h"
#include "flowViewport/API/perViewportSceneIndicesData/fvpFilteringSceneIndicesChainManager.h"

//Hydra headers
Expand Down Expand Up @@ -151,6 +152,91 @@ ViewportInformationAndSceneIndicesPerViewportData* ViewportInformationAndSceneIn
return nullptr;
}

SelectionPtr ViewportInformationAndSceneIndicesPerViewportDataManager::GetOrCreateIsolateSelection(const std::string& viewportId)
{
auto found = _isolateSelection.find(viewportId);
if (found != _isolateSelection.end()) {
return found->second;
}
auto selection = std::make_shared<Selection>();
_isolateSelection[viewportId] = selection;
return selection;
}

SelectionPtr ViewportInformationAndSceneIndicesPerViewportDataManager::GetIsolateSelection(const std::string& viewportId) const
{
auto found = _isolateSelection.find(viewportId);
return (found != _isolateSelection.end()) ? found->second : nullptr;
}

void ViewportInformationAndSceneIndicesPerViewportDataManager::AddIsolateSelection(
const std::string& viewportId,
const PrimSelections& primSelections
)
{
if (!TF_VERIFY(_isolateSelectSceneIndex, "No isolate select scene index set.")) {
return;
}
_CheckAndSetViewport(viewportId);
_isolateSelectSceneIndex->AddIsolateSelection(primSelections);
}

void ViewportInformationAndSceneIndicesPerViewportDataManager::RemoveIsolateSelection(
const std::string& viewportId,
const PrimSelections& primSelections
)
{
if (!TF_VERIFY(_isolateSelectSceneIndex, "No isolate select scene index set.")) {
return;
}
_CheckAndSetViewport(viewportId);
_isolateSelectSceneIndex->RemoveIsolateSelection(primSelections);
}

void ViewportInformationAndSceneIndicesPerViewportDataManager::ReplaceIsolateSelection(
const std::string& viewportId,
const SelectionConstPtr& selection
)
{
if (!TF_VERIFY(_isolateSelectSceneIndex, "No isolate select scene index set.")) {
return;
}
_CheckAndSetViewport(viewportId);
_isolateSelectSceneIndex->ReplaceIsolateSelection(selection);
}

void ViewportInformationAndSceneIndicesPerViewportDataManager::ClearIsolateSelection(const std::string& viewportId)
{
if (!TF_VERIFY(_isolateSelectSceneIndex, "No isolate select scene index set.")) {
return;
}
_CheckAndSetViewport(viewportId);
_isolateSelectSceneIndex->ClearIsolateSelection();
}

void ViewportInformationAndSceneIndicesPerViewportDataManager::SetIsolateSelectSceneIndex(
const IsolateSelectSceneIndexRefPtr& sceneIndex
)
{
_isolateSelectSceneIndex = sceneIndex;
}

IsolateSelectSceneIndexRefPtr
ViewportInformationAndSceneIndicesPerViewportDataManager::GetIsolateSelectSceneIndex() const
{
return _isolateSelectSceneIndex;
}

void
ViewportInformationAndSceneIndicesPerViewportDataManager::_CheckAndSetViewport(
const std::string& viewportId
)
{
if (_isolateSelectSceneIndex->GetViewportId() != viewportId) {
_isolateSelectSceneIndex->SetViewport(viewportId, _isolateSelection.at(viewportId));
}
}

const std::set<PXR_NS::FVP_NS_DEF::DataProducerSceneIndexDataBaseRefPtr>&
ViewportInformationAndSceneIndicesPerViewportDataManager::GetDataProducerSceneIndicesDataFromViewportId(const std::string& viewportId)const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
//Local headers
#include "fvpViewportInformationAndSceneIndicesPerViewportData.h"
#include "flowViewport/sceneIndex/fvpRenderIndexProxyFwd.h"
#include "flowViewport/sceneIndex/fvpPathInterface.h"
#include "flowViewport/sceneIndex/fvpIsolateSelectSceneIndex.h"
#include "flowViewport/selection/fvpSelectionFwd.h"

//Hydra headers
#include <pxr/imaging/hd/sceneIndex.h>
Expand All @@ -31,11 +34,16 @@ namespace FVP_NS_DEF {
*
* To get an instance of this class, please use
* ViewportInformationAndSceneIndicesPerViewportDataManager& manager = ViewportInformationAndSceneIndicesPerViewportDataManager:Get();
*
* The PerViewportDataManager also manages the per-viewport isolate selection,
* as well as providing access to the single isolate select scene index.
*/
class FVP_API ViewportInformationAndSceneIndicesPerViewportDataManager
{
public:

using ViewportIds = std::vector<std::string>;

/// Manager accessor
static ViewportInformationAndSceneIndicesPerViewportDataManager& Get();

Expand All @@ -53,18 +61,58 @@ class FVP_API ViewportInformationAndSceneIndicesPerViewportDataManager
const ViewportInformationAndSceneIndicesPerViewportData* GetViewportInfoAndDataFromViewportId(const std::string& viewportId)const;
ViewportInformationAndSceneIndicesPerViewportData* GetViewportInfoAndDataFromViewportId(const std::string& viewportId);

SelectionPtr GetOrCreateIsolateSelection(const std::string& viewportId);
SelectionPtr GetIsolateSelection(const std::string& viewportId) const;

void AddIsolateSelection(
const std::string& viewportId,
const PrimSelections& primSelections
);
void RemoveIsolateSelection(
const std::string& viewportId,
const PrimSelections& primSelections
);
void ReplaceIsolateSelection(
const std::string& viewportId,
const SelectionConstPtr& selection
);
void ClearIsolateSelection(const std::string& viewportId);

// Get and set the isolate select scene index. This scene index provides
// isolate select services for all viewports.
void SetIsolateSelectSceneIndex(
const IsolateSelectSceneIndexRefPtr& sceneIndex
);
IsolateSelectSceneIndexRefPtr GetIsolateSelectSceneIndex() const;

const std::set<PXR_NS::FVP_NS_DEF::DataProducerSceneIndexDataBaseRefPtr>& GetDataProducerSceneIndicesDataFromViewportId(const std::string& viewportId)const;

bool ModelPanelIsAlreadyRegistered(const std::string& modelPanel)const;
void RemoveAllViewportsInformation();

private:

// Singleton, no public creation or copy.
ViewportInformationAndSceneIndicesPerViewportDataManager() = default;
ViewportInformationAndSceneIndicesPerViewportDataManager(
const ViewportInformationAndSceneIndicesPerViewportDataManager&
) = delete;

void _CheckAndSetViewport(const std::string& viewportId);

///Hydra viewport information
ViewportInformationAndSceneIndicesPerViewportDataVector _viewportsInformationAndSceneIndicesPerViewportData;

ViewportInformationAndSceneIndicesPerViewportDataManager() = default;
// Isolate selection, keyed by viewportId.
std::map<std::string, SelectionPtr> _isolateSelection;

// Isolate select scene index.
IsolateSelectSceneIndexRefPtr _isolateSelectSceneIndex;
};

// Convenience shorthand declaration.
using PerViewportDataManager = ViewportInformationAndSceneIndicesPerViewportDataManager;

} //End of namespace FVP_NS_DEF

#endif // FLOW_VIEWPORT_API_PERVIEWPORTSCENEINDICESDATA_VIEWPORT_INFORMATION_AND_SCENE_INDICES_DATA_PER_VIEWPORT_DATA_MANAGER
#endif // FLOW_VIEWPORT_API_PERVIEWPORTSCENEINDICESDATA_VIEWPORT_INFORMATION_AND_SCENE_INDICES_DATA_PER_VIEWPORT_DATA_MANAGER
4 changes: 4 additions & 0 deletions lib/flowViewport/debugCodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ TF_REGISTRY_FUNCTION(TfDebug)
TF_DEBUG_ENVIRONMENT_SYMBOL(
PXR_NS::FVP_WIREFRAME_SELECTION_HIGHLIGHT_SCENE_INDEX,
"Print information about the Flow Viewport wireframe selection highlight scene index.");

TF_DEBUG_ENVIRONMENT_SYMBOL(
PXR_NS::FVP_ISOLATE_SELECT_SCENE_INDEX,
"Print information about the Flow Viewport isolate select scene index.");
}

PXR_NAMESPACE_CLOSE_SCOPE
1 change: 1 addition & 0 deletions lib/flowViewport/debugCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ TF_DEBUG_CODES(
, FVP_APP_SELECTION_CHANGE
, FVP_MERGING_SCENE_INDEX
, FVP_WIREFRAME_SELECTION_HIGHLIGHT_SCENE_INDEX
, FVP_ISOLATE_SELECT_SCENE_INDEX
);
// clang-format on

Expand Down
16 changes: 16 additions & 0 deletions lib/flowViewport/fvpUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "fvpUtils.h"

#include <pxr/imaging/hd/instanceIndicesSchema.h>
#include <pxr/imaging/hd/selectionSchema.h>

namespace FVP_NS_DEF {
Expand All @@ -39,4 +40,19 @@ PXR_NS::HdDataSourceBaseHandle createFullySelectedDataSource()
return PXR_NS::HdDataSourceBase::Cast(selectionBuilder.Build());
}

PXR_NS::HdDataSourceBaseHandle createInstanceSelectionDataSource(const PXR_NS::SdfPath& instancerPrimPath, int instanceIndex)
{
PXR_NS::HdInstanceIndicesSchema::Builder instanceIndicesBuilder;
instanceIndicesBuilder.SetInstancer(PXR_NS::HdRetainedTypedSampledDataSource<PXR_NS::SdfPath>::New(instancerPrimPath));
instanceIndicesBuilder.SetInstanceIndices(PXR_NS::HdRetainedTypedSampledDataSource<PXR_NS::VtArray<int>>::New({instanceIndex}));
PXR_NS::HdSelectionSchema::Builder selectionBuilder;
// Instancer is expected to be marked "fully selected" even if only certain instances are selected,
// based on USD's _AddToSelection function in selectionSceneIndexObserver.cpp :
// https://github.com/PixarAnimationStudios/OpenUSD/blob/f7b8a021ce3d13f91a0211acf8a64a8b780524df/pxr/imaging/hdx/selectionSceneIndexObserver.cpp#L212-L251
selectionBuilder.SetFullySelected(PXR_NS::HdRetainedTypedSampledDataSource<bool>::New(true));
auto instanceIndicesDataSource = PXR_NS::HdDataSourceBase::Cast(instanceIndicesBuilder.Build());
selectionBuilder.SetNestedInstanceIndices(PXR_NS::HdRetainedSmallVectorDataSource::New(1, &instanceIndicesDataSource));
return PXR_NS::HdDataSourceBase::Cast(selectionBuilder.Build());
}

} // namespace FVP_NS_DEF
2 changes: 2 additions & 0 deletions lib/flowViewport/fvpUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class PrimvarDataSource final : public PXR_NS::HdContainerDataSource

PXR_NS::HdDataSourceBaseHandle FVP_API createFullySelectedDataSource();

PXR_NS::HdDataSourceBaseHandle FVP_API createInstanceSelectionDataSource(const PXR_NS::SdfPath& instancerPrimPath, int instanceIndex);

} // namespace FVP_NS_DEF

#endif // FVP_UTILS_H
2 changes: 2 additions & 0 deletions lib/flowViewport/sceneIndex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# -----------------------------------------------------------------------------
target_sources(${TARGET_NAME}
PRIVATE
fvpIsolateSelectSceneIndex.cpp
fvpMergingSceneIndex.cpp
fvpPathInterface.cpp
fvpPathInterfaceSceneIndex.cpp
Expand All @@ -19,6 +20,7 @@ target_sources(${TARGET_NAME}
)

set(HEADERS
fvpIsolateSelectSceneIndex.h
fvpMergingSceneIndex.h
fvpPathInterface.h
fvpPathInterfaceSceneIndex.h
Expand Down
Loading

0 comments on commit cc115d3

Please sign in to comment.