Panda3D
|
A specialized kind of CollisionHandler that sets the Z height of the collider to a fixed linear offset from the highest detected collision point each frame. More...
#include "collisionHandlerGravity.h"
Public Member Functions | |
void | add_velocity (PN_stdfloat velocity) |
Adds the sepcified amount to the current velocity. More... | |
virtual TypeHandle | force_init_type () |
PN_stdfloat | get_airborne_height () const |
Return the height of the object from the ground. More... | |
const LVector3 & | get_contact_normal () const |
PN_stdfloat | get_gravity () const |
Gets the linear gravity force (always plumb). More... | |
PN_stdfloat | get_impact_velocity () const |
How hard did the object hit the ground. More... | |
bool | get_legacy_mode () const |
returns true if legacy mode is enabled More... | |
PN_stdfloat | get_max_velocity () const |
Retrieves the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second. More... | |
PN_stdfloat | get_offset () const |
Returns the linear offset to add to (or subtract from) the highest detected collision point to determine the actual height at which to set the collider. More... | |
PN_stdfloat | get_reach () const |
Returns the reach to add to (or subtract from) the highest collision point. More... | |
virtual TypeHandle | get_type () const |
PN_stdfloat | get_velocity () const |
Gets the current vertical velocity. More... | |
bool | is_on_ground () const |
Is the object at rest? More... | |
void | set_gravity (PN_stdfloat gravity) |
Sets the linear gravity force (always plumb). More... | |
void | set_legacy_mode (bool legacy_mode) |
Enables old behavior required by Toontown (Sellbot Factory lava room is good test case, lava and conveyor belt specifically). More... | |
void | set_max_velocity (PN_stdfloat max_vel) |
Sets the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second. More... | |
void | set_offset (PN_stdfloat offset) |
Sets the linear offset to add to (or subtract from) the highest detected collision point to determine the actual height at which to set the collider. More... | |
void | set_reach (PN_stdfloat reach) |
Sets the reach to add to (or subtract from) the highest collision point. More... | |
void | set_velocity (PN_stdfloat velocity) |
Sets the current vertical velocity. More... | |
![]() | |
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. More... | |
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. More... | |
virtual void | add_entry (CollisionEntry *entry) |
Called between a begin_group() . More... | |
virtual void | begin_group () |
Will be called by the CollisionTraverser before a new traversal is begun. More... | |
void | clear_center () |
Clears the center NodePath specified with set_center. More... | |
void | clear_colliders () |
Completely empties the list of colliders this handler knows about. More... | |
virtual bool | end_group () |
Called by the CollisionTraverser at the completion of all collision detections for this traversal. More... | |
const NodePath & | get_center () const |
Returns the NodePath specified with set_center, or the empty NodePath if nothing has been specified. More... | |
bool | has_center () const |
Returns true if a NodePath has been specified with set_center(), false otherwise. More... | |
bool | has_collider (const NodePath &collider) const |
Returns true if the handler knows about the indicated collider, false otherwise. More... | |
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. More... | |
bool | remove_collider (const NodePath &collider) |
Removes the collider from the list of colliders that this handler knows about. More... | |
void | set_center (const NodePath ¢er) |
Specifies an arbitrary NodePath that the handler is always considered to be facing. More... | |
![]() | |
CollisionHandlerEvent () | |
The default CollisionHandlerEvent will throw no events. More... | |
void | add_again_pattern (const string &again_pattern) |
Adds the pattern string that indicates how the event names are generated when a collision between two particular nodes is *still* detected. More... | |
void | add_in_pattern (const string &in_pattern) |
Adds a pattern string to the list of events that will be generated in response to a collision. More... | |
void | add_out_pattern (const string &out_pattern) |
Adds the pattern string that indicates how the event names are generated when a collision between two particular nodes is *no longer* detected. More... | |
void | clear () |
Empties the list of elements that all colliders are known to be colliding with. More... | |
void | clear_again_patterns () |
Removes all of the previously-added in patterns. More... | |
void | clear_in_patterns () |
Removes all of the previously-added in patterns. More... | |
void | clear_out_patterns () |
Removes all of the previously-added in patterns. More... | |
void | flush () |
Same as clear() except "out" events are thrown. More... | |
string | get_again_pattern (int n) const |
Returns the nth pattern string that indicates how the event names are generated for each collision detected. More... | |
string | get_in_pattern (int n) const |
Returns the nth pattern string that indicates how the event names are generated for each collision detected. More... | |
int | get_num_again_patterns () const |
Returns the number of in pattern strings that have been added. More... | |
int | get_num_in_patterns () const |
Returns the number of in pattern strings that have been added. More... | |
int | get_num_out_patterns () const |
Returns the number of in pattern strings that have been added. More... | |
string | get_out_pattern (int n) const |
Returns the nth pattern string that indicates how the event names are generated for each collision detected. More... | |
MAKE_SEQ (get_in_patterns, get_num_in_patterns, get_in_pattern) | |
MAKE_SEQ (get_again_patterns, get_num_again_patterns, get_again_pattern) | |
MAKE_SEQ (get_out_patterns, get_num_out_patterns, get_out_pattern) | |
void | set_again_pattern (const string &again_pattern) |
This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. More... | |
void | set_in_pattern (const string &in_pattern) |
This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. More... | |
void | set_out_pattern (const string &out_pattern) |
This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. More... | |
![]() | |
void | set_root (const NodePath &root) |
Sets the root of the collision traversal. More... | |
bool | wants_all_potential_collidees () const |
Returns true if handler wants to know about all solids that are within the collider's bounding volume. More... | |
![]() | |
TypedReferenceCount (const TypedReferenceCount ©) | |
void | operator= (const TypedReferenceCount ©) |
![]() | |
TypedObject (const TypedObject ©) | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_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 ©) |
![]() | |
int | get_ref_count () const |
Returns the current reference count. More... | |
WeakReferenceList * | get_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 TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
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 TypeHandle | get_class_type () |
static void | init_type () |
A specialized kind of CollisionHandler that sets the Z height of the collider to a fixed linear offset from the highest detected collision point each frame.
It's intended to implement walking around on a floor of varying height by casting a ray down from the avatar's head.
Definition at line 31 of file collisionHandlerGravity.h.
|
inline |
Adds the sepcified amount to the current velocity.
This is mostly here allow this common operation to be faster for scripting, but it's also more concise even in cpp.
Definition at line 125 of file collisionHandlerGravity.I.
References set_velocity().
Referenced by get_impact_velocity().
|
inline |
Return the height of the object from the ground.
The object might not necessarily be at rest. Use is_on_ground() if you want to know whether the object is on the ground and at rest.
See Also: is_in_outer_space()
Definition at line 74 of file collisionHandlerGravity.I.
References is_on_ground().
Referenced by get_reach(), and is_on_ground().
|
inline |
Gets the linear gravity force (always plumb).
Definition at line 175 of file collisionHandlerGravity.I.
References set_max_velocity().
Referenced by set_gravity().
|
inline |
How hard did the object hit the ground.
This value is set on impact with the ground. You may want to watch (poll) on is_on_groun() and when that is true, call get_impact_velocity(). Normally I avoid polling, but we are calling is_on_ground() frequently anyway.
Definition at line 102 of file collisionHandlerGravity.I.
References add_velocity().
Referenced by is_on_ground().
|
inline |
returns true if legacy mode is enabled
Definition at line 224 of file collisionHandlerGravity.I.
Referenced by set_legacy_mode().
|
inline |
Retrieves the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second.
See set_max_velocity().
Definition at line 200 of file collisionHandlerGravity.I.
References set_legacy_mode().
Referenced by set_max_velocity().
|
inline |
Returns the linear offset to add to (or subtract from) the highest detected collision point to determine the actual height at which to set the collider.
Definition at line 36 of file collisionHandlerGravity.I.
References set_reach().
Referenced by set_offset().
|
inline |
Returns the reach to add to (or subtract from) the highest collision point.
Definition at line 58 of file collisionHandlerGravity.I.
References get_airborne_height().
Referenced by set_reach().
|
inline |
Gets the current vertical velocity.
Generally, negative values mean the object is in free fall; while postive values mean the object has vertical thrust.
A zero value does not necessarily mean the object on the ground, it may also be weightless and/or at the apex of its jump.
See Also: is_on_ground() and get_gravity()
Definition at line 155 of file collisionHandlerGravity.I.
References set_gravity().
Referenced by set_velocity().
|
inline |
Is the object at rest?
Definition at line 84 of file collisionHandlerGravity.I.
References get_airborne_height(), and get_impact_velocity().
Referenced by get_airborne_height().
|
inline |
Sets the linear gravity force (always plumb).
Definition at line 165 of file collisionHandlerGravity.I.
References get_gravity().
Referenced by get_velocity().
|
inline |
Enables old behavior required by Toontown (Sellbot Factory lava room is good test case, lava and conveyor belt specifically).
Behavior is to throw enter/exit events only for floor that the toon is in contact with
Definition at line 214 of file collisionHandlerGravity.I.
References get_legacy_mode().
Referenced by get_max_velocity().
|
inline |
Sets the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second.
Set this to zero to allow it to instantly teleport any distance.
Definition at line 188 of file collisionHandlerGravity.I.
References get_max_velocity().
Referenced by get_gravity().
|
inline |
Sets the linear offset to add to (or subtract from) the highest detected collision point to determine the actual height at which to set the collider.
Definition at line 24 of file collisionHandlerGravity.I.
References get_offset().
|
inline |
Sets the reach to add to (or subtract from) the highest collision point.
Definition at line 47 of file collisionHandlerGravity.I.
References get_reach().
Referenced by get_offset().
|
inline |
Sets the current vertical velocity.
Definition at line 135 of file collisionHandlerGravity.I.
References get_velocity().
Referenced by add_velocity().