Show how to use the btBroadphaseInterface::aabbTest, it collects all objects that overlap with a given bounding box
This fixes old Issue 114 Removed 2 warnings
This commit is contained in:
@@ -35,9 +35,31 @@ subject to the following restrictions:
|
||||
|
||||
#include <stdio.h> //printf debugging
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "LinearMath/btAabbUtil2.h"
|
||||
|
||||
static GLDebugDrawer gDebugDraw;
|
||||
|
||||
///The MyOverlapCallback is used to show how to collect object that overlap with a given bounding box defined by aabbMin and aabbMax.
|
||||
///See m_dynamicsWorld->getBroadphase()->aabbTest.
|
||||
struct MyOverlapCallback : public btBroadphaseAabbCallback
|
||||
{
|
||||
btVector3 m_queryAabbMin;
|
||||
btVector3 m_queryAabbMax;
|
||||
|
||||
int m_numOverlap;
|
||||
MyOverlapCallback(const btVector3& aabbMin, const btVector3& aabbMax ) : m_queryAabbMin(aabbMin),m_queryAabbMax(aabbMax),m_numOverlap(0) {}
|
||||
virtual bool process(const btBroadphaseProxy* proxy)
|
||||
{
|
||||
btVector3 proxyAabbMin,proxyAabbMax;
|
||||
btCollisionObject* colObj0 = (btCollisionObject*)proxy->m_clientObject;
|
||||
colObj0->getCollisionShape()->getAabb(colObj0->getWorldTransform(),proxyAabbMin,proxyAabbMax);
|
||||
if (TestAabbAgainstAabb2(proxyAabbMin,proxyAabbMax,m_queryAabbMin,m_queryAabbMax))
|
||||
{
|
||||
m_numOverlap++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void BasicDemo::clientMoveAndDisplay()
|
||||
{
|
||||
@@ -52,6 +74,15 @@ void BasicDemo::clientMoveAndDisplay()
|
||||
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
||||
//optional but useful: debug drawing
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
|
||||
btVector3 aabbMin(1,1,1);
|
||||
btVector3 aabbMax(2,2,2);
|
||||
|
||||
MyOverlapCallback aabbOverlap(aabbMin,aabbMax);
|
||||
m_dynamicsWorld->getBroadphase()->aabbTest(aabbMin,aabbMax,aabbOverlap);
|
||||
|
||||
if (aabbOverlap.m_numOverlap)
|
||||
printf("#aabb overlap = %d\n", aabbOverlap.m_numOverlap);
|
||||
}
|
||||
|
||||
renderme();
|
||||
|
||||
@@ -552,7 +552,7 @@ void btWorldImporter::convertConstraint(btTypedConstraintData* constraintData,bt
|
||||
}
|
||||
if (hingeData->m_enableAngularMotor)
|
||||
{
|
||||
hinge->enableAngularMotor(true,hingeData->m_motorTargetVelocity,hingeData->m_maxMotorImpulse);
|
||||
hinge->enableAngularMotor(true,(btScalar)hingeData->m_motorTargetVelocity,(btScalar)hingeData->m_maxMotorImpulse);
|
||||
}
|
||||
hinge->setAngularOnly(hingeData->m_angularOnly!=0);
|
||||
hinge->setLimit(btScalar(hingeData->m_lowerLimit),btScalar(hingeData->m_upperLimit),btScalar(hingeData->m_limitSoftness),btScalar(hingeData->m_biasFactor),btScalar(hingeData->m_relaxationFactor));
|
||||
|
||||
@@ -72,7 +72,7 @@ void stringToFloatArray(const std::string& string, btAlignedObjectArray<float>&
|
||||
btAlignedObjectArray<std::string> pieces;
|
||||
|
||||
bullet_utils::split( pieces, string, " ");
|
||||
for (unsigned int i = 0; i < pieces.size(); ++i)
|
||||
for ( int i = 0; i < pieces.size(); ++i)
|
||||
{
|
||||
assert(pieces[i]!="");
|
||||
floats.push_back((float)atof(pieces[i].c_str()));
|
||||
|
||||
Reference in New Issue
Block a user