Panda3D
Loading...
Searching...
No Matches
bulletClosestHitRayResult.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file bulletClosestHitRayResult.cxx
10 * @author enn0x
11 * @date 2010-02-21
12 */
13
15
16/**
17 *
18 */
19BulletClosestHitRayResult::
20BulletClosestHitRayResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask)
21 : btCollisionWorld::ClosestRayResultCallback(from_pos, to_pos), _mask(mask) {
22
23 _shapePart = -1;
24 _triangleIndex = -1;
25}
26
27/**
28 * Override default implementation.
29 */
31needsCollision(btBroadphaseProxy* proxy0) const {
32
33 btCollisionObject *obj0 = (btCollisionObject *) proxy0->m_clientObject;
34 PandaNode *node0 = (PandaNode *) obj0->getUserPointer();
35 CollideMask mask0 = node0->get_into_collide_mask();
36
37 return (_mask & mask0) != 0;
38}
39
40/**
41 * Override default implementation.
42 */
44addSingleResult(btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace) {
45
46 // Store partindex information
47 if (rayResult.m_localShapeInfo) {
48 _shapePart = rayResult.m_localShapeInfo->m_shapePart;
49 _triangleIndex = rayResult.m_localShapeInfo->m_triangleIndex;
50 }
51
52 // Call the default implementation
53 return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
54};
55
56/**
57 *
58 */
59bool BulletClosestHitRayResult::
60has_hit() const {
61
62 return hasHit();
63}
64
65/**
66 *
67 */
68PN_stdfloat BulletClosestHitRayResult::
69get_hit_fraction() const {
70
71 return (PN_stdfloat)m_closestHitFraction;
72}
73
74/**
75 *
76 */
77PandaNode *BulletClosestHitRayResult::
78get_node() const {
79
80 const btCollisionObject *objectPtr = m_collisionObject;
81 return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : nullptr;
82}
83
84/**
85 *
86 */
87LPoint3 BulletClosestHitRayResult::
88get_hit_pos() const {
89
90 return btVector3_to_LPoint3(m_hitPointWorld);
91}
92
93/**
94 *
95 */
96LVector3 BulletClosestHitRayResult::
97get_hit_normal() const {
98
99 return btVector3_to_LVector3(m_hitNormalWorld);
100}
101
102/**
103 *
104 */
105LPoint3 BulletClosestHitRayResult::
106get_from_pos() const {
107
108 return btVector3_to_LPoint3(m_rayFromWorld);
109}
110
111/**
112 *
113 */
114LPoint3 BulletClosestHitRayResult::
115get_to_pos() const {
116
117 return btVector3_to_LPoint3(m_rayToWorld);
118}
119
120/**
121 *
122 */
123int BulletClosestHitRayResult::
124get_shape_part() const {
125
126 return _shapePart;
127}
128
129/**
130 *
131 */
132int BulletClosestHitRayResult::
133get_triangle_index() const {
134
135 return _triangleIndex;
136}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
get_into_collide_mask
Returns the "into" collide mask for this node.
Definition pandaNode.h:264
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
Override default implementation.
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace)
Override default implementation.