Panda3D
|
The abstract base class for all things that can collide with other things in the world, and all the things they can collide with (except geometry). More...
#include "collisionSolid.h"
Public Member Functions | |
CollisionSolid (const CollisionSolid ©) | |
void | clear_effective_normal () |
Removes the normal previously set by set_effective_normal(). | |
CPT (BoundingVolume) get_bounds() const | |
virtual TypeHandle | force_init_type () |
virtual LPoint3 | get_collision_origin () const =0 |
const LVector3 & | get_effective_normal () const |
Returns the normal that was set by set_effective_normal(). | |
bool | get_respect_effective_normal () const |
See set_respect_effective_normal(). | |
virtual PStatCollector & | get_test_pcollector () |
Returns a PStatCollector that is used to count the number of intersection tests made against a solid of this type in a given frame. | |
virtual TypeHandle | get_type () const |
virtual PStatCollector & | get_volume_pcollector () |
Returns a PStatCollector that is used to count the number of bounding volume tests made against a solid of this type in a given frame. | |
bool | has_effective_normal () const |
Returns true if a special normal was set by set_effective_normal(), false otherwise. | |
bool | is_tangible () const |
Returns whether the solid is considered 'tangible' or not. | |
virtual CollisionSolid * | make_copy ()=0 |
virtual void | output (ostream &out) const |
virtual | PT (CollisionEntry) test_intersection(const CollisionEntry &entry) const |
virtual | PT (PandaNode) get_viz(const CullTraverser *trav |
void | set_bounds (const BoundingVolume &bounding_volume) |
Returns the solid's bounding volume. | |
void | set_effective_normal (const LVector3 &effective_normal) |
Records a false normal for this CollisionSolid that will be reported by the collision system with all collisions into it, instead of its actual normal. | |
void | set_respect_effective_normal (bool respect_effective_normal) |
This is only meaningful for CollisionSolids that will be added to a traverser as colliders. | |
void | set_tangible (bool tangible) |
Sets the current state of the 'tangible' flag. | |
virtual void | write (ostream &out, int indent_level=0) const |
virtual void | write_datagram (BamWriter *manager, Datagram &me) |
Function to write the important information in the particular object to a Datagram. | |
virtual void | xform (const LMatrix4 &mat) |
Transforms the solid by the indicated matrix. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Public Attributes | |
virtual const CullTraverserData bool bounds_only | const |
virtual const CullTraverserData & | data |
Protected Member Functions | |
CPT (RenderState) get_solid_viz_state() | |
CPT (RenderState) get_wireframe_viz_state() | |
CPT (RenderState) get_other_viz_state() | |
CPT (RenderState) get_solid_bounds_viz_state() | |
CPT (RenderState) get_wireframe_bounds_viz_state() | |
CPT (RenderState) get_other_bounds_viz_state() | |
bool | do_has_effective_normal () const |
Returns true if a special normal was set by set_effective_normal(), false otherwise. | |
bool | do_is_tangible () const |
Returns whether the solid is considered 'tangible' or not. | |
virtual void | fill_viz_geom () |
Fills the _viz_geom GeomNode up with Geoms suitable for rendering this solid. | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place. | |
void | mark_internal_bounds_stale () |
Should be called by a derived class to mark the internal bounding volume stale, so that recompute_internal_bounds() will be called when the bounding volume is next requested. | |
void | mark_viz_stale () |
Called internally when the visualization may have been compromised by some change to internal state and will need to be recomputed the next time it is rendered. | |
virtual | PT (CopyOnWriteObject) make_cow_copy() |
virtual | PT (BoundingVolume) compute_internal_bounds() const |
virtual | PT (CollisionEntry) test_intersection_from_sphere(const CollisionEntry &entry) const |
virtual | PT (CollisionEntry) test_intersection_from_line(const CollisionEntry &entry) const |
virtual | PT (CollisionEntry) test_intersection_from_ray(const CollisionEntry &entry) const |
virtual | PT (CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const |
virtual | PT (CollisionEntry) test_intersection_from_parabola(const CollisionEntry &entry) const |
virtual | PT (CollisionEntry) test_intersection_from_box(const CollisionEntry &entry) const |
PT (GeomNode) _viz_geom | |
PT (GeomNode) _bounds_viz_geom | |
Static Protected Member Functions | |
static void | report_undefined_from_intersection (TypeHandle from_type) |
Outputs a message the first time an intersection test is attempted that isn't defined, and explains a bit about what it means. | |
static void | report_undefined_intersection_test (TypeHandle from_type, TypeHandle into_type) |
Outputs a message the first time an intersection test is attempted that isn't defined, and explains a bit about what it means. | |
Friends | |
class | CollisionBox |
class | CollisionHandlerFluidPusher |
class | CollisionLine |
class | CollisionParabola |
class | CollisionRay |
class | CollisionSegment |
class | CollisionSphere |
The abstract base class for all things that can collide with other things in the world, and all the things they can collide with (except geometry).
This class and its derivatives really work very similarly to the way BoundingVolume and all of its derivatives work. There's a different subclass for each basic shape of solid, and double-dispatch function calls handle the subset of the N*N intersection tests that we care about.
Definition at line 50 of file collisionSolid.h.
void CollisionSolid::clear_effective_normal | ( | ) | [inline] |
Removes the normal previously set by set_effective_normal().
Definition at line 78 of file collisionSolid.I.
bool CollisionSolid::do_has_effective_normal | ( | ) | const [inline, protected] |
Returns true if a special normal was set by set_effective_normal(), false otherwise.
Assumes the lock is already held.
Definition at line 161 of file collisionSolid.I.
Referenced by get_effective_normal(), and has_effective_normal().
bool CollisionSolid::do_is_tangible | ( | ) | const [inline, protected] |
Returns whether the solid is considered 'tangible' or not.
Assumes the lock is already held.
Definition at line 149 of file collisionSolid.I.
Referenced by is_tangible().
void CollisionSolid::fill_viz_geom | ( | ) | [protected, virtual] |
Fills the _viz_geom GeomNode up with Geoms suitable for rendering this solid.
Reimplemented in CollisionPolygon, CollisionFloorMesh, CollisionBox, CollisionTube, CollisionSphere, CollisionPlane, CollisionSegment, CollisionParabola, CollisionRay, CollisionInvSphere, and CollisionLine.
Definition at line 430 of file collisionSolid.cxx.
void CollisionSolid::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place.
Reimplemented from TypedWritable.
Reimplemented in CollisionBox, CollisionPolygon, CollisionTube, CollisionSphere, CollisionFloorMesh, CollisionPlane, CollisionParabola, CollisionSegment, CollisionRay, CollisionInvSphere, and CollisionLine.
Definition at line 411 of file collisionSolid.cxx.
References DatagramIterator::get_uint8(), and LVecBase3f::read_datagram().
const LVector3 & CollisionSolid::get_effective_normal | ( | ) | const [inline] |
Returns the normal that was set by set_effective_normal().
It is an error to call this unless has_effective_normal() returns true.
Definition at line 103 of file collisionSolid.I.
References do_has_effective_normal(), and LVector3f::zero().
bool CollisionSolid::get_respect_effective_normal | ( | ) | const [inline] |
See set_respect_effective_normal().
Definition at line 137 of file collisionSolid.I.
PStatCollector & CollisionSolid::get_test_pcollector | ( | ) | [virtual] |
Returns a PStatCollector that is used to count the number of intersection tests made against a solid of this type in a given frame.
Reimplemented in CollisionPolygon, CollisionFloorMesh, CollisionParabola, CollisionBox, CollisionTube, CollisionInvSphere, CollisionSphere, CollisionPlane, and CollisionGeom.
Definition at line 195 of file collisionSolid.cxx.
PStatCollector & CollisionSolid::get_volume_pcollector | ( | ) | [virtual] |
Returns a PStatCollector that is used to count the number of bounding volume tests made against a solid of this type in a given frame.
Reimplemented in CollisionPolygon, CollisionFloorMesh, CollisionParabola, CollisionBox, CollisionTube, CollisionInvSphere, CollisionSphere, CollisionPlane, and CollisionGeom.
Definition at line 183 of file collisionSolid.cxx.
bool CollisionSolid::has_effective_normal | ( | ) | const [inline] |
Returns true if a special normal was set by set_effective_normal(), false otherwise.
Definition at line 90 of file collisionSolid.I.
References do_has_effective_normal().
bool CollisionSolid::is_tangible | ( | ) | const [inline] |
Returns whether the solid is considered 'tangible' or not.
An intangible solid has no effect in a CollisionHandlerPusher (except to throw an event); it's useful for defining 'trigger' planes and spheres, that cause an effect when passed through.
Definition at line 47 of file collisionSolid.I.
References do_is_tangible().
Referenced by CollisionHandlerFluidPusher::add_entry(), CollisionHandlerPhysical::add_entry(), and CollisionHandlerEvent::throw_event_pattern().
void CollisionSolid::mark_internal_bounds_stale | ( | ) | [inline, protected] |
Should be called by a derived class to mark the internal bounding volume stale, so that recompute_internal_bounds() will be called when the bounding volume is next requested.
Definition at line 174 of file collisionSolid.I.
Referenced by CollisionRay::set_from_lens(), CollisionSegment::set_from_lens(), CollisionParabola::set_parabola(), CollisionParabola::set_t1(), CollisionParabola::set_t2(), CollisionSphere::xform(), CollisionBox::xform(), and CollisionParabola::xform().
void CollisionSolid::mark_viz_stale | ( | ) | [inline, protected] |
Called internally when the visualization may have been compromised by some change to internal state and will need to be recomputed the next time it is rendered.
Definition at line 188 of file collisionSolid.I.
Referenced by CollisionRay::set_from_lens(), CollisionSegment::set_from_lens(), CollisionParabola::set_parabola(), CollisionParabola::set_t1(), CollisionParabola::set_t2(), CollisionSphere::xform(), CollisionBox::xform(), and CollisionParabola::xform().
void CollisionSolid::report_undefined_from_intersection | ( | TypeHandle | from_type | ) | [static, protected] |
Outputs a message the first time an intersection test is attempted that isn't defined, and explains a bit about what it means.
Definition at line 368 of file collisionSolid.cxx.
void CollisionSolid::report_undefined_intersection_test | ( | TypeHandle | from_type, |
TypeHandle | into_type | ||
) | [static, protected] |
Outputs a message the first time an intersection test is attempted that isn't defined, and explains a bit about what it means.
Definition at line 340 of file collisionSolid.cxx.
void CollisionSolid::set_bounds | ( | const BoundingVolume & | bounding_volume | ) |
Returns the solid's bounding volume.
Definition at line 108 of file collisionSolid.cxx.
void CollisionSolid::set_effective_normal | ( | const LVector3 & | effective_normal | ) | [inline] |
Records a false normal for this CollisionSolid that will be reported by the collision system with all collisions into it, instead of its actual normal.
This is useful as a workaround for the problem of an avatar wanting to stand on a sloping ground; by storing a false normal, the ground appears to be perfectly level, and the avatar does not tend to slide down it.
Definition at line 65 of file collisionSolid.I.
void CollisionSolid::set_respect_effective_normal | ( | bool | respect_effective_normal | ) | [inline] |
This is only meaningful for CollisionSolids that will be added to a traverser as colliders.
It is normally true, but if set false, it means that this particular solid does not care about the "effective" normal of other solids it meets, but rather always uses the true normal.
Definition at line 120 of file collisionSolid.I.
void CollisionSolid::set_tangible | ( | bool | tangible | ) | [inline] |
Sets the current state of the 'tangible' flag.
Set this true to make the solid tangible, so that a CollisionHandlerPusher will not allow another object to intersect it, or false to make it intangible, so that a CollisionHandlerPusher will ignore it except to throw an event.
Definition at line 27 of file collisionSolid.I.
void CollisionSolid::write_datagram | ( | BamWriter * | manager, |
Datagram & | me | ||
) | [virtual] |
Function to write the important information in the particular object to a Datagram.
Reimplemented from TypedWritable.
Reimplemented in CollisionBox, CollisionPolygon, CollisionTube, CollisionFloorMesh, CollisionSphere, CollisionPlane, CollisionParabola, CollisionSegment, CollisionRay, CollisionInvSphere, and CollisionLine.
Definition at line 392 of file collisionSolid.cxx.
References Datagram::add_uint8(), and LVecBase3f::write_datagram().
void CollisionSolid::xform | ( | const LMatrix4 & | mat | ) | [virtual] |
Transforms the solid by the indicated matrix.
Reimplemented in CollisionFloorMesh, CollisionPolygon, CollisionSegment, CollisionParabola, CollisionRay, CollisionBox, CollisionTube, CollisionSphere, and CollisionPlane.
Definition at line 135 of file collisionSolid.cxx.
References LVecBase3f::normalize().