From 83e7d6cb66f82c8777c7a7a51d304b2888cfe1b0 Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 6 Nov 2023 07:36:12 -0800 Subject: [PATCH] HnTaskManager: added more convenient methods to set task parameters --- Hydrogent/interface/Tasks/HnTaskManager.hpp | 8 ++++-- Hydrogent/src/Tasks/HnTaskManager.cpp | 27 +++++++++++---------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Hydrogent/interface/Tasks/HnTaskManager.hpp b/Hydrogent/interface/Tasks/HnTaskManager.hpp index 694c2d78..f582354e 100644 --- a/Hydrogent/interface/Tasks/HnTaskManager.hpp +++ b/Hydrogent/interface/Tasks/HnTaskManager.hpp @@ -39,8 +39,11 @@ namespace Diligent namespace USD { +struct HnSetupRenderingTaskParams; struct HnRenderRprimsTaskParams; +struct HnPostProcessTaskParams; struct HnRenderPassParams; +struct HnReadRprimIdTaskParams; /// Task manager implementation in Hydrogent. class HnTaskManager @@ -171,7 +174,10 @@ class HnTaskManager bool SetTaskParams(const pxr::SdfPath& Id, TaskParamsType&& Params); + void SetupRendering(const HnSetupRenderingTaskParams& Params); void SetRenderRprimParams(const HnRenderRprimsTaskParams& Params); + void SetPostProcessParams(const HnPostProcessTaskParams& Params); + void SetReadRprimIdParams(const HnReadRprimIdTaskParams& Params); void EnableTask(TaskUID UID, bool Enable); bool IsTaskEnabled(TaskUID UID) const; @@ -192,8 +198,6 @@ class HnTaskManager /// Returns true if the tasks associated with the specified material tag are enabled. bool IsMaterialEnabled(const pxr::TfToken& MaterialTag) const; - void SetSelectionOutlineWidth(float Width); - private: pxr::SdfPath GetRenderRprimsTaskId(const pxr::TfToken& MaterialTag, const HnRenderPassParams& RenderPassParams) const; diff --git a/Hydrogent/src/Tasks/HnTaskManager.cpp b/Hydrogent/src/Tasks/HnTaskManager.cpp index e30fc5e1..c7463204 100644 --- a/Hydrogent/src/Tasks/HnTaskManager.cpp +++ b/Hydrogent/src/Tasks/HnTaskManager.cpp @@ -288,6 +288,11 @@ void HnTaskManager::CreateRenderRprimsTask(const pxr::TfToken& MaterialTag, Task m_RenderTaskIds.emplace_back(RenderRprimsTaskId); } +void HnTaskManager::SetupRendering(const HnSetupRenderingTaskParams& Params) +{ + SetTaskParams(TaskUID_SetupRendering, Params); +} + void HnTaskManager::SetRenderRprimParams(const HnRenderRprimsTaskParams& Params) { for (const auto& TaskId : m_RenderTaskIds) @@ -477,26 +482,22 @@ bool HnTaskManager::IsMaterialEnabled(const pxr::TfToken& MaterialTag) const } } -void HnTaskManager::SetSelectionOutlineWidth(float Width) +void HnTaskManager::SetReadRprimIdParams(const HnReadRprimIdTaskParams& Params) { - auto post_process_task_it = m_TaskInfo.find(TaskUID_PostProcess); - if (post_process_task_it != m_TaskInfo.end()) - { - HnPostProcessTaskParams PostProcessParams = m_ParamsDelegate.GetParameter(post_process_task_it->second.Id, pxr::HdTokens->params); - if (PostProcessParams.SelectionOutlineWidth != Width) - { - PostProcessParams.SelectionOutlineWidth = Width; - SetTaskParams(TaskUID_PostProcess, PostProcessParams); - } - } + SetTaskParams(TaskUID_ReadRprimId, Params); +} + +void HnTaskManager::SetPostProcessParams(const HnPostProcessTaskParams& Params) +{ + SetTaskParams(TaskUID_PostProcess, Params); auto process_selection_task_it = m_TaskInfo.find(TaskUID_ProcessSelection); if (process_selection_task_it != m_TaskInfo.end()) { HnProcessSelectionTaskParams ProcessSelectionParams = m_ParamsDelegate.GetParameter(process_selection_task_it->second.Id, pxr::HdTokens->params); - if (ProcessSelectionParams.MaximumDistance != Width) + if (ProcessSelectionParams.MaximumDistance != Params.SelectionOutlineWidth) { - ProcessSelectionParams.MaximumDistance = Width; + ProcessSelectionParams.MaximumDistance = Params.SelectionOutlineWidth; SetTaskParams(TaskUID_ProcessSelection, ProcessSelectionParams); } }