Bullet Collision Detection & Physics Library
btGhostObject.cpp
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2008 Erwin Coumans http://bulletphysics.com
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#include "btGhostObject.h"
17#include "btCollisionWorld.h"
20
22{
24}
25
27{
30}
31
33{
38 if (index == m_overlappingObjects.size())
39 {
40 //not found
42 }
43}
44
46{
50 if (index < m_overlappingObjects.size())
51 {
54 }
55}
56
58{
60}
61
63{
66}
67
69{
72
76 if (index == m_overlappingObjects.size())
77 {
80 }
81}
82
84{
88
91 if (index < m_overlappingObjects.size())
92 {
96 }
97}
98
100{
105 /* Compute AABB that encompasses angular movement */
106 {
110 R.setIdentity();
111 R.setRotation(convexFromTrans.getRotation());
112 castShape->calculateTemporalAabb(R, linVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax);
113 }
114
116 // do a ray-shape query using convexCaster (CCD)
117 int i;
118 for (i = 0; i < m_overlappingObjects.size(); i++)
119 {
121 //only perform raycast if filterMask matches
122 if (resultCallback.needsCollision(collisionObject->getBroadphaseHandle()))
123 {
124 //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
126 collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(), collisionObjectAabbMin, collisionObjectAabbMax);
128 btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing
131 {
134 collisionObject->getCollisionShape(),
135 collisionObject->getWorldTransform(),
138 }
139 }
140 }
141}
142
144{
147 rayFromTrans.setOrigin(rayFromWorld);
150 rayToTrans.setOrigin(rayToWorld);
151
152 int i;
153 for (i = 0; i < m_overlappingObjects.size(); i++)
154 {
156 //only perform raycast if filterMask matches
157 if (resultCallback.needsCollision(collisionObject->getBroadphaseHandle()))
158 {
161 collisionObject->getCollisionShape(),
162 collisionObject->getWorldTransform(),
164 }
165 }
166}
bool btRayAabb(const btVector3 &rayFrom, const btVector3 &rayTo, const btVector3 &aabbMin, const btVector3 &aabbMax, btScalar &param, btVector3 &normal)
void AabbExpand(btVector3 &aabbMin, btVector3 &aabbMax, const btVector3 &expansionMin, const btVector3 &expansionMax)
Definition btAabbUtil2.h:22
#define btAlignedFree(ptr)
#define btAlignedAlloc(size, alignment)
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:27
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
#define btAssert(x)
Definition btScalar.h:153
int size() const
return the number of elements in the array
int findLinearSearch(const T &key) const
void push_back(const T &_Val)
btCollisionObject can be used to manage collision detection objects.
@ CO_GHOST_OBJECT
CO_GHOST_OBJECT keeps track of all objects overlapping its AABB and that pass its collision filter It...
btBroadphaseProxy * getBroadphaseHandle()
int m_internalType
m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody,...
static void objectQuerySingle(const btConvexShape *castShape, const btTransform &rayFromTrans, const btTransform &rayToTrans, btCollisionObject *collisionObject, const btCollisionShape *collisionShape, const btTransform &colObjWorldTransform, ConvexResultCallback &resultCallback, btScalar allowedPenetration)
objectQuerySingle performs a collision detection query and calls the resultCallback....
static void rayTestSingle(const btTransform &rayFromTrans, const btTransform &rayToTrans, btCollisionObject *collisionObject, const btCollisionShape *collisionShape, const btTransform &colObjWorldTransform, RayResultCallback &resultCallback)
rayTestSingle performs a raycast call and calls the resultCallback.
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
void convexSweepTest(const class btConvexShape *castShape, const btTransform &convexFromWorld, const btTransform &convexToWorld, btCollisionWorld::ConvexResultCallback &resultCallback, btScalar allowedCcdPenetration=0.f) const
virtual void removeOverlappingObjectInternal(btBroadphaseProxy *otherProxy, btDispatcher *dispatcher, btBroadphaseProxy *thisProxy=0)
this method is mainly for expert/internal use only.
void rayTest(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, btCollisionWorld::RayResultCallback &resultCallback) const
btAlignedObjectArray< btCollisionObject * > m_overlappingObjects
virtual ~btGhostObject()
virtual void addOverlappingObjectInternal(btBroadphaseProxy *otherProxy, btBroadphaseProxy *thisProxy=0)
this method is mainly for expert/internal use only.
Hash-space based Pair Cache, thanks to Erin Catto, Box2D, http://www.box2d.org, and Pierre Terdiman,...
virtual btBroadphasePair * addOverlappingPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)
virtual void * removeOverlappingPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1, btDispatcher *dispatcher)
virtual void addOverlappingObjectInternal(btBroadphaseProxy *otherProxy, btBroadphaseProxy *thisProxy=0)
this method is mainly for expert/internal use only.
btHashedOverlappingPairCache * m_hashPairCache
virtual void removeOverlappingObjectInternal(btBroadphaseProxy *otherProxy, btDispatcher *dispatcher, btBroadphaseProxy *thisProxy=0)
this method is mainly for expert/internal use only.
static void calculateVelocity(const btTransform &transform0, const btTransform &transform1, btScalar timeStep, btVector3 &linVel, btVector3 &angVel)
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition btTransform.h:30
void setIdentity()
Set this transformation to the identity.
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:82
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
RayResultCallback is used to report new raycast results.
RayResultCallback is used to report new raycast results.