Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | 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
 
CollisionNodeget_from_node () const
 
NodePath get_from_node_path () const
 
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
 
const ClipPlaneAttribget_into_clip_planes () const
 
PandaNodeget_into_node () const
 
NodePath get_into_node_path () const
 
const LMatrix4 & get_inv_wrt_mat () const
 
bool get_respect_prev_transform () const
 
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
 
virtual TypeHandle get_type () const
 
const LMatrix4 & get_wrt_mat () const
 
const LMatrix4 & get_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 (std::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)
 
void write (std::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...
 
vector_uchar encode_to_bam_stream () const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More...
 
bool encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) 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)=default
 
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...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
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 ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. 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...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 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(vector_uchar data
 
- Static Public Member Functions inherited from TypedWritable
static bool decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr)
 Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. 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 ()
 

Public Attributes

 get_from
 Returns the CollisionSolid pointer for the particular solid that triggered this collision. More...
 
 get_from_node
 Returns the node that contains the CollisionSolid that triggered this collision. More...
 
 get_from_node_path
 Returns the NodePath that represents the CollisionNode that contains the CollisionSolid that triggered this collision. More...
 
 get_into
 Returns the CollisionSolid pointer for the particular solid was collided into. More...
 
 get_into_node
 Returns the node that contains the CollisionSolid that was collided into. More...
 
 get_into_node_path
 Returns the NodePath that represents the specific CollisionNode or GeomNode instance that was collided into. More...
 
 get_respect_prev_transform
 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...
 
 get_t
 returns time value for this collision relative to other CollisionEntries More...
 
 set_t
 Sets a time value for this collision relative to other CollisionEntries. More...
 
- Public Attributes inherited from TypedWritableReferenceCount
static BamReaderreader = nullptr)
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 

Friends

class CollisionHandlerFluidPusher
 
class CollisionTraverser
 

Additional Inherited Members

- Static Public Attributes inherited from TypedWritable
static TypedWritable *const Null = nullptr
 

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

◆ 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 120 of file collisionEntry.cxx.

References NodePath::get_transform().

◆ 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 185 of file collisionEntry.cxx.

References NodePath::get_transform().

◆ 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 171 of file collisionEntry.cxx.

◆ 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 158 of file collisionEntry.cxx.

◆ 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 104 of file collisionEntry.cxx.

References get_surface_point(), NodePath::get_transform(), and has_interior_point().

◆ 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 87 of file collisionEntry.cxx.

◆ 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 73 of file collisionEntry.cxx.

Referenced by get_interior_point().

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

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

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

Referenced by get_interior_point().

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

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

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

◆ reset_collided()

void CollisionEntry::reset_collided ( )
inline

prepare for another collision test

Definition at line 130 of file collisionEntry.I.

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

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

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

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

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

Member Data Documentation

◆ get_from

const CollisionSolid * CollisionEntry::get_from
inline

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

Definition at line 97 of file collisionEntry.h.

◆ get_from_node

CollisionNode * CollisionEntry::get_from_node
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 99 of file collisionEntry.h.

◆ get_from_node_path

NodePath CollisionEntry::get_from_node_path
inline

Returns the NodePath that represents the CollisionNode that contains the CollisionSolid that triggered this collision.

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

Definition at line 101 of file collisionEntry.h.

◆ get_into

const CollisionSolid * CollisionEntry::get_into
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 98 of file collisionEntry.h.

Referenced by PT().

◆ get_into_node

PandaNode * CollisionEntry::get_into_node
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 100 of file collisionEntry.h.

◆ get_into_node_path

NodePath CollisionEntry::get_into_node_path
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 102 of file collisionEntry.h.

◆ get_respect_prev_transform

bool CollisionEntry::get_respect_prev_transform
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 105 of file collisionEntry.h.

◆ get_t

PN_stdfloat CollisionEntry::get_t
inline

returns time value for this collision relative to other CollisionEntries

Definition at line 104 of file collisionEntry.h.

◆ set_t

void CollisionEntry::set_t
inline

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

Definition at line 104 of file collisionEntry.h.


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