8 #include "BulletWorldManager.h"
15 #include <QMutexLocker>
18 #include "IException.h"
28 BulletWorldManager::BulletWorldManager() {
29 m_name =
"Body-Fixed-Coordinate-System";
39 BulletWorldManager::BulletWorldManager(
const QString &name) {
48 BulletWorldManager::~BulletWorldManager() { }
56 QString BulletWorldManager::name()
const {
66 int BulletWorldManager::size()
const{
67 return ( m_world->getCollisionObjectArray().size() );
79 btAssert( index < size() );
80 btAssert( index >= 0 );
81 return ( (
BulletTargetShape *) (m_world->getCollisionObjectArray().at(index)->getUserPointer()) );
94 QString v_name = name.toLower();
95 const btCollisionObjectArray &btobjects = m_world->getCollisionObjectArray();
96 for (
int i = 0 ; i < btobjects.size() ; i++ ) {
98 if ( target->
name().toLower() == v_name ) {
118 m_world->addCollisionObject( target->
body() );
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() );
151 const btCollisionWorld &BulletWorldManager::getWorld()
const {
161 void BulletWorldManager::initWorld() {
162 m_collision.reset(
new btDefaultCollisionConfiguration() );
163 m_dispatcher.reset(
new btCollisionDispatcher(m_collision.data()) );
164 m_broadphase.reset(
new btDbvtBroadphase() );
165 m_world.reset(
new btCollisionWorld( m_dispatcher.data(), m_broadphase.data(), m_collision.data() ) );