You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once you know that a sub-tree is dirty, you know that all of its children are dirty and can avoid making that decision again.
Splitting render into Clean (so far) and (known to be) Dirty functions lets most of the nodes only have to either make the decision about clean/dirty (on the clean so far path) or combine the transforms (on the dirty path). The only node that has to do both is the 1st node reached that is dirty.
Note that if renderMesh can be moved to the end of the calls (after rendering children) then tail call optimization is also a possibility. Tail call optimization is not reasonably doable when the functions end in a for loop. But it's also possible that renderMesh might be more expensive if done after children.
diff --git a/code/cpp/dirty-flag.h b/code/cpp/dirty-flag.h
index 31df713..cf674df 100644
--- a/code/cpp/dirty-flag.h
+++ b/code/cpp/dirty-flag.h
@@ -147,6 +147,8 @@ namespace DirtyFlag
static const int MAX_CHILDREN = 16;
GraphNode* children_[MAX_CHILDREN];
int numChildren_;
Once you know that a sub-tree is dirty, you know that all of its children are dirty and can avoid making that decision again.
Splitting render into Clean (so far) and (known to be) Dirty functions lets most of the nodes only have to either make the decision about clean/dirty (on the clean so far path) or combine the transforms (on the dirty path). The only node that has to do both is the 1st node reached that is dirty.
Note that if renderMesh can be moved to the end of the calls (after rendering children) then tail call optimization is also a possibility. Tail call optimization is not reasonably doable when the functions end in a for loop. But it's also possible that renderMesh might be more expensive if done after children.
diff --git a/code/cpp/dirty-flag.h b/code/cpp/dirty-flag.h
index 31df713..cf674df 100644
--- a/code/cpp/dirty-flag.h
+++ b/code/cpp/dirty-flag.h
@@ -147,6 +147,8 @@ namespace DirtyFlag
static const int MAX_CHILDREN = 16;
GraphNode* children_[MAX_CHILDREN];
int numChildren_;
//^omit
};
//^dirty-graph-node
@@ -162,18 +164,36 @@ namespace DirtyFlag
//^dirty-render
void GraphNode::render(Transform parentWorld, bool dirty)
{
if (dirty)
{
}
if (mesh_) renderMesh(mesh_, world_);
for (int i = 0; i < numChildren_; i++)
{
}
}
//^dirty-render
The text was updated successfully, but these errors were encountered: