Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
BulletWorldManager.cpp
1
5
6/* SPDX-License-Identifier: CC0-1.0 */
7
8#include "BulletWorldManager.h"
9
10#include <iostream>
11#include <iomanip>
12#include <numeric>
13#include <sstream>
14
15#include <QMutexLocker>
16
17#include "FileName.h"
18#include "IException.h"
19#include "IString.h"
20
21using namespace std;
22
23namespace Isis {
24
29 m_name = "Body-Fixed-Coordinate-System";
30 initWorld();
31 }
32
33
40 m_name = name;
41 initWorld();
42 }
43
44
49
50
56 QString BulletWorldManager::name() const {
57 return ( m_name );
58 }
59
60
67 return ( m_world->getCollisionObjectArray().size() );
68 }
69
70
79 btAssert( index < size() );
80 btAssert( index >= 0 );
81 return ( (BulletTargetShape *) (m_world->getCollisionObjectArray().at(index)->getUserPointer()) );
82 }
83
84
93
94 QString v_name = name.toLower();
95 const btCollisionObjectArray &btobjects = m_world->getCollisionObjectArray();
96 for ( int i = 0 ; i < btobjects.size() ; i++ ) {
97 BulletTargetShape *target = (BulletTargetShape *) (btobjects[i]->getUserPointer());
98 if ( target->name().toLower() == v_name ) {
99 return (target);
100 }
101 }
102
103 // Not found...
104 return (0);
105 }
106
107
114
115 // May need to retain the target in a list for world destruction!!??
116 // CollisionBody is expected to contain a UserPointer that links back to
117 // target (BulletTargetShape or some other type).
118 m_world->addCollisionObject( target->body() );
119
120 }
121
122
139 bool BulletWorldManager::raycast(const btVector3 &rayStart, const btVector3 &rayEnd,
140 btCollisionWorld::RayResultCallback &results ) const {
141 m_world->rayTest(rayStart, rayEnd, results);
142 return ( results.hasHit() );
143 }
144
145
151 const btCollisionWorld &BulletWorldManager::getWorld() const {
152 return ( *m_world );
153 }
154
155
162 m_collision.reset( new btDefaultCollisionConfiguration() );
163 m_dispatcher.reset(new btCollisionDispatcher(m_collision.data()) );
164 m_broadphase.reset( new btDbvtBroadphase() ); // Could also be an AxisSweep
165 m_world.reset( new btCollisionWorld( m_dispatcher.data(), m_broadphase.data(), m_collision.data() ) );
166
167 }
168
169} // namespace Isis
Bullet Target Shape for planetary bodies.
btCollisionObject * body() const
Return a pointer to the Bullet target object/shape.
QString name() const
Return name of the target shape.
bool raycast(const btVector3 &observer, const btVector3 &lookdir, btCollisionWorld::RayResultCallback &hits) const
Perform ray casting from a position and a look direction.
QScopedPointer< btCollisionWorld > m_world
!
void addTarget(BulletTargetShape *target)
Add a Bullet shape to the collision world.
virtual ~BulletWorldManager()
Destroys the BulletWorldManager.
void initWorld()
Initialize the collision world for object ray tracing.
QScopedPointer< btCollisionDispatcher > m_dispatcher
!
QString name() const
Name of the world.
QScopedPointer< btDefaultCollisionConfiguration > m_collision
!
BulletTargetShape * getTarget(const int &index=0) const
Return a collision object by index into the world.
const btCollisionWorld & getWorld() const
Get the Collision World where the targets exist.
QScopedPointer< btBroadphaseInterface > m_broadphase
!
BulletWorldManager()
Default empty constructor.
int size() const
Number of collision objects in the world.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.