Panda3D
|
This is a special node that combines multiple independently-moving rigid nodes into one Geom internally (or as few Geoms as possible), for the purposes of improving rendering performance. More...
#include "rigidBodyCombiner.h"
Classes | |
class | VDUnifier |
Public Member Functions | |
RigidBodyCombiner (const string &name) | |
void | collect () |
Walks through the entire subgraph of nodes rooted at this node, accumulates all of the RenderAttribs and Geoms below this node, flattening them into just one Geom (or as few as possible, if there are multiple different states). | |
virtual bool | cull_callback (CullTraverser *trav, CullTraverserData &data) |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time. | |
virtual TypeHandle | force_init_type () |
NodePath | get_internal_scene () |
Returns a special NodePath that represents the internal node of this object. | |
virtual TypeHandle | get_type () const |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
RigidBodyCombiner (const RigidBodyCombiner ©) | |
virtual PandaNode * | make_copy () const |
Returns a newly-allocated PandaNode that is a shallow copy of this one. |
This is a special node that combines multiple independently-moving rigid nodes into one Geom internally (or as few Geoms as possible), for the purposes of improving rendering performance.
To use it, parent a number of moving objects to this node and call collect(). A child node is identified as "moving" if (a) it has a non-identity transform initially, or (b) it is a ModelNode with the preserve_transform flag set. Any other nodes will be considered static, and later transforms applied to them will not be identified.
You should call collect() only at startup or if you change the set of children; it is a relatively expensive call.
Once you call collect(), you may change the transforms on the child nodes freely without having to call collect() again.
RenderEffects such as Billboards are not supported below this node.
Definition at line 52 of file rigidBodyCombiner.h.
void RigidBodyCombiner::collect | ( | ) |
Walks through the entire subgraph of nodes rooted at this node, accumulates all of the RenderAttribs and Geoms below this node, flattening them into just one Geom (or as few as possible, if there are multiple different states).
Nodes that have transforms on them at the time of collect(), or any ModelNodes with the preserve_transform flag, will be identified as "moving" nodes, and their transforms will be monitored as they change in future frames and each new transform directly applied to the vertices.
This call must be made after adding any nodes to or removing any nodes from the subgraph rooted at this node. It should not be made too often, as it is a relatively expensive call. If you need to hide children of this node, consider scaling them to zero (or very near zero), or moving them behind the camera, instead.
Definition at line 101 of file rigidBodyCombiner.cxx.
References SceneGraphReducer::apply_attribs(), SceneGraphReducer::collect_vertex_data(), PandaNode::Children::get_child(), PandaNode::get_children(), PandaNode::Children::get_num_children(), and SceneGraphReducer::unify().
bool RigidBodyCombiner::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [virtual] |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
Note that this function will *not* be called unless set_cull_callback() is called in the constructor of the derived class. It is necessary to call set_cull_callback() to indicated that we require cull_callback() to be called.
By the time this function is called, the node has already passed the bounding-volume test for the viewing frustum, and the node's transform and state have already been applied to the indicated CullTraverserData object.
The return value is true if this node should be visible, or false if it should be culled.
Reimplemented from PandaNode.
Definition at line 162 of file rigidBodyCombiner.cxx.
References Thread::get_current_thread(), and CullTraverser::traverse().
Returns a special NodePath that represents the internal node of this object.
This is the node that is actually sent to the graphics card for rendering; it contains the collection of the children of this node into as few Geoms as possible.
This node is filled up by the last call to collect().
Definition at line 132 of file rigidBodyCombiner.cxx.
PandaNode * RigidBodyCombiner::make_copy | ( | ) | const [protected, virtual] |
Returns a newly-allocated PandaNode that is a shallow copy of this one.
It will be a different pointer, but its internal data may or may not be shared with that of the original PandaNode. No children will be copied.
Reimplemented from PandaNode.
Definition at line 72 of file rigidBodyCombiner.cxx.