Skip to content

Commit

Permalink
Zephyr: Scene: attempt to reduce redundant transform updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fleroviux committed May 27, 2024
1 parent 00c56c3 commit 47a46dc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions zephyr/scene/src/scene_graph.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <zephyr/scene/scene_graph.hpp>
#include <zephyr/scene/scene_node.hpp>
#include <algorithm>

namespace zephyr {

Expand All @@ -22,12 +23,21 @@ namespace zephyr {
}

void SceneGraph::SignalNodeRemoved(SceneNode* node) {
node->Traverse([this](SceneNode* child_node) {
const auto match = std::ranges::find(m_nodes_with_dirty_transform, child_node);
if(match != m_nodes_with_dirty_transform.end()) {
m_nodes_with_dirty_transform.erase(match);
}
return true;
});
}

void SceneGraph::SignalNodeTransformChanged(SceneNode* node) {
// TODO(fleroviux): avoid updating nodes more than once.
// If a node is marked for update once and then later again, ideally skip the first update.
node->Traverse([this](SceneNode* child_node) {
const auto match = std::ranges::find(m_nodes_with_dirty_transform, child_node);
if(match != m_nodes_with_dirty_transform.end()) {
m_nodes_with_dirty_transform.erase(match);
}
m_nodes_with_dirty_transform.push_back(child_node);
return true;
});
Expand Down

0 comments on commit 47a46dc

Please sign in to comment.