-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes from code review and moved a class to flow viewport
- Loading branch information
1 parent
f225b84
commit c4f8f5e
Showing
12 changed files
with
162 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
lib/flowViewport/selection/fvpDataProducersNodeHashCodeToSdfPathRegistry.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// Copyright 2024 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 "fvpDataProducersNodeHashCodeToSdfPathRegistry.h" | ||
#include <pxr/base/tf/instantiateSingleton.h> | ||
|
||
PXR_NAMESPACE_USING_DIRECTIVE | ||
TF_INSTANTIATE_SINGLETON(FVP_NS::DataProducersNodeHashCodeToSdfPathRegistry); | ||
|
||
// DataProducersNodeHashCodeToSdfPathRegistry does a mapping between DCC nodes hash code and Hydra | ||
// paths. The DCC nodes registered in this class are used by data producers scene indices as a | ||
// parent to all their Hydra primitives. The registration/unregistration in this class is automatic | ||
// when you use the flow viewport API and provide a DCC node as a parent. This class is used when | ||
// we select one of these DCC nodes to return the matching SdfPath so that all prims child of this | ||
// node are highlighted. | ||
|
||
namespace FVP_NS_DEF { | ||
|
||
/* static */ | ||
DataProducersNodeHashCodeToSdfPathRegistry& DataProducersNodeHashCodeToSdfPathRegistry::Instance() | ||
{ | ||
return PXR_NS::TfSingleton<DataProducersNodeHashCodeToSdfPathRegistry>::GetInstance(); | ||
} | ||
|
||
void DataProducersNodeHashCodeToSdfPathRegistry::Add(const unsigned long& dccNodeHashCode, const SdfPath& thePath) | ||
{ | ||
if (thePath.IsEmpty() || 0 == dccNodeHashCode) { | ||
TF_CODING_WARNING("Sending an empty SdfPath or an invalid dcc node hash code in DataProducersNodeHashCodeToSdfPathRegistry::Add, ignoring"); | ||
return; | ||
} | ||
|
||
_SdfPathByHashCode.insert({ dccNodeHashCode, thePath }); | ||
} | ||
|
||
void DataProducersNodeHashCodeToSdfPathRegistry::Remove(const unsigned long& dccNodeHashCode) | ||
{ | ||
if (0 == dccNodeHashCode) { | ||
return; | ||
} | ||
|
||
auto it = _SdfPathByHashCode.find(dccNodeHashCode); | ||
if (it != _SdfPathByHashCode.end()) { | ||
_SdfPathByHashCode.erase(it); | ||
} | ||
} | ||
|
||
SdfPath DataProducersNodeHashCodeToSdfPathRegistry::GetPath(const unsigned long& dccNodeHashCode) const | ||
{ | ||
if (0 == dccNodeHashCode) { | ||
TF_CODING_WARNING("Sending an invalid dccNodeHashCode in DataProducersNodeHashCodeToSdfPathRegistry::GetPath"); | ||
return {}; | ||
} | ||
auto it = _SdfPathByHashCode.find(dccNodeHashCode); | ||
if (it != _SdfPathByHashCode.end()) { | ||
return (it->second); | ||
} | ||
return SdfPath(); | ||
} | ||
|
||
} // namespace FVP_NS_DEF |
68 changes: 68 additions & 0 deletions
68
lib/flowViewport/selection/fvpDataProducersNodeHashCodeToSdfPathRegistry.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// Copyright 2024 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_SELECTION__DATA_PRODUCERS_NODE_HASH_CODE_TO_SDFPATH_REGISTRY_H | ||
#define FLOW_VIEWPORT_SELECTION__DATA_PRODUCERS_NODE_HASH_CODE_TO_SDFPATH_REGISTRY_H | ||
|
||
//local headers | ||
#include "flowViewport/api.h" | ||
|
||
//Usd headers | ||
#include <pxr/base/tf/singleton.h> | ||
#include <pxr/usd/sdf/path.h> | ||
|
||
#include <unordered_map> | ||
|
||
namespace FVP_NS_DEF { | ||
|
||
/// DataProducersNodeHashCodeToSdfPathRegistry does a mapping between DCC nodes hash code and Hydra paths. | ||
/// The DCC nodes registered in this class are used by data producers scene indices as a parent to all primitives. | ||
/// The registration/unregistration in this class is automatic when you use the flow viewport API and provide a DCC node as a parent. | ||
/// This class is used when we select one of these nodes to return the matching SdfPath so that all child prims of this node are highlighted. | ||
class DataProducersNodeHashCodeToSdfPathRegistry | ||
{ | ||
public: | ||
// Access the singleton instance | ||
FVP_API | ||
static DataProducersNodeHashCodeToSdfPathRegistry& Instance(); | ||
|
||
FVP_API | ||
void Add(const unsigned long& objectHandlehashCode, const PXR_NS::SdfPath& thePath); | ||
|
||
FVP_API | ||
void Remove(const unsigned long& objectHandleHashCode); | ||
|
||
// Returns an empty SdfPath if the objectHandle is not registered or the matching SdfPath | ||
// otherwise | ||
FVP_API | ||
PXR_NS::SdfPath GetPath(const unsigned long& objectHandleHashCode) const; | ||
|
||
private: | ||
// Singleton, no public creation or copy. | ||
DataProducersNodeHashCodeToSdfPathRegistry() = default; | ||
~DataProducersNodeHashCodeToSdfPathRegistry() = default; | ||
DataProducersNodeHashCodeToSdfPathRegistry(const DataProducersNodeHashCodeToSdfPathRegistry& ) = delete; | ||
DataProducersNodeHashCodeToSdfPathRegistry& operator=(const DataProducersNodeHashCodeToSdfPathRegistry& ) = delete; | ||
|
||
friend class PXR_NS::TfSingleton<DataProducersNodeHashCodeToSdfPathRegistry>; | ||
|
||
std::unordered_map<unsigned long, PXR_NS::SdfPath> _SdfPathByHashCode; | ||
|
||
static std::unique_ptr<DataProducersNodeHashCodeToSdfPathRegistry> _instance; | ||
}; | ||
|
||
} // namespace FVP_NS_DEF | ||
|
||
#endif //FLOW_VIEWPORT_SELECTION__DATA_PRODUCERS_NODE_HASH_CODE_TO_SDFPATH_REGISTRY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 0 additions & 66 deletions
66
lib/mayaHydra/hydraExtensions/mhDataProducersMayaNodeToSdfPathRegistry.cpp
This file was deleted.
Oops, something went wrong.
71 changes: 0 additions & 71 deletions
71
lib/mayaHydra/hydraExtensions/mhDataProducersMayaNodeToSdfPathRegistry.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.