Isis 3 Programmer Reference
BulletAllHitsRayCallback.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include <cmath>
9 
10 #include <QScopedPointer>
11 #include <QString>
12 #include <QVector>
13 
14 
15 #include "BulletAllHitsRayCallback.h"
16 #include "Constants.h"
17 #include "IException.h"
18 #include "SurfacePoint.h"
19 
20 #include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
21 
22 namespace Isis {
23 
24 
30  btCollisionWorld::AllHitsRayResultCallback(btVector3(0,0,0), btVector3(0,0,0)),
31  m_rayHits() {
32  m_flags = (btTriangleRaycastCallback::kF_KeepUnflippedNormal |
33  btTriangleRaycastCallback::kF_UseGjkConvexCastRaytest);
34  }
35 
36 
45  const btVector3 &lookdir,
46  const bool cullBackfacers) :
47  btCollisionWorld::AllHitsRayResultCallback(observer, lookdir),
48  m_rayHits() {
49  m_flags = (btTriangleRaycastCallback::kF_KeepUnflippedNormal |
50  btTriangleRaycastCallback::kF_UseGjkConvexCastRaytest);
51  if ( cullBackfacers ) {
52  m_flags |= btTriangleRaycastCallback::kF_FilterBackfaces;
53  }
54  }
55 
56 
61 
62 
71  return ( hasHit() );
72  }
73 
74 
81  return ( m_rayHits.size() );
82  }
83 
84 
91  return ( AllHitsRayResultCallback::m_rayFromWorld );
92  }
93 
94 
101  return ( AllHitsRayResultCallback::m_rayToWorld );
102  }
103 
104 
113  btAssert( index >= 0 );
114  btAssert( index < size() );
115  return ( m_rayHits[index]);
116  }
117 
118 
131  btScalar BulletAllHitsRayCallback::addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace) {
132  btCollisionWorld::AllHitsRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
133  m_rayHits.push_back(BulletClosestRayCallback(observer(), lookdir(), *this, rayResult, normalInWorldSpace));
134  return (rayResult.m_hitFraction);
135  }
136 } // namespace Isis
137 
138 
139 
Isis::BulletAllHitsRayCallback::isValid
bool isValid() const
Checks if the callback is valid/has a valid intersection.
Definition: BulletAllHitsRayCallback.cpp:70
Isis::BulletAllHitsRayCallback::size
int size() const
Returns the number of intersections found.
Definition: BulletAllHitsRayCallback.cpp:80
Isis::BulletAllHitsRayCallback::lookdir
btVector3 lookdir() const
Return the end of the ray.
Definition: BulletAllHitsRayCallback.cpp:100
Isis::BulletAllHitsRayCallback::BulletAllHitsRayCallback
BulletAllHitsRayCallback()
Default constructor.
Definition: BulletAllHitsRayCallback.cpp:29
Isis::BulletAllHitsRayCallback::hit
const BulletClosestRayCallback & hit(const int &index=0) const
Return a callback for the intersection at a given index.
Definition: BulletAllHitsRayCallback.cpp:112
Isis::BulletAllHitsRayCallback::addSingleResult
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace)
Add a local intersection result to this callback during ray casting.
Definition: BulletAllHitsRayCallback.cpp:131
Isis::BulletAllHitsRayCallback::m_rayHits
QVector< BulletClosestRayCallback > m_rayHits
List of ray hits.
Definition: BulletAllHitsRayCallback.h:46
Isis::BulletAllHitsRayCallback::observer
btVector3 observer() const
Return the beginning of the ray.
Definition: BulletAllHitsRayCallback.cpp:90
Isis::BulletClosestRayCallback
Bullet ray tracing callback for closest hit on target surface.
Definition: BulletClosestRayCallback.h:33
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::BulletAllHitsRayCallback::~BulletAllHitsRayCallback
virtual ~BulletAllHitsRayCallback()
Destroy this callback.
Definition: BulletAllHitsRayCallback.cpp:60