From 3919549c86bc1aee5d067e4e61b5e1df3c6545fa Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 30 Oct 2023 09:07:34 -0700 Subject: [PATCH] Hydrogent task manager: added methods to enable/disable tasks associated with a material tag --- Hydrogent/interface/Tasks/HnTaskManager.hpp | 6 +++ Hydrogent/src/Tasks/HnTaskManager.cpp | 49 +++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/Hydrogent/interface/Tasks/HnTaskManager.hpp b/Hydrogent/interface/Tasks/HnTaskManager.hpp index 37650795..4e6dfaaa 100644 --- a/Hydrogent/interface/Tasks/HnTaskManager.hpp +++ b/Hydrogent/interface/Tasks/HnTaskManager.hpp @@ -140,6 +140,12 @@ class HnTaskManager /// - if an Rprim is selected, returns the Sdf Path of the selected Rprim. const pxr::SdfPath* GetSelectedRPrimId() const; + /// Enables or disables the tasks associated with the specified material tag. + void EnableMaterial(const pxr::TfToken& MaterialTag, bool Enable); + + /// Returns true if the tasks associated with the specified material tag are enabled. + bool IsMaterialEnabled(const pxr::TfToken& MaterialTag) const; + private: pxr::SdfPath GetRenderRprimsTaskId(const pxr::TfToken& MaterialTag) const; diff --git a/Hydrogent/src/Tasks/HnTaskManager.cpp b/Hydrogent/src/Tasks/HnTaskManager.cpp index 675f383e..5c3fd7f2 100644 --- a/Hydrogent/src/Tasks/HnTaskManager.cpp +++ b/Hydrogent/src/Tasks/HnTaskManager.cpp @@ -332,6 +332,55 @@ bool HnTaskManager::IsTaskEnabled(TaskUID UID) const return it != m_TaskInfo.end() ? it->second.Enabled : false; } +void HnTaskManager::EnableMaterial(const pxr::TfToken& MaterialTag, bool Enable) +{ + if (MaterialTag == HnMaterialTagTokens->defaultTag) + { + EnableTask(TaskUID_RenderRprimsDefault, Enable); + } + else if (MaterialTag == HnMaterialTagTokens->masked) + { + EnableTask(TaskUID_RenderRprimsMasked, Enable); + } + else if (MaterialTag == HnMaterialTagTokens->additive) + { + EnableTask(TaskUID_RenderRprimsAdditive, Enable); + } + else if (MaterialTag == HnMaterialTagTokens->translucent) + { + EnableTask(TaskUID_RenderRprimsTranslucent, Enable); + } + else + { + UNEXPECTED("Unknown material tag ", MaterialTag); + } +} + +bool HnTaskManager::IsMaterialEnabled(const pxr::TfToken& MaterialTag) const +{ + if (MaterialTag == HnMaterialTagTokens->defaultTag) + { + return IsTaskEnabled(TaskUID_RenderRprimsDefault); + } + else if (MaterialTag == HnMaterialTagTokens->masked) + { + return IsTaskEnabled(TaskUID_RenderRprimsMasked); + } + else if (MaterialTag == HnMaterialTagTokens->additive) + { + return IsTaskEnabled(TaskUID_RenderRprimsAdditive); + } + else if (MaterialTag == HnMaterialTagTokens->translucent) + { + return IsTaskEnabled(TaskUID_RenderRprimsTranslucent); + } + else + { + UNEXPECTED("Unknown material tag ", MaterialTag); + return false; + } +} + } // namespace USD } // namespace Diligent