make the compiler happy with Collision example

This commit is contained in:
Erwin Coumans
2015-10-19 18:21:45 -07:00
parent 5a21424662
commit abcaa19bc8
4 changed files with 53 additions and 21 deletions

View File

@@ -4,6 +4,7 @@
#define PL_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
#ifdef BT_USE_DOUBLE_PRECISION
typedef double plReal;
#else

View File

@@ -95,8 +95,8 @@ public:
btVector3 pos(0,btScalar(i*1.5),0);
btQuaternion orn(0,0,0,1);
b3Vector4 color = b3MakeVector4(0,1,0,0.8);
b3Vector3 scaling = b3MakeVector3(radius,radius,radius);
btVector4 color(0,1,0,0.8);
btVector3 scaling(radius,radius,radius);
int gfxIndex = m_app->m_renderer->registerGraphicsInstance(sphereGfxShapeId,pos, orn,color,scaling);
@@ -258,8 +258,8 @@ public:
for (int i=0;i<gTotalPoints;i++)
{
const lwContactPoint& contact = pointsOut[i];
b3Vector3 color=b3MakeVector3(1,1,0);
float lineWidth=3;
btVector3 color(1,1,0);
btScalar lineWidth=3;
if (contact.m_distance<0)
{
color.setValue(1,0,0);

View File

@@ -4,6 +4,24 @@
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
//convert the opaque pointer to int
struct RTB3_ColliderOpaque2Int
{
union
{
plCollisionObjectHandle m_ptrValue;
int m_intValue;
};
};
struct RTB3_ShapeOpaque2Int
{
union
{
plCollisionShapeHandle m_ptrValue;
int m_intValue;
};
};
enum RTB3ShapeTypes
{
RTB3_SHAPE_SPHERE=0,
@@ -45,9 +63,9 @@ struct RealTimeBullet3CollisionSdkInternalData
RealTimeBullet3CollisionSdk::RealTimeBullet3CollisionSdk()
{
int szCol = sizeof(b3Collidable);
int szShap = sizeof(b3GpuChildShape);
int szComPair = sizeof(b3CompoundOverlappingPair);
// int szCol = sizeof(b3Collidable);
// int szShap = sizeof(b3GpuChildShape);
// int szComPair = sizeof(b3CompoundOverlappingPair);
m_internalData = new RealTimeBullet3CollisionSdkInternalData;
}
@@ -129,7 +147,9 @@ plCollisionObjectHandle RealTimeBullet3CollisionSdk::createCollisionObject( plC
world->m_collidableOrientations[world->m_nextFreeCollidableIndex].setValue(startOrientation[0],startOrientation[1],startOrientation[2],startOrientation[3]);
world->m_collidableUserPointers[world->m_nextFreeCollidableIndex] = userPointer;
world->m_collidableUserIndices[world->m_nextFreeCollidableIndex] = userIndex;
int shapeIndex = (int)shapeHandle;
RTB3_ShapeOpaque2Int caster;
caster.m_ptrValue = shapeHandle;
int shapeIndex = caster.m_intValue;
collidable.m_shapeIndex = shapeIndex;
b3GpuChildShape& shape = world->m_childShapes[shapeIndex];
collidable.m_shapeType = shape.m_shapeType;
@@ -198,7 +218,13 @@ void detectCollisionDummy(RTB3CollisionWorld* world,int colA, int shapeIndexA, i
(void)contactCache;
}
void plVecCopy(b3Scalar* dst,const b3Vector3& src)
void plVecCopy(float* dst,const b3Vector3& src)
{
dst[0] = src.x;
dst[1] = src.y;
dst[2] = src.z;
}
void plVecCopy(double* dst,const b3Vector3& src)
{
dst[0] = src.x;
dst[1] = src.y;
@@ -257,7 +283,7 @@ void detectCollisionSphereSphere(RTB3CollisionWorld* world,int colA, int shapeIn
b3Vector3 spherePosAWorld = trA(sphereALocalPos);
b3Transform trB(world->m_collidableOrientations[colB],world->m_collidablePositions[colB]);
const b3Vector3& sphereBLocalPos = world->m_childShapes[shapeIndexB].m_childPosition;
b3Vector3 spherePosBWorld = trB(sphereALocalPos);
b3Vector3 spherePosBWorld = trB(sphereBLocalPos);
ComputeClosestPointsSphereSphere(radiusA,spherePosAWorld,radiusB,spherePosBWorld,contactCache);
}
@@ -297,8 +323,11 @@ int RealTimeBullet3CollisionSdk::collide(plCollisionWorldHandle worldHandle,plCo
lwContactPoint* pointsOutOrg, int pointCapacity)
{
RTB3CollisionWorld* world = (RTB3CollisionWorld*) worldHandle;
int colAIndex = (int) colAHandle;
int colBIndex = (int) colBHandle;
RTB3_ColliderOpaque2Int caster;
caster.m_ptrValue =colAHandle;
int colAIndex = caster.m_intValue;
caster.m_ptrValue = colBHandle;
int colBIndex = caster.m_intValue;
const b3Collidable& colA = world->m_collidables[colAIndex];
const b3Collidable& colB = world->m_collidables[colBIndex];
@@ -306,7 +335,6 @@ int RealTimeBullet3CollisionSdk::collide(plCollisionWorldHandle worldHandle,plCo
contactCache.pointCapacity = pointCapacity;
contactCache.pointsOut = pointsOutOrg;
contactCache.numAddedPoints = 0;
int remainingCapacity = pointCapacity;
for (int i=0;i<colA.m_numChildShapes;i++)
{
@@ -314,7 +342,6 @@ int RealTimeBullet3CollisionSdk::collide(plCollisionWorldHandle worldHandle,plCo
{
if (contactCache.numAddedPoints<pointCapacity)
{
lwContactPoint* curPointsOut = &pointsOutOrg[contactCache.numAddedPoints];
funcTbl_detectCollision[world->m_childShapes[colA.m_shapeIndex+i].m_shapeType]
[world->m_childShapes[colB.m_shapeIndex+j].m_shapeType](world,colAIndex,colA.m_shapeIndex+i,colBIndex,colB.m_shapeIndex+j,&contactCache);
}
@@ -335,8 +362,10 @@ void RealTimeBullet3CollisionSdk::collideWorld( plCollisionWorldHandle worldHand
{
for (int j=i+1;j<world->m_nextFreeCollidableIndex;j++)
{
plCollisionObjectHandle colA = (plCollisionObjectHandle)i;
plCollisionObjectHandle colB = (plCollisionObjectHandle)j;
RTB3_ColliderOpaque2Int caster; caster.m_intValue = i;
plCollisionObjectHandle colA = caster.m_ptrValue;
caster.m_intValue = j;
plCollisionObjectHandle colB = caster.m_ptrValue;
filter((plCollisionSdkHandle)this,worldHandle,userData,colA,colB);
}
}

View File

@@ -38,6 +38,8 @@ SET(App_ExampleBrowser_SRCS
../Collision/Internal/Bullet2CollisionSdk.cpp
../Collision/Internal/Bullet2CollisionSdk.h
../Collision/Internal/CollisionSdkInterface.h
../Collision/Internal/RealTimeBullet3CollisionSdk.cpp
../Collision/Internal/RealTimeBullet3CollisionSdk.h
../GyroscopicDemo/GyroscopicSetup.cpp
../GyroscopicDemo/GyroscopicSetup.h
../Planar2D/Planar2D.cpp