Panda3D
Public Member Functions | Static Public Member Functions | Friends | List of all members
CollisionEntry Class Reference

Defines a single collision event. More...

#include "collisionEntry.h"

Inheritance diagram for CollisionEntry:
TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

Public Member Functions

 CollisionEntry (const CollisionEntry &copy)
 
bool collided () const
 returns true if this represents an actual collision as opposed to a potential collision, needed for iterative collision resolution where path of collider changes mid-frame More...
 
 CPT (TransformState) get_wrt_space() const
 
 CPT (TransformState) get_inv_wrt_space() const
 
 CPT (TransformState) get_wrt_prev_space() const
 
virtual TypeHandle force_init_type ()
 
bool get_all (const NodePath &space, LPoint3 &surface_point, LVector3 &surface_normal, LPoint3 &interior_point) const
 Simultaneously transforms the surface point, surface normal, and interior point of the collision into the indicated coordinate space. More...
 
bool get_all_contact_info (const NodePath &space, LPoint3 &contact_pos, LVector3 &contact_normal) const
 Simultaneously transforms the contact position and contact normal of the collision into the indicated coordinate space. More...
 
LVector3 get_contact_normal (const NodePath &space) const
 Returns the surface normal of the "into" object at the contact position. More...
 
LPoint3 get_contact_pos (const NodePath &space) const
 Returns the position of the "from" object at the instant that a collision is first detected. More...
 
const CollisionSolidget_from () const
 Returns the CollisionSolid pointer for the particular solid that triggered this collision. More...
 
CollisionNodeget_from_node () const
 Returns the node that contains the CollisionSolid that triggered this collision. More...
 
NodePath get_from_node_path () const
 Returns the NodePath that represents the CollisionNode that contains the CollisionSolid that triggered this collision. More...
 
LPoint3 get_interior_point (const NodePath &space) const
 Returns the point, within the interior of the "into" object, which represents the depth to which the "from" object has penetrated. More...
 
const CollisionSolidget_into () const
 Returns the CollisionSolid pointer for the particular solid was collided into. More...
 
const ClipPlaneAttribget_into_clip_planes () const
 
PandaNodeget_into_node () const
 Returns the node that contains the CollisionSolid that was collided into. More...
 
NodePath get_into_node_path () const
 Returns the NodePath that represents the specific CollisionNode or GeomNode instance that was collided into. More...
 
const LMatrix4get_inv_wrt_mat () const
 
bool get_respect_prev_transform () const
 Returns true if the collision was detected by a CollisionTraverser whose respect_prev_transform flag was set true, meaning we should consider motion significant in evaluating collisions. More...
 
LVector3 get_surface_normal (const NodePath &space) const
 Returns the surface normal of the "into" object at the point at which a collision is detected. More...
 
LPoint3 get_surface_point (const NodePath &space) const
 Returns the point, on the surface of the "into" object, at which a collision is detected. More...
 
PN_stdfloat get_t () const
 returns time value for this collision relative to other CollisionEntries More...
 
virtual TypeHandle get_type () const
 
const LMatrix4get_wrt_mat () const
 
const LMatrix4get_wrt_prev_mat () const
 
bool has_contact_normal () const
 Returns true if the contact normal has been specified, false otherwise. More...
 
bool has_contact_pos () const
 Returns true if the contact position has been specified, false otherwise. More...
 
bool has_interior_point () const
 Returns true if the interior point has been specified, false otherwise. More...
 
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). More...
 
bool has_surface_normal () const
 Returns true if the surface normal has been specified, false otherwise. More...
 
bool has_surface_point () const
 Returns true if the surface point has been specified, false otherwise. More...
 
void operator= (const CollisionEntry &copy)
 
void output (ostream &out) const
 
void reset_collided ()
 prepare for another collision test More...
 
void set_contact_normal (const LVector3 &normal)
 Stores the surface normal of the "into" object at the contact pos. More...
 
void set_contact_pos (const LPoint3 &pos)
 Stores the position of the "from" object at the instant at which the collision is first detected. More...
 
void set_interior_point (const LPoint3 &point)
 Stores the point, within the interior of the "into" object, which represents the depth to which the "from" object has penetrated. More...
 
void set_surface_normal (const LVector3 &normal)
 Stores the surface normal of the "into" object at the point of the intersection. More...
 
void set_surface_point (const LPoint3 &point)
 Stores the point, on the surface of the "into" object, at which a collision is detected. More...
 
void set_t (PN_stdfloat t)
 Sets a time value for this collision relative to other CollisionEntries. More...
 
void write (ostream &out, int indent_level=0) const
 
- Public Member Functions inherited from TypedWritableReferenceCount
 TypedWritableReferenceCount (const TypedWritableReferenceCount &copy)
 
virtual ReferenceCountas_reference_count ()
 Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More...
 
void operator= (const TypedWritableReferenceCount &copy)
 
- Public Member Functions inherited from TypedWritable
 TypedWritable (const TypedWritable &copy)
 
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(). More...
 
string encode_to_bam_stream () const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. More...
 
bool encode_to_bam_stream (string &data, BamWriter *writer=NULL) const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More...
 
virtual void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is intended to be called by each class's make_from_bam() method to read in all of the relevant data from the BamFile for the new object. More...
 
virtual void finalize (BamReader *manager)
 Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. More...
 
UpdateSeq get_bam_modified () const
 Returns the current bam_modified counter. More...
 
void mark_bam_modified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More...
 
void operator= (const TypedWritable &copy)
 
virtual bool require_fully_complete () const
 Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. More...
 
virtual void update_bam_nested (BamWriter *manager)
 Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. More...
 
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file. More...
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
void operator= (const TypedObject &copy)
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 Returns the current reference count. More...
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
void weak_ref (WeakPointerToVoid *ptv)
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref (WeakPointerToVoid *ptv)
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedWritableReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
static PT (TypedWritableReferenceCount) decode_from_bam_stream(const string &data
 
- Static Public Member Functions inherited from TypedWritable
static bool decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, const string &data, BamReader *reader=NULL)
 Reads the string created by a previous call to encode_to_bam_stream(), and extracts the single object on that string. More...
 
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Friends

class CollisionHandlerFluidPusher
 
class CollisionTraverser
 

Additional Inherited Members

- Public Attributes inherited from TypedWritableReferenceCount
static BamReaderreader = NULL)
 
- Static Public Attributes inherited from TypedWritable
static TypedWritable *const Null = (TypedWritable*)0L
 

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 46 of file collisionEntry.h.

Member Function Documentation

◆ collided()

bool CollisionEntry::collided ( ) const
inline

returns true if this represents an actual collision as opposed to a potential collision, needed for iterative collision resolution where path of collider changes mid-frame

Definition at line 158 of file collisionEntry.I.

References reset_collided().

Referenced by CollisionHandlerFluidPusher::add_entry(), and get_t().

◆ get_all()

bool CollisionEntry::get_all ( const NodePath space,
LPoint3 surface_point,
LVector3 surface_normal,
LPoint3 interior_point 
) const

Simultaneously transforms the surface point, surface normal, and interior point of the collision into the indicated coordinate space.

Returns true if all three properties are available, or false if any one of them is not.

Definition at line 137 of file collisionEntry.cxx.

References get_contact_pos(), LPoint3f::zero(), and LVector3f::zero().

Referenced by get_interior_point().

◆ get_all_contact_info()

bool CollisionEntry::get_all_contact_info ( const NodePath space,
LPoint3 contact_pos,
LVector3 contact_normal 
) const

Simultaneously transforms the contact position and contact normal of the collision into the indicated coordinate space.

Returns true if all three properties are available, or false if any one of them is not.

Definition at line 210 of file collisionEntry.cxx.

References LPoint3f::zero(), and LVector3f::zero().

Referenced by CollisionHandlerFluidPusher::add_entry(), and get_contact_normal().

◆ get_contact_normal()

LVector3 CollisionEntry::get_contact_normal ( const NodePath space) const

Returns the surface normal of the "into" object at the contact position.

The normal will be converted into whichever coordinate space the caller specifies.

Definition at line 193 of file collisionEntry.cxx.

References get_all_contact_info(), and LVector3f::zero().

Referenced by get_contact_pos().

◆ get_contact_pos()

LPoint3 CollisionEntry::get_contact_pos ( const NodePath space) const

Returns the position of the "from" object at the instant that a collision is first detected.

The position will be converted into whichever coordinate space the caller specifies.

Definition at line 177 of file collisionEntry.cxx.

References get_contact_normal(), and LPoint3f::zero().

Referenced by get_all().

◆ get_from()

const CollisionSolid * CollisionEntry::get_from ( ) const
inline

◆ get_from_node()

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 77 of file collisionEntry.I.

References get_into_node().

Referenced by CollisionHandlerEvent::flush(), and get_into().

◆ get_from_node_path()

NodePath CollisionEntry::get_from_node_path ( ) const
inline

◆ get_interior_point()

LPoint3 CollisionEntry::get_interior_point ( const NodePath space) const

Returns the point, within the interior of the "into" object, which represents the depth to which the "from" object has penetrated.

This can also be described as the intersection point on the surface of the "from" object (which is inside the "into" object). It can be thought of as the deepest point of intersection.

The point will be converted into whichever coordinate space the caller specifies.

Definition at line 118 of file collisionEntry.cxx.

References get_all().

Referenced by get_surface_normal().

◆ get_into()

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 64 of file collisionEntry.I.

References get_from_node().

Referenced by CollisionHandlerFluidPusher::add_entry(), CollisionHandlerPhysical::add_entry(), CollisionTraverser::clear_colliders(), CollisionHandlerEvent::flush(), CollisionParabola::get_collision_origin(), has_contact_normal(), has_into(), and CollisionBox::setup_points().

◆ get_into_node()

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 92 of file collisionEntry.I.

References get_from_node_path().

Referenced by CollisionHandlerEvent::flush(), and get_from_node().

◆ get_into_node_path()

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 122 of file collisionEntry.I.

References set_t().

Referenced by CollisionHandlerFluidPusher::add_entry(), CollisionHandlerEvent::add_entry(), CollisionHandlerEvent::flush(), get_from_node_path(), CollisionPlane::get_test_pcollector(), CollisionSphere::get_test_pcollector(), CollisionInvSphere::get_test_pcollector(), CollisionBox::get_test_pcollector(), CollisionTube::get_test_pcollector(), and CollisionPolygon::get_test_pcollector().

◆ get_respect_prev_transform()

bool CollisionEntry::get_respect_prev_transform ( ) const
inline

Returns true if the collision was detected by a CollisionTraverser whose respect_prev_transform flag was set true, meaning we should consider motion significant in evaluating collisions.

Definition at line 181 of file collisionEntry.I.

References set_surface_point().

Referenced by has_contact_normal(), and reset_collided().

◆ get_surface_normal()

LVector3 CollisionEntry::get_surface_normal ( const NodePath space) const

Returns the surface normal of the "into" object at the point at which a collision is detected.

The normal will be converted into whichever coordinate space the caller specifies.

Definition at line 97 of file collisionEntry.cxx.

References get_interior_point(), and LVector3f::zero().

Referenced by CollisionHandlerPhysical::add_entry(), and get_surface_point().

◆ get_surface_point()

LPoint3 CollisionEntry::get_surface_point ( const NodePath space) const

Returns the point, on the surface of the "into" object, at which a collision is detected.

This can be thought of as the first point of intersection. However the contact point is the actual first point of intersection.

The point will be converted into whichever coordinate space the caller specifies.

Definition at line 81 of file collisionEntry.cxx.

References get_surface_normal(), and LPoint3f::zero().

Referenced by CollisionHandlerPhysical::add_entry(), and CollisionHandlerHighestEvent::add_entry().

◆ get_t()

PN_stdfloat CollisionEntry::get_t ( ) const
inline

returns time value for this collision relative to other CollisionEntries

Definition at line 145 of file collisionEntry.I.

References collided().

Referenced by CollisionHandlerFluidPusher::add_entry(), and set_t().

◆ has_contact_normal()

bool CollisionEntry::has_contact_normal ( ) const
inline

Returns true if the contact normal has been specified, false otherwise.

See get_contact_normal(). Some types of collisions may not compute the contact normal.

Definition at line 331 of file collisionEntry.I.

References CollisionHandler::add_entry(), get_from(), get_into(), NodePath::get_prev_transform(), get_respect_prev_transform(), NodePath::get_transform(), and CollisionHandler::wants_all_potential_collidees().

Referenced by has_contact_pos().

◆ has_contact_pos()

bool CollisionEntry::has_contact_pos ( ) const
inline

Returns true if the contact position has been specified, false otherwise.

See get_contact_pos(). Some types of collisions may not compute the contact pos.

Definition at line 318 of file collisionEntry.I.

References has_contact_normal().

Referenced by set_contact_normal().

◆ has_interior_point()

bool CollisionEntry::has_interior_point ( ) const
inline

Returns true if the interior point has been specified, false otherwise.

See get_interior_point(). Some types of collisions may not compute the interior point.

Definition at line 273 of file collisionEntry.I.

References set_contact_pos().

Referenced by has_surface_normal().

◆ has_into()

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 50 of file collisionEntry.I.

References get_into().

Referenced by CollisionHandlerFluidPusher::add_entry(), CollisionHandlerPhysical::add_entry(), CollisionHandlerEvent::flush(), and get_from().

◆ has_surface_normal()

bool CollisionEntry::has_surface_normal ( ) const
inline

Returns true if the surface normal has been specified, false otherwise.

See get_surface_normal(). Some types of collisions may not compute the surface normal.

Definition at line 260 of file collisionEntry.I.

References has_interior_point().

Referenced by CollisionHandlerPhysical::add_entry(), and has_surface_point().

◆ has_surface_point()

bool CollisionEntry::has_surface_point ( ) const
inline

Returns true if the surface point has been specified, false otherwise.

See get_surface_point(). Some types of collisions may not compute the surface point.

Definition at line 247 of file collisionEntry.I.

References has_surface_normal().

Referenced by CollisionHandlerPhysical::add_entry(), and set_interior_point().

◆ reset_collided()

void CollisionEntry::reset_collided ( )
inline

prepare for another collision test

Definition at line 168 of file collisionEntry.I.

References get_respect_prev_transform().

Referenced by CollisionHandlerFluidPusher::add_entry(), and collided().

◆ set_contact_normal()

void CollisionEntry::set_contact_normal ( const LVector3 normal)
inline

Stores the surface normal of the "into" object at the contact pos.

This normal is specified in the coordinate space of the "into" object.

Definition at line 303 of file collisionEntry.I.

References has_contact_pos(), and LVecBase3f::is_nan().

Referenced by set_contact_pos().

◆ set_contact_pos()

void CollisionEntry::set_contact_pos ( const LPoint3 pos)
inline

Stores the position of the "from" object at the instant at which the collision is first detected.

This position is specified in the coordinate space of the "into" object.

Definition at line 287 of file collisionEntry.I.

References LVecBase3f::is_nan(), and set_contact_normal().

Referenced by has_interior_point().

◆ set_interior_point()

void CollisionEntry::set_interior_point ( const LPoint3 point)
inline

Stores the point, within the interior of the "into" object, which represents the depth to which the "from" object has penetrated.

This can also be described as the intersection point on the surface of the "from" object (which is inside the "into" object).

This point is specified in the coordinate space of the "into" object.

Definition at line 232 of file collisionEntry.I.

References has_surface_point(), and LVecBase3f::is_nan().

Referenced by CollisionTube::get_test_pcollector(), and set_surface_normal().

◆ set_surface_normal()

void CollisionEntry::set_surface_normal ( const LVector3 normal)
inline

Stores the surface normal of the "into" object at the point of the intersection.

This normal is specified in the coordinate space of the "into" object.

Definition at line 212 of file collisionEntry.I.

References LVecBase3f::is_nan(), and set_interior_point().

Referenced by CollisionTube::get_test_pcollector(), and set_surface_point().

◆ set_surface_point()

void CollisionEntry::set_surface_point ( const LPoint3 point)
inline

Stores the point, on the surface of the "into" object, at which a collision is detected.

This point is specified in the coordinate space of the "into" object.

Definition at line 196 of file collisionEntry.I.

References LVecBase3f::is_nan(), and set_surface_normal().

Referenced by get_respect_prev_transform(), and CollisionTube::get_test_pcollector().

◆ set_t()

void CollisionEntry::set_t ( PN_stdfloat  t)
inline

Sets a time value for this collision relative to other CollisionEntries.

Definition at line 133 of file collisionEntry.I.

References get_t().

Referenced by get_into_node_path().


The documentation for this class was generated from the following files: