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...
Public Member Functions | |
CollisionHandlerGravity () | |
addAgainPattern (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. | |
addCollider (NodePath const collider, NodePath const 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. | |
addCollider (NodePath const collider, NodePath const 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. | |
addInPattern (string in_pattern) | |
Adds a pattern string to the list of events that will be generated in response to a collision. | |
addOutPattern (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. | |
addVelocity (float velocity) | |
Adds the sepcified amount to the current velocity. | |
clear () | |
Empties the list of elements that all colliders are known to be colliding with. | |
clearAgainPatterns () | |
Removes all of the previously-added in patterns. | |
clearCenter () | |
Clears the center NodePath specified with set_center. | |
clearColliders () | |
Completely empties the list of colliders this handler knows about. | |
clearInPatterns () | |
Removes all of the previously-added in patterns. | |
clearOutPatterns () | |
Removes all of the previously-added in patterns. | |
flush () | |
Same as clear() except "out" events are thrown. | |
string | getAgainPattern (int n) |
Returns the nth pattern string that indicates how the event names are generated for each collision detected. | |
list | getAgainPatterns () |
float | getAirborneHeight () |
Return the height of the object from the ground. | |
NodePath const | getCenter () |
Returns the NodePath specified with set_center, or the empty NodePath if nothing has been specified. | |
Vec3 const | getContactNormal () |
float | getGravity () |
Gets the linear gravity force (always plumb). | |
float | getImpactVelocity () |
How hard did the object hit the ground. | |
string | getInPattern (int n) |
Returns the nth pattern string that indicates how the event names are generated for each collision detected. | |
list | getInPatterns () |
bool | getLegacyMode () |
returns true if legacy mode is enabled | |
float | getMaxVelocity () |
Retrieves the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second. | |
int | getNumAgainPatterns () |
Returns the number of in pattern strings that have been added. | |
int | getNumInPatterns () |
Returns the number of in pattern strings that have been added. | |
int | getNumOutPatterns () |
Returns the number of in pattern strings that have been added. | |
float | getOffset () |
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. | |
string | getOutPattern (int n) |
Returns the nth pattern string that indicates how the event names are generated for each collision detected. | |
list | getOutPatterns () |
float | getReach () |
Returns the reach to add to (or subtract from) the highest collision point. | |
int | getRefCount () |
Returns the current reference count. | |
TypeHandle | getType () |
int | getTypeIndex () |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
float | getVelocity () |
Gets the current vertical velocity. | |
bool | hasCenter () |
Returns true if a NodePath has been specified with set_center(), false otherwise. | |
bool | hasCollider (NodePath const collider) |
Returns true if the handler knows about the indicated collider, false otherwise. | |
bool | hasContact () |
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 | isExactType (TypeHandle handle) |
Returns true if the current object is the indicated type exactly. | |
bool | isOfType (TypeHandle handle) |
Returns true if the current object is or derives from the indicated type. | |
bool | isOnGround () |
Is the object at rest? | |
ref () | |
Explicitly increments the reference count. | |
bool | removeCollider (NodePath const collider) |
Removes the collider from the list of colliders that this handler knows about. | |
setAgainPattern (string again_pattern) | |
This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. | |
setCenter (NodePath const center) | |
Specifies an arbitrary NodePath that the handler is always considered to be facing. | |
setGravity (float gravity) | |
Sets the linear gravity force (always plumb). | |
setInPattern (string in_pattern) | |
This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. | |
setLegacyMode (bool legacy_mode) | |
Enables old behavior required by Toontown (Sellbot Factory lava room is good test case, lava and conveyor belt specifically). | |
setMaxVelocity (float max_vel) | |
Sets the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second. | |
setOffset (float 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. | |
setOutPattern (string out_pattern) | |
This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. | |
setReach (float reach) | |
Sets the reach to add to (or subtract from) the highest collision point. | |
setVelocity (float velocity) | |
Sets the current vertical velocity. | |
bool | testRefCountIntegrity () |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | testRefCountNonzero () |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
bool | unref () |
Explicitly decrements the reference count. | |
Static Public Member Functions | |
static TypeHandle | getClassType () |
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.
addAgainPattern | ( | string | again_pattern | ) | [inherited] |
Adds the pattern string that indicates how the event names are generated when a collision between two particular nodes is *still* detected.
This event is thrown each consecutive time a collision between two particular nodes is detected, starting with the second time.
In general, the in_pattern event is thrown on the first detection of a collision between two particular nodes. In subsequent passes, as long as a collision between those two nodes continues to be detected each frame, the again_pattern is thrown. The first frame in which the collision is no longer detected, the out_pattern event is thrown.
addCollider | ( | NodePath const | collider, |
NodePath const | target, | ||
DriveInterface | drive_interface | ||
) | [inherited] |
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.
addInPattern | ( | string | in_pattern | ) | [inherited] |
Adds a pattern string to the list of events that will be generated in response to a collision.
The pattern string describes how the event name will be composed. It is a string that may contain any of the following:
fn - the name of the "from" object's node in - the name of the "into" object's node fs - 't' if "from" is tangible, 'i' if intangible is - 't' if "into" is tangible, 'i' if intangible ig - 'c' if the collision is into a CollisionNode, 'g' if it is a geom.
%(tag)fh - generate event only if "from" node has the indicated net tag. %(tag)fx - generate event only if "from" node does not have the indicated net tag. %(tag)ih - generate event only if "into" node has the indicated net tag. %(tag)ix - generate event only if "into" node does not have the indicated net tag. %(tag)ft - the indicated net tag value of the "from" node. %(tag)it - the indicated net tag value of the "into" node.
Parentheses in the above are literal and should be included in the actual pattern.
The event name will be based on the in_pattern string specified here, with all occurrences of the above strings replaced with the corresponding values.
In general, the in_pattern event is thrown on the first detection of a collision between two particular nodes. In subsequent passes, as long as a collision between those two nodes continues to be detected each frame, the again_pattern is thrown. The first frame in which the collision is no longer detected, the out_pattern event is thrown.
addOutPattern | ( | string | out_pattern | ) | [inherited] |
Adds the pattern string that indicates how the event names are generated when a collision between two particular nodes is *no longer* detected.
In general, the in_pattern event is thrown on the first detection of a collision between two particular nodes. In subsequent passes, as long as a collision between those two nodes continues to be detected each frame, the again_pattern is thrown. The first frame in which the collision is no longer detected, the out_pattern event is thrown.
addVelocity | ( | float | velocity | ) |
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.
clear | ( | ) | [inherited] |
Empties the list of elements that all colliders are known to be colliding with.
No "out" events will be thrown; if the same collision is detected next frame, a new "in" event will be thrown for each collision.
This can be called each frame to defeat the persistent "in" event mechanism, which prevents the same "in" event from being thrown repeatedly. However, also see add_again_pattern(), which can be used to set the event that is thrown when a collision is detected for two or more consecutive frames.
clearAgainPatterns | ( | ) | [inherited] |
Removes all of the previously-added in patterns.
See add_again_pattern.
clearCenter | ( | ) | [inherited] |
Clears the center NodePath specified with set_center.
clearColliders | ( | ) | [inherited] |
Completely empties the list of colliders this handler knows about.
clearInPatterns | ( | ) | [inherited] |
Removes all of the previously-added in patterns.
See add_in_pattern.
clearOutPatterns | ( | ) | [inherited] |
Removes all of the previously-added in patterns.
See add_out_pattern.
flush | ( | ) | [inherited] |
Same as clear() except "out" events are thrown.
string getAgainPattern | ( | int | n | ) | [inherited] |
Returns the nth pattern string that indicates how the event names are generated for each collision detected.
See add_again_pattern().
list getAgainPatterns | ( | ) | [inherited] |
float getAirborneHeight | ( | ) |
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()
NodePath const getCenter | ( | ) | [inherited] |
static TypeHandle getClassType | ( | ) | [static] |
Reimplemented from CollisionHandlerPhysical.
Vec3 const getContactNormal | ( | ) |
float getGravity | ( | ) |
Gets the linear gravity force (always plumb).
float getImpactVelocity | ( | ) |
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.
string getInPattern | ( | int | n | ) | [inherited] |
Returns the nth pattern string that indicates how the event names are generated for each collision detected.
See add_in_pattern().
list getInPatterns | ( | ) | [inherited] |
bool getLegacyMode | ( | ) |
returns true if legacy mode is enabled
float getMaxVelocity | ( | ) |
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().
int getNumAgainPatterns | ( | ) | [inherited] |
Returns the number of in pattern strings that have been added.
int getNumInPatterns | ( | ) | [inherited] |
Returns the number of in pattern strings that have been added.
int getNumOutPatterns | ( | ) | [inherited] |
Returns the number of in pattern strings that have been added.
float getOffset | ( | ) |
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.
string getOutPattern | ( | int | n | ) | [inherited] |
Returns the nth pattern string that indicates how the event names are generated for each collision detected.
See add_out_pattern().
list getOutPatterns | ( | ) | [inherited] |
float getReach | ( | ) |
Returns the reach to add to (or subtract from) the highest collision point.
int getRefCount | ( | ) | [inherited] |
Returns the current reference count.
TypeHandle getType | ( | ) | [inherited] |
Reimplemented in AnimChannelBase.
int getTypeIndex | ( | ) | [inherited] |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
This is equivalent to get_type().get_index().
float getVelocity | ( | ) |
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()
bool hasCenter | ( | ) | [inherited] |
Returns true if a NodePath has been specified with set_center(), false otherwise.
bool hasCollider | ( | NodePath const | collider | ) | [inherited] |
Returns true if the handler knows about the indicated collider, false otherwise.
bool hasContact | ( | ) | [inherited] |
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.
bool isExactType | ( | TypeHandle | handle | ) | [inherited] |
Returns true if the current object is the indicated type exactly.
bool isOfType | ( | TypeHandle | handle | ) | [inherited] |
Returns true if the current object is or derives from the indicated type.
bool isOnGround | ( | ) |
Is the object at rest?
ref | ( | ) | [inherited] |
Explicitly increments the reference count.
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
bool removeCollider | ( | NodePath const | collider | ) | [inherited] |
Removes the collider from the list of colliders that this handler knows about.
setAgainPattern | ( | string | again_pattern | ) | [inherited] |
This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern.
setCenter | ( | NodePath const | center | ) | [inherited] |
setGravity | ( | float | gravity | ) |
Sets the linear gravity force (always plumb).
setInPattern | ( | string | in_pattern | ) | [inherited] |
This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern.
setLegacyMode | ( | bool | legacy_mode | ) |
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
setMaxVelocity | ( | float | max_vel | ) |
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.
setOffset | ( | float | 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.
setOutPattern | ( | string | out_pattern | ) | [inherited] |
This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern.
setReach | ( | float | reach | ) |
Sets the reach to add to (or subtract from) the highest collision point.
setVelocity | ( | float | velocity | ) |
Sets the current vertical velocity.
bool testRefCountIntegrity | ( | ) | [inherited] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.
bool testRefCountNonzero | ( | ) | [inherited] |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
Returns true if ok, false otherwise.
bool unref | ( | ) | [inherited] |
Explicitly decrements the reference count.
Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
The return value is true if the new reference count is nonzero, false if it is zero.
Reimplemented in GeomVertexArrayFormat, and GeomVertexFormat.