Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

CollisionEntry Class Reference

Defines a single collision event. More...

#include <collisionEntry.h>

Inheritance diagram for CollisionEntry:

TypedReferenceCount TypedObject ReferenceCount List of all members.

Public Member Functions

 CollisionEntry ()
 CollisionEntry (const CollisionEntry &copy)
void operator= (const CollisionEntry &copy)
const CollisionSolidget_from () const
 Returns the CollisionSolid pointer for the particular solid that triggered this collision.

bool has_into () const
 Returns true if the "into" solid is, in fact, a CollisionSolid, and its pointer is known (in which case get_into() may be called to retrieve it).

const CollisionSolidget_into () const
 Returns the CollisionSolid pointer for the particular solid was collided into.

CollisionNodeget_from_node () const
 Returns the node that contains the CollisionSolid that triggered this collision.

PandaNodeget_into_node () const
 Returns the node that contains the CollisionSolid that was collided into.

const NodePathget_into_node_path () const
 Returns the NodePath that represents the specific CollisionNode or GeomNode instance that was collided into.

const LMatrix4f & get_from_space () const
 Returns the global coordinate space of the CollisionNode returned by get_from_node(), as of the time of the collision.

const LMatrix4f & get_into_space () const
 Returns the global coordinate space of the CollisionNode or GeomNode returned by get_into_node(), as of the time of the collision.

const LMatrix4f & get_wrt_space () const
const LMatrix4f & get_inv_wrt_space () const
void set_from_velocity (const LVector3f &vel)
 Indicates the velocity associated with the "from" object, in the object's coordinate space.

bool has_from_velocity () const
 Returns true if the "from" object had an indicated velocity, false otherwise.

const LVector3f & get_from_velocity () const
 Returns the instantaneous velocity of the "from" object, in its own coordinate space.

void set_into_intersection_point (const LPoint3f &point)
bool has_into_intersection_point () const
 Returns true if the detected collision knows its intersection point in the coordinate space of the collided-into object, false otherwise.

const LPoint3f & get_into_intersection_point () const
 Returns the intersection point in the coordinate space of the collided-into object.

bool has_from_intersection_point () const
 Returns true if the detected collision knows its intersection point in the coordinate space of the colliding object, false otherwise.

LPoint3f get_from_intersection_point () const
 Returns the intersection point in the coordinate space of the colliding object.

void set_into_surface_normal (const LVector3f &normal)
bool has_into_surface_normal () const
 Returns true if the detected collision knows the surface normal of the collided-into object at the point of the collision, false otherwise.

const LVector3f & get_into_surface_normal () const
 Returns the surface normal of the collided-into object at the point of the collision.

void set_from_surface_normal (const LVector3f &normal)
bool has_from_surface_normal () const
 Returns true if the detected collision knows the surface normal of the collided-into object at the point of the collision, false otherwise.

const LVector3f & get_from_surface_normal () const
 Returns the surface normal of the collided-into object at the point of the collision, in the space of the collided-from object.

void set_into_depth (float depth)
bool has_into_depth () const
 Returns true if the collision entry knows how "deep" the collision was into the collided-into object; that is, how far into the surface of the collided-into object the colliding object has penetrated.

float get_into_depth () const
 Returns how "deep" the collision was into the collided-into object; that is, how far into the surface of the collided-into object the colliding object has penetrated.

void set_from_depth (float depth)
bool has_from_depth () const
 Returns true if the collision entry knows how "deep" the collision was from the collided-from object; that is, how far from the surface of the collided-from object the colliding object has penetrated.

float get_from_depth () const
 Returns how "deep" the collision was from the collided-from object; that is, how far from the surface of the collided-from object the colliding object has penetrated.

virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.

bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.

int get_ref_count () const
 Returns the current reference count.

int ref () const
 Explicitly increments the reference count.

int unref () const
 Explicitly decrements the reference count.

void test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.


Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()

Private Types

enum  Flags {
  F_has_into_intersection_point = 0x0001, F_has_into_surface_normal = 0x0002, F_has_from_surface_normal = 0x0004, F_has_into_depth = 0x0008,
  F_has_from_depth = 0x0010, F_has_from_velocity = 0x0020
}

Private Member Functions

void test_intersection (CollisionHandler *record, const CollisionTraverser *trav) const
 This is intended to be called only by the CollisionTraverser.

void compute_from_surface_normal ()
 Computes the "from" surface normal by converting the "into" surface normal into the colliding object's space.


Private Attributes

ConstPointerTo< CollisionSolid_from
ConstPointerTo< CollisionSolid_into
PointerTo< CollisionNode_from_node
PointerTo< PandaNode_into_node
NodePath _into_node_path
LMatrix4f _from_space
LMatrix4f _into_space
LMatrix4f _wrt_space
LMatrix4f _inv_wrt_space
int _flags
LVector3f _from_velocity
LPoint3f _into_intersection_point
LVector3f _into_surface_normal
LVector3f _from_surface_normal
float _into_depth
float _from_depth

Static Private Attributes

TypeHandle _type_handle

Friends

class CollisionTraverser

Detailed Description

Defines a single collision event.

One of these is created for each collision detected by a CollisionTraverser, to be dealt with by the CollisionHandler.

A CollisionEntry provides slots for a number of data values (such as intersection point and normal) that might or might not be known for each collision. It is up to the handler to determine what information is known and to do the right thing with it.

Definition at line 63 of file collisionEntry.h.


Member Enumeration Documentation

enum CollisionEntry::Flags [private]
 

Enumeration values:
F_has_into_intersection_point 
F_has_into_surface_normal 
F_has_from_surface_normal 
F_has_into_depth 
F_has_from_depth 
F_has_from_velocity 

Definition at line 126 of file collisionEntry.h.


Constructor & Destructor Documentation

CollisionEntry::CollisionEntry  )  [inline]
 

Definition at line 31 of file collisionEntry.I.

References _from, and INLINE.

CollisionEntry::CollisionEntry const CollisionEntry &  copy  ) 
 

Definition at line 34 of file collisionEntry.cxx.


Member Function Documentation

void CollisionEntry::compute_from_surface_normal  )  [private]
 

Computes the "from" surface normal by converting the "into" surface normal into the colliding object's space.

Definition at line 88 of file collisionEntry.cxx.

virtual TypeHandle CollisionEntry::force_init_type void   )  [inline, virtual]
 

Reimplemented from TypedReferenceCount.

Definition at line 156 of file collisionEntry.h.

TypeHandle CollisionEntry::get_class_type void   )  [inline, static]
 

Reimplemented from TypedReferenceCount.

Definition at line 145 of file collisionEntry.h.

const CollisionSolid * CollisionEntry::get_from  )  const [inline]
 

Returns the CollisionSolid pointer for the particular solid that triggered this collision.

Definition at line 46 of file collisionEntry.I.

References _into, INLINE, and NULL.

Referenced by set_from_surface_normal(), and CollisionPolygon::test_intersection_from_ray().

float CollisionEntry::get_from_depth  )  const [inline]
 

Returns how "deep" the collision was from the collided-from object; that is, how far from the surface of the collided-from object the colliding object has penetrated.

It is an error to call this if has_from_depth() returns false.

Definition at line 567 of file collisionEntry.I.

LPoint3f CollisionEntry::get_from_intersection_point  )  const [inline]
 

Returns the intersection point in the coordinate space of the colliding object.

It is an error to call this if has_from_intersection_point() returns false.

Definition at line 356 of file collisionEntry.I.

References _flags, F_has_into_depth, and INLINE.

CollisionNode * CollisionEntry::get_from_node  )  const [inline]
 

Returns the node that contains the CollisionSolid that triggered this collision.

This will be a node that has been added to a CollisionTraverser via add_collider().

Definition at line 109 of file collisionEntry.I.

Referenced by CollisionHandlerEvent::begin_group(), CollisionTraverser::compare_collider_to_node(), and CollisionPolygon::test_intersection_from_ray().

const LMatrix4f & CollisionEntry::get_from_space  )  const [inline]
 

Returns the global coordinate space of the CollisionNode returned by get_from_node(), as of the time of the collision.

This will be equivalent to a wrt() from the node to render.

Definition at line 128 of file collisionEntry.I.

References _into_space, and INLINE.

const LVector3f & CollisionEntry::get_from_surface_normal  )  const [inline]
 

Returns the surface normal of the collided-into object at the point of the collision, in the space of the collided-from object.

It is an error to call this if has_from_surface_normal() returns false.

Definition at line 455 of file collisionEntry.I.

const LVector3f & CollisionEntry::get_from_velocity  )  const [inline]
 

Returns the instantaneous velocity of the "from" object, in its own coordinate space.

This represents the delta between its current position and its position last frame.

Definition at line 267 of file collisionEntry.I.

References _flags, _into_surface_normal, and F_has_into_surface_normal.

const CollisionSolid * CollisionEntry::get_into  )  const [inline]
 

Returns the CollisionSolid pointer for the particular solid was collided into.

This pointer might be NULL if the collision was into a piece of visible geometry, instead of a normal CollisionSolid collision; see has_into().

Definition at line 90 of file collisionEntry.I.

References _from_space, and INLINE.

Referenced by CollisionSphere::make_copy(), CollisionSegment::make_copy(), and CollisionRay::make_copy().

float CollisionEntry::get_into_depth  )  const [inline]
 

Returns how "deep" the collision was into the collided-into object; that is, how far into the surface of the collided-into object the colliding object has penetrated.

It is an error to call this if has_into_depth() returns false.

Definition at line 513 of file collisionEntry.I.

const LPoint3f & CollisionEntry::get_into_intersection_point  )  const [inline]
 

Returns the intersection point in the coordinate space of the collided-into object.

It is an error to call this if has_into_intersection_point() returns false.

Definition at line 317 of file collisionEntry.I.

References _flags, F_has_from_surface_normal, and F_has_into_surface_normal.

Referenced by has_from_velocity().

PandaNode * CollisionEntry::get_into_node  )  const [inline]
 

Returns the node that contains the CollisionSolid that was collided into.

This returns a PandaNode pointer instead of something more specific, because it might be either a CollisionNode or a GeomNode.

Also see get_into_node_path().

Definition at line 151 of file collisionEntry.I.

References _inv_wrt_space, and INLINE.

Referenced by CollisionHandlerEvent::begin_group().

const NodePath & CollisionEntry::get_into_node_path  )  const [inline]
 

Returns the NodePath that represents the specific CollisionNode or GeomNode instance that was collided into.

This is the same node returned by get_into_node(), represented as a NodePath; however, it may be more useful because the NodePath can resolve the particular instance of the node, if there is more than one.

Definition at line 176 of file collisionEntry.I.

References _flags, F_has_from_velocity, and INLINE.

Referenced by CollisionPolygon::test_intersection_from_ray().

const LMatrix4f & CollisionEntry::get_into_space  )  const [inline]
 

Returns the global coordinate space of the CollisionNode or GeomNode returned by get_into_node(), as of the time of the collision.

Definition at line 193 of file collisionEntry.I.

References _from_velocity.

const LVector3f & CollisionEntry::get_into_surface_normal  )  const [inline]
 

Returns the surface normal of the collided-into object at the point of the collision.

It is an error to call this if has_into_surface_normal() returns false.

Definition at line 405 of file collisionEntry.I.

References _from_depth, has_from_depth(), INLINE, and nassertr.

const LMatrix4f & CollisionEntry::get_inv_wrt_space  )  const [inline]
 

Definition at line 217 of file collisionEntry.I.

Referenced by has_from_velocity().

int ReferenceCount::get_ref_count  )  const [inline, inherited]
 

Returns the current reference count.

Definition at line 183 of file referenceCount.I.

Referenced by RenderState::determine_bin_index(), RenderEffects::determine_show_bounds(), FontPool::ns_garbage_collect(), TexturePool::ns_garbage_collect(), MaterialPool::ns_get_material(), and TexturePool::ns_release_texture().

virtual TypeHandle CollisionEntry::get_type void   )  const [inline, virtual]
 

Reimplemented from TypedReferenceCount.

Definition at line 153 of file collisionEntry.h.

int TypedObject::get_type_index  )  const [inline, inherited]
 

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

Definition at line 71 of file typedObject.I.

References TypeHandle::get_name(), TypedObject::get_type(), and INLINE.

const LMatrix4f & CollisionEntry::get_wrt_space  )  const [inline]
 

Definition at line 205 of file collisionEntry.I.

Referenced by CollisionPolygon::test_intersection_from_ray().

bool CollisionEntry::has_from_depth  )  const [inline]
 

Returns true if the collision entry knows how "deep" the collision was from the collided-from object; that is, how far from the surface of the collided-from object the colliding object has penetrated.

Definition at line 546 of file collisionEntry.I.

Referenced by get_into_surface_normal().

bool CollisionEntry::has_from_intersection_point  )  const [inline]
 

Returns true if the detected collision knows its intersection point in the coordinate space of the colliding object, false otherwise.

Definition at line 335 of file collisionEntry.I.

bool CollisionEntry::has_from_surface_normal  )  const [inline]
 

Returns true if the detected collision knows the surface normal of the collided-into object at the point of the collision, false otherwise.

Definition at line 436 of file collisionEntry.I.

bool CollisionEntry::has_from_velocity  )  const [inline]
 

Returns true if the "from" object had an indicated velocity, false otherwise.

Definition at line 248 of file collisionEntry.I.

References get_into_intersection_point(), get_inv_wrt_space(), and INLINE.

bool CollisionEntry::has_into  )  const [inline]
 

Returns true if the "into" solid is, in fact, a CollisionSolid, and its pointer is known (in which case get_into() may be called to retrieve it).

If this returns false, the collision was detected into a GeomNode, and there is no CollisionSolid pointer to be retrieved.

Definition at line 69 of file collisionEntry.I.

References _from_node, and INLINE.

bool CollisionEntry::has_into_depth  )  const [inline]
 

Returns true if the collision entry knows how "deep" the collision was into the collided-into object; that is, how far into the surface of the collided-into object the colliding object has penetrated.

Definition at line 492 of file collisionEntry.I.

Referenced by set_into_surface_normal().

bool CollisionEntry::has_into_intersection_point  )  const [inline]
 

Returns true if the detected collision knows its intersection point in the coordinate space of the collided-into object, false otherwise.

Definition at line 298 of file collisionEntry.I.

References _flags, _from_surface_normal, F_has_from_surface_normal, and INLINE.

Referenced by set_from_velocity().

bool CollisionEntry::has_into_surface_normal  )  const [inline]
 

Returns true if the detected collision knows the surface normal of the collided-into object at the point of the collision, false otherwise.

Definition at line 386 of file collisionEntry.I.

void CollisionEntry::init_type void   )  [inline, static]
 

Reimplemented from TypedReferenceCount.

Definition at line 148 of file collisionEntry.h.

bool TypedObject::is_exact_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is the indicated type exactly.

Definition at line 101 of file typedObject.I.

Referenced by PT(), and CollisionNode::xform().

bool TypedObject::is_of_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is or derives from the indicated type.

Definition at line 86 of file typedObject.I.

Referenced by EggMaterialCollection::collapse_equivalent_materials(), EggTextureCollection::collapse_equivalent_textures(), DeferredNodeProperty::compose(), AnimBundleMaker::create_s_channel(), CharacterMaker::create_slider(), ProjectionScreen::cull_callback(), DataNode::define_output(), EggNode::determine_draw_order(), CharacterMaker::egg_to_index(), EggGroupUniquifier::EggGroupUniquifier(), EggPoolUniquifier::EggPoolUniquifier(), EggGroupNode::find_textures(), StaticTextFont::get_glyph(), EggMaterialCollection::insert_materials(), EggTextureCollection::insert_textures(), CharacterJoint::make_copy(), PT(), EggGroupNode::r_flatten_transforms(), EggGroupNode::r_transform_vertices(), EggGroupNode::recompute_polygon_normals(), CollisionLevelState::reserve(), PandaFramework::reset_frame_rate(), PandaFramework::set_texture(), EggGroupNode::steal_children(), and DataGraphTraverser::traverse().

void CollisionEntry::operator= const CollisionEntry &  copy  ) 
 

Definition at line 59 of file collisionEntry.cxx.

References _flags, _into_depth, _into_intersection_point, _into_space, _into_surface_normal, _inv_wrt_space, and _wrt_space.

int ReferenceCount::ref  )  const [inline, inherited]
 

Explicitly increments the reference count.

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 225 of file referenceCount.I.

Referenced by ClientDevice::ClientDevice(), EggGroupNode::find_textures(), EggGroupNode::r_apply_texmats(), EggGroupNode::r_flatten_transforms(), and EggGroupNode::reverse_vertex_ordering().

void CollisionEntry::set_from_depth float  depth  )  [inline]
 

Definition at line 526 of file collisionEntry.I.

void CollisionEntry::set_from_surface_normal const LVector3f &  normal  )  [inline]
 

Definition at line 418 of file collisionEntry.I.

References get_from(), INLINE, NULL, PT, and CollisionSolid::test_intersection().

void CollisionEntry::set_from_velocity const LVector3f &  vel  )  [inline]
 

Indicates the velocity associated with the "from" object, in the object's coordinate space.

Definition at line 232 of file collisionEntry.I.

References has_into_intersection_point(), and INLINE.

Referenced by CollisionTraverser::prepare_colliders().

void CollisionEntry::set_into_depth float  depth  )  [inline]
 

Definition at line 472 of file collisionEntry.I.

void CollisionEntry::set_into_intersection_point const LPoint3f &  point  )  [inline]
 

Definition at line 280 of file collisionEntry.I.

References _flags, and F_has_into_surface_normal.

void CollisionEntry::set_into_surface_normal const LVector3f &  normal  )  [inline]
 

Definition at line 368 of file collisionEntry.I.

References _into_depth, has_into_depth(), INLINE, and nassertr.

void CollisionEntry::test_intersection CollisionHandler record,
const CollisionTraverser trav
const [inline, private]
 

This is intended to be called only by the CollisionTraverser.

It requests the CollisionEntry to start the intersection test between the from and into solids stored within it, passing the result (if positive) to the indicated CollisionHandler.

Definition at line 589 of file collisionEntry.I.

Referenced by CollisionTraverser::compare_collider_to_node().

void ReferenceCount::test_ref_count_integrity  )  const [inline, inherited]
 

Does some easy checks to make sure that the reference count isn't completely bogus.

Definition at line 328 of file referenceCount.I.

References INLINE.

Referenced by EggNode::determine_bin(), and ReferenceCount::~ReferenceCount().

int ReferenceCount::unref  )  const [inline, inherited]
 

Explicitly decrements the reference count.

Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete().

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 293 of file referenceCount.I.

References INLINE.

Referenced by RenderState::determine_bin_index(), and RenderEffects::determine_show_bounds().


Friends And Related Function Documentation

friend class CollisionTraverser [friend]
 

Definition at line 161 of file collisionEntry.h.


Member Data Documentation

int CollisionEntry::_flags [private]
 

Definition at line 135 of file collisionEntry.h.

Referenced by get_from_intersection_point(), get_from_velocity(), get_into_intersection_point(), get_into_node_path(), has_into_intersection_point(), operator=(), and set_into_intersection_point().

ConstPointerTo< CollisionSolid > CollisionEntry::_from [private]
 

Definition at line 115 of file collisionEntry.h.

Referenced by CollisionEntry().

float CollisionEntry::_from_depth [private]
 

Definition at line 142 of file collisionEntry.h.

Referenced by get_into_surface_normal().

PointerTo< CollisionNode > CollisionEntry::_from_node [private]
 

Definition at line 118 of file collisionEntry.h.

Referenced by has_into(), and CollisionTraverser::prepare_colliders().

LMatrix4f CollisionEntry::_from_space [private]
 

Definition at line 121 of file collisionEntry.h.

Referenced by get_into().

LVector3f CollisionEntry::_from_surface_normal [private]
 

Definition at line 140 of file collisionEntry.h.

Referenced by has_into_intersection_point().

LVector3f CollisionEntry::_from_velocity [private]
 

Definition at line 137 of file collisionEntry.h.

Referenced by get_into_space().

ConstPointerTo< CollisionSolid > CollisionEntry::_into [private]
 

Definition at line 116 of file collisionEntry.h.

Referenced by get_from().

float CollisionEntry::_into_depth [private]
 

Definition at line 141 of file collisionEntry.h.

Referenced by operator=(), and set_into_surface_normal().

LPoint3f CollisionEntry::_into_intersection_point [private]
 

Definition at line 138 of file collisionEntry.h.

Referenced by operator=().

PointerTo< PandaNode > CollisionEntry::_into_node [private]
 

Definition at line 119 of file collisionEntry.h.

NodePath CollisionEntry::_into_node_path [private]
 

Definition at line 120 of file collisionEntry.h.

LMatrix4f CollisionEntry::_into_space [private]
 

Definition at line 122 of file collisionEntry.h.

Referenced by get_from_space(), and operator=().

LVector3f CollisionEntry::_into_surface_normal [private]
 

Definition at line 139 of file collisionEntry.h.

Referenced by get_from_velocity(), and operator=().

LMatrix4f CollisionEntry::_inv_wrt_space [private]
 

Definition at line 124 of file collisionEntry.h.

Referenced by get_into_node(), and operator=().

TypeHandle CollisionEntry::_type_handle [static, private]
 

Reimplemented from TypedReferenceCount.

Definition at line 24 of file collisionEntry.cxx.

LMatrix4f CollisionEntry::_wrt_space [private]
 

Definition at line 123 of file collisionEntry.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:48:26 2003 for Panda by doxygen1.3