From 6861023e94e9cf33e2f87002ae81f45ab2ccd396 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sat, 28 Oct 2023 00:14:41 -0700 Subject: [PATCH] HnTaskManager: fixed logic in GetSelectedRPrimId --- Hydrogent/interface/Tasks/HnReadRprimIdTask.hpp | 2 +- Hydrogent/src/Tasks/HnTaskManager.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Hydrogent/interface/Tasks/HnReadRprimIdTask.hpp b/Hydrogent/interface/Tasks/HnReadRprimIdTask.hpp index 644bebf7..8f07da92 100644 --- a/Hydrogent/interface/Tasks/HnReadRprimIdTask.hpp +++ b/Hydrogent/interface/Tasks/HnReadRprimIdTask.hpp @@ -79,7 +79,7 @@ class HnReadRprimIdTask final : public HnTask static constexpr Uint32 InvalidMeshIndex = ~0u; /// Returns the mesh index that was read from the mesh id target last time the task was executed. - /// If Mesh Id is not available, returns ~0u. + /// If Mesh Id is not available, returns InvalidMeshIndex (~0u). Uint32 GetMeshIndex() const { return m_MeshIndex; } private: diff --git a/Hydrogent/src/Tasks/HnTaskManager.cpp b/Hydrogent/src/Tasks/HnTaskManager.cpp index b1e8c55c..675f383e 100644 --- a/Hydrogent/src/Tasks/HnTaskManager.cpp +++ b/Hydrogent/src/Tasks/HnTaskManager.cpp @@ -304,12 +304,16 @@ const pxr::SdfPath* HnTaskManager::GetSelectedRPrimId() const const Uint32 MeshIdx = ReadRprimIdTask.GetMeshIndex(); if (MeshIdx == HnReadRprimIdTask::InvalidMeshIndex) { - static const pxr::SdfPath EmptyPath; - return &EmptyPath; + // Data is not yet available + return nullptr; } else { - return static_cast(GetRenderIndex().GetRenderDelegate())->GetRPrimId(MeshIdx); + const pxr::SdfPath* rPRimId = static_cast(GetRenderIndex().GetRenderDelegate())->GetRPrimId(MeshIdx); + static const pxr::SdfPath EmptyPath; + return rPRimId != nullptr ? + rPRimId : + &EmptyPath; // Return empty path to indicate that the data is available, but no RPrim is not selected } }