Panda3D
|
00001 // Filename: bulletClosestHitSweepResult.cxx 00002 // Created by: enn0x (01Dec10) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "bulletClosestHitSweepResult.h" 00016 00017 //////////////////////////////////////////////////////////////////// 00018 // Function: BulletClosestHitSweepResult::Constructor 00019 // Access: Protected 00020 // Description: 00021 //////////////////////////////////////////////////////////////////// 00022 BulletClosestHitSweepResult:: 00023 BulletClosestHitSweepResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask) 00024 : btCollisionWorld::ClosestConvexResultCallback(from_pos, to_pos), _mask(mask) { 00025 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: BulletClosestHitSweepResult::needsCollision 00030 // Access: Protected 00031 // Description: Override default implementation. 00032 //////////////////////////////////////////////////////////////////// 00033 bool BulletClosestHitSweepResult:: 00034 needsCollision(btBroadphaseProxy* proxy0) const { 00035 00036 // Original implementation: 00037 //bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0; 00038 //collides = collides && (m_collisionFilterGroup & proxy0->m_collisionFilterMask); 00039 //return collides; 00040 00041 btCollisionObject *obj0 = (btCollisionObject *) proxy0->m_clientObject; 00042 PandaNode *node0 = (PandaNode *) obj0->getUserPointer(); 00043 CollideMask mask0 = node0->get_into_collide_mask(); 00044 00045 return (_mask & mask0) != 0; 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: BulletClosestHitSweepResult::has_hit 00050 // Access: Published 00051 // Description: 00052 //////////////////////////////////////////////////////////////////// 00053 bool BulletClosestHitSweepResult:: 00054 has_hit() const { 00055 00056 return hasHit(); 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: BulletClosestHitSweepResult::get_hit_fraction 00061 // Access: Published 00062 // Description: 00063 //////////////////////////////////////////////////////////////////// 00064 PN_stdfloat BulletClosestHitSweepResult:: 00065 get_hit_fraction() const { 00066 00067 return (PN_stdfloat)m_closestHitFraction; 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: BulletClosestHitSweepResult::get_node 00072 // Access: Published 00073 // Description: 00074 //////////////////////////////////////////////////////////////////// 00075 PandaNode *BulletClosestHitSweepResult:: 00076 get_node() const { 00077 00078 btCollisionObject *objectPtr = m_hitCollisionObject; 00079 return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : NULL; 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: BulletClosestHitSweepResult::get_hit_pos 00084 // Access: Published 00085 // Description: 00086 //////////////////////////////////////////////////////////////////// 00087 LPoint3 BulletClosestHitSweepResult:: 00088 get_hit_pos() const { 00089 00090 return btVector3_to_LPoint3(m_hitPointWorld); 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: BulletClosestHitSweepResult::get_hit_normal 00095 // Access: Published 00096 // Description: 00097 //////////////////////////////////////////////////////////////////// 00098 LVector3 BulletClosestHitSweepResult:: 00099 get_hit_normal() const { 00100 00101 return btVector3_to_LVector3(m_hitNormalWorld); 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: BulletClosestHitSweepResult::get_from_pos 00106 // Access: Published 00107 // Description: 00108 //////////////////////////////////////////////////////////////////// 00109 LPoint3 BulletClosestHitSweepResult:: 00110 get_from_pos() const { 00111 00112 return btVector3_to_LPoint3(m_convexFromWorld); 00113 } 00114 00115 //////////////////////////////////////////////////////////////////// 00116 // Function: BulletClosestHitSweepResult::get_to_pos 00117 // Access: Published 00118 // Description: 00119 //////////////////////////////////////////////////////////////////// 00120 LPoint3 BulletClosestHitSweepResult:: 00121 get_to_pos() const { 00122 00123 return btVector3_to_LPoint3(m_convexToWorld); 00124 } 00125