15 #include "rigidBodyCombiner.h"
18 #include "modelNode.h"
19 #include "geomVertexData.h"
20 #include "geomVertexFormat.h"
21 #include "geomVertexArrayFormat.h"
22 #include "geomVertexAnimationSpec.h"
23 #include "sceneGraphReducer.h"
24 #include "omniBoundingVolume.h"
25 #include "cullTraverserData.h"
36 RigidBodyCombiner(
const string &name) :
PandaNode(name) {
47 _internal_root->set_final(
true);
59 _internal_root = copy._internal_root;
60 _internal_transforms = copy._internal_transforms;
103 _internal_root =
new GeomNode(get_name());
104 _internal_transforms.clear();
109 for (
int i = 0; i < num_children; i++) {
110 r_collect(cr.
get_child(i), RenderState::make_empty(), NULL);
117 gr.
collect_vertex_data(_internal_root, ~(SceneGraphReducer::CVD_format | SceneGraphReducer::CVD_name | SceneGraphReducer::CVD_animation_type));
118 gr.
unify(_internal_root,
false);
167 Transforms::iterator ti;
168 for (ti = _internal_transforms.begin();
169 ti != _internal_transforms.end();
171 (*ti)->mark_modified(current_thread);
190 void RigidBodyCombiner::
193 CPT(
RenderState) next_state = state->compose(node->get_state());
195 if (!node->get_transform()->is_identity() ||
197 DCAST(
ModelNode, node)->get_preserve_transform() != ModelNode::PT_none)) {
200 _internal_transforms.push_back(new_transform);
201 next_transform = new_transform.p();
210 for (
int i = 0; i < num_geoms; ++i) {
211 PT(
Geom) geom = gnode->get_geom(i)->make_copy();
213 geom->set_vertex_data(convert_vd(next_transform, geom->get_vertex_data()));
215 CPT(
RenderState) gstate = next_state->compose(gnode->get_geom_state(i));
216 root_gnode->add_geom(geom, gstate);
222 for (
int i = 0; i < num_children; i++) {
223 r_collect(cr.
get_child(i), next_state, next_transform);
240 VDTable::iterator vdti = _vd_table.find(VDUnifier(transform, orig));
241 if (vdti != _vd_table.end()) {
242 return (*vdti).second;
245 PT(GeomVertexFormat) format = new GeomVertexFormat(*orig->get_format());
246 if (!orig->get_format()->has_column(InternalName::get_transform_blend())) {
247 PT(GeomVertexArrayFormat) af =
248 new GeomVertexArrayFormat(InternalName::get_transform_blend(), 1,
250 format->add_array(af);
255 format->set_animation(spec);
256 format->maybe_align_columns_for_animation();
258 CPT(GeomVertexFormat) new_format = GeomVertexFormat::register_format(format);
267 new_table->set_rows(
SparseArray::range(0, new_data->get_num_rows()));
268 new_data->set_transform_blend_table(new_table);
275 _vd_table[VDUnifier(transform, orig)] = new_data;
This class records a set of integers, where each integer is either present or not present in the set...
void collect()
Walks through the entire subgraph of nodes rooted at this node, accumulates all of the RenderAttribs ...
A basic node of the scene graph or data graph.
int collect_vertex_data(PandaNode *root, int collect_bits=~0)
Collects all different GeomVertexData blocks that have compatible formats at this node and below into...
NodePath get_internal_scene()
Returns a special NodePath that represents the internal node of this object.
This object describes how the vertex animation, if any, represented in a GeomVertexData is encoded...
PandaNode * get_child(int n) const
Returns the nth child of the node.
This is a special node that combines multiple independently-moving rigid nodes into one Geom internal...
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
An interface for simplifying ("flattening") scene graphs by eliminating unneeded nodes and collapsing...
This collects together the pieces of data that are accumulated for each node while walking the scene ...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
void traverse(const NodePath &root)
Begins the traversal from the indicated node.
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
int get_num_children() const
Returns the number of children of the node.
void unify(PandaNode *root, bool preserve_order)
Calls unify() on every GeomNode at this level and below.
int get_num_children(Thread *current_thread=Thread::get_current_thread()) const
Returns the number of child nodes this node has.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
Children get_children(Thread *current_thread=Thread::get_current_thread()) const
Returns an object that can be used to walk through the list of children of the node.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
void apply_attribs(PandaNode *node, int attrib_types=~(TT_clip_plane|TT_cull_face|TT_apply_texture_color))
Walks the scene graph, accumulating attribs of the indicated types, applying them to the vertices...
PandaNode * get_child(int n, Thread *current_thread=Thread::get_current_thread()) const
Returns the nth child node of this node.
A thread; that is, a lightweight process.
This is a special kind of GeometricBoundingVolume that fills all of space.
virtual bool is_geom_node() const
A simple downcast check.
TypeHandle is the identifier used to differentiate C++ class types.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
A node that holds Geom objects, renderable pieces of geometry.
int get_num_geoms() const
Returns the number of geoms in the node.