Panda3D
 All Classes Functions Variables Enumerations
bulletClosestHitSweepResult.cxx
1 // Filename: bulletClosestHitSweepResult.cxx
2 // Created by: enn0x (01Dec10)
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 #include "bulletClosestHitSweepResult.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: BulletClosestHitSweepResult::Constructor
19 // Access: Protected
20 // Description:
21 ////////////////////////////////////////////////////////////////////
22 BulletClosestHitSweepResult::
23 BulletClosestHitSweepResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask)
24  : btCollisionWorld::ClosestConvexResultCallback(from_pos, to_pos), _mask(mask) {
25 
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: BulletClosestHitSweepResult::needsCollision
30 // Access: Protected
31 // Description: Override default implementation.
32 ////////////////////////////////////////////////////////////////////
34 needsCollision(btBroadphaseProxy* proxy0) const {
35 
36  btCollisionObject *obj0 = (btCollisionObject *) proxy0->m_clientObject;
37  PandaNode *node0 = (PandaNode *) obj0->getUserPointer();
38  CollideMask mask0 = node0->get_into_collide_mask();
39 
40  return (_mask & mask0) != 0;
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: BulletClosestHitSweepResult::has_hit
45 // Access: Published
46 // Description:
47 ////////////////////////////////////////////////////////////////////
48 bool BulletClosestHitSweepResult::
49 has_hit() const {
50 
51  return hasHit();
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: BulletClosestHitSweepResult::get_hit_fraction
56 // Access: Published
57 // Description:
58 ////////////////////////////////////////////////////////////////////
59 PN_stdfloat BulletClosestHitSweepResult::
60 get_hit_fraction() const {
61 
62  return (PN_stdfloat)m_closestHitFraction;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: BulletClosestHitSweepResult::get_node
67 // Access: Published
68 // Description:
69 ////////////////////////////////////////////////////////////////////
70 const PandaNode *BulletClosestHitSweepResult::
71 get_node() const {
72 
73  const btCollisionObject *objectPtr = m_hitCollisionObject;
74  return (objectPtr) ? (const PandaNode *)objectPtr->getUserPointer() : NULL;
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: BulletClosestHitSweepResult::get_hit_pos
79 // Access: Published
80 // Description:
81 ////////////////////////////////////////////////////////////////////
82 LPoint3 BulletClosestHitSweepResult::
83 get_hit_pos() const {
84 
85  return btVector3_to_LPoint3(m_hitPointWorld);
86 }
87 
88 ////////////////////////////////////////////////////////////////////
89 // Function: BulletClosestHitSweepResult::get_hit_normal
90 // Access: Published
91 // Description:
92 ////////////////////////////////////////////////////////////////////
93 LVector3 BulletClosestHitSweepResult::
94 get_hit_normal() const {
95 
96  return btVector3_to_LVector3(m_hitNormalWorld);
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function: BulletClosestHitSweepResult::get_from_pos
101 // Access: Published
102 // Description:
103 ////////////////////////////////////////////////////////////////////
104 LPoint3 BulletClosestHitSweepResult::
105 get_from_pos() const {
106 
107  return btVector3_to_LPoint3(m_convexFromWorld);
108 }
109 
110 ////////////////////////////////////////////////////////////////////
111 // Function: BulletClosestHitSweepResult::get_to_pos
112 // Access: Published
113 // Description:
114 ////////////////////////////////////////////////////////////////////
115 LPoint3 BulletClosestHitSweepResult::
116 get_to_pos() const {
117 
118  return btVector3_to_LPoint3(m_convexToWorld);
119 }
120 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
Override default implementation.
A general bitmask class.
Definition: bitMask.h:35