15 #include "collisionNode.h"
16 #include "config_collide.h"
19 #include "cullTraverserData.h"
20 #include "cullTraverser.h"
21 #include "renderState.h"
22 #include "transformState.h"
23 #include "colorScaleAttrib.h"
24 #include "transparencyAttrib.h"
26 #include "datagramIterator.h"
27 #include "bamReader.h"
28 #include "bamWriter.h"
29 #include "clockObject.h"
30 #include "boundingSphere.h"
31 #include "boundingBox.h"
32 #include "config_mathutil.h"
43 CollisionNode(
const string &name) :
45 _from_collide_mask(get_default_collide_mask()),
51 set_overall_hidden(
true);
54 set_into_collide_mask(get_default_collide_mask());
65 _from_collide_mask(copy._from_collide_mask),
120 for (si = _solids.begin(); si != _solids.end(); ++si) {
144 if (flatten_collision_nodes) {
151 if (get_name() == cother->get_name() &&
155 const COWPT(
CollisionSolid) *solids_end = solids_begin + cother->_solids.size();
156 _solids.insert(_solids.end(), solids_begin, solids_end);
214 Solids::const_iterator si;
215 for (si = _solids.begin(); si != _solids.end(); ++si) {
217 PT(
PandaNode) node = solid->get_viz(trav, data,
false);
223 next_data._state = RenderState::make_empty();
228 if (respect_prev_transform) {
232 CPT(TransformState) transform = node_path.get_net_transform()->invert_compose(node_path.get_net_prev_transform());
234 if (!transform->is_identity()) {
238 for (si = _solids.begin(); si != _solids.end(); ++si) {
240 PT(
PandaNode) node = solid->get_viz(trav, data,
false);
244 next_data._net_transform =
245 next_data._net_transform->compose(transform);
246 next_data._state = get_last_pos_state();
298 PandaNode::output(out);
299 out <<
" (" << _solids.size() <<
" solids)";
313 _from_collide_mask = mask;
326 int &internal_vertices,
328 Thread *current_thread)
const {
333 Solids::const_iterator gi;
334 for (gi = _solids.begin(); gi != _solids.end(); ++gi) {
338 if (!volume->is_empty()) {
339 child_volumes_ref.push_back(volume);
340 child_volumes.push_back(volume);
341 if (!volume->is_exact_type(BoundingBox::get_class_type())) {
354 if (btype == BoundingVolume::BT_box ||
355 (btype != BoundingVolume::BT_sphere && all_box)) {
364 if (child_volumes.size() > 0) {
366 const BoundingVolume **child_end = child_begin + child_volumes.size();
370 internal_bounds = gbv;
371 internal_vertices = 0;
383 get_last_pos_state() {
388 state = RenderState::make
389 (ColorScaleAttrib::make(
LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)),
390 TransparencyAttrib::make(TransparencyAttrib::M_alpha));
418 int num_solids = _solids.size();
419 if (num_solids >= 0xffff) {
425 for(
int i = 0; i < num_solids; i++) {
443 int num_solids = _solids.size();
444 for (
int i = 0; i < num_solids; i++) {
465 parse_params(params, scan, manager);
466 node->fillin(scan, manager);
480 PandaNode::fillin(scan, manager);
483 if (num_solids == 0xffff) {
487 _solids.reserve(num_solids);
488 for(
int i = 0; i < num_solids; i++) {
static const LMatrix4f & ident_mat()
Returns an identity matrix.
A basic node of the scene graph or data graph.
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static BitMask< WType, nbits > all_on()
Returns a BitMask whose bits are all on.
The abstract base class for all things that can collide with other things in the world, and all the things they can collide with (except geometry).
This defines a bounding sphere, consisting of a center and a radius.
Base class for objects that can be written to and read from Bam files.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PN_uint32 get_uint32()
Extracts an unsigned 32-bit integer.
void set_word(WordType value)
Sets the entire BitMask to the value indicated by the given word.
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
void traverse(const NodePath &root)
Begins the traversal from the indicated node.
This is our own Panda specialization on the default STL vector.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
BoundingVolume::BoundsType get_bounds_type() const
Returns the bounding volume type set with set_bounds_type().
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
virtual bool is_collision_node() const
A simple downcast check.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
void mark_internal_bounds_stale(Thread *current_thread=Thread::get_current_thread())
Should be called by a derived class to mark the internal bounding volume stale, so that compute_inter...
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
NodePath get_node_path() const
Constructs and returns an actual NodePath that represents the same path we have just traversed...
This is a 4-by-4 transform matrix.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual bool preserve_name() const
Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operatio...
virtual CollideMask get_legal_collide_mask() const
Returns the subset of CollideMask bits that may be set for this particular type of PandaNode...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
This is the base class for all three-component vectors and points.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
virtual void output(ostream &out) const
Writes a brief description of the node to the indicated output stream.
A thread; that is, a lightweight process.
void add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer to the datagram.
A node in the scene graph that can hold any number of CollisionSolids.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionNode.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
bool almost_equal(const LMatrix4f &other, float threshold) const
Returns true if two matrices are memberwise equal within a specified tolerance.
A class to retrieve the individual data elements previously stored in a Datagram. ...
WordType get_word() const
Returns the entire BitMask as a single word.
CollideMask get_into_collide_mask() const
Returns the current "into" CollideMask.
TypeHandle is the identifier used to differentiate C++ class types.
CollideMask get_from_collide_mask() const
Returns the current "from" CollideMask.
virtual PandaNode * combine_with(PandaNode *other)
Collapses this node with the other node, if possible, and returns a pointer to the combined node...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
void set_from_collide_mask(CollideMask mask)
Sets the "from" CollideMask.
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
bool is_nan() const
Returns true if any component of the matrix is not-a-number, false otherwise.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this node by the indicated matrix, if it means anything to do so...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
void read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.