Panda3D
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
CollisionHandlerPhysical Class Reference

The abstract base class for a number of CollisionHandlers that have some physical effect on their moving bodies: they need to update the nodes' positions based on the effects of the collision. More...

#include "collisionHandlerPhysical.h"

Inheritance diagram for CollisionHandlerPhysical:
CollisionHandlerEvent CollisionHandler TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase CollisionHandlerFloor CollisionHandlerGravity CollisionHandlerPusher CollisionHandlerFluidPusher PhysicsCollisionHandler

List of all members.

Classes

class  ColliderDef

Public Member Functions

void add_collider (const NodePath &collider, const NodePath &target)
 Adds a new collider to the list with a NodePath that will be updated with the collider's new position, or updates the existing collider with a new NodePath object.
void add_collider (const NodePath &collider, const NodePath &target, DriveInterface *drive_interface)
 Adds a new collider to the list with a NodePath that will be updated with the collider's new position, or updates the existing collider with a new NodePath object.
virtual void add_entry (CollisionEntry *entry)
 Called between a begin_group() .
virtual void begin_group ()
 Will be called by the CollisionTraverser before a new traversal is begun.
void clear_center ()
 Clears the center NodePath specified with set_center.
void clear_colliders ()
 Completely empties the list of colliders this handler knows about.
virtual bool end_group ()
 Called by the CollisionTraverser at the completion of all collision detections for this traversal.
virtual TypeHandle force_init_type ()
const NodePathget_center () const
 Returns the NodePath specified with set_center, or the empty NodePath if nothing has been specified.
virtual TypeHandle get_type () const
bool has_center () const
 Returns true if a NodePath has been specified with set_center(), false otherwise.
bool has_collider (const NodePath &collider) const
 Returns true if the handler knows about the indicated collider, false otherwise.
bool has_contact () const
 Did the handler make any contacts with anything on the last collision pass? Depending on how your world is setup, this can be used to tell if the handler is out of the world (i.e.
bool remove_collider (const NodePath &collider)
 Removes the collider from the list of colliders that this handler knows about.
void set_center (const NodePath &center)
 Specifies an arbitrary NodePath that the handler is always considered to be facing.

Static Public Member Functions

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.

Protected Types

typedef pmap< NodePath,
ColliderDef
Colliders
typedef pvector< PT(CollisionEntry) > Entries
typedef pmap< NodePath, Entries > FromEntries

Protected Member Functions

virtual void apply_linear_force (ColliderDef &def, const LVector3 &force)=0
virtual bool handle_entries ()=0
virtual bool validate_target (const NodePath &target)
 Called internally to validate the target passed to add_collider().

Protected Attributes

NodePath _center
Colliders _colliders
FromEntries _from_entries
bool _has_contact

Detailed Description

The abstract base class for a number of CollisionHandlers that have some physical effect on their moving bodies: they need to update the nodes' positions based on the effects of the collision.

Definition at line 34 of file collisionHandlerPhysical.h.


Member Function Documentation

void CollisionHandlerPhysical::add_collider ( const NodePath collider,
const NodePath target 
)

Adds a new collider to the list with a NodePath that will be updated with the collider's new position, or updates the existing collider with a new NodePath object.

Definition at line 115 of file collisionHandlerPhysical.cxx.

References PandaNode::is_collision_node(), NodePath::is_empty(), NodePath::node(), and validate_target().

void CollisionHandlerPhysical::add_collider ( const NodePath collider,
const NodePath target,
DriveInterface drive_interface 
)

Adds a new collider to the list with a NodePath that will be updated with the collider's new position, or updates the existing collider with a new NodePath object.

The indicated DriveInterface will also be updated with the target's new transform each frame. This method should be used when the target is directly controlled by a DriveInterface.

Definition at line 135 of file collisionHandlerPhysical.cxx.

References PandaNode::is_collision_node(), NodePath::is_empty(), NodePath::node(), and validate_target().

Will be called by the CollisionTraverser before a new traversal is begun.

It instructs the handler to reset itself in preparation for a number of CollisionEntries to be sent.

Reimplemented from CollisionHandlerEvent.

Definition at line 51 of file collisionHandlerPhysical.cxx.

Clears the center NodePath specified with set_center.

Definition at line 36 of file collisionHandlerPhysical.I.

Completely empties the list of colliders this handler knows about.

Definition at line 177 of file collisionHandlerPhysical.cxx.

Called by the CollisionTraverser at the completion of all collision detections for this traversal.

It should do whatever finalization is required for the handler.

Reimplemented from CollisionHandlerEvent.

Definition at line 99 of file collisionHandlerPhysical.cxx.

const NodePath & CollisionHandlerPhysical::get_center ( ) const [inline]

Returns the NodePath specified with set_center, or the empty NodePath if nothing has been specified.

Definition at line 47 of file collisionHandlerPhysical.I.

bool CollisionHandlerPhysical::has_center ( ) const [inline]

Returns true if a NodePath has been specified with set_center(), false otherwise.

Definition at line 58 of file collisionHandlerPhysical.I.

References NodePath::is_empty().

Referenced by add_entry().

bool CollisionHandlerPhysical::has_collider ( const NodePath collider) const

Returns true if the handler knows about the indicated collider, false otherwise.

Definition at line 165 of file collisionHandlerPhysical.cxx.

bool CollisionHandlerPhysical::has_contact ( ) const [inline]

Did the handler make any contacts with anything on the last collision pass? Depending on how your world is setup, this can be used to tell if the handler is out of the world (i.e.

out of bounds). That is the original use of this call.

Definition at line 72 of file collisionHandlerPhysical.I.

static void CollisionHandlerPhysical::init_type ( ) [inline, static]

This function is declared non-inline to work around a compiler bug in g++ 2.96.

Making it inline seems to cause problems in the optimizer.

Reimplemented from CollisionHandlerEvent.

Reimplemented in CollisionHandlerGravity, PhysicsCollisionHandler, CollisionHandlerFloor, CollisionHandlerPusher, and CollisionHandlerFluidPusher.

Definition at line 90 of file collisionHandlerPhysical.h.

References CollisionHandlerEvent::init_type().

Referenced by CollisionHandlerPusher::init_type(), CollisionHandlerFloor::init_type(), and CollisionHandlerGravity::init_type().

Removes the collider from the list of colliders that this handler knows about.

Definition at line 149 of file collisionHandlerPhysical.cxx.

void CollisionHandlerPhysical::set_center ( const NodePath center) [inline]

Specifies an arbitrary NodePath that the handler is always considered to be facing.

It does not detect collisions with surfaces that appear to be facing away from this NodePath. This works best when the collision surfaces in question are polygons.

Definition at line 26 of file collisionHandlerPhysical.I.

bool CollisionHandlerPhysical::validate_target ( const NodePath target) [protected, virtual]

Called internally to validate the target passed to add_collider().

Returns true if acceptable, false otherwise.

Reimplemented in PhysicsCollisionHandler.

Definition at line 189 of file collisionHandlerPhysical.cxx.

References NodePath::is_empty().

Referenced by add_collider(), and PhysicsCollisionHandler::validate_target().


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