Skip to content

Commit

Permalink
HnTaskManager: added more convenient methods to set task parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Nov 6, 2023
1 parent c09e0e6 commit 83e7d6c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
8 changes: 6 additions & 2 deletions Hydrogent/interface/Tasks/HnTaskManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
27 changes: 14 additions & 13 deletions Hydrogent/src/Tasks/HnTaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<HnPostProcessTaskParams>(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<HnProcessSelectionTaskParams>(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);
}
}
Expand Down

0 comments on commit 83e7d6c

Please sign in to comment.