diff --git a/lib/flowViewport/API/fvpDataProducerSceneIndexInterface.h b/lib/flowViewport/API/fvpDataProducerSceneIndexInterface.h index 660b0f06f7..5d0456f4e8 100644 --- a/lib/flowViewport/API/fvpDataProducerSceneIndexInterface.h +++ b/lib/flowViewport/API/fvpDataProducerSceneIndexInterface.h @@ -49,8 +49,8 @@ namespace FVP_NS_DEF * * @param[in] customDataProducerSceneIndex is the custom scene index to add. * - * @param[in, out] inoutPreFix is the prefix you want to add to your data producer scene index primitives, it may be modified by this function if you provide a dccnode. - * If you don't want any prefix, pass SdfPath::AbsoluteRootPath() to this parameter. + * @param[in] preFix is the prefix you want to add to your data producer scene index primitives. + * If you don't want any prefix, pass SdfPath::AbsoluteRootPath() to this parameter. * * @param[in] dccNode is a MObject* from a DAG node for Maya, if you provide the pointer value, then we automatically track some events such as transform * or visibility updated and we hide automatically the primitives from the data producer scene index. @@ -73,7 +73,7 @@ namespace FVP_NS_DEF * @return true if the operation succeeded, false otherwise. */ virtual bool addDataProducerSceneIndex(const PXR_NS::HdSceneIndexBaseRefPtr& customDataProducerSceneIndex, - PXR_NS::SdfPath& inoutPreFix, + const PXR_NS::SdfPath& preFix, void* dccNode = nullptr, const std::string& hydraViewportId = PXR_NS::FvpViewportAPITokens->allViewports, const std::string& rendererNames = PXR_NS::FvpViewportAPITokens->allRenderers diff --git a/lib/flowViewport/API/interfacesImp/fvpDataProducerSceneIndexInterfaceImp.cpp b/lib/flowViewport/API/interfacesImp/fvpDataProducerSceneIndexInterfaceImp.cpp index 9407d691e0..8f5a0016a2 100644 --- a/lib/flowViewport/API/interfacesImp/fvpDataProducerSceneIndexInterfaceImp.cpp +++ b/lib/flowViewport/API/interfacesImp/fvpDataProducerSceneIndexInterfaceImp.cpp @@ -56,17 +56,15 @@ DataProducerSceneIndexInterfaceImp& DataProducerSceneIndexInterfaceImp::get() PXR_NS::FVP_NS_DEF::DataProducerSceneIndexDataBaseRefPtr DataProducerSceneIndexInterfaceImp::addUsdStageSceneIndex(UsdImagingCreateSceneIndicesInfo& createInfo, HdSceneIndexBaseRefPtr& finalSceneIndex, UsdImagingStageSceneIndexRefPtr& stageSceneIndex, - SdfPath& inoutPrefix, + const SdfPath& preFix, void* dccNode) { PXR_NS::FVP_NS_DEF::DataProducerSceneIndexDataBaseRefPtr dataProducerSceneIndexData = - _CreateDataProducerSceneIndexDataForUsdStage(createInfo, finalSceneIndex, stageSceneIndex, inoutPrefix, dccNode); + _CreateDataProducerSceneIndexDataForUsdStage(createInfo, finalSceneIndex, stageSceneIndex, preFix, dccNode); if (nullptr == dataProducerSceneIndexData){ return nullptr; } - inoutPrefix = dataProducerSceneIndexData->GetPrefix(); - return dataProducerSceneIndexData; } @@ -76,20 +74,18 @@ bool DataProducerSceneIndexInterfaceImp::addUsdStageDataProducerSceneIndexDataBa } bool DataProducerSceneIndexInterfaceImp::addDataProducerSceneIndex(const PXR_NS::HdSceneIndexBaseRefPtr& customDataProducerSceneIndex, - PXR_NS::SdfPath& inoutPrefix, + const PXR_NS::SdfPath& preFix, void* dccNode /*= nullptr*/, const std::string& hydraViewportId /*= allViewports*/, const std::string& rendererNames /*= allRenderers*/ ) { PXR_NS::FVP_NS_DEF::DataProducerSceneIndexDataBaseRefPtr dataProducerSceneIndexData = - _CreateDataProducerSceneIndexData(customDataProducerSceneIndex, rendererNames, inoutPrefix, dccNode); + _CreateDataProducerSceneIndexData(customDataProducerSceneIndex, rendererNames, preFix, dccNode); if (nullptr == dataProducerSceneIndexData){ return false; } - inoutPrefix = dataProducerSceneIndexData->GetPrefix(); - //PXR_NS::FvpViewportAPITokens->allViewports == hydraViewportId means the user wants customDataProducerSceneIndex to be applied in all viewports. if (PXR_NS::FvpViewportAPITokens->allViewports == hydraViewportId){ //Apply this data producer scene index to all viewports diff --git a/lib/flowViewport/API/interfacesImp/fvpDataProducerSceneIndexInterfaceImp.h b/lib/flowViewport/API/interfacesImp/fvpDataProducerSceneIndexInterfaceImp.h index c92ca4a2e9..a123ee237d 100644 --- a/lib/flowViewport/API/interfacesImp/fvpDataProducerSceneIndexInterfaceImp.h +++ b/lib/flowViewport/API/interfacesImp/fvpDataProducerSceneIndexInterfaceImp.h @@ -51,7 +51,7 @@ class DataProducerSceneIndexInterfaceImp : public DataProducerSceneIndexInterfac FVP_API PXR_NS::FVP_NS_DEF::DataProducerSceneIndexDataBaseRefPtr addUsdStageSceneIndex( PXR_NS::UsdImagingCreateSceneIndicesInfo& createInfo, PXR_NS::HdSceneIndexBaseRefPtr& finalSceneIndex, PXR_NS::UsdImagingStageSceneIndexRefPtr& stageSceneIndex, - PXR_NS::SdfPath& inoutPreFix, + const PXR_NS::SdfPath& preFix, void* dccNode); ///Specific internal function for Usd Stages @@ -59,7 +59,7 @@ class DataProducerSceneIndexInterfaceImp : public DataProducerSceneIndexInterfac ///From FVP_NS_DEF::DataProducerSceneIndexInterface bool addDataProducerSceneIndex(const PXR_NS::HdSceneIndexBaseRefPtr& customDataProducerSceneIndex, - PXR_NS::SdfPath& inoutPreFix, + const PXR_NS::SdfPath& preFix, void* dccNode = nullptr, const std::string& hydraViewportId = PXR_NS::FvpViewportAPITokens->allViewports, const std::string& rendererNames = PXR_NS::FvpViewportAPITokens->allRenderers diff --git a/lib/flowViewport/API/perViewportSceneIndicesData/fvpDataProducerSceneIndexDataBase.cpp b/lib/flowViewport/API/perViewportSceneIndicesData/fvpDataProducerSceneIndexDataBase.cpp index cc569f07c6..260b28d35e 100644 --- a/lib/flowViewport/API/perViewportSceneIndicesData/fvpDataProducerSceneIndexDataBase.cpp +++ b/lib/flowViewport/API/perViewportSceneIndicesData/fvpDataProducerSceneIndexDataBase.cpp @@ -20,25 +20,16 @@ //Local headers #include "fvpDataProducerSceneIndexDataBase.h" -#include "flowViewport/sceneIndex/fvpParentDataModifierSceneIndex.h" -#include "flowViewport/sceneIndex/fvpPathInterfaceSceneIndex.h" #include "flowViewport/API/fvpViewportAPITokens.h" //Hydra headers -#include -#include -#include -#include -#include -#include #include -#include -#include -#include +#include +#include #include #include -#include -#include +#include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -50,7 +41,6 @@ namespace FVP_NS_DEF { DataProducerSceneIndexDataBase::DataProducerSceneIndexDataBase(const CreationParameters& params) { _parentMatrix.SetIdentity(); - _dataProducerSceneIndex = params._customDataProducerSceneIndex; _prefix = params._prefix; _lastSceneIndexChain = params._customDataProducerSceneIndex; @@ -62,7 +52,6 @@ DataProducerSceneIndexDataBase::DataProducerSceneIndexDataBase(const CreationPar DataProducerSceneIndexDataBase::DataProducerSceneIndexDataBase(const CreationParametersForUsdStage& params) { _parentMatrix.SetIdentity(); - _dataProducerSceneIndex = nullptr;//Will be set later _prefix = params._prefix; _lastSceneIndexChain = nullptr;//Will be set later @@ -72,100 +61,35 @@ DataProducerSceneIndexDataBase::DataProducerSceneIndexDataBase(const CreationPar void DataProducerSceneIndexDataBase::UpdateHydraTransformFromParentPath() { - if (! _parentDataModifierSceneIndex){ + if (! _rootOverridesSceneIndex){ return; } - //Update the matrix in the filtering scene index - _parentDataModifierSceneIndex->SetParentTransformMatrix(_parentMatrix); - - //This is still a WIP trying to dirty the prims correctly... - /*HdDataSourceLocatorSet locators; - locators.append(HdXformSchema::GetDefaultLocator()); - locators.append(HdVisibilitySchema::GetDefaultLocator()); - locators.append(HdPrimvarsSchema::GetDefaultLocator()); - _retainedSceneIndex->DirtyPrims({{ _parentPath, locators}}); - */ - - //Set the transform prim as dirty so it gets recomputed - /*HdDataSourceLocatorSet locators; - HdDirtyBitsTranslator::RprimDirtyBitsToLocatorSet(HdTokens->transform, HdChangeTracker::AllSceneDirtyBits, &locators); - - //Set dirty this field in the retained scene index for the parent prim - //_retainedSceneIndex->DirtyPrims( { {_parentPath, locators} } ); - */ - - //Update by removing the prim and adding it again - RemoveParentPrimFromSceneIndex(); - AddParentPrimToSceneIndex(); + _rootOverridesSceneIndex->SetRootTransform(_parentMatrix); } void DataProducerSceneIndexDataBase::UpdateVisibilityFromDCCNode(bool isVisible) { - if (! _parentDataModifierSceneIndex){ - return; - } - //Update the visibility in the filtering scene index - _parentDataModifierSceneIndex->SetParentVisibility(isVisible); - - //This is still a WIP trying to dirty the prims correctly... - /* //Set the transform prim as dirty so it gets recomputed - HdDataSourceLocatorSet locators; - HdDirtyBitsTranslator::RprimDirtyBitsToLocatorSet(HdTokens->transform, HdChangeTracker::DirtyVisibility, &locators); - - //Set dirty this field in the retained scene index for the parent prim - //_retainedSceneIndex->DirtyPrims({{_parentPath, locators}}); - */ - - //Update by removing the prim and adding it again - RemoveParentPrimFromSceneIndex(); - AddParentPrimToSceneIndex(); -} - -void DataProducerSceneIndexDataBase::AddParentPrimToSceneIndex() -{ - if(_visible){ + if (! _rootOverridesSceneIndex){ return; } - //Arrays of added prims - HdRetainedSceneIndex::AddedPrimEntries addedPrims; - - //We are creating a XForm prim which has only 2 attributes a matrix and a visibility. - //This prim will be the parent of all data producer scene index primitives so we can change their transform or visibility from the parent - HdRetainedSceneIndex::AddedPrimEntry parentPrimEntry; - parentPrimEntry.primPath = _prefix; - parentPrimEntry.primType = HdTokens->transform; - parentPrimEntry.dataSource = HdRetainedContainerDataSource::New( - HdXformSchemaTokens->xform, - HdXformSchema::Builder().SetMatrix(HdRetainedTypedSampledDataSource::New(_parentMatrix)).Build(), - - HdVisibilitySchemaTokens->visibility, - HdVisibilitySchema::BuildRetained(HdRetainedTypedSampledDataSource::New(true)) - ); - - addedPrims.emplace_back(parentPrimEntry); - - - //Add new prims to the scene index - _retainedSceneIndex->AddPrims(addedPrims); - _visible = true; -} - -void DataProducerSceneIndexDataBase::RemoveParentPrimFromSceneIndex() -{ - if(!_visible){ - return; - } - - _retainedSceneIndex->RemovePrims({ _prefix}); - _visible = false; + _rootOverridesSceneIndex->SetRootVisibility(isVisible); } void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForDataProducerSceneIndex() { if (_dccNode){ _CreateSceneIndexChainForDataProducerSceneIndexWithDCCNode(_dataProducerSceneIndex); + //Add a flattening scene index so that the root override scene index is applied (flatten only visibility and xform) + using namespace HdMakeDataSourceContainingFlattenedDataSourceProvider; + static HdContainerDataSourceHandle const flattenDataSource = + HdRetainedContainerDataSource::New( + HdVisibilitySchema::GetSchemaToken(), + Make(), + HdXformSchema::GetSchemaToken(), + Make()); + _lastSceneIndexChain = HdFlatteningSceneIndex::New(_lastSceneIndexChain, flattenDataSource); } else{ _CreateSceneIndexChainForDataProducerSceneIndexWithoutDCCNode(_dataProducerSceneIndex); @@ -177,14 +101,17 @@ void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForDataProducerSceneI HdSceneIndexBaseRefPtr DataProducerSceneIndexDataBase::_CreateUsdStageSceneIndexChain(HdSceneIndexBaseRefPtr const & inputStageSceneIndex) { _CreateSceneIndexChainForDataProducerSceneIndexWithDCCNode(inputStageSceneIndex); + UpdateHydraTransformFromParentPath();//Update the transform, this is useful when deleting the node and undoing it return _lastSceneIndexChain; } void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForUsdStageSceneIndex(CreationParametersForUsdStage& params) { - //Set the overridesSceneIndexCallback to insert our scene indices chain after the stage scene index and before the flatten scene index - //If we don't do so, we cannot add a parent which will apply its matrix to the children because of the flatten scene index in the usd stage chain. - params._createInfo.overridesSceneIndexCallback = std::bind(&DataProducerSceneIndexDataBase::_CreateUsdStageSceneIndexChain, this, std::placeholders::_1); + if (params._dccNode){ + //Set the overridesSceneIndexCallback to insert our scene indices chain after the stage scene index and before the flatten scene index + //If we don't do so, we cannot modify the transform or visibility to the children because of the flatten scene index in the usd stage chain. + params._createInfo.overridesSceneIndexCallback = std::bind(&DataProducerSceneIndexDataBase::_CreateUsdStageSceneIndexChain, this, std::placeholders::_1); + } //Create the scene indices chain UsdImagingSceneIndices sceneIndices = UsdImagingCreateSceneIndices(params._createInfo); @@ -196,42 +123,8 @@ void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForUsdStageSceneIndex void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForDataProducerSceneIndexWithDCCNode(HdSceneIndexBaseRefPtr const & inputSceneIndex) { - //Create a parent path to parent the whole inputSceneIndex prims, try to use the DCC node name - std::string nodeName = GetDCCNodeName(); - - if (nodeName.empty()){ - _prefix = _prefix.AppendPath(SdfPath(TfStringPrintf("DataProducerSI_%p", &(*inputSceneIndex)))); - }else{ - //A nodeName was provided by the DCC implementation, and it was sanitized for Hydra - _prefix = _prefix.AppendPath(SdfPath(nodeName)); - } - - //Create a retainedsceneindex to inject a parent path to the be the parent of inputSceneIndex - _retainedSceneIndex = HdRetainedSceneIndex::New(); - // Add a prim inside which will be the parent of inputSceneIndex, its SdfPath will updated in _inOutData._parentPath - AddParentPrimToSceneIndex(); - - //Create a filtering scene index to update the information (transform, visibility,...) from the parent prim. - _parentDataModifierSceneIndex = ParentDataModifierSceneIndex::New(_retainedSceneIndex, _prefix, _parentMatrix, true); - - //Add a prefixing scene index to inputSceneIndex to set the parent which we added to the retainedsceneindex - HdPrefixingSceneIndexRefPtr prefixingSceneIndex = HdPrefixingSceneIndex::New(inputSceneIndex, _prefix); - - //Use a merging scene index to merge the prefixing and the retainedsceneindex - HdMergingSceneIndexRefPtr mergingSceneIndex = HdMergingSceneIndex::New(); - mergingSceneIndex->AddInputScene(_parentDataModifierSceneIndex, SdfPath::AbsoluteRootPath()); - mergingSceneIndex->AddInputScene(prefixingSceneIndex, SdfPath::AbsoluteRootPath()); - - //Add a flattening scene index to the merging scene index, flatten only transform and visibility - static HdContainerDataSourceHandle const flattenedTransformAndVisibilityDataSourceHandle = - HdRetainedContainerDataSource::New( - HdVisibilitySchema::GetSchemaToken(), - HdMakeDataSourceContainingFlattenedDataSourceProvider::Make(), - HdXformSchema::GetSchemaToken(), - HdMakeDataSourceContainingFlattenedDataSourceProvider::Make() - ); - - _lastSceneIndexChain = HdFlatteningSceneIndex::New(mergingSceneIndex, flattenedTransformAndVisibilityDataSourceHandle);//Flattening scene index to apply transform/visibility on children + _rootOverridesSceneIndex = UsdImagingRootOverridesSceneIndex::New(inputSceneIndex); + _lastSceneIndexChain = _rootOverridesSceneIndex; } void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForDataProducerSceneIndexWithoutDCCNode(HdSceneIndexBaseRefPtr const & inputSceneIndex) @@ -242,7 +135,6 @@ void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForDataProducerSceneI sceneIndex = HdPrefixingSceneIndex::New(sceneIndex, _prefix); } - //Add a PathInterfaceSceneIndex for selection _lastSceneIndexChain = sceneIndex; } diff --git a/lib/flowViewport/API/perViewportSceneIndicesData/fvpDataProducerSceneIndexDataBase.h b/lib/flowViewport/API/perViewportSceneIndicesData/fvpDataProducerSceneIndexDataBase.h index bc204da973..7ae34069a4 100644 --- a/lib/flowViewport/API/perViewportSceneIndicesData/fvpDataProducerSceneIndexDataBase.h +++ b/lib/flowViewport/API/perViewportSceneIndicesData/fvpDataProducerSceneIndexDataBase.h @@ -18,12 +18,13 @@ //Local headers #include "flowViewport/api.h" -#include "flowViewport/sceneIndex/fvpParentDataModifierSceneIndex.h" //Hydra headers #include +#include #include #include +#include //The Pixar's namespace needs to be at the highest namespace level for TF_DECLARE_WEAK_AND_REF_PTRS to work. PXR_NAMESPACE_OPEN_SCOPE @@ -75,9 +76,6 @@ TF_DECLARE_WEAK_AND_REF_PTRS(DataProducerSceneIndexDataBase);//Be able to use Re ~DataProducerSceneIndexDataBase() override = default; - virtual void AddParentPrimToSceneIndex(); - virtual void RemoveParentPrimFromSceneIndex(); - //Used to set the usd stage scene indices void SetDataProducerSceneIndex(const HdSceneIndexBaseRefPtr& sceneIndex) {_dataProducerSceneIndex = sceneIndex;} void SetDataProducerLastSceneIndexChain(const HdSceneIndexBaseRefPtr& sceneIndex) {_lastSceneIndexChain = sceneIndex;} @@ -117,18 +115,16 @@ TF_DECLARE_WEAK_AND_REF_PTRS(DataProducerSceneIndexDataBase);//Be able to use Re void* _dccNode; //The following members are optional and only used when a dccNode was passed in the constructor - /** Is a filtering scene index that modifies the parent prim from the retained scene index to update the transform/visibility when it is updated in the DCC. - It is used only when a dccNode was passed.*/ - ParentDataModifierSceneIndexRefPtr _parentDataModifierSceneIndex = nullptr; + /// Is the last scene index of the scene index chain when a dccNode was passed. HdSceneIndexBaseRefPtr _lastSceneIndexChain = nullptr; - /// Is the retained scene index holding the parent prim for _dataProducerSceneIndex. It is used only when a dccNode was passed. - HdRetainedSceneIndexRefPtr _retainedSceneIndex = nullptr; - /// Is the world matrix of the parent prim in the retained scene index. It is used only when a dccNode was passed. + /// Is the world matrix of the scene index. It is used only when a dccNode was passed to override the transform of the root of the scene index. GfMatrix4d _parentMatrix; - /// Is the visibility state of the parent prim in the retained scene index. It is used only when a dccNode was passed. - bool _visible = false; + + /// _rootOverridesSceneIndex is used to set a transform and visibility at the root of the Usd stage/data producer scene index. It is used only when a dccNode was passed. + /// With this scene index when you select the proxyshape node and move it or hide it, we apply the same operation on the stage, same for a data producer scene index with a hosting node. + UsdImagingRootOverridesSceneIndexRefPtr _rootOverridesSceneIndex = nullptr; }; }//End of namespace FVP_NS_DEF diff --git a/lib/flowViewport/sceneIndex/CMakeLists.txt b/lib/flowViewport/sceneIndex/CMakeLists.txt index 7b7b938555..ed1553fc99 100644 --- a/lib/flowViewport/sceneIndex/CMakeLists.txt +++ b/lib/flowViewport/sceneIndex/CMakeLists.txt @@ -9,7 +9,6 @@ target_sources(${TARGET_NAME} fvpRenderIndexProxy.cpp fvpSelectionSceneIndex.cpp fvpWireframeSelectionHighlightSceneIndex.cpp - fvpParentDataModifierSceneIndex.cpp ) set(HEADERS @@ -20,7 +19,6 @@ set(HEADERS fvpRenderIndexProxyFwd.h fvpSelectionSceneIndex.h fvpWireframeSelectionHighlightSceneIndex.h - fvpParentDataModifierSceneIndex.h ) # ----------------------------------------------------------------------------- diff --git a/lib/flowViewport/sceneIndex/fvpParentDataModifierSceneIndex.cpp b/lib/flowViewport/sceneIndex/fvpParentDataModifierSceneIndex.cpp deleted file mode 100644 index ecd8c2fc6f..0000000000 --- a/lib/flowViewport/sceneIndex/fvpParentDataModifierSceneIndex.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -// Copyright 2023 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. -// - -//We use a this filtering scene index to update the data from a HdRetainedSceneIndex where we inserted a parent prim to be the parent of all prims from an data producer scene index -// which is hosted in a DCC node. -// We only update the data from the parent SdfPath, it has the same transform as the DCC node which contains the data producer scene index. - -//Local headers -#include "fvpParentDataModifierSceneIndex.h" - -//USD/Hydra headers -#include -#include -#include -#include - -PXR_NAMESPACE_OPEN_SCOPE - -namespace FVP_NS_DEF { - -//This is the function where we filter prims -HdSceneIndexPrim ParentDataModifierSceneIndex::GetPrim(const SdfPath& primPath) const -{ - if (!_GetInputSceneIndex()){ - return HdSceneIndexPrim(); - } - - HdSceneIndexPrim prim = _GetInputSceneIndex()->GetPrim(primPath); - - if (prim.dataSource && (primPath == _parentPath)){ - //Use an HdContainerDataSourceEditor to overwrite the values for the transform and visibility attributes - prim.dataSource = - HdContainerDataSourceEditor(prim.dataSource) - .Set(HdXformSchema::GetDefaultLocator(), HdXformSchema::Builder().SetMatrix(HdRetainedTypedSampledDataSource::New(_transformMatrix)).Build()) - .Set(HdVisibilitySchema::GetDefaultLocator(), HdVisibilitySchema::BuildRetained(HdRetainedTypedSampledDataSource::New(_visible))) - .Finish(); - } - - return prim;//returned the modified prim -} - -}//End of namespace FVP_NS_DEF - -PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file diff --git a/lib/flowViewport/sceneIndex/fvpParentDataModifierSceneIndex.h b/lib/flowViewport/sceneIndex/fvpParentDataModifierSceneIndex.h deleted file mode 100644 index f38ea99a58..0000000000 --- a/lib/flowViewport/sceneIndex/fvpParentDataModifierSceneIndex.h +++ /dev/null @@ -1,97 +0,0 @@ -// -// Copyright 2023 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 FLOW_VIEWPORT_SCENEINDEX_PARENT_DATA_MODIFIER_SCENE_INDEX_H -#define FLOW_VIEWPORT_SCENEINDEX_PARENT_DATA_MODIFIER_SCENE_INDEX_H - -//Local headers -#include "flowViewport/api.h" - -//Hydra headers -#include -#include -#include - -//The Pixar's namespace needs to be at the highest namespace level for TF_DECLARE_WEAK_AND_REF_PTRS to work. -PXR_NAMESPACE_OPEN_SCOPE - -namespace FVP_NS_DEF { - -//We use a filtering scene index to update the data from a HdRetainedSceneIndex where we inserted a parent prim to be the parent of all prims from a data producer scene index -// which is hosted in a DCC node. - -class ParentDataModifierSceneIndex; -TF_DECLARE_WEAK_AND_REF_PTRS(ParentDataModifierSceneIndex); - -class ParentDataModifierSceneIndex : public HdSingleInputFilteringSceneIndexBase -{ -public: - using ParentClass = HdSingleInputFilteringSceneIndexBase; - - static ParentDataModifierSceneIndexRefPtr New(const HdSceneIndexBaseRefPtr& inputSceneIndex, const SdfPath& parentPath, const GfMatrix4d& transformMatrix, bool visible){ - return TfCreateRefPtr(new ParentDataModifierSceneIndex(inputSceneIndex, parentPath, transformMatrix, visible)); - } - - void SetParentTransformMatrix (const GfMatrix4d& transformMatrix) {_transformMatrix = transformMatrix;} - void SetParentVisibility (bool visible) {_visible = visible;} - - // From HdSceneIndexBase - HdSceneIndexPrim GetPrim(const SdfPath& primPath) const override; - SdfPathVector GetChildPrimPaths(const SdfPath& primPath) const override { //defined in this header file as we do no modification to it - if (_GetInputSceneIndex()){ - return _GetInputSceneIndex()->GetChildPrimPaths(primPath); - } - - return {}; - } - - ~ParentDataModifierSceneIndex() override = default; - -protected: - void _PrimsAdded( - const HdSceneIndexBase& sender, - const HdSceneIndexObserver::AddedPrimEntries& entries) override final - { - _SendPrimsAdded(entries); - } - - void _PrimsRemoved( - const HdSceneIndexBase& sender, - const HdSceneIndexObserver::RemovedPrimEntries& entries) override final - { - _SendPrimsRemoved(entries); - } - - void _PrimsDirtied( - const HdSceneIndexBase& sender, - const HdSceneIndexObserver::DirtiedPrimEntries& entries) override final - { - _SendPrimsDirtied(entries); - } - - SdfPath _parentPath; - GfMatrix4d _transformMatrix; - bool _visible = true; -private: - ParentDataModifierSceneIndex(const HdSceneIndexBaseRefPtr& _inputSceneIndex, const SdfPath& parentPath, const GfMatrix4d& transformMatrix, bool visible) : - ParentClass(_inputSceneIndex), _parentPath(parentPath), _transformMatrix(transformMatrix), _visible(visible) {} -}; - -} //End of namespace FVP_NS_DEF - -PXR_NAMESPACE_CLOSE_SCOPE - -#endif //FLOW_VIEWPORT_SCENEINDEX_PARENT_DATA_MODIFIER_SCENE_INDEX_H - diff --git a/lib/mayaHydra/hydraExtensions/sceneIndex/registration.cpp b/lib/mayaHydra/hydraExtensions/sceneIndex/registration.cpp index 47424444f1..db2e52ee50 100644 --- a/lib/mayaHydra/hydraExtensions/sceneIndex/registration.cpp +++ b/lib/mayaHydra/hydraExtensions/sceneIndex/registration.cpp @@ -263,6 +263,10 @@ void MayaHydraSceneIndexRegistry::_AddSceneIndexForNode(MObject& dagNode) registration->rootSceneIndex = registration->pluginSceneIndex; + registration->rootSceneIndex = HdPrefixingSceneIndex::New( + registration->rootSceneIndex, + registration->sceneIndexPathPrefix); + //Add the PathInterfaceSceneIndex which must be the last scene index, it is used for selection highlighting registration->rootSceneIndex = PathInterfaceSceneIndex::New( registration->rootSceneIndex,