Skip to content

Commit

Permalink
Handle visiblity
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve J. Cai committed Nov 3, 2023
1 parent 6861023 commit b29af45
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Hydrogent/interface/HnMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class HnMesh final : public pxr::HdMesh
Uint32 GetNumEdges() const { return m_NumEdges; }
Uint32 GetNumPoints() const { return m_Topology.GetNumPoints(); }

const bool IsVisible() const { return m_IsVisible; }
const float4x4& GetTransform() const { return m_Transform; }

const pxr::SdfPath& GetMaterialId() const { return m_MaterialId; }
Expand Down Expand Up @@ -146,6 +147,7 @@ class HnMesh final : public pxr::HdMesh

std::unordered_map<pxr::TfToken, std::shared_ptr<pxr::HdBufferSource>, pxr::TfToken::HashFunctor> m_BufferSources;

bool m_IsVisible = true;
Uint32 m_NumTriangles = 0;
Uint32 m_NumEdges = 0;

Expand Down
4 changes: 4 additions & 0 deletions Hydrogent/src/HnMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ void HnMesh::UpdateRepr(pxr::HdSceneDelegate& SceneDelegate,
pxr::GfMatrix4d Transform = SceneDelegate.GetTransform(Id);
m_Transform = float4x4::MakeMatrix(Transform.data());
}
if (pxr::HdChangeTracker::IsVisibilityDirty(DirtyBits, Id))
{
m_IsVisible = SceneDelegate.GetVisible(Id);
}

DirtyBits &= ~pxr::HdChangeTracker::NewRepr;
}
Expand Down
3 changes: 3 additions & 0 deletions Hydrogent/src/HnRenderPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ void HnRenderPass::RenderMesh(RenderState& State,
if (pPosVB == nullptr || pSRB == nullptr)
return;

if (!Mesh.IsVisible())
return;

// Our shader currently supports two texture coordinate sets.
// Gather vertex buffers for both sets.
const auto& TexCoordSets = Material.GetTextureCoordinateSets();
Expand Down

0 comments on commit b29af45

Please sign in to comment.