Skip to content

Commit

Permalink
HYDRA-598 : Fixes from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanierd-adsk committed Nov 14, 2023
1 parent 2748c35 commit 65b7b2c
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,24 @@
#include <mutex>

namespace{
static std::mutex _viewportInformationClient_mutex;
std::mutex _viewportInformationClient_mutex;
}

PXR_NAMESPACE_USING_DIRECTIVE

namespace FVP_NS_DEF {

static InformationInterfaceImp theInterface;

//Set of information clients
static InformationClientSet _viewportInformationClients;

InformationInterface& InformationInterface::Get()
{
return theInterface;
return InformationInterfaceImp::Get();
}

InformationInterfaceImp& InformationInterfaceImp::Get(void)
InformationInterfaceImp& InformationInterfaceImp::Get()
{
static InformationInterfaceImp theInterface;
return theInterface;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@

namespace FVP_NS_DEF {

///Is a singleton, use InformationInterfaceImp& _getInformationInterfaceImp(void) below to get an instance of that interface
///Is a singleton, use InformationInterfaceImp& InformationInterfaceImp::Get() to get an instance of that interface
class InformationInterfaceImp : public InformationInterface
{
public:
InformationInterfaceImp() = default;
virtual ~InformationInterfaceImp() = default;

///Interface accessor
Expand All @@ -41,6 +40,9 @@ class InformationInterfaceImp : public InformationInterface

void SceneIndexAdded(const InformationInterface::ViewportInformation& _viewportInfo);
void SceneIndexRemoved(const InformationInterface::ViewportInformation& viewportInfo);

private:
InformationInterfaceImp() = default;
};

} //End of namespace FVP_NS_DEF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@
#include <mutex>

namespace{
static std::mutex _viewportSelectClient_mutex;
std::mutex _viewportSelectClient_mutex;
}

PXR_NAMESPACE_USING_DIRECTIVE

namespace FVP_NS_DEF {

static SelectionInterfaceImp theInterface;

SelectionClientSet _viewportSelectionClients;

FlowSelectionInterface& FlowSelectionInterface::Get()
{
return theInterface;
return SelectionInterfaceImp::Get();
}

SelectionInterfaceImp& SelectionInterfaceImp::Get()
{
static SelectionInterfaceImp theInterface;
return theInterface;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace FVP_NS_DEF {
class SelectionInterfaceImp : public FVP_NS_DEF::FlowSelectionInterface
{
public:
SelectionInterfaceImp() = default;
virtual ~SelectionInterfaceImp() = default;

///Interface accessor
Expand All @@ -40,6 +39,9 @@ class SelectionInterfaceImp : public FVP_NS_DEF::FlowSelectionInterface

//To be called by maya-hydra
void DummySelectionCallback();

private:
SelectionInterfaceImp() = default;
};

} //End of namespace FVP_NS_DEF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace
{
static std::mutex _viewportInformationAndSceneIndicesPerViewportDataSet_mutex;
std::mutex _viewportInformationAndSceneIndicesPerViewportDataSet_mutex;
}

PXR_NAMESPACE_USING_DIRECTIVE
Expand Down
11 changes: 7 additions & 4 deletions lib/flowViewport/sceneIndex/fvpRenderIndexProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,19 @@ HdRenderIndex* RenderIndexProxy::GetRenderIndex() const
return _renderIndex;
}

void RenderIndexProxy::GetRendererDisplayName(std::string& outRendererName) const
std::string RenderIndexProxy::GetRendererDisplayName() const
{
static std::string empty;

if (! _renderIndex){
return;
return empty;
}
auto rd = _renderIndex->GetRenderDelegate();
if (! rd){
return;
return empty;
}
outRendererName = rd->GetRendererDisplayName();

return rd->GetRendererDisplayName();
}

}//end of namespace FVP_NS_DEF
2 changes: 1 addition & 1 deletion lib/flowViewport/sceneIndex/fvpRenderIndexProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class RenderIndexProxy

///Get the render delegate display name
FVP_API
void GetRendererDisplayName(std::string& outRendererName) const;
std::string GetRendererDisplayName() const;

private:

Expand Down
58 changes: 33 additions & 25 deletions lib/mayaHydra/mayaPlugin/renderOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,31 +796,8 @@ void MtohRenderOverride::_InitHydraResources(const MHWRender::MDrawContext& draw
_engine.SetTaskContextData(FvpTokens->fvpSelectionState, fvpSelectionTrackerValue);

_mayaHydraSceneProducer->Populate();

HdSceneIndexBaseRefPtr lastSceneIndexOfTheChain = _renderIndexProxy->GetMergingSceneIndex();

//Get the latest scene index of the custom filtering scene indices chain and apply the selection scene index
_selectionSceneIndex = Fvp::SelectionSceneIndex::New(lastSceneIndexOfTheChain);
_selectionSceneIndex->SetDisplayName("Flow Viewport Selection Scene Index");

if (!_sceneIndexRegistry) {
_sceneIndexRegistry.reset(new MayaHydraSceneIndexRegistry(*_renderIndexProxy));
}

lastSceneIndexOfTheChain = _selectionSceneIndex;
auto wfSi = TfDynamic_cast<Fvp::WireframeSelectionHighlightSceneIndexRefPtr>(Fvp::WireframeSelectionHighlightSceneIndex::New(lastSceneIndexOfTheChain));
wfSi->SetDisplayName("Flow Viewport Wireframe Selection Highlight Scene Index");

// At time of writing, wireframe selection highlighting of Maya native data
// is done by Maya at render item creation time, so avoid double wireframe
// selection highlighting.
wfSi->addExcludedSceneRoot(_ID);

lastSceneIndexOfTheChain = wfSi;
_renderIndex->InsertSceneIndex(lastSceneIndexOfTheChain, SdfPath::AbsoluteRootPath());

// Set the initial selection onto the selection scene index.
_selectionSceneIndex->ReplaceSelection(*Ufe::GlobalSelection::get());

_CreateSceneIndicesChainAfterMergingSceneIndex();

if (auto* renderDelegate = _GetRenderDelegate()) {
// Pull in any options that may have changed due file-open.
Expand Down Expand Up @@ -884,6 +861,37 @@ void MtohRenderOverride::ClearHydraResources()
_initializationAttempted = false;
}

void MtohRenderOverride::_CreateSceneIndicesChainAfterMergingSceneIndex()
{
//This function is where happens the ordering of filtering scene indices that are after the merging scene index

HdSceneIndexBaseRefPtr lastSceneIndexOfTheChain = _renderIndexProxy->GetMergingSceneIndex();

//Get the latest scene index of the custom filtering scene indices chain and apply the selection scene index
_selectionSceneIndex = Fvp::SelectionSceneIndex::New(lastSceneIndexOfTheChain);
_selectionSceneIndex->SetDisplayName("Flow Viewport Selection Scene Index");

if (!_sceneIndexRegistry) {
_sceneIndexRegistry.reset(new MayaHydraSceneIndexRegistry(*_renderIndexProxy));
}

lastSceneIndexOfTheChain = _selectionSceneIndex;
auto wfSi = TfDynamic_cast<Fvp::WireframeSelectionHighlightSceneIndexRefPtr>(Fvp::WireframeSelectionHighlightSceneIndex::New(lastSceneIndexOfTheChain));
wfSi->SetDisplayName("Flow Viewport Wireframe Selection Highlight Scene Index");

// At time of writing, wireframe selection highlighting of Maya native data
// is done by Maya at render item creation time, so avoid double wireframe
// selection highlighting.
wfSi->addExcludedSceneRoot(_ID);

lastSceneIndexOfTheChain = wfSi;

_renderIndex->InsertSceneIndex(lastSceneIndexOfTheChain, SdfPath::AbsoluteRootPath());

// Set the initial selection onto the selection scene index.
_selectionSceneIndex->ReplaceSelection(*Ufe::GlobalSelection::get());
}

void MtohRenderOverride::_RemovePanel(MString panelName)
{
auto foundPanelCallbacks = _FindPanelCallbacks(panelName);
Expand Down
1 change: 1 addition & 0 deletions lib/mayaHydra/mayaPlugin/renderOverride.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class MtohRenderOverride : public MHWRender::MRenderOverride
void _DetectMayaDefaultLighting(const MHWRender::MDrawContext& drawContext);
HdRenderDelegate* _GetRenderDelegate();
void _SetRenderPurposeTags(const MayaHydraParams& delegateParams);
void _CreateSceneIndicesChainAfterMergingSceneIndex();

void _PickByRegion(
HdxPickHitVector& outHits,
Expand Down
2 changes: 1 addition & 1 deletion plugin/mayaHydraSceneBrowser/mayaHydraSceneBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "mayaHydraSceneBrowser.h"

#include <mayaHydraLib/hydraUtils.h>
#include <mayaHydraLib/mayaHydraLibInterfaceImp.h>
#include <mayaHydraLib/mayaHydraLibInterface.h>

#include <sceneIndexDebuggerWidget.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "mayaHydraSceneBrowserTestCmd.h"

#include <mayaHydraLib/hydraUtils.h>
#include <mayaHydraLib/mayaHydraLibInterfaceImp.h>
#include <mayaHydraLib/mayaHydraLibInterface.h>

#include <maya/MArgList.h>
#include <maya/MFnPlugin.h>
Expand Down

0 comments on commit 65b7b2c

Please sign in to comment.