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() ||
196 (node->
is_of_type(ModelNode::get_class_type()) &&
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) {
213 geom->set_vertex_data(convert_vd(next_transform, geom->get_vertex_data()));
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 =
new GeomVertexArrayFormat();
248 af->add_column(InternalName::get_transform_blend(), 1,
249 Geom::NT_uint16, Geom::C_index, 0, 2);
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);
268 new_data->set_transform_blend_table(new_table);
275 _vd_table[VDUnifier(transform, orig)] = new_data;
const RenderState * get_geom_state(int n) const
Returns the RenderState associated with the nth geom of the node.
int get_num_children() const
Returns the number of children of the node.
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...
This is a special node that combines multiple independently-moving rigid nodes into one Geom internal...
An interface for simplifying ("flattening") scene graphs by eliminating unneeded nodes and collapsing...
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
int get_num_geoms() const
Returns the number of geoms in the node.
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.
void set_panda()
Specifies that vertex animation is to be performed by Panda.
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
void unify(PandaNode *root, bool preserve_order)
Calls unify() on every GeomNode at this level and below.
const GeomVertexFormat * get_format() const
Returns a pointer to the GeomVertexFormat structure that defines this data.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
static SparseArray range(int low_bit, int size)
Returns a SparseArray whose size bits, beginning at low_bit, are on.
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...
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.
A thread; that is, a lightweight process.
This is a special kind of GeometricBoundingVolume that fills all of space.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
PandaNode * get_child(int n) const
Returns the nth child of the node.
TypeHandle is the identifier used to differentiate C++ class types.
virtual bool is_geom_node() const
A simple downcast check.
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.
void add_geom(Geom *geom, const RenderState *state=RenderState::make_empty())
Adds a new Geom to the node.