Skip to content

Commit

Permalink
Render: Fixed handling of nodes removed from culler.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonJoker committed Apr 5, 2024
1 parent e61c95d commit 91aecb0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/Core/Castor3D/Render/Culling/SceneCuller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ namespace castor3d
mutable SceneCullerSignal onCompute;
mutable SceneCullerSubmeshSignal onSubmeshChanged;
mutable SceneCullerBillboardSignal onBillboardChanged;
mutable SceneCullerSubmeshSignal onSubmeshRemoved;
mutable SceneCullerBillboardSignal onBillboardRemoved;

private:
void doInitialiseCulled();
Expand Down
2 changes: 2 additions & 0 deletions include/Core/Castor3D/Render/Node/QueueRenderNodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ namespace castor3d
PipelineNodesBuffer m_pipelinesNodes;

SceneCullerSubmeshSignalConnection m_onSubmeshChanged;
SceneCullerSubmeshSignalConnection m_onSubmeshRemoved;
SceneCullerBillboardSignalConnection m_onBillboardChanged;
SceneCullerBillboardSignalConnection m_onBillboardRemoved;

castor::UnorderedSet< CulledNodeT< SubmeshRenderNode > const * > m_pendingSubmeshes;
castor::UnorderedSet< CulledNodeT< BillboardRenderNode > const * > m_pendingBillboards;
Expand Down
2 changes: 2 additions & 0 deletions source/Core/Castor3D/Render/Culling/SceneCuller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ namespace castor3d

if ( m_culledSubmeshes.end() != it )
{
onSubmeshRemoved( *this, **it, false );
m_culledSubmeshes.erase( it );
}
}
Expand All @@ -194,6 +195,7 @@ namespace castor3d

if ( m_culledBillboards.end() != it )
{
onBillboardRemoved( *this, **it, false );
m_culledBillboards.erase( it );
}
}
Expand Down
32 changes: 30 additions & 2 deletions source/Core/Castor3D/Render/Node/QueueRenderNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,12 +784,24 @@ namespace castor3d
{
doAddSubmesh( node );
} ) }
, m_onSubmeshRemoved{ queue.getCuller().onSubmeshRemoved.connect( [this]( SceneCuller const &
, CulledNodeT< SubmeshRenderNode > const & node
, bool )
{
doRemoveSubmesh( node );
} ) }
, m_onBillboardChanged{ queue.getCuller().onBillboardChanged.connect( [this]( SceneCuller const &
, CulledNodeT< BillboardRenderNode > const & node
, bool )
{
doAddBillboard( node );
} ) }
, m_onBillboardRemoved{ queue.getCuller().onBillboardRemoved.connect( [this]( SceneCuller const &
, CulledNodeT< BillboardRenderNode > const & node
, bool )
{
doRemoveBillboard( node );
} ) }
{
#if VK_EXT_mesh_shader || VK_NV_mesh_shader

Expand Down Expand Up @@ -1407,12 +1419,28 @@ namespace castor3d

void QueueRenderNodes::doAddSubmesh( CulledNodeT< SubmeshRenderNode > const & node )
{
m_pendingSubmeshes.insert( &node );
auto & queue = *getOwner();
auto & renderPass = *queue.getOwner();

if ( renderPass.isValidPass( *node.node->pass )
&& renderPass.isValidRenderable( node.node->instance )
&& renderPass.isValidNode( *node.node->instance.getParent() ) )
{
m_pendingSubmeshes.insert( &node );
}
}

void QueueRenderNodes::doAddBillboard( CulledNodeT< BillboardRenderNode > const & node )
{
m_pendingBillboards.insert( &node );
auto & queue = *getOwner();
auto & renderPass = *queue.getOwner();

if ( renderPass.isValidPass( *node.node->pass )
&& renderPass.isValidRenderable( node.node->instance )
&& renderPass.isValidNode( *node.node->instance.getNode() ) )
{
m_pendingBillboards.insert( &node );
}
}

void QueueRenderNodes::doRemoveSubmesh( CulledNodeT< SubmeshRenderNode > const & node )
Expand Down

0 comments on commit 91aecb0

Please sign in to comment.