Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions

CollisionNode Class Reference

A node in the scene graph that can hold any number of CollisionSolids. More...

#include "collisionNode.h"

Inheritance diagram for CollisionNode:
PandaNode TypedWritable Namable LinkedListNode ReferenceCount TypedObject MemoryBase MemoryBase MemoryBase

List of all members.

Public Member Functions

 CollisionNode (const string &name)
int add_solid (const CollisionSolid *solid)
 Adds the indicated solid to the node.
void clear_solids ()
 Removes all solids from the node.
virtual PandaNodecombine_with (PandaNode *other)
 Collapses this node with the other node, if possible, and returns a pointer to the combined node, or NULL if the two nodes cannot safely be combined.
virtual int complete_pointers (TypedWritable **plist, BamReader *manager)
 Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
 CPT (CollisionSolid) get_solid(int n) const
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 ()
int get_collider_sort () const
 Returns the collider_sort value that has been set for this particular node.
CollideMask get_from_collide_mask () const
 Returns the current "from" CollideMask.
CollideMask get_into_collide_mask () const
 Returns the current "into" CollideMask.
virtual CollideMask get_legal_collide_mask () const
 Returns the subset of CollideMask bits that may be set for this particular type of PandaNode.
int get_num_solids () const
virtual TypeHandle get_type () const
virtual bool is_collision_node () const
 A simple downcast check.
virtual bool is_renderable () const
 Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise.
virtual PandaNodemake_copy () const
 Returns a newly-allocated Node that is a shallow copy of this one.
 MAKE_SEQ (get_solids, get_num_solids, get_solid)
virtual void output (ostream &out) const
 Writes a brief description of the node to the indicated output stream.
virtual bool preserve_name () const
 Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operation, false otherwise.
 PT (CollisionSolid) modify_solid(int n)
void remove_solid (int n)
 Removes the solid with the indicated index.
void set_collide_mask (CollideMask mask)
 Simultaneously sets both the "from" and "into" CollideMask values to the same thing.
void set_collider_sort (int sort)
 Sets a particular collider_sort value on this node.
void set_from_collide_mask (CollideMask mask)
 Sets the "from" CollideMask.
void set_into_collide_mask (CollideMask mask)
 Sets the "into" CollideMask.
void set_solid (int n, CollisionSolid *solid)
 Replaces the solid with the indicated index.
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual void xform (const LMatrix4 &mat)
 Transforms the contents of this node by the indicated matrix, if it means anything to do so.

Static Public Member Functions

static TypeHandle get_class_type ()
static CollideMask get_default_collide_mask ()
 Returns the default into_collide_mask assigned to new CollisionNodes.
static void init_type ()
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type CollisionNode.

Protected Member Functions

 CollisionNode (const CollisionNode &copy)
virtual void compute_internal_bounds (CPT(BoundingVolume)&internal_bounds, int &internal_vertices, int pipeline_stage, Thread *current_thread) const
 Called when needed to recompute the node's _internal_bound object.
void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new CollisionNode.

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type CollisionNode is encountered in the Bam file.

Detailed Description

A node in the scene graph that can hold any number of CollisionSolids.

This may either represent a bit of static geometry in the scene that things will collide with, or an animated object twirling around in the world and running into things.

Definition at line 33 of file collisionNode.h.


Member Function Documentation

int CollisionNode::add_solid ( const CollisionSolid solid) [inline]

Adds the indicated solid to the node.

Returns the index of the new solid within the node's list of solids.

Definition at line 149 of file collisionNode.I.

References PandaNode::mark_internal_bounds_stale().

void CollisionNode::clear_solids ( ) [inline]

Removes all solids from the node.

Definition at line 78 of file collisionNode.I.

References PandaNode::mark_internal_bounds_stale().

PandaNode * CollisionNode::combine_with ( PandaNode other) [virtual]

Collapses this node with the other node, if possible, and returns a pointer to the combined node, or NULL if the two nodes cannot safely be combined.

The return value may be this, other, or a new node altogether.

This function is called from GraphReducer::flatten(), and need not deal with children; its job is just to decide whether to collapse the two nodes and what the collapsed node should look like.

Reimplemented from PandaNode.

Definition at line 143 of file collisionNode.cxx.

References get_from_collide_mask(), get_into_collide_mask(), TypedObject::is_exact_type(), and PandaNode::mark_internal_bounds_stale().

int CollisionNode::complete_pointers ( TypedWritable **  p_list,
BamReader manager 
) [virtual]

Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().

Returns the number of pointers processed.

Reimplemented from TypedWritable.

Definition at line 440 of file collisionNode.cxx.

void CollisionNode::compute_internal_bounds ( CPT(BoundingVolume)&  internal_bounds,
int &  internal_vertices,
int  pipeline_stage,
Thread current_thread 
) const [protected, virtual]

Called when needed to recompute the node's _internal_bound object.

Nodes that contain anything of substance should redefine this to do the right thing.

Reimplemented from PandaNode.

Definition at line 325 of file collisionNode.cxx.

References BoundingVolume::around(), and PandaNode::get_bounds_type().

bool CollisionNode::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 211 of file collisionNode.cxx.

References WorkingNodePath::get_node_path(), and CullTraverser::traverse().

void CollisionNode::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new CollisionNode.

Reimplemented from PandaNode.

Definition at line 479 of file collisionNode.cxx.

References DatagramIterator::get_uint16(), DatagramIterator::get_uint32(), BamReader::read_pointer(), and BitMask< WType, nbits >::set_word().

Referenced by make_from_bam().

int CollisionNode::get_collider_sort ( ) const [inline]

Returns the collider_sort value that has been set for this particular node.

See set_collider_sort().

Definition at line 162 of file collisionNode.I.

CollideMask CollisionNode::get_default_collide_mask ( ) [inline, static]

Returns the default into_collide_mask assigned to new CollisionNodes.

Definition at line 195 of file collisionNode.I.

CollideMask CollisionNode::get_from_collide_mask ( ) const [inline]

Returns the current "from" CollideMask.

In order for a collision to be detected from this object into another object, the intersection of this object's "from" mask and the other object's "into" mask must be nonzero.

Definition at line 53 of file collisionNode.I.

Referenced by CollisionLevelState< MaskType >::any_in_bounds(), and combine_with().

CollideMask CollisionNode::get_into_collide_mask ( ) const [inline]

Returns the current "into" CollideMask.

In order for a collision to be detected from another object into this object, the intersection of the other object's "from" mask and this object's "into" mask must be nonzero.

Reimplemented from PandaNode.

Definition at line 67 of file collisionNode.I.

Referenced by combine_with().

CollideMask CollisionNode::get_legal_collide_mask ( ) const [virtual]

Returns the subset of CollideMask bits that may be set for this particular type of PandaNode.

For most nodes, this is 0; it doesn't make sense to set a CollideMask for most kinds of nodes.

For nodes that can be collided with, such as GeomNode and CollisionNode, this returns all bits on.

Reimplemented from PandaNode.

Definition at line 181 of file collisionNode.cxx.

References BitMask< WType, nbits >::all_on().

bool CollisionNode::is_collision_node ( ) const [virtual]

A simple downcast check.

Returns true if this kind of node happens to inherit from CollisionNode, false otherwise.

This is provided as a a faster alternative to calling is_of_type(CollisionNode::get_class_type()).

Reimplemented from PandaNode.

Definition at line 283 of file collisionNode.cxx.

bool CollisionNode::is_renderable ( ) const [virtual]

Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise.

This will be used to optimize the result of get_net_draw_show_mask(), so that any subtrees that contain only nodes for which is_renderable() is false need not be visited.

Reimplemented from PandaNode.

Definition at line 268 of file collisionNode.cxx.

PandaNode * CollisionNode::make_copy ( ) const [virtual]

Returns a newly-allocated Node that is a shallow copy of this one.

It will be a different Node pointer, but its internal data may or may not be shared with that of the original Node.

Reimplemented from PandaNode.

Definition at line 88 of file collisionNode.cxx.

TypedWritable * CollisionNode::make_from_bam ( const FactoryParams params) [static, protected]

This function is called by the BamReader's factory when a new object of type CollisionNode is encountered in the Bam file.

It should create the CollisionNode and extract its information from the file.

Reimplemented from PandaNode.

Definition at line 460 of file collisionNode.cxx.

References fillin().

Referenced by register_with_read_factory().

void CollisionNode::output ( ostream &  out) const [virtual]

Writes a brief description of the node to the indicated output stream.

This is invoked by the << operator. It may be overridden in derived classes to include some information relevant to the class.

Reimplemented from PandaNode.

Definition at line 297 of file collisionNode.cxx.

bool CollisionNode::preserve_name ( ) const [virtual]

Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operation, false otherwise.

Reimplemented from PandaNode.

Definition at line 100 of file collisionNode.cxx.

void CollisionNode::register_with_read_factory ( ) [static]

Tells the BamReader how to create objects of type CollisionNode.

Reimplemented from PandaNode.

Definition at line 404 of file collisionNode.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

void CollisionNode::remove_solid ( int  n) [inline]

Removes the solid with the indicated index.

This will shift all subsequent indices down by one.

Definition at line 135 of file collisionNode.I.

References PandaNode::mark_internal_bounds_stale().

void CollisionNode::set_collide_mask ( CollideMask  mask) [inline]

Simultaneously sets both the "from" and "into" CollideMask values to the same thing.

Definition at line 23 of file collisionNode.I.

References set_from_collide_mask(), and set_into_collide_mask().

void CollisionNode::set_collider_sort ( int  sort) [inline]

Sets a particular collider_sort value on this node.

This controls the order in which colliders (that is, "from nodes") are grouped together for the collision traversal.

If there are 32 or fewer colliders added to any particular CollisionTraverser, then this value has no meaning. It is only useful if there are many colliders, which may force the CollisionTraverser to make multiple passes through the data; in that case, it may be a useful optimization to group colliders that have similar bounding volumes together (by giving them similar sort values).

Definition at line 184 of file collisionNode.I.

void CollisionNode::set_from_collide_mask ( CollideMask  mask)

Sets the "from" CollideMask.

In order for a collision to be detected from this object into another object, the intersection of this object's "from" mask and the other object's "into" mask must be nonzero.

Definition at line 312 of file collisionNode.cxx.

Referenced by DeferredNodeProperty::apply_to_node(), and set_collide_mask().

void CollisionNode::set_into_collide_mask ( CollideMask  mask) [inline]

Sets the "into" CollideMask.

In order for a collision to be detected from another object into this object, the intersection of the other object's "from" mask and this object's "into" mask must be nonzero.

Reimplemented from PandaNode.

Definition at line 38 of file collisionNode.I.

Referenced by DeferredNodeProperty::apply_to_node(), and set_collide_mask().

void CollisionNode::set_solid ( int  n,
CollisionSolid solid 
) [inline]

Replaces the solid with the indicated index.

Definition at line 122 of file collisionNode.I.

References PandaNode::mark_internal_bounds_stale().

void CollisionNode::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from PandaNode.

Definition at line 415 of file collisionNode.cxx.

References Datagram::add_uint16(), Datagram::add_uint32(), BitMask< WType, nbits >::get_word(), and BamWriter::write_pointer().

void CollisionNode::xform ( const LMatrix4 mat) [virtual]

Transforms the contents of this node by the indicated matrix, if it means anything to do so.

For most kinds of nodes, this does nothing.

Reimplemented from PandaNode.

Definition at line 112 of file collisionNode.cxx.

References LMatrix4f::almost_equal(), LMatrix4f::ident_mat(), LMatrix4f::is_nan(), and PandaNode::mark_internal_bounds_stale().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations