From abcaa19bc8aa0adf9b8ba9e0163a15b129d7a6bf Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 19 Oct 2015 18:21:45 -0700 Subject: [PATCH] make the compiler happy with Collision example --- examples/Collision/CollisionSdkC_Api.h | 1 + .../Collision/CollisionTutorialBullet2.cpp | 8 +-- .../Internal/RealTimeBullet3CollisionSdk.cpp | 63 ++++++++++++++----- examples/ExampleBrowser/CMakeLists.txt | 2 + 4 files changed, 53 insertions(+), 21 deletions(-) diff --git a/examples/Collision/CollisionSdkC_Api.h b/examples/Collision/CollisionSdkC_Api.h index 32cde118c..dba4c146e 100644 --- a/examples/Collision/CollisionSdkC_Api.h +++ b/examples/Collision/CollisionSdkC_Api.h @@ -4,6 +4,7 @@ #define PL_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name + #ifdef BT_USE_DOUBLE_PRECISION typedef double plReal; #else diff --git a/examples/Collision/CollisionTutorialBullet2.cpp b/examples/Collision/CollisionTutorialBullet2.cpp index 90c4895b3..f32968cf8 100644 --- a/examples/Collision/CollisionTutorialBullet2.cpp +++ b/examples/Collision/CollisionTutorialBullet2.cpp @@ -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;im_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; - collidable.m_shapeIndex = shapeIndex; + 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; collidable.m_numChildShapes = 1; @@ -198,12 +218,18 @@ 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; + dst[2] = src.z; +} void ComputeClosestPointsPlaneSphere(const b3Vector3& planeNormalWorld, b3Scalar planeConstant, const b3Vector3& spherePosWorld,b3Scalar sphereRadius, plContactCache* contactCache) { @@ -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,24 +323,25 @@ int RealTimeBullet3CollisionSdk::collide(plCollisionWorldHandle worldHandle,plCo lwContactPoint* pointsOutOrg, int pointCapacity) { RTB3CollisionWorld* world = (RTB3CollisionWorld*) worldHandle; - int colAIndex = (int) colAHandle; - int colBIndex = (int) colBHandle; - const b3Collidable& colA = world->m_collidables[colAIndex]; + 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]; plContactCache contactCache; contactCache.pointCapacity = pointCapacity; contactCache.pointsOut = pointsOutOrg; contactCache.numAddedPoints = 0; - int remainingCapacity = pointCapacity; - + for (int i=0;im_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); } @@ -324,7 +351,7 @@ int RealTimeBullet3CollisionSdk::collide(plCollisionWorldHandle worldHandle,plCo return 0; } - + void RealTimeBullet3CollisionSdk::collideWorld( plCollisionWorldHandle worldHandle, plNearCallback filter, void* userData) { @@ -335,9 +362,11 @@ void RealTimeBullet3CollisionSdk::collideWorld( plCollisionWorldHandle worldHand { for (int j=i+1;jm_nextFreeCollidableIndex;j++) { - plCollisionObjectHandle colA = (plCollisionObjectHandle)i; - plCollisionObjectHandle colB = (plCollisionObjectHandle)j; - filter((plCollisionSdkHandle)this,worldHandle,userData,colA,colB); + 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); } } } diff --git a/examples/ExampleBrowser/CMakeLists.txt b/examples/ExampleBrowser/CMakeLists.txt index df611f4b0..3bbf75bdf 100644 --- a/examples/ExampleBrowser/CMakeLists.txt +++ b/examples/ExampleBrowser/CMakeLists.txt @@ -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