Panda3D
collisionHandlerPhysical.I
1 // Filename: collisionHandlerPhysical.I
2 // Created by: drose (16Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: CollisionHandlerPhysical::set_center
18 // Access: Published
19 // Description: Specifies an arbitrary NodePath that the handler is
20 // always considered to be facing. It does not detect
21 // collisions with surfaces that appear to be facing
22 // away from this NodePath. This works best when the
23 // collision surfaces in question are polygons.
24 ////////////////////////////////////////////////////////////////////
26 set_center(const NodePath &center) {
27  _center = center;
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: CollisionHandlerPhysical::clear_center
32 // Access: Published
33 // Description: Clears the center NodePath specified with set_center.
34 ////////////////////////////////////////////////////////////////////
37  _center = NodePath();
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: CollisionHandlerPhysical::get_center
42 // Access: Published
43 // Description: Returns the NodePath specified with set_center, or
44 // the empty NodePath if nothing has been specified.
45 ////////////////////////////////////////////////////////////////////
47 get_center() const {
48  return _center;
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: CollisionHandlerPhysical::has_center
53 // Access: Published
54 // Description: Returns true if a NodePath has been specified with
55 // set_center(), false otherwise.
56 ////////////////////////////////////////////////////////////////////
58 has_center() const {
59  return !_center.is_empty();
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: CollisionHandlerPhysical::has_contact
64 // Access: Public
65 // Description: Did the handler make any contacts with anything
66 // on the last collision pass? Depending on how your
67 // world is setup, this can be used to tell if the
68 // handler is out of the world (i.e. out of bounds).
69 // That is the original use of this call.
70 ////////////////////////////////////////////////////////////////////
72 has_contact() const {
73  return _has_contact;
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: CollisionHandlerPhysical::ColliderDef::set_target
78 // Access: Public
79 // Description:
80 ////////////////////////////////////////////////////////////////////
81 INLINE void CollisionHandlerPhysical::ColliderDef::
82 set_target(const NodePath &target, DriveInterface *drive_interface) {
83  _target = target;
84  _drive_interface = drive_interface;
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: CollisionHandlerPhysical::ColliderDef::updated_transform
89 // Access: Public
90 // Description: Called by the handler when it has changed the
91 // transform on the target node, this applies the change
92 // to the drive interface if one is specified.
93 ////////////////////////////////////////////////////////////////////
94 INLINE void CollisionHandlerPhysical::ColliderDef::
95 updated_transform() {
96  if (_drive_interface != (DriveInterface *)NULL) {
97  _drive_interface->set_mat(_target.get_mat());
98  _drive_interface->force_dgraph();
99  }
100 }
bool has_contact() const
Did the handler make any contacts with anything on the last collision pass? Depending on how your wor...
This is a TFormer, similar to Trackball, that moves around a transform matrix in response to mouse in...
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:236
const NodePath & get_center() const
Returns the NodePath specified with set_center, or the empty NodePath if nothing has been specified...
void clear_center()
Clears the center NodePath specified with set_center.
bool has_center() const
Returns true if a NodePath has been specified with set_center(), false otherwise. ...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
void set_center(const NodePath &center)
Specifies an arbitrary NodePath that the handler is always considered to be facing.