# CollisionEntry¶

class CollisionEntry

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.

Inheritance diagram

bool collided(void) 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

bool get_all(NodePath const &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.

bool get_all_contact_info(NodePath const &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.

static TypeHandle get_class_type(void)
LVector3 get_contact_normal(NodePath const &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.

LPoint3 get_contact_pos(NodePath const &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.

CollisionSolid const *get_from(void) const

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

CollisionNode *get_from_node(void) const

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().

NodePath get_from_node_path(void) const

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().

LPoint3 get_interior_point(NodePath const &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.

CollisionSolid const *get_into(void) const

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().

PandaNode *get_into_node(void) const

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().

NodePath get_into_node_path(void) const

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.

bool get_respect_prev_transform(void) 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.

LVector3 get_surface_normal(NodePath const &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.

LPoint3 get_surface_point(NodePath const &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.

PN_stdfloat get_t(void) const

returns time value for this collision relative to other CollisionEntries

bool has_contact_normal(void) const

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.

bool has_contact_pos(void) const

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.

bool has_interior_point(void) const

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.

bool has_into(void) 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). If this returns false, the collision was detected into a GeomNode, and there is no CollisionSolid pointer to be retrieved.

bool has_surface_normal(void) const

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.

bool has_surface_point(void) const

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.

void output(std::ostream &out) const
void reset_collided(void)

prepare for another collision test

void set_contact_normal(LVector3 const &normal)

Stores the surface normal of the “into” object at the contact pos.

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

void set_contact_pos(LPoint3 const &pos)

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.

void set_interior_point(LPoint3 const &point)

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.

void set_surface_normal(LVector3 const &normal)

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.

void set_surface_point(LPoint3 const &point)

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.

void set_t(PN_stdfloat t)

Sets a time value for this collision relative to other CollisionEntries

void write(std::ostream &out, int indent_level = 0) const