| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- // Filename: qpcollisionNode.I
- // Created by: drose (16Mar02)
- //
- ////////////////////////////////////////////////////////////////////
- //
- // PANDA 3D SOFTWARE
- // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
- //
- // All use of this software is subject to the terms of the Panda 3d
- // Software license. You should have received a copy of this license
- // along with this source code; you will also find a current copy of
- // the license at http://www.panda3d.org/license.txt .
- //
- // To contact the maintainers of this program write to
- // [email protected] .
- //
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::set_collide_mask
- // Access: Public
- // Description: Simultaneously sets both the "from" and "into"
- // CollideMask values to the same thing.
- ////////////////////////////////////////////////////////////////////
- INLINE void qpCollisionNode::
- set_collide_mask(CollideMask mask) {
- set_from_collide_mask(mask);
- set_into_collide_mask(mask);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::set_from_collide_mask
- // Access: Public
- // Description: Sets the "from" CollideMask. In order for a
- // collision to be detected from this object into
- // another object, the intersection of this object's
- // "from" mask and the other object's "into" mask must
- // be nonzero.
- ////////////////////////////////////////////////////////////////////
- INLINE void qpCollisionNode::
- set_from_collide_mask(CollideMask mask) {
- _from_collide_mask = mask;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::set_into_collide_mask
- // Access: Public
- // Description: Sets the "into" CollideMask. In order for a
- // collision to be detected from another object into
- // this object, the intersection of the other object's
- // "from" mask and this object's "into" mask must be
- // nonzero.
- ////////////////////////////////////////////////////////////////////
- INLINE void qpCollisionNode::
- set_into_collide_mask(CollideMask mask) {
- _into_collide_mask = mask;
- // We mark the bound stale when this changes, not because the actual
- // bounding volume changes, but rather because we piggyback the
- // computing of the _net_collide_mask on the bounding volume.
- mark_bound_stale();
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::get_from_collide_mask
- // Access: Public
- // Description: Returns the current "from" CollideMask. In order for
- // a collision to be detected from this object into
- // another object, the intersection of this object's
- // "from" mask and the other object's "into" mask must
- // be nonzero.
- ////////////////////////////////////////////////////////////////////
- INLINE CollideMask qpCollisionNode::
- get_from_collide_mask() const {
- return _from_collide_mask;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::get_into_collide_mask
- // Access: Public
- // Description: Returns the current "into" CollideMask. In order for
- // a collision to be detected from another object into
- // this object, the intersection of the other object's
- // "from" mask and this object's "into" mask must be
- // nonzero.
- ////////////////////////////////////////////////////////////////////
- INLINE CollideMask qpCollisionNode::
- get_into_collide_mask() const {
- return _into_collide_mask;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::set_collide_geom
- // Access: Public
- // Description: Sets the state of the "collide geom" flag for this
- // qpCollisionNode. Normally, this is false; when this is
- // set true, the CollisionSolids in this node will test
- // for collisions with actual renderable geometry, in
- // addition to whatever CollisionSolids may be indicated
- // by the from_collide_mask.
- //
- // Setting this to true causes this to test *all*
- // GeomNodes for collisions. It is an all-or-none
- // thing; there is no way to collide with only some
- // GeomNodes, as GeomNodes have no into_collide_mask.
- ////////////////////////////////////////////////////////////////////
- INLINE void qpCollisionNode::
- set_collide_geom(bool flag) {
- _collide_geom = flag;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::get_collide_geom
- // Access: Public
- // Description: Returns the current state of the collide_geom flag.
- // See set_collide_geom().
- ////////////////////////////////////////////////////////////////////
- INLINE bool qpCollisionNode::
- get_collide_geom() const {
- return _collide_geom;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::get_num_solids
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- INLINE int qpCollisionNode::
- get_num_solids() const {
- return _solids.size();
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::get_solid
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- INLINE CollisionSolid *qpCollisionNode::
- get_solid(int n) const {
- nassertr(n >= 0 && n < get_num_solids(), NULL);
- return _solids[n];
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::remove_solid
- // Access: Public
- // Description: Removes the solid with the indicated index. This
- // will shift all subsequent indices down by one.
- ////////////////////////////////////////////////////////////////////
- INLINE void qpCollisionNode::
- remove_solid(int n) {
- nassertv(n >= 0 && n < get_num_solids());
- _solids.erase(_solids.begin() + n);
- mark_bound_stale();
- }
- ////////////////////////////////////////////////////////////////////
- // Function: qpCollisionNode::add_solid
- // Access: Public
- // Description: Adds the indicated solid to the node. Returns the
- // index of the new solid within the node's list of
- // solids.
- ////////////////////////////////////////////////////////////////////
- INLINE int qpCollisionNode::
- add_solid(CollisionSolid *solid) {
- _solids.push_back(solid);
- mark_bound_stale();
- return _solids.size() - 1;
- }
|