Panda3D
Loading...
Searching...
No Matches
rigidBodyCombiner.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file rigidBodyCombiner.h
10 * @author drose
11 * @date 2007-02-22
12 */
13
14#ifndef RIGIDBODYCOMBINER_H
15#define RIGIDBODYCOMBINER_H
16
17#include "pandabase.h"
18
19#include "pandaNode.h"
20#include "nodeVertexTransform.h"
21#include "pvector.h"
22
23class NodePath;
24
25/**
26 * This is a special node that combines multiple independently-moving rigid
27 * nodes into one Geom internally (or as few Geoms as possible), for the
28 * purposes of improving rendering performance.
29 *
30 * To use it, parent a number of moving objects to this node and call
31 * collect(). A child node is identified as "moving" if (a) it has a non-
32 * identity transform initially, or (b) it is a ModelNode with the
33 * preserve_transform flag set. Any other nodes will be considered static,
34 * and later transforms applied to them will not be identified.
35 *
36 * You should call collect() only at startup or if you change the set of
37 * children; it is a relatively expensive call.
38 *
39 * Once you call collect(), you may change the transforms on the child nodes
40 * freely without having to call collect() again.
41 *
42 * RenderEffects such as Billboards are not supported below this node.
43 */
44class EXPCL_PANDA_GRUTIL RigidBodyCombiner : public PandaNode {
45PUBLISHED:
46 explicit RigidBodyCombiner(const std::string &name);
47protected:
49 virtual PandaNode *make_copy() const;
50
51PUBLISHED:
52 void collect();
53
54 NodePath get_internal_scene();
55 MAKE_PROPERTY(internal_scene, get_internal_scene);
56
57public:
58 // From parent class PandaNode
59 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
60
61private:
62 void r_collect(PandaNode *node, const RenderState *state,
63 const VertexTransform *transform);
64 PT(GeomVertexData) convert_vd(const VertexTransform *transform,
65 const GeomVertexData *orig);
66
67 PT(PandaNode) _internal_root;
68
70 Transforms _internal_transforms;
71
72 class VDUnifier {
73 public:
74 INLINE VDUnifier(const VertexTransform *transform,
75 const GeomVertexData *orig);
76 INLINE bool operator < (const VDUnifier &other) const;
77
78 const VertexTransform *_transform;
79 const GeomVertexData *_orig;
80 };
81
82 typedef pmap<VDUnifier, PT(GeomVertexData) > VDTable;
83 VDTable _vd_table;
84
85
86public:
87 static TypeHandle get_class_type() {
88 return _type_handle;
89 }
90 static void init_type() {
91 PandaNode::init_type();
92 register_type(_type_handle, "RigidBodyCombiner",
93 PandaNode::get_class_type());
94 }
95 virtual TypeHandle get_type() const {
96 return get_class_type();
97 }
98 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
99
100private:
101 static TypeHandle _type_handle;
102};
103
104#include "rigidBodyCombiner.I"
105
106#endif
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
This VertexTransform gets its matrix from the Transform stored on a node.
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
This is a special node that combines multiple independently-moving rigid nodes into one Geom internal...
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
This is an abstract base class that holds a pointer to some transform, computed in some arbitrary way...
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.