A SERVICE OF

logo

Performance Programming Techniques
165
Figure 14-6 Arranging Scene Graph Nodes
When an action traverses a scene graph, the more nodes it visits, the longer it takes to
execute the action. If scene graph branches are deep, the traversal can become expensive.
To correct this problem, if you nd that the elements in a branch do not change often, you
can precompile that branch using csCompileAction. This action compiles a specied
subgraph into a data structure, which optimizes setting the traversal state.
To compile a subgraph, create a csCompileAction object and apply it to the root node of
the scene graph, as follows
csCompileAction *compileIt = new csCompileAction;
compileIt->apply(node_name);
node_name is the name of the node below which you want to precompile.
Torso
node
Leg
node
Foot
node
Leg
node
Foot
node