diff --git a/Demos/BspDemo/BspConverter.cpp b/Demos/BspDemo/BspConverter.cpp index 05a60049a..2c9475a56 100644 --- a/Demos/BspDemo/BspConverter.cpp +++ b/Demos/BspDemo/BspConverter.cpp @@ -16,12 +16,12 @@ subject to the following restrictions: #include "BspConverter.h" #include "BspLoader.h" #include "CcdPhysicsEnvironment.h" -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" void BspConverter::convertBsp(BspLoader& bspLoader,float scaling) { { - SimdVector3 playerStart (0.f, 0.f, 100.f); + btVector3 playerStart (0.f, 0.f, 100.f); if (bspLoader.findVectorByName(&playerStart[0],"info_player_start")) { @@ -53,7 +53,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling) for (int b=0;b planeEquations; + std::vector planeEquations; int brushid = bspLoader.m_dleafbrushes[leaf.firstLeafBrush+b]; @@ -70,7 +70,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling) BSPBrushSide& brushside = bspLoader.m_dbrushsides[sideid]; int planeid = brushside.planeNum; BSPPlane& plane = bspLoader.m_dplanes[planeid]; - SimdVector3 planeEq; + btVector3 planeEq; planeEq.setValue( plane.normal[0], plane.normal[1], @@ -83,13 +83,13 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling) if (isValidBrush) { - std::vector vertices; + std::vector vertices; getVerticesFromPlaneEquations(planeEquations,vertices); printf("getVerticesFromPlaneEquations returned %i\n",(int)vertices.size()); bool isEntity = false; - SimdVector3 entityTarget(0.f,0.f,0.f); + btVector3 entityTarget(0.f,0.f,0.f); AddConvexVerticesCollider(vertices,isEntity,entityTarget); } @@ -109,7 +109,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling) const BSPEntity& entity = bspLoader.m_entities[i]; const char* cl = bspLoader.ValueForKey(&entity,"classname"); if ( !strcmp( cl, "trigger_push" ) ) { - SimdVector3 targetLocation(0.f,0.f,0.f); + btVector3 targetLocation(0.f,0.f,0.f); cl = bspLoader.ValueForKey(&entity,"target"); if ( strcmp( cl, "" ) ) { @@ -136,7 +136,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling) const BSPModel& model = bspLoader.m_dmodels[modelnr]; for (int n=0;n planeEquations; + std::vector planeEquations; bool isValidBrush = false; //convert brush @@ -148,7 +148,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling) BSPBrushSide& brushside = bspLoader.m_dbrushsides[sideid]; int planeid = brushside.planeNum; BSPPlane& plane = bspLoader.m_dplanes[planeid]; - SimdVector3 planeEq; + btVector3 planeEq; planeEq.setValue( plane.normal[0], plane.normal[1], @@ -160,7 +160,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling) if (isValidBrush) { - std::vector vertices; + std::vector vertices; getVerticesFromPlaneEquations(planeEquations,vertices); bool isEntity=true; @@ -197,27 +197,27 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling) -void BspConverter::getVerticesFromPlaneEquations(const std::vector& planeEquations , std::vector& verticesOut ) +void BspConverter::getVerticesFromPlaneEquations(const std::vector& planeEquations , std::vector& verticesOut ) { const int numbrushes = planeEquations.size(); // brute force: for (int i=0;i 0.0001f ) && ( n3n1.length2() > 0.0001f ) && @@ -231,13 +231,13 @@ void BspConverter::getVerticesFromPlaneEquations(const std::vector& float quotient = (N1.dot(n2n3)); - if (SimdFabs(quotient) > 0.000001f) + if (btFabs(quotient) > 0.000001f) { quotient = -1.f / quotient; n2n3 *= N1[3]; n3n1 *= N2[3]; n1n2 *= N3[3]; - SimdVector3 potentialVertex = n2n3; + btVector3 potentialVertex = n2n3; potentialVertex += n3n1; potentialVertex += n1n2; potentialVertex *= quotient; @@ -257,12 +257,12 @@ void BspConverter::getVerticesFromPlaneEquations(const std::vector& -bool BspConverter::isInside(const std::vector& planeEquations, const SimdVector3& point, float margin) +bool BspConverter::isInside(const std::vector& planeEquations, const btVector3& point, float margin) { int numbrushes = planeEquations.size(); for (int i=0;i0.f) { diff --git a/Demos/BspDemo/BspConverter.h b/Demos/BspDemo/BspConverter.h index dc9e99981..7054cb492 100644 --- a/Demos/BspDemo/BspConverter.h +++ b/Demos/BspDemo/BspConverter.h @@ -18,7 +18,7 @@ subject to the following restrictions: class BspLoader; #include -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" ///BspConverter turns a loaded bsp level into convex parts (vertices) class BspConverter @@ -31,11 +31,11 @@ class BspConverter } ///Utility function to create vertices from a Quake Brush. Brute force but it works. ///Bit overkill to use QHull package - void getVerticesFromPlaneEquations(const std::vector& planeEquations , std::vector& verticesOut ); - bool isInside(const std::vector& planeEquations, const SimdVector3& point, float margin); + void getVerticesFromPlaneEquations(const std::vector& planeEquations , std::vector& verticesOut ); + bool isInside(const std::vector& planeEquations, const btVector3& point, float margin); ///this callback is called for each brush that succesfully converted into vertices - virtual void AddConvexVerticesCollider(std::vector& vertices, bool isEntity, const SimdVector3& entityTargetLocation) = 0; + virtual void AddConvexVerticesCollider(std::vector& vertices, bool isEntity, const btVector3& entityTargetLocation) = 0; }; diff --git a/Demos/BspDemo/BspDemo.cpp b/Demos/BspDemo/BspDemo.cpp index 957a70609..6a3cdb4e3 100644 --- a/Demos/BspDemo/BspDemo.cpp +++ b/Demos/BspDemo/BspDemo.cpp @@ -18,8 +18,8 @@ subject to the following restrictions: #include "btBulletDynamicsCommon.h" -#include "LinearMath/GenQuickprof.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btQuickprof.h" +#include "LinearMath/btIDebugDraw.h" #include "GLDebugDrawer.h" @@ -60,7 +60,7 @@ public: { } - virtual void AddConvexVerticesCollider(std::vector& vertices, bool isEntity, const SimdVector3& entityTargetLocation) + virtual void AddConvexVerticesCollider(std::vector& vertices, bool isEntity, const btVector3& entityTargetLocation) { ///perhaps we can do something special with entities (isEntity) ///like adding a collision Triggering (as example) @@ -69,12 +69,12 @@ public: { bool isDynamic = false; float mass = 0.f; - SimdTransform startTransform; + btTransform startTransform; //can use a shift startTransform.setIdentity(); - startTransform.setOrigin(SimdVector3(0,0,-10.f)); + startTransform.setOrigin(btVector3(0,0,-10.f)); //this create an internal copy of the vertices - CollisionShape* shape = new ConvexHullShape(&vertices[0],vertices.size()); + btCollisionShape* shape = new btConvexHullShape(&vertices[0],vertices.size()); m_demoApp->LocalCreatePhysicsObject(isDynamic, mass, startTransform,shape); } @@ -128,15 +128,15 @@ void BspDemo::initPhysics(char* bspfilename) { - m_cameraUp = SimdVector3(0,0,1); + m_cameraUp = btVector3(0,0,1); m_forwardAxis = 1; ///Setup a Physics Simulation Environment - CollisionDispatcher* dispatcher = new CollisionDispatcher(); - SimdVector3 worldAabbMin(-10000,-10000,-10000); - SimdVector3 worldAabbMax(10000,10000,10000); - OverlappingPairCache* broadphase = new AxisSweep3(worldAabbMin,worldAabbMax); - //BroadphaseInterface* broadphase = new SimpleBroadphase(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(); + btVector3 worldAabbMin(-10000,-10000,-10000); + btVector3 worldAabbMax(10000,10000,10000); + btOverlappingPairCache* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax); + //BroadphaseInterface* broadphase = new btSimpleBroadphase(); m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase); m_physicsEnvironmentPtr->setDeactivationTime(2.f); m_physicsEnvironmentPtr->setGravity(0,0,-10); diff --git a/Demos/BspDemo/BspLoader.cpp b/Demos/BspDemo/BspLoader.cpp index f4f36badd..c4b3e437b 100644 --- a/Demos/BspDemo/BspLoader.cpp +++ b/Demos/BspDemo/BspLoader.cpp @@ -5,16 +5,16 @@ Copyright (C) 1999-2005 Id Software, Inc. This file is part of Quake III Arena source code. Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as +and/or modify it under the terms of the GNU bteral Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Quake III Arena source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +GNU bteral Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU bteral Public License along with Foobar; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== diff --git a/Demos/BspDemo/BspLoader.h b/Demos/BspDemo/BspLoader.h index c89a8a125..36874f051 100644 --- a/Demos/BspDemo/BspLoader.h +++ b/Demos/BspDemo/BspLoader.h @@ -5,16 +5,16 @@ Copyright (C) 1999-2005 Id Software, Inc. This file is part of Quake III Arena source code. Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as +and/or modify it under the terms of the GNU bteral Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Quake III Arena source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +GNU bteral Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU bteral Public License along with Foobar; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== diff --git a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp index b71d89ebb..6c4a5ec99 100644 --- a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp +++ b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp @@ -13,28 +13,17 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ - //#define USER_DEFINED_FRICTION_MODEL 1 //#define PRINT_CONTACT_STATISTICS 1 #define REGISTER_CUSTOM_COLLISION_ALGORITHM 1 -#include "CcdPhysicsEnvironment.h" -#include "ParallelPhysicsEnvironment.h" - #include "btBulletDynamicsCommon.h" -#include "CcdPhysicsController.h" -#include "MyMotionState.h" - -#include "ParallelIslandDispatcher.h" - -#include "LinearMath/GenQuickprof.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btQuickprof.h" +#include "LinearMath/btIDebugDraw.h" #include "GLDebugDrawer.h" - - #include "PHY_Pro.h" #include "BMF_Api.h" #include //printf debugging @@ -68,40 +57,35 @@ const int maxNumObjects = 32760; int shapeIndex[maxNumObjects]; -#ifdef USE_PARALLEL_DISPATCHER -ParallelPhysicsEnvironment* m_physicsEnvironmentPtr = 0; -#else -CcdPhysicsEnvironment* m_physicsEnvironmentPtr = 0; -#endif #define CUBE_HALF_EXTENTS 1 #define EXTRA_HEIGHT -20.f -//GL_LineSegmentShape shapeE(SimdPoint3(-50,0,0), -// SimdPoint3(50,0,0)); +//GL_LineSegmentShape shapeE(btPoint3(-50,0,0), +// btPoint3(50,0,0)); static const int numShapes = 4; -CollisionShape* shapePtr[numShapes] = +btCollisionShape* shapePtr[numShapes] = { ///Please don't make the box sizes larger then 1000: the collision detection will be inaccurate. ///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=346 //#define USE_GROUND_PLANE 1 #ifdef USE_GROUND_PLANE - new StaticPlaneShape(SimdVector3(0,1,0),10), + new btStaticPlaneShape(btVector3(0,1,0),10), #else - new BoxShape (SimdVector3(50,10,50)), + new btBoxShape (btVector3(50,10,50)), #endif - new BoxShape (SimdVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)), - new SphereShape (CUBE_HALF_EXTENTS- 0.05f), + new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)), + new btSphereShape (CUBE_HALF_EXTENTS- 0.05f), - //new ConeShape(CUBE_HALF_EXTENTS,2.f*CUBE_HALF_EXTENTS), - //new BU_Simplex1to4(SimdPoint3(-1,-1,-1),SimdPoint3(1,-1,-1),SimdPoint3(-1,1,-1),SimdPoint3(0,0,1)), + //new btConeShape(CUBE_HALF_EXTENTS,2.f*CUBE_HALF_EXTENTS), + //new btBU_Simplex1to4(btPoint3(-1,-1,-1),btPoint3(1,-1,-1),btPoint3(-1,1,-1),btPoint3(0,0,1)), - //new EmptyShape(), + //new btEmptyShape(), - new BoxShape (SimdVector3(0.4,1,0.8)) + new btBoxShape (btVector3(0.4,1,0.8)) }; @@ -138,19 +122,17 @@ void CcdPhysicsDemo::clientMoveAndDisplay() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - - if (m_physicsEnvironmentPtr) - m_physicsEnvironmentPtr->proceedDeltaTime(0.f,deltaTime); - + if (m_dynamicsWorld) + m_dynamicsWorld->stepSimulation(deltaTime); + #ifdef USE_QUICKPROF - Profiler::beginBlock("render"); + btProfiler::beginBlock("render"); #endif //USE_QUICKPROF renderme(); #ifdef USE_QUICKPROF - Profiler::endBlock("render"); + btProfiler::endBlock("render"); #endif glFlush(); //some additional debugging info @@ -171,12 +153,15 @@ void CcdPhysicsDemo::displayCallback(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + /* if (m_physicsEnvironmentPtr) { m_physicsEnvironmentPtr->UpdateAabbs(deltaTime); //draw contactpoints m_physicsEnvironmentPtr->CallbackTriggers(); } + */ + renderme(); @@ -192,7 +177,7 @@ void CcdPhysicsDemo::displayCallback(void) { void CcdPhysicsDemo::clientResetScene() { - +/* int i; int numObjects = m_physicsEnvironmentPtr->GetNumControllers(); @@ -203,7 +188,7 @@ void CcdPhysicsDemo::clientResetScene() { CcdPhysicsController* ctrl = m_physicsEnvironmentPtr->GetPhysicsController(i); - if ((getDebugMode() & IDebugDraw::DBG_NoHelpText)) + if ((getDebugMode() & btIDebugDraw::DBG_NoHelpText)) { if (ctrl->GetRigidBody()->GetCollisionShape()->GetShapeType() != SPHERE_SHAPE_PROXYTYPE) { @@ -213,7 +198,7 @@ void CcdPhysicsDemo::clientResetScene() ctrl->GetRigidBody()->SetCollisionShape(shapePtr[1]); } - BroadphaseProxy* bpproxy = ctrl->GetRigidBody()->m_broadphaseHandle; + btBroadphaseProxy* bpproxy = ctrl->GetRigidBody()->m_broadphaseHandle; m_physicsEnvironmentPtr->GetBroadphase()->CleanProxyFromPairs(bpproxy); } @@ -236,11 +221,13 @@ void CcdPhysicsDemo::clientResetScene() ctrl->SetAngularVelocity(0,0,0,false); } } + */ + } ///User-defined friction model, the most simple friction model available: no friction -float myFrictionModel( RigidBody& body1, RigidBody& body2, ManifoldPoint& contactPoint, const ContactSolverInfo& solverInfo ) +float myFrictionModel( btRigidBody& body1, btRigidBody& body2, btManifoldPoint& contactPoint, const btContactSolverInfo& solverInfo ) { //don't do any friction return 0.f; @@ -249,32 +236,25 @@ float myFrictionModel( RigidBody& body1, RigidBody& body2, ManifoldPoint& contac void CcdPhysicsDemo::initPhysics() { - CollisionDispatcher* dispatcher = new CollisionDispatcher(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(); - SimdVector3 worldAabbMin(-10000,-10000,-10000); - SimdVector3 worldAabbMax(10000,10000,10000); + btVector3 worldAabbMin(-10000,-10000,-10000); + btVector3 worldAabbMax(10000,10000,10000); - OverlappingPairCache* broadphase = new AxisSweep3(worldAabbMin,worldAabbMax,maxProxies); -// OverlappingPairCache* broadphase = new SimpleBroadphase; + btOverlappingPairCache* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies); +// btOverlappingPairCache* broadphase = new btSimpleBroadphase; #ifdef REGISTER_CUSTOM_COLLISION_ALGORITHM - dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new SphereSphereCollisionAlgorithm::CreateFunc); + dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc); #endif //REGISTER_CUSTOM_COLLISION_ALGORITHM + btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver; -#ifdef USE_PARALLEL_DISPATCHER - m_physicsEnvironmentPtr = new ParallelPhysicsEnvironment(dispatcher2,broadphase); -#else - m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase); -#endif - m_physicsEnvironmentPtr->setDeactivationTime(2.f); + m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver); - m_physicsEnvironmentPtr->setGravity(0,-10,0); - - m_physicsEnvironmentPtr->setDebugDrawer(&debugDrawer); #ifdef USER_DEFINED_FRICTION_MODEL - SequentialImpulseConstraintSolver* solver = (SequentialImpulseConstraintSolver*) m_physicsEnvironmentPtr->GetConstraintSolver(); + btSequentialImpulseConstraintSolver* solver = (btSequentialImpulseConstraintSolver*) m_physicsEnvironmentPtr->GetConstraintSolver(); //solver->SetContactSolverFunc(ContactSolverFunc func,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE); solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE); solver->SetFrictionSolverFunc(myFrictionModel,DEFAULT_CONTACT_SOLVER_TYPE,USER_CONTACT_SOLVER_TYPE1); @@ -285,7 +265,7 @@ void CcdPhysicsDemo::initPhysics() int i; - SimdTransform tr; + btTransform tr; tr.setIdentity(); @@ -301,26 +281,26 @@ void CcdPhysicsDemo::initPhysics() if (useCompound) { - CompoundShape* compoundShape = new CompoundShape(); - CollisionShape* oldShape = shapePtr[1]; + btCompoundShape* compoundShape = new btCompoundShape(); + btCollisionShape* oldShape = shapePtr[1]; shapePtr[1] = compoundShape; - SimdTransform ident; + btTransform ident; ident.setIdentity(); - ident.setOrigin(SimdVector3(0,0,0)); + ident.setOrigin(btVector3(0,0,0)); compoundShape->AddChildShape(ident,oldShape);// - ident.setOrigin(SimdVector3(0,0,2)); - compoundShape->AddChildShape(ident,new SphereShape(0.9));// + ident.setOrigin(btVector3(0,0,2)); + compoundShape->AddChildShape(ident,new btSphereShape(0.9));// } for (i=0;iSetMargin(0.05f); bool isDyna = i>0; - SimdTransform trans; + btTransform trans; trans.setIdentity(); if (i>0) @@ -338,13 +318,13 @@ void CcdPhysicsDemo::initPhysics() row2 |=1; } - SimdVector3 pos(col*2*CUBE_HALF_EXTENTS + (row2%2)*CUBE_HALF_EXTENTS, + btVector3 pos(col*2*CUBE_HALF_EXTENTS + (row2%2)*CUBE_HALF_EXTENTS, row*2*CUBE_HALF_EXTENTS+CUBE_HALF_EXTENTS+EXTRA_HEIGHT,0); trans.setOrigin(pos); } else { - trans.setOrigin(SimdVector3(0,-30,0)); + trans.setOrigin(btVector3(0,-30,0)); } float mass = 1.f; @@ -352,13 +332,16 @@ void CcdPhysicsDemo::initPhysics() if (!isDyna) mass = 0.f; - CcdPhysicsController* ctrl = LocalCreatePhysicsObject(isDyna,mass,trans,shape); - + btRigidBody* body = LocalCreateRigidBody(isDyna,mass,trans,shape); + + m_dynamicsWorld->AddCollisionObject(body); + // Only do CCD if motion in one timestep (1.f/60.f) exceeds CUBE_HALF_EXTENTS - ctrl->GetRigidBody()->m_ccdSquareMotionTreshold = CUBE_HALF_EXTENTS; + body->m_ccdSquareMotionTreshold = CUBE_HALF_EXTENTS; //Experimental: better estimation of CCD Time of Impact: - ctrl->GetRigidBody()->m_ccdSweptShereRadius = 0.2*CUBE_HALF_EXTENTS; + body->m_ccdSweptShereRadius = 0.2*CUBE_HALF_EXTENTS; + #ifdef USER_DEFINED_FRICTION_MODEL ///Advanced use: override the friction solver ctrl->GetRigidBody()->m_frictionSolverType = USER_CONTACT_SOLVER_TYPE1; @@ -369,7 +352,6 @@ void CcdPhysicsDemo::initPhysics() clientResetScene(); - m_physicsEnvironmentPtr->SyncMotionStates(0.f); } diff --git a/Demos/CcdPhysicsDemo/MyMotionState.cpp b/Demos/CcdPhysicsDemo/MyMotionState.cpp index 4699dd718..fe3636d5d 100644 --- a/Demos/CcdPhysicsDemo/MyMotionState.cpp +++ b/Demos/CcdPhysicsDemo/MyMotionState.cpp @@ -14,7 +14,7 @@ subject to the following restrictions: */ #include "MyMotionState.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btPoint3.h" MyMotionState::MyMotionState() { @@ -51,13 +51,13 @@ void MyMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& q void MyMotionState::setWorldPosition(float posX,float posY,float posZ) { - SimdPoint3 pos(posX,posY,posZ); + btPoint3 pos(posX,posY,posZ); m_worldTransform.setOrigin( pos ); } void MyMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) { - SimdQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); + btQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); m_worldTransform.setRotation( orn ); } diff --git a/Demos/CcdPhysicsDemo/MyMotionState.h b/Demos/CcdPhysicsDemo/MyMotionState.h index cbf9988e2..7aa7c8520 100644 --- a/Demos/CcdPhysicsDemo/MyMotionState.h +++ b/Demos/CcdPhysicsDemo/MyMotionState.h @@ -17,7 +17,7 @@ subject to the following restrictions: #define MY_MOTIONSTATE_H #include "PHY_IMotionState.h" -#include +#include class MyMotionState : public PHY_IMotionState @@ -37,7 +37,7 @@ class MyMotionState : public PHY_IMotionState virtual void calculateWorldTransformations(); - SimdTransform m_worldTransform; + btTransform m_worldTransform; }; diff --git a/Demos/ColladaDemo/ColladaConverter.cpp b/Demos/ColladaDemo/ColladaConverter.cpp index a3c9247d4..8caf5f355 100644 --- a/Demos/ColladaDemo/ColladaConverter.cpp +++ b/Demos/ColladaDemo/ColladaConverter.cpp @@ -37,7 +37,7 @@ char* getLastFileName(); char* fixFileName(const char* lpCmdLine); //todo: sort out this domInstance_rigid_bodyRef forward definition, put it in the headerfile and make it virtual (make code more re-usable) -struct RigidBodyInput +struct btRigidBodyInput { domInstance_rigid_bodyRef m_instanceRigidBodyRef; domRigid_bodyRef m_rigidBodyRef2; @@ -52,12 +52,12 @@ struct ConstraintInput }; -struct RigidBodyOutput +struct btRigidBodyOutput { float m_mass; bool m_isDynamics; - CollisionShape* m_colShape; - CompoundShape* m_compoundShape; + btCollisionShape* m_colShape; + btCompoundShape* m_compoundShape; }; @@ -66,13 +66,13 @@ domMatrix_Array emptyMatrixArray; domNodeRef m_colladadomNodes[COLLADA_CONVERTER_MAX_NUM_OBJECTS]; -SimdTransform GetSimdTransformFromCOLLADA_DOM(domMatrix_Array& matrixArray, +btTransform GetbtTransformFromCOLLADA_DOM(domMatrix_Array& matrixArray, domRotate_Array& rotateArray, domTranslate_Array& translateArray ) { - SimdTransform startTransform; + btTransform startTransform; startTransform.setIdentity(); unsigned int i; @@ -81,9 +81,9 @@ SimdTransform GetSimdTransformFromCOLLADA_DOM(domMatrix_Array& matrixArray, { domMatrixRef matrixRef = matrixArray[i]; domFloat4x4 fl16 = matrixRef->getValue(); - SimdVector3 origin(fl16.get(3),fl16.get(7),fl16.get(11)); + btVector3 origin(fl16.get(3),fl16.get(7),fl16.get(11)); startTransform.setOrigin(origin); - SimdMatrix3x3 basis(fl16.get(0),fl16.get(1),fl16.get(2), + btMatrix3x3 basis(fl16.get(0),fl16.get(1),fl16.get(2), fl16.get(4),fl16.get(5),fl16.get(6), fl16.get(8),fl16.get(9),fl16.get(10)); startTransform.setBasis(basis); @@ -94,15 +94,15 @@ SimdTransform GetSimdTransformFromCOLLADA_DOM(domMatrix_Array& matrixArray, domRotateRef rotateRef = rotateArray[i]; domFloat4 fl4 = rotateRef->getValue(); float angleRad = SIMD_RADS_PER_DEG*fl4.get(3); - SimdQuaternion rotQuat(SimdVector3(fl4.get(0),fl4.get(1),fl4.get(2)),angleRad); - startTransform.getBasis() = startTransform.getBasis() * SimdMatrix3x3(rotQuat); + btQuaternion rotQuat(btVector3(fl4.get(0),fl4.get(1),fl4.get(2)),angleRad); + startTransform.getBasis() = startTransform.getBasis() * btMatrix3x3(rotQuat); } for (i=0;igetValue(); - startTransform.getOrigin() += SimdVector3(fl3.get(0),fl3.get(1),fl3.get(2)); + startTransform.getOrigin() += btVector3(fl3.get(0),fl3.get(1),fl3.get(2)); } return startTransform; } @@ -185,20 +185,20 @@ bool ColladaConverter::convert() printf(" X is Up Data and Hiearchies must be converted!\n" ); printf(" Conversion to X axis Up isn't currently supported!\n" ); printf(" COLLADA_RT defaulting to Y Up \n" ); - SetGravity(SimdVector3(-10,0,0)); - SetCameraInfo(SimdVector3(1,0,0),1); + SetGravity(btVector3(-10,0,0)); + SetCameraInfo(btVector3(1,0,0),1); break; case UPAXISTYPE_Y_UP: printf(" Y Axis is Up for this file \n" ); printf(" COLLADA_RT set to Y Up \n" ); - SetGravity(SimdVector3(0,-10,0)); - SetCameraInfo(SimdVector3(0,1,0),0); + SetGravity(btVector3(0,-10,0)); + SetCameraInfo(btVector3(0,1,0),0); break; case UPAXISTYPE_Z_UP: printf(" Z Axis is Up for this file \n" ); printf(" All Geometry and Hiearchies must be converted!\n" ); - SetGravity(SimdVector3(0,0,-10)); + SetGravity(btVector3(0,0,-10)); break; default: @@ -294,7 +294,7 @@ bool ColladaConverter::convert() const domFloat3 grav = physicsSceneRef->getTechnique_common()->getGravity()->getValue(); printf("gravity set to %f,%f,%f\n",grav.get(0),grav.get(1),grav.get(2)); - SetGravity(SimdVector3(grav.get(0),grav.get(1),grav.get(2))); + SetGravity(btVector3(grav.get(0),grav.get(1),grav.get(2))); } } @@ -324,8 +324,8 @@ bool ColladaConverter::convert() float mass = 1.f; bool isDynamics = true; - CollisionShape* colShape = 0; - CompoundShape* compoundShape = 0; + btCollisionShape* colShape = 0; + btCompoundShape* compoundShape = 0; xsNCName bodyName = instRigidbodyRef->getBody(); @@ -355,11 +355,11 @@ bool ColladaConverter::convert() { - RigidBodyOutput output; + btRigidBodyOutput output; output.m_colShape = colShape; output.m_compoundShape = compoundShape; - RigidBodyInput rbInput; + btRigidBodyInput rbInput; rbInput.m_rigidBodyRef2 = rigidBodyRef; rbInput.m_instanceRigidBodyRef = instRigidbodyRef; ConvertRigidBodyRef( rbInput , output ); @@ -380,7 +380,7 @@ bool ColladaConverter::convert() if (colShape) { - RigidBodyInput input; + btRigidBodyInput input; input.m_instanceRigidBodyRef = instRigidbodyRef; input.m_rigidBodyRef2 = 0; input.m_bodyName = (char*)bodyName; @@ -399,8 +399,8 @@ bool ColladaConverter::convert() float mass = 1.f; bool isDynamics = true; - CollisionShape* colShape = 0; - CompoundShape* compoundShape = 0; + btCollisionShape* colShape = 0; + btCompoundShape* compoundShape = 0; xsNCName bodyName = instRigidbodyRef->getBody(); @@ -430,11 +430,11 @@ bool ColladaConverter::convert() { - RigidBodyOutput output; + btRigidBodyOutput output; output.m_colShape = colShape; output.m_compoundShape = compoundShape; - RigidBodyInput rbInput; + btRigidBodyInput rbInput; rbInput.m_rigidBodyRef2 = rigidBodyRef; rbInput.m_instanceRigidBodyRef = instRigidbodyRef; ConvertRigidBodyRef( rbInput , output ); @@ -455,7 +455,7 @@ bool ColladaConverter::convert() if (colShape) { - RigidBodyInput input; + btRigidBodyInput input; input.m_instanceRigidBodyRef = instRigidbodyRef; input.m_rigidBodyRef2 = 0; input.m_bodyName = (char*)bodyName; @@ -560,31 +560,31 @@ void ColladaConverter::PrepareConstraints(ConstraintInput& input) const domRigid_constraint::domTechnique_commonRef commonRef = rigidConstraintRef->getTechnique_common(); domFloat3 flMin = commonRef->getLimits()->getLinear()->getMin()->getValue(); - SimdVector3 minLinearLimit(flMin.get(0),flMin.get(1),flMin.get(2)); + btVector3 minLinearLimit(flMin.get(0),flMin.get(1),flMin.get(2)); domFloat3 flMax = commonRef->getLimits()->getLinear()->getMax()->getValue(); - SimdVector3 maxLinearLimit(flMax.get(0),flMax.get(1),flMax.get(2)); + btVector3 maxLinearLimit(flMax.get(0),flMax.get(1),flMax.get(2)); domFloat3 coneMinLimit = commonRef->getLimits()->getSwing_cone_and_twist()->getMin()->getValue(); - SimdVector3 angularMin(coneMinLimit.get(0),coneMinLimit.get(1),coneMinLimit.get(2)); + btVector3 angularMin(coneMinLimit.get(0),coneMinLimit.get(1),coneMinLimit.get(2)); domFloat3 coneMaxLimit = commonRef->getLimits()->getSwing_cone_and_twist()->getMax()->getValue(); - SimdVector3 angularMax(coneMaxLimit.get(0),coneMaxLimit.get(1),coneMaxLimit.get(2)); + btVector3 angularMax(coneMaxLimit.get(0),coneMaxLimit.get(1),coneMaxLimit.get(2)); { int constraintId; - SimdTransform attachFrameRef0; + btTransform attachFrameRef0; attachFrameRef0 = - GetSimdTransformFromCOLLADA_DOM + GetbtTransformFromCOLLADA_DOM ( emptyMatrixArray, attachRefBody->getRotate_array(), attachRefBody->getTranslate_array()); - SimdTransform attachFrameOther; + btTransform attachFrameOther; attachFrameOther = - GetSimdTransformFromCOLLADA_DOM + GetbtTransformFromCOLLADA_DOM ( emptyMatrixArray, attachBody1->getRotate_array(), @@ -609,10 +609,10 @@ void ColladaConverter::PrepareConstraints(ConstraintInput& input) //limited means upper > lower //limitIndex: first 3 are linear, next 3 are angular - SimdVector3 linearLowerLimits = minLinearLimit; - SimdVector3 linearUpperLimits = maxLinearLimit; - SimdVector3 angularLowerLimits = angularMin; - SimdVector3 angularUpperLimits = angularMax; + btVector3 linearLowerLimits = minLinearLimit; + btVector3 linearUpperLimits = maxLinearLimit; + btVector3 angularLowerLimits = angularMin; + btVector3 angularUpperLimits = angularMax; { for (int i=0;i<3;i++) { @@ -665,11 +665,11 @@ void ColladaConverter::PrepareConstraints(ConstraintInput& input) } -void ColladaConverter::PreparePhysicsObject(struct RigidBodyInput& input, bool isDynamics, float mass,CollisionShape* colShape) +void ColladaConverter::PreparePhysicsObject(struct btRigidBodyInput& input, bool isDynamics, float mass,btCollisionShape* colShape) { - SimdTransform startTransform; + btTransform startTransform; startTransform.setIdentity(); - SimdVector3 startScale(1.f,1.f,1.f); + btVector3 startScale(1.f,1.f,1.f); //The 'target' points to a graphics element/node, which contains the start (world) transform daeElementRef elem = input.m_instanceRigidBodyRef->getTarget().getElement(); @@ -681,7 +681,7 @@ void ColladaConverter::PreparePhysicsObject(struct RigidBodyInput& input, bool i //find transform of the node that this rigidbody maps to - startTransform = GetSimdTransformFromCOLLADA_DOM( + startTransform = GetbtTransformFromCOLLADA_DOM( node->getMatrix_array(), node->getRotate_array(), node->getTranslate_array() @@ -692,7 +692,7 @@ void ColladaConverter::PreparePhysicsObject(struct RigidBodyInput& input, bool i { domScaleRef scaleRef = node->getScale_array()[i]; domFloat3 fl3 = scaleRef->getValue(); - startScale = SimdVector3(fl3.get(0),fl3.get(1),fl3.get(2)); + startScale = btVector3(fl3.get(0),fl3.get(1),fl3.get(2)); } } @@ -764,15 +764,15 @@ bool ColladaConverter::saveAs(const char* filename) } { - SimdQuaternion quat = m_physObjects[i]->GetRigidBody()->getCenterOfMassTransform().getRotation(); - SimdVector3 axis(quat.getX(),quat.getY(),quat.getZ()); + btQuaternion quat = m_physObjects[i]->GetRigidBody()->getCenterOfMassTransform().getRotation(); + btVector3 axis(quat.getX(),quat.getY(),quat.getZ()); axis[3] = 0.f; //check for axis length - SimdScalar len = axis.length2(); + btScalar len = axis.length2(); if (len < SIMD_EPSILON*SIMD_EPSILON) - axis = SimdVector3(1.f,0.f,0.f); + axis = btVector3(1.f,0.f,0.f); else - axis /= SimdSqrt(len); + axis /= btSqrt(len); m_colladadomNodes[i]->getRotate_array().get(0)->getValue().set(0,axis[0]); m_colladadomNodes[i]->getRotate_array().get(0)->getValue().set(1,axis[1]); m_colladadomNodes[i]->getRotate_array().get(0)->getValue().set(2,axis[2]); @@ -886,7 +886,7 @@ char* fixFileName(const char* lpCmdLine) } -void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOutput& rbOutput) +void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBodyOutput& rbOutput) { const domRigid_body::domTechnique_commonRef techniqueRef = rbInput.m_rigidBodyRef2->getTechnique_common(); @@ -913,9 +913,9 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut if (planeRef->getEquation()) { const domFloat4 planeEq = planeRef->getEquation()->getValue(); - SimdVector3 planeNormal(planeEq.get(0),planeEq.get(1),planeEq.get(2)); - SimdScalar planeConstant = planeEq.get(3); - rbOutput.m_colShape = new StaticPlaneShape(planeNormal,planeConstant); + btVector3 planeNormal(planeEq.get(0),planeEq.get(1),planeEq.get(2)); + btScalar planeConstant = planeEq.get(3); + rbOutput.m_colShape = new btStaticPlaneShape(planeNormal,planeConstant); } } @@ -928,14 +928,14 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut float x = halfExtents.get(0); float y = halfExtents.get(1); float z = halfExtents.get(2); - rbOutput.m_colShape = new BoxShape(SimdVector3(x,y,z)); + rbOutput.m_colShape = new btBoxShape(btVector3(x,y,z)); } if (shapeRef->getSphere()) { domSphereRef sphereRef = shapeRef->getSphere(); domSphere::domRadiusRef radiusRef = sphereRef->getRadius(); domFloat radius = radiusRef->getValue(); - rbOutput.m_colShape = new SphereShape(radius); + rbOutput.m_colShape = new btSphereShape(radius); } if (shapeRef->getCylinder()) @@ -946,7 +946,7 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut domFloat radius0 = radius2.get(0); //Cylinder around the local Y axis - rbOutput.m_colShape = new CylinderShape(SimdVector3(radius0,height,radius0)); + rbOutput.m_colShape = new btCylinderShape(btVector3(radius0,height,radius0)); } @@ -960,7 +960,7 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut { const domMeshRef meshRef = geom->getMesh(); - TriangleMesh* trimesh = new TriangleMesh(); + btTriangleMesh* trimesh = new btTriangleMesh(); for (unsigned int tg = 0;tggetTriangles_array().getCount();tg++) @@ -969,7 +969,7 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut domTrianglesRef triRef = meshRef->getTriangles_array()[tg]; const domPRef pRef = triRef->getP(); - IndexedMesh meshPart; + btIndexedMesh meshPart; meshPart.m_triangleIndexStride=0; @@ -1024,7 +1024,7 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut int vertexStride = 3;//instead of hardcoded stride, should use the 'accessor' for (;t not supported, transformed into convex\n"); - rbOutput.m_colShape = new ConvexTriangleMeshShape(trimesh); + rbOutput.m_colShape = new btConvexTriangleMeshShape(trimesh); } else { printf("static concave triangle added\n"); - rbOutput.m_colShape = new TriangleMeshShape(trimesh); + rbOutput.m_colShape = new btTriangleMeshShape(trimesh); } } @@ -1086,7 +1086,7 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut - ConvexHullShape* convexHullShape = new ConvexHullShape(0,0); + btConvexHullShape* convexHullShape = new btConvexHullShape(0,0); //it is quite a trick to get to the vertices, using Collada. //we are not there yet... @@ -1144,7 +1144,7 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut domFloat fl2 = listFloats.get(k+2); //printf("float %f %f %f\n",fl0,fl1,fl2); - convexHullShape->AddPoint(SimdPoint3(fl0,fl1,fl2)); + convexHullShape->AddPoint(btPoint3(fl0,fl1,fl2)); } } @@ -1192,7 +1192,7 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut domFloat fl2 = listFloats.get(k+2); //printf("float %f %f %f\n",fl0,fl1,fl2); - convexHullShape->AddPoint(SimdPoint3(fl0,fl1,fl2)); + convexHullShape->AddPoint(btPoint3(fl0,fl1,fl2)); } } @@ -1237,14 +1237,14 @@ void ColladaConverter::ConvertRigidBodyRef( RigidBodyInput& rbInput,RigidBodyOut if (!rbOutput.m_compoundShape) { - rbOutput.m_compoundShape = new CompoundShape(); + rbOutput.m_compoundShape = new btCompoundShape(); } - SimdTransform localTransform; + btTransform localTransform; localTransform.setIdentity(); if (hasShapeLocalTransform) { - localTransform = GetSimdTransformFromCOLLADA_DOM( + localTransform = GetbtTransformFromCOLLADA_DOM( emptyMatrixArray, shapeRef->getRotate_array(), shapeRef->getTranslate_array() diff --git a/Demos/ColladaDemo/ColladaConverter.h b/Demos/ColladaDemo/ColladaConverter.h index 33526e90b..554e5c7bf 100644 --- a/Demos/ColladaDemo/ColladaConverter.h +++ b/Demos/ColladaDemo/ColladaConverter.h @@ -18,10 +18,10 @@ subject to the following restrictions: #ifndef COLLADA_CONVERTER_H #define COLLADA_CONVERTER_H -#include "LinearMath/SimdTransform.h" -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btTransform.h" +#include "LinearMath/btVector3.h" -class CollisionShape; +class btCollisionShape; class PHY_IPhysicsController; class CcdPhysicsController; class ConstraintInput; @@ -44,11 +44,11 @@ protected: int m_numObjects; CcdPhysicsController* m_physObjects[COLLADA_CONVERTER_MAX_NUM_OBJECTS]; - void PreparePhysicsObject(struct RigidBodyInput& input, bool isDynamics, float mass,CollisionShape* colShape); + void PreparePhysicsObject(struct btRigidBodyInput& input, bool isDynamics, float mass,btCollisionShape* colShape); void PrepareConstraints(ConstraintInput& input); - void ConvertRigidBodyRef( struct RigidBodyInput& , struct RigidBodyOutput& output ); + void ConvertRigidBodyRef( struct btRigidBodyInput& , struct btRigidBodyOutput& output ); public: @@ -68,22 +68,22 @@ public: ///those 2 virtuals are called for each constraint/physics object virtual int createUniversalD6Constraint( class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther, - SimdTransform& localAttachmentFrameRef, - SimdTransform& localAttachmentOther, - const SimdVector3& linearMinLimits, - const SimdVector3& linearMaxLimits, - const SimdVector3& angularMinLimits, - const SimdVector3& angularMaxLimits + btTransform& localAttachmentFrameRef, + btTransform& localAttachmentOther, + const btVector3& linearMinLimits, + const btVector3& linearMaxLimits, + const btVector3& angularMinLimits, + const btVector3& angularMaxLimits ) = 0; virtual CcdPhysicsController* CreatePhysicsObject(bool isDynamic, float mass, - const SimdTransform& startTransform, - CollisionShape* shape) = 0; + const btTransform& startTransform, + btCollisionShape* shape) = 0; - virtual void SetGravity(const SimdVector3& gravity) = 0; + virtual void SetGravity(const btVector3& gravity) = 0; - virtual void SetCameraInfo(const SimdVector3& up, int forwardAxis) = 0; + virtual void SetCameraInfo(const btVector3& up, int forwardAxis) = 0; }; diff --git a/Demos/ColladaDemo/ColladaDemo.cpp b/Demos/ColladaDemo/ColladaDemo.cpp index 6e07c531e..8984bf47f 100644 --- a/Demos/ColladaDemo/ColladaDemo.cpp +++ b/Demos/ColladaDemo/ColladaDemo.cpp @@ -16,8 +16,8 @@ subject to the following restrictions: #include "CcdPhysicsEnvironment.h" #include "CcdPhysicsController.h" #include "btBulletDynamicsCommon.h" -#include "LinearMath/GenQuickprof.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btQuickprof.h" +#include "LinearMath/btIDebugDraw.h" #include "GLDebugDrawer.h" @@ -50,12 +50,12 @@ class MyColladaConverter : public ColladaConverter ///those 2 virtuals are called for each constraint/physics object virtual int createUniversalD6Constraint( class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther, - SimdTransform& localAttachmentFrameRef, - SimdTransform& localAttachmentOther, - const SimdVector3& linearMinLimits, - const SimdVector3& linearMaxLimits, - const SimdVector3& angularMinLimits, - const SimdVector3& angularMaxLimits + btTransform& localAttachmentFrameRef, + btTransform& localAttachmentOther, + const btVector3& linearMinLimits, + const btVector3& linearMaxLimits, + const btVector3& angularMinLimits, + const btVector3& angularMaxLimits ) { return m_demoApp->GetPhysicsEnvironment()->createUniversalD6Constraint( @@ -71,19 +71,19 @@ class MyColladaConverter : public ColladaConverter virtual CcdPhysicsController* CreatePhysicsObject(bool isDynamic, float mass, - const SimdTransform& startTransform, - CollisionShape* shape) + const btTransform& startTransform, + btCollisionShape* shape) { CcdPhysicsController* ctrl = m_demoApp->LocalCreatePhysicsObject(isDynamic, mass, startTransform,shape); return ctrl; } - virtual void SetGravity(const SimdVector3& grav) + virtual void SetGravity(const btVector3& grav) { m_demoApp->GetPhysicsEnvironment()->setGravity(grav.getX(),grav.getY(),grav.getZ()); } - virtual void SetCameraInfo(const SimdVector3& camUp,int forwardAxis) + virtual void SetCameraInfo(const btVector3& camUp,int forwardAxis) { m_demoApp->setCameraUp(camUp); m_demoApp->setCameraForwardAxis(forwardAxis); @@ -138,15 +138,15 @@ int main(int argc,char** argv) void ColladaDemo::initPhysics(const char* filename) { - m_cameraUp = SimdVector3(0,0,1); + m_cameraUp = btVector3(0,0,1); m_forwardAxis = 1; ///Setup a Physics Simulation Environment - CollisionDispatcher* dispatcher = new CollisionDispatcher(); - SimdVector3 worldAabbMin(-10000,-10000,-10000); - SimdVector3 worldAabbMax(10000,10000,10000); - OverlappingPairCache* broadphase = new AxisSweep3(worldAabbMin,worldAabbMax); - //BroadphaseInterface* broadphase = new SimpleBroadphase(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(); + btVector3 worldAabbMin(-10000,-10000,-10000); + btVector3 worldAabbMax(10000,10000,10000); + btOverlappingPairCache* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax); + //BroadphaseInterface* broadphase = new btSimpleBroadphase(); m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase); m_physicsEnvironmentPtr->setDeactivationTime(2.f); m_physicsEnvironmentPtr->setGravity(0,0,-10); diff --git a/Demos/CollisionDemo/CollisionDemo.cpp b/Demos/CollisionDemo/CollisionDemo.cpp index ee4cc9323..49b9d90a4 100644 --- a/Demos/CollisionDemo/CollisionDemo.cpp +++ b/Demos/CollisionDemo/CollisionDemo.cpp @@ -16,15 +16,15 @@ subject to the following restrictions: /// /// Collision Demo shows a degenerate case, where the Simplex solver has to deal with near-affine dependent cases -/// See the define CATCH_DEGENERATE_TETRAHEDRON in Bullet's VoronoiSimplexSolver.cpp +/// See the define CATCH_DEGENERATE_TETRAHEDRON in Bullet's btVoronoiSimplexSolver.cpp /// ///This low-level internal demo does intentionally NOT use the btBulletCollisionCommon.h header ///It needs internal access #include "GL_Simplex1to4.h" -#include "LinearMath/SimdQuaternion.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btQuaternion.h" +#include "LinearMath/btTransform.h" #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" #include "BulletCollision/CollisionShapes/btBoxShape.h" #include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" @@ -35,7 +35,7 @@ subject to the following restrictions: #include "CollisionDemo.h" #include "GL_ShapeDrawer.h" #include "GlutStuff.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" float yaw=0.f,pitch=0.f,roll=0.f; @@ -44,9 +44,9 @@ const int numObjects = 2; GL_Simplex1to4 simplex; -PolyhedralConvexShape* shapePtr[maxNumObjects]; +btPolyhedralConvexShape* shapePtr[maxNumObjects]; -SimdTransform tr[numObjects]; +btTransform tr[numObjects]; int screenWidth = 640; int screenHeight = 480; @@ -70,22 +70,22 @@ int main(int argc,char** argv) void CollisionDemo::initPhysics() { - m_debugMode |= IDebugDraw::DBG_DrawWireframe; + m_debugMode |= btIDebugDraw::DBG_DrawWireframe; m_azi = 250.f; m_ele = 25.f; - tr[0].setOrigin(SimdVector3(0.0013328250f,8.1363249f,7.0390840f)); - tr[1].setOrigin(SimdVector3(0.00000000f,9.1262732f,2.0343180f)); + tr[0].setOrigin(btVector3(0.0013328250f,8.1363249f,7.0390840f)); + tr[1].setOrigin(btVector3(0.00000000f,9.1262732f,2.0343180f)); - //tr[0].setOrigin(SimdVector3(0,0,0)); - //tr[1].setOrigin(SimdVector3(0,10,0)); + //tr[0].setOrigin(btVector3(0,0,0)); + //tr[1].setOrigin(btVector3(0,10,0)); - SimdMatrix3x3 basisA; + btMatrix3x3 basisA; basisA.setValue(0.99999958f,0.00022980258f,0.00090992288f, -0.00029313788f,0.99753088f,0.070228584f, -0.00089153741f,-0.070228823f,0.99753052f); - SimdMatrix3x3 basisB; + btMatrix3x3 basisB; basisB.setValue(1.0000000f,4.4865553e-018f,-4.4410586e-017f, 4.4865495e-018f,0.97979438f,0.20000751f, 4.4410586e-017f,-0.20000751f,0.97979438f); @@ -95,11 +95,11 @@ void CollisionDemo::initPhysics() - SimdVector3 boxHalfExtentsA(1.0000004768371582f,1.0000004768371582f,1.0000001192092896f); - SimdVector3 boxHalfExtentsB(3.2836332321166992f,3.2836332321166992f,3.2836320400238037f); + btVector3 boxHalfExtentsA(1.0000004768371582f,1.0000004768371582f,1.0000001192092896f); + btVector3 boxHalfExtentsB(3.2836332321166992f,3.2836332321166992f,3.2836320400238037f); - BoxShape* boxA = new BoxShape(boxHalfExtentsA); - BoxShape* boxB = new BoxShape(boxHalfExtentsB); + btBoxShape* boxA = new btBoxShape(boxHalfExtentsA); + btBoxShape* boxB = new btBoxShape(boxHalfExtentsB); shapePtr[0] = boxA; shapePtr[1] = boxB; @@ -112,8 +112,8 @@ void CollisionDemo::clientMoveAndDisplay() } -static VoronoiSimplexSolver sGjkSimplexSolver; -SimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver; +static btVoronoiSimplexSolver sGjkSimplexSolver; +btSimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver; @@ -127,13 +127,13 @@ void CollisionDemo::displayCallback(void) { float m[16]; int i; - GjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0); + btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0); - SimdVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f); + btVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f); convexConvex.SetCachedSeperatingAxis(seperatingAxis); - PointCollector gjkOutput; - GjkPairDetector::ClosestPointInput input; + btPointCollector gjkOutput; + btGjkPairDetector::ClosestPointInput input; input.m_transformA = tr[0]; input.m_transformB = tr[1]; @@ -141,7 +141,7 @@ void CollisionDemo::displayCallback(void) { if (gjkOutput.m_hasResult) { - SimdVector3 endPt = gjkOutput.m_pointInWorld + + btVector3 endPt = gjkOutput.m_pointInWorld + gjkOutput.m_normalOnBInWorld*gjkOutput.m_distance; glBegin(GL_LINES); @@ -159,26 +159,26 @@ void CollisionDemo::displayCallback(void) { tr[i].getOpenGLMatrix( m ); - GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],SimdVector3(1,1,1),getDebugMode()); + GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode()); } simplex.SetSimplexSolver(&sGjkSimplexSolver); - SimdPoint3 ybuf[4],pbuf[4],qbuf[4]; + btPoint3 ybuf[4],pbuf[4],qbuf[4]; int numpoints = sGjkSimplexSolver.getSimplex(pbuf,qbuf,ybuf); simplex.Reset(); for (i=0;iAddCollisionObject(&objects[0]); collisionWorld->AddCollisionObject(&objects[1]); @@ -107,8 +107,8 @@ void CollisionInterfaceDemo::clientMoveAndDisplay() } -static VoronoiSimplexSolver sGjkSimplexSolver; -SimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver; +static btVoronoiSimplexSolver sGjkSimplexSolver; +btSimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver; @@ -127,21 +127,21 @@ void CollisionInterfaceDemo::displayCallback(void) { int numManifolds = collisionWorld->GetDispatcher()->GetNumManifolds(); for (i=0;iGetDispatcher()->GetManifoldByIndexInternal(i); - CollisionObject* obA = static_cast(contactManifold->GetBody0()); - CollisionObject* obB = static_cast(contactManifold->GetBody1()); + btPersistentManifold* contactManifold = collisionWorld->GetDispatcher()->GetManifoldByIndexInternal(i); + btCollisionObject* obA = static_cast(contactManifold->GetBody0()); + btCollisionObject* obB = static_cast(contactManifold->GetBody1()); contactManifold->RefreshContactPoints(obA->m_worldTransform,obB->m_worldTransform); int numContacts = contactManifold->GetNumContacts(); for (int j=0;jGetContactPoint(j); + btManifoldPoint& pt = contactManifold->GetContactPoint(j); glBegin(GL_LINES); glColor3f(1, 0, 1); - SimdVector3 ptA = pt.GetPositionWorldOnA(); - SimdVector3 ptB = pt.GetPositionWorldOnB(); + btVector3 ptA = pt.GetPositionWorldOnA(); + btVector3 ptB = pt.GetPositionWorldOnB(); glVertex3d(ptA.x(),ptA.y(),ptA.z()); glVertex3d(ptB.x(),ptB.y(),ptB.z()); @@ -162,14 +162,14 @@ void CollisionInterfaceDemo::displayCallback(void) { { objects[i].m_worldTransform.getOpenGLMatrix( m ); - GL_ShapeDrawer::DrawOpenGL(m,objects[i].m_collisionShape,SimdVector3(1,1,1),getDebugMode()); + GL_ShapeDrawer::DrawOpenGL(m,objects[i].m_collisionShape,btVector3(1,1,1),getDebugMode()); } - SimdQuaternion orn; + btQuaternion orn; orn.setEuler(yaw,pitch,roll); - objects[1].m_worldTransform.setOrigin(objects[1].m_worldTransform.getOrigin()+SimdVector3(0,-0.01,0)); + objects[1].m_worldTransform.setOrigin(objects[1].m_worldTransform.getOrigin()+btVector3(0,-0.01,0)); objects[0].m_worldTransform.setRotation(orn); @@ -182,8 +182,8 @@ void CollisionInterfaceDemo::displayCallback(void) { void CollisionInterfaceDemo::clientResetScene() { - objects[0].m_worldTransform.setOrigin(SimdVector3(0.0f,3.f,0.f)); - objects[1].m_worldTransform.setOrigin(SimdVector3(0.0f,9.f,0.f)); + objects[0].m_worldTransform.setOrigin(btVector3(0.0f,3.f,0.f)); + objects[1].m_worldTransform.setOrigin(btVector3(0.0f,9.f,0.f)); } diff --git a/Demos/CollisionInterfaceDemo/CollisionInterfaceDemo.h b/Demos/CollisionInterfaceDemo/CollisionInterfaceDemo.h index 28b0cd414..6ec45cb55 100644 --- a/Demos/CollisionInterfaceDemo/CollisionInterfaceDemo.h +++ b/Demos/CollisionInterfaceDemo/CollisionInterfaceDemo.h @@ -17,7 +17,7 @@ subject to the following restrictions: #include "DemoApplication.h" -///CollisionInterfaceDemo shows how to use the collision detection without dynamics (CollisionWorld/CollisionObject) +///CollisionInterfaceDemo shows how to use the collision detection without dynamics (btCollisionWorld/CollisionObject) class CollisionInterfaceDemo : public DemoApplication { public: diff --git a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp index 0835c97ad..d6891f256 100644 --- a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp +++ b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp @@ -17,7 +17,7 @@ subject to the following restrictions: #include "CcdPhysicsController.h" #include "MyMotionState.h" #include "btBulletDynamicsCommon.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" #include "GLDebugDrawer.h" #include "PHY_Pro.h" #include "ConcaveDemo.h" @@ -30,17 +30,17 @@ GLDebugDrawer debugDrawer; static const int NUM_VERTICES = 5; static const int NUM_TRIANGLES=4; -SimdVector3 gVertices[NUM_VERTICES]; +btVector3 gVertices[NUM_VERTICES]; int gIndices[NUM_TRIANGLES*3]; const float TRIANGLE_SIZE=80.f; -///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= CollisionObject::customMaterialCallback; -inline SimdScalar calculateCombinedFriction(float friction0,float friction1) +///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback; +inline btScalar calculateCombinedFriction(float friction0,float friction1) { - SimdScalar friction = friction0 * friction1; + btScalar friction = friction0 * friction1; - const SimdScalar MAX_FRICTION = 10.f; + const btScalar MAX_FRICTION = 10.f; if (friction < -MAX_FRICTION) friction = -MAX_FRICTION; if (friction > MAX_FRICTION) @@ -49,14 +49,14 @@ inline SimdScalar calculateCombinedFriction(float friction0,float friction1) } -inline SimdScalar calculateCombinedRestitution(float restitution0,float restitution1) +inline btScalar calculateCombinedRestitution(float restitution0,float restitution1) { return restitution0 * restitution1; } -bool CustomMaterialCombinerCallback(ManifoldPoint& cp, const CollisionObject* colObj0,int partId0,int index0,const CollisionObject* colObj1,int partId1,int index1) +bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1) { float friction0 = colObj0->getFriction(); @@ -64,12 +64,12 @@ bool CustomMaterialCombinerCallback(ManifoldPoint& cp, const CollisionObject* co float restitution0 = colObj0->getRestitution(); float restitution1 = colObj1->getRestitution(); - if (colObj0->m_collisionFlags & CollisionObject::customMaterialCallback) + if (colObj0->m_collisionFlags & btCollisionObject::customMaterialCallback) { friction0 = 1.0;//partId0,index0 restitution0 = 0.f; } - if (colObj1->m_collisionFlags & CollisionObject::customMaterialCallback) + if (colObj1->m_collisionFlags & btCollisionObject::customMaterialCallback) { if (index1&1) { @@ -107,7 +107,7 @@ void ConcaveDemo::initPhysics() { #define TRISIZE 10.f - int vertStride = sizeof(SimdVector3); + int vertStride = sizeof(btVector3); int indexStride = 3*sizeof(int); const int NUM_VERTS_X = 50; @@ -116,7 +116,7 @@ void ConcaveDemo::initPhysics() const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1); - SimdVector3* gVertices = new SimdVector3[totalVerts]; + btVector3* gVertices = new btVector3[totalVerts]; int* gIndices = new int[totalTriangles*3]; int i; @@ -144,39 +144,39 @@ void ConcaveDemo::initPhysics() } } - TriangleIndexVertexArray* indexVertexArrays = new TriangleIndexVertexArray(totalTriangles, + btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles, gIndices, indexStride, totalVerts,(float*) &gVertices[0].x(),vertStride); - CollisionShape* trimeshShape = new BvhTriangleMeshShape(indexVertexArrays); + btCollisionShape* trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays); - // ConstraintSolver* solver = new SequentialImpulseConstraintSolver; + // btConstraintSolver* solver = new btSequentialImpulseConstraintSolver; - CollisionDispatcher* dispatcher = new CollisionDispatcher(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(); - OverlappingPairCache* broadphase = new SimpleBroadphase(); + btOverlappingPairCache* broadphase = new btSimpleBroadphase(); m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase); bool isDynamic = false; float mass = 0.f; - SimdTransform startTransform; + btTransform startTransform; startTransform.setIdentity(); - startTransform.setOrigin(SimdVector3(0,-2,0)); + startTransform.setOrigin(btVector3(0,-2,0)); CcdPhysicsController* staticTrimesh = LocalCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape); //enable custom material callback - staticTrimesh->GetRigidBody()->m_collisionFlags |= CollisionObject::customMaterialCallback; + staticTrimesh->GetRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback; { for (int i=0;i<10;i++) { - CollisionShape* boxShape = new BoxShape(SimdVector3(1,1,1)); - startTransform.setOrigin(SimdVector3(2*i,1,1)); + btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1)); + startTransform.setOrigin(btVector3(2*i,1,1)); LocalCreatePhysicsObject(true, 1, startTransform,boxShape); } } diff --git a/Demos/ConcaveDemo/MyMotionState.cpp b/Demos/ConcaveDemo/MyMotionState.cpp index 4699dd718..fe3636d5d 100644 --- a/Demos/ConcaveDemo/MyMotionState.cpp +++ b/Demos/ConcaveDemo/MyMotionState.cpp @@ -14,7 +14,7 @@ subject to the following restrictions: */ #include "MyMotionState.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btPoint3.h" MyMotionState::MyMotionState() { @@ -51,13 +51,13 @@ void MyMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& q void MyMotionState::setWorldPosition(float posX,float posY,float posZ) { - SimdPoint3 pos(posX,posY,posZ); + btPoint3 pos(posX,posY,posZ); m_worldTransform.setOrigin( pos ); } void MyMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) { - SimdQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); + btQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); m_worldTransform.setRotation( orn ); } diff --git a/Demos/ConcaveDemo/MyMotionState.h b/Demos/ConcaveDemo/MyMotionState.h index cbf9988e2..7aa7c8520 100644 --- a/Demos/ConcaveDemo/MyMotionState.h +++ b/Demos/ConcaveDemo/MyMotionState.h @@ -17,7 +17,7 @@ subject to the following restrictions: #define MY_MOTIONSTATE_H #include "PHY_IMotionState.h" -#include +#include class MyMotionState : public PHY_IMotionState @@ -37,7 +37,7 @@ class MyMotionState : public PHY_IMotionState virtual void calculateWorldTransformations(); - SimdTransform m_worldTransform; + btTransform m_worldTransform; }; diff --git a/Demos/ConstraintDemo/ConstraintDemo.cpp b/Demos/ConstraintDemo/ConstraintDemo.cpp index dfc42d98d..c605dbb7c 100644 --- a/Demos/ConstraintDemo/ConstraintDemo.cpp +++ b/Demos/ConstraintDemo/ConstraintDemo.cpp @@ -17,7 +17,7 @@ subject to the following restrictions: #include "CcdPhysicsController.h" #include "MyMotionState.h" #include "btBulletDynamicsCommon.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" #include "GLDebugDrawer.h" @@ -53,12 +53,12 @@ int main(int argc,char** argv) void ConstraintDemo::initPhysics() { - //ConstraintSolver* solver = new SequentialImpulseConstraintSolver; + //ConstraintSolver* solver = new btSequentialImpulseConstraintSolver; //ConstraintSolver* solver = new OdeConstraintSolver; - CollisionDispatcher* dispatcher = new CollisionDispatcher(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(); - OverlappingPairCache* broadphase = new SimpleBroadphase(); + btOverlappingPairCache* broadphase = new btSimpleBroadphase(); m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase); @@ -66,16 +66,16 @@ void ConstraintDemo::initPhysics() m_physicsEnvironmentPtr->setGravity(0,-10,0); - CollisionShape* shape = new BoxShape(SimdVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)); - SimdTransform trans; + btCollisionShape* shape = new btBoxShape(btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)); + btTransform trans; trans.setIdentity(); - trans.setOrigin(SimdVector3(0,20,0)); + trans.setOrigin(btVector3(0,20,0)); bool isDynamic = false; float mass = 1.f; CcdPhysicsController* ctrl0 = LocalCreatePhysicsObject( isDynamic,mass,trans,shape); - trans.setOrigin(SimdVector3(2*CUBE_HALF_EXTENTS,20,0)); + trans.setOrigin(btVector3(2*CUBE_HALF_EXTENTS,20,0)); isDynamic = true; CcdPhysicsController* ctrl1 = LocalCreatePhysicsObject( isDynamic,mass,trans,shape); diff --git a/Demos/ConstraintDemo/ConstraintDemo.h b/Demos/ConstraintDemo/ConstraintDemo.h index 229fa4382..7fb9c7e13 100644 --- a/Demos/ConstraintDemo/ConstraintDemo.h +++ b/Demos/ConstraintDemo/ConstraintDemo.h @@ -17,7 +17,7 @@ subject to the following restrictions: #include "DemoApplication.h" -///ConstraintDemo shows how to create a constraint, like Hinge or GenericD6constraint +///ConstraintDemo shows how to create a constraint, like Hinge or btGenericD6constraint class ConstraintDemo : public DemoApplication { public: diff --git a/Demos/ConstraintDemo/MyMotionState.cpp b/Demos/ConstraintDemo/MyMotionState.cpp index 4699dd718..fe3636d5d 100644 --- a/Demos/ConstraintDemo/MyMotionState.cpp +++ b/Demos/ConstraintDemo/MyMotionState.cpp @@ -14,7 +14,7 @@ subject to the following restrictions: */ #include "MyMotionState.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btPoint3.h" MyMotionState::MyMotionState() { @@ -51,13 +51,13 @@ void MyMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& q void MyMotionState::setWorldPosition(float posX,float posY,float posZ) { - SimdPoint3 pos(posX,posY,posZ); + btPoint3 pos(posX,posY,posZ); m_worldTransform.setOrigin( pos ); } void MyMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) { - SimdQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); + btQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); m_worldTransform.setRotation( orn ); } diff --git a/Demos/ConstraintDemo/MyMotionState.h b/Demos/ConstraintDemo/MyMotionState.h index cbf9988e2..7aa7c8520 100644 --- a/Demos/ConstraintDemo/MyMotionState.h +++ b/Demos/ConstraintDemo/MyMotionState.h @@ -17,7 +17,7 @@ subject to the following restrictions: #define MY_MOTIONSTATE_H #include "PHY_IMotionState.h" -#include +#include class MyMotionState : public PHY_IMotionState @@ -37,7 +37,7 @@ class MyMotionState : public PHY_IMotionState virtual void calculateWorldTransformations(); - SimdTransform m_worldTransform; + btTransform m_worldTransform; }; diff --git a/Demos/ContinuousConvexCollision/ContinuousConvexCollision.h b/Demos/ContinuousConvexCollision/ContinuousConvexCollision.h index da3316c66..e2fd0642a 100644 --- a/Demos/ContinuousConvexCollision/ContinuousConvexCollision.h +++ b/Demos/ContinuousConvexCollision/ContinuousConvexCollision.h @@ -18,7 +18,7 @@ subject to the following restrictions: #include "DemoApplication.h" ///ContinuousConvexCollisionDemo shows the working of the continuous collision detection, including linear and angular motion -class ContinuousConvexCollisionDemo : public DemoApplication +class btContinuousConvexCollisionDemo : public DemoApplication { public: diff --git a/Demos/ContinuousConvexCollision/ContinuousConvexCollisionDemo.cpp b/Demos/ContinuousConvexCollision/ContinuousConvexCollisionDemo.cpp index f0490b6e6..b412e0df3 100644 --- a/Demos/ContinuousConvexCollision/ContinuousConvexCollisionDemo.cpp +++ b/Demos/ContinuousConvexCollision/ContinuousConvexCollisionDemo.cpp @@ -20,8 +20,8 @@ ///This low level demo need internal access, and intentionally doesn't include the btBulletCollisionCommon.h headerfile -#include "LinearMath/SimdQuaternion.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btQuaternion.h" +#include "LinearMath/btTransform.h" #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" #include "BulletCollision/CollisionShapes/btBoxShape.h" #include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h" @@ -31,7 +31,7 @@ #include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" #include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h" -#include "LinearMath/SimdTransformUtil.h" +#include "LinearMath/btTransformUtil.h" #include "DebugCastResult.h" #include "BulletCollision/CollisionShapes/btSphereShape.h" @@ -50,14 +50,14 @@ float yaw=0.f,pitch=0.f,roll=0.f; const int maxNumObjects = 4; const int numObjects = 2; -SimdVector3 angVels[numObjects]; -SimdVector3 linVels[numObjects]; +btVector3 angVels[numObjects]; +btVector3 linVels[numObjects]; -PolyhedralConvexShape* shapePtr[maxNumObjects]; +btPolyhedralConvexShape* shapePtr[maxNumObjects]; -SimdTransform fromTrans[maxNumObjects]; -SimdTransform toTrans[maxNumObjects]; +btTransform fromTrans[maxNumObjects]; +btTransform toTrans[maxNumObjects]; int screenWidth = 640; @@ -66,7 +66,7 @@ int screenHeight = 480; int main(int argc,char** argv) { - ContinuousConvexCollisionDemo* ccdDemo = new ContinuousConvexCollisionDemo(); + btContinuousConvexCollisionDemo* ccdDemo = new btContinuousConvexCollisionDemo(); ccdDemo->setCameraDistance(40.f); @@ -75,17 +75,17 @@ int main(int argc,char** argv) return glutmain(argc, argv,screenWidth,screenHeight,"Continuous Convex Collision Demo",ccdDemo); } -void ContinuousConvexCollisionDemo::initPhysics() +void btContinuousConvexCollisionDemo::initPhysics() { - fromTrans[0].setOrigin(SimdVector3(0,10,20)); - toTrans[0].setOrigin(SimdVector3(0,10,-20)); - fromTrans[1].setOrigin(SimdVector3(-2,7,0)); - toTrans[1].setOrigin(SimdVector3(-2,10,0)); + fromTrans[0].setOrigin(btVector3(0,10,20)); + toTrans[0].setOrigin(btVector3(0,10,-20)); + fromTrans[1].setOrigin(btVector3(-2,7,0)); + toTrans[1].setOrigin(btVector3(-2,10,0)); - SimdMatrix3x3 identBasis; + btMatrix3x3 identBasis; identBasis.setIdentity(); - SimdMatrix3x3 basisA; + btMatrix3x3 basisA; basisA.setIdentity(); basisA.setEulerZYX(0.f,-SIMD_HALF_PI,0.f); @@ -96,15 +96,15 @@ void ContinuousConvexCollisionDemo::initPhysics() toTrans[1].setBasis(identBasis); toTrans[1].setBasis(identBasis); - SimdVector3 boxHalfExtentsA(10,1,1); - SimdVector3 boxHalfExtentsB(1.1f,1.1f,1.1f); - BoxShape* boxA = new BoxShape(boxHalfExtentsA); -// BU_Simplex1to4* boxA = new BU_Simplex1to4(SimdPoint3(-2,0,-2),SimdPoint3(2,0,-2),SimdPoint3(0,0,2),SimdPoint3(0,2,0)); -// BU_Simplex1to4* boxA = new BU_Simplex1to4(SimdPoint3(-12,0,0),SimdPoint3(12,0,0)); + btVector3 boxHalfExtentsA(10,1,1); + btVector3 boxHalfExtentsB(1.1f,1.1f,1.1f); + btBoxShape* boxA = new btBoxShape(boxHalfExtentsA); +// btBU_Simplex1to4* boxA = new btBU_Simplex1to4(btPoint3(-2,0,-2),btPoint3(2,0,-2),btPoint3(0,0,2),btPoint3(0,2,0)); +// btBU_Simplex1to4* boxA = new btBU_Simplex1to4(btPoint3(-12,0,0),btPoint3(12,0,0)); - BoxShape* boxB = new BoxShape(boxHalfExtentsB); -// BU_Simplex1to4 boxB(SimdPoint3(0,10,0),SimdPoint3(0,-10,0)); + btBoxShape* boxB = new btBoxShape(boxHalfExtentsB); +// btBU_Simplex1to4 boxB(btPoint3(0,10,0),btPoint3(0,-10,0)); shapePtr[0] = boxA; @@ -115,22 +115,22 @@ void ContinuousConvexCollisionDemo::initPhysics() for (int i=0;im_fraction,hitTrans); + btTransform hitTrans; + btTransformUtil::IntegrateTransform(fromTrans[0],linVels[0],angVels[0],rayResultPtr->m_fraction,hitTrans); hitTrans.getOpenGLMatrix(m); - GL_ShapeDrawer::DrawOpenGL(m,shapePtr[0],SimdVector3(0,1,0),getDebugMode()); + GL_ShapeDrawer::DrawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode()); - SimdTransformUtil::IntegrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans); + btTransformUtil::IntegrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans); hitTrans.getOpenGLMatrix(m); - GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],SimdVector3(0,1,1),getDebugMode()); + GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode()); } diff --git a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp index 21f576e80..f888be7e4 100644 --- a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp +++ b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp @@ -21,8 +21,8 @@ subject to the following restrictions: #include "CcdPhysicsController.h" #include "btBulletDynamicsCommon.h" -#include "LinearMath/GenQuickprof.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btQuickprof.h" +#include "LinearMath/btIDebugDraw.h" #include "GLDebugDrawer.h" @@ -42,11 +42,11 @@ const int maxNumObjects = 450; int shapeIndex[maxNumObjects]; -SimdVector3 centroid; +btVector3 centroid; #define CUBE_HALF_EXTENTS 4 -CollisionShape* shapePtr[maxNumObjects]; +btCollisionShape* shapePtr[maxNumObjects]; @@ -81,25 +81,25 @@ void ConvexDecompositionDemo::initPhysics(const char* filename) tcount = wo.loadObj(filename); - CollisionDispatcher* dispatcher = new CollisionDispatcher(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(); - SimdVector3 worldAabbMin(-10000,-10000,-10000); - SimdVector3 worldAabbMax(10000,10000,10000); + btVector3 worldAabbMin(-10000,-10000,-10000); + btVector3 worldAabbMax(10000,10000,10000); - OverlappingPairCache* broadphase = new AxisSweep3(worldAabbMin,worldAabbMax); - //OverlappingPairCache* broadphase = new SimpleBroadphase(); + btOverlappingPairCache* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax); + //OverlappingPairCache* broadphase = new btSimpleBroadphase(); m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase); m_physicsEnvironmentPtr->setDeactivationTime(2.f); m_physicsEnvironmentPtr->setGravity(0,-10,0); - SimdTransform startTransform; + btTransform startTransform; startTransform.setIdentity(); - startTransform.setOrigin(SimdVector3(0,-4,0)); + startTransform.setOrigin(btVector3(0,-4,0)); - LocalCreatePhysicsObject(false,0,startTransform,new BoxShape(SimdVector3(30,2,30))); + LocalCreatePhysicsObject(false,0,startTransform,new btBoxShape(btVector3(30,2,30))); class MyConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface { @@ -119,9 +119,9 @@ void ConvexDecompositionDemo::initPhysics(const char* filename) virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result) { - TriangleMesh* trimesh = new TriangleMesh(); + btTriangleMesh* trimesh = new btTriangleMesh(); - SimdVector3 localScaling(6.f,6.f,6.f); + btVector3 localScaling(6.f,6.f,6.f); //export data to .obj printf("ConvexResult\n"); @@ -148,9 +148,9 @@ void ConvexDecompositionDemo::initPhysics(const char* filename) unsigned int index0 = *src++; unsigned int index1 = *src++; unsigned int index2 = *src++; - SimdVector3 vertex0(result.mHullVertices[index0*3], result.mHullVertices[index0*3+1],result.mHullVertices[index0*3+2]); - SimdVector3 vertex1(result.mHullVertices[index1*3], result.mHullVertices[index1*3+1],result.mHullVertices[index1*3+2]); - SimdVector3 vertex2(result.mHullVertices[index2*3], result.mHullVertices[index2*3+1],result.mHullVertices[index2*3+2]); + btVector3 vertex0(result.mHullVertices[index0*3], result.mHullVertices[index0*3+1],result.mHullVertices[index0*3+2]); + btVector3 vertex1(result.mHullVertices[index1*3], result.mHullVertices[index1*3+1],result.mHullVertices[index1*3+2]); + btVector3 vertex2(result.mHullVertices[index2*3], result.mHullVertices[index2*3+1],result.mHullVertices[index2*3+2]); vertex0 *= localScaling; vertex1 *= localScaling; vertex2 *= localScaling; @@ -173,9 +173,9 @@ void ConvexDecompositionDemo::initPhysics(const char* filename) unsigned int index2 = *src++; - SimdVector3 vertex0(result.mHullVertices[index0*3], result.mHullVertices[index0*3+1],result.mHullVertices[index0*3+2]); - SimdVector3 vertex1(result.mHullVertices[index1*3], result.mHullVertices[index1*3+1],result.mHullVertices[index1*3+2]); - SimdVector3 vertex2(result.mHullVertices[index2*3], result.mHullVertices[index2*3+1],result.mHullVertices[index2*3+2]); + btVector3 vertex0(result.mHullVertices[index0*3], result.mHullVertices[index0*3+1],result.mHullVertices[index0*3+2]); + btVector3 vertex1(result.mHullVertices[index1*3], result.mHullVertices[index1*3+1],result.mHullVertices[index1*3+2]); + btVector3 vertex2(result.mHullVertices[index2*3], result.mHullVertices[index2*3+1],result.mHullVertices[index2*3+2]); vertex0 *= localScaling; vertex1 *= localScaling; vertex2 *= localScaling; @@ -196,8 +196,8 @@ void ConvexDecompositionDemo::initPhysics(const char* filename) bool isDynamic = true; float mass = 1.f; - CollisionShape* convexShape = new ConvexTriangleMeshShape(trimesh); - SimdTransform trans; + btCollisionShape* convexShape = new btConvexTriangleMeshShape(trimesh); + btTransform trans; trans.setIdentity(); trans.setOrigin(centroid); m_convexDemo->LocalCreatePhysicsObject(isDynamic, mass, trans,convexShape); @@ -216,9 +216,9 @@ void ConvexDecompositionDemo::initPhysics(const char* filename) if (tcount) { - TriangleMesh* trimesh = new TriangleMesh(); + btTriangleMesh* trimesh = new btTriangleMesh(); - SimdVector3 localScaling(6.f,6.f,6.f); + btVector3 localScaling(6.f,6.f,6.f); for (int i=0;iAddTriangle(vertex0,vertex1,vertex2); } - CollisionShape* convexShape = new ConvexTriangleMeshShape(trimesh); + btCollisionShape* convexShape = new btConvexTriangleMeshShape(trimesh); bool isDynamic = true; float mass = 1.f; - SimdTransform startTransform; + btTransform startTransform; startTransform.setIdentity(); - startTransform.setOrigin(SimdVector3(20,2,0)); + startTransform.setOrigin(btVector3(20,2,0)); LocalCreatePhysicsObject(isDynamic, mass, startTransform,convexShape); diff --git a/Demos/ConvexHullDistance/ConvexHullDistanceDemo.cpp b/Demos/ConvexHullDistance/ConvexHullDistanceDemo.cpp index b1de88bf4..394cb6d0f 100644 --- a/Demos/ConvexHullDistance/ConvexHullDistanceDemo.cpp +++ b/Demos/ConvexHullDistance/ConvexHullDistanceDemo.cpp @@ -16,12 +16,12 @@ subject to the following restrictions: /// /// Convex Hull Distance Demo shows distance calculation between two convex hulls of points. -/// GJK with the VoronoiSimplexSolver is used. +/// GJK with the btVoronoiSimplexSolver is used. /// #include "GL_Simplex1to4.h" -#include "LinearMath/SimdQuaternion.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btQuaternion.h" +#include "LinearMath/btTransform.h" #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" #include "BulletCollision/CollisionShapes/btConvexHullShape.h" @@ -51,9 +51,9 @@ const int numObjects = 2; GL_Simplex1to4 simplex; -PolyhedralConvexShape* shapePtr[maxNumObjects]; +btPolyhedralConvexShape* shapePtr[maxNumObjects]; -SimdTransform tr[numObjects]; +btTransform tr[numObjects]; int screenWidth = 640.f; int screenHeight = 480.f; @@ -62,26 +62,26 @@ int main(int argc,char** argv) { clientResetScene(); - SimdMatrix3x3 basisA; + btMatrix3x3 basisA; basisA.setIdentity(); - SimdMatrix3x3 basisB; + btMatrix3x3 basisB; basisB.setIdentity(); tr[0].setBasis(basisA); tr[1].setBasis(basisB); - SimdPoint3 points0[3]={SimdPoint3(1,0,0),SimdPoint3(0,1,0),SimdPoint3(0,0,1)}; - SimdPoint3 points1[5]={SimdPoint3(1,0,0),SimdPoint3(0,1,0),SimdPoint3(0,0,1),SimdPoint3(0,0,-1),SimdPoint3(-1,-1,0)}; + btPoint3 points0[3]={btPoint3(1,0,0),btPoint3(0,1,0),btPoint3(0,0,1)}; + btPoint3 points1[5]={btPoint3(1,0,0),btPoint3(0,1,0),btPoint3(0,0,1),btPoint3(0,0,-1),btPoint3(-1,-1,0)}; - ConvexHullShape hullA(points0,3); - ConvexHullShape hullB(points1,5); + btConvexHullShape hullA(points0,3); + btConvexHullShape hullB(points1,5); shapePtr[0] = &hullA; shapePtr[1] = &hullB; - SimdTransform tr; + btTransform tr; tr.setIdentity(); @@ -97,8 +97,8 @@ void clientMoveAndDisplay() } -static VoronoiSimplexSolver sGjkSimplexSolver; -SimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver; +static btVoronoiSimplexSolver sGjkSimplexSolver; +btSimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver; @@ -112,13 +112,13 @@ void clientDisplay(void) { float m[16]; int i; - GjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0); + btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0); - SimdVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f); + btVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f); convexConvex.SetCachedSeperatingAxis(seperatingAxis); - PointCollector gjkOutput; - GjkPairDetector::ClosestPointInput input; + btPointCollector gjkOutput; + btGjkPairDetector::ClosestPointInput input; input.m_transformA = tr[0]; input.m_transformB = tr[1]; @@ -126,7 +126,7 @@ void clientDisplay(void) { if (gjkOutput.m_hasResult) { - SimdVector3 endPt = gjkOutput.m_pointInWorld + + btVector3 endPt = gjkOutput.m_pointInWorld + gjkOutput.m_normalOnBInWorld*gjkOutput.m_distance; glBegin(GL_LINES); @@ -142,26 +142,26 @@ void clientDisplay(void) { tr[i].getOpenGLMatrix( m ); - GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],SimdVector3(1,1,1),getDebugMode()); + GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode()); } simplex.SetSimplexSolver(&sGjkSimplexSolver); - SimdPoint3 ybuf[4],pbuf[4],qbuf[4]; + btPoint3 ybuf[4],pbuf[4],qbuf[4]; int numpoints = sGjkSimplexSolver.getSimplex(pbuf,qbuf,ybuf); simplex.Reset(); for (i=0;i #include "GlutStuff.h" @@ -51,34 +51,34 @@ subject to the following restrictions: EpaPenetrationDepthSolver epaPenDepthSolver; -SimplexSolverInterface simplexSolver; +btSimplexSolverInterface simplexSolver; int screenWidth = 640.f; int screenHeight = 480.f; // Scene stuff -SimdPoint3 g_sceneVolumeMin( -1, -1, -1 ); -SimdPoint3 g_sceneVolumeMax( 1, 1, 1 ); +btPoint3 g_sceneVolumeMin( -1, -1, -1 ); +btPoint3 g_sceneVolumeMax( 1, 1, 1 ); bool g_shapesPenetrate = false; -SimdVector3 g_wWitnesses[ 2 ]; +btVector3 g_wWitnesses[ 2 ]; // Shapes stuff -ConvexShape* g_pConvexShapes[ 2 ] = { 0 }; -SimdTransform g_convexShapesTransform[ 2 ]; +btConvexShape* g_pConvexShapes[ 2 ] = { 0 }; +btTransform g_convexShapesTransform[ 2 ]; -SimdScalar g_animAngle = SIMD_RADS_PER_DEG; +btScalar g_animAngle = SIMD_RADS_PER_DEG; bool g_pauseAnim = true; // 0 - Box ; 1 - Sphere int g_shapesType[ 2 ] = { 0 }; // Box config -SimdVector3 g_boxExtents( 1, 1, 1 ); +btVector3 g_boxExtents( 1, 1, 1 ); // Sphere config -SimdScalar g_sphereRadius = 1; +btScalar g_sphereRadius = 1; float randomFloat( float rangeMin, float rangeMax ) { @@ -90,9 +90,9 @@ int randomShapeType( int minShapeType, int maxShapeType ) return ( ( ( ( maxShapeType - minShapeType ) + 1 ) * rand() ) / ( ( RAND_MAX + 1 ) + minShapeType ) ); } -SimdVector3 randomPosition( const SimdPoint3& minPoint, const SimdPoint3& maxPoint ) +btVector3 randomPosition( const btPoint3& minPoint, const btPoint3& maxPoint ) { - return SimdVector3( randomFloat( minPoint.getX(), maxPoint.getX() ), + return btVector3( randomFloat( minPoint.getX(), maxPoint.getX() ), randomFloat( minPoint.getY(), maxPoint.getY() ), randomFloat( minPoint.getZ(), maxPoint.getZ() ) ); } @@ -104,39 +104,39 @@ bool createBoxShape( int shapeIndex ) // //if ( b ) //{ - // g_pConvexShapes[ shapeIndex ] = new BoxShape( SimdVector3( 1, 1, 1 ) ); + // g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 1, 1, 1 ) ); // g_pConvexShapes[ shapeIndex ]->SetMargin( 0.05 ); // g_convexShapesTransform[ shapeIndex ].setIdentity(); - // SimdMatrix3x3 basis( 0.99365157, 0.024418538, -0.10981932, + // btMatrix3x3 basis( 0.99365157, 0.024418538, -0.10981932, // -0.025452739, 0.99964380, -0.0080251107, // 0.10958424, 0.010769366, 0.99391919 ); - // g_convexShapesTransform[ shapeIndex ].setOrigin( SimdVector3( 4.4916530, -19.059078, -0.22695254 ) ); + // g_convexShapesTransform[ shapeIndex ].setOrigin( btVector3( 4.4916530, -19.059078, -0.22695254 ) ); // g_convexShapesTransform[ shapeIndex ].setBasis( basis ); // b = false; //} //else //{ - // g_pConvexShapes[ shapeIndex ] = new BoxShape( SimdVector3( 25, 10, 25 ) ); + // g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 25, 10, 25 ) ); // g_pConvexShapes[ shapeIndex ]->SetMargin( 0.05 ); - // //SimdMatrix3x3 basis( 0.658257, 0.675022, -0.333709, + // //btMatrix3x3 basis( 0.658257, 0.675022, -0.333709, // // -0.333120, 0.658556, 0.675023, // // 0.675314, -0.333120, 0.658256 ); // g_convexShapesTransform[ shapeIndex ].setIdentity(); - // g_convexShapesTransform[ shapeIndex ].setOrigin( SimdVector3( 0, -30, 0/*0.326090, -0.667531, 0.214331*/ ) ); + // g_convexShapesTransform[ shapeIndex ].setOrigin( btVector3( 0, -30, 0/*0.326090, -0.667531, 0.214331*/ ) ); // //g_convexShapesTransform[ shapeIndex ].setBasis( basis ); //} //#endif - g_pConvexShapes[ shapeIndex ] = new BoxShape( SimdVector3( 1, 1, 1 ) ); + g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 1, 1, 1 ) ); g_pConvexShapes[ shapeIndex ]->SetMargin( 1e-1 ); @@ -149,7 +149,7 @@ bool createBoxShape( int shapeIndex ) bool createSphereShape( int shapeIndex ) { - g_pConvexShapes[ shapeIndex ] = new SphereShape( g_sphereRadius ); + g_pConvexShapes[ shapeIndex ] = new btSphereShape( g_sphereRadius ); g_pConvexShapes[ shapeIndex ]->SetMargin( 1e-1 ); @@ -160,12 +160,12 @@ bool createSphereShape( int shapeIndex ) //static bool b = true; //if ( b ) //{ - // g_convexShapesTransform[ shapeIndex ].setOrigin( SimdVector3( 0.001, 0, 0 ) ); + // g_convexShapesTransform[ shapeIndex ].setOrigin( btVector3( 0.001, 0, 0 ) ); // b = false; //} //else //{ - // g_convexShapesTransform[ shapeIndex ].setOrigin( SimdVector3( 0, 0, 0 ) ); + // g_convexShapesTransform[ shapeIndex ].setOrigin( btVector3( 0, 0, 0 ) ); //} //#endif @@ -191,15 +191,15 @@ bool calcPenDepth() { // Ryn Hybrid Pen Depth and EPA if necessary - SimdVector3 v( 1, 0, 0 ); + btVector3 v( 1, 0, 0 ); - SimdScalar squaredDistance = SIMD_INFINITY; - SimdScalar delta = 0.f; + btScalar squaredDistance = SIMD_INFINITY; + btScalar delta = 0.f; - const SimdScalar margin = g_pConvexShapes[ 0 ]->GetMargin() + g_pConvexShapes[ 1 ]->GetMargin(); - const SimdScalar marginSqrd = margin * margin; + const btScalar margin = g_pConvexShapes[ 0 ]->GetMargin() + g_pConvexShapes[ 1 ]->GetMargin(); + const btScalar marginSqrd = margin * margin; - SimdScalar maxRelErrorSqrd = 1e-3 * 1e-3; + btScalar maxRelErrorSqrd = 1e-3 * 1e-3; simplexSolver.reset(); @@ -207,16 +207,16 @@ bool calcPenDepth() { assert( ( v.length2() > 0 ) && "Warning: v is the zero vector!" ); - SimdVector3 seperatingAxisInA = -v * g_convexShapesTransform[ 0 ].getBasis(); - SimdVector3 seperatingAxisInB = v * g_convexShapesTransform[ 1 ].getBasis(); + btVector3 seperatingAxisInA = -v * g_convexShapesTransform[ 0 ].getBasis(); + btVector3 seperatingAxisInB = v * g_convexShapesTransform[ 1 ].getBasis(); - SimdVector3 pInA = g_pConvexShapes[ 0 ]->LocalGetSupportingVertexWithoutMargin( seperatingAxisInA ); - SimdVector3 qInB = g_pConvexShapes[ 1 ]->LocalGetSupportingVertexWithoutMargin( seperatingAxisInB ); + btVector3 pInA = g_pConvexShapes[ 0 ]->LocalGetSupportingVertexWithoutMargin( seperatingAxisInA ); + btVector3 qInB = g_pConvexShapes[ 1 ]->LocalGetSupportingVertexWithoutMargin( seperatingAxisInB ); - SimdPoint3 pWorld = g_convexShapesTransform[ 0 ]( pInA ); - SimdPoint3 qWorld = g_convexShapesTransform[ 1 ]( qInB ); + btPoint3 pWorld = g_convexShapesTransform[ 0 ]( pInA ); + btPoint3 qWorld = g_convexShapesTransform[ 1 ]( qInB ); - SimdVector3 w = pWorld - qWorld; + btVector3 w = pWorld - qWorld; delta = v.dot( w ); // potential exit, they don't overlap @@ -232,7 +232,7 @@ bool calcPenDepth() simplexSolver.compute_points( g_wWitnesses[ 0 ], g_wWitnesses[ 1 ] ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); - SimdScalar vLength = sqrt( squaredDistance ); + btScalar vLength = sqrt( squaredDistance ); g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->GetMargin() / vLength ); g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->GetMargin() / vLength ); @@ -249,7 +249,7 @@ bool calcPenDepth() simplexSolver.compute_points( g_wWitnesses[ 0 ], g_wWitnesses[ 1 ] ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); - SimdScalar vLength = sqrt( squaredDistance ); + btScalar vLength = sqrt( squaredDistance ); g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->GetMargin() / vLength ); g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->GetMargin() / vLength ); @@ -257,7 +257,7 @@ bool calcPenDepth() return true; } - SimdScalar previousSquaredDistance = squaredDistance; + btScalar previousSquaredDistance = squaredDistance; squaredDistance = v.length2(); //are we getting any closer ? @@ -269,7 +269,7 @@ bool calcPenDepth() simplexSolver.compute_points( g_wWitnesses[ 0 ], g_wWitnesses[ 1 ] ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); - SimdScalar vLength = sqrt( squaredDistance ); + btScalar vLength = sqrt( squaredDistance ); g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->GetMargin() / vLength ); g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->GetMargin() / vLength ); @@ -313,7 +313,7 @@ void drawShape( int shapeIndex ) if ( g_pConvexShapes[ shapeIndex ]->GetShapeType() == BOX_SHAPE_PROXYTYPE ) { - glutWireCube( ( ( BoxShape* ) g_pConvexShapes[ shapeIndex ] )->GetHalfExtents().x() * 2 ); + glutWireCube( ( ( btBoxShape* ) g_pConvexShapes[ shapeIndex ] )->GetHalfExtents().x() * 2 ); } else if ( g_pConvexShapes[ shapeIndex ]->GetShapeType() == SPHERE_SHAPE_PROXYTYPE ) { @@ -349,10 +349,10 @@ void clientMoveAndDisplay() { if ( !g_pauseAnim ) { - SimdMatrix3x3 rot; + btMatrix3x3 rot; rot.setEulerZYX( g_animAngle * 0.05, g_animAngle * 0.05, g_animAngle * 0.05 ); - SimdTransform t; + btTransform t; t.setIdentity(); t.setBasis( rot ); @@ -419,11 +419,11 @@ void clientKeyboard(unsigned char key, int x, int y) else if ( key == 'T' || key == 't' ) { #ifdef DEBUG_ME - SimdVector3 shapeAPos = g_convexShapesTransform[ 0 ].getOrigin(); - SimdVector3 shapeBPos = g_convexShapesTransform[ 1 ].getOrigin(); + btVector3 shapeAPos = g_convexShapesTransform[ 0 ].getOrigin(); + btVector3 shapeBPos = g_convexShapesTransform[ 1 ].getOrigin(); - SimdMatrix3x3 shapeARot = g_convexShapesTransform[ 0 ].getBasis(); - SimdMatrix3x3 shapeBRot = g_convexShapesTransform[ 1 ].getBasis(); + btMatrix3x3 shapeARot = g_convexShapesTransform[ 0 ].getBasis(); + btMatrix3x3 shapeBRot = g_convexShapesTransform[ 1 ].getBasis(); FILE* fp = 0; diff --git a/Demos/ForkLiftDemo/ForkLiftDemo.cpp b/Demos/ForkLiftDemo/ForkLiftDemo.cpp index d5acdca89..7061dcad7 100644 --- a/Demos/ForkLiftDemo/ForkLiftDemo.cpp +++ b/Demos/ForkLiftDemo/ForkLiftDemo.cpp @@ -27,8 +27,8 @@ subject to the following restrictions: #include "PHY_IVehicle.h" #include "ParallelIslandDispatcher.h" -#include "LinearMath/GenQuickprof.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btQuickprof.h" +#include "LinearMath/btIDebugDraw.h" #include "GLDebugDrawer.h" @@ -50,7 +50,7 @@ const int maxOverlap = 65535; DefaultMotionState wheelMotionState[4]; -///PHY_IVehicle is the interface behind the constraint that implements the raycast vehicle (WrapperVehicle which holds a RaycastVehicle) +///PHY_IVehicle is the interface behind the constraint that implements the raycast vehicle (WrapperVehicle which holds a btRaycastVehicle) ///notice that for higher-quality slow-moving vehicles, another approach might be better ///implementing explicit hinged-wheel constraints with cylinder collision, rather then raycasts PHY_IVehicle* gVehicleConstraint=0; @@ -66,9 +66,9 @@ float suspensionStiffness = 10.f; float suspensionDamping = 1.3f; float suspensionCompression = 2.4f; float rollInfluence = 0.1f; -SimdVector3 wheelDirectionCS0(0,-1,0); -SimdVector3 wheelAxleCS(1,0,0); -SimdScalar suspensionRestLength(0.6); +btVector3 wheelDirectionCS0(0,-1,0); +btVector3 wheelAxleCS(1,0,0); +btScalar suspensionRestLength(0.6); #define CUBE_HALF_EXTENTS 1 @@ -97,20 +97,20 @@ m_cameraHeight(4.f), m_minCameraDistance(3.f), m_maxCameraDistance(10.f) { - m_cameraPosition = SimdVector3(30,30,30); + m_cameraPosition = btVector3(30,30,30); } void ForkLiftDemo::setupPhysics() { - CollisionDispatcher* dispatcher = new CollisionDispatcher(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(); //ParallelIslandDispatcher* dispatcher2 = new ParallelIslandDispatcher(); - SimdVector3 worldAabbMin(-30000,-30000,-30000); - SimdVector3 worldAabbMax(30000,30000,30000); + btVector3 worldAabbMin(-30000,-30000,-30000); + btVector3 worldAabbMax(30000,30000,30000); - OverlappingPairCache* broadphase = new AxisSweep3(worldAabbMin,worldAabbMax,maxProxies); - //OverlappingPairCache* broadphase = new SimpleBroadphase(maxProxies,maxOverlap); + btOverlappingPairCache* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies); + //OverlappingPairCache* broadphase = new btSimpleBroadphase(maxProxies,maxOverlap); #ifdef USE_PARALLEL_DISPATCHER m_physicsEnvironmentPtr = new ParallelPhysicsEnvironment(dispatcher2,broadphase); @@ -124,7 +124,7 @@ void ForkLiftDemo::setupPhysics() m_physicsEnvironmentPtr->setGravity(0,-10,0);//0,0);//-10,0); int i; - CollisionShape* groundShape = new BoxShape(SimdVector3(50,3,50)); + btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50)); #define USE_TRIMESH_GROUND 1 #ifdef USE_TRIMESH_GROUND @@ -133,7 +133,7 @@ void ForkLiftDemo::setupPhysics() const float TRIANGLE_SIZE=20.f; //create a triangle-mesh ground - int vertStride = sizeof(SimdVector3); + int vertStride = sizeof(btVector3); int indexStride = 3*sizeof(int); const int NUM_VERTS_X = 50; @@ -142,7 +142,7 @@ const float TRIANGLE_SIZE=20.f; const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1); - SimdVector3* gVertices = new SimdVector3[totalVerts]; + btVector3* gVertices = new btVector3[totalVerts]; int* gIndices = new int[totalTriangles*3]; @@ -170,25 +170,25 @@ const float TRIANGLE_SIZE=20.f; } } - TriangleIndexVertexArray* indexVertexArrays = new TriangleIndexVertexArray(totalTriangles, + btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles, gIndices, indexStride, totalVerts,(float*) &gVertices[0].x(),vertStride); - groundShape = new BvhTriangleMeshShape(indexVertexArrays); + groundShape = new btBvhTriangleMeshShape(indexVertexArrays); #endif // - SimdTransform tr; + btTransform tr; tr.setIdentity(); - tr.setOrigin(SimdVector3(0,-20.f,0)); + tr.setOrigin(btVector3(0,-20.f,0)); //create ground object LocalCreatePhysicsObject(false,0,tr,groundShape); - CollisionShape* chassisShape = new BoxShape(SimdVector3(1.f,0.5f,2.f)); - tr.setOrigin(SimdVector3(0,0.f,0)); + btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f,0.5f,2.f)); + tr.setOrigin(btVector3(0,0.f,0)); m_carChassis = LocalCreatePhysicsObject(true,800,tr,chassisShape); @@ -211,8 +211,8 @@ const float TRIANGLE_SIZE=20.f; gVehicleConstraint = m_physicsEnvironmentPtr->getVehicleConstraint(constraintId); - SimdVector3 connectionPointCS0(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); - RaycastVehicle::VehicleTuning tuning; + btVector3 connectionPointCS0(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); + btRaycastVehicle::btVehicleTuning tuning; bool isFrontWheel=true; int rightIndex = 0; int upIndex = 1; @@ -224,18 +224,18 @@ const float TRIANGLE_SIZE=20.f; (PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); - connectionPointCS0 = SimdVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); + connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); gVehicleConstraint->AddWheel(&wheelMotionState[1], (PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); - connectionPointCS0 = SimdVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); + connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); isFrontWheel = false; gVehicleConstraint->AddWheel(&wheelMotionState[2], (PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); - connectionPointCS0 = SimdVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); + connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); gVehicleConstraint->AddWheel(&wheelMotionState[3], (PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); @@ -280,8 +280,8 @@ void ForkLiftDemo::renderme() float m[16]; int i; - CylinderShapeX wheelShape(SimdVector3(wheelWidth,wheelRadius,wheelRadius)); - SimdVector3 wheelColor(1,0,0); + btCylinderShapeX wheelShape(btVector3(wheelWidth,wheelRadius,wheelRadius)); + btVector3 wheelColor(1,0,0); for (i=0;i<4;i++) { @@ -318,14 +318,14 @@ void ForkLiftDemo::clientMoveAndDisplay() #ifdef USE_QUICKPROF - Profiler::beginBlock("render"); + btProfiler::beginBlock("render"); #endif //USE_QUICKPROF renderme(); #ifdef USE_QUICKPROF - Profiler::endBlock("render"); + btProfiler::endBlock("render"); #endif glFlush(); glutSwapBuffers(); @@ -419,7 +419,7 @@ void ForkLiftDemo::updateCamera() //interpolate the camera height m_cameraPosition[1] = (15.0*m_cameraPosition[1] + m_cameraTargetPosition[1] + m_cameraHeight)/16.0; - SimdVector3 camToObject = m_cameraTargetPosition - m_cameraPosition; + btVector3 camToObject = m_cameraTargetPosition - m_cameraPosition; //keep distance between min and max distance float cameraDistance = camToObject.length(); diff --git a/Demos/GjkConvexCastDemo/LinearConvexCastDemo.cpp b/Demos/GjkConvexCastDemo/LinearConvexCastDemo.cpp index ebc577cb6..67b9e41cc 100644 --- a/Demos/GjkConvexCastDemo/LinearConvexCastDemo.cpp +++ b/Demos/GjkConvexCastDemo/LinearConvexCastDemo.cpp @@ -21,8 +21,8 @@ ///Low level demo, doesn't include btBulletCollisionCommon.h -#include "LinearMath/SimdQuaternion.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btQuaternion.h" +#include "LinearMath/btTransform.h" #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" #include "BulletCollision/CollisionShapes/btBoxShape.h" #include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h" @@ -49,9 +49,9 @@ const int maxNumObjects = 4; const int numObjects = 2; -PolyhedralConvexShape* shapePtr[maxNumObjects]; +btPolyhedralConvexShape* shapePtr[maxNumObjects]; -SimdTransform tr[numObjects]; +btTransform tr[numObjects]; int screenWidth = 640; int screenHeight = 480; void DrawRasterizerLine(float const* , float const*, int) @@ -73,15 +73,15 @@ int main(int argc,char** argv) void LinearConvexCastDemo::initPhysics() { setCameraDistance(30.f); - tr[0].setOrigin(SimdVector3(0,0,0)); - tr[1].setOrigin(SimdVector3(0,10,0)); + tr[0].setOrigin(btVector3(0,0,0)); + tr[1].setOrigin(btVector3(0,10,0)); - SimdMatrix3x3 basisA; + btMatrix3x3 basisA; basisA.setValue(0.99999958f,0.00022980258f,0.00090992288f, -0.00029313788f,0.99753088f,0.070228584f, -0.00089153741f,-0.070228823f,0.99753052f); - SimdMatrix3x3 basisB; + btMatrix3x3 basisB; basisB.setValue(1.0000000f,4.4865553e-018f,-4.4410586e-017f, 4.4865495e-018f,0.97979438f,0.20000751f, 4.4410586e-017f,-0.20000751f,0.97979438f); @@ -91,25 +91,25 @@ void LinearConvexCastDemo::initPhysics() - SimdVector3 boxHalfExtentsA(0.2,4,4); - SimdVector3 boxHalfExtentsB(6,6,6); + btVector3 boxHalfExtentsA(0.2,4,4); + btVector3 boxHalfExtentsB(6,6,6); - BoxShape* boxA = new BoxShape(boxHalfExtentsA); -/* BU_Simplex1to4 boxB; - boxB.AddVertex(SimdPoint3(-5,0,-5)); - boxB.AddVertex(SimdPoint3(5,0,-5)); - boxB.AddVertex(SimdPoint3(0,0,5)); - boxB.AddVertex(SimdPoint3(0,5,0)); + btBoxShape* boxA = new btBoxShape(boxHalfExtentsA); +/* btBU_Simplex1to4 boxB; + boxB.AddVertex(btPoint3(-5,0,-5)); + boxB.AddVertex(btPoint3(5,0,-5)); + boxB.AddVertex(btPoint3(0,0,5)); + boxB.AddVertex(btPoint3(0,5,0)); */ - BoxShape* boxB = new BoxShape(boxHalfExtentsB); + btBoxShape* boxB = new btBoxShape(boxHalfExtentsB); shapePtr[0] = boxA; shapePtr[1] = boxB; shapePtr[0]->SetMargin(0.01f); shapePtr[1]->SetMargin(0.01f); - SimdTransform tr; + btTransform tr; tr.setIdentity(); } @@ -124,9 +124,9 @@ void LinearConvexCastDemo::clientMoveAndDisplay() #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" #include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h" -static VoronoiSimplexSolver sVoronoiSimplexSolver; +static btVoronoiSimplexSolver sVoronoiSimplexSolver; -SimplexSolverInterface& gGjkSimplexSolver = sVoronoiSimplexSolver; +btSimplexSolverInterface& gGjkSimplexSolver = sVoronoiSimplexSolver; bool drawLine= false; @@ -145,13 +145,13 @@ void LinearConvexCastDemo::displayCallback(void) for (i=0;i @@ -29,16 +29,16 @@ subject to the following restrictions: #else #include #endif -struct DebugCastResult : public ConvexCast::CastResult +struct btDebugCastResult : public btConvexCast::CastResult { - SimdTransform m_fromTrans; - const PolyhedralConvexShape* m_shape; - SimdVector3 m_linVel; - SimdVector3 m_angVel; + btTransform m_fromTrans; + const btPolyhedralConvexShape* m_shape; + btVector3 m_linVel; + btVector3 m_angVel; - DebugCastResult(const SimdTransform& fromTrans,const PolyhedralConvexShape* shape, - const SimdVector3& linVel,const SimdVector3& angVel) + btDebugCastResult(const btTransform& fromTrans,const btPolyhedralConvexShape* shape, + const btVector3& linVel,const btVector3& angVel) :m_fromTrans(fromTrans), m_shape(shape), m_linVel(linVel), @@ -46,7 +46,7 @@ struct DebugCastResult : public ConvexCast::CastResult { } - virtual void DrawCoordSystem(const SimdTransform& tr) + virtual void DrawCoordSystem(const btTransform& tr) { float m[16]; tr.getOpenGLMatrix(m); @@ -66,14 +66,14 @@ struct DebugCastResult : public ConvexCast::CastResult glPopMatrix(); } - virtual void DebugDraw(SimdScalar fraction) + virtual void DebugDraw(btScalar fraction) { float m[16]; - SimdTransform hitTrans; - SimdTransformUtil::IntegrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans); + btTransform hitTrans; + btTransformUtil::IntegrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans); hitTrans.getOpenGLMatrix(m); - GL_ShapeDrawer::DrawOpenGL(m,m_shape,SimdVector3(1,0,0),IDebugDraw::DBG_NoDebug); + GL_ShapeDrawer::DrawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug); } }; diff --git a/Demos/OpenGL/DemoApplication.cpp b/Demos/OpenGL/DemoApplication.cpp index 220d700a0..dfb0e2a99 100644 --- a/Demos/OpenGL/DemoApplication.cpp +++ b/Demos/OpenGL/DemoApplication.cpp @@ -14,7 +14,8 @@ subject to the following restrictions: */ #include "DemoApplication.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" +#include "BulletDynamics/Dynamics/btDynamicsWorld.h" #include "CcdPhysicsEnvironment.h" #include "CcdPhysicsController.h" @@ -23,21 +24,24 @@ subject to the following restrictions: #include "BulletCollision/CollisionShapes/btCollisionShape.h" #include "BulletCollision/CollisionShapes/btBoxShape.h" #include "GL_ShapeDrawer.h" -#include "LinearMath/GenQuickprof.h" +#include "LinearMath/btQuickprof.h" #include "BMF_Api.h" +#include "BulletDynamics/Dynamics/btMassProps.h" int numObjects = 0; const int maxNumObjects = 16384; DefaultMotionState ms[maxNumObjects]; CcdPhysicsController* physObjects[maxNumObjects]; -SimdTransform startTransforms[maxNumObjects]; -CollisionShape* gShapePtr[maxNumObjects];//1 rigidbody has 1 shape (no re-use of shapes) +btTransform startTransforms[maxNumObjects]; +btCollisionShape* gShapePtr[maxNumObjects];//1 rigidbody has 1 shape (no re-use of shapes) DemoApplication::DemoApplication() - //see IDebugDraw.h for modes + //see btIDebugDraw.h for modes : m_physicsEnvironmentPtr(0), +m_dynamicsWorld(0), +m_pickConstraint(0), m_cameraDistance(15.0), m_debugMode(0), m_ele(0.f), @@ -133,21 +137,21 @@ void DemoApplication::updateCamera() { float razi = m_azi * 0.01745329251994329547;// rads per deg - SimdQuaternion rot(m_cameraUp,razi); + btQuaternion rot(m_cameraUp,razi); - SimdVector3 eyePos(0,0,0); + btVector3 eyePos(0,0,0); eyePos[m_forwardAxis] = -m_cameraDistance; - SimdVector3 forward(eyePos[0],eyePos[1],eyePos[2]); + btVector3 forward(eyePos[0],eyePos[1],eyePos[2]); if (forward.length2() < SIMD_EPSILON) { forward.setValue(1.f,0.f,0.f); } - SimdVector3 right = m_cameraUp.cross(forward); - SimdQuaternion roll(right,-rele); + btVector3 right = m_cameraUp.cross(forward); + btQuaternion roll(right,-rele); - eyePos = SimdMatrix3x3(rot) * SimdMatrix3x3(roll) * eyePos; + eyePos = btMatrix3x3(rot) * btMatrix3x3(roll) * eyePos; m_cameraPosition[0] = eyePos.getX(); m_cameraPosition[1] = eyePos.getY(); @@ -226,70 +230,70 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y) case 'x' : zoomOut(); break; case 'i' : toggleIdle(); break; case 'h': - if (m_debugMode & IDebugDraw::DBG_NoHelpText) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_NoHelpText); + if (m_debugMode & btIDebugDraw::DBG_NoHelpText) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_NoHelpText); else - m_debugMode |= IDebugDraw::DBG_NoHelpText; + m_debugMode |= btIDebugDraw::DBG_NoHelpText; break; case 'w': - if (m_debugMode & IDebugDraw::DBG_DrawWireframe) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_DrawWireframe); + if (m_debugMode & btIDebugDraw::DBG_DrawWireframe) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawWireframe); else - m_debugMode |= IDebugDraw::DBG_DrawWireframe; + m_debugMode |= btIDebugDraw::DBG_DrawWireframe; break; case 'p': - if (m_debugMode & IDebugDraw::DBG_ProfileTimings) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_ProfileTimings); + if (m_debugMode & btIDebugDraw::DBG_ProfileTimings) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_ProfileTimings); else - m_debugMode |= IDebugDraw::DBG_ProfileTimings; + m_debugMode |= btIDebugDraw::DBG_ProfileTimings; break; case 'm': - if (m_debugMode & IDebugDraw::DBG_EnableSatComparison) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_EnableSatComparison); + if (m_debugMode & btIDebugDraw::DBG_EnableSatComparison) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableSatComparison); else - m_debugMode |= IDebugDraw::DBG_EnableSatComparison; + m_debugMode |= btIDebugDraw::DBG_EnableSatComparison; break; case 'n': - if (m_debugMode & IDebugDraw::DBG_DisableBulletLCP) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_DisableBulletLCP); + if (m_debugMode & btIDebugDraw::DBG_DisableBulletLCP) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DisableBulletLCP); else - m_debugMode |= IDebugDraw::DBG_DisableBulletLCP; + m_debugMode |= btIDebugDraw::DBG_DisableBulletLCP; break; case 't' : - if (m_debugMode & IDebugDraw::DBG_DrawText) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_DrawText); + if (m_debugMode & btIDebugDraw::DBG_DrawText) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawText); else - m_debugMode |= IDebugDraw::DBG_DrawText; + m_debugMode |= btIDebugDraw::DBG_DrawText; break; case 'y': - if (m_debugMode & IDebugDraw::DBG_DrawFeaturesText) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_DrawFeaturesText); + if (m_debugMode & btIDebugDraw::DBG_DrawFeaturesText) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawFeaturesText); else - m_debugMode |= IDebugDraw::DBG_DrawFeaturesText; + m_debugMode |= btIDebugDraw::DBG_DrawFeaturesText; break; case 'a': - if (m_debugMode & IDebugDraw::DBG_DrawAabb) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_DrawAabb); + if (m_debugMode & btIDebugDraw::DBG_DrawAabb) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawAabb); else - m_debugMode |= IDebugDraw::DBG_DrawAabb; + m_debugMode |= btIDebugDraw::DBG_DrawAabb; break; case 'c' : - if (m_debugMode & IDebugDraw::DBG_DrawContactPoints) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_DrawContactPoints); + if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawContactPoints); else - m_debugMode |= IDebugDraw::DBG_DrawContactPoints; + m_debugMode |= btIDebugDraw::DBG_DrawContactPoints; break; case 'd' : - if (m_debugMode & IDebugDraw::DBG_NoDeactivation) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_NoDeactivation); + if (m_debugMode & btIDebugDraw::DBG_NoDeactivation) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_NoDeactivation); else - m_debugMode |= IDebugDraw::DBG_NoDeactivation; + m_debugMode |= btIDebugDraw::DBG_NoDeactivation; break; @@ -306,10 +310,10 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y) break; case '1': { - if (m_debugMode & IDebugDraw::DBG_EnableCCD) - m_debugMode = m_debugMode & (~IDebugDraw::DBG_EnableCCD); + if (m_debugMode & btIDebugDraw::DBG_EnableCCD) + m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableCCD); else - m_debugMode |= IDebugDraw::DBG_EnableCCD; + m_debugMode |= btIDebugDraw::DBG_EnableCCD; break; } @@ -380,21 +384,45 @@ void DemoApplication::displayCallback() -void DemoApplication::shootBox(const SimdVector3& destination) +void DemoApplication::shootBox(const btVector3& destination) { + + if (m_dynamicsWorld) + { + bool isDynamic = true; + float mass = 1.f; + btTransform startTransform; + startTransform.setIdentity(); + btVector3 camPos = getCameraPosition(); + startTransform.setOrigin(camPos); + btCollisionShape* boxShape = new btBoxShape(btVector3(1.f,1.f,1.f)); + + btRigidBody* body = this->LocalCreateRigidBody(isDynamic, mass, startTransform,boxShape); + m_dynamicsWorld->AddCollisionObject(body); + + btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]); + linVel.normalize(); + linVel*=m_ShootBoxInitialSpeed; + + body->m_worldTransform.setOrigin(camPos); + body->m_worldTransform.setRotation(btQuaternion(0,0,0,1)); + body->setLinearVelocity(linVel); + body->setAngularVelocity(btVector3(0,0,0)); + } + if (m_physicsEnvironmentPtr) { bool isDynamic = true; float mass = 1.f; - SimdTransform startTransform; + btTransform startTransform; startTransform.setIdentity(); - SimdVector3 camPos = getCameraPosition(); + btVector3 camPos = getCameraPosition(); startTransform.setOrigin(camPos); - CollisionShape* boxShape = new BoxShape(SimdVector3(1.f,1.f,1.f)); + btCollisionShape* boxShape = new btBoxShape(btVector3(1.f,1.f,1.f)); CcdPhysicsController* newBox = LocalCreatePhysicsObject(isDynamic, mass, startTransform,boxShape); - SimdVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]); + btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]); linVel.normalize(); linVel*=m_ShootBoxInitialSpeed; @@ -407,12 +435,12 @@ void DemoApplication::shootBox(const SimdVector3& destination) int gPickingConstraintId = 0; -SimdVector3 gOldPickingPos; +btVector3 gOldPickingPos; float gOldPickingDist = 0.f; -RigidBody* pickedBody = 0;//for deactivation state +btRigidBody* pickedBody = 0;//for deactivation state -SimdVector3 DemoApplication::GetRayTo(int x,int y) +btVector3 DemoApplication::GetRayTo(int x,int y) { float top = 1.f; @@ -421,16 +449,16 @@ SimdVector3 DemoApplication::GetRayTo(int x,int y) float tanFov = (top-bottom)*0.5f / nearPlane; float fov = 2.0 * atanf (tanFov); - SimdVector3 rayFrom = getCameraPosition(); - SimdVector3 rayForward = (getCameraTargetPosition()-getCameraPosition()); + btVector3 rayFrom = getCameraPosition(); + btVector3 rayForward = (getCameraTargetPosition()-getCameraPosition()); rayForward.normalize(); float farPlane = 600.f; rayForward*= farPlane; - SimdVector3 rightOffset; - SimdVector3 vertical = m_cameraUp; + btVector3 rightOffset; + btVector3 vertical = m_cameraUp; - SimdVector3 hor; + btVector3 hor; hor = rayForward.cross(vertical); hor.normalize(); vertical = hor.cross(rayForward); @@ -439,10 +467,10 @@ SimdVector3 DemoApplication::GetRayTo(int x,int y) float tanfov = tanf(0.5f*fov); hor *= 2.f * farPlane * tanfov; vertical *= 2.f * farPlane * tanfov; - SimdVector3 rayToCenter = rayFrom + rayForward; - SimdVector3 dHor = hor * 1.f/float(m_glutScreenWidth); - SimdVector3 dVert = vertical * 1.f/float(m_glutScreenHeight); - SimdVector3 rayTo = rayToCenter - 0.5f * hor + 0.5f * vertical; + btVector3 rayToCenter = rayFrom + rayForward; + btVector3 dHor = hor * 1.f/float(m_glutScreenWidth); + btVector3 dVert = vertical * 1.f/float(m_glutScreenHeight); + btVector3 rayTo = rayToCenter - 0.5f * hor + 0.5f * vertical; rayTo += x * dHor; rayTo -= y * dVert; return rayTo; @@ -454,7 +482,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y) //printf("button %i, state %i, x=%i,y=%i\n",button,state,x,y); //button 0, state 0 means left mouse down - SimdVector3 rayTo = GetRayTo(x,y); + btVector3 rayTo = GetRayTo(x,y); switch (button) { @@ -468,8 +496,40 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y) }; case 1: { + + if (state==0) { + + //apply an impulse + if (m_dynamicsWorld) + { + float hit[3]; + float normal[3]; + + btCollisionWorld::ClosestRayResultCallback rayCallback(m_cameraPosition,rayTo); + m_dynamicsWorld->RayTest(m_cameraPosition,rayTo,rayCallback); + if (rayCallback.HasHit()) + { + + if (rayCallback.m_collisionObject->m_internalOwner) + { + btRigidBody* body = (btRigidBody*)rayCallback.m_collisionObject->m_internalOwner; + if (body) + { + body->SetActivationState(ACTIVE_TAG); + btVector3 impulse = rayTo; + impulse.normalize(); + float impulseStrength = 10.f; + impulse *= impulseStrength; + btVector3 relPos = rayCallback.m_hitPointWorld - body->getCenterOfMassPosition(); + body->applyImpulse(impulse,relPos); + } + } + + } + } + //apply an impulse if (m_physicsEnvironmentPtr) { @@ -479,15 +539,15 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y) if (hitObj) { CcdPhysicsController* physCtrl = static_cast(hitObj); - RigidBody* body = physCtrl->GetRigidBody(); + btRigidBody* body = physCtrl->GetRigidBody(); if (body) { body->SetActivationState(ACTIVE_TAG); - SimdVector3 impulse = rayTo; + btVector3 impulse = rayTo; impulse.normalize(); float impulseStrength = 10.f; impulse *= impulseStrength; - SimdVector3 relPos( + btVector3 relPos( hit[0] - body->getCenterOfMassPosition().getX(), hit[1] - body->getCenterOfMassPosition().getY(), hit[2] - body->getCenterOfMassPosition().getZ()); @@ -509,6 +569,48 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y) { if (state==0) { + + //add a point to point constraint for picking + if (m_dynamicsWorld) + { + float hit[3]; + float normal[3]; + btCollisionWorld::ClosestRayResultCallback rayCallback(m_cameraPosition,rayTo); + m_dynamicsWorld->RayTest(m_cameraPosition,rayTo,rayCallback); + if (rayCallback.HasHit()) + { + + if (rayCallback.m_collisionObject->m_internalOwner) + { + btRigidBody* body = (btRigidBody*)rayCallback.m_collisionObject->m_internalOwner; + if (body && !body->IsStatic()) + { + pickedBody = body; + pickedBody->SetActivationState(DISABLE_DEACTIVATION); + + + btVector3 pickPos = rayCallback.m_hitPointWorld; + + btVector3 localPivot = body->getCenterOfMassTransform().inverse() * pickPos; + + btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*body,localPivot); + m_dynamicsWorld->addConstraint(p2p); + m_pickConstraint = p2p; + + //save mouse position for dragging + gOldPickingPos = rayTo; + + btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]); + + gOldPickingDist = (pickPos-eyePos).length(); + + //very weak constraint for picking + p2p->m_setting.m_tau = 0.1f; + } + } + } + } + //add a point to point constraint for picking if (m_physicsEnvironmentPtr) { @@ -519,16 +621,16 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y) { CcdPhysicsController* physCtrl = static_cast(hitObj); - RigidBody* body = physCtrl->GetRigidBody(); + btRigidBody* body = physCtrl->GetRigidBody(); if (body && !body->IsStatic()) { pickedBody = body; pickedBody->SetActivationState(DISABLE_DEACTIVATION); - SimdVector3 pickPos(hit[0],hit[1],hit[2]); + btVector3 pickPos(hit[0],hit[1],hit[2]); - SimdVector3 localPivot = body->getCenterOfMassTransform().inverse() * pickPos; + btVector3 localPivot = body->getCenterOfMassTransform().inverse() * pickPos; gPickingConstraintId = m_physicsEnvironmentPtr->createConstraint(physCtrl,0,PHY_POINT2POINT_CONSTRAINT, localPivot.getX(), @@ -541,11 +643,11 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y) gOldPickingPos = rayTo; - SimdVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]); + btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]); gOldPickingDist = (pickPos-eyePos).length(); - Point2PointConstraint* p2p = static_cast(m_physicsEnvironmentPtr->getConstraintById(gPickingConstraintId)); + btPoint2PointConstraint* p2p = static_cast(m_physicsEnvironmentPtr->getConstraintById(gPickingConstraintId)); if (p2p) { //very weak constraint for picking @@ -556,6 +658,18 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y) } } else { + + if (m_pickConstraint && m_dynamicsWorld) + { + m_dynamicsWorld->removeConstraint(m_pickConstraint); + delete m_pickConstraint; + //printf("removed constraint %i",gPickingConstraintId); + m_pickConstraint = 0; + pickedBody->ForceActivationState(ACTIVE_TAG); + pickedBody->m_deactivationTime = 0.f; + pickedBody = 0; + } + if (gPickingConstraintId && m_physicsEnvironmentPtr) { m_physicsEnvironmentPtr->removeConstraint(gPickingConstraintId); @@ -582,23 +696,43 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y) void DemoApplication::mouseMotionFunc(int x,int y) { + if (m_pickConstraint) + { + //move the constraint pivot + btPoint2PointConstraint* p2p = static_cast(m_pickConstraint); + if (p2p) + { + //keep it at the same picking distance + + btVector3 newRayTo = GetRayTo(x,y); + btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]); + btVector3 dir = newRayTo-eyePos; + dir.normalize(); + dir *= gOldPickingDist; + + btVector3 newPos = eyePos + dir; + p2p->SetPivotB(newPos); + } + + } + if (gPickingConstraintId && m_physicsEnvironmentPtr) { //move the constraint pivot - Point2PointConstraint* p2p = static_cast(m_physicsEnvironmentPtr->getConstraintById(gPickingConstraintId)); + btPoint2PointConstraint* p2p = static_cast(m_physicsEnvironmentPtr->getConstraintById(gPickingConstraintId)); if (p2p) { //keep it at the same picking distance - SimdVector3 newRayTo = GetRayTo(x,y); - SimdVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]); - SimdVector3 dir = newRayTo-eyePos; + btVector3 newRayTo = GetRayTo(x,y); + btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]); + btVector3 dir = newRayTo-eyePos; dir.normalize(); dir *= gOldPickingDist; - SimdVector3 newPos = eyePos + dir; + btVector3 newPos = eyePos + dir; p2p->SetPivotB(newPos); } @@ -606,16 +740,40 @@ void DemoApplication::mouseMotionFunc(int x,int y) } + +btRigidBody* DemoApplication::LocalCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape) +{ + btVector3 localInertia(0,0,0); + if (isDynamic) + shape->CalculateLocalInertia(mass,localInertia); + + btMassProps massProps(0.f,localInertia); + + btRigidBody* body = new btRigidBody(massProps); + body->m_collisionShape = shape; + body->m_worldTransform = startTransform; + body->m_internalOwner = body; + body->setMassProps( mass, localInertia); + body->setGravity(btVector3(0,-9.8f,0)); + if (!isDynamic) + { + body->m_collisionFlags = btCollisionObject::isStatic;//?? + } + return body; +} + + + ///Very basic import -CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic, float mass, const SimdTransform& startTransform,CollisionShape* shape) +CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape) { startTransforms[numObjects] = startTransform; - CcdConstructionInfo ccdObjectCi; + btCcdConstructionInfo ccdObjectCi; ccdObjectCi.m_friction = 0.5f; - SimdTransform tr; + btTransform tr; tr.setIdentity(); int i = numObjects; @@ -623,20 +781,20 @@ CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic, gShapePtr[i] = shape; gShapePtr[i]->SetMargin(0.05f); - SimdQuaternion orn = startTransform.getRotation(); + btQuaternion orn = startTransform.getRotation(); ms[i].setWorldOrientation(orn[0],orn[1],orn[2],orn[3]); ms[i].setWorldPosition(startTransform.getOrigin().getX(),startTransform.getOrigin().getY(),startTransform.getOrigin().getZ()); ccdObjectCi.m_MotionState = &ms[i]; - ccdObjectCi.m_gravity = SimdVector3(0,-9.8,0); - ccdObjectCi.m_localInertiaTensor =SimdVector3(0,0,0); + ccdObjectCi.m_gravity = btVector3(0,-9.8,0); + ccdObjectCi.m_localInertiaTensor =btVector3(0,0,0); if (!isDynamic) { ccdObjectCi.m_mass = 0.f; - ccdObjectCi.m_collisionFlags = CollisionObject::isStatic; - ccdObjectCi.m_collisionFilterGroup = CcdConstructionInfo::StaticFilter; - ccdObjectCi.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter; + ccdObjectCi.m_collisionFlags = btCollisionObject::isStatic; + ccdObjectCi.m_collisionFilterGroup = btCcdConstructionInfo::StaticFilter; + ccdObjectCi.m_collisionFilterMask = btCcdConstructionInfo::AllFilter ^ btCcdConstructionInfo::StaticFilter; } else { @@ -644,7 +802,7 @@ CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic, ccdObjectCi.m_collisionFlags = 0; } - SimdVector3 localInertia(0.f,0.f,0.f); + btVector3 localInertia(0.f,0.f,0.f); if (isDynamic) { @@ -677,10 +835,50 @@ void DemoApplication::renderme() float m[16]; + if (m_dynamicsWorld) + { + int numObjects = m_dynamicsWorld->GetNumCollisionObjects(); + btVector3 wireColor(1,0,0); + for (int i=0;iGetCollisionObjectArray()[i]; + colObj->m_worldTransform.getOpenGLMatrix(m); + + btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation + if (i & 1) + { + wireColor = btVector3(0.f,0.0f,1.f); + } + ///color differently for active, sleeping, wantsdeactivation states + if (colObj->GetActivationState() == 1) //active + { + if (i & 1) + { + wireColor += btVector3 (1.f,0.f,0.f); + } else + { + wireColor += btVector3 (.5f,0.f,0.f); + } + } + if (colObj->GetActivationState() == 2) //ISLAND_SLEEPING + { + if (i & 1) + { + wireColor += btVector3 (0.f,1.f, 0.f); + } else + { + wireColor += btVector3 (0.f,0.5f,0.f); + } + } + + GL_ShapeDrawer::DrawOpenGL(m,colObj->m_collisionShape,wireColor,getDebugMode()); + } + } + if (m_physicsEnvironmentPtr) { - if (getDebugMode() & IDebugDraw::DBG_DisableBulletLCP) + if (getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP) { //don't use Bullet, use quickstep m_physicsEnvironmentPtr->setSolverType(0); @@ -690,7 +888,7 @@ void DemoApplication::renderme() m_physicsEnvironmentPtr->setSolverType(1); } - if (getDebugMode() & IDebugDraw::DBG_EnableCCD) + if (getDebugMode() & btIDebugDraw::DBG_EnableCCD) { m_physicsEnvironmentPtr->setCcdMode(3); } else @@ -699,7 +897,7 @@ void DemoApplication::renderme() } - bool isSatEnabled = (getDebugMode() & IDebugDraw::DBG_EnableSatComparison); + bool isSatEnabled = (getDebugMode() & btIDebugDraw::DBG_EnableSatComparison); m_physicsEnvironmentPtr->EnableSatCollisionDetection(isSatEnabled); @@ -711,34 +909,34 @@ void DemoApplication::renderme() { CcdPhysicsController* ctrl = m_physicsEnvironmentPtr->GetPhysicsController(i); - RigidBody* body = ctrl->GetRigidBody(); + btRigidBody* body = ctrl->GetRigidBody(); body->m_worldTransform.getOpenGLMatrix( m ); - SimdVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation + btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation if (i & 1) { - wireColor = SimdVector3(0.f,0.0f,1.f); + wireColor = btVector3(0.f,0.0f,1.f); } ///color differently for active, sleeping, wantsdeactivation states if (ctrl->GetRigidBody()->GetActivationState() == 1) //active { if (i & 1) { - wireColor += SimdVector3 (1.f,0.f,0.f); + wireColor += btVector3 (1.f,0.f,0.f); } else { - wireColor += SimdVector3 (.5f,0.f,0.f); + wireColor += btVector3 (.5f,0.f,0.f); } } if (ctrl->GetRigidBody()->GetActivationState() == 2) //ISLAND_SLEEPING { if (i & 1) { - wireColor += SimdVector3 (0.f,1.f, 0.f); + wireColor += btVector3 (0.f,1.f, 0.f); } else { - wireColor += SimdVector3 (0.f,0.5f,0.f); + wireColor += btVector3 (0.f,0.5f,0.f); } } @@ -747,7 +945,7 @@ void DemoApplication::renderme() ctrl->GetRigidBody()->GetCollisionShape()->SetExtraDebugInfo(extraDebug); float vec[16]; - SimdTransform ident; + btTransform ident; ident.setIdentity(); ident.getOpenGLMatrix(vec); @@ -759,7 +957,7 @@ void DemoApplication::renderme() } - if (!(getDebugMode() & IDebugDraw::DBG_NoHelpText)) + if (!(getDebugMode() & btIDebugDraw::DBG_NoHelpText)) { float xOffset = 10.f; @@ -774,15 +972,15 @@ void DemoApplication::renderme() #ifdef USE_QUICKPROF - if ( getDebugMode() & IDebugDraw::DBG_ProfileTimings) + if ( getDebugMode() & btIDebugDraw::DBG_ProfileTimings) { static int counter = 0; counter++; std::map::iterator iter; - for (iter = Profiler::mProfileBlocks.begin(); iter != Profiler::mProfileBlocks.end(); ++iter) + for (iter = btProfiler::mProfileBlocks.begin(); iter != btProfiler::mProfileBlocks.end(); ++iter) { char blockTime[128]; - sprintf(blockTime, "%s: %lf",&((*iter).first[0]),Profiler::getBlockTime((*iter).first, Profiler::BLOCK_CYCLE_SECONDS));//BLOCK_TOTAL_PERCENT)); + sprintf(blockTime, "%s: %lf",&((*iter).first[0]),btProfiler::getBlockTime((*iter).first, btProfiler::BLOCK_CYCLE_SECONDS));//BLOCK_TOTAL_PERCENT)); glRasterPos3f(xOffset,yStart,0); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),blockTime); yStart += yIncr; @@ -790,7 +988,7 @@ void DemoApplication::renderme() } } #endif //USE_QUICKPROF - //profiling << Profiler::createStatsString(Profiler::BLOCK_TOTAL_PERCENT); + //profiling << btProfiler::createStatsString(btProfiler::BLOCK_TOTAL_PERCENT); //<< std::endl; @@ -836,9 +1034,9 @@ void DemoApplication::renderme() BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; - bool useBulletLCP = !(getDebugMode() & IDebugDraw::DBG_DisableBulletLCP); + bool useBulletLCP = !(getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP); - bool useCCD = (getDebugMode() & IDebugDraw::DBG_EnableCCD); + bool useCCD = (getDebugMode() & btIDebugDraw::DBG_EnableCCD); glRasterPos3f(xOffset,yStart,0); sprintf(buf,"m Bullet GJK = %i",!isSatEnabled); diff --git a/Demos/OpenGL/DemoApplication.h b/Demos/OpenGL/DemoApplication.h index 31f2ae384..503f98884 100644 --- a/Demos/OpenGL/DemoApplication.h +++ b/Demos/OpenGL/DemoApplication.h @@ -35,14 +35,16 @@ subject to the following restrictions: #include -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdMatrix3x3.h" -#include "LinearMath/SimdTransform.h" - -class CcdPhysicsEnvironment; -class CcdPhysicsController; -class CollisionShape; +#include "LinearMath/btVector3.h" +#include "LinearMath/btMatrix3x3.h" +#include "LinearMath/btTransform.h" +class CcdPhysicsEnvironment; +class CcdPhysicsController; +class btCollisionShape; +class btDynamicsWorld; +class btRigidBody; +class btTypedConstraint; class DemoApplication { @@ -53,18 +55,21 @@ class DemoApplication ///this is the most important class CcdPhysicsEnvironment* m_physicsEnvironmentPtr; + btDynamicsWorld* m_dynamicsWorld; + + btTypedConstraint* m_pickConstraint; float m_cameraDistance; int m_debugMode; float m_ele; float m_azi; - SimdVector3 m_cameraPosition; - SimdVector3 m_cameraTargetPosition;//look at + btVector3 m_cameraPosition; + btVector3 m_cameraTargetPosition;//look at float m_scaleBottom; float m_scaleFactor; - SimdVector3 m_cameraUp; + btVector3 m_cameraUp; int m_forwardAxis; int m_glutScreenWidth; @@ -99,7 +104,7 @@ class DemoApplication return m_physicsEnvironmentPtr; } - void setCameraUp(const SimdVector3& camUp) + void setCameraUp(const btVector3& camUp) { m_cameraUp = camUp; } @@ -114,11 +119,11 @@ class DemoApplication virtual void updateCamera(); - SimdVector3 getCameraPosition() + btVector3 getCameraPosition() { return m_cameraPosition; } - SimdVector3 getCameraTargetPosition() + btVector3 getCameraTargetPosition() { return m_cameraTargetPosition; } @@ -135,11 +140,13 @@ class DemoApplication virtual void clientResetScene() =0 ; ///Demo functions - void shootBox(const SimdVector3& destination); + void shootBox(const btVector3& destination); - SimdVector3 GetRayTo(int x,int y); + btVector3 GetRayTo(int x,int y); - CcdPhysicsController* LocalCreatePhysicsObject(bool isDynamic, float mass, const SimdTransform& startTransform,CollisionShape* shape); + CcdPhysicsController* LocalCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape); + + btRigidBody* LocalCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape); ///callback methods by glut diff --git a/Demos/OpenGL/GLDebugDrawer.cpp b/Demos/OpenGL/GLDebugDrawer.cpp index 716fd5782..605b49ad5 100644 --- a/Demos/OpenGL/GLDebugDrawer.cpp +++ b/Demos/OpenGL/GLDebugDrawer.cpp @@ -1,6 +1,6 @@ #include "GLDebugDrawer.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btPoint3.h" #ifdef WIN32 //needed for glut.h #include @@ -22,7 +22,7 @@ GLDebugDrawer::GLDebugDrawer() { } -void GLDebugDrawer::DrawLine(const SimdVector3& from,const SimdVector3& to,const SimdVector3& color) +void GLDebugDrawer::DrawLine(const btVector3& from,const btVector3& to,const btVector3& color) { if (m_debugMode > 0) { @@ -40,12 +40,12 @@ void GLDebugDrawer::SetDebugMode(int debugMode) } -void GLDebugDrawer::DrawContactPoint(const SimdVector3& pointOnB,const SimdVector3& normalOnB,float distance,int lifeTime,const SimdVector3& color) +void GLDebugDrawer::DrawContactPoint(const btVector3& pointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color) { - if (m_debugMode & IDebugDraw::DBG_DrawContactPoints) + if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints) { - SimdVector3 to=pointOnB+normalOnB*distance; - const SimdVector3&from = pointOnB; + btVector3 to=pointOnB+normalOnB*distance; + const btVector3&from = pointOnB; glBegin(GL_LINES); glColor3f(color.getX(), color.getY(), color.getZ()); glVertex3d(from.getX(), from.getY(), from.getZ()); diff --git a/Demos/OpenGL/GLDebugDrawer.h b/Demos/OpenGL/GLDebugDrawer.h index 2a4942580..7904cbdfa 100644 --- a/Demos/OpenGL/GLDebugDrawer.h +++ b/Demos/OpenGL/GLDebugDrawer.h @@ -1,11 +1,11 @@ #ifndef GL_DEBUG_DRAWER_H #define GL_DEBUG_DRAWER_H -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" -class GLDebugDrawer : public IDebugDraw +class GLDebugDrawer : public btIDebugDraw { int m_debugMode; @@ -13,9 +13,9 @@ public: GLDebugDrawer(); - virtual void DrawLine(const SimdVector3& from,const SimdVector3& to,const SimdVector3& color); + virtual void DrawLine(const btVector3& from,const btVector3& to,const btVector3& color); - virtual void DrawContactPoint(const SimdVector3& PointOnB,const SimdVector3& normalOnB,float distance,int lifeTime,const SimdVector3& color); + virtual void DrawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color); virtual void SetDebugMode(int debugMode); diff --git a/Demos/OpenGL/GL_ShapeDrawer.cpp b/Demos/OpenGL/GL_ShapeDrawer.cpp index 9cad8907b..0f9887a8f 100644 --- a/Demos/OpenGL/GL_ShapeDrawer.cpp +++ b/Demos/OpenGL/GL_ShapeDrawer.cpp @@ -39,7 +39,7 @@ subject to the following restrictions: #include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" //for debugmodes #include "BMF_Api.h" #include //printf debugging @@ -63,11 +63,11 @@ void GL_ShapeDrawer::DrawCoordSystem() { -class GlDrawcallback : public TriangleCallback +class GlDrawcallback : public btTriangleCallback { public: - virtual void ProcessTriangle(SimdVector3* triangle,int partId, int triangleIndex) + virtual void ProcessTriangle(btVector3* triangle,int partId, int triangleIndex) { glBegin(GL_LINES); glColor3f(1, 0, 0); @@ -84,10 +84,10 @@ public: } }; -class TriangleGlDrawcallback : public InternalTriangleIndexCallback +class TriangleGlDrawcallback : public btInternalTriangleIndexCallback { public: - virtual void InternalProcessTriangleIndex(SimdVector3* triangle,int partId,int triangleIndex) + virtual void InternalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) { glBegin(GL_TRIANGLES);//LINES); glColor3f(1, 0, 0); @@ -104,7 +104,7 @@ public: }; -void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const SimdVector3& color,int debugMode) +void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode) { @@ -113,11 +113,11 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim if (shape->GetShapeType() == COMPOUND_SHAPE_PROXYTYPE) { - const CompoundShape* compoundShape = static_cast(shape); + const btCompoundShape* compoundShape = static_cast(shape); for (int i=compoundShape->GetNumChildShapes()-1;i>=0;i--) { - SimdTransform childTrans = compoundShape->GetChildTransform(i); - const CollisionShape* colShape = compoundShape->GetChildShape(i); + btTransform childTrans = compoundShape->GetChildTransform(i); + const btCollisionShape* colShape = compoundShape->GetChildShape(i); float childMat[16]; childTrans.getOpenGLMatrix(childMat); DrawOpenGL(childMat,colShape,color,debugMode); @@ -135,14 +135,14 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim bool useWireframeFallback = true; - if (!(debugMode & IDebugDraw::DBG_DrawWireframe)) + if (!(debugMode & btIDebugDraw::DBG_DrawWireframe)) { switch (shape->GetShapeType()) { case BOX_SHAPE_PROXYTYPE: { - const BoxShape* boxShape = static_cast(shape); - SimdVector3 halfExtent = boxShape->GetHalfExtents(); + const btBoxShape* boxShape = static_cast(shape); + btVector3 halfExtent = boxShape->GetHalfExtents(); glScaled(2*halfExtent[0], 2*halfExtent[1], 2*halfExtent[2]); glutSolidCube(1.0); useWireframeFallback = false; @@ -159,7 +159,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim break; case SPHERE_SHAPE_PROXYTYPE: { - const SphereShape* sphereShape = static_cast(shape); + const btSphereShape* sphereShape = static_cast(shape); float radius = sphereShape->GetMargin();//radius doesn't include the margin, so draw with margin glutSolidSphere(radius,10,10); useWireframeFallback = false; @@ -168,7 +168,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim case MULTI_SPHERE_SHAPE_PROXYTYPE: case CONE_SHAPE_PROXYTYPE: { - const ConeShape* coneShape = static_cast(shape); + const btConeShape* coneShape = static_cast(shape); float radius = coneShape->GetRadius();//+coneShape->GetMargin(); float height = coneShape->GetHeight();//+coneShape->GetMargin(); //glRotatef(-90.0, 1.0, 0.0, 0.0); @@ -187,7 +187,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim case CONVEX_SHAPE_PROXYTYPE: case CYLINDER_SHAPE_PROXYTYPE: { - const CylinderShape* cylinder = static_cast(shape); + const btCylinderShape* cylinder = static_cast(shape); int upAxis = cylinder->GetUpAxis(); GLUquadricObj *quadObj = gluNewQuadric(); @@ -246,7 +246,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim /// for polyhedral shapes if (shape->IsPolyhedral()) { - PolyhedralConvexShape* polyshape = (PolyhedralConvexShape*) shape; + btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape; glBegin(GL_LINES); @@ -255,7 +255,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim int i; for (i=0;iGetNumEdges();i++) { - SimdPoint3 a,b; + btPoint3 a,b; polyshape->GetEdge(i,a,b); glVertex3f(a.getX(),a.getY(),a.getZ()); @@ -266,7 +266,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim glEnd(); - if (debugMode==IDebugDraw::DBG_DrawFeaturesText) + if (debugMode==btIDebugDraw::DBG_DrawFeaturesText) { glRasterPos3f(0.0, 0.0, 0.0); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->GetExtraDebugInfo()); @@ -274,7 +274,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim glColor3f(1.f, 1.f, 1.f); for (i=0;iGetNumVertices();i++) { - SimdPoint3 vtx; + btPoint3 vtx; polyshape->GetVertex(i,vtx); glRasterPos3f(vtx.x(), vtx.y(), vtx.z()); char buf[12]; @@ -284,10 +284,10 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim for (i=0;iGetNumPlanes();i++) { - SimdVector3 normal; - SimdPoint3 vtx; + btVector3 normal; + btPoint3 vtx; polyshape->GetPlane(normal,vtx,i); - SimdScalar d = vtx.dot(normal); + btScalar d = vtx.dot(normal); glRasterPos3f(normal.x()*d, normal.y()*d, normal.z()*d); char buf[12]; @@ -303,13 +303,13 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim if (shape->GetShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) { - TriangleMeshShape* concaveMesh = (TriangleMeshShape*) shape; - //SimdVector3 aabbMax(1e30f,1e30f,1e30f); - //SimdVector3 aabbMax(100,100,100);//1e30f,1e30f,1e30f); + btTriangleMeshShape* concaveMesh = (btTriangleMeshShape*) shape; + //btVector3 aabbMax(1e30f,1e30f,1e30f); + //btVector3 aabbMax(100,100,100);//1e30f,1e30f,1e30f); //todo pass camera, for some culling - SimdVector3 aabbMax(1e30f,1e30f,1e30f); - SimdVector3 aabbMin(-1e30f,-1e30f,-1e30f); + btVector3 aabbMax(1e30f,1e30f,1e30f); + btVector3 aabbMin(-1e30f,-1e30f,-1e30f); GlDrawcallback drawCallback; @@ -320,16 +320,17 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim if (shape->GetShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE) { - ConvexTriangleMeshShape* convexMesh = (ConvexTriangleMeshShape*) shape; + btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape; //todo: pass camera for some culling - SimdVector3 aabbMax(1e30f,1e30f,1e30f); - SimdVector3 aabbMin(-1e30f,-1e30f,-1e30f); + btVector3 aabbMax(1e30f,1e30f,1e30f); + btVector3 aabbMin(-1e30f,-1e30f,-1e30f); TriangleGlDrawcallback drawCallback; convexMesh->GetStridingMesh()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax); } + glDisable(GL_DEPTH_BUFFER_BIT); glRasterPos3f(0,0,0);//mvtx.x(), vtx.y(), vtx.z()); if (debugMode&IDebugDraw::DBG_DrawText) @@ -342,7 +343,6 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->GetExtraDebugInfo()); } glEnable(GL_DEPTH_BUFFER_BIT); - // glPopMatrix(); } diff --git a/Demos/OpenGL/GL_ShapeDrawer.h b/Demos/OpenGL/GL_ShapeDrawer.h index 2e1dfecc1..a37f3799e 100644 --- a/Demos/OpenGL/GL_ShapeDrawer.h +++ b/Demos/OpenGL/GL_ShapeDrawer.h @@ -15,15 +15,15 @@ subject to the following restrictions: #ifndef GL_SHAPE_DRAWER_H #define GL_SHAPE_DRAWER_H -class CollisionShape; -#include "LinearMath/SimdVector3.h" +class btCollisionShape; +#include "LinearMath/btVector3.h" /// OpenGL shape drawing class GL_ShapeDrawer { public: - static void DrawOpenGL(float* m, const CollisionShape* shape, const SimdVector3& color,int debugMode); + static void DrawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode); static void DrawCoordSystem(); }; diff --git a/Demos/OpenGL/GL_Simplex1to4.cpp b/Demos/OpenGL/GL_Simplex1to4.cpp index fc577a34b..93a744590 100644 --- a/Demos/OpenGL/GL_Simplex1to4.cpp +++ b/Demos/OpenGL/GL_Simplex1to4.cpp @@ -26,7 +26,7 @@ subject to the following restrictions: #else #include #endif -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btTransform.h" GL_Simplex1to4::GL_Simplex1to4() :m_simplexSolver(0) @@ -38,7 +38,7 @@ GL_Simplex1to4::GL_Simplex1to4() /// void GL_Simplex1to4::CalcClosest(float* m) { - SimdTransform tr; + btTransform tr; tr.setFromOpenGLMatrix(m); @@ -50,12 +50,12 @@ void GL_Simplex1to4::CalcClosest(float* m) m_simplexSolver->reset(); bool res; - SimdVector3 v; + btVector3 v; for (int i=0;iaddVertex(v,v,SimdPoint3(0.f,0.f,0.f)); + m_simplexSolver->addVertex(v,v,btPoint3(0.f,0.f,0.f)); res = m_simplexSolver->closest(v); } diff --git a/Demos/OpenGL/GL_Simplex1to4.h b/Demos/OpenGL/GL_Simplex1to4.h index 42ad58310..e59d30543 100644 --- a/Demos/OpenGL/GL_Simplex1to4.h +++ b/Demos/OpenGL/GL_Simplex1to4.h @@ -21,9 +21,9 @@ subject to the following restrictions: ///GL_Simplex1to4 is a class to debug a Simplex Solver with 1 to 4 points. ///Can be used by GJK. -class GL_Simplex1to4 : public BU_Simplex1to4 +class GL_Simplex1to4 : public btBU_Simplex1to4 { - SimplexSolverInterface* m_simplexSolver; + btSimplexSolverInterface* m_simplexSolver; public: @@ -31,7 +31,7 @@ class GL_Simplex1to4 : public BU_Simplex1to4 void CalcClosest(float* m); - void SetSimplexSolver(SimplexSolverInterface* simplexSolver) { + void SetSimplexSolver(btSimplexSolverInterface* simplexSolver) { m_simplexSolver = simplexSolver; } diff --git a/Demos/OpenGL/RenderTexture.cpp b/Demos/OpenGL/RenderTexture.cpp index a0ea8ed30..b0baa40b2 100644 --- a/Demos/OpenGL/RenderTexture.cpp +++ b/Demos/OpenGL/RenderTexture.cpp @@ -30,7 +30,7 @@ RenderTexture::RenderTexture(int width,int height) { for (int y=0;y>=1; } diff --git a/Demos/OpenGL/RenderTexture.h b/Demos/OpenGL/RenderTexture.h index 9ac636b2c..b6eea54d7 100644 --- a/Demos/OpenGL/RenderTexture.h +++ b/Demos/OpenGL/RenderTexture.h @@ -16,7 +16,7 @@ subject to the following restrictions: #ifndef RENDER_TEXTURE_H #define RENDER_TEXTURE_H -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" #include "BMF_FontData.h" /// @@ -33,7 +33,7 @@ public: RenderTexture(int width,int height); ~RenderTexture(); - inline void SetPixel(int x,int y,const SimdVector4& rgba) + inline void SetPixel(int x,int y,const btVector4& rgba) { unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4]; diff --git a/Demos/Raytracer/Raytracer.cpp b/Demos/Raytracer/Raytracer.cpp index 3c6e43031..d128f7a54 100644 --- a/Demos/Raytracer/Raytracer.cpp +++ b/Demos/Raytracer/Raytracer.cpp @@ -19,8 +19,8 @@ Very basic raytracer, rendering into a texture. ///Low level demo, doesn't include btBulletCollisionCommon.h #include "GL_Simplex1to4.h" -#include "LinearMath/SimdQuaternion.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btQuaternion.h" +#include "LinearMath/btTransform.h" #include "GL_ShapeDrawer.h" #include "Raytracer.h" @@ -48,7 +48,7 @@ Very basic raytracer, rendering into a texture. #include "RenderTexture.h" -VoronoiSimplexSolver simplexSolver; +btVoronoiSimplexSolver simplexSolver; float yaw=0.f,pitch=0.f,roll=0.f; const int maxNumObjects = 4; @@ -57,8 +57,8 @@ const int numObjects = 4; /// simplex contains the vertices, and some extra code to draw and debug GL_Simplex1to4 simplex; -ConvexShape* shapePtr[maxNumObjects]; -SimdTransform transforms[maxNumObjects]; +btConvexShape* shapePtr[maxNumObjects]; +btTransform transforms[maxNumObjects]; RenderTexture* raytracePicture = 0; @@ -66,12 +66,12 @@ int screenWidth = 128; int screenHeight = 128; GLuint glTextureId; -SphereShape mySphere(1); -BoxShape myBox(SimdVector3(0.4f,0.4f,0.4f)); -CylinderShape myCylinder(SimdVector3(0.3f,0.3f,0.3f)); -ConeShape myCone(1,1); +btSphereShape mySphere(1); +btBoxShape myBox(btVector3(0.4f,0.4f,0.4f)); +btCylinderShape myCylinder(btVector3(0.3f,0.3f,0.3f)); +btConeShape myCone(1,1); -MinkowskiSumShape myMink(&myCylinder,&myBox); +btMinkowskiSumShape myMink(&myCylinder,&myBox); /// @@ -96,25 +96,25 @@ void Raytracer::initPhysics() myCone.SetMargin(0.2f); simplex.SetSimplexSolver(&simplexSolver); - simplex.AddVertex(SimdPoint3(-1,0,-1)); - simplex.AddVertex(SimdPoint3(1,0,-1)); - simplex.AddVertex(SimdPoint3(0,0,1)); - simplex.AddVertex(SimdPoint3(0,1,0)); + simplex.AddVertex(btPoint3(-1,0,-1)); + simplex.AddVertex(btPoint3(1,0,-1)); + simplex.AddVertex(btPoint3(0,0,1)); + simplex.AddVertex(btPoint3(0,1,0)); /// convex hull of 5 spheres #define NUM_SPHERES 5 - SimdVector3 inertiaHalfExtents(10.f,10.f,10.f); - SimdVector3 positions[NUM_SPHERES] = { - SimdVector3(-1.2f, -0.3f, 0.f), - SimdVector3(0.8f, -0.3f, 0.f), - SimdVector3(0.5f, 0.6f, 0.f), - SimdVector3(-0.5f, 0.6f, 0.f), - SimdVector3(0.f, 0.f, 0.f) + btVector3 inertiaHalfExtents(10.f,10.f,10.f); + btVector3 positions[NUM_SPHERES] = { + btVector3(-1.2f, -0.3f, 0.f), + btVector3(0.8f, -0.3f, 0.f), + btVector3(0.5f, 0.6f, 0.f), + btVector3(-0.5f, 0.6f, 0.f), + btVector3(0.f, 0.f, 0.f) }; - // MultiSphereShape* multiSphereShape = new MultiSphereShape(inertiaHalfExtents,positions,radi,NUM_SPHERES); - ConvexHullShape* convexHullShape = new ConvexHullShape(positions,3); + // btMultiSphereShape* multiSphereShape = new btMultiSphereShape(inertiaHalfExtents,positions,radi,NUM_SPHERES); + btConvexHullShape* convexHullShape = new btConvexHullShape(positions,3); //choose shape @@ -146,16 +146,16 @@ void Raytracer::displayCallback() for (int i=0;iSetPixel(x,y,rgba); } } - ConvexCast::CastResult rayResult; - SimdTransform rayToTrans; + btConvexCast::CastResult rayResult; + btTransform rayToTrans; rayToTrans.setIdentity(); - SimdVector3 rayTo; + btVector3 rayTo; for (int x=0;x 1.f) light = 1.f; - rgba = SimdVector4(light,light,light,1.f); + rgba = btVector4(light,light,light,1.f); raytracePicture->SetPixel(x,y,rgba); } else { //clear is already done - //rgba = SimdVector4(0.f,0.f,0.f,0.f); + //rgba = btVector4(0.f,0.f,0.f,0.f); //raytracePicture->SetPixel(x,y,rgba); } @@ -386,7 +386,7 @@ void Raytracer::displayCallback() transA.getOpenGLMatrix( m ); /// draw the simplex - GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],SimdVector3(1,1,1)); + GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1)); /// calculate closest point from simplex to the origin, and draw this vector simplex.CalcClosest(m); diff --git a/Demos/SimplexDemo/SimplexDemo.cpp b/Demos/SimplexDemo/SimplexDemo.cpp index 5d31f2a2b..78fcfd5d1 100644 --- a/Demos/SimplexDemo/SimplexDemo.cpp +++ b/Demos/SimplexDemo/SimplexDemo.cpp @@ -19,15 +19,15 @@ subject to the following restrictions: */ #include "GL_Simplex1to4.h" -#include "LinearMath/SimdQuaternion.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btQuaternion.h" +#include "LinearMath/btTransform.h" #include "GL_ShapeDrawer.h" #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" #include "SimplexDemo.h" #include "GlutStuff.h" -VoronoiSimplexSolver simplexSolver; +btVoronoiSimplexSolver simplexSolver; @@ -40,7 +40,7 @@ int screenHeight = 480; GL_Simplex1to4 simplex; -PolyhedralConvexShape* shapePtr[maxNumObjects]; +btPolyhedralConvexShape* shapePtr[maxNumObjects]; /// @@ -78,17 +78,17 @@ void SimplexDemo::displayCallback() for (i=0;im_collisionFlags |= CollisionObject::customMaterialCallback; -inline SimdScalar calculateCombinedFriction(float friction0,float friction1) +///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback; +inline btScalar calculateCombinedFriction(float friction0,float friction1) { - SimdScalar friction = friction0 * friction1; + btScalar friction = friction0 * friction1; - const SimdScalar MAX_FRICTION = 10.f; + const btScalar MAX_FRICTION = 10.f; if (friction < -MAX_FRICTION) friction = -MAX_FRICTION; if (friction > MAX_FRICTION) @@ -50,7 +50,7 @@ inline SimdScalar calculateCombinedFriction(float friction0,float friction1) } -inline SimdScalar calculateCombinedRestitution(float restitution0,float restitution1) +inline btScalar calculateCombinedRestitution(float restitution0,float restitution1) { return restitution0 * restitution1; } @@ -74,7 +74,7 @@ void UserCollisionAlgorithm::initPhysics() { #define TRISIZE 10.f - int vertStride = sizeof(SimdVector3); + int vertStride = sizeof(btVector3); int indexStride = 3*sizeof(int); const int NUM_VERTS_X = 50; @@ -83,7 +83,7 @@ void UserCollisionAlgorithm::initPhysics() const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1); - SimdVector3* gVertices = new SimdVector3[totalVerts]; + btVector3* gVertices = new btVector3[totalVerts]; int* gIndices = new int[totalTriangles*3]; int i; @@ -111,41 +111,41 @@ void UserCollisionAlgorithm::initPhysics() } } - TriangleIndexVertexArray* indexVertexArrays = new TriangleIndexVertexArray(totalTriangles, + btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles, gIndices, indexStride, totalVerts,(float*) &gVertices[0].x(),vertStride); - CollisionShape* trimeshShape = new BvhTriangleMeshShape(indexVertexArrays); + btCollisionShape* trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays); - //ConstraintSolver* solver = new SequentialImpulseConstraintSolver; + //ConstraintSolver* solver = new btSequentialImpulseConstraintSolver; - CollisionDispatcher* dispatcher = new CollisionDispatcher(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(); - SimdVector3 maxAabb(10000,10000,10000); - OverlappingPairCache* broadphase = new AxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase(); - dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new SphereSphereCollisionAlgorithm::CreateFunc); + btVector3 maxAabb(10000,10000,10000); + btOverlappingPairCache* broadphase = new btAxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase(); + dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc); m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase); bool isDynamic = false; float mass = 0.f; - SimdTransform startTransform; + btTransform startTransform; startTransform.setIdentity(); - startTransform.setOrigin(SimdVector3(0,-2,0)); + startTransform.setOrigin(btVector3(0,-2,0)); CcdPhysicsController* staticTrimesh = LocalCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape); //enable custom material callback - staticTrimesh->GetRigidBody()->m_collisionFlags |= CollisionObject::customMaterialCallback; + staticTrimesh->GetRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback; { for (int i=0;i<10;i++) { - CollisionShape* sphereShape = new SphereShape(1); - startTransform.setOrigin(SimdVector3(1,2*i,1)); + btCollisionShape* sphereShape = new btSphereShape(1); + startTransform.setOrigin(btVector3(1,2*i,1)); LocalCreatePhysicsObject(true, 1, startTransform,sphereShape); } } diff --git a/Demos/VehicleDemo/VehicleDemo.cpp b/Demos/VehicleDemo/VehicleDemo.cpp index cb082567f..81836f87a 100644 --- a/Demos/VehicleDemo/VehicleDemo.cpp +++ b/Demos/VehicleDemo/VehicleDemo.cpp @@ -28,8 +28,8 @@ subject to the following restrictions: #include "ParallelIslandDispatcher.h" -#include "LinearMath/GenQuickprof.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btQuickprof.h" +#include "LinearMath/btIDebugDraw.h" #include "GLDebugDrawer.h" @@ -51,7 +51,7 @@ const int maxOverlap = 65535; DefaultMotionState wheelMotionState[4]; -///PHY_IVehicle is the interface behind the constraint that implements the raycast vehicle (WrapperVehicle which holds a RaycastVehicle) +///PHY_IVehicle is the interface behind the constraint that implements the raycast vehicle (WrapperVehicle which holds a btRaycastVehicle) ///notice that for higher-quality slow-moving vehicles, another approach might be better ///implementing explicit hinged-wheel constraints with cylinder collision, rather then raycasts PHY_IVehicle* gVehicleConstraint=0; @@ -67,9 +67,9 @@ float suspensionStiffness = 10.f; float suspensionDamping = 1.3f; float suspensionCompression = 2.4f; float rollInfluence = 0.1f; -SimdVector3 wheelDirectionCS0(0,-1,0); -SimdVector3 wheelAxleCS(1,0,0); -SimdScalar suspensionRestLength(0.6); +btVector3 wheelDirectionCS0(0,-1,0); +btVector3 wheelAxleCS(1,0,0); +btScalar suspensionRestLength(0.6); #define CUBE_HALF_EXTENTS 1 @@ -98,20 +98,20 @@ m_cameraHeight(4.f), m_minCameraDistance(3.f), m_maxCameraDistance(10.f) { - m_cameraPosition = SimdVector3(30,30,30); + m_cameraPosition = btVector3(30,30,30); } void VehicleDemo::setupPhysics() { - CollisionDispatcher* dispatcher = new CollisionDispatcher(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(); ParallelIslandDispatcher* dispatcher2 = new ParallelIslandDispatcher(); - SimdVector3 worldAabbMin(-30000,-30000,-30000); - SimdVector3 worldAabbMax(30000,30000,30000); + btVector3 worldAabbMin(-30000,-30000,-30000); + btVector3 worldAabbMax(30000,30000,30000); - OverlappingPairCache* broadphase = new AxisSweep3(worldAabbMin,worldAabbMax,maxProxies); - //OverlappingPairCache* broadphase = new SimpleBroadphase(maxProxies,maxOverlap); + btOverlappingPairCache* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies); + //OverlappingPairCache* broadphase = new btSimpleBroadphase(maxProxies,maxOverlap); #ifdef USE_PARALLEL_DISPATCHER m_physicsEnvironmentPtr = new ParallelPhysicsEnvironment(dispatcher2,broadphase); @@ -125,7 +125,7 @@ void VehicleDemo::setupPhysics() m_physicsEnvironmentPtr->setGravity(0,-10,0);//0,0);//-10,0); int i; - CollisionShape* groundShape = new BoxShape(SimdVector3(50,3,50)); + btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50)); #define USE_TRIMESH_GROUND 1 #ifdef USE_TRIMESH_GROUND @@ -134,7 +134,7 @@ void VehicleDemo::setupPhysics() const float TRIANGLE_SIZE=20.f; //create a triangle-mesh ground - int vertStride = sizeof(SimdVector3); + int vertStride = sizeof(btVector3); int indexStride = 3*sizeof(int); const int NUM_VERTS_X = 50; @@ -143,7 +143,7 @@ const float TRIANGLE_SIZE=20.f; const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1); - SimdVector3* gVertices = new SimdVector3[totalVerts]; + btVector3* gVertices = new btVector3[totalVerts]; int* gIndices = new int[totalTriangles*3]; @@ -171,25 +171,25 @@ const float TRIANGLE_SIZE=20.f; } } - TriangleIndexVertexArray* indexVertexArrays = new TriangleIndexVertexArray(totalTriangles, + btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles, gIndices, indexStride, totalVerts,(float*) &gVertices[0].x(),vertStride); - groundShape = new BvhTriangleMeshShape(indexVertexArrays); + groundShape = new btBvhTriangleMeshShape(indexVertexArrays); #endif // - SimdTransform tr; + btTransform tr; tr.setIdentity(); - tr.setOrigin(SimdVector3(0,-20.f,0)); + tr.setOrigin(btVector3(0,-20.f,0)); //create ground object LocalCreatePhysicsObject(false,0,tr,groundShape); - CollisionShape* chassisShape = new BoxShape(SimdVector3(1.f,0.5f,2.f)); - tr.setOrigin(SimdVector3(0,0.f,0)); + btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f,0.5f,2.f)); + tr.setOrigin(btVector3(0,0.f,0)); m_carChassis = LocalCreatePhysicsObject(true,800,tr,chassisShape); @@ -212,8 +212,8 @@ const float TRIANGLE_SIZE=20.f; gVehicleConstraint = m_physicsEnvironmentPtr->getVehicleConstraint(constraintId); - SimdVector3 connectionPointCS0(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); - RaycastVehicle::VehicleTuning tuning; + btVector3 connectionPointCS0(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); + btRaycastVehicle::btVehicleTuning tuning; bool isFrontWheel=true; int rightIndex = 0; int upIndex = 1; @@ -225,18 +225,18 @@ const float TRIANGLE_SIZE=20.f; (PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); - connectionPointCS0 = SimdVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); + connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); gVehicleConstraint->AddWheel(&wheelMotionState[1], (PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); - connectionPointCS0 = SimdVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); + connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); isFrontWheel = false; gVehicleConstraint->AddWheel(&wheelMotionState[2], (PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); - connectionPointCS0 = SimdVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); + connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); gVehicleConstraint->AddWheel(&wheelMotionState[3], (PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); @@ -281,8 +281,8 @@ void VehicleDemo::renderme() float m[16]; int i; - CylinderShapeX wheelShape(SimdVector3(wheelWidth,wheelRadius,wheelRadius)); - SimdVector3 wheelColor(1,0,0); + btCylinderShapeX wheelShape(btVector3(wheelWidth,wheelRadius,wheelRadius)); + btVector3 wheelColor(1,0,0); for (i=0;i<4;i++) { @@ -319,14 +319,14 @@ void VehicleDemo::clientMoveAndDisplay() #ifdef USE_QUICKPROF - Profiler::beginBlock("render"); + btProfiler::beginBlock("render"); #endif //USE_QUICKPROF renderme(); #ifdef USE_QUICKPROF - Profiler::endBlock("render"); + btProfiler::endBlock("render"); #endif glFlush(); glutSwapBuffers(); @@ -420,7 +420,7 @@ void VehicleDemo::updateCamera() //interpolate the camera height m_cameraPosition[1] = (15.0*m_cameraPosition[1] + m_cameraTargetPosition[1] + m_cameraHeight)/16.0; - SimdVector3 camToObject = m_cameraTargetPosition - m_cameraPosition; + btVector3 camToObject = m_cameraTargetPosition - m_cameraPosition; //keep distance between min and max distance float cameraDistance = camToObject.length(); diff --git a/Extras/AlgebraicCCD/BU_AlgebraicPolynomialSolver.cpp b/Extras/AlgebraicCCD/BU_AlgebraicPolynomialSolver.cpp index f20bb7e32..735e36ad0 100644 --- a/Extras/AlgebraicCCD/BU_AlgebraicPolynomialSolver.cpp +++ b/Extras/AlgebraicCCD/BU_AlgebraicPolynomialSolver.cpp @@ -16,23 +16,23 @@ subject to the following restrictions: #include "BU_AlgebraicPolynomialSolver.h" #include -#include +#include -int BU_AlgebraicPolynomialSolver::Solve2Quadratic(SimdScalar p, SimdScalar q) +int BU_AlgebraicPolynomialSolver::Solve2Quadratic(btScalar p, btScalar q) { - SimdScalar basic_h_local; - SimdScalar basic_h_local_delta; + btScalar basic_h_local; + btScalar basic_h_local_delta; basic_h_local = p * 0.5f; basic_h_local_delta = basic_h_local * basic_h_local - q; if (basic_h_local_delta > 0.0f) { - basic_h_local_delta = SimdSqrt(basic_h_local_delta); + basic_h_local_delta = btSqrt(basic_h_local_delta); m_roots[0] = - basic_h_local + basic_h_local_delta; m_roots[1] = - basic_h_local - basic_h_local_delta; return 2; } - else if (SimdGreaterEqual(basic_h_local_delta, SIMD_EPSILON)) { + else if (btGreaterEqual(basic_h_local_delta, SIMD_EPSILON)) { m_roots[0] = - basic_h_local; return 1; } @@ -42,13 +42,13 @@ int BU_AlgebraicPolynomialSolver::Solve2Quadratic(SimdScalar p, SimdScalar q) } -int BU_AlgebraicPolynomialSolver::Solve2QuadraticFull(SimdScalar a,SimdScalar b, SimdScalar c) +int BU_AlgebraicPolynomialSolver::Solve2QuadraticFull(btScalar a,btScalar b, btScalar c) { - SimdScalar radical = b * b - 4.0f * a * c; + btScalar radical = b * b - 4.0f * a * c; if(radical >= 0.f) { - SimdScalar sqrtRadical = SimdSqrt(radical); - SimdScalar idenom = 1.0f/(2.0f * a); + btScalar sqrtRadical = btSqrt(radical); + btScalar idenom = 1.0f/(2.0f * a); m_roots[0]=(-b + sqrtRadical) * idenom; m_roots[1]=(-b - sqrtRadical) * idenom; return 2; @@ -58,8 +58,8 @@ int BU_AlgebraicPolynomialSolver::Solve2QuadraticFull(SimdScalar a,SimdScalar b, #define cubic_rt(x) \ - ((x) > 0.0f ? SimdPow((SimdScalar)(x), 0.333333333333333333333333f) : \ - ((x) < 0.0f ? -SimdPow((SimdScalar)-(x), 0.333333333333333333333333f) : 0.0f)) + ((x) > 0.0f ? btPow((btScalar)(x), 0.333333333333333333333333f) : \ + ((x) < 0.0f ? -btPow((btScalar)-(x), 0.333333333333333333333333f) : 0.0f)) @@ -72,26 +72,26 @@ int BU_AlgebraicPolynomialSolver::Solve2QuadraticFull(SimdScalar a,SimdScalar b, /* it returns the number of different roots found, and stores the roots in */ /* roots[0,2]. it returns -1 for a degenerate equation 0 = 0. */ /* */ -int BU_AlgebraicPolynomialSolver::Solve3Cubic(SimdScalar lead, SimdScalar a, SimdScalar b, SimdScalar c) +int BU_AlgebraicPolynomialSolver::Solve3Cubic(btScalar lead, btScalar a, btScalar b, btScalar c) { - SimdScalar p, q, r; - SimdScalar delta, u, phi; - SimdScalar dummy; + btScalar p, q, r; + btScalar delta, u, phi; + btScalar dummy; if (lead != 1.0) { /* */ /* transform into normal form: x^3 + a x^2 + b x + c = 0 */ /* */ - if (SimdEqual(lead, SIMD_EPSILON)) { + if (btEqual(lead, SIMD_EPSILON)) { /* */ /* we have a x^2 + b x + c = 0 */ /* */ - if (SimdEqual(a, SIMD_EPSILON)) { + if (btEqual(a, SIMD_EPSILON)) { /* */ /* we have b x + c = 0 */ /* */ - if (SimdEqual(b, SIMD_EPSILON)) { - if (SimdEqual(c, SIMD_EPSILON)) { + if (btEqual(b, SIMD_EPSILON)) { + if (btEqual(c, SIMD_EPSILON)) { return -1; } else { @@ -128,8 +128,8 @@ int BU_AlgebraicPolynomialSolver::Solve3Cubic(SimdScalar lead, SimdScalar a, Sim /* */ /* now use Cardano's formula */ /* */ - if (SimdEqual(p, SIMD_EPSILON)) { - if (SimdEqual(q, SIMD_EPSILON)) { + if (btEqual(p, SIMD_EPSILON)) { + if (btEqual(q, SIMD_EPSILON)) { /* */ /* one triple root */ /* */ @@ -151,7 +151,7 @@ int BU_AlgebraicPolynomialSolver::Solve3Cubic(SimdScalar lead, SimdScalar a, Sim /* */ /* one real and two complex roots. note that v = -p / u. */ /* */ - u = -q + SimdSqrt(delta); + u = -q + btSqrt(delta); u = cubic_rt(u); m_roots[0] = u - p / u - a; return 1; @@ -160,19 +160,19 @@ int BU_AlgebraicPolynomialSolver::Solve3Cubic(SimdScalar lead, SimdScalar a, Sim /* */ /* Casus irreducibilis: we have three real roots */ /* */ - r = SimdSqrt(-p); + r = btSqrt(-p); p *= -r; r *= 2.0; - phi = SimdAcos(-q / p) / 3.0f; + phi = btAcos(-q / p) / 3.0f; dummy = SIMD_2_PI / 3.0f; - m_roots[0] = r * SimdCos(phi) - a; - m_roots[1] = r * SimdCos(phi + dummy) - a; - m_roots[2] = r * SimdCos(phi - dummy) - a; + m_roots[0] = r * btCos(phi) - a; + m_roots[1] = r * btCos(phi + dummy) - a; + m_roots[2] = r * btCos(phi - dummy) - a; return 3; } else { /* */ - /* one single and one SimdScalar root */ + /* one single and one btScalar root */ /* */ r = cubic_rt(-q); m_roots[0] = 2.0f * r - a; @@ -191,31 +191,31 @@ int BU_AlgebraicPolynomialSolver::Solve3Cubic(SimdScalar lead, SimdScalar a, Sim /* it returns the number of different roots found, and stores the roots in */ /* roots[0,3]. it returns -1 for a degenerate equation 0 = 0. */ /* */ -int BU_AlgebraicPolynomialSolver::Solve4Quartic(SimdScalar lead, SimdScalar a, SimdScalar b, SimdScalar c, SimdScalar d) +int BU_AlgebraicPolynomialSolver::Solve4Quartic(btScalar lead, btScalar a, btScalar b, btScalar c, btScalar d) { - SimdScalar p, q ,r; - SimdScalar u, v, w; + btScalar p, q ,r; + btScalar u, v, w; int i, num_roots, num_tmp; - //SimdScalar tmp[2]; + //btScalar tmp[2]; if (lead != 1.0) { /* */ /* transform into normal form: x^4 + a x^3 + b x^2 + c x + d = 0 */ /* */ - if (SimdEqual(lead, SIMD_EPSILON)) { + if (btEqual(lead, SIMD_EPSILON)) { /* */ /* we have a x^3 + b x^2 + c x + d = 0 */ /* */ - if (SimdEqual(a, SIMD_EPSILON)) { + if (btEqual(a, SIMD_EPSILON)) { /* */ /* we have b x^2 + c x + d = 0 */ /* */ - if (SimdEqual(b, SIMD_EPSILON)) { + if (btEqual(b, SIMD_EPSILON)) { /* */ /* we have c x + d = 0 */ /* */ - if (SimdEqual(c, SIMD_EPSILON)) { - if (SimdEqual(d, SIMD_EPSILON)) { + if (btEqual(c, SIMD_EPSILON)) { + if (btEqual(d, SIMD_EPSILON)) { return -1; } else { @@ -254,7 +254,7 @@ int BU_AlgebraicPolynomialSolver::Solve4Quartic(SimdScalar lead, SimdScalar a, S p = b - 6.0f * a * a; q = a * (8.0f * a * a - 2.0f * b) + c; r = a * (a * (b - 3.f * a * a) - c) + d; - if (SimdEqual(q, SIMD_EPSILON)) { + if (btEqual(q, SIMD_EPSILON)) { /* */ /* biquadratic equation: y^4 + p y^2 + r = 0. */ /* */ @@ -263,23 +263,23 @@ int BU_AlgebraicPolynomialSolver::Solve4Quartic(SimdScalar lead, SimdScalar a, S if (m_roots[0] > 0.0f) { if (num_roots > 1) { if ((m_roots[1] > 0.0f) && (m_roots[1] != m_roots[0])) { - u = SimdSqrt(m_roots[1]); + u = btSqrt(m_roots[1]); m_roots[2] = u - a; m_roots[3] = -u - a; - u = SimdSqrt(m_roots[0]); + u = btSqrt(m_roots[0]); m_roots[0] = u - a; m_roots[1] = -u - a; return 4; } else { - u = SimdSqrt(m_roots[0]); + u = btSqrt(m_roots[0]); m_roots[0] = u - a; m_roots[1] = -u - a; return 2; } } else { - u = SimdSqrt(m_roots[0]); + u = btSqrt(m_roots[0]); m_roots[0] = u - a; m_roots[1] = -u - a; return 2; @@ -288,7 +288,7 @@ int BU_AlgebraicPolynomialSolver::Solve4Quartic(SimdScalar lead, SimdScalar a, S } return 0; } - else if (SimdEqual(r, SIMD_EPSILON)) { + else if (btEqual(r, SIMD_EPSILON)) { /* */ /* no absolute term: y (y^3 + p y + q) = 0. */ /* */ @@ -321,17 +321,17 @@ int BU_AlgebraicPolynomialSolver::Solve4Quartic(SimdScalar lead, SimdScalar a, S u = w * w - r; v = 2.0f * w - p; - if (SimdEqual(u, SIMD_EPSILON)) + if (btEqual(u, SIMD_EPSILON)) u = 0.0; else if (u > 0.0f) - u = SimdSqrt(u); + u = btSqrt(u); else return 0; - if (SimdEqual(v, SIMD_EPSILON)) + if (btEqual(v, SIMD_EPSILON)) v = 0.0; else if (v > 0.0f) - v = SimdSqrt(v); + v = btSqrt(v); else return 0; @@ -343,7 +343,7 @@ int BU_AlgebraicPolynomialSolver::Solve4Quartic(SimdScalar lead, SimdScalar a, S m_roots[i] -= a; } w += 2.0f *u; - SimdScalar tmp[2]; + btScalar tmp[2]; tmp[0] = m_roots[0]; tmp[1] = m_roots[1]; diff --git a/Extras/AlgebraicCCD/BU_AlgebraicPolynomialSolver.h b/Extras/AlgebraicCCD/BU_AlgebraicPolynomialSolver.h index 85f88ac8a..52d21a0f5 100644 --- a/Extras/AlgebraicCCD/BU_AlgebraicPolynomialSolver.h +++ b/Extras/AlgebraicCCD/BU_AlgebraicPolynomialSolver.h @@ -26,19 +26,19 @@ class BU_AlgebraicPolynomialSolver : public BUM_PolynomialSolverInterface public: BU_AlgebraicPolynomialSolver() {}; - int Solve2Quadratic(SimdScalar p, SimdScalar q); - int Solve2QuadraticFull(SimdScalar a,SimdScalar b, SimdScalar c); - int Solve3Cubic(SimdScalar lead, SimdScalar a, SimdScalar b, SimdScalar c); - int Solve4Quartic(SimdScalar lead, SimdScalar a, SimdScalar b, SimdScalar c, SimdScalar d); + int Solve2Quadratic(btScalar p, btScalar q); + int Solve2QuadraticFull(btScalar a,btScalar b, btScalar c); + int Solve3Cubic(btScalar lead, btScalar a, btScalar b, btScalar c); + int Solve4Quartic(btScalar lead, btScalar a, btScalar b, btScalar c, btScalar d); - SimdScalar GetRoot(int i) const + btScalar GetRoot(int i) const { return m_roots[i]; } private: - SimdScalar m_roots[4]; + btScalar m_roots[4]; }; diff --git a/Extras/AlgebraicCCD/BU_Collidable.cpp b/Extras/AlgebraicCCD/BU_Collidable.cpp index 80589325d..f88928098 100644 --- a/Extras/AlgebraicCCD/BU_Collidable.cpp +++ b/Extras/AlgebraicCCD/BU_Collidable.cpp @@ -16,10 +16,10 @@ subject to the following restrictions: #include "BU_Collidable.h" #include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include +#include #include "BU_MotionStateInterface.h" -BU_Collidable::BU_Collidable(BU_MotionStateInterface& motion,PolyhedralConvexShape& shape,void* userPointer ) +BU_Collidable::BU_Collidable(BU_MotionStateInterface& motion,btPolyhedralConvexShape& shape,void* userPointer ) :m_motionState(motion),m_shape(shape),m_userPointer(userPointer) { } diff --git a/Extras/AlgebraicCCD/BU_Collidable.h b/Extras/AlgebraicCCD/BU_Collidable.h index a94beb6bc..513acbde1 100644 --- a/Extras/AlgebraicCCD/BU_Collidable.h +++ b/Extras/AlgebraicCCD/BU_Collidable.h @@ -18,14 +18,14 @@ subject to the following restrictions: #define BU_COLLIDABLE -class PolyhedralConvexShape; +class btPolyhedralConvexShape; class BU_MotionStateInterface; -#include +#include class BU_Collidable { public: - BU_Collidable(BU_MotionStateInterface& motion,PolyhedralConvexShape& shape, void* userPointer); + BU_Collidable(BU_MotionStateInterface& motion,btPolyhedralConvexShape& shape, void* userPointer); void* GetUserPointer() const { @@ -41,7 +41,7 @@ public: return m_motionState; } - inline const PolyhedralConvexShape& GetShape() const + inline const btPolyhedralConvexShape& GetShape() const { return m_shape; }; @@ -49,7 +49,7 @@ public: private: BU_MotionStateInterface& m_motionState; - PolyhedralConvexShape& m_shape; + btPolyhedralConvexShape& m_shape; void* m_userPointer; }; diff --git a/Extras/AlgebraicCCD/BU_CollisionPair.cpp b/Extras/AlgebraicCCD/BU_CollisionPair.cpp index 12edccc28..09a36be2c 100644 --- a/Extras/AlgebraicCCD/BU_CollisionPair.cpp +++ b/Extras/AlgebraicCCD/BU_CollisionPair.cpp @@ -23,13 +23,13 @@ subject to the following restrictions: #include "BU_MotionStateInterface.h" #include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" -#include -#include "LinearMath/SimdTransformUtil.h" +#include +#include "LinearMath/btTransformUtil.h" -BU_CollisionPair::BU_CollisionPair(const PolyhedralConvexShape* convexA,const PolyhedralConvexShape* convexB,SimdScalar tolerance) -: m_convexA(convexA),m_convexB(convexB),m_screwing(SimdVector3(0,0,0),SimdVector3(0,0,0)), +BU_CollisionPair::BU_CollisionPair(const btPolyhedralConvexShape* convexA,const btPolyhedralConvexShape* convexB,btScalar tolerance) +: m_convexA(convexA),m_convexB(convexB),m_screwing(btVector3(0,0,0),btVector3(0,0,0)), m_tolerance(tolerance) { @@ -40,55 +40,55 @@ m_tolerance(tolerance) /* -bool BU_CollisionPair::GetTimeOfImpact(const SimdVector3& linearMotionA,const SimdQuaternion& angularMotionA,const SimdVector3& linearMotionB,const SimdQuaternion& angularMotionB, SimdScalar& toi,SimdTransform& impactTransA,SimdTransform& impactTransB) +bool BU_CollisionPair::GetTimeOfImpact(const btVector3& linearMotionA,const btQuaternion& angularMotionA,const btVector3& linearMotionB,const btQuaternion& angularMotionB, btScalar& toi,btTransform& impactTransA,btTransform& impactTransB) */ bool BU_CollisionPair::calcTimeOfImpact( - const SimdTransform& fromA, - const SimdTransform& toA, - const SimdTransform& fromB, - const SimdTransform& toB, + const btTransform& fromA, + const btTransform& toA, + const btTransform& fromB, + const btTransform& toB, CastResult& result) { - SimdVector3 linvelA,angvelA; - SimdVector3 linvelB,angvelB; + btVector3 linvelA,angvelA; + btVector3 linvelB,angvelB; - SimdTransformUtil::CalculateVelocity(fromA,toA,1.f,linvelA,angvelA); - SimdTransformUtil::CalculateVelocity(fromB,toB,1.f,linvelB,angvelB); + btTransformUtil::CalculateVelocity(fromA,toA,1.f,linvelA,angvelA); + btTransformUtil::CalculateVelocity(fromB,toB,1.f,linvelB,angvelB); - SimdVector3 linearMotionA = toA.getOrigin() - fromA.getOrigin(); - SimdQuaternion angularMotionA(0,0,0,1.f); - SimdVector3 linearMotionB = toB.getOrigin() - fromB.getOrigin(); - SimdQuaternion angularMotionB(0,0,0,1); + btVector3 linearMotionA = toA.getOrigin() - fromA.getOrigin(); + btQuaternion angularMotionA(0,0,0,1.f); + btVector3 linearMotionB = toB.getOrigin() - fromB.getOrigin(); + btQuaternion angularMotionB(0,0,0,1); result.m_fraction = 1.f; - SimdTransform impactTransA; - SimdTransform impactTransB; + btTransform impactTransA; + btTransform impactTransB; int index=0; - SimdScalar toiUnscaled=result.m_fraction; - const SimdScalar toiUnscaledLimit = result.m_fraction; + btScalar toiUnscaled=result.m_fraction; + const btScalar toiUnscaledLimit = result.m_fraction; - SimdTransform a2w; + btTransform a2w; a2w = fromA; - SimdTransform b2w = fromB; + btTransform b2w = fromB; /* debugging code { const int numvertsB = m_convexB->GetNumVertices(); for (int v=0;vGetVertex(v,pt); pt = b2w * pt; char buf[1000]; @@ -110,52 +110,52 @@ bool BU_CollisionPair::calcTimeOfImpact( */ - SimdTransform b2wp = b2w; + btTransform b2wp = b2w; b2wp.setOrigin(b2w.getOrigin() + linearMotionB); b2wp.setRotation( b2w.getRotation() + angularMotionB); impactTransB = b2wp; - SimdTransform a2wp; + btTransform a2wp; a2wp.setOrigin(a2w.getOrigin()+ linearMotionA); a2wp.setRotation(a2w.getRotation()+angularMotionA); impactTransA = a2wp; - SimdTransform a2winv; + btTransform a2winv; a2winv = a2w.inverse(); - SimdTransform b2wpinv; + btTransform b2wpinv; b2wpinv = b2wp.inverse(); - SimdTransform b2winv; + btTransform b2winv; b2winv = b2w.inverse(); - SimdTransform a2wpinv; + btTransform a2wpinv; a2wpinv = a2wp.inverse(); //Redon's version with concatenated transforms - SimdTransform relative; + btTransform relative; relative = b2w * b2wpinv * a2wp * a2winv; //relative = a2winv * a2wp * b2wpinv * b2w; - SimdQuaternion qrel; + btQuaternion qrel; relative.getBasis().getRotation(qrel); - SimdVector3 linvel = relative.getOrigin(); + btVector3 linvel = relative.getOrigin(); if (linvel.length() < SCREWEPSILON) { linvel.setValue(0.,0.,0.); } - SimdVector3 angvel; - angvel[0] = 2.f * SimdAsin (qrel[0]); - angvel[1] = 2.f * SimdAsin (qrel[1]); - angvel[2] = 2.f * SimdAsin (qrel[2]); + btVector3 angvel; + angvel[0] = 2.f * btAsin (qrel[0]); + angvel[1] = 2.f * btAsin (qrel[1]); + angvel[2] = 2.f * btAsin (qrel[2]); if (angvel.length() < SCREWEPSILON) { @@ -165,10 +165,10 @@ bool BU_CollisionPair::calcTimeOfImpact( //Redon's version with concatenated transforms m_screwing = BU_Screwing(linvel,angvel); - SimdTransform w2s; + btTransform w2s; m_screwing.LocalMatrix(w2s); - SimdTransform s2w; + btTransform s2w; s2w = w2s.inverse(); //impactTransA = a2w; @@ -176,7 +176,7 @@ bool BU_CollisionPair::calcTimeOfImpact( bool hit = false; - if (SimdFuzzyZero(m_screwing.GetS()) && SimdFuzzyZero(m_screwing.GetW())) + if (btFuzzyZero(m_screwing.GetS()) && btFuzzyZero(m_screwing.GetW())) { //W = 0 , S = 0 , no collision //toi = 0; @@ -185,7 +185,7 @@ bool BU_CollisionPair::calcTimeOfImpact( const int numvertsB = m_convexB->GetNumVertices(); for (int v=0;vGetVertex(v,pt); pt = impactTransB * pt; char buf[1000]; @@ -217,7 +217,7 @@ bool BU_CollisionPair::calcTimeOfImpact( //for all edged in A check agains all edges in B for (int ea = 0;ea < m_convexA->GetNumEdges();ea++) { - SimdPoint3 pA0,pA1; + btPoint3 pA0,pA1; m_convexA->GetEdge(ea,pA0,pA1); @@ -231,7 +231,7 @@ bool BU_CollisionPair::calcTimeOfImpact( for (int eb = 0; eb < numedgesB;eb++) { { - SimdPoint3 pB0,pB1; + btPoint3 pB0,pB1; m_convexB->GetEdge(eb,pB0,pB1); pB0= b2w * pB0;//in world space @@ -241,12 +241,12 @@ bool BU_CollisionPair::calcTimeOfImpact( pB1 = w2s * pB1;//in screwing space - SimdScalar lambda,mu; + btScalar lambda,mu; toiUnscaled = 1.; - SimdVector3 edgeDirA(pA1-pA0); - SimdVector3 edgeDirB(pB1-pB0); + btVector3 edgeDirA(pA1-pA0); + btVector3 edgeDirB(pB1-pB0); if (edgeEdge.GetTimeOfImpact(m_screwing,pA0,edgeDirA,pB0,edgeDirB,toiUnscaled,lambda,mu)) { @@ -258,10 +258,10 @@ bool BU_CollisionPair::calcTimeOfImpact( //inside check is already done by checking the mu and gamma ! - SimdPoint3 vtx = pA0+lambda * (pA1-pA0); - SimdPoint3 hitpt = m_screwing.InBetweenPosition(vtx,toiUnscaled); + btPoint3 vtx = pA0+lambda * (pA1-pA0); + btPoint3 hitpt = m_screwing.InBetweenPosition(vtx,toiUnscaled); - SimdPoint3 hitptWorld = s2w * hitpt; + btPoint3 hitptWorld = s2w * hitpt; { if (toiUnscaled < result.m_fraction) @@ -269,7 +269,7 @@ bool BU_CollisionPair::calcTimeOfImpact( hit = true; - SimdVector3 hitNormal = edgeDirB.cross(edgeDirA); + btVector3 hitNormal = edgeDirB.cross(edgeDirA); hitNormal = m_screwing.InBetweenVector(hitNormal,toiUnscaled); @@ -279,9 +279,9 @@ bool BU_CollisionPair::calcTimeOfImpact( //an approximated normal can be calculated by taking the cross product of both edges //take care of the sign ! - SimdVector3 hitNormalWorld = s2w.getBasis() * hitNormal ; + btVector3 hitNormalWorld = s2w.getBasis() * hitNormal ; - SimdScalar dist = m_screwing.GetU().dot(hitNormalWorld); + btScalar dist = m_screwing.GetU().dot(hitNormalWorld); if (dist > 0) hitNormalWorld *= -1; @@ -312,7 +312,7 @@ bool BU_CollisionPair::calcTimeOfImpact( //int v=3; { - SimdPoint3 vtx; + btPoint3 vtx; m_convexA->GetVertex(v,vtx); vtx = a2w * vtx;//in world space @@ -326,23 +326,23 @@ bool BU_CollisionPair::calcTimeOfImpact( { - SimdVector3 planeNorm; - SimdPoint3 planeSupport; + btVector3 planeNorm; + btPoint3 planeSupport; m_convexB->GetPlane(planeNorm,planeSupport,p); planeSupport = b2w * planeSupport;//transform to world space - SimdVector3 planeNormWorld = b2w.getBasis() * planeNorm; + btVector3 planeNormWorld = b2w.getBasis() * planeNorm; planeSupport = w2s * planeSupport ; //transform to screwing space planeNorm = w2s.getBasis() * planeNormWorld; planeNorm.normalize(); - SimdScalar d = planeSupport.dot(planeNorm); + btScalar d = planeSupport.dot(planeNorm); - SimdVector4 planeEq(planeNorm[0],planeNorm[1],planeNorm[2],d); + btVector4 planeEq(planeNorm[0],planeNorm[1],planeNorm[2],d); BU_VertexPoly vtxApolyB; @@ -368,11 +368,11 @@ bool BU_CollisionPair::calcTimeOfImpact( { // printf("toiUnscaled %f\n",toiUnscaled ); - SimdPoint3 hitpt = m_screwing.InBetweenPosition(vtx,toiUnscaled); - SimdVector3 hitNormal = m_screwing.InBetweenVector(planeNorm ,toiUnscaled); + btPoint3 hitpt = m_screwing.InBetweenPosition(vtx,toiUnscaled); + btVector3 hitNormal = m_screwing.InBetweenVector(planeNorm ,toiUnscaled); - SimdVector3 hitNormalWorld = s2w.getBasis() * hitNormal ; - SimdPoint3 hitptWorld = s2w * hitpt; + btVector3 hitNormalWorld = s2w.getBasis() * hitNormal ; + btPoint3 hitptWorld = s2w * hitpt; hitpt = b2winv * hitptWorld; @@ -408,7 +408,7 @@ bool BU_CollisionPair::calcTimeOfImpact( //int v=0; { - SimdPoint3 vtx; + btPoint3 vtx; m_convexB->GetVertex(v,vtx); vtx = b2w * vtx;//in world space @@ -436,23 +436,23 @@ bool BU_CollisionPair::calcTimeOfImpact( { { - SimdVector3 planeNorm; - SimdPoint3 planeSupport; + btVector3 planeNorm; + btPoint3 planeSupport; m_convexA->GetPlane(planeNorm,planeSupport,p); planeSupport = a2w * planeSupport;//transform to world space - SimdVector3 planeNormWorld = a2w.getBasis() * planeNorm; + btVector3 planeNormWorld = a2w.getBasis() * planeNorm; planeSupport = w2s * planeSupport ; //transform to screwing space planeNorm = w2s.getBasis() * planeNormWorld; planeNorm.normalize(); - SimdScalar d = planeSupport.dot(planeNorm); + btScalar d = planeSupport.dot(planeNorm); - SimdVector4 planeEq(planeNorm[0],planeNorm[1],planeNorm[2],d); + btVector4 planeEq(planeNorm[0],planeNorm[1],planeNorm[2],d); BU_VertexPoly vtxBpolyA; @@ -464,15 +464,15 @@ bool BU_CollisionPair::calcTimeOfImpact( { if (toiUnscaled < toiUnscaledLimit) { - SimdPoint3 hitpt = m_screwing.InBetweenPosition( vtx , -toiUnscaled); - SimdVector3 hitNormal = m_screwing.InBetweenVector(-planeNorm ,-toiUnscaled); - //SimdScalar len = hitNormal.length()-1; + btPoint3 hitpt = m_screwing.InBetweenPosition( vtx , -toiUnscaled); + btVector3 hitNormal = m_screwing.InBetweenVector(-planeNorm ,-toiUnscaled); + //btScalar len = hitNormal.length()-1; - //assert( SimdFuzzyZero(len) ); + //assert( btFuzzyZero(len) ); - SimdVector3 hitNormalWorld = s2w.getBasis() * hitNormal ; - SimdPoint3 hitptWorld = s2w * hitpt; + btVector3 hitNormalWorld = s2w.getBasis() * hitNormal ; + btPoint3 hitptWorld = s2w * hitpt; hitpt = a2winv * hitptWorld; @@ -522,19 +522,19 @@ bool BU_CollisionPair::calcTimeOfImpact( } else { - //SimdScalar vel = linearMotionB.length(); + //btScalar vel = linearMotionB.length(); //todo: check this margin result.m_fraction *= 0.99f; //move B to new position impactTransB.setOrigin(b2w.getOrigin()+ result.m_fraction*linearMotionB); - SimdQuaternion ornB = b2w.getRotation()+angularMotionB*result.m_fraction; + btQuaternion ornB = b2w.getRotation()+angularMotionB*result.m_fraction; ornB.normalize(); impactTransB.setRotation(ornB); //now transform A - SimdTransform a2s,a2b; + btTransform a2s,a2b; a2s.mult( w2s , a2w); a2s= m_screwing.InBetweenTransform(a2s,result.m_fraction); a2s.multInverseLeft(w2s,a2s); @@ -543,10 +543,10 @@ bool BU_CollisionPair::calcTimeOfImpact( //transform by motion B impactTransA.mult(impactTransB, a2b); //normalize rotation - SimdQuaternion orn; + btQuaternion orn; impactTransA.getBasis().getRotation(orn); orn.normalize(); - impactTransA.setBasis(SimdMatrix3x3(orn)); + impactTransA.setBasis(btMatrix3x3(orn)); } } @@ -555,7 +555,7 @@ bool BU_CollisionPair::calcTimeOfImpact( const int numvertsB = m_convexB->GetNumVertices(); for (int v=0;vGetVertex(v,pt); pt = impactTransB * pt; char buf[1000]; diff --git a/Extras/AlgebraicCCD/BU_CollisionPair.h b/Extras/AlgebraicCCD/BU_CollisionPair.h index 939cf8a40..69ca15225 100644 --- a/Extras/AlgebraicCCD/BU_CollisionPair.h +++ b/Extras/AlgebraicCCD/BU_CollisionPair.h @@ -21,34 +21,34 @@ subject to the following restrictions: #include -#include +#include -class PolyhedralConvexShape; +class btPolyhedralConvexShape; ///BU_CollisionPair implements collision algorithm for algebraic time of impact calculation of feature based shapes. -class BU_CollisionPair : public ConvexCast +class BU_CollisionPair : public btConvexCast { public: - BU_CollisionPair(const PolyhedralConvexShape* convexA,const PolyhedralConvexShape* convexB,SimdScalar tolerance=0.2f); + BU_CollisionPair(const btPolyhedralConvexShape* convexA,const btPolyhedralConvexShape* convexB,btScalar tolerance=0.2f); //toi virtual bool calcTimeOfImpact( - const SimdTransform& fromA, - const SimdTransform& toA, - const SimdTransform& fromB, - const SimdTransform& toB, + const btTransform& fromA, + const btTransform& toA, + const btTransform& fromB, + const btTransform& toB, CastResult& result); private: - const PolyhedralConvexShape* m_convexA; - const PolyhedralConvexShape* m_convexB; + const btPolyhedralConvexShape* m_convexA; + const btPolyhedralConvexShape* m_convexB; BU_Screwing m_screwing; - SimdScalar m_tolerance; + btScalar m_tolerance; }; #endif //BU_COLLISIONPAIR diff --git a/Extras/AlgebraicCCD/BU_EdgeEdge.cpp b/Extras/AlgebraicCCD/BU_EdgeEdge.cpp index e5261b5a7..8df4c0d91 100644 --- a/Extras/AlgebraicCCD/BU_EdgeEdge.cpp +++ b/Extras/AlgebraicCCD/BU_EdgeEdge.cpp @@ -16,8 +16,8 @@ subject to the following restrictions: #include "BU_EdgeEdge.h" #include "BU_Screwing.h" -#include -#include +#include +#include //#include "BU_IntervalArithmeticPolynomialSolver.h" #include "BU_AlgebraicPolynomialSolver.h" @@ -36,37 +36,37 @@ BU_EdgeEdge::BU_EdgeEdge() bool BU_EdgeEdge::GetTimeOfImpact( const BU_Screwing& screwAB, - const SimdPoint3& a,//edge in object A - const SimdVector3& u, - const SimdPoint3& c,//edge in object B - const SimdVector3& v, - SimdScalar &minTime, - SimdScalar &lambda1, - SimdScalar& mu1 + const btPoint3& a,//edge in object A + const btVector3& u, + const btPoint3& c,//edge in object B + const btVector3& v, + btScalar &minTime, + btScalar &lambda1, + btScalar& mu1 ) { bool hit=false; - SimdScalar lambda; - SimdScalar mu; + btScalar lambda; + btScalar mu; - const SimdScalar w=screwAB.GetW(); - const SimdScalar s=screwAB.GetS(); + const btScalar w=screwAB.GetW(); + const btScalar s=screwAB.GetS(); - if (SimdFuzzyZero(s) && - SimdFuzzyZero(w)) + if (btFuzzyZero(s) && + btFuzzyZero(w)) { //no motion, no collision return false; } - if (SimdFuzzyZero(w) ) + if (btFuzzyZero(w) ) { //pure translation W=0, S <> 0 //no trig, f(t)=t - SimdScalar det = u.y()*v.x()-u.x()*v.y(); - if (!SimdFuzzyZero(det)) + btScalar det = u.y()*v.x()-u.x()*v.y(); + if (!btFuzzyZero(det)) { lambda = (a.x()*v.y() - c.x() * v.y() - v.x() * a.y() + v.x() * c.y()) / det; mu = (u.y() * a.x() - u.y() * c.x() - u.x() * a.y() + u.x() * c.y()) / det; @@ -74,7 +74,7 @@ bool BU_EdgeEdge::GetTimeOfImpact( if (mu >=0 && mu <= 1 && lambda >= 0 && lambda <= 1) { // single potential collision is - SimdScalar t = (c.z()-a.z()+mu*v.z()-lambda*u.z())/s; + btScalar t = (c.z()-a.z()+mu*v.z()-lambda*u.z())/s; //if this is on the edge, and time t within [0..1] report hit if (t>=0 && t <= minTime) { @@ -91,14 +91,14 @@ bool BU_EdgeEdge::GetTimeOfImpact( } } else { - if (SimdFuzzyZero(s) ) + if (btFuzzyZero(s) ) { - if (SimdFuzzyZero(u.z()) ) + if (btFuzzyZero(u.z()) ) { - if (SimdFuzzyZero(v.z()) ) + if (btFuzzyZero(v.z()) ) { //u.z()=0,v.z()=0 - if (SimdFuzzyZero(a.z()-c.z())) + if (btFuzzyZero(a.z()-c.z())) { //printf("NOT YET planar problem, 4 vertex=edge cases\n"); @@ -110,7 +110,7 @@ bool BU_EdgeEdge::GetTimeOfImpact( } else { - SimdScalar mu = (a.z() - c.z())/v.z(); + btScalar mu = (a.z() - c.z())/v.z(); if (0<=mu && mu <= 1) { // printf("NOT YET//u.z()=0,v.z()<>0\n"); @@ -124,22 +124,22 @@ bool BU_EdgeEdge::GetTimeOfImpact( { //u.z()<>0 - if (SimdFuzzyZero(v.z()) ) + if (btFuzzyZero(v.z()) ) { //printf("u.z()<>0,v.z()=0\n"); lambda = (c.z() - a.z())/u.z(); if (0<=lambda && lambda <= 1) { //printf("u.z()<>0,v.z()=0\n"); - SimdPoint3 rotPt(a.x()+lambda * u.x(), a.y()+lambda * u.y(),0.f); - SimdScalar r2 = rotPt.length2();//px*px + py*py; + btPoint3 rotPt(a.x()+lambda * u.x(), a.y()+lambda * u.y(),0.f); + btScalar r2 = rotPt.length2();//px*px + py*py; //either y=a*x+b, or x = a*x+b... //depends on whether value v.x() is zero or not - SimdScalar aa; - SimdScalar bb; + btScalar aa; + btScalar bb; - if (SimdFuzzyZero(v.x())) + if (btFuzzyZero(v.x())) { aa = v.x()/v.y(); bb= c.x()+ (-c.y() /v.y()) *v.x(); @@ -155,21 +155,21 @@ bool BU_EdgeEdge::GetTimeOfImpact( bb= c.y()+ (-c.x() /v.x()) *v.y(); } - SimdScalar disc = aa*aa*r2 + r2 - bb*bb; + btScalar disc = aa*aa*r2 + r2 - bb*bb; if (disc <0) { //edge doesn't intersect the circle (motion of the vertex) return false; } - SimdScalar rad = SimdSqrt(r2); + btScalar rad = btSqrt(r2); - if (SimdFuzzyZero(disc)) + if (btFuzzyZero(disc)) { - SimdPoint3 intersectPt; + btPoint3 intersectPt; - SimdScalar mu; + btScalar mu; //intersectionPoint edge with circle; - if (SimdFuzzyZero(v.x())) + if (btFuzzyZero(v.x())) { intersectPt.setY( (-2*aa*bb)/(2*(aa*aa+1))); intersectPt.setX( aa*intersectPt.y()+bb ); @@ -191,20 +191,20 @@ bool BU_EdgeEdge::GetTimeOfImpact( { //two points... //intersectionPoint edge with circle; - SimdPoint3 intersectPt; + btPoint3 intersectPt; //intersectionPoint edge with circle; - if (SimdFuzzyZero(v.x())) + if (btFuzzyZero(v.x())) { - SimdScalar mu; + btScalar mu; - intersectPt.setY((-2.f*aa*bb+2.f*SimdSqrt(disc))/(2.f*(aa*aa+1.f))); + intersectPt.setY((-2.f*aa*bb+2.f*btSqrt(disc))/(2.f*(aa*aa+1.f))); intersectPt.setX(aa*intersectPt.y()+bb); mu = ((intersectPt.getY()-c.getY())/v.getY()); if (0.f <= mu && mu <= 1.f) { hit = Calc2DRotationPointPoint(rotPt,rad,screwAB.GetW(),intersectPt,minTime); } - intersectPt.setY((-2.f*aa*bb-2.f*SimdSqrt(disc))/(2.f*(aa*aa+1.f))); + intersectPt.setY((-2.f*aa*bb-2.f*btSqrt(disc))/(2.f*(aa*aa+1.f))); intersectPt.setX(aa*intersectPt.y()+bb); mu = ((intersectPt.getY()-c.getY())/v.getY()); if (0 <= mu && mu <= 1) @@ -214,16 +214,16 @@ bool BU_EdgeEdge::GetTimeOfImpact( } else { - SimdScalar mu; + btScalar mu; - intersectPt.setX((-2.f*aa*bb+2.f*SimdSqrt(disc))/(2*(aa*aa+1.f))); + intersectPt.setX((-2.f*aa*bb+2.f*btSqrt(disc))/(2*(aa*aa+1.f))); intersectPt.setY(aa*intersectPt.x()+bb); mu = ((intersectPt.getX()-c.getX())/v.getX()); if (0 <= mu && mu <= 1) { hit = Calc2DRotationPointPoint(rotPt,rad,screwAB.GetW(),intersectPt,minTime); } - intersectPt.setX((-2.f*aa*bb-2.f*SimdSqrt(disc))/(2.f*(aa*aa+1.f))); + intersectPt.setX((-2.f*aa*bb-2.f*btSqrt(disc))/(2.f*(aa*aa+1.f))); intersectPt.setY(aa*intersectPt.x()+bb); mu = ((intersectPt.getX()-c.getX())/v.getX()); if (0.f <= mu && mu <= 1.f) @@ -247,7 +247,7 @@ bool BU_EdgeEdge::GetTimeOfImpact( { //u.z()<>0,v.z()<>0 //printf("general case with s=0\n"); - hit = GetTimeOfImpactGeneralCase(screwAB,a,u,c,v,minTime,lambda,mu); + hit = GetTimeOfImpactbteralCase(screwAB,a,u,c,v,minTime,lambda,mu); if (hit) { lambda1 = lambda; @@ -260,7 +260,7 @@ bool BU_EdgeEdge::GetTimeOfImpact( } else { //printf("general case, W<>0,S<>0\n"); - hit = GetTimeOfImpactGeneralCase(screwAB,a,u,c,v,minTime,lambda,mu); + hit = GetTimeOfImpactbteralCase(screwAB,a,u,c,v,minTime,lambda,mu); if (hit) { lambda1 = lambda; @@ -277,60 +277,60 @@ bool BU_EdgeEdge::GetTimeOfImpact( } -bool BU_EdgeEdge::GetTimeOfImpactGeneralCase( +bool BU_EdgeEdge::GetTimeOfImpactbteralCase( const BU_Screwing& screwAB, - const SimdPoint3& a,//edge in object A - const SimdVector3& u, - const SimdPoint3& c,//edge in object B - const SimdVector3& v, - SimdScalar &minTime, - SimdScalar &lambda, - SimdScalar& mu + const btPoint3& a,//edge in object A + const btVector3& u, + const btPoint3& c,//edge in object B + const btVector3& v, + btScalar &minTime, + btScalar &lambda, + btScalar& mu ) { bool hit = false; - SimdScalar coefs[4]={0.f,0.f,0.f,0.f}; + btScalar coefs[4]={0.f,0.f,0.f,0.f}; BU_Polynomial polynomialSolver; int numroots = 0; - //SimdScalar eps=1e-15f; - //SimdScalar eps2=1e-20f; - SimdScalar s=screwAB.GetS(); - SimdScalar w = screwAB.GetW(); + //btScalar eps=1e-15f; + //btScalar eps2=1e-20f; + btScalar s=screwAB.GetS(); + btScalar w = screwAB.GetW(); - SimdScalar ax = a.x(); - SimdScalar ay = a.y(); - SimdScalar az = a.z(); - SimdScalar cx = c.x(); - SimdScalar cy = c.y(); - SimdScalar cz = c.z(); - SimdScalar vx = v.x(); - SimdScalar vy = v.y(); - SimdScalar vz = v.z(); - SimdScalar ux = u.x(); - SimdScalar uy = u.y(); - SimdScalar uz = u.z(); + btScalar ax = a.x(); + btScalar ay = a.y(); + btScalar az = a.z(); + btScalar cx = c.x(); + btScalar cy = c.y(); + btScalar cz = c.z(); + btScalar vx = v.x(); + btScalar vy = v.y(); + btScalar vz = v.z(); + btScalar ux = u.x(); + btScalar uy = u.y(); + btScalar uz = u.z(); - if (!SimdFuzzyZero(v.z())) + if (!btFuzzyZero(v.z())) { //Maple Autogenerated C code - SimdScalar t1,t2,t3,t4,t7,t8,t10; - SimdScalar t13,t14,t15,t16,t17,t18,t19,t20; - SimdScalar t21,t22,t23,t24,t25,t26,t27,t28,t29,t30; - SimdScalar t31,t32,t33,t34,t35,t36,t39,t40; - SimdScalar t41,t43,t48; - SimdScalar t63; + btScalar t1,t2,t3,t4,t7,t8,t10; + btScalar t13,t14,t15,t16,t17,t18,t19,t20; + btScalar t21,t22,t23,t24,t25,t26,t27,t28,t29,t30; + btScalar t31,t32,t33,t34,t35,t36,t39,t40; + btScalar t41,t43,t48; + btScalar t63; - SimdScalar aa,bb,cc,dd;//the coefficients + btScalar aa,bb,cc,dd;//the coefficients t1 = v.y()*s; t2 = t1*u.x(); t3 = v.x()*s; t4 = t3*u.y(); - t7 = SimdTan(w/2.0f); + t7 = btTan(w/2.0f); t8 = 1.0f/t7; t10 = 1.0f/v.z(); aa = (t2-t4)*t8*t10; @@ -377,17 +377,17 @@ bool BU_EdgeEdge::GetTimeOfImpactGeneralCase( } else { - SimdScalar t1,t2,t3,t4,t7,t8,t10; - SimdScalar t13,t14,t15,t16,t17,t18,t19,t20; - SimdScalar t21,t22,t23,t24,t25,t26,t27,t28,t29,t30; - SimdScalar t31,t32,t33,t34,t35,t36,t37,t38,t57; - SimdScalar p1,p2,p3,p4; + btScalar t1,t2,t3,t4,t7,t8,t10; + btScalar t13,t14,t15,t16,t17,t18,t19,t20; + btScalar t21,t22,t23,t24,t25,t26,t27,t28,t29,t30; + btScalar t31,t32,t33,t34,t35,t36,t37,t38,t57; + btScalar p1,p2,p3,p4; t1 = uy*s; t2 = t1*vx; t3 = ux*s; t4 = t3*vy; - t7 = SimdTan(w/2.0f); + t7 = btTan(w/2.0f); t8 = 1/t7; t10 = 1/uz; t13 = ux*az; @@ -435,38 +435,38 @@ bool BU_EdgeEdge::GetTimeOfImpactGeneralCase( for (int i=0;i=0.f && t= -0.001); //if (hit) @@ -545,10 +545,10 @@ bool BU_EdgeEdge::Calc2DRotationPointPoint(const SimdPoint3& rotPt, SimdScalar r // cos (alpha) = adjacent/hypothenuse; //adjacent = dotproduct(ipedge,point); //hypothenuse = sqrt(r2); - SimdScalar adjacent = intersectPt.dot(rotPt)/rotRadius; - SimdScalar hypo = rotRadius; - SimdScalar alpha = SimdAcos(adjacent/hypo); - SimdScalar t = alpha / rotW; + btScalar adjacent = intersectPt.dot(rotPt)/rotRadius; + btScalar hypo = rotRadius; + btScalar alpha = btAcos(adjacent/hypo); + btScalar t = alpha / rotW; if (t >= 0 && t < minTime) { hit = true; @@ -564,13 +564,13 @@ bool BU_EdgeEdge::Calc2DRotationPointPoint(const SimdPoint3& rotPt, SimdScalar r bool BU_EdgeEdge::GetTimeOfImpactVertexEdge( const BU_Screwing& screwAB, - const SimdPoint3& a,//edge in object A - const SimdVector3& u, - const SimdPoint3& c,//edge in object B - const SimdVector3& v, - SimdScalar &minTime, - SimdScalar &lamda, - SimdScalar& mu + const btPoint3& a,//edge in object A + const btVector3& u, + const btPoint3& c,//edge in object B + const btVector3& v, + btScalar &minTime, + btScalar &lamda, + btScalar& mu ) { diff --git a/Extras/AlgebraicCCD/BU_EdgeEdge.h b/Extras/AlgebraicCCD/BU_EdgeEdge.h index 8c3721dd3..c8c5768a6 100644 --- a/Extras/AlgebraicCCD/BU_EdgeEdge.h +++ b/Extras/AlgebraicCCD/BU_EdgeEdge.h @@ -18,13 +18,13 @@ subject to the following restrictions: #define BU_EDGEEDGE class BU_Screwing; -#include -#include -#include +#include +#include +#include //class BUM_Point2; -#include +#include ///BU_EdgeEdge implements algebraic time of impact calculation between two (angular + linear) moving edges. class BU_EdgeEdge @@ -35,39 +35,39 @@ public: BU_EdgeEdge(); bool GetTimeOfImpact( const BU_Screwing& screwAB, - const SimdPoint3& a,//edge in object A - const SimdVector3& u, - const SimdPoint3& c,//edge in object B - const SimdVector3& v, - SimdScalar &minTime, - SimdScalar &lamda, - SimdScalar& mu + const btPoint3& a,//edge in object A + const btVector3& u, + const btPoint3& c,//edge in object B + const btVector3& v, + btScalar &minTime, + btScalar &lamda, + btScalar& mu ); private: - bool Calc2DRotationPointPoint(const SimdPoint3& rotPt, SimdScalar rotRadius, SimdScalar rotW,const SimdPoint3& intersectPt,SimdScalar& minTime); - bool GetTimeOfImpactGeneralCase( + bool Calc2DRotationPointPoint(const btPoint3& rotPt, btScalar rotRadius, btScalar rotW,const btPoint3& intersectPt,btScalar& minTime); + bool GetTimeOfImpactbteralCase( const BU_Screwing& screwAB, - const SimdPoint3& a,//edge in object A - const SimdVector3& u, - const SimdPoint3& c,//edge in object B - const SimdVector3& v, - SimdScalar &minTime, - SimdScalar &lamda, - SimdScalar& mu + const btPoint3& a,//edge in object A + const btVector3& u, + const btPoint3& c,//edge in object B + const btVector3& v, + btScalar &minTime, + btScalar &lamda, + btScalar& mu ); bool GetTimeOfImpactVertexEdge( const BU_Screwing& screwAB, - const SimdPoint3& a,//edge in object A - const SimdVector3& u, - const SimdPoint3& c,//edge in object B - const SimdVector3& v, - SimdScalar &minTime, - SimdScalar &lamda, - SimdScalar& mu + const btPoint3& a,//edge in object A + const btVector3& u, + const btPoint3& c,//edge in object B + const btVector3& v, + btScalar &minTime, + btScalar &lamda, + btScalar& mu ); diff --git a/Extras/AlgebraicCCD/BU_MotionStateInterface.h b/Extras/AlgebraicCCD/BU_MotionStateInterface.h index 867c7e4ac..513675622 100644 --- a/Extras/AlgebraicCCD/BU_MotionStateInterface.h +++ b/Extras/AlgebraicCCD/BU_MotionStateInterface.h @@ -18,32 +18,32 @@ subject to the following restrictions: #define BU_MOTIONSTATE -#include -#include -#include +#include +#include +#include class BU_MotionStateInterface { public: virtual ~BU_MotionStateInterface(){}; - virtual void SetTransform(const SimdTransform& trans) = 0; - virtual void GetTransform(SimdTransform& trans) const = 0; + virtual void SetTransform(const btTransform& trans) = 0; + virtual void GetTransform(btTransform& trans) const = 0; - virtual void SetPosition(const SimdPoint3& position) = 0; - virtual void GetPosition(SimdPoint3& position) const = 0; + virtual void SetPosition(const btPoint3& position) = 0; + virtual void GetPosition(btPoint3& position) const = 0; - virtual void SetOrientation(const SimdQuaternion& orientation) = 0; - virtual void GetOrientation(SimdQuaternion& orientation) const = 0; + virtual void SetOrientation(const btQuaternion& orientation) = 0; + virtual void GetOrientation(btQuaternion& orientation) const = 0; - virtual void SetBasis(const SimdMatrix3x3& basis) = 0; - virtual void GetBasis(SimdMatrix3x3& basis) const = 0; + virtual void SetBasis(const btMatrix3x3& basis) = 0; + virtual void GetBasis(btMatrix3x3& basis) const = 0; - virtual void SetLinearVelocity(const SimdVector3& linvel) = 0; - virtual void GetLinearVelocity(SimdVector3& linvel) const = 0; + virtual void SetLinearVelocity(const btVector3& linvel) = 0; + virtual void GetLinearVelocity(btVector3& linvel) const = 0; - virtual void GetAngularVelocity(SimdVector3& angvel) const = 0; - virtual void SetAngularVelocity(const SimdVector3& angvel) = 0; + virtual void GetAngularVelocity(btVector3& angvel) const = 0; + virtual void SetAngularVelocity(const btVector3& angvel) = 0; }; diff --git a/Extras/AlgebraicCCD/BU_PolynomialSolverInterface.h b/Extras/AlgebraicCCD/BU_PolynomialSolverInterface.h index beb0be58d..00e3e1294 100644 --- a/Extras/AlgebraicCCD/BU_PolynomialSolverInterface.h +++ b/Extras/AlgebraicCCD/BU_PolynomialSolverInterface.h @@ -15,7 +15,7 @@ subject to the following restrictions: #ifndef BUM_POLYNOMIAL_SOLVER_INTERFACE #define BUM_POLYNOMIAL_SOLVER_INTERFACE -#include +#include // //BUM_PolynomialSolverInterface is interface class for polynomial root finding. //The number of roots is returned as a result, query GetRoot to get the actual solution. @@ -26,13 +26,13 @@ public: virtual ~BUM_PolynomialSolverInterface() {}; -// virtual int Solve2QuadraticFull(SimdScalar a,SimdScalar b, SimdScalar c) = 0; +// virtual int Solve2QuadraticFull(btScalar a,btScalar b, btScalar c) = 0; - virtual int Solve3Cubic(SimdScalar lead, SimdScalar a, SimdScalar b, SimdScalar c) = 0; + virtual int Solve3Cubic(btScalar lead, btScalar a, btScalar b, btScalar c) = 0; - virtual int Solve4Quartic(SimdScalar lead, SimdScalar a, SimdScalar b, SimdScalar c, SimdScalar d) = 0; + virtual int Solve4Quartic(btScalar lead, btScalar a, btScalar b, btScalar c, btScalar d) = 0; - virtual SimdScalar GetRoot(int i) const = 0; + virtual btScalar GetRoot(int i) const = 0; }; diff --git a/Extras/AlgebraicCCD/BU_Screwing.cpp b/Extras/AlgebraicCCD/BU_Screwing.cpp index 8cb982a20..1f5915740 100644 --- a/Extras/AlgebraicCCD/BU_Screwing.cpp +++ b/Extras/AlgebraicCCD/BU_Screwing.cpp @@ -18,15 +18,15 @@ subject to the following restrictions: #include "BU_Screwing.h" -BU_Screwing::BU_Screwing(const SimdVector3& relLinVel,const SimdVector3& relAngVel) { +BU_Screwing::BU_Screwing(const btVector3& relLinVel,const btVector3& relAngVel) { - const SimdScalar dx=relLinVel[0]; - const SimdScalar dy=relLinVel[1]; - const SimdScalar dz=relLinVel[2]; - const SimdScalar wx=relAngVel[0]; - const SimdScalar wy=relAngVel[1]; - const SimdScalar wz=relAngVel[2]; + const btScalar dx=relLinVel[0]; + const btScalar dy=relLinVel[1]; + const btScalar dz=relLinVel[2]; + const btScalar wx=relAngVel[0]; + const btScalar wy=relAngVel[1]; + const btScalar wz=relAngVel[2]; // Compute the screwing parameters : // w : total amount of rotation @@ -34,25 +34,25 @@ BU_Screwing::BU_Screwing(const SimdVector3& relLinVel,const SimdVector3& relAngV // u : vector along the screwing axis (||u||=1) // o : point on the screwing axis - m_w=SimdSqrt(wx*wx+wy*wy+wz*wz); + m_w=btSqrt(wx*wx+wy*wy+wz*wz); //if (!w) { if (fabs(m_w)= BUM_EPSILON2) { if (n1[0] || n1[1] || n1[2]) { // n1 is not the zero vector n1.normalize(); - SimdVector3 n1orth=m_u.cross(n1); + btVector3 n1orth=m_u.cross(n1); - float n2x=SimdCos(0.5f*m_w); - float n2y=SimdSin(0.5f*m_w); + float n2x=btCos(0.5f*m_w); + float n2y=btSin(0.5f*m_w); m_o=0.5f*t.dot(n1)*(n1+n2x/n2y*n1orth); } else { - m_o=SimdPoint3(0.f,0.f,0.f); + m_o=btPoint3(0.f,0.f,0.f); } } @@ -99,7 +99,7 @@ BU_Screwing::BU_Screwing(const SimdVector3& relLinVel,const SimdVector3& relAngV //the screwing frame : -void BU_Screwing::LocalMatrix(SimdTransform &t) const { +void BU_Screwing::LocalMatrix(btTransform &t) const { //So the whole computations do this : align the Oz axis along the // screwing axis (thanks to u), and then find two others orthogonal axes to // complete the basis. @@ -107,9 +107,9 @@ void BU_Screwing::LocalMatrix(SimdTransform &t) const { if ((m_u[0]>SCREWEPSILON)||(m_u[0]<-SCREWEPSILON)||(m_u[1]>SCREWEPSILON)||(m_u[1]<-SCREWEPSILON)) { // to avoid numerical problems - float n=SimdSqrt(m_u[0]*m_u[0]+m_u[1]*m_u[1]); + float n=btSqrt(m_u[0]*m_u[0]+m_u[1]*m_u[1]); float invn=1.0f/n; - SimdMatrix3x3 mat; + btMatrix3x3 mat; mat[0][0]=-m_u[1]*invn; mat[0][1]=m_u[0]*invn; @@ -123,7 +123,7 @@ void BU_Screwing::LocalMatrix(SimdTransform &t) const { mat[2][1]=m_u[1]; mat[2][2]=m_u[2]; - t.setOrigin(SimdPoint3( + t.setOrigin(btPoint3( m_o[0]*m_u[1]*invn-m_o[1]*m_u[0]*invn, -(m_o[0]*mat[1][0]+m_o[1]*mat[1][1]+m_o[2]*n), -(m_o[0]*m_u[0]+m_o[1]*m_u[1]+m_o[2]*m_u[2]))); @@ -133,24 +133,24 @@ void BU_Screwing::LocalMatrix(SimdTransform &t) const { } else { - SimdMatrix3x3 m; + btMatrix3x3 m; m[0][0]=1.; m[1][0]=0.; m[2][0]=0.; m[0][1]=0.f; - m[1][1]=float(SimdSign(m_u[2])); + m[1][1]=float(btSign(m_u[2])); m[2][1]=0.f; m[0][2]=0.f; m[1][2]=0.f; - m[2][2]=float(SimdSign(m_u[2])); + m[2][2]=float(btSign(m_u[2])); - t.setOrigin(SimdPoint3( + t.setOrigin(btPoint3( -m_o[0], - -SimdSign(m_u[2])*m_o[1], - -SimdSign(m_u[2])*m_o[2] + -btSign(m_u[2])*m_o[1], + -btSign(m_u[2])*m_o[2] )); t.setBasis(m); @@ -158,42 +158,42 @@ void BU_Screwing::LocalMatrix(SimdTransform &t) const { } //gives interpolated transform for time in [0..1] in screwing frame -SimdTransform BU_Screwing::InBetweenTransform(const SimdTransform& tr,SimdScalar t) const +btTransform BU_Screwing::InBetweenTransform(const btTransform& tr,btScalar t) const { - SimdPoint3 org = tr.getOrigin(); + btPoint3 org = tr.getOrigin(); - SimdPoint3 neworg ( - org.x()*SimdCos(m_w*t)-org.y()*SimdSin(m_w*t), - org.x()*SimdSin(m_w*t)+org.y()*SimdCos(m_w*t), + btPoint3 neworg ( + org.x()*btCos(m_w*t)-org.y()*btSin(m_w*t), + org.x()*btSin(m_w*t)+org.y()*btCos(m_w*t), org.z()+m_s*CalculateF(t)); - SimdTransform newtr; + btTransform newtr; newtr.setOrigin(neworg); - SimdMatrix3x3 basis = tr.getBasis(); - SimdMatrix3x3 basisorg = tr.getBasis(); + btMatrix3x3 basis = tr.getBasis(); + btMatrix3x3 basisorg = tr.getBasis(); - SimdQuaternion rot(SimdVector3(0.,0.,1.),m_w*t); - SimdQuaternion tmpOrn; + btQuaternion rot(btVector3(0.,0.,1.),m_w*t); + btQuaternion tmpOrn; tr.getBasis().getRotation(tmpOrn); rot = rot * tmpOrn; //to avoid numerical drift, normalize quaternion rot.normalize(); - newtr.setBasis(SimdMatrix3x3(rot)); + newtr.setBasis(btMatrix3x3(rot)); return newtr; } -SimdScalar BU_Screwing::CalculateF(SimdScalar t) const +btScalar BU_Screwing::CalculateF(btScalar t) const { - SimdScalar result; + btScalar result; if (!m_w) { result = t; } else { - result = ( SimdTan((m_w*t)/2.f) / SimdTan(m_w/2.f)); + result = ( btTan((m_w*t)/2.f) / btTan(m_w/2.f)); } return result; } diff --git a/Extras/AlgebraicCCD/BU_Screwing.h b/Extras/AlgebraicCCD/BU_Screwing.h index 8c521c353..f5efa890e 100644 --- a/Extras/AlgebraicCCD/BU_Screwing.h +++ b/Extras/AlgebraicCCD/BU_Screwing.h @@ -18,9 +18,9 @@ subject to the following restrictions: #define B_SCREWING_H -#include -#include -#include +#include +#include +#include #define SCREWEPSILON 0.00001f @@ -31,47 +31,47 @@ class BU_Screwing public: - BU_Screwing(const SimdVector3& relLinVel,const SimdVector3& relAngVel); + BU_Screwing(const btVector3& relLinVel,const btVector3& relAngVel); ~BU_Screwing() { }; - SimdScalar CalculateF(SimdScalar t) const; + btScalar CalculateF(btScalar t) const; //gives interpolated position for time in [0..1] in screwing frame - inline SimdPoint3 InBetweenPosition(const SimdPoint3& pt,SimdScalar t) const + inline btPoint3 InBetweenPosition(const btPoint3& pt,btScalar t) const { - return SimdPoint3( - pt.x()*SimdCos(m_w*t)-pt.y()*SimdSin(m_w*t), - pt.x()*SimdSin(m_w*t)+pt.y()*SimdCos(m_w*t), + return btPoint3( + pt.x()*btCos(m_w*t)-pt.y()*btSin(m_w*t), + pt.x()*btSin(m_w*t)+pt.y()*btCos(m_w*t), pt.z()+m_s*CalculateF(t)); } - inline SimdVector3 InBetweenVector(const SimdVector3& vec,SimdScalar t) const + inline btVector3 InBetweenVector(const btVector3& vec,btScalar t) const { - return SimdVector3( - vec.x()*SimdCos(m_w*t)-vec.y()*SimdSin(m_w*t), - vec.x()*SimdSin(m_w*t)+vec.y()*SimdCos(m_w*t), + return btVector3( + vec.x()*btCos(m_w*t)-vec.y()*btSin(m_w*t), + vec.x()*btSin(m_w*t)+vec.y()*btCos(m_w*t), vec.z()); } //gives interpolated transform for time in [0..1] in screwing frame - SimdTransform InBetweenTransform(const SimdTransform& tr,SimdScalar t) const; + btTransform InBetweenTransform(const btTransform& tr,btScalar t) const; //gives matrix from global frame into screwing frame - void LocalMatrix(SimdTransform &t) const; + void LocalMatrix(btTransform &t) const; - inline const SimdVector3& GetU() const { return m_u;} - inline const SimdVector3& GetO() const {return m_o;} - inline const SimdScalar GetS() const{ return m_s;} - inline const SimdScalar GetW() const { return m_w;} + inline const btVector3& GetU() const { return m_u;} + inline const btVector3& GetO() const {return m_o;} + inline const btScalar GetS() const{ return m_s;} + inline const btScalar GetW() const { return m_w;} private: float m_w; float m_s; - SimdVector3 m_u; - SimdVector3 m_o; + btVector3 m_u; + btVector3 m_o; }; #endif //B_SCREWING_H diff --git a/Extras/AlgebraicCCD/BU_StaticMotionState.h b/Extras/AlgebraicCCD/BU_StaticMotionState.h index e533525c4..86fcbcc94 100644 --- a/Extras/AlgebraicCCD/BU_StaticMotionState.h +++ b/Extras/AlgebraicCCD/BU_StaticMotionState.h @@ -18,62 +18,62 @@ subject to the following restrictions: #define BU_STATIC_MOTIONSTATE -#include +#include class BU_StaticMotionState :public BU_MotionStateInterface { public: virtual ~BU_StaticMotionState(){}; - virtual void SetTransform(const SimdTransform& trans) + virtual void SetTransform(const btTransform& trans) { m_trans = trans; } - virtual void GetTransform(SimdTransform& trans) const + virtual void GetTransform(btTransform& trans) const { trans = m_trans; } - virtual void SetPosition(const SimdPoint3& position) + virtual void SetPosition(const btPoint3& position) { m_trans.setOrigin( position ); } - virtual void GetPosition(SimdPoint3& position) const + virtual void GetPosition(btPoint3& position) const { position = m_trans.getOrigin(); } - virtual void SetOrientation(const SimdQuaternion& orientation) + virtual void SetOrientation(const btQuaternion& orientation) { m_trans.setRotation( orientation); } - virtual void GetOrientation(SimdQuaternion& orientation) const + virtual void GetOrientation(btQuaternion& orientation) const { orientation = m_trans.getRotation(); } - virtual void SetBasis(const SimdMatrix3x3& basis) + virtual void SetBasis(const btMatrix3x3& basis) { m_trans.setBasis( basis); } - virtual void GetBasis(SimdMatrix3x3& basis) const + virtual void GetBasis(btMatrix3x3& basis) const { basis = m_trans.getBasis(); } - virtual void SetLinearVelocity(const SimdVector3& linvel) + virtual void SetLinearVelocity(const btVector3& linvel) { m_linearVelocity = linvel; } - virtual void GetLinearVelocity(SimdVector3& linvel) const + virtual void GetLinearVelocity(btVector3& linvel) const { linvel = m_linearVelocity; } - virtual void SetAngularVelocity(const SimdVector3& angvel) + virtual void SetAngularVelocity(const btVector3& angvel) { m_angularVelocity = angvel; } - virtual void GetAngularVelocity(SimdVector3& angvel) const + virtual void GetAngularVelocity(btVector3& angvel) const { angvel = m_angularVelocity; } @@ -82,9 +82,9 @@ public: protected: - SimdTransform m_trans; - SimdVector3 m_angularVelocity; - SimdVector3 m_linearVelocity; + btTransform m_trans; + btVector3 m_angularVelocity; + btVector3 m_linearVelocity; }; diff --git a/Extras/AlgebraicCCD/BU_VertexPoly.cpp b/Extras/AlgebraicCCD/BU_VertexPoly.cpp index d9e4bc876..2f5fb0edc 100644 --- a/Extras/AlgebraicCCD/BU_VertexPoly.cpp +++ b/Extras/AlgebraicCCD/BU_VertexPoly.cpp @@ -17,9 +17,9 @@ subject to the following restrictions: #include "BU_VertexPoly.h" #include "BU_Screwing.h" -#include -#include -#include +#include +#include +#include #define USE_ALGEBRAIC #ifdef USE_ALGEBRAIC @@ -30,7 +30,7 @@ subject to the following restrictions: #define BU_Polynomial BU_IntervalArithmeticPolynomialSolver #endif -inline bool TestFuzzyZero(SimdScalar x) { return SimdFabs(x) < 0.0001f; } +inline bool TestFuzzyZero(btScalar x) { return btFabs(x) < 0.0001f; } BU_VertexPoly::BU_VertexPoly() @@ -41,9 +41,9 @@ BU_VertexPoly::BU_VertexPoly() //false otherwise. If true, minTime contains the time of impact bool BU_VertexPoly::GetTimeOfImpact( const BU_Screwing& screwAB, - const SimdPoint3& a, - const SimdVector4& planeEq, - SimdScalar &minTime,bool swapAB) + const btPoint3& a, + const btVector4& planeEq, + btScalar &minTime,bool swapAB) { bool hit = false; @@ -57,21 +57,21 @@ bool BU_VertexPoly::GetTimeOfImpact( //case w<>0 and s<> 0 - const SimdScalar w=screwAB.GetW(); - const SimdScalar s=screwAB.GetS(); + const btScalar w=screwAB.GetW(); + const btScalar s=screwAB.GetS(); - SimdScalar coefs[4]; - const SimdScalar p=planeEq[0]; - const SimdScalar q=planeEq[1]; - const SimdScalar r=planeEq[2]; - const SimdScalar d=planeEq[3]; + btScalar coefs[4]; + const btScalar p=planeEq[0]; + const btScalar q=planeEq[1]; + const btScalar r=planeEq[2]; + const btScalar d=planeEq[3]; - const SimdVector3 norm(p,q,r); + const btVector3 norm(p,q,r); BU_Polynomial polynomialSolver; int numroots = 0; - //SimdScalar eps=1e-80f; - //SimdScalar eps2=1e-100f; + //btScalar eps=1e-80f; + //btScalar eps2=1e-100f; if (TestFuzzyZero(screwAB.GetS()) ) { @@ -93,7 +93,7 @@ bool BU_VertexPoly::GetTimeOfImpact( // W = 0 , S <> 0 //pax+qay+r(az+st)=d - SimdScalar dist = (d - a.dot(norm)); + btScalar dist = (d - a.dot(norm)); if (TestFuzzyZero(r)) { @@ -108,7 +108,7 @@ bool BU_VertexPoly::GetTimeOfImpact( } else { - SimdScalar etoi = (dist)/(r*screwAB.GetS()); + btScalar etoi = (dist)/(r*screwAB.GetS()); if (swapAB) etoi *= -1; @@ -124,7 +124,7 @@ bool BU_VertexPoly::GetTimeOfImpact( //ax^3+bx^2+cx+d=0 //degenerate coefficients mess things up :( - SimdScalar ietsje = (r*s)/SimdTan(w/2.f); + btScalar ietsje = (r*s)/btTan(w/2.f); if (ietsje*ietsje < 0.01f) ietsje = 0.f; @@ -140,9 +140,9 @@ bool BU_VertexPoly::GetTimeOfImpact( for (int i=0;i -#include -#include +#include +#include +#include ///BU_VertexPoly implements algebraic time of impact calculation between vertex and a plane. class BU_VertexPoly @@ -30,9 +30,9 @@ public: BU_VertexPoly(); bool GetTimeOfImpact( const BU_Screwing& screwAB, - const SimdPoint3& vtx, - const SimdVector4& planeEq, - SimdScalar &minTime, + const btPoint3& vtx, + const btVector4& planeEq, + btScalar &minTime, bool swapAB); private: diff --git a/Extras/AlternativeCollisionAlgorithms/SphereSphereCollisionAlgorithm.cpp b/Extras/AlternativeCollisionAlgorithms/SphereSphereCollisionAlgorithm.cpp index 184d3d68d..09a4f15b8 100644 --- a/Extras/AlternativeCollisionAlgorithms/SphereSphereCollisionAlgorithm.cpp +++ b/Extras/AlternativeCollisionAlgorithms/SphereSphereCollisionAlgorithm.cpp @@ -13,13 +13,13 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#include "SphereSphereCollisionAlgorithm.h" +#include "btSphereSphereCollisionAlgorithm.h" #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" #include "BulletCollision/CollisionShapes/btSphereShape.h" #include "BulletCollision/CollisionDispatch/btCollisionObject.h" -SphereSphereCollisionAlgorithm::SphereSphereCollisionAlgorithm(PersistentManifold* mf,const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) -: CollisionAlgorithm(ci), +btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) +: btCollisionAlgorithm(ci), m_ownManifold(false), m_manifoldPtr(mf) { @@ -30,7 +30,7 @@ m_manifoldPtr(mf) } } -SphereSphereCollisionAlgorithm::~SphereSphereCollisionAlgorithm() +btSphereSphereCollisionAlgorithm::~btSphereSphereCollisionAlgorithm() { if (m_ownManifold) { @@ -39,42 +39,42 @@ SphereSphereCollisionAlgorithm::~SphereSphereCollisionAlgorithm() } } -void SphereSphereCollisionAlgorithm::ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo) +void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) { if (!m_manifoldPtr) return; - CollisionObject* col0 = static_cast(proxy0->m_clientObject); - CollisionObject* col1 = static_cast(proxy1->m_clientObject); - SphereShape* sphere0 = (SphereShape*)col0->m_collisionShape; - SphereShape* sphere1 = (SphereShape*)col1->m_collisionShape; + btCollisionObject* col0 = static_cast(proxy0->m_clientObject); + btCollisionObject* col1 = static_cast(proxy1->m_clientObject); + btSphereShape* sphere0 = (btSphereShape*)col0->m_collisionShape; + btSphereShape* sphere1 = (btSphereShape*)col1->m_collisionShape; - SimdVector3 diff = col0->m_worldTransform.getOrigin()- col1->m_worldTransform.getOrigin(); + btVector3 diff = col0->m_worldTransform.getOrigin()- col1->m_worldTransform.getOrigin(); float len = diff.length(); - SimdScalar radius0 = sphere0->GetRadius(); - SimdScalar radius1 = sphere1->GetRadius(); + btScalar radius0 = sphere0->GetRadius(); + btScalar radius1 = sphere1->GetRadius(); ///iff distance positive, don't generate a new contact if ( len > (radius0+radius1)) return; ///distance (negative means penetration) - SimdScalar dist = len - (radius0+radius1); + btScalar dist = len - (radius0+radius1); - SimdVector3 normalOnSurfaceB = diff / len; + btVector3 normalOnSurfaceB = diff / len; ///point on A (worldspace) - SimdVector3 pos0 = col0->m_worldTransform.getOrigin() - radius0 * normalOnSurfaceB; + btVector3 pos0 = col0->m_worldTransform.getOrigin() - radius0 * normalOnSurfaceB; ///point on B (worldspace) - SimdVector3 pos1 = col1->m_worldTransform.getOrigin() + radius1* normalOnSurfaceB; + btVector3 pos1 = col1->m_worldTransform.getOrigin() + radius1* normalOnSurfaceB; /// report a contact. internally this will be kept persistent, and contact reduction is done - ManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); + btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); resultOut->AddContactPoint(normalOnSurfaceB,pos1,dist); m_dispatcher->ReleaseManifoldResult(resultOut); } -float SphereSphereCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo) +float btSphereSphereCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) { //not yet return 1.f; diff --git a/Extras/AlternativeCollisionAlgorithms/SphereSphereCollisionAlgorithm.h b/Extras/AlternativeCollisionAlgorithms/SphereSphereCollisionAlgorithm.h index 5783a8306..04951af93 100644 --- a/Extras/AlternativeCollisionAlgorithms/SphereSphereCollisionAlgorithm.h +++ b/Extras/AlternativeCollisionAlgorithms/SphereSphereCollisionAlgorithm.h @@ -19,33 +19,33 @@ subject to the following restrictions: #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -class PersistentManifold; +class btPersistentManifold; -/// SphereSphereCollisionAlgorithm provides sphere-sphere collision detection. +/// btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection. /// Other features are frame-coherency (persistent data) and collision response. -/// Also provides the most basic sample for custom/user CollisionAlgorithm -class SphereSphereCollisionAlgorithm : public CollisionAlgorithm +/// Also provides the most basic sample for custom/user btCollisionAlgorithm +class btSphereSphereCollisionAlgorithm : public btCollisionAlgorithm { bool m_ownManifold; - PersistentManifold* m_manifoldPtr; + btPersistentManifold* m_manifoldPtr; public: - SphereSphereCollisionAlgorithm(const CollisionAlgorithmConstructionInfo& ci) - : CollisionAlgorithm(ci) {} + btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) + : btCollisionAlgorithm(ci) {} - virtual void ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - virtual float CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - SphereSphereCollisionAlgorithm(PersistentManifold* mf,const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1); + btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - virtual ~SphereSphereCollisionAlgorithm(); + virtual ~btSphereSphereCollisionAlgorithm(); - struct CreateFunc :public CollisionAlgorithmCreateFunc + struct CreateFunc :public btCollisionAlgorithmCreateFunc { - virtual CollisionAlgorithm* CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo& ci, BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) { - return new SphereSphereCollisionAlgorithm(0,ci,proxy0,proxy1); + return new btSphereSphereCollisionAlgorithm(0,ci,proxy0,proxy1); } }; diff --git a/Extras/EPA/Epa.cpp b/Extras/EPA/Epa.cpp index 4d46d506d..00975780e 100644 --- a/Extras/EPA/Epa.cpp +++ b/Extras/EPA/Epa.cpp @@ -15,11 +15,11 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#include "LinearMath/SimdScalar.h" -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdPoint3.h" -#include "LinearMath/SimdTransform.h" -#include "LinearMath/SimdMinMax.h" +#include "LinearMath/btScalar.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btPoint3.h" +#include "LinearMath/btTransform.h" +#include "LinearMath/btSimdMinMax.h" #include "BulletCollision/CollisionShapes/btConvexShape.h" @@ -37,11 +37,11 @@ subject to the following restrictions: #include "NarrowPhaseCollision/EpaPolyhedron.h" #include "NarrowPhaseCollision/Epa.h" -const SimdScalar EPA_MAX_RELATIVE_ERROR = 1e-2f; -const SimdScalar EPA_MAX_RELATIVE_ERROR_SQRD = EPA_MAX_RELATIVE_ERROR * EPA_MAX_RELATIVE_ERROR; +const btScalar EPA_MAX_RELATIVE_ERROR = 1e-2f; +const btScalar EPA_MAX_RELATIVE_ERROR_SQRD = EPA_MAX_RELATIVE_ERROR * EPA_MAX_RELATIVE_ERROR; -Epa::Epa( ConvexShape* pConvexShapeA, ConvexShape* pConvexShapeB, - const SimdTransform& transformA, const SimdTransform& transformB ) : m_pConvexShapeA( pConvexShapeA ), +Epa::Epa( btConvexShape* pConvexShapeA, btConvexShape* pConvexShapeB, + const btTransform& transformA, const btTransform& transformB ) : m_pConvexShapeA( pConvexShapeA ), m_pConvexShapeB( pConvexShapeB ), m_transformA( transformA ), m_transformB( transformB ) @@ -53,14 +53,14 @@ Epa::~Epa() { } -bool Epa::Initialize( SimplexSolverInterface& simplexSolver ) +bool Epa::Initialize( btSimplexSolverInterface& simplexSolver ) { // Run GJK on the enlarged shapes to obtain a simplex of the enlarged CSO - SimdVector3 v( 1, 0, 0 ); - SimdScalar squaredDistance = SIMD_INFINITY; + btVector3 v( 1, 0, 0 ); + btScalar squaredDistance = SIMD_INFINITY; - SimdScalar delta = 0.f; + btScalar delta = 0.f; simplexSolver.reset(); @@ -70,16 +70,16 @@ bool Epa::Initialize( SimplexSolverInterface& simplexSolver ) { EPA_DEBUG_ASSERT( ( v.length2() > 0 ) ,"Warning : v has zero magnitude!" ); - SimdVector3 seperatingAxisInA = -v * m_transformA.getBasis(); - SimdVector3 seperatingAxisInB = v * m_transformB.getBasis(); + btVector3 seperatingAxisInA = -v * m_transformA.getBasis(); + btVector3 seperatingAxisInB = v * m_transformB.getBasis(); - SimdVector3 pInA = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); - SimdVector3 qInB = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); + btVector3 pInA = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); + btVector3 qInB = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); - SimdPoint3 pWorld = m_transformA( pInA ); - SimdPoint3 qWorld = m_transformB( qInB ); + btPoint3 pWorld = m_transformA( pInA ); + btPoint3 qWorld = m_transformB( qInB ); - SimdVector3 w = pWorld - qWorld; + btVector3 w = pWorld - qWorld; delta = v.dot( w ); EPA_DEBUG_ASSERT( ( delta <= 0 ) ,"Shapes are disjoint, EPA should have never been called!" ); @@ -98,7 +98,7 @@ bool Epa::Initialize( SimplexSolverInterface& simplexSolver ) if (!closestOk) return false; - SimdScalar prevVSqrd = squaredDistance; + btScalar prevVSqrd = squaredDistance; squaredDistance = v.length2(); // Is v converging to v(A-B) ? @@ -115,9 +115,9 @@ bool Epa::Initialize( SimplexSolverInterface& simplexSolver ) ++nbIterations; } - SimdPoint3 simplexPoints[ 5 ]; - SimdPoint3 wSupportPointsOnA[ 5 ]; - SimdPoint3 wSupportPointsOnB[ 5 ]; + btPoint3 simplexPoints[ 5 ]; + btPoint3 wSupportPointsOnA[ 5 ]; + btPoint3 wSupportPointsOnB[ 5 ]; int nbSimplexPoints = simplexSolver.getSimplex( wSupportPointsOnA, wSupportPointsOnB, simplexPoints ); @@ -142,18 +142,18 @@ bool Epa::Initialize( SimplexSolverInterface& simplexSolver ) // We have a line segment inside the CSO that contains the origin // Create an hexahedron ( two tetrahedron glued together ) by adding 3 new points - SimdVector3 d = simplexPoints[ 0 ] - simplexPoints[ 1 ]; + btVector3 d = simplexPoints[ 0 ] - simplexPoints[ 1 ]; d.normalize(); - SimdVector3 v1; - SimdVector3 v2; - SimdVector3 v3; + btVector3 v1; + btVector3 v2; + btVector3 v3; - SimdVector3 e1; + btVector3 e1; - SimdScalar absx = abs( d.getX() ); - SimdScalar absy = abs( d.getY() ); - SimdScalar absz = abs( d.getZ() ); + btScalar absx = abs( d.getX() ); + btScalar absy = abs( d.getY() ); + btScalar absz = abs( d.getZ() ); if ( absx < absy ) { @@ -186,14 +186,14 @@ bool Epa::Initialize( SimplexSolverInterface& simplexSolver ) nbPolyhedronPoints = 5; - SimdVector3 seperatingAxisInA = v1 * m_transformA.getBasis(); - SimdVector3 seperatingAxisInB = -v1 * m_transformB.getBasis(); + btVector3 seperatingAxisInA = v1 * m_transformA.getBasis(); + btVector3 seperatingAxisInB = -v1 * m_transformB.getBasis(); - SimdVector3 p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); - SimdVector3 q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); + btVector3 p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); + btVector3 q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); - SimdPoint3 pWorld = m_transformA( p ); - SimdPoint3 qWorld = m_transformB( q ); + btPoint3 pWorld = m_transformA( p ); + btPoint3 qWorld = m_transformB( q ); wSupportPointsOnA[ 2 ] = pWorld; wSupportPointsOnB[ 2 ] = qWorld; @@ -255,21 +255,21 @@ bool Epa::Initialize( SimplexSolverInterface& simplexSolver ) // We have a triangle inside the CSO that contains the origin // Create an hexahedron ( two tetrahedron glued together ) by adding 2 new points - SimdVector3 v0 = simplexPoints[ 2 ] - simplexPoints[ 0 ]; - SimdVector3 v1 = simplexPoints[ 1 ] - simplexPoints[ 0 ]; - SimdVector3 triangleNormal = v0.cross( v1 ); + btVector3 v0 = simplexPoints[ 2 ] - simplexPoints[ 0 ]; + btVector3 v1 = simplexPoints[ 1 ] - simplexPoints[ 0 ]; + btVector3 triangleNormal = v0.cross( v1 ); triangleNormal.normalize(); nbPolyhedronPoints = 5; - SimdVector3 seperatingAxisInA = triangleNormal * m_transformA.getBasis(); - SimdVector3 seperatingAxisInB = -triangleNormal * m_transformB.getBasis(); + btVector3 seperatingAxisInA = triangleNormal * m_transformA.getBasis(); + btVector3 seperatingAxisInB = -triangleNormal * m_transformB.getBasis(); - SimdVector3 p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); - SimdVector3 q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); + btVector3 p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); + btVector3 q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); - SimdPoint3 pWorld = m_transformA( p ); - SimdPoint3 qWorld = m_transformB( q ); + btPoint3 pWorld = m_transformA( p ); + btPoint3 qWorld = m_transformB( q ); wSupportPointsOnA[ 3 ] = pWorld; wSupportPointsOnB[ 3 ] = qWorld; @@ -316,17 +316,17 @@ bool Epa::Initialize( SimplexSolverInterface& simplexSolver ) #endif #ifndef EPA_POLYHEDRON_USE_PLANES - SimdPoint3 wTetraPoints[ 4 ] = { simplexPoints[ initTetraIndices[ 0 ] ], + btPoint3 wTetraPoints[ 4 ] = { simplexPoints[ initTetraIndices[ 0 ] ], simplexPoints[ initTetraIndices[ 1 ] ], simplexPoints[ initTetraIndices[ 2 ] ], simplexPoints[ initTetraIndices[ 3 ] ] }; - SimdPoint3 wTetraSupportPointsOnA[ 4 ] = { wSupportPointsOnA[ initTetraIndices[ 0 ] ], + btPoint3 wTetraSupportPointsOnA[ 4 ] = { wSupportPointsOnA[ initTetraIndices[ 0 ] ], wSupportPointsOnA[ initTetraIndices[ 1 ] ], wSupportPointsOnA[ initTetraIndices[ 2 ] ], wSupportPointsOnA[ initTetraIndices[ 3 ] ] }; - SimdPoint3 wTetraSupportPointsOnB[ 4 ] = { wSupportPointsOnB[ initTetraIndices[ 0 ] ], + btPoint3 wTetraSupportPointsOnB[ 4 ] = { wSupportPointsOnB[ initTetraIndices[ 0 ] ], wSupportPointsOnB[ initTetraIndices[ 1 ] ], wSupportPointsOnB[ initTetraIndices[ 2 ] ], wSupportPointsOnB[ initTetraIndices[ 3 ] ] }; @@ -398,16 +398,16 @@ bool Epa::Initialize( SimplexSolverInterface& simplexSolver ) return true; } -SimdScalar Epa::CalcPenDepth( SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB ) +btScalar Epa::CalcPenDepth( btPoint3& wWitnessOnA, btPoint3& wWitnessOnB ) { - SimdVector3 v; + btVector3 v; - SimdScalar upperBoundSqrd = SIMD_INFINITY; - SimdScalar vSqrd = 0; + btScalar upperBoundSqrd = SIMD_INFINITY; + btScalar vSqrd = 0; #ifdef _DEBUG - SimdScalar prevVSqrd; + btScalar prevVSqrd; #endif - SimdScalar delta; + btScalar delta; bool isCloseEnough = false; @@ -445,20 +445,20 @@ SimdScalar Epa::CalcPenDepth( SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB ) #endif //_DEBUG EPA_DEBUG_ASSERT( ( v.length2() > 0 ) ,"Zero vector not allowed!" ); - SimdVector3 seperatingAxisInA = v * m_transformA.getBasis(); - SimdVector3 seperatingAxisInB = -v * m_transformB.getBasis(); + btVector3 seperatingAxisInA = v * m_transformA.getBasis(); + btVector3 seperatingAxisInB = -v * m_transformB.getBasis(); - SimdVector3 p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); - SimdVector3 q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); + btVector3 p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); + btVector3 q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); - SimdPoint3 pWorld = m_transformA( p ); - SimdPoint3 qWorld = m_transformB( q ); + btPoint3 pWorld = m_transformA( p ); + btPoint3 qWorld = m_transformB( q ); - SimdPoint3 w = pWorld - qWorld; + btPoint3 w = pWorld - qWorld; delta = v.dot( w ); // Keep tighest upper bound - upperBoundSqrd = SimdMin( upperBoundSqrd, delta * delta / vSqrd ); + upperBoundSqrd = btMin( upperBoundSqrd, delta * delta / vSqrd ); //assert_msg( vSqrd <= upperBoundSqrd, "A triangle was falsely rejected!" ); isCloseEnough = ( upperBoundSqrd <= ( 1 + 1e-4f ) * vSqrd ); @@ -544,10 +544,10 @@ SimdScalar Epa::CalcPenDepth( SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB ) return v.length(); } -bool Epa::TetrahedronContainsOrigin( const SimdPoint3& point0, const SimdPoint3& point1, - const SimdPoint3& point2, const SimdPoint3& point3 ) +bool Epa::TetrahedronContainsOrigin( const btPoint3& point0, const btPoint3& point1, + const btPoint3& point2, const btPoint3& point3 ) { - SimdVector3 facesNormals[ 4 ] = { ( point1 - point0 ).cross( point2 - point0 ), + btVector3 facesNormals[ 4 ] = { ( point1 - point0 ).cross( point2 - point0 ), ( point2 - point1 ).cross( point3 - point1 ), ( point3 - point2 ).cross( point0 - point2 ), ( point0 - point3 ).cross( point1 - point3 ) }; @@ -558,7 +558,7 @@ bool Epa::TetrahedronContainsOrigin( const SimdPoint3& point0, const SimdPoint3& ( ( facesNormals[ 3 ].dot( point3 ) > 0 ) != ( facesNormals[ 3 ].dot( point2 ) > 0 ) ); } -bool Epa::TetrahedronContainsOrigin( SimdPoint3* pPoints ) +bool Epa::TetrahedronContainsOrigin( btPoint3* pPoints ) { return TetrahedronContainsOrigin( pPoints[ 0 ], pPoints[ 1 ], pPoints[ 2 ], pPoints[ 3 ] ); } diff --git a/Extras/EPA/Epa.h b/Extras/EPA/Epa.h index 0acf394d5..1ea084754 100644 --- a/Extras/EPA/Epa.h +++ b/Extras/EPA/Epa.h @@ -21,8 +21,8 @@ subject to the following restrictions: -extern const SimdScalar EPA_MAX_RELATIVE_ERROR; -extern const SimdScalar EPA_MAX_RELATIVE_ERROR_SQRD; +extern const btScalar EPA_MAX_RELATIVE_ERROR; +extern const btScalar EPA_MAX_RELATIVE_ERROR_SQRD; class Epa { @@ -34,30 +34,30 @@ class Epa public : - Epa( ConvexShape* pConvexShapeA, ConvexShape* pConvexShapeB, - const SimdTransform& transformA, const SimdTransform& transformB ); + Epa( btConvexShape* pConvexShapeA, btConvexShape* pConvexShapeB, + const btTransform& transformA, const btTransform& transformB ); ~Epa(); - bool Initialize( SimplexSolverInterface& simplexSolver ); + bool Initialize( btSimplexSolverInterface& simplexSolver ); - SimdScalar CalcPenDepth( SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB ); + btScalar CalcPenDepth( btPoint3& wWitnessOnA, btPoint3& wWitnessOnB ); private : - bool TetrahedronContainsOrigin( SimdPoint3* pPoints ); - bool TetrahedronContainsOrigin( const SimdPoint3& point0, const SimdPoint3& point1, - const SimdPoint3& point2, const SimdPoint3& point3 ); + bool TetrahedronContainsOrigin( btPoint3* pPoints ); + bool TetrahedronContainsOrigin( const btPoint3& point0, const btPoint3& point1, + const btPoint3& point2, const btPoint3& point3 ); private : //! Priority queue std::vector< EpaFace* > m_faceEntries; - ConvexShape* m_pConvexShapeA; - ConvexShape* m_pConvexShapeB; + btConvexShape* m_pConvexShapeA; + btConvexShape* m_pConvexShapeB; - SimdTransform m_transformA; - SimdTransform m_transformB; + btTransform m_transformA; + btTransform m_transformB; EpaPolyhedron m_polyhedron; }; diff --git a/Extras/EPA/EpaFace.cpp b/Extras/EPA/EpaFace.cpp index 331d97934..425009ba9 100644 --- a/Extras/EPA/EpaFace.cpp +++ b/Extras/EPA/EpaFace.cpp @@ -14,9 +14,9 @@ subject to the following restrictions: 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "LinearMath/SimdScalar.h" -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btScalar.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btPoint3.h" #include "NarrowPhaseCollision/EpaCommon.h" @@ -25,7 +25,7 @@ subject to the following restrictions: #include "NarrowPhaseCollision/EpaFace.h" #ifdef EPA_POLYHEDRON_USE_PLANES -SimdScalar PLANE_THICKNESS = 1e-5f; +btScalar PLANE_THICKNESS = 1e-5f; #endif EpaFace::EpaFace() : m_pHalfEdge( 0 ), m_deleted( false ) @@ -43,17 +43,17 @@ bool EpaFace::Initialize() CollectVertices( m_pVertices ); - const SimdVector3 e0 = m_pVertices[ 1 ]->m_point - m_pVertices[ 0 ]->m_point; - const SimdVector3 e1 = m_pVertices[ 2 ]->m_point - m_pVertices[ 0 ]->m_point; + const btVector3 e0 = m_pVertices[ 1 ]->m_point - m_pVertices[ 0 ]->m_point; + const btVector3 e1 = m_pVertices[ 2 ]->m_point - m_pVertices[ 0 ]->m_point; - const SimdScalar e0Sqrd = e0.length2(); - const SimdScalar e1Sqrd = e1.length2(); - const SimdScalar e0e1 = e0.dot( e1 ); + const btScalar e0Sqrd = e0.length2(); + const btScalar e1Sqrd = e1.length2(); + const btScalar e0e1 = e0.dot( e1 ); m_determinant = e0Sqrd * e1Sqrd - e0e1 * e0e1; - const SimdScalar e0v0 = e0.dot( m_pVertices[ 0 ]->m_point ); - const SimdScalar e1v0 = e1.dot( m_pVertices[ 0 ]->m_point ); + const btScalar e0v0 = e0.dot( m_pVertices[ 0 ]->m_point ); + const btScalar e1v0 = e1.dot( m_pVertices[ 0 ]->m_point ); m_lambdas[ 0 ] = e0e1 * e1v0 - e1Sqrd * e0v0; m_lambdas[ 1 ] = e0e1 * e0v0 - e0Sqrd * e1v0; @@ -83,8 +83,8 @@ bool EpaFace::CalculatePlane() // Traditional method - const SimdVector3 v1 = m_pVertices[ 1 ]->m_point - m_pVertices[ 0 ]->m_point; - const SimdVector3 v2 = m_pVertices[ 2 ]->m_point - m_pVertices[ 0 ]->m_point; + const btVector3 v1 = m_pVertices[ 1 ]->m_point - m_pVertices[ 0 ]->m_point; + const btVector3 v2 = m_pVertices[ 2 ]->m_point - m_pVertices[ 0 ]->m_point; m_planeNormal = v2.cross( v1 ); @@ -99,10 +99,10 @@ bool EpaFace::CalculatePlane() // Robust method - //SimdVector3 _v1 = m_pVertices[ 1 ]->m_point - m_pVertices[ 0 ]->m_point; - //SimdVector3 _v2 = m_pVertices[ 2 ]->m_point - m_pVertices[ 0 ]->m_point; + //btVector3 _v1 = m_pVertices[ 1 ]->m_point - m_pVertices[ 0 ]->m_point; + //btVector3 _v2 = m_pVertices[ 2 ]->m_point - m_pVertices[ 0 ]->m_point; - //SimdVector3 n; + //btVector3 n; //n = _v2.cross( _v1 ); @@ -119,8 +119,8 @@ bool EpaFace::CalculatePlane() //n /= 3; //n.normalize(); - //SimdVector3 c = ( m_pVertices[ 0 ]->m_point + m_pVertices[ 1 ]->m_point + m_pVertices[ 2 ]->m_point ) / 3; - //SimdScalar d = c.dot( -n ); + //btVector3 c = ( m_pVertices[ 0 ]->m_point + m_pVertices[ 1 ]->m_point + m_pVertices[ 2 ]->m_point ) / 3; + //btScalar d = c.dot( -n ); //m_robustPlaneNormal = n; //m_robustPlaneDistance = d; @@ -142,8 +142,8 @@ bool EpaFace::CalculatePlane() void EpaFace::CalcClosestPoint() { - const SimdVector3 e0 = m_pVertices[ 1 ]->m_point - m_pVertices[ 0 ]->m_point; - const SimdVector3 e1 = m_pVertices[ 2 ]->m_point - m_pVertices[ 0 ]->m_point; + const btVector3 e0 = m_pVertices[ 1 ]->m_point - m_pVertices[ 0 ]->m_point; + const btVector3 e1 = m_pVertices[ 2 ]->m_point - m_pVertices[ 0 ]->m_point; m_v = m_pVertices[ 0 ]->m_point + ( e0 * m_lambdas[ 0 ] + e1 * m_lambdas[ 1 ] ) / m_determinant; @@ -151,20 +151,20 @@ void EpaFace::CalcClosestPoint() m_vSqrd = m_v.length2(); } -void EpaFace::CalcClosestPointOnA( SimdVector3& closestPointOnA ) +void EpaFace::CalcClosestPointOnA( btVector3& closestPointOnA ) { - const SimdVector3 e0 = m_pVertices[ 1 ]->m_wSupportPointOnA - m_pVertices[ 0 ]->m_wSupportPointOnA; - const SimdVector3 e1 = m_pVertices[ 2 ]->m_wSupportPointOnA - m_pVertices[ 0 ]->m_wSupportPointOnA; + const btVector3 e0 = m_pVertices[ 1 ]->m_wSupportPointOnA - m_pVertices[ 0 ]->m_wSupportPointOnA; + const btVector3 e1 = m_pVertices[ 2 ]->m_wSupportPointOnA - m_pVertices[ 0 ]->m_wSupportPointOnA; closestPointOnA = m_pVertices[ 0 ]->m_wSupportPointOnA + ( e0 * m_lambdas[ 0 ] + e1 * m_lambdas[ 1 ] ) / m_determinant; } -void EpaFace::CalcClosestPointOnB( SimdVector3& closestPointOnB ) +void EpaFace::CalcClosestPointOnB( btVector3& closestPointOnB ) { - const SimdVector3 e0 = m_pVertices[ 1 ]->m_wSupportPointOnB - m_pVertices[ 0 ]->m_wSupportPointOnB; - const SimdVector3 e1 = m_pVertices[ 2 ]->m_wSupportPointOnB - m_pVertices[ 0 ]->m_wSupportPointOnB; + const btVector3 e0 = m_pVertices[ 1 ]->m_wSupportPointOnB - m_pVertices[ 0 ]->m_wSupportPointOnB; + const btVector3 e1 = m_pVertices[ 2 ]->m_wSupportPointOnB - m_pVertices[ 0 ]->m_wSupportPointOnB; closestPointOnB = m_pVertices[ 0 ]->m_wSupportPointOnB + ( e0 * m_lambdas[ 0 ] + e1 * m_lambdas[ 1 ] ) / diff --git a/Extras/EPA/EpaFace.h b/Extras/EPA/EpaFace.h index 42907864c..d77d0d5d4 100644 --- a/Extras/EPA/EpaFace.h +++ b/Extras/EPA/EpaFace.h @@ -21,7 +21,7 @@ class EpaVertex; class EpaHalfEdge; #ifdef EPA_POLYHEDRON_USE_PLANES -extern SimdScalar PLANE_THICKNESS; +extern btScalar PLANE_THICKNESS; #endif //! Note : This class is not supposed to be a base class @@ -44,8 +44,8 @@ class EpaFace bool CalculatePlane(); #endif void CalcClosestPoint(); - void CalcClosestPointOnA( SimdVector3& closestPointOnA ); - void CalcClosestPointOnB( SimdVector3& closestPointOnB ); + void CalcClosestPointOnA( btVector3& closestPointOnA ); + void CalcClosestPointOnB( btVector3& closestPointOnB ); bool IsAffinelyDependent() const; bool IsClosestPointInternal() const; @@ -63,18 +63,18 @@ class EpaFace EpaVertex* m_pVertices[ 3 ]; #ifdef EPA_POLYHEDRON_USE_PLANES - SimdVector3 m_planeNormal; - SimdScalar m_planeDistance; + btVector3 m_planeNormal; + btScalar m_planeDistance; - //SimdVector3 m_robustPlaneNormal; - //SimdScalar m_robustPlaneDistance; + //btVector3 m_robustPlaneNormal; + //btScalar m_robustPlaneDistance; #endif - SimdVector3 m_v; - SimdScalar m_vSqrd; + btVector3 m_v; + btScalar m_vSqrd; - SimdScalar m_determinant; - SimdScalar m_lambdas[ 2 ]; + btScalar m_determinant; + btScalar m_lambdas[ 2 ]; bool m_deleted; }; diff --git a/Extras/EPA/EpaPenetrationDepthSolver.cpp b/Extras/EPA/EpaPenetrationDepthSolver.cpp index c5cb907a4..049bd2a04 100644 --- a/Extras/EPA/EpaPenetrationDepthSolver.cpp +++ b/Extras/EPA/EpaPenetrationDepthSolver.cpp @@ -14,11 +14,11 @@ subject to the following restrictions: 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "LinearMath/SimdScalar.h" -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdPoint3.h" -#include "LinearMath/SimdTransform.h" -#include "LinearMath/SimdMinMax.h" +#include "LinearMath/btScalar.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btPoint3.h" +#include "LinearMath/btTransform.h" +#include "LinearMath/btSimdMinMax.h" #include @@ -36,19 +36,19 @@ subject to the following restrictions: #include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h" #include "NarrowPhaseCollision/EpaPenetrationDepthSolver.h" -SimdScalar g_GJKMaxRelError = 1e-3f; -SimdScalar g_GJKMaxRelErrorSqrd = g_GJKMaxRelError * g_GJKMaxRelError; +btScalar g_GJKMaxRelError = 1e-3f; +btScalar g_GJKMaxRelErrorSqrd = g_GJKMaxRelError * g_GJKMaxRelError; -bool EpaPenetrationDepthSolver::CalcPenDepth( SimplexSolverInterface& simplexSolver, - ConvexShape* pConvexA, ConvexShape* pConvexB, - const SimdTransform& transformA, const SimdTransform& transformB, - SimdVector3& v, SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB, - class IDebugDraw* debugDraw ) +bool EpaPenetrationDepthSolver::CalcPenDepth( btSimplexSolverInterface& simplexSolver, + btConvexShape* pConvexA, btConvexShape* pConvexB, + const btTransform& transformA, const btTransform& transformB, + btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB, + class btIDebugDraw* debugDraw ) { EPA_DEBUG_ASSERT( pConvexA ,"Convex shape A is invalid!" ); EPA_DEBUG_ASSERT( pConvexB ,"Convex shape B is invalid!" ); - SimdScalar penDepth; + btScalar penDepth; #ifdef EPA_USE_HYBRID bool needsEPA = !HybridPenDepth( simplexSolver, pConvexA, pConvexB, transformA, transformB, @@ -70,17 +70,17 @@ bool EpaPenetrationDepthSolver::CalcPenDepth( SimplexSolverInterface& simplexSol } #ifdef EPA_USE_HYBRID -bool EpaPenetrationDepthSolver::HybridPenDepth( SimplexSolverInterface& simplexSolver, - ConvexShape* pConvexA, ConvexShape* pConvexB, - const SimdTransform& transformA, const SimdTransform& transformB, - SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB, - SimdScalar& penDepth, SimdVector3& v ) +bool EpaPenetrationDepthSolver::HybridPenDepth( btSimplexSolverInterface& simplexSolver, + btConvexShape* pConvexA, btConvexShape* pConvexB, + const btTransform& transformA, const btTransform& transformB, + btPoint3& wWitnessOnA, btPoint3& wWitnessOnB, + btScalar& penDepth, btVector3& v ) { - SimdScalar squaredDistance = SIMD_INFINITY; - SimdScalar delta = 0.f; + btScalar squaredDistance = SIMD_INFINITY; + btScalar delta = 0.f; - const SimdScalar margin = pConvexA->GetMargin() + pConvexB->GetMargin(); - const SimdScalar marginSqrd = margin * margin; + const btScalar margin = pConvexA->GetMargin() + pConvexB->GetMargin(); + const btScalar marginSqrd = margin * margin; simplexSolver.reset(); @@ -90,16 +90,16 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( SimplexSolverInterface& simplexS { assert( ( v.length2() > 0 ) && "Warning: v is the zero vector!" ); - SimdVector3 seperatingAxisInA = -v * transformA.getBasis(); - SimdVector3 seperatingAxisInB = v * transformB.getBasis(); + btVector3 seperatingAxisInA = -v * transformA.getBasis(); + btVector3 seperatingAxisInB = v * transformB.getBasis(); - SimdVector3 pInA = pConvexA->LocalGetSupportingVertexWithoutMargin( seperatingAxisInA ); - SimdVector3 qInB = pConvexB->LocalGetSupportingVertexWithoutMargin( seperatingAxisInB ); + btVector3 pInA = pConvexA->LocalGetSupportingVertexWithoutMargin( seperatingAxisInA ); + btVector3 qInB = pConvexB->LocalGetSupportingVertexWithoutMargin( seperatingAxisInB ); - SimdPoint3 pWorld = transformA( pInA ); - SimdPoint3 qWorld = transformB( qInB ); + btPoint3 pWorld = transformA( pInA ); + btPoint3 qWorld = transformB( qInB ); - SimdVector3 w = pWorld - qWorld; + btVector3 w = pWorld - qWorld; delta = v.dot( w ); // potential exit, they don't overlap @@ -117,7 +117,7 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( SimplexSolverInterface& simplexS simplexSolver.compute_points( wWitnessOnA, wWitnessOnB ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); - SimdScalar vLength = sqrt( squaredDistance ); + btScalar vLength = sqrt( squaredDistance ); wWitnessOnA -= v * ( pConvexA->GetMargin() / vLength ); wWitnessOnB += v * ( pConvexB->GetMargin() / vLength ); @@ -137,7 +137,7 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( SimplexSolverInterface& simplexS simplexSolver.compute_points( wWitnessOnA, wWitnessOnB ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); - SimdScalar vLength = sqrt( squaredDistance ); + btScalar vLength = sqrt( squaredDistance ); wWitnessOnA -= v * ( pConvexA->GetMargin() / vLength ); wWitnessOnB += v * ( pConvexB->GetMargin() / vLength ); @@ -148,7 +148,7 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( SimplexSolverInterface& simplexS return true; } - SimdScalar previousSquaredDistance = squaredDistance; + btScalar previousSquaredDistance = squaredDistance; squaredDistance = v.length2(); //are we getting any closer ? @@ -160,7 +160,7 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( SimplexSolverInterface& simplexS simplexSolver.compute_points( wWitnessOnA, wWitnessOnB ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); - SimdScalar vLength = sqrt( squaredDistance ); + btScalar vLength = sqrt( squaredDistance ); wWitnessOnA -= v * ( pConvexA->GetMargin() / vLength ); wWitnessOnB += v * ( pConvexB->GetMargin() / vLength ); @@ -184,10 +184,10 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( SimplexSolverInterface& simplexS } #endif -SimdScalar EpaPenetrationDepthSolver::EpaPenDepth( SimplexSolverInterface& simplexSolver, - ConvexShape* pConvexA, ConvexShape* pConvexB, - const SimdTransform& transformA, const SimdTransform& transformB, - SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB ) +btScalar EpaPenetrationDepthSolver::EpaPenDepth( btSimplexSolverInterface& simplexSolver, + btConvexShape* pConvexA, btConvexShape* pConvexB, + const btTransform& transformA, const btTransform& transformB, + btPoint3& wWitnessOnA, btPoint3& wWitnessOnB ) { Epa epa( pConvexA, pConvexB, transformA, transformB ); diff --git a/Extras/EPA/EpaPenetrationDepthSolver.h b/Extras/EPA/EpaPenetrationDepthSolver.h index ee772728e..7902c8419 100644 --- a/Extras/EPA/EpaPenetrationDepthSolver.h +++ b/Extras/EPA/EpaPenetrationDepthSolver.h @@ -22,34 +22,34 @@ subject to the following restrictions: * calculate the penetration depth between two convex shapes. */ -extern SimdScalar g_GJKMaxRelError; -extern SimdScalar g_GJKMaxRelErrorSqrd; +extern btScalar g_GJKMaxRelError; +extern btScalar g_GJKMaxRelErrorSqrd; //! Note : This class is not supposed to be a base class -class EpaPenetrationDepthSolver : public ConvexPenetrationDepthSolver +class EpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver { public : - bool CalcPenDepth( SimplexSolverInterface& simplexSolver, - ConvexShape* pConvexA, ConvexShape* pConvexB, - const SimdTransform& transformA, const SimdTransform& transformB, - SimdVector3& v, SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB, - class IDebugDraw* debugDraw ); + bool CalcPenDepth( btSimplexSolverInterface& simplexSolver, + btConvexShape* pConvexA, btConvexShape* pConvexB, + const btTransform& transformA, const btTransform& transformB, + btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB, + class btIDebugDraw* debugDraw ); private : #ifdef EPA_USE_HYBRID - bool HybridPenDepth( SimplexSolverInterface& simplexSolver, - ConvexShape* pConvexA, ConvexShape* pConvexB, - const SimdTransform& transformA, const SimdTransform& transformB, - SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB, - SimdScalar& penDepth, SimdVector3& v ); + bool HybridPenDepth( btSimplexSolverInterface& simplexSolver, + btConvexShape* pConvexA, btConvexShape* pConvexB, + const btTransform& transformA, const btTransform& transformB, + btPoint3& wWitnessOnA, btPoint3& wWitnessOnB, + btScalar& penDepth, btVector3& v ); #endif - SimdScalar EpaPenDepth( SimplexSolverInterface& simplexSolver, - ConvexShape* pConvexA, ConvexShape* pConvexB, - const SimdTransform& transformA, const SimdTransform& transformB, - SimdPoint3& wWitnessOnA, SimdPoint3& wWitnessOnB ); + btScalar EpaPenDepth( btSimplexSolverInterface& simplexSolver, + btConvexShape* pConvexA, btConvexShape* pConvexB, + const btTransform& transformA, const btTransform& transformB, + btPoint3& wWitnessOnA, btPoint3& wWitnessOnB ); }; #endif // EPA_PENETRATION_DEPTH_H diff --git a/Extras/EPA/EpaPolyhedron.cpp b/Extras/EPA/EpaPolyhedron.cpp index b5a2dde92..6aeee94c1 100644 --- a/Extras/EPA/EpaPolyhedron.cpp +++ b/Extras/EPA/EpaPolyhedron.cpp @@ -14,9 +14,9 @@ subject to the following restrictions: 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "LinearMath/SimdScalar.h" -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btScalar.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btPoint3.h" #include "Memory2.h" #include @@ -42,8 +42,8 @@ EpaPolyhedron::~EpaPolyhedron() Destroy(); } -bool EpaPolyhedron::Create( SimdPoint3* pInitialPoints, - SimdPoint3* pSupportPointsOnA, SimdPoint3* pSupportPointsOnB, +bool EpaPolyhedron::Create( btPoint3* pInitialPoints, + btPoint3* pSupportPointsOnA, btPoint3* pSupportPointsOnB, const int nbInitialPoints ) { #ifndef EPA_POLYHEDRON_USE_PLANES @@ -134,8 +134,8 @@ bool EpaPolyhedron::Create( SimdPoint3* pInitialPoints, { int axisIndex = axisOrderIndices[ axis ]; - SimdScalar axisMin = SIMD_INFINITY; - SimdScalar axisMax = -SIMD_INFINITY; + btScalar axisMin = SIMD_INFINITY; + btScalar axisMax = -SIMD_INFINITY; for ( int i = 0; i < 4; ++i ) { @@ -194,36 +194,36 @@ bool EpaPolyhedron::Create( SimdPoint3* pInitialPoints, ////////////////////////////////////////////////////////////////////////// #ifdef EPA_POLYHEDRON_USE_PLANES - SimdVector3 v0 = pInitialPoints[ finalPointsIndices[ 1 ] ] - pInitialPoints[ finalPointsIndices[ 0 ] ]; - SimdVector3 v1 = pInitialPoints[ finalPointsIndices[ 2 ] ] - pInitialPoints[ finalPointsIndices[ 0 ] ]; + btVector3 v0 = pInitialPoints[ finalPointsIndices[ 1 ] ] - pInitialPoints[ finalPointsIndices[ 0 ] ]; + btVector3 v1 = pInitialPoints[ finalPointsIndices[ 2 ] ] - pInitialPoints[ finalPointsIndices[ 0 ] ]; #else - SimdVector3 v0 = pInitialPoints[ 1 ] - pInitialPoints[ 0 ]; - SimdVector3 v1 = pInitialPoints[ 2 ] - pInitialPoints[ 0 ]; + btVector3 v0 = pInitialPoints[ 1 ] - pInitialPoints[ 0 ]; + btVector3 v1 = pInitialPoints[ 2 ] - pInitialPoints[ 0 ]; #endif - SimdVector3 planeNormal = v1.cross( v0 ); + btVector3 planeNormal = v1.cross( v0 ); planeNormal.normalize(); #ifdef EPA_POLYHEDRON_USE_PLANES - SimdScalar planeDistance = pInitialPoints[ finalPointsIndices[ 0 ] ].dot( -planeNormal ); + btScalar planeDistance = pInitialPoints[ finalPointsIndices[ 0 ] ].dot( -planeNormal ); #else - SimdScalar planeDistance = pInitialPoints[ 0 ].dot( -planeNormal ); + btScalar planeDistance = pInitialPoints[ 0 ].dot( -planeNormal ); #endif #ifdef EPA_POLYHEDRON_USE_PLANES - bool pointOnPlane0 = SimdEqual( pInitialPoints[ finalPointsIndices[ 0 ] ].dot( planeNormal ) + planeDistance, PLANE_THICKNESS ); + bool pointOnPlane0 = btEqual( pInitialPoints[ finalPointsIndices[ 0 ] ].dot( planeNormal ) + planeDistance, PLANE_THICKNESS ); if (!pointOnPlane0) { EPA_DEBUG_ASSERT(0,"Point0 should be on plane!"); return false; } - bool pointOnPlane1 = SimdEqual( pInitialPoints[ finalPointsIndices[ 1 ] ].dot( planeNormal ) + planeDistance, PLANE_THICKNESS ); + bool pointOnPlane1 = btEqual( pInitialPoints[ finalPointsIndices[ 1 ] ].dot( planeNormal ) + planeDistance, PLANE_THICKNESS ); if (!pointOnPlane1) { EPA_DEBUG_ASSERT(0,"Point1 should be on plane!"); return false; } - bool pointOnPlane2 = SimdEqual( pInitialPoints[ finalPointsIndices[ 2 ] ].dot( planeNormal ) + planeDistance, PLANE_THICKNESS ); + bool pointOnPlane2 = btEqual( pInitialPoints[ finalPointsIndices[ 2 ] ].dot( planeNormal ) + planeDistance, PLANE_THICKNESS ); if (!pointOnPlane2) { EPA_DEBUG_ASSERT(0,"Point2 should be on plane!"); @@ -235,7 +235,7 @@ bool EpaPolyhedron::Create( SimdPoint3* pInitialPoints, { if ( planeDistance > 0 ) { - SimdVector3 tmp = pInitialPoints[ 1 ]; + btVector3 tmp = pInitialPoints[ 1 ]; pInitialPoints[ 1 ] = pInitialPoints[ 2 ]; pInitialPoints[ 2 ] = tmp; @@ -256,16 +256,16 @@ bool EpaPolyhedron::Create( SimdPoint3* pInitialPoints, #else finalPointsIndices[ 3 ] = -1; - SimdScalar absMaxDist = -SIMD_INFINITY; - SimdScalar maxDist; + btScalar absMaxDist = -SIMD_INFINITY; + btScalar maxDist; for ( int pointIndex = 0; pointIndex < nbInitialPoints; ++pointIndex ) { - SimdScalar dist = planeNormal.dot( pInitialPoints[ pointIndex ] ) + planeDistance; - SimdScalar absDist = abs( dist ); + btScalar dist = planeNormal.dot( pInitialPoints[ pointIndex ] ) + planeDistance; + btScalar absDist = abs( dist ); if ( ( absDist > absMaxDist ) && - !SimdEqual( dist, PLANE_THICKNESS ) ) + !btEqual( dist, PLANE_THICKNESS ) ) { absMaxDist = absDist; maxDist = dist; @@ -283,7 +283,7 @@ bool EpaPolyhedron::Create( SimdPoint3* pInitialPoints, { // Can swap indices only - SimdPoint3 tmp = pInitialPoints[ finalPointsIndices[ 1 ] ]; + btPoint3 tmp = pInitialPoints[ finalPointsIndices[ 1 ] ]; pInitialPoints[ finalPointsIndices[ 1 ] ] = pInitialPoints[ finalPointsIndices[ 2 ] ]; pInitialPoints[ finalPointsIndices[ 2 ] ] = tmp; @@ -425,7 +425,7 @@ bool EpaPolyhedron::Create( SimdPoint3* pInitialPoints, { EpaFace* pFace = *facesItr; - SimdScalar dist = pFace->m_planeNormal.dot( pInitialPoints[ i ] ) + pFace->m_planeDistance; + btScalar dist = pFace->m_planeNormal.dot( pInitialPoints[ i ] ) + pFace->m_planeDistance; if ( dist > PLANE_THICKNESS ) { @@ -486,9 +486,9 @@ EpaHalfEdge* EpaPolyhedron::CreateHalfEdge() return pNewHalfEdge; } -EpaVertex* EpaPolyhedron::CreateVertex( const SimdPoint3& wSupportPoint, - const SimdPoint3& wSupportPointOnA, - const SimdPoint3& wSupportPointOnB ) +EpaVertex* EpaPolyhedron::CreateVertex( const btPoint3& wSupportPoint, + const btPoint3& wSupportPointOnA, + const btPoint3& wSupportPointOnB ) { EpaVertex* pNewVertex = new EpaVertex( wSupportPoint, wSupportPointOnA, wSupportPointOnB ); EPA_DEBUG_ASSERT( pNewVertex ,"Failed to allocate memory for a new EpaVertex!" ); @@ -542,9 +542,9 @@ void EpaPolyhedron::DestroyAllVertices() } } -bool EpaPolyhedron::Expand( const SimdPoint3& wSupportPoint, - const SimdPoint3& wSupportPointOnA, - const SimdPoint3& wSupportPointOnB, +bool EpaPolyhedron::Expand( const btPoint3& wSupportPoint, + const btPoint3& wSupportPointOnA, + const btPoint3& wSupportPointOnB, EpaFace* pFace, std::list< EpaFace* >& newFaces ) { EPA_DEBUG_ASSERT( !pFace->m_deleted ,"Face is already deleted!" ); @@ -555,7 +555,7 @@ bool EpaPolyhedron::Expand( const SimdPoint3& wSupportPoint, // wSupportPoint must be front of face's plane used to do the expansion #ifdef EPA_POLYHEDRON_USE_PLANES - SimdScalar dist = pFace->m_planeNormal.dot( wSupportPoint ) + pFace->m_planeDistance; + btScalar dist = pFace->m_planeNormal.dot( wSupportPoint ) + pFace->m_planeDistance; if ( dist <= PLANE_THICKNESS ) { return false; @@ -601,7 +601,7 @@ int EpaPolyhedron::GetNbFaces() const return m_faces.size(); } -void EpaPolyhedron::DeleteVisibleFaces( const SimdPoint3& point, EpaFace* pFace, +void EpaPolyhedron::DeleteVisibleFaces( const btPoint3& point, EpaFace* pFace, std::list< EpaHalfEdge* >& coneBaseTwinHalfEdges ) { EPA_DEBUG_ASSERT( !pFace->m_deleted ,"Face is already deleted!" ); @@ -622,12 +622,12 @@ void EpaPolyhedron::DeleteVisibleFaces( const SimdPoint3& point, EpaFace* pFace, #ifdef EPA_POLYHEDRON_USE_PLANES EPA_DEBUG_ASSERT( ( pAdjacentFace->m_planeNormal.length2() > 0 ) ,"Invalid plane!" ); - SimdScalar pointDist = pAdjacentFace->m_planeNormal.dot( point ) + + btScalar pointDist = pAdjacentFace->m_planeNormal.dot( point ) + pAdjacentFace->m_planeDistance; if ( pointDist > PLANE_THICKNESS ) #else - SimdScalar dot = pAdjacentFace->m_v.dot( point ); + btScalar dot = pAdjacentFace->m_v.dot( point ); if ( dot >= pAdjacentFace->m_vSqrd ) #endif { diff --git a/Extras/EPA/EpaPolyhedron.h b/Extras/EPA/EpaPolyhedron.h index 1f898de64..f1548aee1 100644 --- a/Extras/EPA/EpaPolyhedron.h +++ b/Extras/EPA/EpaPolyhedron.h @@ -34,16 +34,16 @@ class EpaPolyhedron EpaPolyhedron(); ~EpaPolyhedron(); - bool Create( SimdPoint3* pInitialPoints, - SimdPoint3* pSupportPointsOnA, SimdPoint3* pSupportPointsOnB, + bool Create( btPoint3* pInitialPoints, + btPoint3* pSupportPointsOnA, btPoint3* pSupportPointsOnB, const int nbInitialPoints ); void Destroy(); EpaFace* CreateFace(); EpaHalfEdge* CreateHalfEdge(); - EpaVertex* CreateVertex( const SimdPoint3& wSupportPoint, - const SimdPoint3& wSupportPointOnA, - const SimdPoint3& wSupportPointOnB ); + EpaVertex* CreateVertex( const btPoint3& wSupportPoint, + const btPoint3& wSupportPointOnA, + const btPoint3& wSupportPointOnB ); void DeleteFace( EpaFace* pFace ); @@ -51,9 +51,9 @@ class EpaPolyhedron void DestroyAllHalfEdges(); void DestroyAllVertices(); - bool Expand( const SimdPoint3& wSupportPoint, - const SimdPoint3& wSupportPointOnA, - const SimdPoint3& wSupportPointOnB, + bool Expand( const btPoint3& wSupportPoint, + const btPoint3& wSupportPointOnA, + const btPoint3& wSupportPointOnB, EpaFace* pFace, std::list< EpaFace* >& newFaces ); std::list< EpaFace* >& GetFaces(); @@ -61,7 +61,7 @@ class EpaPolyhedron private : - void DeleteVisibleFaces( const SimdPoint3& point, EpaFace* pFace, + void DeleteVisibleFaces( const btPoint3& point, EpaFace* pFace, std::list< EpaHalfEdge* >& coneBaseTwinHalfEdges ); void CreateCone( EpaVertex* pAppexVertex, std::list< EpaHalfEdge* >& baseTwinHalfEdges, diff --git a/Extras/EPA/EpaVertex.h b/Extras/EPA/EpaVertex.h index b0eac4020..67eccbd29 100644 --- a/Extras/EPA/EpaVertex.h +++ b/Extras/EPA/EpaVertex.h @@ -30,13 +30,13 @@ class EpaVertex public : - EpaVertex( const SimdPoint3& point ) : /*m_pHalfEdge( 0 ),*/ m_point( point ) + EpaVertex( const btPoint3& point ) : /*m_pHalfEdge( 0 ),*/ m_point( point ) { } - EpaVertex( const SimdPoint3& point, - const SimdPoint3& wSupportPointOnA, - const SimdPoint3& wSupportPointOnB ) : /*m_pHalfEdge( 0 ),*/ m_point( point ), + EpaVertex( const btPoint3& point, + const btPoint3& wSupportPointOnA, + const btPoint3& wSupportPointOnB ) : /*m_pHalfEdge( 0 ),*/ m_point( point ), m_wSupportPointOnA( wSupportPointOnA ), m_wSupportPointOnB( wSupportPointOnB ) { @@ -51,10 +51,10 @@ class EpaVertex //! This is not necessary //EpaHalfEdge* m_pHalfEdge; - SimdPoint3 m_point; + btPoint3 m_point; - SimdPoint3 m_wSupportPointOnA; - SimdPoint3 m_wSupportPointOnB; + btPoint3 m_wSupportPointOnA; + btPoint3 m_wSupportPointOnB; }; #endif diff --git a/Extras/ExtraSolid35/CombinedSimplexSolver.cpp b/Extras/ExtraSolid35/CombinedSimplexSolver.cpp index fd38dcf37..5168cbb9e 100644 --- a/Extras/ExtraSolid35/CombinedSimplexSolver.cpp +++ b/Extras/ExtraSolid35/CombinedSimplexSolver.cpp @@ -30,7 +30,7 @@ void CombinedSimplexSolver::reset() } -void CombinedSimplexSolver::addVertex(const SimdVector3& w, const SimdPoint3& p, const SimdPoint3& q) +void CombinedSimplexSolver::addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q) { printf("addVertex (%f %f %f)\n",w[0],w[1],w[2]); m_voronoiSolver.addVertex(w,p,q); @@ -38,8 +38,8 @@ void CombinedSimplexSolver::addVertex(const SimdVector3& w, const SimdPoint3& p, int i; i=0; - SimdPoint3 vp1,vp2; - SimdPoint3 jp1,jp2; + btPoint3 vp1,vp2; + btPoint3 jp1,jp2; /* bool isClosest0 = m_voronoiSolver.closest(vp1); bool isClosest1 = m_johnsonSolver.closest(vp1); @@ -52,12 +52,12 @@ void CombinedSimplexSolver::addVertex(const SimdVector3& w, const SimdPoint3& p, -bool CombinedSimplexSolver::closest(SimdVector3& v) +bool CombinedSimplexSolver::closest(btVector3& v) { bool result0 = 0; bool result1 = 0; - SimdVector3 v0,v1; + btVector3 v0,v1; result0 = m_voronoiSolver.closest(v0); result1 = m_johnsonSolver.closest(v1); @@ -79,10 +79,10 @@ bool CombinedSimplexSolver::closest(SimdVector3& v) return result1; } -SimdScalar CombinedSimplexSolver::maxVertex() +btScalar CombinedSimplexSolver::maxVertex() { - SimdScalar maxv0 = m_voronoiSolver.maxVertex(); - SimdScalar maxv1 = m_johnsonSolver.maxVertex(); + btScalar maxv0 = m_voronoiSolver.maxVertex(); + btScalar maxv1 = m_johnsonSolver.maxVertex(); MY_ASSERT(maxv0 = maxv1); if (m_useVoronoiSolver) return maxv0; @@ -102,7 +102,7 @@ bool CombinedSimplexSolver::fullSimplex() const return fullSimplex1; } -int CombinedSimplexSolver::getSimplex(SimdPoint3 *pBuf, SimdPoint3 *qBuf, SimdVector3 *yBuf) const +int CombinedSimplexSolver::getSimplex(btPoint3 *pBuf, btPoint3 *qBuf, btVector3 *yBuf) const { @@ -119,12 +119,12 @@ int CombinedSimplexSolver::getSimplex(SimdPoint3 *pBuf, SimdPoint3 *qBuf, SimdVe void CombinedSimplexSolver::debugPrint() { - SimdPoint3 pBuf0[4]; - SimdPoint3 qBuf0[4]; - SimdPoint3 yBuf0[4]; - SimdPoint3 pBuf1[4]; - SimdPoint3 qBuf1[4]; - SimdPoint3 yBuf1[4]; + btPoint3 pBuf0[4]; + btPoint3 qBuf0[4]; + btPoint3 yBuf0[4]; + btPoint3 pBuf1[4]; + btPoint3 qBuf1[4]; + btPoint3 yBuf1[4]; int verts0,verts1; verts0 = m_voronoiSolver.getSimplex(&pBuf0[0], &qBuf0[0], &yBuf0[0]); @@ -146,7 +146,7 @@ void CombinedSimplexSolver::debugPrint() } -bool CombinedSimplexSolver::inSimplex(const SimdVector3& w) +bool CombinedSimplexSolver::inSimplex(const btVector3& w) { bool insimplex0 = m_voronoiSolver.inSimplex(w); bool insimplex1 = m_johnsonSolver.inSimplex(w); @@ -163,9 +163,9 @@ bool CombinedSimplexSolver::inSimplex(const SimdVector3& w) return insimplex1; } -void CombinedSimplexSolver::backup_closest(SimdVector3& v) +void CombinedSimplexSolver::backup_closest(btVector3& v) { - SimdVector3 v0,v1; + btVector3 v0,v1; m_voronoiSolver.backup_closest(v0); m_johnsonSolver.backup_closest(v1); @@ -189,10 +189,10 @@ bool CombinedSimplexSolver::emptySimplex() const return empty1; } -void CombinedSimplexSolver::compute_points(SimdPoint3& p1, SimdPoint3& p2) +void CombinedSimplexSolver::compute_points(btPoint3& p1, btPoint3& p2) { - SimdPoint3 tmpP1,tmpP2; - SimdPoint3 tmpJP1,tmpJP2; + btPoint3 tmpP1,tmpP2; + btPoint3 tmpJP1,tmpJP2; m_voronoiSolver.compute_points(tmpP1,tmpP2); m_johnsonSolver.compute_points(tmpJP1,tmpJP2); diff --git a/Extras/ExtraSolid35/CombinedSimplexSolver.h b/Extras/ExtraSolid35/CombinedSimplexSolver.h index 95d5195f2..8332a8b2c 100644 --- a/Extras/ExtraSolid35/CombinedSimplexSolver.h +++ b/Extras/ExtraSolid35/CombinedSimplexSolver.h @@ -17,10 +17,10 @@ #include "Solid3JohnsonSimplexSolver.h" /// CombinedSimplexSolver runs both Solid and Voronoi Simplex Solver for comparison -class CombinedSimplexSolver: public SimplexSolverInterface +class CombinedSimplexSolver: public btSimplexSolverInterface { - VoronoiSimplexSolver m_voronoiSolver; -// VoronoiSimplexSolver m_johnsonSolver; + btVoronoiSimplexSolver m_voronoiSolver; +// btVoronoiSimplexSolver m_johnsonSolver; Solid3JohnsonSimplexSolver m_johnsonSolver; @@ -35,23 +35,23 @@ class CombinedSimplexSolver: public SimplexSolverInterface virtual void reset(); - virtual void addVertex(const SimdVector3& w, const SimdPoint3& p, const SimdPoint3& q); + virtual void addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q); - virtual bool closest(SimdVector3& v); + virtual bool closest(btVector3& v); - virtual SimdScalar maxVertex(); + virtual btScalar maxVertex(); virtual bool fullSimplex() const; - virtual int getSimplex(SimdPoint3 *pBuf, SimdPoint3 *qBuf, SimdVector3 *yBuf) const; + virtual int getSimplex(btPoint3 *pBuf, btPoint3 *qBuf, btVector3 *yBuf) const; - virtual bool inSimplex(const SimdVector3& w); + virtual bool inSimplex(const btVector3& w); - virtual void backup_closest(SimdVector3& v) ; + virtual void backup_closest(btVector3& v) ; virtual bool emptySimplex() const; - virtual void compute_points(SimdPoint3& p1, SimdPoint3& p2); + virtual void compute_points(btPoint3& p1, btPoint3& p2); virtual int numVertices() const; diff --git a/Extras/ExtraSolid35/Solid3EpaPenetrationDepth.cpp b/Extras/ExtraSolid35/Solid3EpaPenetrationDepth.cpp index cc79f43c6..136369b32 100644 --- a/Extras/ExtraSolid35/Solid3EpaPenetrationDepth.cpp +++ b/Extras/ExtraSolid35/Solid3EpaPenetrationDepth.cpp @@ -8,7 +8,7 @@ * LICENSE.QPL included in the packaging of this file. * * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software + * GNU bteral Public License (GPL) version 2 as published by the Free Software * Foundation and appearing in the file LICENSE.GPL included in the * packaging of this file. * @@ -26,34 +26,34 @@ #include #include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h" #include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "LinearMath/GenMinMax.h" +#include "LinearMath/btMinMax.h" #define ASSERT_MESSAGE class ReplaceMeAccuracy { public: - static SimdScalar rel_error2; // squared relative error in the computed distance - static SimdScalar depth_tolerance; // terminate EPA if upper_bound <= depth_tolerance * dist2 - static SimdScalar tol_error; // error tolerance if the distance is almost zero + static btScalar rel_error2; // squared relative error in the computed distance + static btScalar depth_tolerance; // terminate EPA if upper_bound <= depth_tolerance * dist2 + static btScalar tol_error; // error tolerance if the distance is almost zero - static void setAccuracy(SimdScalar rel_error) + static void setAccuracy(btScalar rel_error) { rel_error2 = rel_error * rel_error; - depth_tolerance = SimdScalar(1.0f) + SimdScalar(2.0f) * rel_error; + depth_tolerance = btScalar(1.0f) + btScalar(2.0f) * rel_error; } - static void setTolerance(SimdScalar epsilon) + static void setTolerance(btScalar epsilon) { tol_error = epsilon; } }; -static const SimdScalar rel_error = SimdScalar(1.0e-3); +static const btScalar rel_error = btScalar(1.0e-3); -SimdScalar ReplaceMeAccuracy::rel_error2 = rel_error * rel_error; -SimdScalar ReplaceMeAccuracy::depth_tolerance = SimdScalar(1.0) + SimdScalar(2.0) * rel_error; -SimdScalar ReplaceMeAccuracy::tol_error = SIMD_EPSILON; +btScalar ReplaceMeAccuracy::rel_error2 = rel_error * rel_error; +btScalar ReplaceMeAccuracy::depth_tolerance = btScalar(1.0) + btScalar(2.0) * rel_error; +btScalar ReplaceMeAccuracy::tol_error = SIMD_EPSILON; @@ -101,28 +101,28 @@ public: bool isObsolete() const { return m_obsolete; } - bool computeClosest(const SimdVector3 *verts); + bool computeClosest(const btVector3 *verts); - const SimdVector3& getClosest() const { return m_closest; } + const btVector3& getClosest() const { return m_closest; } bool isClosestInternal() const { - return m_lambda1 >= SimdScalar(0.0) && - m_lambda2 >= SimdScalar(0.0) && + return m_lambda1 >= btScalar(0.0) && + m_lambda2 >= btScalar(0.0) && m_lambda1 + m_lambda2 <= m_det; } - SimdScalar getDist2() const { return m_dist2; } + btScalar getDist2() const { return m_dist2; } - SimdPoint3 getClosestPoint(const SimdPoint3 *points) const + btPoint3 getClosestPoint(const btPoint3 *points) const { - const SimdPoint3& p0 = points[m_indices[0]]; + const btPoint3& p0 = points[m_indices[0]]; return p0 + (m_lambda1 * (points[m_indices[1]] - p0) + m_lambda2 * (points[m_indices[2]] - p0)) / m_det; } - void silhouette(const SimdVector3& w, ReplaceMeEdgeBuffer& edgeBuffer) + void silhouette(const btVector3& w, ReplaceMeEdgeBuffer& edgeBuffer) { edgeBuffer.clear(); m_obsolete = true; @@ -132,18 +132,18 @@ public: } private: - void silhouette(int index, const SimdVector3& w, ReplaceMeEdgeBuffer& edgeBuffer); + void silhouette(int index, const btVector3& w, ReplaceMeEdgeBuffer& edgeBuffer); int m_indices[3]; bool m_obsolete; ReplaceMeFacet *m_adjFacets[3]; int m_adjEdges[3]; - SimdScalar m_det; - SimdScalar m_lambda1; - SimdScalar m_lambda2; - SimdVector3 m_closest; - SimdScalar m_dist2; + btScalar m_det; + btScalar m_lambda1; + btScalar m_lambda2; + btVector3 m_closest; + btScalar m_dist2; }; @@ -163,17 +163,17 @@ bool ReplaceMeFacet::link(int edge0, ReplaceMeFacet *facet, int edge1) } -bool ReplaceMeFacet::computeClosest(const SimdVector3 *verts) +bool ReplaceMeFacet::computeClosest(const btVector3 *verts) { - const SimdVector3& p0 = verts[m_indices[0]]; + const btVector3& p0 = verts[m_indices[0]]; - SimdVector3 v1 = verts[m_indices[1]] - p0; - SimdVector3 v2 = verts[m_indices[2]] - p0; - SimdScalar v1dv1 = v1.length2(); - SimdScalar v1dv2 = v1.dot(v2); - SimdScalar v2dv2 = v2.length2(); - SimdScalar p0dv1 = p0.dot(v1); - SimdScalar p0dv2 = p0.dot(v2); + btVector3 v1 = verts[m_indices[1]] - p0; + btVector3 v2 = verts[m_indices[2]] - p0; + btScalar v1dv1 = v1.length2(); + btScalar v1dv2 = v1.dot(v2); + btScalar v2dv2 = v2.length2(); + btScalar p0dv1 = p0.dot(v1); + btScalar p0dv2 = p0.dot(v2); m_det = v1dv1 * v2dv2 - v1dv2 * v1dv2; // non-negative //printf("m_det = %f\n",m_det); @@ -192,7 +192,7 @@ bool ReplaceMeFacet::computeClosest(const SimdVector3 *verts) return false; } -void ReplaceMeFacet::silhouette(int index, const SimdVector3& w, +void ReplaceMeFacet::silhouette(int index, const btVector3& w, ReplaceMeEdgeBuffer& edgeBuffer) { if (!m_obsolete) { @@ -227,9 +227,9 @@ inline int ReplaceMeEdge::getTarget() const const int MaxSupportPoints = 100;//1000; const int MaxFacets = 200;//b2000; -static SimdPoint3 pBuf[MaxSupportPoints]; -static SimdPoint3 qBuf[MaxSupportPoints]; -static SimdVector3 yBuf[MaxSupportPoints]; +static btPoint3 pBuf[MaxSupportPoints]; +static btPoint3 qBuf[MaxSupportPoints]; +static btVector3 yBuf[MaxSupportPoints]; static ReplaceMeFacet facetBuf[MaxFacets]; static int freeFacet = 0; @@ -249,7 +249,7 @@ public: ReplaceMeFacetComp myFacetComp; inline ReplaceMeFacet *addFacet(int i0, int i1, int i2, - SimdScalar lower2, SimdScalar upper2) + btScalar lower2, btScalar upper2) { assert(i0 != i1 && i0 != i2 && i1 != i2); if (freeFacet < MaxFacets) @@ -300,27 +300,27 @@ inline ReplaceMeFacet *addFacet(int i0, int i1, int i2, -inline bool originInTetrahedron(const SimdVector3& p1, const SimdVector3& p2, - const SimdVector3& p3, const SimdVector3& p4) +inline bool originInTetrahedron(const btVector3& p1, const btVector3& p2, + const btVector3& p3, const btVector3& p4) { - SimdVector3 normal1 = (p2 - p1).cross(p3 - p1); - SimdVector3 normal2 = (p3 - p2).cross(p4 - p2); - SimdVector3 normal3 = (p4 - p3).cross(p1 - p3); - SimdVector3 normal4 = (p1 - p4).cross(p2 - p4); + btVector3 normal1 = (p2 - p1).cross(p3 - p1); + btVector3 normal2 = (p3 - p2).cross(p4 - p2); + btVector3 normal3 = (p4 - p3).cross(p1 - p3); + btVector3 normal4 = (p1 - p4).cross(p2 - p4); return - (normal1.dot(p1) > SimdScalar(0.0)) != (normal1.dot(p4) > SimdScalar(0.0)) && - (normal2.dot(p2) > SimdScalar(0.0)) != (normal2.dot(p1) > SimdScalar(0.0)) && - (normal3.dot(p3) > SimdScalar(0.0)) != (normal3.dot(p2) > SimdScalar(0.0)) && - (normal4.dot(p4) > SimdScalar(0.0)) != (normal4.dot(p3) > SimdScalar(0.0)); + (normal1.dot(p1) > btScalar(0.0)) != (normal1.dot(p4) > btScalar(0.0)) && + (normal2.dot(p2) > btScalar(0.0)) != (normal2.dot(p1) > btScalar(0.0)) && + (normal3.dot(p3) > btScalar(0.0)) != (normal3.dot(p2) > btScalar(0.0)) && + (normal4.dot(p4) > btScalar(0.0)) != (normal4.dot(p3) > btScalar(0.0)); } -bool Solid3EpaPenetrationDepth::CalcPenDepth( SimplexSolverInterface& simplexSolver, - ConvexShape* convexA,ConvexShape* convexB, - const SimdTransform& transformA,const SimdTransform& transformB, - SimdVector3& v, SimdPoint3& pa, SimdPoint3& pb) +bool Solid3EpaPenetrationDepth::CalcPenDepth( btSimplexSolverInterface& simplexSolver, + btConvexShape* convexA,btConvexShape* convexB, + const btTransform& transformA,const btTransform& transformB, + btVector3& v, btPoint3& pa, btPoint3& pb) { int num_verts = simplexSolver.getSimplex(pBuf, qBuf, yBuf); @@ -336,17 +336,17 @@ bool Solid3EpaPenetrationDepth::CalcPenDepth( SimplexSolverInterface& simplexSol // We have a line segment inside the Minkowski sum containing the // origin. Blow it up by adding three additional support points. - SimdVector3 dir = (yBuf[1] - yBuf[0]).normalized(); + btVector3 dir = (yBuf[1] - yBuf[0]).normalized(); int axis = dir.furthestAxis(); - static SimdScalar sin_60 = 0.8660254037f;//84438646763723170752941.22474487f;//13915890490986420373529;// + static btScalar sin_60 = 0.8660254037f;//84438646763723170752941.22474487f;//13915890490986420373529;// - SimdQuaternion rot(dir[0] * sin_60, dir[1] * sin_60, dir[2] * sin_60, SimdScalar(0.5)); - SimdMatrix3x3 rot_mat(rot); + btQuaternion rot(dir[0] * sin_60, dir[1] * sin_60, dir[2] * sin_60, btScalar(0.5)); + btMatrix3x3 rot_mat(rot); - SimdVector3 aux1 = dir.cross(SimdVector3(axis == 0, axis == 1, axis == 2)); - SimdVector3 aux2 = rot_mat * aux1; - SimdVector3 aux3 = rot_mat * aux2; + btVector3 aux1 = dir.cross(btVector3(axis == 0, axis == 1, axis == 2)); + btVector3 aux2 = rot_mat * aux1; + btVector3 aux3 = rot_mat * aux2; pBuf[2] = transformA(convexA->LocalGetSupportingVertex(aux1*transformA.getBasis())); qBuf[2] = transformB(convexB->LocalGetSupportingVertex((-aux1)*transformB.getBasis())); @@ -387,9 +387,9 @@ bool Solid3EpaPenetrationDepth::CalcPenDepth( SimplexSolverInterface& simplexSol // We have a triangle inside the Minkowski sum containing // the origin. First blow it up. - SimdVector3 v1 = yBuf[1] - yBuf[0]; - SimdVector3 v2 = yBuf[2] - yBuf[0]; - SimdVector3 vv = v1.cross(v2); + btVector3 v1 = yBuf[1] - yBuf[0]; + btVector3 v2 = yBuf[2] - yBuf[0]; + btVector3 vv = v1.cross(v2); pBuf[3] = transformA(convexA->LocalGetSupportingVertex(vv*transformA.getBasis())); qBuf[3] = transformB(convexB->LocalGetSupportingVertex((-vv)*transformB.getBasis())); @@ -430,15 +430,15 @@ bool Solid3EpaPenetrationDepth::CalcPenDepth( SimplexSolverInterface& simplexSol num_facets = 0; freeFacet = 0; - ReplaceMeFacet *f0 = addFacet(0, 1, 2, SimdScalar(0.0), SIMD_INFINITY); - ReplaceMeFacet *f1 = addFacet(0, 3, 1, SimdScalar(0.0), SIMD_INFINITY); - ReplaceMeFacet *f2 = addFacet(0, 2, 3, SimdScalar(0.0), SIMD_INFINITY); - ReplaceMeFacet *f3 = addFacet(1, 3, 2, SimdScalar(0.0), SIMD_INFINITY); + ReplaceMeFacet *f0 = addFacet(0, 1, 2, btScalar(0.0), SIMD_INFINITY); + ReplaceMeFacet *f1 = addFacet(0, 3, 1, btScalar(0.0), SIMD_INFINITY); + ReplaceMeFacet *f2 = addFacet(0, 2, 3, btScalar(0.0), SIMD_INFINITY); + ReplaceMeFacet *f3 = addFacet(1, 3, 2, btScalar(0.0), SIMD_INFINITY); - if (!f0 || f0->getDist2() == SimdScalar(0.0) || - !f1 || f1->getDist2() == SimdScalar(0.0) || - !f2 || f2->getDist2() == SimdScalar(0.0) || - !f3 || f3->getDist2() == SimdScalar(0.0)) + if (!f0 || f0->getDist2() == btScalar(0.0) || + !f1 || f1->getDist2() == btScalar(0.0) || + !f2 || f2->getDist2() == btScalar(0.0) || + !f3 || f3->getDist2() == btScalar(0.0)) { return false; } @@ -461,7 +461,7 @@ bool Solid3EpaPenetrationDepth::CalcPenDepth( SimplexSolverInterface& simplexSol ReplaceMeFacet *facet = 0; - SimdScalar upper_bound2 = SIMD_INFINITY; + btScalar upper_bound2 = SIMD_INFINITY; do { facet = facetHeap[0]; @@ -470,7 +470,7 @@ bool Solid3EpaPenetrationDepth::CalcPenDepth( SimplexSolverInterface& simplexSol if (!facet->isObsolete()) { - assert(facet->getDist2() > SimdScalar(0.0)); + assert(facet->getDist2() > btScalar(0.0)); if (num_verts == MaxSupportPoints) { @@ -487,16 +487,16 @@ bool Solid3EpaPenetrationDepth::CalcPenDepth( SimplexSolverInterface& simplexSol int index = num_verts++; - SimdScalar far_dist2 = yBuf[index].dot(facet->getClosest()); + btScalar far_dist2 = yBuf[index].dot(facet->getClosest()); // Make sure the support mapping is OK. - //assert(far_dist2 > SimdScalar(0.0)); + //assert(far_dist2 > btScalar(0.0)); // // this is to avoid problems with implicit-sphere-touching contact // - if (far_dist2 < SimdScalar(0.0)) + if (far_dist2 < btScalar(0.0)) { return false; } diff --git a/Extras/ExtraSolid35/Solid3EpaPenetrationDepth.h b/Extras/ExtraSolid35/Solid3EpaPenetrationDepth.h index 0d2f98c28..7532f04f2 100644 --- a/Extras/ExtraSolid35/Solid3EpaPenetrationDepth.h +++ b/Extras/ExtraSolid35/Solid3EpaPenetrationDepth.h @@ -8,7 +8,7 @@ * LICENSE.QPL included in the packaging of this file. * * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software + * GNU bteral Public License (GPL) version 2 as published by the Free Software * Foundation and appearing in the file LICENSE.GPL included in the * packaging of this file. * @@ -28,14 +28,14 @@ #include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h" /// Solid3EpaPenetrationDepth contains the 'Expanding Polytope Algorithm' from Solid 3.5 -class Solid3EpaPenetrationDepth : public ConvexPenetrationDepthSolver +class Solid3EpaPenetrationDepth : public btConvexPenetrationDepthSolver { public: - virtual bool CalcPenDepth(SimplexSolverInterface& simplexSolver, - ConvexShape* convexA,ConvexShape* convexB, - const SimdTransform& transformA,const SimdTransform& transformB, - SimdVector3& v, SimdPoint3& pa, SimdPoint3& pb); + virtual bool CalcPenDepth(btSimplexSolverInterface& simplexSolver, + btConvexShape* convexA,btConvexShape* convexB, + const btTransform& transformA,const btTransform& transformB, + btVector3& v, btPoint3& pa, btPoint3& pb); }; diff --git a/Extras/ExtraSolid35/Solid3JohnsonSimplexSolver.cpp b/Extras/ExtraSolid35/Solid3JohnsonSimplexSolver.cpp index 0ad4e2ef7..0a4f0ad97 100644 --- a/Extras/ExtraSolid35/Solid3JohnsonSimplexSolver.cpp +++ b/Extras/ExtraSolid35/Solid3JohnsonSimplexSolver.cpp @@ -8,7 +8,7 @@ * LICENSE.QPL included in the packaging of this file. * * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software + * GNU bteral Public License (GPL) version 2 as published by the Free Software * Foundation and appearing in the file LICENSE.GPL included in the * packaging of this file. * @@ -22,7 +22,7 @@ */ #include "Solid3JohnsonSimplexSolver.h" -#include "LinearMath/GenMinMax.h" +#include "LinearMath/btMinMax.h" //#define USE_BACKUP_PROCEDURE //#define FAST_CLOSEST @@ -48,7 +48,7 @@ void Solid3JohnsonSimplexSolver::reset() -void Solid3JohnsonSimplexSolver::addVertex(const SimdVector3& w) +void Solid3JohnsonSimplexSolver::addVertex(const btVector3& w) { assert(!fullSimplex()); m_last = 0; @@ -66,7 +66,7 @@ void Solid3JohnsonSimplexSolver::addVertex(const SimdVector3& w) compute_det(); } -void Solid3JohnsonSimplexSolver::addVertex(const SimdVector3& w, const SimdPoint3& p, const SimdPoint3& q) +void Solid3JohnsonSimplexSolver::addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q) { addVertex(w); m_p[m_last] = p; @@ -83,12 +83,12 @@ bool Solid3JohnsonSimplexSolver::fullSimplex() const return m_bits1 == 0xf; } -SimdScalar Solid3JohnsonSimplexSolver::maxVertex() +btScalar Solid3JohnsonSimplexSolver::maxVertex() { return m_maxlen2; } -bool Solid3JohnsonSimplexSolver::closest(SimdVector3& v) +bool Solid3JohnsonSimplexSolver::closest(btVector3& v) { #ifdef FAST_CLOSEST T_Bits s; @@ -125,14 +125,14 @@ bool Solid3JohnsonSimplexSolver::closest(SimdVector3& v) // Original GJK calls the backup procedure at this point. #ifdef USE_BACKUP_PROCEDURE - backup_closest(SimdVector3& v); + backup_closest(btVector3& v); #endif return false; } -int Solid3JohnsonSimplexSolver::getSimplex(SimdPoint3 *pBuf, SimdPoint3 *qBuf, SimdVector3 *yBuf) const +int Solid3JohnsonSimplexSolver::getSimplex(btPoint3 *pBuf, btPoint3 *qBuf, btVector3 *yBuf) const { int num_verts = 0; int i; @@ -155,7 +155,7 @@ int Solid3JohnsonSimplexSolver::getSimplex(SimdPoint3 *pBuf, SimdPoint3 *qBuf, S return num_verts; } -bool Solid3JohnsonSimplexSolver::inSimplex(const SimdVector3& w) +bool Solid3JohnsonSimplexSolver::inSimplex(const btVector3& w) { int i; T_Bits bit; @@ -171,18 +171,18 @@ bool Solid3JohnsonSimplexSolver::inSimplex(const SimdVector3& w) -void Solid3JohnsonSimplexSolver::backup_closest(SimdVector3& v) +void Solid3JohnsonSimplexSolver::backup_closest(btVector3& v) { - SimdScalar min_dist2 = SIMD_INFINITY; + btScalar min_dist2 = SIMD_INFINITY; T_Bits s; for (s = m_all_bits; s != 0x0; --s) { if (subseteq(s, m_all_bits) && proper(s)) { - SimdVector3 u; + btVector3 u; compute_vector(s, u); - SimdScalar dist2 = u.length2(); + btScalar dist2 = u.length2(); if (dist2 < min_dist2) { min_dist2 = dist2; @@ -195,11 +195,11 @@ void Solid3JohnsonSimplexSolver::backup_closest(SimdVector3& v) } -void Solid3JohnsonSimplexSolver::compute_points(SimdPoint3& p1, SimdPoint3& p2) +void Solid3JohnsonSimplexSolver::compute_points(btPoint3& p1, btPoint3& p2) { - SimdScalar sum = SimdScalar(0.0); - p1.setValue(SimdScalar(0.0), SimdScalar(0.0), SimdScalar(0.0)); - p2.setValue(SimdScalar(0.0), SimdScalar(0.0), SimdScalar(0.0)); + btScalar sum = btScalar(0.0); + p1.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); + p2.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); int i; T_Bits bit; for (i = 0, bit = 0x1; i < 4; ++i, bit <<= 1) @@ -212,8 +212,8 @@ void Solid3JohnsonSimplexSolver::compute_points(SimdPoint3& p1, SimdPoint3& p2) } } - assert(sum > SimdScalar(0.0)); - SimdScalar s = SimdScalar(1.0) / sum; + assert(sum > btScalar(0.0)); + btScalar s = btScalar(1.0) / sum; p1 *= s; p2 *= s; } @@ -272,12 +272,12 @@ bool Solid3JohnsonSimplexSolver::valid(T_Bits s) { if (contains(s, bit)) { - if (m_det[s][i] <= SimdScalar(0.0)) + if (m_det[s][i] <= btScalar(0.0)) { return false; } } - else if (m_det[s | bit][i] > SimdScalar(0.0)) + else if (m_det[s | bit][i] > btScalar(0.0)) { return false; } @@ -292,7 +292,7 @@ bool Solid3JohnsonSimplexSolver::proper(T_Bits s) T_Bits bit; for (i = 0, bit = 0x1; i < 4; ++i, bit <<= 1) { - if (contains(s, bit) && m_det[s][i] <= SimdScalar(0.0)) + if (contains(s, bit) && m_det[s][i] <= btScalar(0.0)) { return false; } @@ -300,11 +300,11 @@ bool Solid3JohnsonSimplexSolver::proper(T_Bits s) return true; } -void Solid3JohnsonSimplexSolver::compute_vector(T_Bits s, SimdVector3& v) +void Solid3JohnsonSimplexSolver::compute_vector(T_Bits s, btVector3& v) { - m_maxlen2 = SimdScalar(0.0); - SimdScalar sum = SimdScalar(0.0); - v .setValue(SimdScalar(0.0), SimdScalar(0.0), SimdScalar(0.0)); + m_maxlen2 = btScalar(0.0); + btScalar sum = btScalar(0.0); + v .setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); int i; T_Bits bit; @@ -318,7 +318,7 @@ void Solid3JohnsonSimplexSolver::compute_vector(T_Bits s, SimdVector3& v) } } - assert(sum > SimdScalar(0.0)); + assert(sum > btScalar(0.0)); v /= sum; } diff --git a/Extras/ExtraSolid35/Solid3JohnsonSimplexSolver.h b/Extras/ExtraSolid35/Solid3JohnsonSimplexSolver.h index 48b015c19..290719170 100644 --- a/Extras/ExtraSolid35/Solid3JohnsonSimplexSolver.h +++ b/Extras/ExtraSolid35/Solid3JohnsonSimplexSolver.h @@ -8,7 +8,7 @@ * LICENSE.QPL included in the packaging of this file. * * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software + * GNU bteral Public License (GPL) version 2 as published by the Free Software * Foundation and appearing in the file LICENSE.GPL included in the * packaging of this file. * @@ -30,7 +30,7 @@ /// Solid3JohnsonSimplexSolver contains Johnson subdistance algorithm from Solid 3.5 library -class Solid3JohnsonSimplexSolver : public SimplexSolverInterface +class Solid3JohnsonSimplexSolver : public btSimplexSolverInterface { private: @@ -42,22 +42,22 @@ private: void compute_det(); bool valid(T_Bits s); bool proper(T_Bits s); - void compute_vector(T_Bits s, SimdVector3& v); + void compute_vector(T_Bits s, btVector3& v); - SimdScalar m_det[16][4]; // cached sub-determinants - SimdVector3 m_edge[4][4]; + btScalar m_det[16][4]; // cached sub-determinants + btVector3 m_edge[4][4]; #ifdef JOHNSON_ROBUST - SimdScalar m_norm[4][4]; + btScalar m_norm[4][4]; #endif - SimdPoint3 m_p[4]; // support points of object A in local coordinates - SimdPoint3 m_q[4]; // support points of object B in local coordinates - SimdVector3 m_y[4]; // support points of A - B in world coordinates - SimdScalar m_ylen2[4]; // Squared lengths support points y + btPoint3 m_p[4]; // support points of object A in local coordinates + btPoint3 m_q[4]; // support points of object B in local coordinates + btVector3 m_y[4]; // support points of A - B in world coordinates + btScalar m_ylen2[4]; // Squared lengths support points y - SimdScalar m_maxlen2; // Maximum squared length to a vertex of the current + btScalar m_maxlen2; // Maximum squared length to a vertex of the current // simplex T_Bits m_bits1; // identifies current simplex T_Bits m_last; // identifies last found support point @@ -69,7 +69,7 @@ private: private: - void addVertex(const SimdVector3& w); + void addVertex(const btVector3& w); public: Solid3JohnsonSimplexSolver(); @@ -78,23 +78,23 @@ public: virtual void reset(); - virtual void addVertex(const SimdVector3& w, const SimdPoint3& p, const SimdPoint3& q); + virtual void addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q); - virtual bool closest(SimdVector3& v); + virtual bool closest(btVector3& v); - virtual SimdScalar maxVertex(); + virtual btScalar maxVertex(); virtual bool fullSimplex() const; - virtual int getSimplex(SimdPoint3 *pBuf, SimdPoint3 *qBuf, SimdVector3 *yBuf) const; + virtual int getSimplex(btPoint3 *pBuf, btPoint3 *qBuf, btVector3 *yBuf) const; - virtual bool inSimplex(const SimdVector3& w); + virtual bool inSimplex(const btVector3& w); - virtual void backup_closest(SimdVector3& v) ; + virtual void backup_closest(btVector3& v) ; virtual bool emptySimplex() const ; - virtual void compute_points(SimdPoint3& p1, SimdPoint3& p2) ; + virtual void compute_points(btPoint3& p1, btPoint3& p2) ; virtual int numVertices() const ; diff --git a/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.cpp b/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.cpp index 290d477ff..c0e4c207a 100644 --- a/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.cpp +++ b/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.cpp @@ -21,14 +21,14 @@ subject to the following restrictions: #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" #include "BulletCollision/CollisionShapes/btConvexShape.h" #include "CcdPhysicsEnvironment.h" -#include "LinearMath/SimdTransformUtil.h" +#include "LinearMath/btTransformUtil.h" #include "BulletCollision/CollisionShapes/btSphereShape.h" #include "BulletCollision/CollisionShapes/btConeShape.h" class BP_Proxy; -///todo: fill all the empty CcdPhysicsController methods, hook them up to the RigidBody class +///todo: fill all the empty CcdPhysicsController methods, hook them up to the btRigidBody class //'temporarily' global variables float gDeactivationTime = 2.f; @@ -39,8 +39,8 @@ float gAngularSleepingTreshold = 1.0f; #include "BulletDynamics/Dynamics/btMassProps.h" -SimdVector3 startVel(0,0,0);//-10000); -CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) +btVector3 startVel(0,0,0);//-10000); +CcdPhysicsController::CcdPhysicsController (const btCcdConstructionInfo& ci) :m_cci(ci) { m_collisionDelay = 0; @@ -61,14 +61,14 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) } -SimdTransform CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState* motionState) +btTransform CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState* motionState) { - SimdTransform trans; + btTransform trans; float tmp[3]; motionState->getWorldPosition(tmp[0],tmp[1],tmp[2]); - trans.setOrigin(SimdVector3(tmp[0],tmp[1],tmp[2])); + trans.setOrigin(btVector3(tmp[0],tmp[1],tmp[2])); - SimdQuaternion orn; + btQuaternion orn; motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]); trans.setRotation(orn); return trans; @@ -78,11 +78,11 @@ SimdTransform CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState void CcdPhysicsController::CreateRigidbody() { - SimdTransform trans = GetTransformFromMotionState(m_cci.m_MotionState); + btTransform trans = GetTransformFromMotionState(m_cci.m_MotionState); - MassProps mp(m_cci.m_mass, m_cci.m_localInertiaTensor); + btMassProps mp(m_cci.m_mass, m_cci.m_localInertiaTensor); - m_body = new RigidBody(mp,0,0,m_cci.m_friction,m_cci.m_restitution); + m_body = new btRigidBody(mp,0,0,m_cci.m_friction,m_cci.m_restitution); m_body->m_collisionShape = m_cci.m_collisionShape; @@ -120,27 +120,27 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) if (!m_body->IsStatic()) { - const SimdVector3& worldPos = m_body->getCenterOfMassPosition(); + const btVector3& worldPos = m_body->getCenterOfMassPosition(); m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]); - const SimdQuaternion& worldquat = m_body->getOrientation(); + const btQuaternion& worldquat = m_body->getOrientation(); m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]); m_MotionState->calculateWorldTransformations(); float scale[3]; m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]); - SimdVector3 scaling(scale[0],scale[1],scale[2]); + btVector3 scaling(scale[0],scale[1],scale[2]); GetCollisionShape()->setLocalScaling(scaling); } else { - SimdVector3 worldPos; - SimdQuaternion worldquat; + btVector3 worldPos; + btQuaternion worldquat; m_MotionState->getWorldPosition(worldPos[0],worldPos[1],worldPos[2]); m_MotionState->getWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]); - SimdTransform oldTrans = m_body->getCenterOfMassTransform(); - SimdTransform newTrans(worldquat,worldPos); + btTransform oldTrans = m_body->getCenterOfMassTransform(); + btTransform newTrans(worldquat,worldPos); m_body->setCenterOfMassTransform(newTrans); //need to keep track of previous position for friction effects... @@ -149,7 +149,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) float scale[3]; m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]); - SimdVector3 scaling(scale[0],scale[1],scale[2]); + btVector3 scaling(scale[0],scale[1],scale[2]); GetCollisionShape()->setLocalScaling(scaling); } return true; @@ -219,8 +219,8 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc { m_body->activate(); - SimdVector3 dloc(dlocX,dlocY,dlocZ); - SimdTransform xform = m_body->getCenterOfMassTransform(); + btVector3 dloc(dlocX,dlocY,dlocZ); + btTransform xform = m_body->getCenterOfMassTransform(); if (local) { @@ -239,15 +239,15 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) { m_body->activate(); - SimdMatrix3x3 drotmat( rotval[0],rotval[1],rotval[2], + btMatrix3x3 drotmat( rotval[0],rotval[1],rotval[2], rotval[4],rotval[5],rotval[6], rotval[8],rotval[9],rotval[10]); - SimdMatrix3x3 currentOrn; + btMatrix3x3 currentOrn; GetWorldOrientation(currentOrn); - SimdTransform xform = m_body->getCenterOfMassTransform(); + btTransform xform = m_body->getCenterOfMassTransform(); xform.setBasis(xform.getBasis()*(local ? drotmat : (currentOrn.inverse() * drotmat * currentOrn))); @@ -257,17 +257,17 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) } -void CcdPhysicsController::GetWorldOrientation(SimdMatrix3x3& mat) +void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat) { float orn[4]; m_MotionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]); - SimdQuaternion quat(orn[0],orn[1],orn[2],orn[3]); + btQuaternion quat(orn[0],orn[1],orn[2],orn[3]); mat.setRotation(quat); } void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal) { - SimdQuaternion q = m_body->getCenterOfMassTransform().getRotation(); + btQuaternion q = m_body->getCenterOfMassTransform().getRotation(); quatImag0 = q[0]; quatImag1 = q[1]; quatImag2 = q[2]; @@ -277,8 +277,8 @@ void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float { m_body->activate(); m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); - SimdTransform xform = m_body->getCenterOfMassTransform(); - xform.setRotation(SimdQuaternion(quatImag0,quatImag1,quatImag2,quatReal)); + btTransform xform = m_body->getCenterOfMassTransform(); + xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal)); m_body->setCenterOfMassTransform(xform); } @@ -287,8 +287,8 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ) { m_body->activate(); m_MotionState->setWorldPosition(posX,posY,posZ); - SimdTransform xform = m_body->getCenterOfMassTransform(); - xform.setOrigin(SimdVector3(posX,posY,posZ)); + btTransform xform = m_body->getCenterOfMassTransform(); + xform.setOrigin(btVector3(posX,posY,posZ)); m_body->setCenterOfMassTransform(xform); } @@ -298,7 +298,7 @@ void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvel void CcdPhysicsController::getPosition(PHY__Vector3& pos) const { - const SimdTransform& xform = m_body->getCenterOfMassTransform(); + const btTransform& xform = m_body->getCenterOfMassTransform(); pos[0] = xform.getOrigin().x(); pos[1] = xform.getOrigin().y(); pos[2] = xform.getOrigin().z(); @@ -306,11 +306,11 @@ void CcdPhysicsController::getPosition(PHY__Vector3& pos) const void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ) { - if (!SimdFuzzyZero(m_cci.m_scaling.x()-scaleX) || - !SimdFuzzyZero(m_cci.m_scaling.y()-scaleY) || - !SimdFuzzyZero(m_cci.m_scaling.z()-scaleZ)) + if (!btFuzzyZero(m_cci.m_scaling.x()-scaleX) || + !btFuzzyZero(m_cci.m_scaling.y()-scaleY) || + !btFuzzyZero(m_cci.m_scaling.z()-scaleZ)) { - m_cci.m_scaling = SimdVector3(scaleX,scaleY,scaleZ); + m_cci.m_scaling = btVector3(scaleX,scaleY,scaleZ); if (m_body && m_body->GetCollisionShape()) { @@ -324,8 +324,8 @@ void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ) // physics methods void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local) { - SimdVector3 torque(torqueX,torqueY,torqueZ); - SimdTransform xform = m_body->getCenterOfMassTransform(); + btVector3 torque(torqueX,torqueY,torqueZ); + btTransform xform = m_body->getCenterOfMassTransform(); if (local) { torque = xform.getBasis()*torque; @@ -335,8 +335,8 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local) { - SimdVector3 force(forceX,forceY,forceZ); - SimdTransform xform = m_body->getCenterOfMassTransform(); + btVector3 force(forceX,forceY,forceZ); + btTransform xform = m_body->getCenterOfMassTransform(); if (local) { force = xform.getBasis()*force; @@ -345,14 +345,14 @@ void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo } void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local) { - SimdVector3 angvel(ang_velX,ang_velY,ang_velZ); + btVector3 angvel(ang_velX,ang_velY,ang_velZ); if (angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { m_body->activate(); } { - SimdTransform xform = m_body->getCenterOfMassTransform(); + btTransform xform = m_body->getCenterOfMassTransform(); if (local) { angvel = xform.getBasis()*angvel; @@ -365,14 +365,14 @@ void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,flo void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local) { - SimdVector3 linVel(lin_velX,lin_velY,lin_velZ); + btVector3 linVel(lin_velX,lin_velY,lin_velZ); if (linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { m_body->activate(); } { - SimdTransform xform = m_body->getCenterOfMassTransform(); + btTransform xform = m_body->getCenterOfMassTransform(); if (local) { linVel = xform.getBasis()*linVel; @@ -382,13 +382,13 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa } void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ) { - SimdVector3 impulse(impulseX,impulseY,impulseZ); + btVector3 impulse(impulseX,impulseY,impulseZ); if (impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { m_body->activate(); - SimdVector3 pos(attachX,attachY,attachZ); + btVector3 pos(attachX,attachY,attachZ); m_body->activate(); @@ -402,7 +402,7 @@ void CcdPhysicsController::SetActive(bool active) // reading out information from physics void CcdPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ) { - const SimdVector3& linvel = this->m_body->getLinearVelocity(); + const btVector3& linvel = this->m_body->getLinearVelocity(); linvX = linvel.x(); linvY = linvel.y(); linvZ = linvel.z(); @@ -411,7 +411,7 @@ void CcdPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& l void CcdPhysicsController::GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ) { - const SimdVector3& angvel= m_body->getAngularVelocity(); + const btVector3& angvel= m_body->getAngularVelocity(); angVelX = angvel.x(); angVelY = angvel.y(); angVelZ = angvel.z(); @@ -419,9 +419,9 @@ void CcdPhysicsController::GetAngularVelocity(float& angVelX,float& angVelY,flo void CcdPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ) { - SimdVector3 pos(posX,posY,posZ); - SimdVector3 rel_pos = pos-m_body->getCenterOfMassPosition(); - SimdVector3 linvel = m_body->getVelocityInLocalPoint(rel_pos); + btVector3 pos(posX,posY,posZ); + btVector3 rel_pos = pos-m_body->getCenterOfMassPosition(); + btVector3 linvel = m_body->getVelocityInLocalPoint(rel_pos); linvX = linvel.x(); linvY = linvel.y(); linvZ = linvel.z(); @@ -436,7 +436,7 @@ void CcdPhysicsController::setRigidBody(bool rigid) if (!rigid) { //fake it for now - SimdVector3 inertia = m_body->getInvInertiaDiagLocal(); + btVector3 inertia = m_body->getInvInertiaDiagLocal(); inertia[1] = 0.f; m_body->setInvInertiaDiagLocal(inertia); m_body->updateInertiaTensor(); @@ -494,24 +494,24 @@ bool CcdPhysicsController::wantsSleeping() PHY_IPhysicsController* CcdPhysicsController::GetReplica() { //very experimental, shape sharing is not implemented yet. - //just support SphereShape/ConeShape for now + //just support btSphereShape/ConeShape for now - CcdConstructionInfo cinfo = m_cci; + btCcdConstructionInfo cinfo = m_cci; if (cinfo.m_collisionShape) { switch (cinfo.m_collisionShape->GetShapeType()) { case SPHERE_SHAPE_PROXYTYPE: { - SphereShape* orgShape = (SphereShape*)cinfo.m_collisionShape; - cinfo.m_collisionShape = new SphereShape(*orgShape); + btSphereShape* orgShape = (btSphereShape*)cinfo.m_collisionShape; + cinfo.m_collisionShape = new btSphereShape(*orgShape); break; } case CONE_SHAPE_PROXYTYPE: { - ConeShape* orgShape = (ConeShape*)cinfo.m_collisionShape; - cinfo.m_collisionShape = new ConeShape(*orgShape); + btConeShape* orgShape = (btConeShape*)cinfo.m_collisionShape; + cinfo.m_collisionShape = new btConeShape(*orgShape); break; } @@ -570,13 +570,13 @@ void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,flo void DefaultMotionState::setWorldPosition(float posX,float posY,float posZ) { - SimdPoint3 pos(posX,posY,posZ); + btPoint3 pos(posX,posY,posZ); m_worldTransform.setOrigin( pos ); } void DefaultMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) { - SimdQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); + btQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); m_worldTransform.setRotation( orn ); } diff --git a/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.h b/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.h index 6e048e782..47a86789b 100644 --- a/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.h +++ b/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.h @@ -21,16 +21,16 @@ subject to the following restrictions: /// PHY_IPhysicsController is the abstract simplified Interface to a physical object. /// It contains the IMotionState and IDeformableMesh Interfaces. -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdScalar.h" -#include "LinearMath/SimdMatrix3x3.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btScalar.h" +#include "LinearMath/btMatrix3x3.h" +#include "LinearMath/btTransform.h" #include "BulletDynamics/Dynamics/btRigidBody.h" #include "PHY_IMotionState.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for CollisionShape access -class CollisionShape; +#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for btCollisionShape access +class btCollisionShape; extern float gDeactivationTime; extern float gLinearSleepingTreshold; @@ -41,12 +41,12 @@ class CcdPhysicsEnvironment; -struct CcdConstructionInfo +struct btCcdConstructionInfo { ///CollisionFilterGroups provides some optional usage of basic collision filtering ///this is done during broadphase, so very early in the pipeline - ///more advanced collision filtering should be done in CollisionDispatcher::NeedsCollision + ///more advanced collision filtering should be done in btCollisionDispatcher::NeedsCollision enum CollisionFilterGroups { DefaultFilter = 1, @@ -57,7 +57,7 @@ struct CcdConstructionInfo }; - CcdConstructionInfo() + btCcdConstructionInfo() : m_gravity(0,0,0), m_scaling(1.f,1.f,1.f), m_mass(0.f), @@ -74,26 +74,26 @@ struct CcdConstructionInfo { } - SimdVector3 m_localInertiaTensor; - SimdVector3 m_gravity; - SimdVector3 m_scaling; - SimdScalar m_mass; - SimdScalar m_restitution; - SimdScalar m_friction; - SimdScalar m_linearDamping; - SimdScalar m_angularDamping; + btVector3 m_localInertiaTensor; + btVector3 m_gravity; + btVector3 m_scaling; + btScalar m_mass; + btScalar m_restitution; + btScalar m_friction; + btScalar m_linearDamping; + btScalar m_angularDamping; int m_collisionFlags; ///optional use of collision group/mask: ///only collision with object goups that match the collision mask. ///this is very basic early out. advanced collision filtering should be - ///done in the CollisionDispatcher::NeedsCollision and NeedsResponse + ///done in the btCollisionDispatcher::NeedsCollision and NeedsResponse ///both values default to 1 short int m_collisionFilterGroup; short int m_collisionFilterMask; - CollisionShape* m_collisionShape; + btCollisionShape* m_collisionShape; class PHY_IMotionState* m_MotionState; CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication @@ -101,19 +101,19 @@ struct CcdConstructionInfo }; -class RigidBody; +class btRigidBody; ///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution. class CcdPhysicsController : public PHY_IPhysicsController { - RigidBody* m_body; + btRigidBody* m_body; class PHY_IMotionState* m_MotionState; void* m_newClientInfo; - CcdConstructionInfo m_cci;//needed for replication - void GetWorldOrientation(SimdMatrix3x3& mat); + btCcdConstructionInfo m_cci;//needed for replication + void GetWorldOrientation(btMatrix3x3& mat); void CreateRigidbody(); @@ -122,14 +122,14 @@ class CcdPhysicsController : public PHY_IPhysicsController int m_collisionDelay; - CcdPhysicsController (const CcdConstructionInfo& ci); + CcdPhysicsController (const btCcdConstructionInfo& ci); virtual ~CcdPhysicsController(); - RigidBody* GetRigidBody() { return m_body;} + btRigidBody* GetRigidBody() { return m_body;} - CollisionShape* GetCollisionShape() { + btCollisionShape* GetCollisionShape() { return m_body->GetCollisionShape(); } //////////////////////////////////// @@ -206,9 +206,9 @@ class CcdPhysicsController : public PHY_IPhysicsController void UpdateDeactivation(float timeStep); - static SimdTransform GetTransformFromMotionState(PHY_IMotionState* motionState); + static btTransform GetTransformFromMotionState(PHY_IMotionState* motionState); - void SetAabb(const SimdVector3& aabbMin,const SimdVector3& aabbMax); + void SetAabb(const btVector3& aabbMin,const btVector3& aabbMax); class PHY_IMotionState* GetMotionState() @@ -227,7 +227,7 @@ class CcdPhysicsController : public PHY_IPhysicsController -///DefaultMotionState implements standard motionstate, using SimdTransform +///DefaultMotionState implements standard motionstate, using btTransform class DefaultMotionState : public PHY_IMotionState { @@ -245,8 +245,8 @@ class DefaultMotionState : public PHY_IMotionState virtual void calculateWorldTransformations(); - SimdTransform m_worldTransform; - SimdVector3 m_localScaling; + btTransform m_worldTransform; + btVector3 m_localScaling; }; diff --git a/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.cpp b/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.cpp index 7259c7f38..9fc70d8ca 100644 --- a/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.cpp +++ b/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.cpp @@ -20,7 +20,7 @@ subject to the following restrictions: #include "CcdPhysicsController.h" #include -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btTransform.h" #include "BulletDynamics/Dynamics/btRigidBody.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" #include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" @@ -39,10 +39,10 @@ subject to the following restrictions: //profiling/timings -#include "LinearMath/GenQuickprof.h" +#include "LinearMath/btQuickprof.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" #include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" @@ -67,10 +67,10 @@ bool useIslands = true; #include "BulletDynamics/Vehicle/btWheelInfo.h" #include "PHY_IVehicle.h" -RaycastVehicle::VehicleTuning gTuning; +btRaycastVehicle::btVehicleTuning gTuning; #endif //NEW_BULLET_VEHICLE_SUPPORT -#include "LinearMath/GenAabbUtil2.h" +#include "LinearMath/btAabbUtil2.h" #include "BulletDynamics/ConstraintSolver/btConstraintSolver.h" #include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h" @@ -96,18 +96,18 @@ void DrawRasterizerLine(const float* from,const float* to,int color); class WrapperVehicle : public PHY_IVehicle { - RaycastVehicle* m_vehicle; + btRaycastVehicle* m_vehicle; PHY_IPhysicsController* m_chassis; public: - WrapperVehicle(RaycastVehicle* vehicle,PHY_IPhysicsController* chassis) + WrapperVehicle(btRaycastVehicle* vehicle,PHY_IPhysicsController* chassis) :m_vehicle(vehicle), m_chassis(chassis) { } - RaycastVehicle* GetVehicle() + btRaycastVehicle* GetVehicle() { return m_vehicle; } @@ -127,12 +127,12 @@ public: bool hasSteering ) { - SimdVector3 connectionPointCS0(connectionPoint[0],connectionPoint[1],connectionPoint[2]); - SimdVector3 wheelDirectionCS0(downDirection[0],downDirection[1],downDirection[2]); - SimdVector3 wheelAxle(axleDirection[0],axleDirection[1],axleDirection[2]); + btVector3 connectionPointCS0(connectionPoint[0],connectionPoint[1],connectionPoint[2]); + btVector3 wheelDirectionCS0(downDirection[0],downDirection[1],downDirection[2]); + btVector3 wheelAxle(axleDirection[0],axleDirection[1],axleDirection[2]); - WheelInfo& info = m_vehicle->AddWheel(connectionPointCS0,wheelDirectionCS0,wheelAxle, + btWheelInfo& info = m_vehicle->AddWheel(connectionPointCS0,wheelDirectionCS0,wheelAxle, suspensionRestLength,wheelRadius,gTuning,hasSteering); info.m_clientInfo = motionState; @@ -144,12 +144,12 @@ public: int i; for (i=0;iGetWheelInfo(i); + btWheelInfo& info = m_vehicle->GetWheelInfo(i); PHY_IMotionState* motionState = (PHY_IMotionState*)info.m_clientInfo ; m_vehicle->UpdateWheelTransform(i); - SimdTransform trans = m_vehicle->GetWheelTransformWS(i); - SimdQuaternion orn = trans.getRotation(); - const SimdVector3& pos = trans.getOrigin(); + btTransform trans = m_vehicle->GetWheelTransformWS(i); + btQuaternion orn = trans.getRotation(); + const btVector3& pos = trans.getOrigin(); motionState->setWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]); motionState->setWorldPosition(pos.x(),pos.y(),pos.z()); @@ -163,16 +163,16 @@ public: virtual void GetWheelPosition(int wheelIndex,float& posX,float& posY,float& posZ) const { - SimdTransform trans = m_vehicle->GetWheelTransformWS(wheelIndex); + btTransform trans = m_vehicle->GetWheelTransformWS(wheelIndex); posX = trans.getOrigin().x(); posY = trans.getOrigin().y(); posZ = trans.getOrigin().z(); } virtual void GetWheelOrientationQuaternion(int wheelIndex,float& quatX,float& quatY,float& quatZ,float& quatW) const { - SimdTransform trans = m_vehicle->GetWheelTransformWS(wheelIndex); - SimdQuaternion quat = trans.getRotation(); - SimdMatrix3x3 orn2(quat); + btTransform trans = m_vehicle->GetWheelTransformWS(wheelIndex); + btQuaternion quat = trans.getRotation(); + btMatrix3x3 orn2(quat); quatX = trans.getRotation().x(); quatY = trans.getRotation().y(); @@ -191,7 +191,7 @@ public: if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) { - WheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); + btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); rotation = info.m_rotation; } return rotation; @@ -224,7 +224,7 @@ public: { if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) { - WheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); + btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); info.m_brake = braking; } } @@ -233,7 +233,7 @@ public: { if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) { - WheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); + btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); info.m_frictionSlip = friction; } @@ -243,7 +243,7 @@ public: { if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) { - WheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); + btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); info.m_suspensionStiffness = suspensionStiffness; } @@ -253,7 +253,7 @@ public: { if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) { - WheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); + btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); info.m_wheelsDampingRelaxation = suspensionDamping; } } @@ -262,7 +262,7 @@ public: { if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) { - WheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); + btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); info.m_wheelsDampingCompression = suspensionCompression; } } @@ -273,7 +273,7 @@ public: { if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) { - WheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); + btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); info.m_rollInfluence = rollInfluence; } } @@ -290,30 +290,30 @@ public: -static void DrawAabb(IDebugDraw* debugDrawer,const SimdVector3& from,const SimdVector3& to,const SimdVector3& color) +static void DrawAabb(btIDebugDraw* debugDrawer,const btVector3& from,const btVector3& to,const btVector3& color) { - SimdVector3 halfExtents = (to-from)* 0.5f; - SimdVector3 center = (to+from) *0.5f; + btVector3 halfExtents = (to-from)* 0.5f; + btVector3 center = (to+from) *0.5f; int i,j; - SimdVector3 edgecoord(1.f,1.f,1.f),pa,pb; + btVector3 edgecoord(1.f,1.f,1.f),pa,pb; for (i=0;i<4;i++) { for (j=0;j<3;j++) { - pa = SimdVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], + pa = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], edgecoord[2]*halfExtents[2]); pa+=center; int othercoord = j%3; edgecoord[othercoord]*=-1.f; - pb = SimdVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], + pb = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], edgecoord[2]*halfExtents[2]); pb+=center; debugDrawer->DrawLine(pa,pb,color); } - edgecoord = SimdVector3(-1.f,-1.f,-1.f); + edgecoord = btVector3(-1.f,-1.f,-1.f); if (i<3) edgecoord[i]*=-1.f; } @@ -326,7 +326,7 @@ static void DrawAabb(IDebugDraw* debugDrawer,const SimdVector3& from,const SimdV -CcdPhysicsEnvironment::CcdPhysicsEnvironment(Dispatcher* dispatcher,OverlappingPairCache* pairCache) +CcdPhysicsEnvironment::CcdPhysicsEnvironment(btDispatcher* dispatcher,btOverlappingPairCache* pairCache) : m_numIterations(10), m_numTimeSubSteps(1), m_ccdMode(0), @@ -341,37 +341,37 @@ m_scalingPropagated(false) m_triggerCallbacks[i] = 0; } if (!dispatcher) - dispatcher = new CollisionDispatcher(); + dispatcher = new btCollisionDispatcher(); if(!pairCache) { //todo: calculate/let user specify this world sizes - SimdVector3 worldMin(-10000,-10000,-10000); - SimdVector3 worldMax(10000,10000,10000); + btVector3 worldMin(-10000,-10000,-10000); + btVector3 worldMax(10000,10000,10000); - pairCache = new AxisSweep3(worldMin,worldMax); + pairCache = new btAxisSweep3(worldMin,worldMax); - //broadphase = new SimpleBroadphase(); + //broadphase = new btSimpleBroadphase(); } setSolverType(1);//issues with quickstep and memory allocations - m_collisionWorld = new CollisionWorld(dispatcher,pairCache); + m_collisionWorld = new btCollisionWorld(dispatcher,pairCache); m_debugDrawer = 0; - m_gravity = SimdVector3(0.f,-10.f,0.f); + m_gravity = btVector3(0.f,-10.f,0.f); - m_islandManager = new SimulationIslandManager(); + m_islandManager = new btSimulationIslandManager(); } void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) { - RigidBody* body = ctrl->GetRigidBody(); + btRigidBody* body = ctrl->GetRigidBody(); //this m_userPointer is just used for triggers, see CallbackTriggers body->m_internalOwner = ctrl; @@ -383,15 +383,15 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) assert(body->m_broadphaseHandle); - CollisionShape* shapeinterface = ctrl->GetCollisionShape(); + btCollisionShape* shapeinterface = ctrl->GetCollisionShape(); assert(shapeinterface); - const SimdTransform& t = ctrl->GetRigidBody()->getCenterOfMassTransform(); + const btTransform& t = ctrl->GetRigidBody()->getCenterOfMassTransform(); body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse(); - SimdPoint3 minAabb,maxAabb; + btPoint3 minAabb,maxAabb; shapeinterface->GetAabb(t,minAabb,maxAabb); @@ -400,7 +400,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) //extent it with the motion - SimdVector3 linMotion = body->getLinearVelocity()*timeStep; + btVector3 linMotion = body->getLinearVelocity()*timeStep; float maxAabbx = maxAabb.getX(); float maxAabby = maxAabb.getY(); @@ -423,8 +423,8 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) minAabbz += linMotion.z(); - minAabb = SimdVector3(minAabbx,minAabby,minAabbz); - maxAabb = SimdVector3(maxAabbx,maxAabby,maxAabbz); + minAabb = btVector3(minAabbx,minAabby,minAabbz); + maxAabb = btVector3(maxAabbx,maxAabby,maxAabbz); @@ -437,12 +437,12 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr //also remove constraint { - std::vector::iterator i; + std::vector::iterator i; for (i=m_constraints.begin(); !(i==m_constraints.end()); i++) { - TypedConstraint* constraint = (*i); + btTypedConstraint* constraint = (*i); if ((&constraint->GetRigidBodyA() == ctrl->GetRigidBody() || (&constraint->GetRigidBodyB() == ctrl->GetRigidBody()))) { @@ -454,12 +454,12 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr } { - std::vector::iterator i; + std::vector::iterator i; for (i=m_constraints.begin(); !(i==m_constraints.end()); i++) { - TypedConstraint* constraint = (*i); + btTypedConstraint* constraint = (*i); if ((&constraint->GetRigidBodyA() == ctrl->GetRigidBody() || (&constraint->GetRigidBodyB() == ctrl->GetRigidBody()))) { @@ -515,8 +515,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) #ifdef USE_QUICKPROF - //toggle Profiler - if ( m_debugDrawer && m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_ProfileTimings) + //toggle btProfiler + if ( m_debugDrawer && m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_ProfileTimings) { if (!m_profileTimings) { @@ -526,7 +526,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) char filename[128]; sprintf(filename,"quickprof_bullet_timings%i.csv",counter++); - Profiler::init(filename, Profiler::BLOCK_CYCLE_SECONDS);//BLOCK_TOTAL_MICROSECONDS + btProfiler::init(filename, btProfiler::BLOCK_CYCLE_SECONDS);//BLOCK_TOTAL_MICROSECONDS } } else @@ -534,14 +534,14 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) if (m_profileTimings) { m_profileTimings = 0; - Profiler::destroy(); + btProfiler::destroy(); } } #endif //USE_QUICKPROF - if (!SimdFuzzyZero(timeStep)) + if (!btFuzzyZero(timeStep)) { { @@ -553,8 +553,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) CcdPhysicsController* ctrl = *i; - SimdTransform predictedTrans; - RigidBody* body = ctrl->GetRigidBody(); + btTransform predictedTrans; + btRigidBody* body = ctrl->GetRigidBody(); if (body->GetActivationState() != ISLAND_SLEEPING) { @@ -602,17 +602,17 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) //printf("CcdPhysicsEnvironment::proceedDeltaTime\n"); - if (SimdFuzzyZero(timeStep)) + if (btFuzzyZero(timeStep)) return true; if (m_debugDrawer) { - gDisableDeactivation = (m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_NoDeactivation); + gDisableDeactivation = (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_NoDeactivation); } #ifdef USE_QUICKPROF - Profiler::beginBlock("SyncMotionStates"); + btProfiler::beginBlock("SyncMotionStates"); #endif //USE_QUICKPROF @@ -625,9 +625,9 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) #ifdef USE_QUICKPROF - Profiler::endBlock("SyncMotionStates"); + btProfiler::endBlock("SyncMotionStates"); - Profiler::beginBlock("predictIntegratedTransform"); + btProfiler::beginBlock("predictIntegratedTransform"); #endif //USE_QUICKPROF { @@ -639,8 +639,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) for (k=0;kGetRigidBody(); + // btTransform predictedTrans; + btRigidBody* body = ctrl->GetRigidBody(); body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse(); @@ -658,10 +658,10 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } #ifdef USE_QUICKPROF - Profiler::endBlock("predictIntegratedTransform"); + btProfiler::endBlock("predictIntegratedTransform"); #endif //USE_QUICKPROF - OverlappingPairCache* scene = m_collisionWorld->GetPairCache(); + btOverlappingPairCache* scene = m_collisionWorld->GetPairCache(); // @@ -670,14 +670,14 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) #ifdef USE_QUICKPROF - Profiler::beginBlock("DispatchAllCollisionPairs"); + btProfiler::beginBlock("DispatchAllCollisionPairs"); #endif //USE_QUICKPROF int numsubstep = m_numIterations; - DispatcherInfo dispatchInfo; + btDispatcherInfo dispatchInfo; dispatchInfo.m_timeStep = timeStep; dispatchInfo.m_stepCount = 0; dispatchInfo.m_enableSatConvex = m_enableSatCollisionDetection; @@ -689,7 +689,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) #ifdef USE_QUICKPROF - Profiler::endBlock("DispatchAllCollisionPairs"); + btProfiler::endBlock("DispatchAllCollisionPairs"); #endif //USE_QUICKPROF m_islandManager->UpdateActivationState(GetCollisionWorld(),GetCollisionWorld()->GetDispatcher()); @@ -699,10 +699,10 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) int numConstraints = m_constraints.size(); for (i=0;i< numConstraints ; i++ ) { - TypedConstraint* constraint = m_constraints[i]; + btTypedConstraint* constraint = m_constraints[i]; - const RigidBody* colObj0 = &constraint->GetRigidBodyA(); - const RigidBody* colObj1 = &constraint->GetRigidBodyB(); + const btRigidBody* colObj0 = &constraint->GetRigidBodyA(); + const btRigidBody* colObj1 = &constraint->GetRigidBodyB(); if (((colObj0) && ((colObj0)->mergesSimulationIslands())) && ((colObj1) && ((colObj1)->mergesSimulationIslands()))) @@ -722,7 +722,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) //contacts #ifdef USE_QUICKPROF - Profiler::beginBlock("SolveConstraint"); + btProfiler::beginBlock("SolveConstraint"); #endif //USE_QUICKPROF @@ -741,7 +741,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) //point to point constraints for (i=0;i< numConstraints ; i++ ) { - TypedConstraint* constraint = m_constraints[i]; + btTypedConstraint* constraint = m_constraints[i]; constraint->BuildJacobian(); constraint->SolveConstraint( timeStep ); @@ -752,7 +752,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } #ifdef USE_QUICKPROF - Profiler::endBlock("SolveConstraint"); + btProfiler::endBlock("SolveConstraint"); #endif //USE_QUICKPROF //solve the vehicles @@ -763,23 +763,23 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) for (int i=0;iGetVehicle(); + btRaycastVehicle* vehicle = wrapperVehicle->GetVehicle(); vehicle->UpdateVehicle( timeStep); } #endif //NEW_BULLET_VEHICLE_SUPPORT - struct InplaceSolverIslandCallback : public SimulationIslandManager::IslandCallback + struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCallback { - ContactSolverInfo& m_solverInfo; - ConstraintSolver* m_solver; - IDebugDraw* m_debugDrawer; + btContactSolverInfo& m_solverInfo; + btConstraintSolver* m_solver; + btIDebugDraw* m_debugDrawer; InplaceSolverIslandCallback( - ContactSolverInfo& solverInfo, - ConstraintSolver* solver, - IDebugDraw* debugDrawer) + btContactSolverInfo& solverInfo, + btConstraintSolver* solver, + btIDebugDraw* debugDrawer) :m_solverInfo(solverInfo), m_solver(solver), m_debugDrawer(debugDrawer) @@ -787,7 +787,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } - virtual void ProcessIsland(PersistentManifold** manifolds,int numManifolds) + virtual void ProcessIsland(btPersistentManifold** manifolds,int numManifolds) { m_solver->SolveGroup( manifolds, numManifolds,m_solverInfo,m_debugDrawer); } @@ -806,25 +806,25 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) m_debugDrawer); #ifdef USE_QUICKPROF - Profiler::beginBlock("BuildAndProcessIslands"); + btProfiler::beginBlock("BuildAndProcessIslands"); #endif //USE_QUICKPROF /// solve all the contact points and contact friction m_islandManager->BuildAndProcessIslands(GetCollisionWorld()->GetDispatcher(),m_collisionWorld->GetCollisionObjectArray(),&solverCallback); #ifdef USE_QUICKPROF - Profiler::endBlock("BuildAndProcessIslands"); + btProfiler::endBlock("BuildAndProcessIslands"); - Profiler::beginBlock("CallbackTriggers"); + btProfiler::beginBlock("CallbackTriggers"); #endif //USE_QUICKPROF CallbackTriggers(); #ifdef USE_QUICKPROF - Profiler::endBlock("CallbackTriggers"); + btProfiler::endBlock("CallbackTriggers"); - Profiler::beginBlock("proceedToTransform"); + btProfiler::beginBlock("proceedToTransform"); #endif //USE_QUICKPROF { @@ -844,10 +844,10 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) if (m_ccdMode == 3) { - DispatcherInfo dispatchInfo; + btDispatcherInfo dispatchInfo; dispatchInfo.m_timeStep = timeStep; dispatchInfo.m_stepCount = 0; - dispatchInfo.m_dispatchFunc = DispatcherInfo::DISPATCH_CONTINUOUS; + dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS; //pairCache->RefreshOverlappingPairs();//?? GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(scene,dispatchInfo); @@ -872,8 +872,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) CcdPhysicsController* ctrl = *i; - SimdTransform predictedTrans; - RigidBody* body = ctrl->GetRigidBody(); + btTransform predictedTrans; + btRigidBody* body = ctrl->GetRigidBody(); if (body->IsActive()) { @@ -910,7 +910,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) !(i==m_controllers.end()); i++) { CcdPhysicsController* ctrl = (*i); - RigidBody* body = ctrl->GetRigidBody(); + btRigidBody* body = ctrl->GetRigidBody(); ctrl->UpdateDeactivation(timeStep); @@ -947,17 +947,17 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) #ifdef USE_QUICKPROF - Profiler::endBlock("proceedToTransform"); + btProfiler::endBlock("proceedToTransform"); - Profiler::beginBlock("SyncMotionStates"); + btProfiler::beginBlock("SyncMotionStates"); #endif //USE_QUICKPROF SyncMotionStates(timeStep); #ifdef USE_QUICKPROF - Profiler::endBlock("SyncMotionStates"); + btProfiler::endBlock("SyncMotionStates"); - Profiler::endProfilingCycle(); + btProfiler::endProfilingCycle(); #endif //USE_QUICKPROF @@ -1047,7 +1047,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType) if (m_solverType != solverType) { - m_solver = new SequentialImpulseConstraintSolver(); + m_solver = new btSequentialImpulseConstraintSolver(); break; } @@ -1090,7 +1090,7 @@ void CcdPhysicsEnvironment::SyncMotionStates(float timeStep) } void CcdPhysicsEnvironment::setGravity(float x,float y,float z) { - m_gravity = SimdVector3(x,y,z); + m_gravity = btVector3(x,y,z); std::vector::iterator i; @@ -1108,7 +1108,7 @@ void CcdPhysicsEnvironment::setGravity(float x,float y,float z) #ifdef NEW_BULLET_VEHICLE_SUPPORT -class DefaultVehicleRaycaster : public VehicleRaycaster +class DefaultVehicleRaycaster : public btVehicleRaycaster { CcdPhysicsEnvironment* m_physEnv; PHY_IPhysicsController* m_chassis; @@ -1123,15 +1123,15 @@ public: virtual ~DefaultVehicleRaycaster() { } - /* struct VehicleRaycasterResult + /* struct btVehicleRaycasterResult { - VehicleRaycasterResult() :m_distFraction(-1.f){}; - SimdVector3 m_hitPointInWorld; - SimdVector3 m_hitNormalInWorld; - SimdScalar m_distFraction; + btVehicleRaycasterResult() :m_distFraction(-1.f){}; + btVector3 m_hitPointInWorld; + btVector3 m_hitNormalInWorld; + btScalar m_distFraction; }; */ - virtual void* CastRay(const SimdVector3& from,const SimdVector3& to, VehicleRaycasterResult& result) + virtual void* CastRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result) { @@ -1190,15 +1190,15 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl CcdPhysicsController* c0 = (CcdPhysicsController*)ctrl0; CcdPhysicsController* c1 = (CcdPhysicsController*)ctrl1; - RigidBody* rb0 = c0 ? c0->GetRigidBody() : 0; - RigidBody* rb1 = c1 ? c1->GetRigidBody() : 0; + btRigidBody* rb0 = c0 ? c0->GetRigidBody() : 0; + btRigidBody* rb1 = c1 ? c1->GetRigidBody() : 0; ASSERT(rb0); - SimdVector3 pivotInA(pivotX,pivotY,pivotZ); - SimdVector3 pivotInB = rb1 ? rb1->getCenterOfMassTransform().inverse()(rb0->getCenterOfMassTransform()(pivotInA)) : pivotInA; - SimdVector3 axisInA(axisX,axisY,axisZ); - SimdVector3 axisInB = rb1 ? + btVector3 pivotInA(pivotX,pivotY,pivotZ); + btVector3 pivotInB = rb1 ? rb1->getCenterOfMassTransform().inverse()(rb0->getCenterOfMassTransform()(pivotInA)) : pivotInA; + btVector3 axisInA(axisX,axisY,axisZ); + btVector3 axisInB = rb1 ? (rb1->getCenterOfMassTransform().getBasis().inverse()*(rb0->getCenterOfMassTransform().getBasis() * axisInA)) : rb0->getCenterOfMassTransform().getBasis() * axisInA; @@ -1209,15 +1209,15 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl case PHY_POINT2POINT_CONSTRAINT: { - Point2PointConstraint* p2p = 0; + btPoint2PointConstraint* p2p = 0; if (rb1) { - p2p = new Point2PointConstraint(*rb0, + p2p = new btPoint2PointConstraint(*rb0, *rb1,pivotInA,pivotInB); } else { - p2p = new Point2PointConstraint(*rb0, + p2p = new btPoint2PointConstraint(*rb0, pivotInA); } @@ -1232,22 +1232,22 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl case PHY_GENERIC_6DOF_CONSTRAINT: { - Generic6DofConstraint* genericConstraint = 0; + btGeneric6DofConstraint* genericConstraint = 0; if (rb1) { - SimdTransform frameInA; - SimdTransform frameInB; + btTransform frameInA; + btTransform frameInB; - SimdVector3 axis1, axis2; - SimdPlaneSpace1( axisInA, axis1, axis2 ); + btVector3 axis1, axis2; + btPlaneSpace1( axisInA, axis1, axis2 ); frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(), axisInA.y(), axis1.y(), axis2.y(), axisInA.z(), axis1.z(), axis2.z() ); - SimdPlaneSpace1( axisInB, axis1, axis2 ); + btPlaneSpace1( axisInB, axis1, axis2 ); frameInB.getBasis().setValue( axisInB.x(), axis1.x(), axis2.x(), axisInB.y(), axis1.y(), axis2.y(), axisInB.z(), axis1.z(), axis2.z() ); @@ -1255,7 +1255,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl frameInA.setOrigin( pivotInA ); frameInB.setOrigin( pivotInB ); - genericConstraint = new Generic6DofConstraint( + genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, frameInA,frameInB); @@ -1281,18 +1281,18 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl case PHY_LINEHINGE_CONSTRAINT: { - HingeConstraint* hinge = 0; + btHingeConstraint* hinge = 0; if (rb1) { - hinge = new HingeConstraint( + hinge = new btHingeConstraint( *rb0, *rb1,pivotInA,pivotInB,axisInA,axisInB); } else { - hinge = new HingeConstraint(*rb0, + hinge = new btHingeConstraint(*rb0, pivotInA,axisInA); } @@ -1309,10 +1309,10 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl case PHY_VEHICLE_CONSTRAINT: { - RaycastVehicle::VehicleTuning* tuning = new RaycastVehicle::VehicleTuning(); - RigidBody* chassis = rb0; + btRaycastVehicle::btVehicleTuning* tuning = new btRaycastVehicle::btVehicleTuning(); + btRigidBody* chassis = rb0; DefaultVehicleRaycaster* raycaster = new DefaultVehicleRaycaster(this,ctrl0); - RaycastVehicle* vehicle = new RaycastVehicle(*tuning,chassis,raycaster); + btRaycastVehicle* vehicle = new btRaycastVehicle(*tuning,chassis,raycaster); WrapperVehicle* wrapperVehicle = new WrapperVehicle(vehicle,ctrl0); m_wrapperVehicles.push_back(wrapperVehicle); vehicle->SetUserConstraintId(gConstraintUid++); @@ -1328,7 +1328,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl } }; - //RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB + //RigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB return 0; @@ -1340,30 +1340,30 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl //Following the COLLADA physics specification for constraints int CcdPhysicsEnvironment::createUniversalD6Constraint( class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther, - SimdTransform& frameInA, - SimdTransform& frameInB, - const SimdVector3& linearMinLimits, - const SimdVector3& linearMaxLimits, - const SimdVector3& angularMinLimits, - const SimdVector3& angularMaxLimits + btTransform& frameInA, + btTransform& frameInB, + const btVector3& linearMinLimits, + const btVector3& linearMaxLimits, + const btVector3& angularMinLimits, + const btVector3& angularMaxLimits ) { //we could either add some logic to recognize ball-socket and hinge, or let that up to the user //perhaps some warning or hint that hinge/ball-socket is more efficient? - Generic6DofConstraint* genericConstraint = 0; + btGeneric6DofConstraint* genericConstraint = 0; CcdPhysicsController* ctrl0 = (CcdPhysicsController*) ctrlRef; CcdPhysicsController* ctrl1 = (CcdPhysicsController*) ctrlOther; - RigidBody* rb0 = ctrl0->GetRigidBody(); - RigidBody* rb1 = ctrl1->GetRigidBody(); + btRigidBody* rb0 = ctrl0->GetRigidBody(); + btRigidBody* rb1 = ctrl1->GetRigidBody(); if (rb1) { - genericConstraint = new Generic6DofConstraint( + genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, frameInA,frameInB); genericConstraint->setLinearLowerLimit(linearMinLimits); @@ -1392,12 +1392,12 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint( void CcdPhysicsEnvironment::removeConstraint(int constraintId) { - std::vector::iterator i; + std::vector::iterator i; for (i=m_constraints.begin(); !(i==m_constraints.end()); i++) { - TypedConstraint* constraint = (*i); + btTypedConstraint* constraint = (*i); if (constraint->GetUserConstraintId() == constraintId) { std::swap(*i, m_constraints.back()); @@ -1409,12 +1409,12 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintId) } - struct FilterClosestRayResultCallback : public CollisionWorld::ClosestRayResultCallback + struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResultCallback { PHY_IPhysicsController* m_ignoreClient; - FilterClosestRayResultCallback (PHY_IPhysicsController* ignoreClient,const SimdVector3& rayFrom,const SimdVector3& rayTo) - : CollisionWorld::ClosestRayResultCallback(rayFrom,rayTo), + FilterClosestRayResultCallback (PHY_IPhysicsController* ignoreClient,const btVector3& rayFrom,const btVector3& rayTo) + : btCollisionWorld::ClosestRayResultCallback(rayFrom,rayTo), m_ignoreClient(ignoreClient) { @@ -1424,7 +1424,7 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintId) { } - virtual float AddSingleResult(const CollisionWorld::LocalRayResult& rayResult) + virtual float AddSingleResult(const btCollisionWorld::LocalRayResult& rayResult) { CcdPhysicsController* curHit = static_cast(rayResult.m_collisionObject->m_internalOwner); //ignore client... @@ -1441,10 +1441,10 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintId) PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ) { - SimdVector3 rayFrom(fromX,fromY,fromZ); - SimdVector3 rayTo(toX,toY,toZ); + btVector3 rayFrom(fromX,fromY,fromZ); + btVector3 rayTo(toX,toY,toZ); - SimdVector3 hitPointWorld,normalWorld; + btVector3 hitPointWorld,normalWorld; //Either Ray Cast with or without filtering @@ -1487,7 +1487,7 @@ void CcdPhysicsEnvironment::getContactPoint(int i,float& hitX,float& hitY,float& -BroadphaseInterface* CcdPhysicsEnvironment::GetBroadphase() +btBroadphaseInterface* CcdPhysicsEnvironment::GetBroadphase() { return m_collisionWorld->GetBroadphase(); } @@ -1530,13 +1530,13 @@ CcdPhysicsController* CcdPhysicsEnvironment::GetPhysicsController( int index) -TypedConstraint* CcdPhysicsEnvironment::getConstraintById(int constraintId) +btTypedConstraint* CcdPhysicsEnvironment::getConstraintById(int constraintId) { int numConstraint = m_constraints.size(); int i; for (i=0;iGetUserConstraintId()==constraintId) { return constraint; @@ -1621,28 +1621,28 @@ void CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctr void CcdPhysicsEnvironment::CallbackTriggers() { - if (m_triggerCallbacks[PHY_OBJECT_RESPONSE] || (m_debugDrawer && (m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_DrawContactPoints))) + if (m_triggerCallbacks[PHY_OBJECT_RESPONSE] || (m_debugDrawer && (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_DrawContactPoints))) { //walk over all overlapping pairs, and if one of the involved bodies is registered for trigger callback, perform callback int numManifolds = m_collisionWorld->GetDispatcher()->GetNumManifolds(); for (int i=0;iGetDispatcher()->GetManifoldByIndexInternal(i); + btPersistentManifold* manifold = m_collisionWorld->GetDispatcher()->GetManifoldByIndexInternal(i); int numContacts = manifold->GetNumContacts(); if (numContacts) { - if (m_debugDrawer && (m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_DrawContactPoints)) + if (m_debugDrawer && (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_DrawContactPoints)) { for (int j=0;jGetContactPoint(j); + btVector3 color(1,0,0); + const btManifoldPoint& cp = manifold->GetContactPoint(j); if (m_debugDrawer) m_debugDrawer->DrawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.GetDistance(),cp.GetLifeTime(),color); } } - RigidBody* obj0 = static_cast(manifold->GetBody0()); - RigidBody* obj1 = static_cast(manifold->GetBody1()); + btRigidBody* obj0 = static_cast(manifold->GetBody0()); + btRigidBody* obj1 = static_cast(manifold->GetBody1()); //m_internalOwner is set in 'addPhysicsController' CcdPhysicsController* ctrl0 = static_cast(obj0->m_internalOwner); @@ -1703,7 +1703,7 @@ int numController = 0; void CcdPhysicsEnvironment::UpdateAabbs(float timeStep) { std::vector::iterator i; - BroadphaseInterface* scene = GetBroadphase(); + btBroadphaseInterface* scene = GetBroadphase(); numController = m_controllers.size(); currentController = 0; @@ -1716,30 +1716,30 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep) { currentController++; CcdPhysicsController* ctrl = (*i); - RigidBody* body = ctrl->GetRigidBody(); + btRigidBody* body = ctrl->GetRigidBody(); - SimdPoint3 minAabb,maxAabb; - CollisionShape* shapeinterface = ctrl->GetCollisionShape(); + btPoint3 minAabb,maxAabb; + btCollisionShape* shapeinterface = ctrl->GetCollisionShape(); shapeinterface->CalculateTemporalAabb(body->getCenterOfMassTransform(), body->getLinearVelocity(), //body->getAngularVelocity(), - SimdVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(), + btVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(), timeStep,minAabb,maxAabb); - SimdVector3 manifoldExtraExtents(gContactBreakingTreshold,gContactBreakingTreshold,gContactBreakingTreshold); + btVector3 manifoldExtraExtents(gContactBreakingTreshold,gContactBreakingTreshold,gContactBreakingTreshold); minAabb -= manifoldExtraExtents; maxAabb += manifoldExtraExtents; - BroadphaseProxy* bp = body->m_broadphaseHandle; + btBroadphaseProxy* bp = body->m_broadphaseHandle; if (bp) { - SimdVector3 color (1,1,0); + btVector3 color (1,1,0); if (m_debugDrawer) { @@ -1767,7 +1767,7 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep) }; - if (m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_DrawAabb) + if (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_DrawAabb) { DrawAabb(m_debugDrawer,minAabb,maxAabb,color); } @@ -1802,15 +1802,15 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep) PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radius,const PHY__Vector3& position) { - CcdConstructionInfo cinfo; - cinfo.m_collisionShape = new SphereShape(radius); + btCcdConstructionInfo cinfo; + cinfo.m_collisionShape = new btSphereShape(radius); cinfo.m_MotionState = 0; cinfo.m_physicsEnv = this; - cinfo.m_collisionFlags |= CollisionObject::noContactResponse; + cinfo.m_collisionFlags |= btCollisionObject::noContactResponse; DefaultMotionState* motionState = new DefaultMotionState(); cinfo.m_MotionState = motionState; motionState->m_worldTransform.setIdentity(); - motionState->m_worldTransform.setOrigin(SimdVector3(position[0],position[1],position[2])); + motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2])); CcdPhysicsController* sphereController = new CcdPhysicsController(cinfo); @@ -1821,14 +1821,14 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radi PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float coneradius,float coneheight) { - CcdConstructionInfo cinfo; - cinfo.m_collisionShape = new ConeShape(coneradius,coneheight); + btCcdConstructionInfo cinfo; + cinfo.m_collisionShape = new btConeShape(coneradius,coneheight); cinfo.m_MotionState = 0; cinfo.m_physicsEnv = this; DefaultMotionState* motionState = new DefaultMotionState(); cinfo.m_MotionState = motionState; motionState->m_worldTransform.setIdentity(); -// motionState->m_worldTransform.setOrigin(SimdVector3(position[0],position[1],position[2])); +// motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2])); CcdPhysicsController* sphereController = new CcdPhysicsController(cinfo); @@ -1838,12 +1838,12 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float conera float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid) { - std::vector::iterator i; + std::vector::iterator i; for (i=m_constraints.begin(); !(i==m_constraints.end()); i++) { - TypedConstraint* constraint = (*i); + btTypedConstraint* constraint = (*i); if (constraint->GetUserConstraintId() == constraintid) { return constraint->GetAppliedImpulse(); diff --git a/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.h b/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.h index bab856c43..740c6d1e4 100644 --- a/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.h +++ b/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.h @@ -19,16 +19,16 @@ subject to the following restrictions: #include "PHY_IPhysicsEnvironment.h" #include class CcdPhysicsController; -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btTransform.h" -class TypedConstraint; -class SimulationIslandManager; -class CollisionDispatcher; -class Dispatcher; +class btTypedConstraint; +class btSimulationIslandManager; +class btCollisionDispatcher; +class btDispatcher; //#include "btBroadphaseInterface.h" //switch on/off new vehicle support @@ -37,10 +37,10 @@ class Dispatcher; #include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" class WrapperVehicle; -class PersistentManifold; -class BroadphaseInterface; -class OverlappingPairCache; -class IDebugDraw; +class btPersistentManifold; +class btBroadphaseInterface; +class btOverlappingPairCache; +class btIDebugDraw; class PHY_IVehicle; /// CcdPhysicsEnvironment is an experimental mainloop for physics simulation using optional continuous collision detection. @@ -49,12 +49,12 @@ class PHY_IVehicle; /// A derived class may be able to 'construct' entities by loading and/or converting class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment { - SimdVector3 m_gravity; + btVector3 m_gravity; protected: - IDebugDraw* m_debugDrawer; + btIDebugDraw* m_debugDrawer; //solver iterations int m_numIterations; @@ -67,12 +67,12 @@ protected: int m_profileTimings; bool m_enableSatCollisionDetection; - ContactSolverInfo m_solverInfo; + btContactSolverInfo m_solverInfo; - SimulationIslandManager* m_islandManager; + btSimulationIslandManager* m_islandManager; public: - CcdPhysicsEnvironment(Dispatcher* dispatcher=0, OverlappingPairCache* pairCache=0); + CcdPhysicsEnvironment(btDispatcher* dispatcher=0, btOverlappingPairCache* pairCache=0); virtual ~CcdPhysicsEnvironment(); @@ -82,7 +82,7 @@ protected: /// Perform an integration step of duration 'timeStep'. - virtual void setDebugDrawer(IDebugDraw* debugDrawer) + virtual void setDebugDrawer(btIDebugDraw* debugDrawer) { m_debugDrawer = debugDrawer; } @@ -127,12 +127,12 @@ protected: //Following the COLLADA physics specification for constraints virtual int createUniversalD6Constraint( class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther, - SimdTransform& localAttachmentFrameRef, - SimdTransform& localAttachmentOther, - const SimdVector3& linearMinLimits, - const SimdVector3& linearMaxLimits, - const SimdVector3& angularMinLimits, - const SimdVector3& angularMaxLimits + btTransform& localAttachmentFrameRef, + btTransform& localAttachmentOther, + const btVector3& linearMinLimits, + const btVector3& linearMaxLimits, + const btVector3& angularMinLimits, + const btVector3& angularMaxLimits ); @@ -154,7 +154,7 @@ protected: } #endif //NEW_BULLET_VEHICLE_SUPPORT - TypedConstraint* getConstraintById(int constraintId); + btTypedConstraint* getConstraintById(int constraintId); virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ); @@ -183,7 +183,7 @@ protected: void removeCcdPhysicsController(CcdPhysicsController* ctrl); - BroadphaseInterface* GetBroadphase(); + btBroadphaseInterface* GetBroadphase(); @@ -207,34 +207,34 @@ protected: - const PersistentManifold* GetManifold(int index) const; + const btPersistentManifold* GetManifold(int index) const; - std::vector m_constraints; + std::vector m_constraints; void SyncMotionStates(float timeStep); - class CollisionWorld* GetCollisionWorld() + class btCollisionWorld* GetCollisionWorld() { return m_collisionWorld; } - const class CollisionWorld* GetCollisionWorld() const + const class btCollisionWorld* GetCollisionWorld() const { return m_collisionWorld; } - SimulationIslandManager* GetSimulationIslandManager() + btSimulationIslandManager* GetSimulationIslandManager() { return m_islandManager; } - const SimulationIslandManager* GetSimulationIslandManager() const + const btSimulationIslandManager* GetSimulationIslandManager() const { return m_islandManager; } - class ConstraintSolver* GetConstraintSolver() + class btConstraintSolver* GetConstraintSolver() { return m_solver; } @@ -253,9 +253,9 @@ protected: std::vector m_wrapperVehicles; - class CollisionWorld* m_collisionWorld; + class btCollisionWorld* m_collisionWorld; - class ConstraintSolver* m_solver; + class btConstraintSolver* m_solver; bool m_scalingPropagated; diff --git a/Extras/PhysicsInterface/CcdPhysics/ParallelIslandDispatcher.cpp b/Extras/PhysicsInterface/CcdPhysics/ParallelIslandDispatcher.cpp index 1d31cf3db..bb1a24542 100644 --- a/Extras/PhysicsInterface/CcdPhysics/ParallelIslandDispatcher.cpp +++ b/Extras/PhysicsInterface/CcdPhysics/ParallelIslandDispatcher.cpp @@ -51,29 +51,29 @@ ParallelIslandDispatcher::ParallelIslandDispatcher (): }; -PersistentManifold* ParallelIslandDispatcher::GetNewManifold(void* b0,void* b1) +btPersistentManifold* ParallelIslandDispatcher::GetNewManifold(void* b0,void* b1) { gNumManifold2++; //ASSERT(gNumManifold < 65535); - CollisionObject* body0 = (CollisionObject*)b0; - CollisionObject* body1 = (CollisionObject*)b1; + btCollisionObject* body0 = (btCollisionObject*)b0; + btCollisionObject* body1 = (btCollisionObject*)b1; - PersistentManifold* manifold = new PersistentManifold (body0,body1); + btPersistentManifold* manifold = new btPersistentManifold (body0,body1); m_manifoldsPtr.push_back(manifold); return manifold; } -void ParallelIslandDispatcher::ClearManifold(PersistentManifold* manifold) +void ParallelIslandDispatcher::ClearManifold(btPersistentManifold* manifold) { manifold->ClearManifold(); } -void ParallelIslandDispatcher::ReleaseManifold(PersistentManifold* manifold) +void ParallelIslandDispatcher::ReleaseManifold(btPersistentManifold* manifold) { gNumManifold2--; @@ -82,7 +82,7 @@ void ParallelIslandDispatcher::ReleaseManifold(PersistentManifold* manifold) ClearManifold(manifold); - std::vector::iterator i = + std::vector::iterator i = std::find(m_manifoldsPtr.begin(), m_manifoldsPtr.end(), manifold); if (!(i == m_manifoldsPtr.end())) { @@ -99,14 +99,14 @@ void ParallelIslandDispatcher::ReleaseManifold(PersistentManifold* manifold) // // todo: this is random access, it can be walked 'cache friendly'! // -void ParallelIslandDispatcher::BuildAndProcessIslands(CollisionObjectArray& collisionObjects, IslandCallback* callback) +void ParallelIslandDispatcher::BuildAndProcessIslands(btCollisionObjectArray& collisionObjects, IslandCallback* callback) { int numBodies = collisionObjects.size(); for (int islandId=0;islandId islandmanifold; + std::vector islandmanifold; //int numSleeping = 0; @@ -115,7 +115,7 @@ void ParallelIslandDispatcher::BuildAndProcessIslands(CollisionObjectArray& coll int i; for (i=0;im_islandTag1 == islandId) { if (colObj0->GetActivationState()== ACTIVE_TAG) @@ -132,12 +132,12 @@ void ParallelIslandDispatcher::BuildAndProcessIslands(CollisionObjectArray& coll for (i=0;iGetManifoldByIndexInternal(i); + btPersistentManifold* manifold = this->GetManifoldByIndexInternal(i); //filtering for response - CollisionObject* colObj0 = static_cast(manifold->GetBody0()); - CollisionObject* colObj1 = static_cast(manifold->GetBody1()); + btCollisionObject* colObj0 = static_cast(manifold->GetBody0()); + btCollisionObject* colObj1 = static_cast(manifold->GetBody1()); { if (((colObj0) && (colObj0)->m_islandTag1 == (islandId)) || ((colObj1) && (colObj1)->m_islandTag1 == (islandId))) @@ -153,7 +153,7 @@ void ParallelIslandDispatcher::BuildAndProcessIslands(CollisionObjectArray& coll int i; for (i=0;im_islandTag1 == islandId) { colObj0->SetActivationState( ISLAND_SLEEPING ); @@ -167,7 +167,7 @@ void ParallelIslandDispatcher::BuildAndProcessIslands(CollisionObjectArray& coll int i; for (i=0;im_islandTag1 == islandId) { if ( colObj0->GetActivationState() == ISLAND_SLEEPING) @@ -189,73 +189,73 @@ void ParallelIslandDispatcher::BuildAndProcessIslands(CollisionObjectArray& coll -CollisionAlgorithm* ParallelIslandDispatcher::InternalFindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) +btCollisionAlgorithm* ParallelIslandDispatcher::InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) { m_count++; - CollisionObject* body0 = (CollisionObject*)proxy0.m_clientObject; - CollisionObject* body1 = (CollisionObject*)proxy1.m_clientObject; + btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject; + btCollisionObject* body1 = (btCollisionObject*)proxy1.m_clientObject; - CollisionAlgorithmConstructionInfo ci; + btCollisionAlgorithmConstructionInfo ci; ci.m_dispatcher = this; if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConvex() ) { - return new ConvexConvexAlgorithm(0,ci,&proxy0,&proxy1); + return new btConvexConvexAlgorithm(0,ci,&proxy0,&proxy1); } if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConcave()) { - return new ConvexConcaveCollisionAlgorithm(ci,&proxy0,&proxy1); + return new btConvexConcaveCollisionAlgorithm(ci,&proxy0,&proxy1); } if (body1->m_collisionShape->IsConvex() && body0->m_collisionShape->IsConcave()) { - return new ConvexConcaveCollisionAlgorithm(ci,&proxy1,&proxy0); + return new btConvexConcaveCollisionAlgorithm(ci,&proxy1,&proxy0); } if (body0->m_collisionShape->IsCompound()) { - return new CompoundCollisionAlgorithm(ci,&proxy0,&proxy1); + return new btCompoundCollisionAlgorithm(ci,&proxy0,&proxy1); } else { if (body1->m_collisionShape->IsCompound()) { - return new CompoundCollisionAlgorithm(ci,&proxy1,&proxy0); + return new btCompoundCollisionAlgorithm(ci,&proxy1,&proxy0); } } //failed to find an algorithm - return new EmptyAlgorithm(ci); + return new btEmptyAlgorithm(ci); } -bool ParallelIslandDispatcher::NeedsResponse(const CollisionObject& colObj0,const CollisionObject& colObj1) +bool ParallelIslandDispatcher::NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1) { //here you can do filtering bool hasResponse = - (!(colObj0.m_collisionFlags & CollisionObject::noContactResponse)) && - (!(colObj1.m_collisionFlags & CollisionObject::noContactResponse)); + (!(colObj0.m_collisionFlags & btCollisionObject::noContactResponse)) && + (!(colObj1.m_collisionFlags & btCollisionObject::noContactResponse)); hasResponse = hasResponse && (colObj0.IsActive() || colObj1.IsActive()); return hasResponse; } -bool ParallelIslandDispatcher::NeedsCollision(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) +bool ParallelIslandDispatcher::NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) { - CollisionObject* body0 = (CollisionObject*)proxy0.m_clientObject; - CollisionObject* body1 = (CollisionObject*)proxy1.m_clientObject; + btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject; + btCollisionObject* body1 = (btCollisionObject*)proxy1.m_clientObject; assert(body0); assert(body1); bool needsCollision = true; - if ((body0->m_collisionFlags & CollisionObject::isStatic) && - (body1->m_collisionFlags & CollisionObject::isStatic)) + if ((body0->m_collisionFlags & btCollisionObject::isStatic) && + (body1->m_collisionFlags & btCollisionObject::isStatic)) needsCollision = false; if ((!body0->IsActive()) && (!body1->IsActive())) @@ -266,23 +266,23 @@ bool ParallelIslandDispatcher::NeedsCollision(BroadphaseProxy& proxy0,Broadphase } ///allows the user to get contact point callbacks -ManifoldResult* ParallelIslandDispatcher::GetNewManifoldResult(CollisionObject* obj0,CollisionObject* obj1,PersistentManifold* manifold) +btManifoldResult* ParallelIslandDispatcher::GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold) { //in-place, this prevents parallel dispatching, but just adding a list would fix that. - ManifoldResult* manifoldResult = new (&m_defaultManifoldResult) ManifoldResult(obj0,obj1,manifold); + btManifoldResult* manifoldResult = new (&m_defaultManifoldResult) btManifoldResult(obj0,obj1,manifold); return manifoldResult; } ///allows the user to get contact point callbacks -void ParallelIslandDispatcher::ReleaseManifoldResult(ManifoldResult*) +void ParallelIslandDispatcher::ReleaseManifoldResult(btManifoldResult*) { } -void ParallelIslandDispatcher::DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo) +void ParallelIslandDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo) { //m_blockedForChanges = true; @@ -296,7 +296,7 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(OverlappingPairCache* p for (i=0;i= 0) { @@ -310,7 +310,7 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(OverlappingPairCache* p if (pair.m_algorithms[dispatcherId]) { - if (dispatchInfo.m_dispatchFunc == DispatcherInfo::DISPATCH_DISCRETE) + if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) { pair.m_algorithms[dispatcherId]->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo); } else @@ -324,13 +324,13 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(OverlappingPairCache* p } else { //non-persistent algorithm dispatcher - CollisionAlgorithm* algo = FindAlgorithm( + btCollisionAlgorithm* algo = FindAlgorithm( *pair.m_pProxy0, *pair.m_pProxy1); if (algo) { - if (dispatchInfo.m_dispatchFunc == DispatcherInfo::DISPATCH_DISCRETE) + if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) { algo->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo); } else diff --git a/Extras/PhysicsInterface/CcdPhysics/ParallelIslandDispatcher.h b/Extras/PhysicsInterface/CcdPhysics/ParallelIslandDispatcher.h index 123e79a53..36f888438 100644 --- a/Extras/PhysicsInterface/CcdPhysics/ParallelIslandDispatcher.h +++ b/Extras/PhysicsInterface/CcdPhysics/ParallelIslandDispatcher.h @@ -24,7 +24,7 @@ subject to the following restrictions: #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" #include -class IDebugDraw; +class btIDebugDraw; #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" @@ -35,28 +35,28 @@ class IDebugDraw; ///ParallelIslandDispatcher dispatches entire simulation islands in parallel. ///For both collision detection and constraint solving. ///This development heads toward multi-core, CELL SPU and GPU approach -class ParallelIslandDispatcher : public Dispatcher +class ParallelIslandDispatcher : public btDispatcher { - std::vector m_manifoldsPtr; + std::vector m_manifoldsPtr; - UnionFind m_unionFind; + btUnionFind m_unionFind; bool m_useIslands; - ManifoldResult m_defaultManifoldResult; + btManifoldResult m_defaultManifoldResult; - CollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; + btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; public: - UnionFind& GetUnionFind() { return m_unionFind;} + btUnionFind& GetUnionFind() { return m_unionFind;} struct IslandCallback { virtual ~IslandCallback() {}; - virtual void ProcessIsland(PersistentManifold** manifolds,int numManifolds) = 0; + virtual void ProcessIsland(btPersistentManifold** manifolds,int numManifolds) = 0; }; @@ -65,12 +65,12 @@ public: return m_manifoldsPtr.size(); } - PersistentManifold* GetManifoldByIndexInternal(int index) + btPersistentManifold* GetManifoldByIndexInternal(int index) { return m_manifoldsPtr[index]; } - const PersistentManifold* GetManifoldByIndexInternal(int index) const + const btPersistentManifold* GetManifoldByIndexInternal(int index) const { return m_manifoldsPtr[index]; } @@ -88,37 +88,37 @@ public: ParallelIslandDispatcher (); virtual ~ParallelIslandDispatcher() {}; - virtual PersistentManifold* GetNewManifold(void* b0,void* b1); + virtual btPersistentManifold* GetNewManifold(void* b0,void* b1); - virtual void ReleaseManifold(PersistentManifold* manifold); + virtual void ReleaseManifold(btPersistentManifold* manifold); - virtual void BuildAndProcessIslands(CollisionObjectArray& collisionObjects, IslandCallback* callback); + virtual void BuildAndProcessIslands(btCollisionObjectArray& collisionObjects, IslandCallback* callback); ///allows the user to get contact point callbacks - virtual ManifoldResult* GetNewManifoldResult(CollisionObject* obj0,CollisionObject* obj1,PersistentManifold* manifold); + virtual btManifoldResult* GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold); ///allows the user to get contact point callbacks - virtual void ReleaseManifoldResult(ManifoldResult*); + virtual void ReleaseManifoldResult(btManifoldResult*); - virtual void ClearManifold(PersistentManifold* manifold); + virtual void ClearManifold(btPersistentManifold* manifold); - CollisionAlgorithm* FindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) + btCollisionAlgorithm* FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) { - CollisionAlgorithm* algo = InternalFindAlgorithm(proxy0,proxy1); + btCollisionAlgorithm* algo = InternalFindAlgorithm(proxy0,proxy1); return algo; } - CollisionAlgorithm* InternalFindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1); + btCollisionAlgorithm* InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); - virtual bool NeedsCollision(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1); + virtual bool NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); - virtual bool NeedsResponse(const CollisionObject& colObj0,const CollisionObject& colObj1); + virtual bool NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1); virtual int GetUniqueId() { return RIGIDBODY_DISPATCHER;} - virtual void DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo); + virtual void DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo); diff --git a/Extras/PhysicsInterface/CcdPhysics/ParallelPhysicsEnvironment.cpp b/Extras/PhysicsInterface/CcdPhysics/ParallelPhysicsEnvironment.cpp index d974f67e2..67748a266 100644 --- a/Extras/PhysicsInterface/CcdPhysics/ParallelPhysicsEnvironment.cpp +++ b/Extras/PhysicsInterface/CcdPhysics/ParallelPhysicsEnvironment.cpp @@ -24,7 +24,7 @@ subject to the following restrictions: #include "SimulationIsland.h" -ParallelPhysicsEnvironment::ParallelPhysicsEnvironment(ParallelIslandDispatcher* dispatcher, OverlappingPairCache* pairCache): +ParallelPhysicsEnvironment::ParallelPhysicsEnvironment(ParallelIslandDispatcher* dispatcher, btOverlappingPairCache* pairCache): CcdPhysicsEnvironment(dispatcher,pairCache) { @@ -41,14 +41,14 @@ ParallelPhysicsEnvironment::~ParallelPhysicsEnvironment() bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) { // Make sure the broadphase / overlapping AABB paircache is up-to-date - OverlappingPairCache* scene = m_collisionWorld->GetPairCache(); + btOverlappingPairCache* scene = m_collisionWorld->GetPairCache(); scene->RefreshOverlappingPairs(); // Find the connected sets that can be simulated in parallel // Using union find #ifdef USE_QUICKPROF - Profiler::beginBlock("IslandUnionFind"); + btProfiler::beginBlock("IslandUnionFind"); #endif //USE_QUICKPROF GetSimulationIslandManager()->UpdateActivationState(GetCollisionWorld(),GetCollisionWorld()->GetDispatcher()); @@ -58,10 +58,10 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) int numConstraints = m_constraints.size(); for (i=0;i< numConstraints ; i++ ) { - TypedConstraint* constraint = m_constraints[i]; + btTypedConstraint* constraint = m_constraints[i]; - const RigidBody* colObj0 = &constraint->GetRigidBodyA(); - const RigidBody* colObj1 = &constraint->GetRigidBodyB(); + const btRigidBody* colObj0 = &constraint->GetRigidBodyA(); + const btRigidBody* colObj1 = &constraint->GetRigidBodyB(); if (((colObj0) && ((colObj0)->mergesSimulationIslands())) && ((colObj1) && ((colObj1)->mergesSimulationIslands()))) @@ -80,7 +80,7 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) GetSimulationIslandManager()->StoreIslandActivationState(GetCollisionWorld()); #ifdef USE_QUICKPROF - Profiler::endBlock("IslandUnionFind"); + btProfiler::endBlock("IslandUnionFind"); #endif //USE_QUICKPROF @@ -88,7 +88,7 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) ///build simulation islands #ifdef USE_QUICKPROF - Profiler::beginBlock("BuildIslands"); + btProfiler::beginBlock("BuildIslands"); #endif //USE_QUICKPROF std::vector simulationIslands; @@ -105,7 +105,7 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } } - Dispatcher* dispatcher = GetCollisionWorld()->GetDispatcher(); + btDispatcher* dispatcher = GetCollisionWorld()->GetDispatcher(); //this is a brute force approach, will rethink later about more subtle ways @@ -117,10 +117,10 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) { - BroadphasePair* pair = &scene->GetOverlappingPair(i); + btBroadphasePair* pair = &scene->GetOverlappingPair(i); - CollisionObject* col0 = static_cast(pair->m_pProxy0->m_clientObject); - CollisionObject* col1 = static_cast(pair->m_pProxy1->m_clientObject); + btCollisionObject* col0 = static_cast(pair->m_pProxy0->m_clientObject); + btCollisionObject* col1 = static_cast(pair->m_pProxy1->m_clientObject); if (col0->m_islandTag1 > col1->m_islandTag1) { @@ -136,7 +136,7 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) //store constraint indices for each island for (unsigned int ui=0;ui constraint.GetRigidBodyB().m_islandTag1) { simulationIslands[constraint.GetRigidBodyA().m_islandTag1].m_constraintIndices.push_back(ui); @@ -151,12 +151,12 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) for (i=0;iGetNumManifolds();i++) { - PersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i); + btPersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i); //filtering for response - CollisionObject* colObj0 = static_cast(manifold->GetBody0()); - CollisionObject* colObj1 = static_cast(manifold->GetBody1()); + btCollisionObject* colObj0 = static_cast(manifold->GetBody0()); + btCollisionObject* colObj1 = static_cast(manifold->GetBody1()); { int islandTag = colObj0->m_islandTag1; if (colObj1->m_islandTag1 > islandTag) @@ -169,15 +169,15 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } #ifdef USE_QUICKPROF - Profiler::endBlock("BuildIslands"); + btProfiler::endBlock("BuildIslands"); #endif //USE_QUICKPROF #ifdef USE_QUICKPROF - Profiler::beginBlock("SimulateIsland"); + btProfiler::beginBlock("SimulateIsland"); #endif //USE_QUICKPROF - TypedConstraint** constraintBase = 0; + btTypedConstraint** constraintBase = 0; if (m_constraints.size()) constraintBase = &m_constraints[0]; @@ -198,7 +198,7 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) #ifdef USE_QUICKPROF - Profiler::endBlock("SimulateIsland"); + btProfiler::endBlock("SimulateIsland"); #endif //USE_QUICKPROF return true; diff --git a/Extras/PhysicsInterface/CcdPhysics/ParallelPhysicsEnvironment.h b/Extras/PhysicsInterface/CcdPhysics/ParallelPhysicsEnvironment.h index 4c433bf52..666e5ee7d 100644 --- a/Extras/PhysicsInterface/CcdPhysics/ParallelPhysicsEnvironment.h +++ b/Extras/PhysicsInterface/CcdPhysics/ParallelPhysicsEnvironment.h @@ -29,7 +29,7 @@ class ParallelPhysicsEnvironment : public CcdPhysicsEnvironment public: - ParallelPhysicsEnvironment(ParallelIslandDispatcher* dispatcher=0, OverlappingPairCache* pairCache=0); + ParallelPhysicsEnvironment(ParallelIslandDispatcher* dispatcher=0, btOverlappingPairCache* pairCache=0); virtual ~ParallelPhysicsEnvironment(); diff --git a/Extras/PhysicsInterface/CcdPhysics/SimulationIsland.cpp b/Extras/PhysicsInterface/CcdPhysics/SimulationIsland.cpp index 83bfb7bab..420470bbf 100644 --- a/Extras/PhysicsInterface/CcdPhysics/SimulationIsland.cpp +++ b/Extras/PhysicsInterface/CcdPhysics/SimulationIsland.cpp @@ -14,7 +14,7 @@ subject to the following restrictions: */ #include "SimulationIsland.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btTransform.h" #include "CcdPhysicsController.h" #include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" #include "BulletCollision/CollisionShapes/btCollisionShape.h" @@ -22,17 +22,17 @@ subject to the following restrictions: #include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" #include "BulletDynamics/ConstraintSolver/btConstraintSolver.h" #include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" extern float gContactBreakingTreshold; -bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations,TypedConstraint** constraintsBaseAddress,BroadphasePair* overlappingPairBaseAddress, Dispatcher* dispatcher,BroadphaseInterface* broadphase,class ConstraintSolver* solver,float timeStep) +bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIterations,btTypedConstraint** constraintsBaseAddress,btBroadphasePair* overlappingPairBaseAddress, btDispatcher* dispatcher,btBroadphaseInterface* broadphase,class btConstraintSolver* solver,float timeStep) { #ifdef USE_QUICKPROF - Profiler::beginBlock("predictIntegratedTransform"); + btProfiler::beginBlock("predictIntegratedTransform"); #endif //USE_QUICKPROF { @@ -44,8 +44,8 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, for (k=0;kGetRigidBody(); + // btTransform predictedTrans; + btRigidBody* body = ctrl->GetRigidBody(); //todo: only do this when necessary, it's used for contact points body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse(); @@ -63,7 +63,7 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, } #ifdef USE_QUICKPROF - Profiler::endBlock("predictIntegratedTransform"); + btProfiler::endBlock("predictIntegratedTransform"); #endif //USE_QUICKPROF //BroadphaseInterface* scene = GetBroadphase(); @@ -75,20 +75,20 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, #ifdef USE_QUICKPROF - Profiler::beginBlock("DispatchAllCollisionPairs"); + btProfiler::beginBlock("DispatchAllCollisionPairs"); #endif //USE_QUICKPROF // int numsubstep = m_numIterations; - DispatcherInfo dispatchInfo; + btDispatcherInfo dispatchInfo; dispatchInfo.m_timeStep = timeStep; dispatchInfo.m_stepCount = 0; dispatchInfo.m_enableSatConvex = false;//m_enableSatCollisionDetection; dispatchInfo.m_debugDraw = debugDrawer; - std::vector overlappingPairs; + std::vector overlappingPairs; overlappingPairs.resize(this->m_overlappingPairIndices.size()); //gather overlapping pair info @@ -115,13 +115,13 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, #ifdef USE_QUICKPROF - Profiler::endBlock("DispatchAllCollisionPairs"); + btProfiler::endBlock("DispatchAllCollisionPairs"); #endif //USE_QUICKPROF //contacts #ifdef USE_QUICKPROF - Profiler::beginBlock("SolveConstraint"); + btProfiler::beginBlock("SolveConstraint"); #endif //USE_QUICKPROF @@ -139,7 +139,7 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, //point to point constraints for (i=0;i< numConstraints ; i++ ) { - TypedConstraint* constraint = constraintsBaseAddress[m_constraintIndices[i]]; + btTypedConstraint* constraint = constraintsBaseAddress[m_constraintIndices[i]]; constraint->BuildJacobian(); constraint->SolveConstraint( timeStep ); @@ -149,7 +149,7 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, } #ifdef USE_QUICKPROF - Profiler::endBlock("SolveConstraint"); + btProfiler::endBlock("SolveConstraint"); #endif //USE_QUICKPROF /* @@ -162,7 +162,7 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, for (int i=0;iGetVehicle(); + btRaycastVehicle* vehicle = wrapperVehicle->GetVehicle(); vehicle->UpdateVehicle( timeStep); } #endif //NEW_BULLET_VEHICLE_SUPPORT @@ -170,20 +170,20 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, /* - Profiler::beginBlock("CallbackTriggers"); + btProfiler::beginBlock("CallbackTriggers"); #endif //USE_QUICKPROF CallbackTriggers(); #ifdef USE_QUICKPROF - Profiler::endBlock("CallbackTriggers"); + btProfiler::endBlock("CallbackTriggers"); } */ //OverlappingPairCache* scene = GetCollisionWorld()->GetPairCache(); - ContactSolverInfo solverInfo; + btContactSolverInfo solverInfo; solverInfo.m_friction = 0.9f; solverInfo.m_numIterations = numSolverIterations; @@ -198,7 +198,7 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, #ifdef USE_QUICKPROF - Profiler::beginBlock("proceedToTransform"); + btProfiler::beginBlock("proceedToTransform"); #endif //USE_QUICKPROF { @@ -216,10 +216,10 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, /* if (m_ccdMode == 3) { - DispatcherInfo dispatchInfo; + btDispatcherInfo dispatchInfo; dispatchInfo.m_timeStep = timeStep; dispatchInfo.m_stepCount = 0; - dispatchInfo.m_dispatchFunc = DispatcherInfo::DISPATCH_CONTINUOUS; + dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS; // GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(scene,dispatchInfo); toi = dispatchInfo.m_timeOfImpact; @@ -243,8 +243,8 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, CcdPhysicsController* ctrl = *i; - SimdTransform predictedTrans; - RigidBody* body = ctrl->GetRigidBody(); + btTransform predictedTrans; + btRigidBody* body = ctrl->GetRigidBody(); if (body->IsActive()) { @@ -276,7 +276,7 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, !(i==m_controllers.end()); i++) { CcdPhysicsController* ctrl = (*i); - RigidBody* body = ctrl->GetRigidBody(); + btRigidBody* body = ctrl->GetRigidBody(); ctrl->UpdateDeactivation(timeStep); @@ -313,15 +313,15 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations, #ifdef USE_QUICKPROF - Profiler::endBlock("proceedToTransform"); + btProfiler::endBlock("proceedToTransform"); - Profiler::beginBlock("SyncMotionStates"); + btProfiler::beginBlock("SyncMotionStates"); #endif //USE_QUICKPROF SyncMotionStates(timeStep); #ifdef USE_QUICKPROF - Profiler::endBlock("SyncMotionStates"); + btProfiler::endBlock("SyncMotionStates"); #endif //USE_QUICKPROF @@ -363,7 +363,7 @@ void SimulationIsland::SyncMotionStates(float timeStep) -void SimulationIsland::UpdateAabbs(IDebugDraw* debugDrawer,BroadphaseInterface* scene,float timeStep) +void SimulationIsland::UpdateAabbs(btIDebugDraw* debugDrawer,btBroadphaseInterface* scene,float timeStep) { std::vector::iterator i; @@ -375,33 +375,33 @@ void SimulationIsland::UpdateAabbs(IDebugDraw* debugDrawer,BroadphaseInterface* !(i==m_controllers.end()); i++) { CcdPhysicsController* ctrl = (*i); - RigidBody* body = ctrl->GetRigidBody(); + btRigidBody* body = ctrl->GetRigidBody(); - SimdPoint3 minAabb,maxAabb; - CollisionShape* shapeinterface = ctrl->GetCollisionShape(); + btPoint3 minAabb,maxAabb; + btCollisionShape* shapeinterface = ctrl->GetCollisionShape(); shapeinterface->CalculateTemporalAabb(body->getCenterOfMassTransform(), body->getLinearVelocity(), //body->getAngularVelocity(), - SimdVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(), + btVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(), timeStep,minAabb,maxAabb); - SimdVector3 manifoldExtraExtents(gContactBreakingTreshold,gContactBreakingTreshold,gContactBreakingTreshold); + btVector3 manifoldExtraExtents(gContactBreakingTreshold,gContactBreakingTreshold,gContactBreakingTreshold); minAabb -= manifoldExtraExtents; maxAabb += manifoldExtraExtents; - BroadphaseProxy* bp = body->m_broadphaseHandle; + btBroadphaseProxy* bp = body->m_broadphaseHandle; if (bp) { - SimdVector3 color (1,1,0); + btVector3 color (1,1,0); /* - class IDebugDraw* m_debugDrawer = 0; + class btIDebugDraw* m_debugDrawer = 0; if (m_debugDrawer) { //draw aabb @@ -428,7 +428,7 @@ void SimulationIsland::UpdateAabbs(IDebugDraw* debugDrawer,BroadphaseInterface* }; - if (m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_DrawAabb) + if (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_DrawAabb) { DrawAabb(m_debugDrawer,minAabb,maxAabb,color); } diff --git a/Extras/PhysicsInterface/CcdPhysics/SimulationIsland.h b/Extras/PhysicsInterface/CcdPhysics/SimulationIsland.h index ea47bee2a..e89e73da2 100644 --- a/Extras/PhysicsInterface/CcdPhysics/SimulationIsland.h +++ b/Extras/PhysicsInterface/CcdPhysics/SimulationIsland.h @@ -17,9 +17,9 @@ subject to the following restrictions: #define SIMULATION_ISLAND_H #include -class BroadphaseInterface; -class Dispatcher; -class IDebugDraw; +class btBroadphaseInterface; +class btDispatcher; +class btIDebugDraw; ///SimulationIsland groups all computations and data (for collision detection and dynamics) that can execute in parallel with other SimulationIsland's ///The ParallelPhysicsEnvironment and ParallelIslandDispatcher will dispatch SimulationIsland's @@ -30,12 +30,12 @@ class SimulationIsland public: std::vector m_controllers; - std::vector m_manifolds; + std::vector m_manifolds; std::vector m_overlappingPairIndices; std::vector m_constraintIndices; - bool Simulate(IDebugDraw* debugDrawer,int numSolverIterations,class TypedConstraint** constraintsBaseAddress,struct BroadphasePair* overlappingPairBaseAddress, Dispatcher* dispatcher,BroadphaseInterface* broadphase, class ConstraintSolver* solver, float timeStep); + bool Simulate(btIDebugDraw* debugDrawer,int numSolverIterations,class btTypedConstraint** constraintsBaseAddress,struct btBroadphasePair* overlappingPairBaseAddress, btDispatcher* dispatcher,btBroadphaseInterface* broadphase, class btConstraintSolver* solver, float timeStep); int GetNumControllers() @@ -47,7 +47,7 @@ class SimulationIsland void SyncMotionStates(float timeStep); - void UpdateAabbs(IDebugDraw* debugDrawer,BroadphaseInterface* broadphase,float timeStep); + void UpdateAabbs(btIDebugDraw* debugDrawer,btBroadphaseInterface* broadphase,float timeStep); }; #endif //SIMULATION_ISLAND_H diff --git a/Extras/PhysicsInterface/Common/PHY_Pro.h b/Extras/PhysicsInterface/Common/PHY_Pro.h index aa455164d..7ab4129ca 100644 --- a/Extras/PhysicsInterface/Common/PHY_Pro.h +++ b/Extras/PhysicsInterface/Common/PHY_Pro.h @@ -17,7 +17,7 @@ subject to the following restrictions: #define PHY_PROPSH -class CollisionShape; +class btCollisionShape; // Properties of dynamic objects struct PHY_ShapeProps { @@ -29,7 +29,7 @@ struct PHY_ShapeProps { bool m_do_anisotropic; // Should I do anisotropic friction? bool m_do_fh; // Should the object have a linear Fh spring? bool m_do_rot_fh; // Should the object have an angular Fh spring? - CollisionShape* m_shape; + btCollisionShape* m_shape; }; diff --git a/Extras/SATConvexCollision/Hull.cpp b/Extras/SATConvexCollision/Hull.cpp index 35f3faa3f..d310b7dc5 100644 --- a/Extras/SATConvexCollision/Hull.cpp +++ b/Extras/SATConvexCollision/Hull.cpp @@ -540,7 +540,7 @@ Hull* Hull::MakeHullFromTemp() -void Hull::ProcessHullHull(Separation& sep,const Hull& shapeA,const Hull& shapeB,const Transform& trA,const Transform& trB,HullContactCollector* collector) +void Hull::ProcessHullHull(btSeparation& sep,const Hull& shapeA,const Hull& shapeB,const Transform& trA,const Transform& trB,HullContactCollector* collector) { Point3 vertsA[Hull::kMaxVerts]; Point3 vertsB[Hull::kMaxVerts]; @@ -563,7 +563,7 @@ void Hull::ProcessHullHull(Separation& sep,const Hull& shapeA,const Hull& shapeB #ifdef SHAPE_COLLIDER_USE_CACHING // update cached pair - if (sep.m_separator != Separation::kFeatureNone) + if (sep.m_separator != btSeparation::kFeatureNone) { // re-use the separation if (UpdateSeparationHullHull(sep, pVertsA, pVertsB, trA, trB) == true) @@ -756,7 +756,7 @@ int Hull::ClipFace(int numVerts, Point3** ppVtxIn, Point3** ppVtxOut, const Plan -int Hull::AddContactsHullHull(Separation& sep, const Point3* pVertsA, const Point3* pVertsB, +int Hull::AddContactsHullHull(btSeparation& sep, const Point3* pVertsA, const Point3* pVertsB, const Transform& trA, const Transform& trB,const Hull& hullA,const Hull& hullB, HullContactCollector* hullContactCollector) { @@ -765,7 +765,7 @@ int Hull::AddContactsHullHull(Separation& sep, const Point3* pVertsA, const Poin Vector3 normalWorld = sep.m_axis; // edge->edge contact is always a single point - if (sep.m_separator == Separation::kFeatureBoth) + if (sep.m_separator == btSeparation::kFeatureBoth) { const Hull::Edge& edgeA = hullA.GetEdge(sep.m_featureA); const Hull::Edge& edgeB = hullB.GetEdge(sep.m_featureB); @@ -799,7 +799,7 @@ int Hull::AddContactsHullHull(Separation& sep, const Point3* pVertsA, const Poin // find face of hull A that is most opposite contact axis // TODO: avoid having to transform planes here - if (sep.m_separator == Separation::kFeatureB) + if (sep.m_separator == btSeparation::kFeatureB) { const Hull::Edge& edgeB = hullB.GetEdge(hullB.GetFaceFirstEdge(faceB)); tangent = Normalize(pVertsB[edgeB.m_verts[1]] - pVertsB[edgeB.m_verts[0]]); @@ -921,7 +921,7 @@ int Hull::AddContactsHullHull(Separation& sep, const Point3* pVertsA, const Poin // if no separating axis was found then details of least penetrating axis are returned // resulting axis always points away from hullB // either transform can be null in which case it is treated as identity (this avoids a bunch of work) -bool Hull::GetSeparationHullHull(Separation& sep, const Point3* pVertsA, const Point3* pVertsB, +bool Hull::GetSeparationHullHull(btSeparation& sep, const Point3* pVertsA, const Point3* pVertsB, const Transform& trA, const Transform& trB, const Hull& hullA, const Hull& hullB @@ -930,7 +930,7 @@ bool Hull::GetSeparationHullHull(Separation& sep, const Point3* pVertsA, const P //const Hull& hullA((const Hull&)*sep.m_pShapeA->GetShape()); //const Hull& hullB((const Hull&)*sep.m_pShapeB->GetShape()); - sep.m_separator = Separation::kFeatureNone; + sep.m_separator = btSeparation::kFeatureNone; sep.m_dist = MinValueF; sep.m_featureA = sep.m_featureB = -1; sep.m_contact = -1; @@ -952,7 +952,7 @@ bool Hull::GetSeparationHullHull(Separation& sep, const Point3* pVertsA, const P sep.m_featureB = p; sep.m_dist = minDist; sep.m_axis = planeWorld.GetNormal(); - sep.m_separator = Separation::kFeatureB; + sep.m_separator = btSeparation::kFeatureB; } // got a separating plane? @@ -982,7 +982,7 @@ bool Hull::GetSeparationHullHull(Separation& sep, const Point3* pVertsA, const P { sep.m_dist = (float)minDist; sep.m_axis = -planeWorld.GetNormal(); - sep.m_separator = Separation::kFeatureA; + sep.m_separator = btSeparation::kFeatureA; } } @@ -1048,7 +1048,7 @@ bool Hull::GetSeparationHullHull(Separation& sep, const Point3* pVertsA, const P sep.m_featureB = eb; sep.m_dist = dminA; sep.m_axis = axis; - sep.m_separator = Separation::kFeatureBoth; + sep.m_separator = btSeparation::kFeatureBoth; return true; } @@ -1065,7 +1065,7 @@ bool Hull::GetSeparationHullHull(Separation& sep, const Point3* pVertsA, const P // sep.m_featureB = eb; sep.m_dist = dminA; sep.m_axis = axis; -// sep.m_separator = Separation::kFeatureBoth; +// sep.m_separator = btSeparation::kFeatureBoth; } } diff --git a/Extras/SATConvexCollision/Hull.h b/Extras/SATConvexCollision/Hull.h index 4dbbb4eb1..55bd184b2 100644 --- a/Extras/SATConvexCollision/Hull.h +++ b/Extras/SATConvexCollision/Hull.h @@ -138,8 +138,8 @@ public: Point3 GetFaceCentroid(short face) const; - //static void ProcessHullHull(Separation& sep); - static void ProcessHullHull(Separation& sep,const Hull& shapeA,const Hull& shapeB,const Transform& trA,const Transform& trB, HullContactCollector* collector); + //static void ProcessHullHull(btSeparation& sep); + static void ProcessHullHull(btSeparation& sep,const Hull& shapeA,const Hull& shapeB,const Transform& trA,const Transform& trB, HullContactCollector* collector); virtual void ComputeInertia(const Transform& transform, Point3& centerOfMass, Matrix33& inertia, float totalMass) const; virtual Bounds3 ComputeBounds(const Transform& transform) const; @@ -153,13 +153,13 @@ public: /// Clips a face to the back of a plane static int ClipFace(int numVerts, Point3** ppVtxIn, Point3** ppVtxOut, const Plane& plane); - static bool GetSeparationHullHull(Separation& sep, const Point3* pVertsA, const Point3* pVertsB, + static bool GetSeparationHullHull(btSeparation& sep, const Point3* pVertsA, const Point3* pVertsB, const Transform& trA, const Transform& trB, const Hull& hullA, const Hull& hullB ); - static int AddContactsHullHull(Separation& sep, const Point3* pVertsA, const Point3* pVertsB, + static int AddContactsHullHull(btSeparation& sep, const Point3* pVertsA, const Point3* pVertsB, const Transform& trA, const Transform& trB,const Hull& hullA,const Hull& hullB, HullContactCollector* hullContactCollector); diff --git a/Extras/SATConvexCollision/HullContactCollector.h b/Extras/SATConvexCollision/HullContactCollector.h index ba80f35a1..2d14fb5d1 100644 --- a/Extras/SATConvexCollision/HullContactCollector.h +++ b/Extras/SATConvexCollision/HullContactCollector.h @@ -20,7 +20,7 @@ subject to the following restrictions: class Vector3; class Point3; class Scalar; -struct Separation; +struct btSeparation; ///HullContactCollector collects the Hull computation to the contact point results class HullContactCollector @@ -29,7 +29,7 @@ public: virtual ~HullContactCollector() {}; - virtual int BatchAddContactGroup(const Separation& sep,int numContacts,const Vector3& normalWorld,const Vector3& tangent,const Point3* positionsWorld,const float* depths)=0; + virtual int BatchAddContactGroup(const btSeparation& sep,int numContacts,const Vector3& normalWorld,const Vector3& tangent,const Point3* positionsWorld,const float* depths)=0; virtual int GetMaxNumContacts() const = 0; diff --git a/Extras/SATConvexCollision/Shape.h b/Extras/SATConvexCollision/Shape.h index a9200fe2c..e63150d76 100644 --- a/Extras/SATConvexCollision/Shape.h +++ b/Extras/SATConvexCollision/Shape.h @@ -26,7 +26,7 @@ -struct Separation +struct btSeparation { short m_featureA; diff --git a/Extras/quickstep/OdeConstraintSolver.cpp b/Extras/quickstep/OdeConstraintSolver.cpp index be1dc0dd6..5cc76c1d4 100644 --- a/Extras/quickstep/OdeConstraintSolver.cpp +++ b/Extras/quickstep/OdeConstraintSolver.cpp @@ -20,12 +20,12 @@ subject to the following restrictions: #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" #include "BulletDynamics/Dynamics/btRigidBody.h" #include "btContactConstraint.h" -#include "Solve2LinearConstraint.h" +#include "btSolve2LinearConstraint.h" #include "btContactSolverInfo.h" #include "Dynamics/BU_Joint.h" #include "Dynamics/ContactJoint.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" #define USE_SOR_SOLVER @@ -69,13 +69,13 @@ m_erp(0.4f) //iterative lcp and penalty method -float OdeConstraintSolver::SolveGroup(PersistentManifold** manifoldPtr, int numManifolds,const ContactSolverInfo& infoGlobal,IDebugDraw* debugDrawer) +float OdeConstraintSolver::SolveGroup(btPersistentManifold** manifoldPtr, int numManifolds,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer) { m_CurBody = 0; m_CurJoint = 0; - RigidBody* bodies [MAX_QUICKSTEP_RIGIDBODIES]; + btRigidBody* bodies [MAX_QUICKSTEP_RIGIDBODIES]; int numBodies = 0; BU_Joint* joints [MAX_QUICKSTEP_RIGIDBODIES*4]; @@ -86,11 +86,11 @@ float OdeConstraintSolver::SolveGroup(PersistentManifold** manifoldPtr, int numM int body0=-1,body1=-1; - PersistentManifold* manifold = manifoldPtr[j]; + btPersistentManifold* manifold = manifoldPtr[j]; if (manifold->GetNumContacts() > 0) { - body0 = ConvertBody((RigidBody*)manifold->GetBody0(),bodies,numBodies); - body1 = ConvertBody((RigidBody*)manifold->GetBody1(),bodies,numBodies); + body0 = ConvertBody((btRigidBody*)manifold->GetBody0(),bodies,numBodies); + body1 = ConvertBody((btRigidBody*)manifold->GetBody1(),bodies,numBodies); ConvertConstraint(manifold,joints,numJoints,bodies,body0,body1,debugDrawer); } } @@ -104,15 +104,15 @@ float OdeConstraintSolver::SolveGroup(PersistentManifold** manifoldPtr, int numM ///////////////////////////////////////////////////////////////////////////////// -typedef SimdScalar dQuaternion[4]; +typedef btScalar dQuaternion[4]; #define _R(i,j) R[(i)*4+(j)] void dRfromQ1 (dMatrix3 R, const dQuaternion q) { // q = (s,vx,vy,vz) - SimdScalar qq1 = 2.f*q[1]*q[1]; - SimdScalar qq2 = 2.f*q[2]*q[2]; - SimdScalar qq3 = 2.f*q[3]*q[3]; + btScalar qq1 = 2.f*q[1]*q[1]; + btScalar qq2 = 2.f*q[2]*q[2]; + btScalar qq3 = 2.f*q[3]*q[3]; _R(0,0) = 1.f - qq2 - qq3; _R(0,1) = 2*(q[1]*q[2] - q[0]*q[3]); _R(0,2) = 2*(q[1]*q[3] + q[0]*q[2]); @@ -132,7 +132,7 @@ void dRfromQ1 (dMatrix3 R, const dQuaternion q) -int OdeConstraintSolver::ConvertBody(RigidBody* body,RigidBody** bodies,int& numBodies) +int OdeConstraintSolver::ConvertBody(btRigidBody* body,btRigidBody** bodies,int& numBodies) { if (!body || (body->getInvMass() == 0.f) ) { @@ -194,13 +194,13 @@ int OdeConstraintSolver::ConvertBody(RigidBody* body,RigidBody** bodies,int& num static ContactJoint gJointArray[MAX_JOINTS_1]; -void OdeConstraintSolver::ConvertConstraint(PersistentManifold* manifold,BU_Joint** joints,int& numJoints, - RigidBody** bodies,int _bodyId0,int _bodyId1,IDebugDraw* debugDrawer) +void OdeConstraintSolver::ConvertConstraint(btPersistentManifold* manifold,BU_Joint** joints,int& numJoints, + btRigidBody** bodies,int _bodyId0,int _bodyId1,btIDebugDraw* debugDrawer) { - manifold->RefreshContactPoints(((RigidBody*)manifold->GetBody0())->getCenterOfMassTransform(), - ((RigidBody*)manifold->GetBody1())->getCenterOfMassTransform()); + manifold->RefreshContactPoints(((btRigidBody*)manifold->GetBody0())->getCenterOfMassTransform(), + ((btRigidBody*)manifold->GetBody1())->getCenterOfMassTransform()); int bodyId0 = _bodyId0,bodyId1 = _bodyId1; @@ -209,31 +209,31 @@ void OdeConstraintSolver::ConvertConstraint(PersistentManifold* manifold,BU_Join bool swapBodies = (bodyId0 < 0); - RigidBody* body0,*body1; + btRigidBody* body0,*body1; if (swapBodies) { bodyId0 = _bodyId1; bodyId1 = _bodyId0; - body0 = (RigidBody*)manifold->GetBody1(); - body1 = (RigidBody*)manifold->GetBody0(); + body0 = (btRigidBody*)manifold->GetBody1(); + body1 = (btRigidBody*)manifold->GetBody0(); } else { - body0 = (RigidBody*)manifold->GetBody0(); - body1 = (RigidBody*)manifold->GetBody1(); + body0 = (btRigidBody*)manifold->GetBody0(); + body1 = (btRigidBody*)manifold->GetBody1(); } assert(bodyId0 >= 0); - SimdVector3 color(0,1,0); + btVector3 color(0,1,0); for (i=0;iGetContactPoint(i); + const btManifoldPoint& cp = manifold->GetContactPoint(i); debugDrawer->DrawContactPoint( cp.m_positionWorldOnB, diff --git a/Extras/quickstep/OdeConstraintSolver.h b/Extras/quickstep/OdeConstraintSolver.h index f194e0f70..d91b29399 100644 --- a/Extras/quickstep/OdeConstraintSolver.h +++ b/Extras/quickstep/OdeConstraintSolver.h @@ -16,14 +16,14 @@ subject to the following restrictions: #ifndef ODE_CONSTRAINT_SOLVER_H #define ODE_CONSTRAINT_SOLVER_H -#include "ConstraintSolver.h" +#include "btConstraintSolver.h" -class RigidBody; +class btRigidBody; class BU_Joint; /// OdeConstraintSolver is one of the available solvers for Bullet dynamics framework /// It uses the the unmodified version of quickstep solver from the open dynamics project -class OdeConstraintSolver : public ConstraintSolver +class OdeConstraintSolver : public btConstraintSolver { private: @@ -34,9 +34,9 @@ private: float m_erp; - int ConvertBody(RigidBody* body,RigidBody** bodies,int& numBodies); - void ConvertConstraint(PersistentManifold* manifold,BU_Joint** joints,int& numJoints, - RigidBody** bodies,int _bodyId0,int _bodyId1,IDebugDraw* debugDrawer); + int ConvertBody(btRigidBody* body,btRigidBody** bodies,int& numBodies); + void ConvertConstraint(btPersistentManifold* manifold,BU_Joint** joints,int& numJoints, + btRigidBody** bodies,int _bodyId0,int _bodyId1,btIDebugDraw* debugDrawer); public: @@ -44,7 +44,7 @@ public: virtual ~OdeConstraintSolver() {} - virtual float SolveGroup(PersistentManifold** manifold,int numManifolds,const ContactSolverInfo& info,IDebugDraw* debugDrawer = 0); + virtual float SolveGroup(btPersistentManifold** manifold,int numManifolds,const btContactSolverInfo& info,btIDebugDraw* debugDrawer = 0); ///setConstraintForceMixing, the cfm adds some positive value to the main diagonal ///This can improve convergence (make matrix positive semidefinite), but it can make the simulation look more 'springy' diff --git a/Extras/quickstep/SorLcp.cpp b/Extras/quickstep/SorLcp.cpp index 264513637..623dbf078 100644 --- a/Extras/quickstep/SorLcp.cpp +++ b/Extras/quickstep/SorLcp.cpp @@ -5,10 +5,10 @@ * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * + * (1) The GNU Lesser bteral Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * + * bteral Public License is included with this library in the * * file LICENSE.TXT. * * (2) The BSD-style license that is included with this library in * * the file LICENSE-BSD.TXT. * @@ -28,7 +28,7 @@ // todo: write own successive overrelaxation gauss-seidel, or jacobi iterative solver -#include "LinearMath/SimdScalar.h" +#include "LinearMath/btScalar.h" #include "BulletDynamics/Dynamics/btRigidBody.h" #include @@ -55,8 +55,8 @@ //////////////////////////////////////////////////////////////////// //math stuff -typedef SimdScalar dVector4[4]; -typedef SimdScalar dMatrix3[4*3]; +typedef btScalar dVector4[4]; +typedef btScalar dMatrix3[4*3]; #define dInfinity FLT_MAX @@ -85,7 +85,7 @@ typedef SimdScalar dMatrix3[4*3]; #define REAL float #define dDOTpq(a,b,p,q) ((a)[0]*(b)[0] + (a)[p]*(b)[q] + (a)[2*(p)]*(b)[2*(q)]) -SimdScalar dDOT1 (const SimdScalar *a, const SimdScalar *b) { return dDOTpq(a,b,1,1); } +btScalar dDOT1 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,1,1); } #define dDOT14(a,b) dDOTpq(a,b,1,4) #define dCROSS(a,op,b,c) \ @@ -171,12 +171,12 @@ extern "C" { #define ALLOCA dALLOCA16 -typedef const SimdScalar *dRealPtr; -typedef SimdScalar *dRealMutablePtr; -#define dRealArray(name,n) SimdScalar name[n]; -#define dRealAllocaArray(name,n) SimdScalar *name = (SimdScalar*) ALLOCA ((n)*sizeof(SimdScalar)); +typedef const btScalar *dRealPtr; +typedef btScalar *dRealMutablePtr; +#define dRealArray(name,n) btScalar name[n]; +#define dRealAllocaArray(name,n) btScalar *name = (btScalar*) ALLOCA ((n)*sizeof(btScalar)); -void dSetZero1 (SimdScalar *a, int n) +void dSetZero1 (btScalar *a, int n) { dAASSERT (a && n >= 0); while (n > 0) { @@ -185,7 +185,7 @@ void dSetZero1 (SimdScalar *a, int n) } } -void dSetValue1 (SimdScalar *a, int n, SimdScalar value) +void dSetValue1 (btScalar *a, int n, btScalar value) { dAASSERT (a && n >= 0); while (n > 0) { @@ -220,7 +220,7 @@ void dSetValue1 (SimdScalar *a, int n, SimdScalar value) // compute iMJ = inv(M)*J' static void compute_invM_JT (int m, dRealMutablePtr J, dRealMutablePtr iMJ, int *jb, - RigidBody * const *body, dRealPtr invI) + btRigidBody * const *body, dRealPtr invI) { int i,j; dRealMutablePtr iMJ_ptr = iMJ; @@ -228,7 +228,7 @@ static void compute_invM_JT (int m, dRealMutablePtr J, dRealMutablePtr iMJ, int for (i=0; igetInvMass(); + btScalar k = body[b1]->getInvMass(); for (j=0; j<3; j++) iMJ_ptr[j] = k*J_ptr[j]; dMULTIPLY0_331 (iMJ_ptr + 3, invI + 12*b1, J_ptr + 3); if (b2 >= 0) { @@ -330,7 +330,7 @@ static void multiply_J (int m, dRealMutablePtr J, int *jb, for (i=0; i= 0) { - hi[index] = SimdFabs (hicopy[index] * lambda[findex[index]]); + hi[index] = btFabs (hicopy[index] * lambda[findex[index]]); lo[index] = -hi[index]; } @@ -597,10 +597,10 @@ static void SOR_LCP (int m, int nb, dRealMutablePtr J, int *jb, RigidBody * cons void SolveInternal1 (float global_cfm, float global_erp, - RigidBody * const *body, int nb, + btRigidBody * const *body, int nb, BU_Joint * const *_joint, int nj, - const ContactSolverInfo& solverInfo) + const btContactSolverInfo& solverInfo) { int numIter = solverInfo.m_numIterations; @@ -608,7 +608,7 @@ void SolveInternal1 (float global_cfm, int i,j; - SimdScalar stepsize1 = dRecip(solverInfo.m_timeStep); + btScalar stepsize1 = dRecip(solverInfo.m_timeStep); // number all bodies in the body list - set their tag values for (i=0; igetInvMass(); + btScalar body_invMass = body[i]->getInvMass(); for (j=0; j<3; j++) tmp1[i*6+j] = body[i]->m_facc[j] * body_invMass + body[i]->getLinearVelocity()[j] * stepsize1; dMULTIPLY0_331NEW (tmp1 + i*6 + 3,=,invI + i*12,body[i]->m_tacc); @@ -779,7 +779,7 @@ void SolveInternal1 (float global_cfm, #ifdef WARM_STARTING dSetZero1 (lambda,m); //@@@ shouldn't be necessary for (i=0; ilambda,info[i].m * sizeof(SimdScalar)); + memcpy (lambda+ofs[i],joint[i]->lambda,info[i].m * sizeof(btScalar)); } #endif @@ -793,7 +793,7 @@ void SolveInternal1 (float global_cfm, //@@@ note that this doesn't work for contact joints yet, as they are // recreated every iteration for (i=0; ilambda,lambda+ofs[i],info[i].m * sizeof(SimdScalar)); + memcpy (joint[i]->lambda,lambda+ofs[i],info[i].m * sizeof(btScalar)); } #endif @@ -803,8 +803,8 @@ void SolveInternal1 (float global_cfm, // add stepsize * cforce to the body velocity for (i=0; igetLinearVelocity(); - SimdVector3 angvel = body[i]->getAngularVelocity(); + btVector3 linvel = body[i]->getLinearVelocity(); + btVector3 angvel = body[i]->getAngularVelocity(); for (j=0; j<3; j++) linvel[j] += solverInfo.m_timeStep* cforce[i*6+j]; @@ -824,9 +824,9 @@ void SolveInternal1 (float global_cfm, // add stepsize * invM * fe to the body velocity for (i=0; igetInvMass(); - SimdVector3 linvel = body[i]->getLinearVelocity(); - SimdVector3 angvel = body[i]->getAngularVelocity(); + btScalar body_invMass = body[i]->getInvMass(); + btVector3 linvel = body[i]->getLinearVelocity(); + btVector3 angvel = body[i]->getAngularVelocity(); for (j=0; j<3; j++) { diff --git a/Extras/quickstep/SorLcp.h b/Extras/quickstep/SorLcp.h index d12fca1f7..374c8637b 100644 --- a/Extras/quickstep/SorLcp.h +++ b/Extras/quickstep/SorLcp.h @@ -5,10 +5,10 @@ * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * + * (1) The GNU Lesser bteral Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * + * bteral Public License is included with this library in the * * file LICENSE.TXT. * * (2) The BSD-style license that is included with this library in * * the file LICENSE-BSD.TXT. * @@ -25,16 +25,16 @@ #ifndef SOR_LCP_H #define SOR_LCP_H -class RigidBody; +class btRigidBody; class BU_Joint; -#include "LinearMath/SimdScalar.h" +#include "LinearMath/btScalar.h" -struct ContactSolverInfo; +struct btContactSolverInfo; void SolveInternal1 (float global_cfm, float global_erp, - RigidBody * const *body, int nb, - BU_Joint * const *_joint, int nj, const ContactSolverInfo& info); + btRigidBody * const *body, int nb, + BU_Joint * const *_joint, int nj, const btContactSolverInfo& info); int dRandInt2 (int n); diff --git a/Extras/test_BulletOde.cpp b/Extras/test_BulletOde.cpp index 2f970e23a..750220330 100644 --- a/Extras/test_BulletOde.cpp +++ b/Extras/test_BulletOde.cpp @@ -5,10 +5,10 @@ * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * + * (1) The GNU Lesser bteral Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * + * bteral Public License is included with this library in the * * file LICENSE.TXT. * * (2) The BSD-style license that is included with this library in * * the file LICENSE-BSD.TXT. * @@ -69,14 +69,14 @@ struct MyObject { dBodyID body; // the body - CollisionObject collider; //the collisionShape + btCollisionObject collider; //the collisionShape }; static int num=0; // number of objects in simulation static int nextobj=0; // next object to recycle if num==NUM static dWorldID world; -CollisionWorld* collisionWorld = 0; +btCollisionWorld* collisionWorld = 0; static MyObject obj[NUM]; static dJointGroupID contactgroup; @@ -88,24 +88,24 @@ static int write_world = 0; -SimdTransform GetTransformFromOde(const dReal* pos,const dReal* rot) +btTransform GetTransformFromOde(const dReal* pos,const dReal* rot) { - SimdTransform trans; + btTransform trans; trans.setIdentity(); // rot is pointer to object's rotation matrix, 4*3 format! - SimdMatrix3x3 orn(rot[0],rot[1],rot[2], + btMatrix3x3 orn(rot[0],rot[1],rot[2], rot[4],rot[5],rot[6], rot[8],rot[9],rot[10]); - trans.setOrigin(SimdVector3(pos[0],pos[1],pos[2])); + trans.setOrigin(btVector3(pos[0],pos[1],pos[2])); trans.setBasis(orn); return trans; } -void GetOdeFromTransform(const SimdTransform& trans,dReal* pos,dReal* rot) +void GetOdeFromTransform(const btTransform& trans,dReal* pos,dReal* rot) { pos[0] = trans.getOrigin().x(); pos[1] = trans.getOrigin().y(); @@ -180,7 +180,7 @@ static void command (int cmd) // destroy the body and geoms for slot i dBodyDestroy (obj[i].body); collisionWorld->RemoveCollisionObject(&obj[i].collider); - obj[i].collider.m_broadphaseHandle = (BroadphaseProxy*)(-1); + obj[i].collider.m_broadphaseHandle = (btBroadphaseProxy*)(-1); //todo: destroy collider @@ -210,7 +210,7 @@ static void command (int cmd) if (cmd == 'b') { dMassSetBox (&m,DENSITY,sides[0],sides[1],sides[2]); - obj[i].collider.m_collisionShape = new BoxShape(SimdVector3(0.5*sides[0],0.5*sides[1],0.5*sides[2])); + obj[i].collider.m_collisionShape = new btBoxShape(btVector3(0.5*sides[0],0.5*sides[1],0.5*sides[2])); obj[i].collider.m_worldTransform = GetTransformFromOde(dBodyGetPosition(obj[i].body),dBodyGetRotation(obj[i].body)); collisionWorld->AddCollisionObject(&obj[i].collider); obj[i].collider.m_userPointer = obj[i].body; @@ -221,7 +221,7 @@ static void command (int cmd) sides[1] *= 0.2; sides[2] *= 0.2; dMassSetCappedCylinder (&m,DENSITY,3,sides[0],sides[1]); - obj[i].collider.m_collisionShape = new CylinderShapeZ(SimdVector3(sides[0],sides[1],sides[1])); + obj[i].collider.m_collisionShape = new btCylinderShapeZ(btVector3(sides[0],sides[1],sides[1])); obj[i].collider.m_worldTransform = GetTransformFromOde(dBodyGetPosition(obj[i].body),dBodyGetRotation(obj[i].body)); collisionWorld->AddCollisionObject(&obj[i].collider); obj[i].collider.m_userPointer = obj[i].body; @@ -238,7 +238,7 @@ static void command (int cmd) else if (cmd == 's') { sides[0] *= 0.5; dMassSetSphere (&m,DENSITY,sides[0]); - obj[i].collider.m_collisionShape = new SphereShape(sides[0]); + obj[i].collider.m_collisionShape = new btSphereShape(sides[0]); obj[i].collider.m_worldTransform = GetTransformFromOde(dBodyGetPosition(obj[i].body),dBodyGetRotation(obj[i].body)); @@ -289,7 +289,7 @@ static void command (int cmd) // draw a geom -void drawGeom (CollisionObject& collider)//, const dReal *pos, const dReal *R, int show_aabb) +void drawGeom (btCollisionObject& collider)//, const dReal *pos, const dReal *R, int show_aabb) { dReal pos[4]; dReal R[16]; @@ -304,7 +304,7 @@ void drawGeom (CollisionObject& collider)//, const dReal *pos, const dReal *R, i if (type == BOX_SHAPE_PROXYTYPE) { dVector3 sides; - BoxShape* boxShape = static_cast(collider.m_collisionShape); + btBoxShape* boxShape = static_cast(collider.m_collisionShape); sides[0] = 2.f*boxShape->GetHalfExtents().x(); sides[1] = 2.f*boxShape->GetHalfExtents().y(); sides[2] = 2.f*boxShape->GetHalfExtents().z(); @@ -313,7 +313,7 @@ void drawGeom (CollisionObject& collider)//, const dReal *pos, const dReal *R, i } else if (type == SPHERE_SHAPE_PROXYTYPE) { - SphereShape* sphereShape = static_cast(collider.m_collisionShape); + btSphereShape* sphereShape = static_cast(collider.m_collisionShape); dReal radius = sphereShape->GetMargin(); dsDrawSphere (pos,R,radius); @@ -322,7 +322,7 @@ void drawGeom (CollisionObject& collider)//, const dReal *pos, const dReal *R, i else if (type == CYLINDER_SHAPE_PROXYTYPE) { - CylinderShapeZ* cylinder = static_cast(collider.m_collisionShape); + btCylinderShapeZ* cylinder = static_cast(collider.m_collisionShape); dReal radius = cylinder->GetHalfExtents()[0]; dReal length = 2.f*cylinder->GetHalfExtents()[1]; radius += cylinder->GetMargin(); @@ -381,15 +381,15 @@ static void simLoop (int pause) for (int i=0;iGetDispatcher()->GetNumManifolds();i++) { - PersistentManifold* manifold = collisionWorld->GetDispatcher()->GetManifoldByIndexInternal(i); - CollisionObject* obj0 = static_cast(manifold->GetBody0()); - CollisionObject* obj1 = static_cast(manifold->GetBody1()); + btPersistentManifold* manifold = collisionWorld->GetDispatcher()->GetManifoldByIndexInternal(i); + btCollisionObject* obj0 = static_cast(manifold->GetBody0()); + btCollisionObject* obj1 = static_cast(manifold->GetBody1()); //RefreshContactPoints will update and/or remove existing contactpoints from previous frames manifold->RefreshContactPoints(obj0->m_worldTransform,obj1->m_worldTransform); for (int j=0;jGetNumContacts();j++) { - ManifoldPoint& pt = manifold->GetContactPoint(j); + btManifoldPoint& pt = manifold->GetContactPoint(j); if (pt.GetDistance()<0.f) { //report point to ODE @@ -495,11 +495,11 @@ int main (int argc, char **argv) //space = dHashSpaceCreate (0); float bpsize = 1000.f; - AxisSweep3 broadphase(SimdVector3(-bpsize,-bpsize,-bpsize),SimdVector3(bpsize,bpsize,bpsize)); + btAxisSweep3 broadphase(btVector3(-bpsize,-bpsize,-bpsize),btVector3(bpsize,bpsize,bpsize)); //SimpleBroadphase broadphase; - CollisionDispatcher dispatcher; - collisionWorld = new CollisionWorld(&dispatcher,&broadphase); + btCollisionDispatcher dispatcher; + collisionWorld = new btCollisionWorld(&dispatcher,&broadphase); contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-0.5); @@ -510,9 +510,9 @@ int main (int argc, char **argv) dWorldSetContactSurfaceLayer (world,0.001); //dCreatePlane (space,0,0,1,0); - CollisionObject groundPlane; + btCollisionObject groundPlane; groundPlane.m_worldTransform.setIdentity(); - groundPlane.m_collisionShape = new BoxShape(SimdVector3(50,50,0.04)); + groundPlane.m_collisionShape = new btBoxShape(btVector3(50,50,0.04)); groundPlane.m_collisionShape->SetMargin(0.005f); collisionWorld->AddCollisionObject(&groundPlane); groundPlane.m_userPointer = 0; diff --git a/src/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp b/src/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp index 3e167f745..7e4d6d8c8 100644 --- a/src/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp +++ b/src/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp @@ -4,7 +4,7 @@ // -// AxisSweep3 +// btAxisSweep3 // // Copyright (c) 2006 Simon Hobbs // @@ -21,7 +21,7 @@ #include -BroadphaseProxy* AxisSweep3::CreateProxy( const SimdVector3& min, const SimdVector3& max,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask) +btBroadphaseProxy* btAxisSweep3::CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask) { unsigned short handleId = AddHandle(min,max, userPtr,collisionFilterGroup,collisionFilterMask); @@ -30,13 +30,13 @@ BroadphaseProxy* AxisSweep3::CreateProxy( const SimdVector3& min, const SimdVe return handle; } -void AxisSweep3::DestroyProxy(BroadphaseProxy* proxy) +void btAxisSweep3::DestroyProxy(btBroadphaseProxy* proxy) { Handle* handle = static_cast(proxy); RemoveHandle(handle->m_handleId); } -void AxisSweep3::SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const SimdVector3& aabbMax) +void btAxisSweep3::SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax) { Handle* handle = static_cast(proxy); UpdateHandle(handle->m_handleId,aabbMin,aabbMax); @@ -47,8 +47,8 @@ void AxisSweep3::SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const -AxisSweep3::AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAabbMax, int maxHandles) -:OverlappingPairCache() +btAxisSweep3::btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles) +:btOverlappingPairCache() { //assert(bounds.HasVolume()); @@ -59,9 +59,9 @@ AxisSweep3::AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAab m_worldAabbMin = worldAabbMin; m_worldAabbMax = worldAabbMax; - SimdVector3 aabbSize = m_worldAabbMax - m_worldAabbMin; + btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin; - m_quantize = SimdVector3(65535.0f,65535.0f,65535.0f) / aabbSize; + m_quantize = btVector3(65535.0f,65535.0f,65535.0f) / aabbSize; // allocate handles buffer and put all handles on free list m_pHandles = new Handle[maxHandles]; @@ -99,7 +99,7 @@ AxisSweep3::AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAab } } -AxisSweep3::~AxisSweep3() +btAxisSweep3::~btAxisSweep3() { for (int i = 2; i >= 0; i--) @@ -107,15 +107,15 @@ AxisSweep3::~AxisSweep3() delete[] m_pHandles; } -void AxisSweep3::Quantize(unsigned short* out, const SimdPoint3& point, int isMax) const +void btAxisSweep3::Quantize(unsigned short* out, const btPoint3& point, int isMax) const { - SimdPoint3 clampedPoint(point); + btPoint3 clampedPoint(point); /* if (isMax) - clampedPoint += SimdVector3(10,10,10); + clampedPoint += btVector3(10,10,10); else { - clampedPoint -= SimdVector3(10,10,10); + clampedPoint -= btVector3(10,10,10); } */ @@ -123,7 +123,7 @@ void AxisSweep3::Quantize(unsigned short* out, const SimdPoint3& point, int isMa clampedPoint.setMax(m_worldAabbMin); clampedPoint.setMin(m_worldAabbMax); - SimdVector3 v = (clampedPoint - m_worldAabbMin) * m_quantize; + btVector3 v = (clampedPoint - m_worldAabbMin) * m_quantize; out[0] = (unsigned short)(((int)v.getX() & 0xfffc) | isMax); out[1] = (unsigned short)(((int)v.getY() & 0xfffc) | isMax); out[2] = (unsigned short)(((int)v.getZ() & 0xfffc) | isMax); @@ -132,7 +132,7 @@ void AxisSweep3::Quantize(unsigned short* out, const SimdPoint3& point, int isMa -unsigned short AxisSweep3::AllocHandle() +unsigned short btAxisSweep3::AllocHandle() { assert(m_firstFreeHandle); @@ -143,7 +143,7 @@ unsigned short AxisSweep3::AllocHandle() return handle; } -void AxisSweep3::FreeHandle(unsigned short handle) +void btAxisSweep3::FreeHandle(unsigned short handle) { assert(handle > 0 && handle < m_maxHandles); @@ -155,7 +155,7 @@ void AxisSweep3::FreeHandle(unsigned short handle) -unsigned short AxisSweep3::AddHandle(const SimdPoint3& aabbMin,const SimdPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask) +unsigned short btAxisSweep3::AddHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask) { // quantize the bounds unsigned short min[3], max[3]; @@ -208,7 +208,7 @@ unsigned short AxisSweep3::AddHandle(const SimdPoint3& aabbMin,const SimdPoint3& } -void AxisSweep3::RemoveHandle(unsigned short handle) +void btAxisSweep3::RemoveHandle(unsigned short handle) { Handle* pHandle = GetHandle(handle); @@ -256,7 +256,7 @@ void AxisSweep3::RemoveHandle(unsigned short handle) } -bool AxisSweep3::TestOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB) +bool btAxisSweep3::TestOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB) { //optimization 1: check the array index (memory address), instead of the m_pos @@ -287,7 +287,7 @@ bool AxisSweep3::TestOverlap(int ignoreAxis,const Handle* pHandleA, const Handle return true; } -void AxisSweep3::UpdateHandle(unsigned short handle, const SimdPoint3& aabbMin,const SimdPoint3& aabbMax) +void btAxisSweep3::UpdateHandle(unsigned short handle, const btPoint3& aabbMin,const btPoint3& aabbMax) { // assert(bounds.IsFinite()); //assert(bounds.HasVolume()); @@ -330,7 +330,7 @@ void AxisSweep3::UpdateHandle(unsigned short handle, const SimdPoint3& aabbMin,c } // sorting a min edge downwards can only ever *add* overlaps -void AxisSweep3::SortMinDown(int axis, unsigned short edge, bool updateOverlaps) +void btAxisSweep3::SortMinDown(int axis, unsigned short edge, bool updateOverlaps) { Edge* pEdge = m_pEdges[axis] + edge; Edge* pPrev = pEdge - 1; @@ -371,7 +371,7 @@ void AxisSweep3::SortMinDown(int axis, unsigned short edge, bool updateOverlaps) } // sorting a min edge upwards can only ever *remove* overlaps -void AxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps) +void btAxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps) { Edge* pEdge = m_pEdges[axis] + edge; Edge* pNext = pEdge + 1; @@ -388,7 +388,7 @@ void AxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps) { Handle* handle0 = GetHandle(pEdge->m_handle); Handle* handle1 = GetHandle(pNext->m_handle); - BroadphasePair tmpPair(*handle0,*handle1); + btBroadphasePair tmpPair(*handle0,*handle1); RemoveOverlappingPair(tmpPair); } @@ -413,7 +413,7 @@ void AxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps) } // sorting a max edge downwards can only ever *remove* overlaps -void AxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlaps) +void btAxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlaps) { Edge* pEdge = m_pEdges[axis] + edge; Edge* pPrev = pEdge - 1; @@ -430,7 +430,7 @@ void AxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlaps) { Handle* handle0 = GetHandle(pEdge->m_handle); Handle* handle1 = GetHandle(pPrev->m_handle); - BroadphasePair* pair = FindPair(handle0,handle1); + btBroadphasePair* pair = FindPair(handle0,handle1); //assert(pair); if (pair) @@ -459,7 +459,7 @@ void AxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlaps) } // sorting a max edge upwards can only ever *add* overlaps -void AxisSweep3::SortMaxUp(int axis, unsigned short edge, bool updateOverlaps) +void btAxisSweep3::SortMaxUp(int axis, unsigned short edge, bool updateOverlaps) { Edge* pEdge = m_pEdges[axis] + edge; Edge* pNext = pEdge + 1; diff --git a/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h b/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h index 7d7e78d55..3f3d6a89d 100644 --- a/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h +++ b/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h @@ -2,7 +2,7 @@ //Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ // -// AxisSweep3.h +// btAxisSweep3.h // // Copyright (c) 2006 Simon Hobbs // @@ -19,15 +19,15 @@ #ifndef AXIS_SWEEP_3_H #define AXIS_SWEEP_3_H -#include "LinearMath/SimdPoint3.h" -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btPoint3.h" +#include "LinearMath/btVector3.h" #include "btOverlappingPairCache.h" #include "btBroadphaseProxy.h" -/// AxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase. +/// btAxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase. /// It uses arrays rather then lists for storage of the 3 axis. Also it operates using integer coordinates instead of floats. /// The TestOverlap check is optimized to check the array index, rather then the actual AABB coordinates/pos -class AxisSweep3 : public OverlappingPairCache +class btAxisSweep3 : public btOverlappingPairCache { public: @@ -43,7 +43,7 @@ public: }; public: - class Handle : public BroadphaseProxy + class Handle : public btBroadphaseProxy { public: @@ -52,7 +52,7 @@ public: unsigned short m_handleId; unsigned short m_pad; - //void* m_pOwner; this is now in BroadphaseProxy.m_clientObject + //void* m_pOwner; this is now in btBroadphaseProxy.m_clientObject inline void SetNextFree(unsigned short next) {m_minEdges[0] = next;} inline unsigned short GetNextFree() const {return m_minEdges[0];} @@ -60,10 +60,10 @@ public: private: - SimdPoint3 m_worldAabbMin; // overall system bounds - SimdPoint3 m_worldAabbMax; // overall system bounds + btPoint3 m_worldAabbMin; // overall system bounds + btPoint3 m_worldAabbMax; // overall system bounds - SimdVector3 m_quantize; // scaling factor for quantization + btVector3 m_quantize; // scaling factor for quantization int m_numHandles; // number of active handles int m_maxHandles; // max number of handles @@ -83,7 +83,7 @@ private: //Overlap* AddOverlap(unsigned short handleA, unsigned short handleB); //void RemoveOverlap(unsigned short handleA, unsigned short handleB); - void Quantize(unsigned short* out, const SimdPoint3& point, int isMax) const; + void Quantize(unsigned short* out, const btPoint3& point, int isMax) const; void SortMinDown(int axis, unsigned short edge, bool updateOverlaps = true); void SortMinUp(int axis, unsigned short edge, bool updateOverlaps = true); @@ -91,24 +91,24 @@ private: void SortMaxUp(int axis, unsigned short edge, bool updateOverlaps = true); public: - AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAabbMax, int maxHandles = 16384); - virtual ~AxisSweep3(); + btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles = 16384); + virtual ~btAxisSweep3(); virtual void RefreshOverlappingPairs() { //this is replace by sweep and prune } - unsigned short AddHandle(const SimdPoint3& aabbMin,const SimdPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask); + unsigned short AddHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask); void RemoveHandle(unsigned short handle); - void UpdateHandle(unsigned short handle, const SimdPoint3& aabbMin,const SimdPoint3& aabbMax); + void UpdateHandle(unsigned short handle, const btPoint3& aabbMin,const btPoint3& aabbMax); inline Handle* GetHandle(unsigned short index) const {return m_pHandles + index;} //Broadphase Interface - virtual BroadphaseProxy* CreateProxy( const SimdVector3& min, const SimdVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask); - virtual void DestroyProxy(BroadphaseProxy* proxy); - virtual void SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const SimdVector3& aabbMax); + virtual btBroadphaseProxy* CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask); + virtual void DestroyProxy(btBroadphaseProxy* proxy); + virtual void SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax); }; diff --git a/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h b/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h index 8e5bab336..3dc2676e0 100644 --- a/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h +++ b/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h @@ -18,21 +18,21 @@ subject to the following restrictions: -struct DispatcherInfo; -class Dispatcher; -struct BroadphaseProxy; -#include "LinearMath/SimdVector3.h" +struct btDispatcherInfo; +class btDispatcher; +struct btBroadphaseProxy; +#include "LinearMath/btVector3.h" ///BroadphaseInterface for aabb-overlapping object pairs -class BroadphaseInterface +class btBroadphaseInterface { public: - virtual ~BroadphaseInterface() {} + virtual ~btBroadphaseInterface() {} - virtual BroadphaseProxy* CreateProxy( const SimdVector3& min, const SimdVector3& max,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) =0; - virtual void DestroyProxy(BroadphaseProxy* proxy)=0; - virtual void SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const SimdVector3& aabbMax)=0; - virtual void CleanProxyFromPairs(BroadphaseProxy* proxy)=0; + virtual btBroadphaseProxy* CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) =0; + virtual void DestroyProxy(btBroadphaseProxy* proxy)=0; + virtual void SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)=0; + virtual void CleanProxyFromPairs(btBroadphaseProxy* proxy)=0; }; diff --git a/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h b/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h index b26a2701d..510cad60b 100644 --- a/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h +++ b/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h @@ -18,7 +18,7 @@ subject to the following restrictions: -/// Dispatcher uses these types +/// btDispatcher uses these types /// IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and concave /// to facilitate type checking enum BroadphaseNativeTypes @@ -56,18 +56,18 @@ CONCAVE_SHAPES_END_HERE, ///BroadphaseProxy -struct BroadphaseProxy +struct btBroadphaseProxy { - //Usually the client CollisionObject or Rigidbody class + //Usually the client btCollisionObject or Rigidbody class void* m_clientObject; short int m_collisionFilterGroup; short int m_collisionFilterMask; //used for memory pools - BroadphaseProxy() :m_clientObject(0){} + btBroadphaseProxy() :m_clientObject(0){} - BroadphaseProxy(void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) + btBroadphaseProxy(void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :m_clientObject(userPtr), m_collisionFilterGroup(collisionFilterGroup), m_collisionFilterMask(collisionFilterMask) @@ -96,17 +96,17 @@ struct BroadphaseProxy }; -class CollisionAlgorithm; +class btCollisionAlgorithm; -struct BroadphaseProxy; +struct btBroadphaseProxy; -//Increase SIMPLE_MAX_ALGORITHMS to allow multiple Dispatchers caching their own algorithms +//Increase SIMPLE_MAX_ALGORITHMS to allow multiple btDispatchers caching their own algorithms #define SIMPLE_MAX_ALGORITHMS 1 /// contains a pair of aabb-overlapping objects -struct BroadphasePair +struct btBroadphasePair { - BroadphasePair () + btBroadphasePair () : m_pProxy0(0), m_pProxy1(0) @@ -117,7 +117,7 @@ struct BroadphasePair } } - BroadphasePair(const BroadphasePair& other) + btBroadphasePair(const btBroadphasePair& other) : m_pProxy0(other.m_pProxy0), m_pProxy1(other.m_pProxy1) { @@ -126,7 +126,7 @@ struct BroadphasePair m_algorithms[i] = other.m_algorithms[i]; } } - BroadphasePair(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) + btBroadphasePair(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) { //keep them sorted, so the std::set operations work @@ -148,15 +148,15 @@ struct BroadphasePair } - BroadphaseProxy* m_pProxy0; - BroadphaseProxy* m_pProxy1; + btBroadphaseProxy* m_pProxy0; + btBroadphaseProxy* m_pProxy1; - mutable CollisionAlgorithm* m_algorithms[SIMPLE_MAX_ALGORITHMS]; + mutable btCollisionAlgorithm* m_algorithms[SIMPLE_MAX_ALGORITHMS]; }; //comparison for set operation, see Solid DT_Encounter -inline bool operator<(const BroadphasePair& a, const BroadphasePair& b) +inline bool operator<(const btBroadphasePair& a, const btBroadphasePair& b) { return a.m_pProxy0 < b.m_pProxy0 || (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 < b.m_pProxy1); diff --git a/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp b/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp index c104fe86d..2ad0c86d8 100644 --- a/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp +++ b/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp @@ -16,7 +16,7 @@ subject to the following restrictions: #include "btCollisionAlgorithm.h" #include "btDispatcher.h" -CollisionAlgorithm::CollisionAlgorithm(const CollisionAlgorithmConstructionInfo& ci) +btCollisionAlgorithm::btCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) { m_dispatcher = ci.m_dispatcher; } diff --git a/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h b/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h index 9368a16f2..185ec23f4 100644 --- a/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h +++ b/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h @@ -16,50 +16,50 @@ subject to the following restrictions: #ifndef COLLISION_ALGORITHM_H #define COLLISION_ALGORITHM_H -struct BroadphaseProxy; -class Dispatcher; +struct btBroadphaseProxy; +class btDispatcher; -struct CollisionAlgorithmConstructionInfo +struct btCollisionAlgorithmConstructionInfo { - CollisionAlgorithmConstructionInfo() + btCollisionAlgorithmConstructionInfo() :m_dispatcher(0) { } - CollisionAlgorithmConstructionInfo(Dispatcher* dispatcher,int temp) + btCollisionAlgorithmConstructionInfo(btDispatcher* dispatcher,int temp) :m_dispatcher(dispatcher) { } - Dispatcher* m_dispatcher; + btDispatcher* m_dispatcher; int GetDispatcherId(); }; -///CollisionAlgorithm is an collision interface that is compatible with the Broadphase and Dispatcher. +///CollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatcher. ///It is persistent over frames -class CollisionAlgorithm +class btCollisionAlgorithm { protected: - Dispatcher* m_dispatcher; + btDispatcher* m_dispatcher; protected: int GetDispatcherId(); public: - CollisionAlgorithm() {}; + btCollisionAlgorithm() {}; - CollisionAlgorithm(const CollisionAlgorithmConstructionInfo& ci); + btCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci); - virtual ~CollisionAlgorithm() {}; + virtual ~btCollisionAlgorithm() {}; - virtual void ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const struct DispatcherInfo& dispatchInfo) = 0; + virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const struct btDispatcherInfo& dispatchInfo) = 0; - virtual float CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const struct DispatcherInfo& dispatchInfo) = 0; + virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const struct btDispatcherInfo& dispatchInfo) = 0; }; diff --git a/src/BulletCollision/BroadphaseCollision/btDispatcher.cpp b/src/BulletCollision/BroadphaseCollision/btDispatcher.cpp index cd392935f..20768225b 100644 --- a/src/BulletCollision/BroadphaseCollision/btDispatcher.cpp +++ b/src/BulletCollision/BroadphaseCollision/btDispatcher.cpp @@ -15,7 +15,7 @@ subject to the following restrictions: #include "btDispatcher.h" -Dispatcher::~Dispatcher() +btDispatcher::~btDispatcher() { } diff --git a/src/BulletCollision/BroadphaseCollision/btDispatcher.h b/src/BulletCollision/BroadphaseCollision/btDispatcher.h index 47a006f69..e481ba476 100644 --- a/src/BulletCollision/BroadphaseCollision/btDispatcher.h +++ b/src/BulletCollision/BroadphaseCollision/btDispatcher.h @@ -16,29 +16,29 @@ subject to the following restrictions: #ifndef _DISPATCHER_H #define _DISPATCHER_H -class CollisionAlgorithm; -struct BroadphaseProxy; -class RigidBody; -struct CollisionObject; -class ManifoldResult; -class OverlappingPairCache; +class btCollisionAlgorithm; +struct btBroadphaseProxy; +class btRigidBody; +struct btCollisionObject; +class btManifoldResult; +class btOverlappingPairCache; -enum CollisionDispatcherId +enum btCollisionDispatcherId { RIGIDBODY_DISPATCHER = 0, USERCALLBACK_DISPATCHER }; -class PersistentManifold; +class btPersistentManifold; -struct DispatcherInfo +struct btDispatcherInfo { enum DispatchFunc { DISPATCH_DISCRETE = 1, DISPATCH_CONTINUOUS }; - DispatcherInfo() + btDispatcherInfo() :m_dispatchFunc(DISPATCH_DISCRETE), m_timeOfImpact(1.f), m_useContinuous(false), @@ -52,46 +52,46 @@ struct DispatcherInfo int m_dispatchFunc; float m_timeOfImpact; bool m_useContinuous; - class IDebugDraw* m_debugDraw; + class btIDebugDraw* m_debugDraw; bool m_enableSatConvex; }; -/// Dispatcher can be used in combination with broadphase to dispatch overlapping pairs. +/// btDispatcher can be used in combination with broadphase to dispatch overlapping pairs. /// For example for pairwise collision detection or user callbacks (game logic). -class Dispatcher +class btDispatcher { public: - virtual ~Dispatcher() ; + virtual ~btDispatcher() ; - virtual CollisionAlgorithm* FindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) = 0; + virtual btCollisionAlgorithm* FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) = 0; // // asume dispatchers to have unique id's in the range [0..max dispacher] // virtual int GetUniqueId() = 0; - virtual PersistentManifold* GetNewManifold(void* body0,void* body1)=0; + virtual btPersistentManifold* GetNewManifold(void* body0,void* body1)=0; - virtual void ReleaseManifold(PersistentManifold* manifold)=0; + virtual void ReleaseManifold(btPersistentManifold* manifold)=0; - virtual void ClearManifold(PersistentManifold* manifold)=0; + virtual void ClearManifold(btPersistentManifold* manifold)=0; - virtual bool NeedsCollision(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) = 0; + virtual bool NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) = 0; - virtual bool NeedsResponse(const CollisionObject& colObj0,const CollisionObject& colObj1)=0; + virtual bool NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1)=0; - virtual ManifoldResult* GetNewManifoldResult(CollisionObject* obj0,CollisionObject* obj1,PersistentManifold* manifold) =0; + virtual btManifoldResult* GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold) =0; - virtual void ReleaseManifoldResult(ManifoldResult*)=0; + virtual void ReleaseManifoldResult(btManifoldResult*)=0; - virtual void DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo)=0; + virtual void DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo)=0; virtual int GetNumManifolds() const = 0; - virtual PersistentManifold* GetManifoldByIndexInternal(int index) = 0; + virtual btPersistentManifold* GetManifoldByIndexInternal(int index) = 0; }; diff --git a/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp b/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp index 01c306dbb..e168d6d9e 100644 --- a/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp +++ b/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp @@ -23,36 +23,36 @@ subject to the following restrictions: int gOverlappingPairs = 0; -OverlappingPairCache::OverlappingPairCache(): +btOverlappingPairCache::btOverlappingPairCache(): m_blockedForChanges(false) //m_NumOverlapBroadphasePair(0) { } -OverlappingPairCache::~OverlappingPairCache() +btOverlappingPairCache::~btOverlappingPairCache() { //todo/test: show we erase/delete data, or is it automatic } -void OverlappingPairCache::RemoveOverlappingPair(BroadphasePair& findPair) +void btOverlappingPairCache::RemoveOverlappingPair(btBroadphasePair& findPair) { - std::set::iterator it = m_overlappingPairSet.find(findPair); + std::set::iterator it = m_overlappingPairSet.find(findPair); // assert(it != m_overlappingPairSet.end()); if (it != m_overlappingPairSet.end()) { gOverlappingPairs--; - BroadphasePair* pair = (BroadphasePair*)(&(*it)); + btBroadphasePair* pair = (btBroadphasePair*)(&(*it)); CleanOverlappingPair(*pair); m_overlappingPairSet.erase(it); } } -void OverlappingPairCache::CleanOverlappingPair(BroadphasePair& pair) +void btOverlappingPairCache::CleanOverlappingPair(btBroadphasePair& pair) { for (int dispatcherId=0;dispatcherId::iterator it = m_overlappingPairSet.find(tmpPair); + btBroadphasePair tmpPair(*proxy0,*proxy1); + std::set::iterator it = m_overlappingPairSet.find(tmpPair); if ((it == m_overlappingPairSet.end())) return 0; //assert(it != m_overlappingPairSet.end()); - BroadphasePair* pair = (BroadphasePair*)(&(*it)); + btBroadphasePair* pair = (btBroadphasePair*)(&(*it)); return pair; } @@ -109,21 +109,21 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase -void OverlappingPairCache::CleanProxyFromPairs(BroadphaseProxy* proxy) +void btOverlappingPairCache::CleanProxyFromPairs(btBroadphaseProxy* proxy) { - class CleanPairCallback : public OverlapCallback + class CleanPairCallback : public btOverlapCallback { - BroadphaseProxy* m_cleanProxy; - OverlappingPairCache* m_pairCache; + btBroadphaseProxy* m_cleanProxy; + btOverlappingPairCache* m_pairCache; public: - CleanPairCallback(BroadphaseProxy* cleanProxy,OverlappingPairCache* pairCache) + CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache) :m_cleanProxy(cleanProxy), m_pairCache(pairCache) { } - virtual bool ProcessOverlap(BroadphasePair& pair) + virtual bool ProcessOverlap(btBroadphasePair& pair) { if ((pair.m_pProxy0 == m_cleanProxy) || (pair.m_pProxy1 == m_cleanProxy)) @@ -143,19 +143,19 @@ void OverlappingPairCache::CleanProxyFromPairs(BroadphaseProxy* proxy) -void OverlappingPairCache::RemoveOverlappingPairsContainingProxy(BroadphaseProxy* proxy) +void btOverlappingPairCache::RemoveOverlappingPairsContainingProxy(btBroadphaseProxy* proxy) { - class RemovePairCallback : public OverlapCallback + class RemovePairCallback : public btOverlapCallback { - BroadphaseProxy* m_obsoleteProxy; + btBroadphaseProxy* m_obsoleteProxy; public: - RemovePairCallback(BroadphaseProxy* obsoleteProxy) + RemovePairCallback(btBroadphaseProxy* obsoleteProxy) :m_obsoleteProxy(obsoleteProxy) { } - virtual bool ProcessOverlap(BroadphasePair& pair) + virtual bool ProcessOverlap(btBroadphasePair& pair) { return ((pair.m_pProxy0 == m_obsoleteProxy) || (pair.m_pProxy1 == m_obsoleteProxy)); @@ -171,18 +171,18 @@ void OverlappingPairCache::RemoveOverlappingPairsContainingProxy(BroadphaseProxy -void OverlappingPairCache::ProcessAllOverlappingPairs(OverlapCallback* callback) +void btOverlappingPairCache::ProcessAllOverlappingPairs(btOverlapCallback* callback) { - std::set::iterator it = m_overlappingPairSet.begin(); + std::set::iterator it = m_overlappingPairSet.begin(); for (; !(it==m_overlappingPairSet.end());) { - BroadphasePair* pair = (BroadphasePair*)(&(*it)); + btBroadphasePair* pair = (btBroadphasePair*)(&(*it)); if (callback->ProcessOverlap(*pair)) { CleanOverlappingPair(*pair); - std::set::iterator it2 = it; + std::set::iterator it2 = it; //why does next line not compile under OS X?? #ifdef MAC_OSX_FIXED_STL_SET it2++; diff --git a/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h b/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h index eadac3b36..a92ec70dd 100644 --- a/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h +++ b/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h @@ -20,51 +20,51 @@ subject to the following restrictions: #include "btBroadphaseInterface.h" #include "btBroadphaseProxy.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btPoint3.h" #include -struct OverlapCallback +struct btOverlapCallback { -virtual ~OverlapCallback() +virtual ~btOverlapCallback() { } //return true for deletion of the pair - virtual bool ProcessOverlap(BroadphasePair& pair) = 0; + virtual bool ProcessOverlap(btBroadphasePair& pair) = 0; }; ///OverlappingPairCache maintains the objects with overlapping AABB -///Typically managed by the Broadphase, Axis3Sweep or SimpleBroadphase -class OverlappingPairCache : public BroadphaseInterface +///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase +class btOverlappingPairCache : public btBroadphaseInterface { //avoid brute-force finding all the time - std::set m_overlappingPairSet; + std::set m_overlappingPairSet; //during the dispatch, check that user doesn't destroy/create proxy bool m_blockedForChanges; public: - OverlappingPairCache(); - virtual ~OverlappingPairCache(); + btOverlappingPairCache(); + virtual ~btOverlappingPairCache(); - void ProcessAllOverlappingPairs(OverlapCallback*); + void ProcessAllOverlappingPairs(btOverlapCallback*); - void RemoveOverlappingPair(BroadphasePair& pair); + void RemoveOverlappingPair(btBroadphasePair& pair); - void CleanOverlappingPair(BroadphasePair& pair); + void CleanOverlappingPair(btBroadphasePair& pair); - void AddOverlappingPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1); + void AddOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - BroadphasePair* FindPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1); + btBroadphasePair* FindPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - void CleanProxyFromPairs(BroadphaseProxy* proxy); + void CleanProxyFromPairs(btBroadphaseProxy* proxy); - void RemoveOverlappingPairsContainingProxy(BroadphaseProxy* proxy); + void RemoveOverlappingPairsContainingProxy(btBroadphaseProxy* proxy); - inline bool NeedsCollision(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) const + inline bool NeedsCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const { bool collides = proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask; collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask); diff --git a/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp b/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp index af8fe8a3c..bb8cd18ae 100644 --- a/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp +++ b/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp @@ -17,13 +17,13 @@ subject to the following restrictions: #include #include -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdTransform.h" -#include "LinearMath/SimdMatrix3x3.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btTransform.h" +#include "LinearMath/btMatrix3x3.h" #include -void SimpleBroadphase::validate() +void btSimpleBroadphase::validate() { for (int i=0;i= m_maxProxies) { @@ -80,10 +80,10 @@ BroadphaseProxy* SimpleBroadphase::CreateProxy( const SimdVector3& min, const assert(min[0]<= max[0] && min[1]<= max[1] && min[2]<= max[2]); int freeIndex= m_freeProxies[m_firstFreeProxy]; - SimpleBroadphaseProxy* proxy = new (&m_proxies[freeIndex])SimpleBroadphaseProxy(min,max,shapeType,userPtr,collisionFilterGroup,collisionFilterMask); + btSimpleBroadphaseProxy* proxy = new (&m_proxies[freeIndex])btSimpleBroadphaseProxy(min,max,shapeType,userPtr,collisionFilterGroup,collisionFilterMask); m_firstFreeProxy++; - SimpleBroadphaseProxy* proxy1 = &m_proxies[0]; + btSimpleBroadphaseProxy* proxy1 = &m_proxies[0]; int index = proxy - proxy1; assert(index == freeIndex); @@ -95,10 +95,10 @@ BroadphaseProxy* SimpleBroadphase::CreateProxy( const SimdVector3& min, const return proxy; } -class RemovingOverlapCallback : public OverlapCallback +class RemovingOverlapCallback : public btOverlapCallback { protected: - virtual bool ProcessOverlap(BroadphasePair& pair) + virtual bool ProcessOverlap(btBroadphasePair& pair) { assert(0); } @@ -107,28 +107,28 @@ protected: class RemovePairContainingProxy { - BroadphaseProxy* m_targetProxy; + btBroadphaseProxy* m_targetProxy; public: virtual ~RemovePairContainingProxy() { } protected: - virtual bool ProcessOverlap(BroadphasePair& pair) + virtual bool ProcessOverlap(btBroadphasePair& pair) { - SimpleBroadphaseProxy* proxy0 = static_cast(pair.m_pProxy0); - SimpleBroadphaseProxy* proxy1 = static_cast(pair.m_pProxy1); + btSimpleBroadphaseProxy* proxy0 = static_cast(pair.m_pProxy0); + btSimpleBroadphaseProxy* proxy1 = static_cast(pair.m_pProxy1); return ((m_targetProxy == proxy0 || m_targetProxy == proxy1)); }; }; -void SimpleBroadphase::DestroyProxy(BroadphaseProxy* proxyOrg) +void btSimpleBroadphase::DestroyProxy(btBroadphaseProxy* proxyOrg) { int i; - SimpleBroadphaseProxy* proxy0 = static_cast(proxyOrg); - SimpleBroadphaseProxy* proxy1 = &m_proxies[0]; + btSimpleBroadphaseProxy* proxy0 = static_cast(proxyOrg); + btSimpleBroadphaseProxy* proxy1 = &m_proxies[0]; int index = proxy0 - proxy1; assert (index < m_maxProxies); @@ -140,10 +140,10 @@ void SimpleBroadphase::DestroyProxy(BroadphaseProxy* proxyOrg) //then remove non-overlapping ones /*for (i=0;im_min = aabbMin; sbp->m_max = aabbMax; } @@ -182,7 +182,7 @@ void SimpleBroadphase::SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin -bool SimpleBroadphase::AabbOverlap(SimpleBroadphaseProxy* proxy0,SimpleBroadphaseProxy* proxy1) +bool btSimpleBroadphase::AabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1) { return proxy0->m_min[0] <= proxy1->m_max[0] && proxy1->m_min[0] <= proxy0->m_max[0] && proxy0->m_min[1] <= proxy1->m_max[1] && proxy1->m_min[1] <= proxy0->m_max[1] && @@ -193,28 +193,28 @@ bool SimpleBroadphase::AabbOverlap(SimpleBroadphaseProxy* proxy0,SimpleBroadphas //then remove non-overlapping ones -class CheckOverlapCallback : public OverlapCallback +class CheckOverlapCallback : public btOverlapCallback { public: - virtual bool ProcessOverlap(BroadphasePair& pair) + virtual bool ProcessOverlap(btBroadphasePair& pair) { - return (!SimpleBroadphase::AabbOverlap(static_cast(pair.m_pProxy0),static_cast(pair.m_pProxy1))); + return (!btSimpleBroadphase::AabbOverlap(static_cast(pair.m_pProxy0),static_cast(pair.m_pProxy1))); } }; -void SimpleBroadphase::RefreshOverlappingPairs() +void btSimpleBroadphase::RefreshOverlappingPairs() { //first check for new overlapping pairs int i,j; for (i=0;i(proxy); + btSimpleBroadphaseProxy* proxy0 = static_cast(proxy); return proxy0; } @@ -66,18 +66,18 @@ protected: virtual void RefreshOverlappingPairs(); public: - SimpleBroadphase(int maxProxies=16384); - virtual ~SimpleBroadphase(); + btSimpleBroadphase(int maxProxies=16384); + virtual ~btSimpleBroadphase(); - static bool AabbOverlap(SimpleBroadphaseProxy* proxy0,SimpleBroadphaseProxy* proxy1); + static bool AabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1); - virtual BroadphaseProxy* CreateProxy( const SimdVector3& min, const SimdVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask); + virtual btBroadphaseProxy* CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask); - virtual void DestroyProxy(BroadphaseProxy* proxy); - virtual void SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const SimdVector3& aabbMax); + virtual void DestroyProxy(btBroadphaseProxy* proxy); + virtual void SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax); diff --git a/src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h b/src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h index d86948bec..a051dbb05 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h +++ b/src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h @@ -18,23 +18,23 @@ subject to the following restrictions: #include -typedef std::vector CollisionObjectArray; -class CollisionAlgorithm; -struct BroadphaseProxy; -struct CollisionAlgorithmConstructionInfo; +typedef std::vector btCollisionObjectArray; +class btCollisionAlgorithm; +struct btBroadphaseProxy; +struct btCollisionAlgorithmConstructionInfo; -struct CollisionAlgorithmCreateFunc +struct btCollisionAlgorithmCreateFunc { bool m_swapped; - CollisionAlgorithmCreateFunc() + btCollisionAlgorithmCreateFunc() :m_swapped(false) { } - virtual ~CollisionAlgorithmCreateFunc(){}; + virtual ~btCollisionAlgorithmCreateFunc(){}; - virtual CollisionAlgorithm* CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo& ci, BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) { return 0; } diff --git a/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp b/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp index 50cb74064..38c59ecf9 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp +++ b/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp @@ -33,7 +33,7 @@ int gNumManifold = 0; -CollisionDispatcher::CollisionDispatcher (): +btCollisionDispatcher::btCollisionDispatcher (): m_useIslands(true), m_defaultManifoldResult(0,0,0), m_count(0) @@ -41,12 +41,12 @@ CollisionDispatcher::CollisionDispatcher (): int i; //default CreationFunctions, filling the m_doubleDispatch table - m_convexConvexCreateFunc = new ConvexConvexAlgorithm::CreateFunc; - m_convexConcaveCreateFunc = new ConvexConcaveCollisionAlgorithm::CreateFunc; - m_swappedConvexConcaveCreateFunc = new ConvexConcaveCollisionAlgorithm::SwappedCreateFunc; - m_compoundCreateFunc = new CompoundCollisionAlgorithm::CreateFunc; - m_swappedCompoundCreateFunc = new CompoundCollisionAlgorithm::SwappedCreateFunc; - m_emptyCreateFunc = new EmptyAlgorithm::CreateFunc; + m_convexConvexCreateFunc = new btConvexConvexAlgorithm::CreateFunc; + m_convexConcaveCreateFunc = new btConvexConcaveCollisionAlgorithm::CreateFunc; + m_swappedConvexConcaveCreateFunc = new btConvexConcaveCollisionAlgorithm::SwappedCreateFunc; + m_compoundCreateFunc = new btCompoundCollisionAlgorithm::CreateFunc; + m_swappedCompoundCreateFunc = new btCompoundCollisionAlgorithm::SwappedCreateFunc; + m_emptyCreateFunc = new btEmptyAlgorithm::CreateFunc; for (i=0;iClearManifold(); } -void CollisionDispatcher::ReleaseManifold(PersistentManifold* manifold) +void btCollisionDispatcher::ReleaseManifold(btPersistentManifold* manifold) { gNumManifold--; @@ -106,7 +106,7 @@ void CollisionDispatcher::ReleaseManifold(PersistentManifold* manifold) ClearManifold(manifold); - std::vector::iterator i = + std::vector::iterator i = std::find(m_manifoldsPtr.begin(), m_manifoldsPtr.end(), manifold); if (!(i == m_manifoldsPtr.end())) { @@ -121,47 +121,47 @@ void CollisionDispatcher::ReleaseManifold(PersistentManifold* manifold) -CollisionAlgorithm* CollisionDispatcher::FindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) +btCollisionAlgorithm* btCollisionDispatcher::FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) { #define USE_DISPATCH_REGISTRY_ARRAY 1 #ifdef USE_DISPATCH_REGISTRY_ARRAY - CollisionObject* body0 = (CollisionObject*)proxy0.m_clientObject; - CollisionObject* body1 = (CollisionObject*)proxy1.m_clientObject; - CollisionAlgorithmConstructionInfo ci; + btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject; + btCollisionObject* body1 = (btCollisionObject*)proxy1.m_clientObject; + btCollisionAlgorithmConstructionInfo ci; ci.m_dispatcher = this; - CollisionAlgorithm* algo = m_doubleDispatch[body0->m_collisionShape->GetShapeType()][body1->m_collisionShape->GetShapeType()] + btCollisionAlgorithm* algo = m_doubleDispatch[body0->m_collisionShape->GetShapeType()][body1->m_collisionShape->GetShapeType()] ->CreateCollisionAlgorithm(ci,&proxy0,&proxy1); #else - CollisionAlgorithm* algo = InternalFindAlgorithm(proxy0,proxy1); + btCollisionAlgorithm* algo = InternalFindAlgorithm(proxy0,proxy1); #endif //USE_DISPATCH_REGISTRY_ARRAY return algo; } -CollisionAlgorithmCreateFunc* CollisionDispatcher::InternalFindCreateFunc(int proxyType0,int proxyType1) +btCollisionAlgorithmCreateFunc* btCollisionDispatcher::InternalFindCreateFunc(int proxyType0,int proxyType1) { - if (BroadphaseProxy::IsConvex(proxyType0) && BroadphaseProxy::IsConvex(proxyType1)) + if (btBroadphaseProxy::IsConvex(proxyType0) && btBroadphaseProxy::IsConvex(proxyType1)) { return m_convexConvexCreateFunc; } - if (BroadphaseProxy::IsConvex(proxyType0) && BroadphaseProxy::IsConcave(proxyType1)) + if (btBroadphaseProxy::IsConvex(proxyType0) && btBroadphaseProxy::IsConcave(proxyType1)) { return m_convexConcaveCreateFunc; } - if (BroadphaseProxy::IsConvex(proxyType1) && BroadphaseProxy::IsConcave(proxyType0)) + if (btBroadphaseProxy::IsConvex(proxyType1) && btBroadphaseProxy::IsConcave(proxyType0)) { return m_swappedConvexConcaveCreateFunc; } - if (BroadphaseProxy::IsCompound(proxyType0)) + if (btBroadphaseProxy::IsCompound(proxyType0)) { return m_compoundCreateFunc; } else { - if (BroadphaseProxy::IsCompound(proxyType1)) + if (btBroadphaseProxy::IsCompound(proxyType1)) { return m_swappedCompoundCreateFunc; } @@ -173,72 +173,72 @@ CollisionAlgorithmCreateFunc* CollisionDispatcher::InternalFindCreateFunc(int pr -CollisionAlgorithm* CollisionDispatcher::InternalFindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) +btCollisionAlgorithm* btCollisionDispatcher::InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) { m_count++; - CollisionObject* body0 = (CollisionObject*)proxy0.m_clientObject; - CollisionObject* body1 = (CollisionObject*)proxy1.m_clientObject; + btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject; + btCollisionObject* body1 = (btCollisionObject*)proxy1.m_clientObject; - CollisionAlgorithmConstructionInfo ci; + btCollisionAlgorithmConstructionInfo ci; ci.m_dispatcher = this; if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConvex() ) { - return new ConvexConvexAlgorithm(0,ci,&proxy0,&proxy1); + return new btConvexConvexAlgorithm(0,ci,&proxy0,&proxy1); } if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConcave()) { - return new ConvexConcaveCollisionAlgorithm(ci,&proxy0,&proxy1); + return new btConvexConcaveCollisionAlgorithm(ci,&proxy0,&proxy1); } if (body1->m_collisionShape->IsConvex() && body0->m_collisionShape->IsConcave()) { - return new ConvexConcaveCollisionAlgorithm(ci,&proxy1,&proxy0); + return new btConvexConcaveCollisionAlgorithm(ci,&proxy1,&proxy0); } if (body0->m_collisionShape->IsCompound()) { - return new CompoundCollisionAlgorithm(ci,&proxy0,&proxy1); + return new btCompoundCollisionAlgorithm(ci,&proxy0,&proxy1); } else { if (body1->m_collisionShape->IsCompound()) { - return new CompoundCollisionAlgorithm(ci,&proxy1,&proxy0); + return new btCompoundCollisionAlgorithm(ci,&proxy1,&proxy0); } } //failed to find an algorithm - return new EmptyAlgorithm(ci); + return new btEmptyAlgorithm(ci); } -bool CollisionDispatcher::NeedsResponse(const CollisionObject& colObj0,const CollisionObject& colObj1) +bool btCollisionDispatcher::NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1) { //here you can do filtering bool hasResponse = - (!(colObj0.m_collisionFlags & CollisionObject::noContactResponse)) && - (!(colObj1.m_collisionFlags & CollisionObject::noContactResponse)); + (!(colObj0.m_collisionFlags & btCollisionObject::noContactResponse)) && + (!(colObj1.m_collisionFlags & btCollisionObject::noContactResponse)); hasResponse = hasResponse && (colObj0.IsActive() || colObj1.IsActive()); return hasResponse; } -bool CollisionDispatcher::NeedsCollision(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) +bool btCollisionDispatcher::NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) { - CollisionObject* body0 = (CollisionObject*)proxy0.m_clientObject; - CollisionObject* body1 = (CollisionObject*)proxy1.m_clientObject; + btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject; + btCollisionObject* body1 = (btCollisionObject*)proxy1.m_clientObject; assert(body0); assert(body1); bool needsCollision = true; - if ((body0->m_collisionFlags & CollisionObject::isStatic) && - (body1->m_collisionFlags & CollisionObject::isStatic)) + if ((body0->m_collisionFlags & btCollisionObject::isStatic) && + (body1->m_collisionFlags & btCollisionObject::isStatic)) needsCollision = false; if ((!body0->IsActive()) && (!body1->IsActive())) @@ -249,37 +249,37 @@ bool CollisionDispatcher::NeedsCollision(BroadphaseProxy& proxy0,BroadphaseProxy } ///allows the user to get contact point callbacks -ManifoldResult* CollisionDispatcher::GetNewManifoldResult(CollisionObject* obj0,CollisionObject* obj1,PersistentManifold* manifold) +btManifoldResult* btCollisionDispatcher::GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold) { //in-place, this prevents parallel dispatching, but just adding a list would fix that. - ManifoldResult* manifoldResult = new (&m_defaultManifoldResult) ManifoldResult(obj0,obj1,manifold); + btManifoldResult* manifoldResult = new (&m_defaultManifoldResult) btManifoldResult(obj0,obj1,manifold); return manifoldResult; } ///allows the user to get contact point callbacks -void CollisionDispatcher::ReleaseManifoldResult(ManifoldResult*) +void btCollisionDispatcher::ReleaseManifoldResult(btManifoldResult*) { } -class CollisionPairCallback : public OverlapCallback +class CollisionPairCallback : public btOverlapCallback { - DispatcherInfo& m_dispatchInfo; - CollisionDispatcher* m_dispatcher; + btDispatcherInfo& m_dispatchInfo; + btCollisionDispatcher* m_dispatcher; int m_dispatcherId; public: - CollisionPairCallback(DispatcherInfo& dispatchInfo,CollisionDispatcher* dispatcher,int dispatcherId) + CollisionPairCallback(btDispatcherInfo& dispatchInfo,btCollisionDispatcher* dispatcher,int dispatcherId) :m_dispatchInfo(dispatchInfo), m_dispatcher(dispatcher), m_dispatcherId(dispatcherId) { } - virtual bool ProcessOverlap(BroadphasePair& pair) + virtual bool ProcessOverlap(btBroadphasePair& pair) { if (m_dispatcherId>= 0) { @@ -293,7 +293,7 @@ public: if (pair.m_algorithms[m_dispatcherId]) { - if (m_dispatchInfo.m_dispatchFunc == DispatcherInfo::DISPATCH_DISCRETE) + if (m_dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) { pair.m_algorithms[m_dispatcherId]->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo); } else @@ -307,13 +307,13 @@ public: } else { //non-persistent algorithm dispatcher - CollisionAlgorithm* algo = m_dispatcher->FindAlgorithm( + btCollisionAlgorithm* algo = m_dispatcher->FindAlgorithm( *pair.m_pProxy0, *pair.m_pProxy1); if (algo) { - if (m_dispatchInfo.m_dispatchFunc == DispatcherInfo::DISPATCH_DISCRETE) + if (m_dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) { algo->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo); } else @@ -330,7 +330,7 @@ public: }; -void CollisionDispatcher::DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo) +void btCollisionDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo) { //m_blockedForChanges = true; diff --git a/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h b/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h index f3641b431..52946a876 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h +++ b/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h @@ -24,8 +24,8 @@ subject to the following restrictions: #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -class IDebugDraw; -class OverlappingPairCache; +class btIDebugDraw; +class btOverlappingPairCache; #include "btCollisionCreateFunc.h" @@ -35,77 +35,82 @@ class OverlappingPairCache; ///CollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs. ///Time of Impact, Closest Points and Penetration Depth. -class CollisionDispatcher : public Dispatcher +class btCollisionDispatcher : public btDispatcher { - std::vector m_manifoldsPtr; + std::vector m_manifoldsPtr; bool m_useIslands; - ManifoldResult m_defaultManifoldResult; + btManifoldResult m_defaultManifoldResult; - CollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; + btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; - CollisionAlgorithmCreateFunc* InternalFindCreateFunc(int proxyType0,int proxyType1); + btCollisionAlgorithmCreateFunc* InternalFindCreateFunc(int proxyType0,int proxyType1); //default CreationFunctions, filling the m_doubleDispatch table - CollisionAlgorithmCreateFunc* m_convexConvexCreateFunc; - CollisionAlgorithmCreateFunc* m_convexConcaveCreateFunc; - CollisionAlgorithmCreateFunc* m_swappedConvexConcaveCreateFunc; - CollisionAlgorithmCreateFunc* m_compoundCreateFunc; - CollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc; - CollisionAlgorithmCreateFunc* m_emptyCreateFunc; + btCollisionAlgorithmCreateFunc* m_convexConvexCreateFunc; + btCollisionAlgorithmCreateFunc* m_convexConcaveCreateFunc; + btCollisionAlgorithmCreateFunc* m_swappedConvexConcaveCreateFunc; + btCollisionAlgorithmCreateFunc* m_compoundCreateFunc; + btCollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc; + btCollisionAlgorithmCreateFunc* m_emptyCreateFunc; public: ///RegisterCollisionCreateFunc allows registration of custom/alternative collision create functions - void RegisterCollisionCreateFunc(int proxyType0,int proxyType1, CollisionAlgorithmCreateFunc* createFunc); + void RegisterCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc); int GetNumManifolds() const { return m_manifoldsPtr.size(); } - PersistentManifold* GetManifoldByIndexInternal(int index) + btPersistentManifold** getInternalManifoldPointer() + { + return &m_manifoldsPtr[0]; + } + + btPersistentManifold* GetManifoldByIndexInternal(int index) { return m_manifoldsPtr[index]; } - const PersistentManifold* GetManifoldByIndexInternal(int index) const + const btPersistentManifold* GetManifoldByIndexInternal(int index) const { return m_manifoldsPtr[index]; } int m_count; - CollisionDispatcher (); - virtual ~CollisionDispatcher(); + btCollisionDispatcher (); + virtual ~btCollisionDispatcher(); - virtual PersistentManifold* GetNewManifold(void* b0,void* b1); + virtual btPersistentManifold* GetNewManifold(void* b0,void* b1); - virtual void ReleaseManifold(PersistentManifold* manifold); + virtual void ReleaseManifold(btPersistentManifold* manifold); ///allows the user to get contact point callbacks - virtual ManifoldResult* GetNewManifoldResult(CollisionObject* obj0,CollisionObject* obj1,PersistentManifold* manifold); + virtual btManifoldResult* GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold); ///allows the user to get contact point callbacks - virtual void ReleaseManifoldResult(ManifoldResult*); + virtual void ReleaseManifoldResult(btManifoldResult*); - virtual void ClearManifold(PersistentManifold* manifold); + virtual void ClearManifold(btPersistentManifold* manifold); - CollisionAlgorithm* FindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1); + btCollisionAlgorithm* FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); - CollisionAlgorithm* InternalFindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1); + btCollisionAlgorithm* InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); - virtual bool NeedsCollision(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1); + virtual bool NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); - virtual bool NeedsResponse(const CollisionObject& colObj0,const CollisionObject& colObj1); + virtual bool NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1); virtual int GetUniqueId() { return RIGIDBODY_DISPATCHER;} - virtual void DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo); + virtual void DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo); diff --git a/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp b/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp index fb0be6f22..69831b68b 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp +++ b/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp @@ -15,7 +15,7 @@ subject to the following restrictions: #include "btCollisionObject.h" -CollisionObject::CollisionObject() +btCollisionObject::btCollisionObject() : m_collisionFlags(0), m_activationState1(1), m_deactivationTime(0.f), @@ -30,18 +30,18 @@ CollisionObject::CollisionObject() } -void CollisionObject::SetActivationState(int newState) +void btCollisionObject::SetActivationState(int newState) { if ( (m_activationState1 != DISABLE_DEACTIVATION) && (m_activationState1 != DISABLE_SIMULATION)) m_activationState1 = newState; } -void CollisionObject::ForceActivationState(int newState) +void btCollisionObject::ForceActivationState(int newState) { m_activationState1 = newState; } -void CollisionObject::activate() +void btCollisionObject::activate() { if (!(m_collisionFlags & isStatic)) { @@ -50,8 +50,8 @@ void CollisionObject::activate() } } -bool CollisionObject::mergesSimulationIslands() const +bool btCollisionObject::mergesSimulationIslands() const { //static objects, and object without contact response don't merge islands - return ( !(m_collisionFlags & (isStatic |noContactResponse ))); + return ( !(m_collisionFlags & (isStatic | noContactResponse))); } diff --git a/src/BulletCollision/CollisionDispatch/btCollisionObject.h b/src/BulletCollision/CollisionDispatch/btCollisionObject.h index 96ecb1e3f..f9b4c22fb 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionObject.h +++ b/src/BulletCollision/CollisionDispatch/btCollisionObject.h @@ -16,7 +16,7 @@ subject to the following restrictions: #ifndef COLLISION_OBJECT_H #define COLLISION_OBJECT_H -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btTransform.h" //island management, m_activationState1 #define ACTIVE_TAG 1 @@ -25,23 +25,23 @@ subject to the following restrictions: #define DISABLE_DEACTIVATION 4 #define DISABLE_SIMULATION 5 -struct BroadphaseProxy; -class CollisionShape; +struct btBroadphaseProxy; +class btCollisionShape; -/// CollisionObject can be used to manage collision detection objects. -/// CollisionObject maintains all information that is needed for a collision detection: Shape, Transform and AABB proxy. -/// They can be added to the CollisionWorld. -struct CollisionObject +/// btCollisionObject can be used to manage collision detection objects. +/// btCollisionObject maintains all information that is needed for a collision detection: Shape, Transform and AABB proxy. +/// They can be added to the btCollisionWorld. +struct btCollisionObject { - SimdTransform m_worldTransform; + btTransform m_worldTransform; BroadphaseProxy* m_broadphaseHandle; CollisionShape* m_collisionShape; //m_interpolationWorldTransform is used for CCD and interpolation //it can be either previous or future (predicted) transform - SimdTransform m_interpolationWorldTransform; + btTransform m_interpolationWorldTransform; - SimdTransform m_cachedInvertedWorldTransform; + btTransform m_cachedInvertedWorldTransform; enum CollisionFlags { @@ -56,10 +56,8 @@ struct CollisionObject int m_activationState1; float m_deactivationTime; - SimdScalar m_friction; - SimdScalar m_restitution; - - + btScalar m_friction; + btScalar m_restitution; //users can point to their objects, m_userPointer is not used by Bullet void* m_userObjectPointer; @@ -70,7 +68,7 @@ struct CollisionObject ///time of impact calculation float m_hitFraction; - ///Swept sphere radius (0.0 by default), see ConvexConvexAlgorithm:: + ///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm:: float m_ccdSweptShereRadius; /// Don't do continuous collision detection if square motion (in one step) is less then m_ccdSquareMotionTreshold @@ -89,10 +87,10 @@ struct CollisionObject - CollisionObject(); + btCollisionObject(); - void SetCollisionShape(CollisionShape* collisionShape) + void SetCollisionShape(btCollisionShape* collisionShape) { m_collisionShape = collisionShape; } diff --git a/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp b/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp index 21e26aa60..2b3b5d6de 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp +++ b/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp @@ -24,22 +24,22 @@ subject to the following restrictions: #include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" -#include "LinearMath/GenAabbUtil2.h" +#include "LinearMath/btAabbUtil2.h" #include -CollisionWorld::~CollisionWorld() +btCollisionWorld::~btCollisionWorld() { //clean up remaining objects - std::vector::iterator i; + std::vector::iterator i; for (i=m_collisionObjects.begin(); !(i==m_collisionObjects.end()); i++) { - CollisionObject* collisionObject= (*i); + btCollisionObject* collisionObject= (*i); - BroadphaseProxy* bp = collisionObject->m_broadphaseHandle; + btBroadphaseProxy* bp = collisionObject->m_broadphaseHandle; if (bp) { // @@ -61,15 +61,15 @@ CollisionWorld::~CollisionWorld() -void CollisionWorld::AddCollisionObject(CollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask) +void btCollisionWorld::AddCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask) { m_collisionObjects.push_back(collisionObject); //calculate new AABB - SimdTransform trans = collisionObject->m_worldTransform; + btTransform trans = collisionObject->m_worldTransform; - SimdVector3 minAabb; - SimdVector3 maxAabb; + btVector3 minAabb; + btVector3 maxAabb; collisionObject->m_collisionShape->GetAabb(trans,minAabb,maxAabb); int type = collisionObject->m_collisionShape->GetShapeType(); @@ -87,15 +87,15 @@ void CollisionWorld::AddCollisionObject(CollisionObject* collisionObject,short i } -void CollisionWorld::PerformDiscreteCollisionDetection() +void btCollisionWorld::PerformDiscreteCollisionDetection() { - DispatcherInfo dispatchInfo; + btDispatcherInfo dispatchInfo; dispatchInfo.m_timeStep = 0.f; dispatchInfo.m_stepCount = 0; //update aabb (of all moved objects) - SimdVector3 aabbMin,aabbMax; + btVector3 aabbMin,aabbMax; for (size_t i=0;im_cachedInvertedWorldTransform = m_collisionObjects[i]->m_worldTransform.inverse(); @@ -105,14 +105,14 @@ void CollisionWorld::PerformDiscreteCollisionDetection() m_pairCache->RefreshOverlappingPairs(); - Dispatcher* dispatcher = GetDispatcher(); + btDispatcher* dispatcher = GetDispatcher(); if (dispatcher) dispatcher->DispatchAllCollisionPairs(m_pairCache,dispatchInfo); } -void CollisionWorld::RemoveCollisionObject(CollisionObject* collisionObject) +void btCollisionWorld::RemoveCollisionObject(btCollisionObject* collisionObject) { @@ -120,7 +120,7 @@ void CollisionWorld::RemoveCollisionObject(CollisionObject* collisionObject) { - BroadphaseProxy* bp = collisionObject->m_broadphaseHandle; + btBroadphaseProxy* bp = collisionObject->m_broadphaseHandle; if (bp) { // @@ -133,7 +133,7 @@ void CollisionWorld::RemoveCollisionObject(CollisionObject* collisionObject) } - std::vector::iterator i = std::find(m_collisionObjects.begin(), m_collisionObjects.end(), collisionObject); + std::vector::iterator i = std::find(m_collisionObjects.begin(), m_collisionObjects.end(), collisionObject); if (!(i == m_collisionObjects.end())) { @@ -142,23 +142,23 @@ void CollisionWorld::RemoveCollisionObject(CollisionObject* collisionObject) } } -void CollisionWorld::RayTestSingle(const SimdTransform& rayFromTrans,const SimdTransform& rayToTrans, - CollisionObject* collisionObject, - const CollisionShape* collisionShape, - const SimdTransform& colObjWorldTransform, +void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans, + btCollisionObject* collisionObject, + const btCollisionShape* collisionShape, + const btTransform& colObjWorldTransform, RayResultCallback& resultCallback) { - SphereShape pointShape(0.0f); + btSphereShape pointShape(0.0f); if (collisionShape->IsConvex()) { - ConvexCast::CastResult castResult; + btConvexCast::CastResult castResult; castResult.m_fraction = 1.f;//?? - ConvexShape* convexShape = (ConvexShape*) collisionShape; - VoronoiSimplexSolver simplexSolver; - SubsimplexConvexCast convexCaster(&pointShape,convexShape,&simplexSolver); + btConvexShape* convexShape = (btConvexShape*) collisionShape; + btVoronoiSimplexSolver simplexSolver; + btSubsimplexConvexCast convexCaster(&pointShape,convexShape,&simplexSolver); //GjkConvexCast convexCaster(&pointShape,convexShape,&simplexSolver); //ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0); @@ -172,7 +172,7 @@ void CollisionWorld::RayTestSingle(const SimdTransform& rayFromTrans,const SimdT { - CollisionWorld::LocalRayResult localRayResult + btCollisionWorld::LocalRayResult localRayResult ( collisionObject, 0, @@ -192,24 +192,24 @@ void CollisionWorld::RayTestSingle(const SimdTransform& rayFromTrans,const SimdT if (collisionShape->IsConcave()) { - TriangleMeshShape* triangleMesh = (TriangleMeshShape*)collisionShape; + btTriangleMeshShape* triangleMesh = (btTriangleMeshShape*)collisionShape; - SimdTransform worldTocollisionObject = colObjWorldTransform.inverse(); + btTransform worldTocollisionObject = colObjWorldTransform.inverse(); - SimdVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin(); - SimdVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin(); + btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin(); + btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin(); //ConvexCast::CastResult - struct BridgeTriangleRaycastCallback : public TriangleRaycastCallback + struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback { - CollisionWorld::RayResultCallback* m_resultCallback; - CollisionObject* m_collisionObject; - TriangleMeshShape* m_triangleMesh; + btCollisionWorld::RayResultCallback* m_resultCallback; + btCollisionObject* m_collisionObject; + btTriangleMeshShape* m_triangleMesh; - BridgeTriangleRaycastCallback( const SimdVector3& from,const SimdVector3& to, - CollisionWorld::RayResultCallback* resultCallback, CollisionObject* collisionObject,TriangleMeshShape* triangleMesh): - TriangleRaycastCallback(from,to), + BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to, + btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh): + btTriangleRaycastCallback(from,to), m_resultCallback(resultCallback), m_collisionObject(collisionObject), m_triangleMesh(triangleMesh) @@ -217,13 +217,13 @@ void CollisionWorld::RayTestSingle(const SimdTransform& rayFromTrans,const SimdT } - virtual float ReportHit(const SimdVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex ) + virtual float ReportHit(const btVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex ) { - CollisionWorld::LocalShapeInfo shapeInfo; + btCollisionWorld::LocalShapeInfo shapeInfo; shapeInfo.m_shapePart = partId; shapeInfo.m_triangleIndex = triangleIndex; - CollisionWorld::LocalRayResult rayResult + btCollisionWorld::LocalRayResult rayResult (m_collisionObject, &shapeInfo, hitNormalLocal, @@ -240,9 +240,9 @@ void CollisionWorld::RayTestSingle(const SimdTransform& rayFromTrans,const SimdT BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,triangleMesh); rcb.m_hitFraction = resultCallback.m_closestHitFraction; - SimdVector3 rayAabbMinLocal = rayFromLocal; + btVector3 rayAabbMinLocal = rayFromLocal; rayAabbMinLocal.setMin(rayToLocal); - SimdVector3 rayAabbMaxLocal = rayFromLocal; + btVector3 rayAabbMaxLocal = rayFromLocal; rayAabbMaxLocal.setMax(rayToLocal); triangleMesh->ProcessAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal); @@ -252,13 +252,13 @@ void CollisionWorld::RayTestSingle(const SimdTransform& rayFromTrans,const SimdT //todo: use AABB tree or other BVH acceleration structure! if (collisionShape->IsCompound()) { - const CompoundShape* compoundShape = static_cast(collisionShape); + const btCompoundShape* compoundShape = static_cast(collisionShape); int i=0; for (i=0;iGetNumChildShapes();i++) { - SimdTransform childTrans = compoundShape->GetChildTransform(i); - const CollisionShape* childCollisionShape = compoundShape->GetChildShape(i); - SimdTransform childWorldTrans = colObjWorldTransform * childTrans; + btTransform childTrans = compoundShape->GetChildTransform(i); + const btCollisionShape* childCollisionShape = compoundShape->GetChildShape(i); + btTransform childWorldTrans = colObjWorldTransform * childTrans; RayTestSingle(rayFromTrans,rayToTrans, collisionObject, childCollisionShape, @@ -273,11 +273,11 @@ void CollisionWorld::RayTestSingle(const SimdTransform& rayFromTrans,const SimdT } } -void CollisionWorld::RayTest(const SimdVector3& rayFromWorld, const SimdVector3& rayToWorld, RayResultCallback& resultCallback) +void btCollisionWorld::RayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) { - SimdTransform rayFromTrans,rayToTrans; + btTransform rayFromTrans,rayToTrans; rayFromTrans.setIdentity(); rayFromTrans.setOrigin(rayFromWorld); rayToTrans.setIdentity(); @@ -285,8 +285,8 @@ void CollisionWorld::RayTest(const SimdVector3& rayFromWorld, const SimdVector3& rayToTrans.setOrigin(rayToWorld); //do culling based on aabb (rayFrom/rayTo) - SimdVector3 rayAabbMin = rayFromWorld; - SimdVector3 rayAabbMax = rayFromWorld; + btVector3 rayAabbMin = rayFromWorld; + btVector3 rayAabbMax = rayFromWorld; rayAabbMin.setMin(rayToWorld); rayAabbMax.setMax(rayToWorld); @@ -294,16 +294,16 @@ void CollisionWorld::RayTest(const SimdVector3& rayFromWorld, const SimdVector3& /// brute force go over all objects. Once there is a broadphase, use that, or /// add a raycast against aabb first. - std::vector::iterator iter; + std::vector::iterator iter; for (iter=m_collisionObjects.begin(); !(iter==m_collisionObjects.end()); iter++) { - CollisionObject* collisionObject= (*iter); + btCollisionObject* collisionObject= (*iter); //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject(); - SimdVector3 collisionObjectAabbMin,collisionObjectAabbMax; + btVector3 collisionObjectAabbMin,collisionObjectAabbMax; collisionObject->m_collisionShape->GetAabb(collisionObject->m_worldTransform,collisionObjectAabbMin,collisionObjectAabbMax); //check aabb overlap diff --git a/src/BulletCollision/CollisionDispatch/btCollisionWorld.h b/src/BulletCollision/CollisionDispatch/btCollisionWorld.h index 3c140454b..66fa52b92 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionWorld.h +++ b/src/BulletCollision/CollisionDispatch/btCollisionWorld.h @@ -22,7 +22,7 @@ subject to the following restrictions: * * Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ). * - * There is the Physics Forum for Feedback and General Collision Detection and Physics discussions. + * There is the Physics Forum for Feedback and bteral Collision Detection and Physics discussions. * Please visit http://www.continuousphysics.com/Bullet/phpBB2/index.php * * @section install_sec Installation @@ -44,12 +44,12 @@ subject to the following restrictions: * The Dependencies can be seen in this documentation under Directories * * @subsection step4 Step 4: Integrating in your application, Full Rigid Body Simulation - * Check out CcdPhysicsDemo how to create a CcdPhysicsEnvironment , CollisionShape and RigidBody, Stepping the simulation and synchronizing your derived version of the PHY_IMotionState class. + * Check out CcdPhysicsDemo how to create a CcdPhysicsEnvironment , btCollisionShape and btRigidBody, Stepping the simulation and synchronizing your derived version of the PHY_IMotionState class. * @subsection step5 Step 5 : Integrate the Collision Detection Library (without Dynamics and other Extras) * Bullet Collision Detection can also be used without the Dynamics/Extras. - * Check out CollisionWorld and CollisionObject, and the CollisionInterfaceDemo. Also in Extras/test_BulletOde.cpp there is a sample Collision Detection integration with Open Dynamics Engine, ODE, http://www.ode.org + * Check out btCollisionWorld and btCollisionObject, and the CollisionInterfaceDemo. Also in Extras/test_BulletOde.cpp there is a sample Collision Detection integration with Open Dynamics Engine, ODE, http://www.ode.org * @subsection step6 Step 6 : Use Snippets like the GJK Closest Point calculation. - * Bullet has been designed in a modular way keeping dependencies to a minimum. The ConvexHullDistance demo demonstrates direct use of GjkPairDetector. + * Bullet has been designed in a modular way keeping dependencies to a minimum. The ConvexHullDistance demo demonstrates direct use of btGjkPairDetector. * * @section copyright Copyright * Copyright (C) 2005-2006 Erwin Coumans, some contributions Copyright Gino van den Bergen, Christer Ericson, Simon Hobbs, Ricardo Padrela, F Richter(res), Stephane Redon @@ -64,12 +64,12 @@ subject to the following restrictions: #define COLLISION_WORLD_H -class CollisionShape; -class BroadphaseInterface; -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdTransform.h" +class btCollisionShape; +class btBroadphaseInterface; +#include "LinearMath/btVector3.h" +#include "LinearMath/btTransform.h" #include "btCollisionObject.h" -#include "btCollisionDispatcher.h" //for definition of CollisionObjectArray +#include "btCollisionDispatcher.h" //for definition of btCollisionObjectArray #include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" #include @@ -77,61 +77,62 @@ class BroadphaseInterface; ///CollisionWorld is interface and container for the collision detection -class CollisionWorld +class btCollisionWorld { +protected: - std::vector m_collisionObjects; + std::vector m_collisionObjects; - Dispatcher* m_dispatcher1; + btDispatcher* m_dispatcher1; - OverlappingPairCache* m_pairCache; + btOverlappingPairCache* m_pairCache; public: - CollisionWorld(Dispatcher* dispatcher,OverlappingPairCache* pairCache) + btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache) :m_dispatcher1(dispatcher), m_pairCache(pairCache) { } - virtual ~CollisionWorld(); + virtual ~btCollisionWorld(); - BroadphaseInterface* GetBroadphase() + btBroadphaseInterface* GetBroadphase() { return m_pairCache; } - OverlappingPairCache* GetPairCache() + btOverlappingPairCache* GetPairCache() { return m_pairCache; } - Dispatcher* GetDispatcher() + btDispatcher* GetDispatcher() { return m_dispatcher1; } ///LocalShapeInfo gives extra information for complex shapes - ///Currently, only TriangleMeshShape is available, so it just contains triangleIndex and subpart + ///Currently, only btTriangleMeshShape is available, so it just contains triangleIndex and subpart struct LocalShapeInfo { int m_shapePart; int m_triangleIndex; - //const CollisionShape* m_shapeTemp; - //const SimdTransform* m_shapeLocalTransform; + //const btCollisionShape* m_shapeTemp; + //const btTransform* m_shapeLocalTransform; }; struct LocalRayResult { - LocalRayResult(const CollisionObject* collisionObject, + LocalRayResult(const btCollisionObject* collisionObject, LocalShapeInfo* localShapeInfo, - const SimdVector3& hitNormalLocal, + const btVector3& hitNormalLocal, float hitFraction) :m_collisionObject(collisionObject), m_localShapeInfo(m_localShapeInfo), @@ -140,9 +141,9 @@ public: { } - const CollisionObject* m_collisionObject; + const btCollisionObject* m_collisionObject; LocalShapeInfo* m_localShapeInfo; - const SimdVector3& m_hitNormalLocal; + const btVector3& m_hitNormalLocal; float m_hitFraction; }; @@ -168,19 +169,19 @@ public: struct ClosestRayResultCallback : public RayResultCallback { - ClosestRayResultCallback(SimdVector3 rayFromWorld,SimdVector3 rayToWorld) + ClosestRayResultCallback(btVector3 rayFromWorld,btVector3 rayToWorld) :m_rayFromWorld(rayFromWorld), m_rayToWorld(rayToWorld), m_collisionObject(0) { } - SimdVector3 m_rayFromWorld;//used to calculate hitPointWorld from hitFraction - SimdVector3 m_rayToWorld; + btVector3 m_rayFromWorld;//used to calculate hitPointWorld from hitFraction + btVector3 m_rayToWorld; - SimdVector3 m_hitNormalWorld; - SimdVector3 m_hitPointWorld; - const CollisionObject* m_collisionObject; + btVector3 m_hitNormalWorld; + btVector3 m_hitPointWorld; + const btCollisionObject* m_collisionObject; virtual float AddSingleResult(const LocalRayResult& rayResult) { @@ -204,33 +205,33 @@ public: return m_collisionObjects.size(); } - /// RayTest performs a raycast on all objects in the CollisionWorld, and calls the resultCallback + /// RayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback /// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback. - void RayTest(const SimdVector3& rayFromWorld, const SimdVector3& rayToWorld, RayResultCallback& resultCallback); + void RayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback); /// RayTestSingle performs a raycast call and calls the resultCallback. It is used internally by RayTest. - /// In a future implementation, we consider moving the ray test as a virtual method in CollisionShape. + /// In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape. /// This allows more customization. - void RayTestSingle(const SimdTransform& rayFromTrans,const SimdTransform& rayToTrans, - CollisionObject* collisionObject, - const CollisionShape* collisionShape, - const SimdTransform& colObjWorldTransform, + void RayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans, + btCollisionObject* collisionObject, + const btCollisionShape* collisionShape, + const btTransform& colObjWorldTransform, RayResultCallback& resultCallback); - void AddCollisionObject(CollisionObject* collisionObject,short int collisionFilterGroup=1,short int collisionFilterMask=1); + void AddCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=1,short int collisionFilterMask=1); - CollisionObjectArray& GetCollisionObjectArray() + btCollisionObjectArray& GetCollisionObjectArray() { return m_collisionObjects; } - const CollisionObjectArray& GetCollisionObjectArray() const + const btCollisionObjectArray& GetCollisionObjectArray() const { return m_collisionObjects; } - void RemoveCollisionObject(CollisionObject* collisionObject); + void RemoveCollisionObject(btCollisionObject* collisionObject); virtual void PerformDiscreteCollisionDetection(); diff --git a/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp b/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp index ad05ae532..7f0ee3a3f 100644 --- a/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp +++ b/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp @@ -18,29 +18,29 @@ subject to the following restrictions: #include "BulletCollision/CollisionShapes/btCompoundShape.h" -CompoundCollisionAlgorithm::CompoundCollisionAlgorithm( const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) +btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) :m_dispatcher(ci.m_dispatcher), m_compoundProxy(*proxy0), m_otherProxy(*proxy1) { - CollisionObject* colObj = static_cast(m_compoundProxy.m_clientObject); + btCollisionObject* colObj = static_cast(m_compoundProxy.m_clientObject); assert (colObj->m_collisionShape->IsCompound()); - CompoundShape* compoundShape = static_cast(colObj->m_collisionShape); + btCompoundShape* compoundShape = static_cast(colObj->m_collisionShape); int numChildren = compoundShape->GetNumChildShapes(); m_childProxies.resize( numChildren ); int i; for (i=0;iGetChildShape(i); - CollisionObject* colObj = static_cast(m_childProxies[i].m_clientObject); - CollisionShape* orgShape = colObj->m_collisionShape; + btCollisionShape* childShape = compoundShape->GetChildShape(i); + btCollisionObject* colObj = static_cast(m_childProxies[i].m_clientObject); + btCollisionShape* orgShape = colObj->m_collisionShape; colObj->m_collisionShape = childShape; m_childCollisionAlgorithms[i] = m_dispatcher->FindAlgorithm(m_childProxies[i],m_otherProxy); colObj->m_collisionShape =orgShape; @@ -48,7 +48,7 @@ m_otherProxy(*proxy1) } -CompoundCollisionAlgorithm::~CompoundCollisionAlgorithm() +btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm() { int numChildren = m_childCollisionAlgorithms.size(); int i; @@ -58,12 +58,12 @@ CompoundCollisionAlgorithm::~CompoundCollisionAlgorithm() } } -void CompoundCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,BroadphaseProxy* ,const DispatcherInfo& dispatchInfo) +void btCompoundCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo) { - CollisionObject* colObj = static_cast(m_compoundProxy.m_clientObject); + btCollisionObject* colObj = static_cast(m_compoundProxy.m_clientObject); assert (colObj->m_collisionShape->IsCompound()); - CompoundShape* compoundShape = static_cast(colObj->m_collisionShape); + btCompoundShape* compoundShape = static_cast(colObj->m_collisionShape); //We will use the OptimizedBVH, AABB tree to cull potential child-overlaps //If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals @@ -77,16 +77,16 @@ void CompoundCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,BroadphaseP int i; for (i=0;iGetChildShape(i); - CollisionObject* colObj = static_cast(m_childProxies[i].m_clientObject); + //temporarily exchange parent btCollisionShape with childShape, and recurse + btCollisionShape* childShape = compoundShape->GetChildShape(i); + btCollisionObject* colObj = static_cast(m_childProxies[i].m_clientObject); //backup - SimdTransform orgTrans = colObj->m_worldTransform; - CollisionShape* orgShape = colObj->m_collisionShape; + btTransform orgTrans = colObj->m_worldTransform; + btCollisionShape* orgShape = colObj->m_collisionShape; - SimdTransform childTrans = compoundShape->GetChildTransform(i); - SimdTransform newChildWorldTrans = orgTrans*childTrans ; + btTransform childTrans = compoundShape->GetChildTransform(i); + btTransform newChildWorldTrans = orgTrans*childTrans ; colObj->m_worldTransform = newChildWorldTrans; colObj->m_collisionShape = childShape; @@ -97,12 +97,12 @@ void CompoundCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,BroadphaseP } } -float CompoundCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo) +float btCompoundCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) { - CollisionObject* colObj = static_cast(m_compoundProxy.m_clientObject); + btCollisionObject* colObj = static_cast(m_compoundProxy.m_clientObject); assert (colObj->m_collisionShape->IsCompound()); - CompoundShape* compoundShape = static_cast(colObj->m_collisionShape); + btCompoundShape* compoundShape = static_cast(colObj->m_collisionShape); //We will use the OptimizedBVH, AABB tree to cull potential child-overlaps //If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals @@ -117,16 +117,16 @@ float CompoundCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* proxy0, int i; for (i=0;iGetChildShape(i); - CollisionObject* colObj = static_cast(m_childProxies[i].m_clientObject); + //temporarily exchange parent btCollisionShape with childShape, and recurse + btCollisionShape* childShape = compoundShape->GetChildShape(i); + btCollisionObject* colObj = static_cast(m_childProxies[i].m_clientObject); //backup - SimdTransform orgTrans = colObj->m_worldTransform; - CollisionShape* orgShape = colObj->m_collisionShape; + btTransform orgTrans = colObj->m_worldTransform; + btCollisionShape* orgShape = colObj->m_collisionShape; - SimdTransform childTrans = compoundShape->GetChildTransform(i); - SimdTransform newChildWorldTrans = orgTrans*childTrans ; + btTransform childTrans = compoundShape->GetChildTransform(i); + btTransform newChildWorldTrans = orgTrans*childTrans ; colObj->m_worldTransform = newChildWorldTrans; colObj->m_collisionShape = childShape; diff --git a/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h b/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h index d346821d7..f32b4e98a 100644 --- a/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h +++ b/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h @@ -21,49 +21,49 @@ subject to the following restrictions: #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -class Dispatcher; +class btDispatcher; #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" #include #include "btCollisionCreateFunc.h" -/// CompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes +/// btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes /// Place holder, not fully implemented yet -class CompoundCollisionAlgorithm : public CollisionAlgorithm +class btCompoundCollisionAlgorithm : public btCollisionAlgorithm { - Dispatcher* m_dispatcher; - BroadphaseProxy m_compoundProxy; - BroadphaseProxy m_otherProxy; - std::vector m_childProxies; - std::vector m_childCollisionAlgorithms; + btDispatcher* m_dispatcher; + btBroadphaseProxy m_compoundProxy; + btBroadphaseProxy m_otherProxy; + std::vector m_childProxies; + std::vector m_childCollisionAlgorithms; - BroadphaseProxy m_compound; + btBroadphaseProxy m_compound; - BroadphaseProxy m_other; + btBroadphaseProxy m_other; public: - CompoundCollisionAlgorithm( const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1); + btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - virtual ~CompoundCollisionAlgorithm(); + virtual ~btCompoundCollisionAlgorithm(); - virtual void ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - float CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - struct CreateFunc :public CollisionAlgorithmCreateFunc + struct CreateFunc :public btCollisionAlgorithmCreateFunc { - virtual CollisionAlgorithm* CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo& ci, BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) { - return new CompoundCollisionAlgorithm(ci,proxy0,proxy1); + return new btCompoundCollisionAlgorithm(ci,proxy0,proxy1); } }; - struct SwappedCreateFunc :public CollisionAlgorithmCreateFunc + struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc { - virtual CollisionAlgorithm* CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo& ci, BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) { - return new CompoundCollisionAlgorithm(ci,proxy1,proxy0); + return new btCompoundCollisionAlgorithm(ci,proxy1,proxy0); } }; diff --git a/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp b/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp index 2cb6d5f73..03274ceaf 100644 --- a/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp +++ b/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp @@ -24,23 +24,23 @@ subject to the following restrictions: #include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h" #include "BulletCollision/CollisionShapes/btTriangleShape.h" #include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" #include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" -ConvexConcaveCollisionAlgorithm::ConvexConcaveCollisionAlgorithm( const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) -: CollisionAlgorithm(ci),m_convex(*proxy0),m_concave(*proxy1), -m_ConvexTriangleCallback(ci.m_dispatcher,proxy0,proxy1) +btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) +: btCollisionAlgorithm(ci),m_convex(*proxy0),m_concave(*proxy1), +m_btConvexTriangleCallback(ci.m_dispatcher,proxy0,proxy1) { } -ConvexConcaveCollisionAlgorithm::~ConvexConcaveCollisionAlgorithm() +btConvexConcaveCollisionAlgorithm::~btConvexConcaveCollisionAlgorithm() { } -ConvexTriangleCallback::ConvexTriangleCallback(Dispatcher* dispatcher,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1): +btConvexTriangleCallback::btConvexTriangleCallback(btDispatcher* dispatcher,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1): m_convexProxy(proxy0),m_triangleProxy(*proxy1),m_dispatcher(dispatcher), m_dispatchInfoPtr(0) { @@ -53,7 +53,7 @@ ConvexTriangleCallback::ConvexTriangleCallback(Dispatcher* dispatcher,Broadphas ClearCache(); } -ConvexTriangleCallback::~ConvexTriangleCallback() +btConvexTriangleCallback::~btConvexTriangleCallback() { ClearCache(); m_dispatcher->ReleaseManifold( m_manifoldPtr ); @@ -61,14 +61,14 @@ ConvexTriangleCallback::~ConvexTriangleCallback() } -void ConvexTriangleCallback::ClearCache() +void btConvexTriangleCallback::ClearCache() { m_dispatcher->ClearManifold(m_manifoldPtr); }; -void ConvexTriangleCallback::ProcessTriangle(SimdVector3* triangle,int partId, int triangleIndex) +void btConvexTriangleCallback::ProcessTriangle(btVector3* triangle,int partId, int triangleIndex) { //just for debugging purposes @@ -77,23 +77,23 @@ void ConvexTriangleCallback::ProcessTriangle(SimdVector3* triangle,int partId, i //aabb filter is already applied! - CollisionAlgorithmConstructionInfo ci; + btCollisionAlgorithmConstructionInfo ci; ci.m_dispatcher = m_dispatcher; - CollisionObject* ob = static_cast(m_triangleProxy.m_clientObject); + btCollisionObject* ob = static_cast(m_triangleProxy.m_clientObject); ///debug drawing of the overlapping triangles if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->GetDebugMode() > 0) { - SimdVector3 color(255,255,0); - SimdTransform& tr = ob->m_worldTransform; + btVector3 color(255,255,0); + btTransform& tr = ob->m_worldTransform; m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[0]),tr(triangle[1]),color); m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[1]),tr(triangle[2]),color); m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[2]),tr(triangle[0]),color); - //SimdVector3 center = triangle[0] + triangle[1]+triangle[2]; + //btVector3 center = triangle[0] + triangle[1]+triangle[2]; //center *= 0.333333f; //m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[0]),tr(center),color); //m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[1]),tr(center),color); @@ -102,19 +102,19 @@ void ConvexTriangleCallback::ProcessTriangle(SimdVector3* triangle,int partId, i } - CollisionObject* colObj = static_cast(m_convexProxy->m_clientObject); + btCollisionObject* colObj = static_cast(m_convexProxy->m_clientObject); if (colObj->m_collisionShape->IsConvex()) { - TriangleShape tm(triangle[0],triangle[1],triangle[2]); + btTriangleShape tm(triangle[0],triangle[1],triangle[2]); tm.SetMargin(m_collisionMarginTriangle); - CollisionShape* tmpShape = ob->m_collisionShape; + btCollisionShape* tmpShape = ob->m_collisionShape; ob->m_collisionShape = &tm; - ///this should use the Dispatcher, so the actual registered algorithm is used - ConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexProxy,&m_triangleProxy); + ///this should use the btDispatcher, so the actual registered algorithm is used + btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexProxy,&m_triangleProxy); cvxcvxalgo.SetShapeIdentifiers(-1,-1,partId,triangleIndex); cvxcvxalgo.ProcessCollision(m_convexProxy,&m_triangleProxy,*m_dispatchInfoPtr); ob->m_collisionShape = tmpShape; @@ -127,43 +127,43 @@ void ConvexTriangleCallback::ProcessTriangle(SimdVector3* triangle,int partId, i -void ConvexTriangleCallback::SetTimeStepAndCounters(float collisionMarginTriangle,const DispatcherInfo& dispatchInfo) +void btConvexTriangleCallback::SetTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo) { m_dispatchInfoPtr = &dispatchInfo; m_collisionMarginTriangle = collisionMarginTriangle; //recalc aabbs - CollisionObject* convexBody = (CollisionObject* )m_convexProxy->m_clientObject; - CollisionObject* triBody = (CollisionObject* )m_triangleProxy.m_clientObject; + btCollisionObject* convexBody = (btCollisionObject* )m_convexProxy->m_clientObject; + btCollisionObject* triBody = (btCollisionObject* )m_triangleProxy.m_clientObject; - SimdTransform convexInTriangleSpace; + btTransform convexInTriangleSpace; convexInTriangleSpace = triBody->m_worldTransform.inverse() * convexBody->m_worldTransform; - CollisionShape* convexShape = static_cast(convexBody->m_collisionShape); - //CollisionShape* triangleShape = static_cast(triBody->m_collisionShape); + btCollisionShape* convexShape = static_cast(convexBody->m_collisionShape); + //CollisionShape* triangleShape = static_cast(triBody->m_collisionShape); convexShape->GetAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax); float extraMargin = collisionMarginTriangle;//CONVEX_DISTANCE_MARGIN;//+0.1f; - SimdVector3 extra(extraMargin,extraMargin,extraMargin); + btVector3 extra(extraMargin,extraMargin,extraMargin); m_aabbMax += extra; m_aabbMin -= extra; } -void ConvexConcaveCollisionAlgorithm::ClearCache() +void btConvexConcaveCollisionAlgorithm::ClearCache() { - m_ConvexTriangleCallback.ClearCache(); + m_btConvexTriangleCallback.ClearCache(); } -void ConvexConcaveCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,BroadphaseProxy* ,const DispatcherInfo& dispatchInfo) +void btConvexConcaveCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo) { - CollisionObject* convexBody = static_cast(m_convex.m_clientObject); - CollisionObject* triBody = static_cast(m_concave.m_clientObject); + btCollisionObject* convexBody = static_cast(m_convex.m_clientObject); + btCollisionObject* triBody = static_cast(m_concave.m_clientObject); if (triBody->m_collisionShape->IsConcave()) { @@ -173,22 +173,22 @@ void ConvexConcaveCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,Broadp - CollisionObject* triOb = static_cast(m_concave.m_clientObject); + btCollisionObject* triOb = static_cast(m_concave.m_clientObject); ConcaveShape* concaveShape = static_cast( triOb->m_collisionShape); if (convexBody->m_collisionShape->IsConvex()) { float collisionMarginTriangle = concaveShape->GetMargin(); - m_ConvexTriangleCallback.SetTimeStepAndCounters(collisionMarginTriangle,dispatchInfo); + m_btConvexTriangleCallback.SetTimeStepAndCounters(collisionMarginTriangle,dispatchInfo); //Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here. - //m_dispatcher->ClearManifold(m_ConvexTriangleCallback.m_manifoldPtr); + //m_dispatcher->ClearManifold(m_btConvexTriangleCallback.m_manifoldPtr); - m_ConvexTriangleCallback.m_manifoldPtr->SetBodies(m_convex.m_clientObject,m_concave.m_clientObject); + m_btConvexTriangleCallback.m_manifoldPtr->SetBodies(m_convex.m_clientObject,m_concave.m_clientObject); - concaveShape->ProcessAllTriangles( &m_ConvexTriangleCallback,m_ConvexTriangleCallback.GetAabbMin(),m_ConvexTriangleCallback.GetAabbMax()); + concaveShape->ProcessAllTriangles( &m_btConvexTriangleCallback,m_btConvexTriangleCallback.GetAabbMin(),m_btConvexTriangleCallback.GetAabbMax()); } @@ -198,12 +198,12 @@ void ConvexConcaveCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,Broadp } -float ConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* ,BroadphaseProxy* ,const DispatcherInfo& dispatchInfo) +float btConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo) { - //quick approximation using raycast, todo: hook up to the continuous collision detection (one of the ConvexCast) - CollisionObject* convexbody = (CollisionObject* )m_convex.m_clientObject; - CollisionObject* triBody = static_cast(m_concave.m_clientObject); + //quick approximation using raycast, todo: hook up to the continuous collision detection (one of the btConvexCast) + btCollisionObject* convexbody = (btCollisionObject* )m_convex.m_clientObject; + btCollisionObject* triBody = static_cast(m_concave.m_clientObject); //only perform CCD above a certain treshold, this prevents blocking on the long run //because object in a blocked ccd state (hitfraction<1) get their linear velocity halved each frame... @@ -213,24 +213,24 @@ float ConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* ,B return 1.f; } - //const SimdVector3& from = convexbody->m_worldTransform.getOrigin(); - //SimdVector3 to = convexbody->m_interpolationWorldTransform.getOrigin(); + //const btVector3& from = convexbody->m_worldTransform.getOrigin(); + //btVector3 to = convexbody->m_interpolationWorldTransform.getOrigin(); //todo: only do if the motion exceeds the 'radius' - SimdTransform convexFromLocal = triBody->m_cachedInvertedWorldTransform * convexbody->m_worldTransform; - SimdTransform convexToLocal = triBody->m_cachedInvertedWorldTransform * convexbody->m_interpolationWorldTransform; + btTransform convexFromLocal = triBody->m_cachedInvertedWorldTransform * convexbody->m_worldTransform; + btTransform convexToLocal = triBody->m_cachedInvertedWorldTransform * convexbody->m_interpolationWorldTransform; - struct LocalTriangleSphereCastCallback : public TriangleCallback + struct LocalTriangleSphereCastCallback : public btTriangleCallback { - SimdTransform m_ccdSphereFromTrans; - SimdTransform m_ccdSphereToTrans; - SimdTransform m_meshTransform; + btTransform m_ccdSphereFromTrans; + btTransform m_ccdSphereToTrans; + btTransform m_meshTransform; float m_ccdSphereRadius; float m_hitFraction; - LocalTriangleSphereCastCallback(const SimdTransform& from,const SimdTransform& to,float ccdSphereRadius,float hitFraction) + LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,float ccdSphereRadius,float hitFraction) :m_ccdSphereFromTrans(from), m_ccdSphereToTrans(to), m_ccdSphereRadius(ccdSphereRadius), @@ -239,17 +239,17 @@ float ConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* ,B } - virtual void ProcessTriangle(SimdVector3* triangle, int partId, int triangleIndex) + virtual void ProcessTriangle(btVector3* triangle, int partId, int triangleIndex) { //do a swept sphere for now - SimdTransform ident; + btTransform ident; ident.setIdentity(); - ConvexCast::CastResult castResult; + btConvexCast::CastResult castResult; castResult.m_fraction = m_hitFraction; - SphereShape pointShape(m_ccdSphereRadius); - TriangleShape triShape(triangle[0],triangle[1],triangle[2]); - VoronoiSimplexSolver simplexSolver; - SubsimplexConvexCast convexCaster(&pointShape,&triShape,&simplexSolver); + btSphereShape pointShape(m_ccdSphereRadius); + btTriangleShape triShape(triangle[0],triangle[1],triangle[2]); + btVoronoiSimplexSolver simplexSolver; + btSubsimplexConvexCast convexCaster(&pointShape,&triShape,&simplexSolver); //GjkConvexCast convexCaster(&pointShape,convexShape,&simplexSolver); //ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0); //local space? @@ -271,12 +271,12 @@ float ConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* ,B if (triBody->m_collisionShape->IsConcave()) { - SimdVector3 rayAabbMin = convexFromLocal.getOrigin(); + btVector3 rayAabbMin = convexFromLocal.getOrigin(); rayAabbMin.setMin(convexToLocal.getOrigin()); - SimdVector3 rayAabbMax = convexFromLocal.getOrigin(); + btVector3 rayAabbMax = convexFromLocal.getOrigin(); rayAabbMax.setMax(convexToLocal.getOrigin()); - rayAabbMin -= SimdVector3(convexbody->m_ccdSweptShereRadius,convexbody->m_ccdSweptShereRadius,convexbody->m_ccdSweptShereRadius); - rayAabbMax += SimdVector3(convexbody->m_ccdSweptShereRadius,convexbody->m_ccdSweptShereRadius,convexbody->m_ccdSweptShereRadius); + rayAabbMin -= btVector3(convexbody->m_ccdSweptShereRadius,convexbody->m_ccdSweptShereRadius,convexbody->m_ccdSweptShereRadius); + rayAabbMax += btVector3(convexbody->m_ccdSweptShereRadius,convexbody->m_ccdSweptShereRadius,convexbody->m_ccdSweptShereRadius); float curHitFraction = 1.f; //is this available? LocalTriangleSphereCastCallback raycastCallback(convexFromLocal,convexToLocal, @@ -284,7 +284,7 @@ float ConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* ,B raycastCallback.m_hitFraction = convexbody->m_hitFraction; - CollisionObject* concavebody = (CollisionObject* )m_concave.m_clientObject; + btCollisionObject* concavebody = (btCollisionObject* )m_concave.m_clientObject; ConcaveShape* triangleMesh = (ConcaveShape*) concavebody->m_collisionShape; diff --git a/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h b/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h index 94549015e..e73ed4dba 100644 --- a/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h +++ b/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h @@ -21,43 +21,43 @@ subject to the following restrictions: #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" #include "BulletCollision/CollisionShapes/btTriangleCallback.h" #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -class Dispatcher; +class btDispatcher; #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" #include "btCollisionCreateFunc.h" ///For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), ProcessTriangle is called. -class ConvexTriangleCallback : public TriangleCallback +class btConvexTriangleCallback : public btTriangleCallback { - BroadphaseProxy* m_convexProxy; - BroadphaseProxy m_triangleProxy; + btBroadphaseProxy* m_convexProxy; + btBroadphaseProxy m_triangleProxy; - SimdVector3 m_aabbMin; - SimdVector3 m_aabbMax ; + btVector3 m_aabbMin; + btVector3 m_aabbMax ; - Dispatcher* m_dispatcher; - const DispatcherInfo* m_dispatchInfoPtr; + btDispatcher* m_dispatcher; + const btDispatcherInfo* m_dispatchInfoPtr; float m_collisionMarginTriangle; public: int m_triangleCount; - PersistentManifold* m_manifoldPtr; + btPersistentManifold* m_manifoldPtr; - ConvexTriangleCallback(Dispatcher* dispatcher,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1); + btConvexTriangleCallback(btDispatcher* dispatcher,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - void SetTimeStepAndCounters(float collisionMarginTriangle,const DispatcherInfo& dispatchInfo); + void SetTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo); - virtual ~ConvexTriangleCallback(); + virtual ~btConvexTriangleCallback(); - virtual void ProcessTriangle(SimdVector3* triangle, int partId, int triangleIndex); + virtual void ProcessTriangle(btVector3* triangle, int partId, int triangleIndex); void ClearCache(); - inline const SimdVector3& GetAabbMin() const + inline const btVector3& GetAabbMin() const { return m_aabbMin; } - inline const SimdVector3& GetAabbMax() const + inline const btVector3& GetAabbMax() const { return m_aabbMax; } @@ -67,42 +67,42 @@ int m_triangleCount; -/// ConvexConcaveCollisionAlgorithm supports collision between convex shapes and (concave) trianges meshes. -class ConvexConcaveCollisionAlgorithm : public CollisionAlgorithm +/// btConvexConcaveCollisionAlgorithm supports collision between convex shapes and (concave) trianges meshes. +class btConvexConcaveCollisionAlgorithm : public btCollisionAlgorithm { - BroadphaseProxy m_convex; + btBroadphaseProxy m_convex; - BroadphaseProxy m_concave; + btBroadphaseProxy m_concave; - ConvexTriangleCallback m_ConvexTriangleCallback; + btConvexTriangleCallback m_btConvexTriangleCallback; public: - ConvexConcaveCollisionAlgorithm( const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1); + btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - virtual ~ConvexConcaveCollisionAlgorithm(); + virtual ~btConvexConcaveCollisionAlgorithm(); - virtual void ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - float CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); void ClearCache(); - struct CreateFunc :public CollisionAlgorithmCreateFunc + struct CreateFunc :public btCollisionAlgorithmCreateFunc { - virtual CollisionAlgorithm* CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo& ci, BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) { - return new ConvexConcaveCollisionAlgorithm(ci,proxy0,proxy1); + return new btConvexConcaveCollisionAlgorithm(ci,proxy0,proxy1); } }; - struct SwappedCreateFunc :public CollisionAlgorithmCreateFunc + struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc { - virtual CollisionAlgorithm* CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo& ci, BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) { - return new ConvexConcaveCollisionAlgorithm(ci,proxy1,proxy0); + return new btConvexConcaveCollisionAlgorithm(ci,proxy1,proxy0); } }; diff --git a/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp b/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp index d53e47e62..12f5afffc 100644 --- a/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp +++ b/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp @@ -81,8 +81,8 @@ bool gDisableConvexCollision = false; -ConvexConvexAlgorithm::ConvexConvexAlgorithm(PersistentManifold* mf,const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) -: CollisionAlgorithm(ci), +btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) +: btCollisionAlgorithm(ci), m_gjkPairDetector(0,0,&m_simplexSolver,0), m_useEpa(!gUseEpa), m_box0(*proxy0), @@ -105,7 +105,7 @@ m_lowLevelOfDetail(false) -ConvexConvexAlgorithm::~ConvexConvexAlgorithm() +btConvexConvexAlgorithm::~btConvexConvexAlgorithm() { if (m_ownManifold) { @@ -114,35 +114,35 @@ ConvexConvexAlgorithm::~ConvexConvexAlgorithm() } } -void ConvexConvexAlgorithm ::SetLowLevelOfDetail(bool useLowLevel) +void btConvexConvexAlgorithm ::SetLowLevelOfDetail(bool useLowLevel) { m_lowLevelOfDetail = useLowLevel; } -class FlippedContactResult : public DiscreteCollisionDetectorInterface::Result +class FlippedContactResult : public btDiscreteCollisionDetectorInterface::Result { - DiscreteCollisionDetectorInterface::Result* m_org; + btDiscreteCollisionDetectorInterface::Result* m_org; public: - FlippedContactResult(DiscreteCollisionDetectorInterface::Result* org) + FlippedContactResult(btDiscreteCollisionDetectorInterface::Result* org) : m_org(org) { } - virtual void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth) + virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth) { - SimdVector3 flippedNormal = -normalOnBInWorld; + btVector3 flippedNormal = -normalOnBInWorld; m_org->AddContactPoint(flippedNormal,pointInWorld,depth); } }; -static MinkowskiPenetrationDepthSolver gPenetrationDepthSolver; +static btMinkowskiPenetrationDepthSolver gPenetrationDepthSolver; //static EpaPenetrationDepthSolver gEpaPenetrationDepthSolver; @@ -150,7 +150,7 @@ static MinkowskiPenetrationDepthSolver gPenetrationDepthSolver; Solid3EpaPenetrationDepth gSolidEpaPenetrationSolver; #endif //USE_EPA -void ConvexConvexAlgorithm::CheckPenetrationDepthSolver() +void btConvexConvexAlgorithm::CheckPenetrationDepthSolver() { if (m_useEpa != gUseEpa) { @@ -171,15 +171,15 @@ void ConvexConvexAlgorithm::CheckPenetrationDepthSolver() #ifdef USE_HULL -Transform GetTransformFromSimdTransform(const SimdTransform& trans) +Transform GetTransformFrombtTransform(const btTransform& trans) { - //const SimdVector3& rowA0 = trans.getBasis().getRow(0); - ////const SimdVector3& rowA1 = trans.getBasis().getRow(1); - //const SimdVector3& rowA2 = trans.getBasis().getRow(2); + //const btVector3& rowA0 = trans.getBasis().getRow(0); + ////const btVector3& rowA1 = trans.getBasis().getRow(1); + //const btVector3& rowA2 = trans.getBasis().getRow(2); - SimdVector3 rowA0 = trans.getBasis().getColumn(0); - SimdVector3 rowA1 = trans.getBasis().getColumn(1); - SimdVector3 rowA2 = trans.getBasis().getColumn(2); + btVector3 rowA0 = trans.getBasis().getColumn(0); + btVector3 rowA1 = trans.getBasis().getColumn(1); + btVector3 rowA2 = trans.getBasis().getColumn(2); Vector3 x(rowA0.getX(),rowA0.getY(),rowA0.getZ()); @@ -196,28 +196,28 @@ Transform GetTransformFromSimdTransform(const SimdTransform& trans) return Transform(ornA,transA); } -class ManifoldResultCollector : public HullContactCollector +class btManifoldResultCollector : public HullContactCollector { public: - ManifoldResult& m_manifoldResult; + btManifoldResult& m_manifoldResult; - ManifoldResultCollector(ManifoldResult& manifoldResult) + btManifoldResultCollector(btManifoldResult& manifoldResult) :m_manifoldResult(manifoldResult) { } - virtual ~ManifoldResultCollector() {}; + virtual ~btManifoldResultCollector() {}; - virtual int BatchAddContactGroup(const Separation& sep,int numContacts,const Vector3& normalWorld,const Vector3& tangent,const Point3* positionsWorld,const float* depths) + virtual int BatchAddContactGroup(const btSeparation& sep,int numContacts,const Vector3& normalWorld,const Vector3& tangent,const Point3* positionsWorld,const float* depths) { for (int i=0;iNeedsCollision(m_box0,m_box1); if (!needsCollision) return; - CollisionObject* col0 = static_cast(m_box0.m_clientObject); - CollisionObject* col1 = static_cast(m_box1.m_clientObject); + btCollisionObject* col0 = static_cast(m_box0.m_clientObject); + btCollisionObject* col1 = static_cast(m_box1.m_clientObject); #ifdef USE_HULL @@ -264,29 +264,29 @@ void ConvexConvexAlgorithm ::ProcessCollision (BroadphaseProxy* ,BroadphaseProxy { - PolyhedralConvexShape* polyhedron0 = static_cast(col0->m_collisionShape); - PolyhedralConvexShape* polyhedron1 = static_cast(col1->m_collisionShape); + btPolyhedralConvexShape* polyhedron0 = static_cast(col0->m_collisionShape); + btPolyhedralConvexShape* polyhedron1 = static_cast(col1->m_collisionShape); if (polyhedron0->m_optionalHull && polyhedron1->m_optionalHull) { //printf("Hull-Hull"); //todo: cache this information, rather then initialize - Separation sep; + btSeparation sep; sep.m_featureA = 0; sep.m_featureB = 0; sep.m_contact = -1; sep.m_separator = 0; - //convert from SimdTransform to Transform + //convert from btTransform to Transform - Transform trA = GetTransformFromSimdTransform(col0->m_worldTransform); - Transform trB = GetTransformFromSimdTransform(col1->m_worldTransform); + Transform trA = GetTransformFrombtTransform(col0->m_worldTransform); + Transform trB = GetTransformFrombtTransform(col1->m_worldTransform); //either use persistent manifold or clear it every time m_dispatcher->ClearManifold(m_manifoldPtr); - ManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); + btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); - ManifoldResultCollector hullContactCollector(*resultOut); + btManifoldResultCollector hullContactCollector(*resultOut); Hull::ProcessHullHull(sep,*polyhedron0->m_optionalHull,*polyhedron1->m_optionalHull, trA,trB,&hullContactCollector); @@ -301,12 +301,12 @@ void ConvexConvexAlgorithm ::ProcessCollision (BroadphaseProxy* ,BroadphaseProxy #endif //USE_HULL - ManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); + btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); - ConvexShape* min0 = static_cast(col0->m_collisionShape); - ConvexShape* min1 = static_cast(col1->m_collisionShape); + btConvexShape* min0 = static_cast(col0->m_collisionShape); + btConvexShape* min1 = static_cast(col1->m_collisionShape); - GjkPairDetector::ClosestPointInput input; + btGjkPairDetector::ClosestPointInput input; //TODO: if (dispatchInfo.m_useContinuous) @@ -328,7 +328,7 @@ void ConvexConvexAlgorithm ::ProcessCollision (BroadphaseProxy* ,BroadphaseProxy bool disableCcd = false; -float ConvexConvexAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo) +float btConvexConvexAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) { ///Rather then checking ALL pairs, only calculate TOI when motion exceeds treshold @@ -336,8 +336,8 @@ float ConvexConvexAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* proxy0,Broad ///col0->m_worldTransform, float resultFraction = 1.f; - CollisionObject* col1 = static_cast(m_box1.m_clientObject); - CollisionObject* col0 = static_cast(m_box0.m_clientObject); + btCollisionObject* col1 = static_cast(m_box1.m_clientObject); + btCollisionObject* col0 = static_cast(m_box0.m_clientObject); float squareMot0 = (col0->m_interpolationWorldTransform.getOrigin() - col0->m_worldTransform.getOrigin()).length2(); @@ -366,14 +366,14 @@ float ConvexConvexAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* proxy0,Broad /// Convex0 against sphere for Convex1 { - ConvexShape* convex0 = static_cast(col0->m_collisionShape); + btConvexShape* convex0 = static_cast(col0->m_collisionShape); - SphereShape sphere1(col1->m_ccdSweptShereRadius); //todo: allow non-zero sphere sizes, for better approximation - ConvexCast::CastResult result; - VoronoiSimplexSolver voronoiSimplex; + btSphereShape sphere1(col1->m_ccdSweptShereRadius); //todo: allow non-zero sphere sizes, for better approximation + btConvexCast::CastResult result; + btVoronoiSimplexSolver voronoiSimplex; //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex); ///Simplification, one object is simplified as a sphere - GjkConvexCast ccd1( convex0 ,&sphere1,&voronoiSimplex); + btGjkConvexCast ccd1( convex0 ,&sphere1,&voronoiSimplex); //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0); if (ccd1.calcTimeOfImpact(col0->m_worldTransform,col0->m_interpolationWorldTransform, col1->m_worldTransform,col1->m_interpolationWorldTransform,result)) @@ -399,14 +399,14 @@ float ConvexConvexAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* proxy0,Broad /// Sphere (for convex0) against Convex1 { - ConvexShape* convex1 = static_cast(col1->m_collisionShape); + btConvexShape* convex1 = static_cast(col1->m_collisionShape); - SphereShape sphere0(col0->m_ccdSweptShereRadius); //todo: allow non-zero sphere sizes, for better approximation - ConvexCast::CastResult result; - VoronoiSimplexSolver voronoiSimplex; + btSphereShape sphere0(col0->m_ccdSweptShereRadius); //todo: allow non-zero sphere sizes, for better approximation + btConvexCast::CastResult result; + btVoronoiSimplexSolver voronoiSimplex; //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex); ///Simplification, one object is simplified as a sphere - GjkConvexCast ccd1(&sphere0,convex1,&voronoiSimplex); + btGjkConvexCast ccd1(&sphere0,convex1,&voronoiSimplex); //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0); if (ccd1.calcTimeOfImpact(col0->m_worldTransform,col0->m_interpolationWorldTransform, col1->m_worldTransform,col1->m_interpolationWorldTransform,result)) diff --git a/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h b/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h index 2c3e660b9..cae7e055d 100644 --- a/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h +++ b/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h @@ -23,21 +23,21 @@ subject to the following restrictions: #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" #include "btCollisionCreateFunc.h" -class ConvexPenetrationDepthSolver; +class btConvexPenetrationDepthSolver; ///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations. -class ConvexConvexAlgorithm : public CollisionAlgorithm +class btConvexConvexAlgorithm : public btCollisionAlgorithm { //ConvexPenetrationDepthSolver* m_penetrationDepthSolver; - VoronoiSimplexSolver m_simplexSolver; - GjkPairDetector m_gjkPairDetector; + btVoronoiSimplexSolver m_simplexSolver; + btGjkPairDetector m_gjkPairDetector; bool m_useEpa; public: - BroadphaseProxy m_box0; - BroadphaseProxy m_box1; + btBroadphaseProxy m_box0; + btBroadphaseProxy m_box1; bool m_ownManifold; - PersistentManifold* m_manifoldPtr; + btPersistentManifold* m_manifoldPtr; bool m_lowLevelOfDetail; void CheckPenetrationDepthSolver(); @@ -46,13 +46,13 @@ public: public: - ConvexConvexAlgorithm(PersistentManifold* mf,const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1); + btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - virtual ~ConvexConvexAlgorithm(); + virtual ~btConvexConvexAlgorithm(); - virtual void ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - virtual float CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); void SetLowLevelOfDetail(bool useLowLevel); @@ -64,16 +64,16 @@ public: m_gjkPairDetector.m_index1=index1; } - const PersistentManifold* GetManifold() + const btPersistentManifold* GetManifold() { return m_manifoldPtr; } - struct CreateFunc :public CollisionAlgorithmCreateFunc + struct CreateFunc :public btCollisionAlgorithmCreateFunc { - virtual CollisionAlgorithm* CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo& ci, BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) { - return new ConvexConvexAlgorithm(0,ci,proxy0,proxy1); + return new btConvexConvexAlgorithm(0,ci,proxy0,proxy1); } }; diff --git a/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp b/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp index 8ed38034c..0b45f26a6 100644 --- a/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp +++ b/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp @@ -17,17 +17,17 @@ subject to the following restrictions: -EmptyAlgorithm::EmptyAlgorithm(const CollisionAlgorithmConstructionInfo& ci) - : CollisionAlgorithm(ci) +btEmptyAlgorithm::btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) + : btCollisionAlgorithm(ci) { } -void EmptyAlgorithm::ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo) +void btEmptyAlgorithm::ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) { } -float EmptyAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo) +float btEmptyAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) { return 1.f; } diff --git a/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h b/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h index 12a7f0607..33606ddd3 100644 --- a/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h +++ b/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h @@ -21,23 +21,23 @@ subject to the following restrictions: #define ATTRIBUTE_ALIGNED(a) ///EmptyAlgorithm is a stub for unsupported collision pairs. -///The dispatcher can dispatch a persistent EmptyAlgorithm to avoid a search every frame. -class EmptyAlgorithm : public CollisionAlgorithm +///The dispatcher can dispatch a persistent btEmptyAlgorithm to avoid a search every frame. +class btEmptyAlgorithm : public btCollisionAlgorithm { public: - EmptyAlgorithm(const CollisionAlgorithmConstructionInfo& ci); + btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& ci); - virtual void ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - virtual float CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - struct CreateFunc :public CollisionAlgorithmCreateFunc + struct CreateFunc :public btCollisionAlgorithmCreateFunc { - virtual CollisionAlgorithm* CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo& ci, BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) { - return new EmptyAlgorithm(ci); + return new btEmptyAlgorithm(ci); } }; diff --git a/src/BulletCollision/CollisionDispatch/btManifoldResult.cpp b/src/BulletCollision/CollisionDispatch/btManifoldResult.cpp index 7bc5e828e..589efd708 100644 --- a/src/BulletCollision/CollisionDispatch/btManifoldResult.cpp +++ b/src/BulletCollision/CollisionDispatch/btManifoldResult.cpp @@ -22,12 +22,12 @@ subject to the following restrictions: ///This is to allow MaterialCombiner/Custom Friction/Restitution values ContactAddedCallback gContactAddedCallback=0; -///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= CollisionObject::customMaterialCallback; -inline SimdScalar calculateCombinedFriction(const CollisionObject* body0,const CollisionObject* body1) +///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback; +inline btScalar calculateCombinedFriction(const btCollisionObject* body0,const btCollisionObject* body1) { - SimdScalar friction = body0->getFriction() * body1->getFriction(); + btScalar friction = body0->getFriction() * body1->getFriction(); - const SimdScalar MAX_FRICTION = 10.f; + const btScalar MAX_FRICTION = 10.f; if (friction < -MAX_FRICTION) friction = -MAX_FRICTION; if (friction > MAX_FRICTION) @@ -36,14 +36,14 @@ inline SimdScalar calculateCombinedFriction(const CollisionObject* body0,const C } -inline SimdScalar calculateCombinedRestitution(const CollisionObject* body0,const CollisionObject* body1) +inline btScalar calculateCombinedRestitution(const btCollisionObject* body0,const btCollisionObject* body1) { return body0->getRestitution() * body1->getRestitution(); } -ManifoldResult::ManifoldResult(CollisionObject* body0,CollisionObject* body1,PersistentManifold* manifoldPtr) +btManifoldResult::btManifoldResult(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* manifoldPtr) :m_manifoldPtr(manifoldPtr), m_body0(body0), m_body1(body1) @@ -51,21 +51,21 @@ ManifoldResult::ManifoldResult(CollisionObject* body0,CollisionObject* body1,Per } -void ManifoldResult::AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth) +void btManifoldResult::AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth) { if (depth > m_manifoldPtr->GetContactBreakingTreshold()) return; - SimdTransform transAInv = m_body0->m_cachedInvertedWorldTransform; - SimdTransform transBInv= m_body1->m_cachedInvertedWorldTransform; + btTransform transAInv = m_body0->m_cachedInvertedWorldTransform; + btTransform transBInv= m_body1->m_cachedInvertedWorldTransform; //transAInv = m_body0->m_worldTransform.inverse(); //transBInv= m_body1->m_worldTransform.inverse(); - SimdVector3 pointA = pointInWorld + normalOnBInWorld * depth; - SimdVector3 localA = transAInv(pointA ); - SimdVector3 localB = transBInv(pointInWorld); - ManifoldPoint newPt(localA,localB,normalOnBInWorld,depth); + btVector3 pointA = pointInWorld + normalOnBInWorld * depth; + btVector3 localA = transAInv(pointA ); + btVector3 localB = transBInv(pointInWorld); + btManifoldPoint newPt(localA,localB,normalOnBInWorld,depth); @@ -74,7 +74,7 @@ void ManifoldResult::AddContactPoint(const SimdVector3& normalOnBInWorld,const S { // This is not needed, just use the old info! -// const ManifoldPoint& oldPoint = m_manifoldPtr->GetContactPoint(insertIndex); +// const btManifoldPoint& oldPoint = m_manifoldPtr->GetContactPoint(insertIndex); // newPt.CopyPersistentInformation(oldPoint); // m_manifoldPtr->ReplaceContactPoint(newPt,insertIndex); @@ -88,8 +88,8 @@ void ManifoldResult::AddContactPoint(const SimdVector3& normalOnBInWorld,const S //User can override friction and/or restitution if (gContactAddedCallback && //and if either of the two bodies requires custom material - ((m_body0->m_collisionFlags & CollisionObject::customMaterialCallback) || - (m_body1->m_collisionFlags & CollisionObject::customMaterialCallback))) + ((m_body0->m_collisionFlags & btCollisionObject::customMaterialCallback) || + (m_body1->m_collisionFlags & btCollisionObject::customMaterialCallback))) { //experimental feature info, for per-triangle material etc. (*gContactAddedCallback)(newPt,m_body0,m_partId0,m_index0,m_body1,m_partId1,m_index1); diff --git a/src/BulletCollision/CollisionDispatch/btManifoldResult.h b/src/BulletCollision/CollisionDispatch/btManifoldResult.h index 72bcdc4e8..8e6980422 100644 --- a/src/BulletCollision/CollisionDispatch/btManifoldResult.h +++ b/src/BulletCollision/CollisionDispatch/btManifoldResult.h @@ -18,30 +18,30 @@ subject to the following restrictions: #define MANIFOLD_RESULT_H #include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" -struct CollisionObject; -class PersistentManifold; -class ManifoldPoint; +struct btCollisionObject; +class btPersistentManifold; +class btManifoldPoint; -typedef bool (*ContactAddedCallback)(ManifoldPoint& cp, const CollisionObject* colObj0,int partId0,int index0,const CollisionObject* colObj1,int partId1,int index1); +typedef bool (*ContactAddedCallback)(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1); extern ContactAddedCallback gContactAddedCallback; ///ManifoldResult is a helper class to manage contact results. -class ManifoldResult : public DiscreteCollisionDetectorInterface::Result +class btManifoldResult : public btDiscreteCollisionDetectorInterface::Result { - PersistentManifold* m_manifoldPtr; - CollisionObject* m_body0; - CollisionObject* m_body1; + btPersistentManifold* m_manifoldPtr; + btCollisionObject* m_body0; + btCollisionObject* m_body1; int m_partId0; int m_partId1; int m_index0; int m_index1; public: - ManifoldResult(CollisionObject* body0,CollisionObject* body1,PersistentManifold* manifoldPtr); + btManifoldResult(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* manifoldPtr); - virtual ~ManifoldResult() {}; + virtual ~btManifoldResult() {}; virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1) { @@ -51,7 +51,7 @@ public: m_index1=index1; } - virtual void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth); + virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth); diff --git a/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp b/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp index b8430bd55..48ad8fa80 100644 --- a/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp +++ b/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp @@ -9,32 +9,32 @@ #include -SimulationIslandManager::SimulationIslandManager() +btSimulationIslandManager::btSimulationIslandManager() { } -SimulationIslandManager::~SimulationIslandManager() +btSimulationIslandManager::~btSimulationIslandManager() { } -void SimulationIslandManager::InitUnionFind(int n) +void btSimulationIslandManager::InitUnionFind(int n) { m_unionFind.reset(n); } -void SimulationIslandManager::FindUnions(Dispatcher* dispatcher) +void btSimulationIslandManager::FindUnions(btDispatcher* dispatcher) { { for (int i=0;iGetNumManifolds();i++) { - const PersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i); + const btPersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i); //static objects (invmass 0.f) don't merge ! - const CollisionObject* colObj0 = static_cast(manifold->GetBody0()); - const CollisionObject* colObj1 = static_cast(manifold->GetBody1()); + const btCollisionObject* colObj0 = static_cast(manifold->GetBody0()); + const btCollisionObject* colObj1 = static_cast(manifold->GetBody1()); if (((colObj0) && ((colObj0)->mergesSimulationIslands())) && ((colObj1) && ((colObj1)->mergesSimulationIslands()))) @@ -43,29 +43,26 @@ void SimulationIslandManager::FindUnions(Dispatcher* dispatcher) m_unionFind.unite((colObj0)->m_islandTag1, (colObj1)->m_islandTag1); } - - } } - } -void SimulationIslandManager::UpdateActivationState(CollisionWorld* colWorld,Dispatcher* dispatcher) +void btSimulationIslandManager::UpdateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher) { InitUnionFind(colWorld->GetCollisionObjectArray().size()); // put the index into m_controllers into m_tag { - std::vector::iterator i; + std::vector::iterator i; int index = 0; for (i=colWorld->GetCollisionObjectArray().begin(); !(i==colWorld->GetCollisionObjectArray().end()); i++) { - CollisionObject* collisionObject= (*i); + btCollisionObject* collisionObject= (*i); collisionObject->m_islandTag1 = index; collisionObject->m_hitFraction = 1.f; index++; @@ -83,19 +80,19 @@ void SimulationIslandManager::UpdateActivationState(CollisionWorld* colWorld,Dis -void SimulationIslandManager::StoreIslandActivationState(CollisionWorld* colWorld) +void btSimulationIslandManager::StoreIslandActivationState(btCollisionWorld* colWorld) { // put the islandId ('find' value) into m_tag { - std::vector::iterator i; + std::vector::iterator i; int index = 0; for (i=colWorld->GetCollisionObjectArray().begin(); !(i==colWorld->GetCollisionObjectArray().end()); i++) { - CollisionObject* collisionObject= (*i); + btCollisionObject* collisionObject= (*i); if (collisionObject->mergesSimulationIslands()) { @@ -109,17 +106,17 @@ void SimulationIslandManager::StoreIslandActivationState(CollisionWorld* colWorl } } -inline int getIslandId(const PersistentManifold* lhs) +inline int getIslandId(const btPersistentManifold* lhs) { int islandId; - const CollisionObject* rcolObj0 = static_cast(lhs->GetBody0()); - const CollisionObject* rcolObj1 = static_cast(lhs->GetBody1()); + const btCollisionObject* rcolObj0 = static_cast(lhs->GetBody0()); + const btCollisionObject* rcolObj1 = static_cast(lhs->GetBody1()); islandId= rcolObj0->m_islandTag1>=0?rcolObj0->m_islandTag1:rcolObj1->m_islandTag1; return islandId; } -bool PersistentManifoldSortPredicate(const PersistentManifold* lhs, const PersistentManifold* rhs) +bool btPersistentManifoldSortPredicate(const btPersistentManifold* lhs, const btPersistentManifold* rhs) { int rIslandId0,lIslandId0; rIslandId0 = getIslandId(rhs); @@ -131,7 +128,7 @@ bool PersistentManifoldSortPredicate(const PersistentManifold* lhs, const Persis // // todo: this is random access, it can be walked 'cache friendly'! // -void SimulationIslandManager::BuildAndProcessIslands(Dispatcher* dispatcher,CollisionObjectArray& collisionObjects, IslandCallback* callback) +void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback) { //we are going to sort the unionfind array, and store the element id in the size //afterwards, we clean unionfind, to make sure no-one uses it anymore @@ -158,7 +155,7 @@ void SimulationIslandManager::BuildAndProcessIslands(Dispatcher* dispatcher,Coll { int i = GetUnionFind().getElement(idx).m_sz; - CollisionObject* colObj0 = collisionObjects[i]; + btCollisionObject* colObj0 = collisionObjects[i]; if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1)) { printf("error in island management\n"); @@ -184,7 +181,7 @@ void SimulationIslandManager::BuildAndProcessIslands(Dispatcher* dispatcher,Coll for (idx=startIslandIndex;idxm_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1)) { printf("error in island management\n"); @@ -205,7 +202,7 @@ void SimulationIslandManager::BuildAndProcessIslands(Dispatcher* dispatcher,Coll { int i = GetUnionFind().getElement(idx).m_sz; - CollisionObject* colObj0 = collisionObjects[i]; + btCollisionObject* colObj0 = collisionObjects[i]; if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1)) { printf("error in island management\n"); @@ -224,17 +221,17 @@ void SimulationIslandManager::BuildAndProcessIslands(Dispatcher* dispatcher,Coll } } - std::vector islandmanifold; + std::vector islandmanifold; int i; int maxNumManifolds = dispatcher->GetNumManifolds(); islandmanifold.reserve(maxNumManifolds); for (i=0;iGetManifoldByIndexInternal(i); + btPersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i); - CollisionObject* colObj0 = static_cast(manifold->GetBody0()); - CollisionObject* colObj1 = static_cast(manifold->GetBody1()); + btCollisionObject* colObj0 = static_cast(manifold->GetBody0()); + btCollisionObject* colObj1 = static_cast(manifold->GetBody1()); //todo: check sleeping conditions! if (((colObj0) && colObj0->GetActivationState() != ISLAND_SLEEPING) || @@ -250,7 +247,7 @@ void SimulationIslandManager::BuildAndProcessIslands(Dispatcher* dispatcher,Coll // Sort manifolds, based on islands // Sort the vector using predicate and std::sort - std::sort(islandmanifold.begin(), islandmanifold.end(), PersistentManifoldSortPredicate); + std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate); //now process all active islands (sets of manifolds for now) diff --git a/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.h b/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.h index ca28685d8..6a28a960c 100644 --- a/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.h +++ b/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.h @@ -19,29 +19,29 @@ subject to the following restrictions: #include "BulletCollision/CollisionDispatch/btUnionFind.h" #include "btCollisionCreateFunc.h" -class CollisionWorld; -class Dispatcher; +class btCollisionWorld; +class btDispatcher; -///SimulationIslandManager creates and handles simulation islands, using UnionFind -class SimulationIslandManager +///SimulationIslandManager creates and handles simulation islands, using btUnionFind +class btSimulationIslandManager { - UnionFind m_unionFind; + btUnionFind m_unionFind; public: - SimulationIslandManager(); - virtual ~SimulationIslandManager(); + btSimulationIslandManager(); + virtual ~btSimulationIslandManager(); void InitUnionFind(int n); - UnionFind& GetUnionFind() { return m_unionFind;} + btUnionFind& GetUnionFind() { return m_unionFind;} - virtual void UpdateActivationState(CollisionWorld* colWorld,Dispatcher* dispatcher); - virtual void StoreIslandActivationState(CollisionWorld* world); + virtual void UpdateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher); + virtual void StoreIslandActivationState(btCollisionWorld* world); - void FindUnions(Dispatcher* dispatcher); + void FindUnions(btDispatcher* dispatcher); @@ -49,10 +49,10 @@ public: { virtual ~IslandCallback() {}; - virtual void ProcessIsland(class PersistentManifold** manifolds,int numManifolds) = 0; + virtual void ProcessIsland(class btPersistentManifold** manifolds,int numManifolds) = 0; }; - void BuildAndProcessIslands(Dispatcher* dispatcher,CollisionObjectArray& collisionObjects, IslandCallback* callback); + void BuildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback); }; diff --git a/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp b/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp index 6e2bd93b2..09a4f15b8 100644 --- a/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp +++ b/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp @@ -18,8 +18,8 @@ subject to the following restrictions: #include "BulletCollision/CollisionShapes/btSphereShape.h" #include "BulletCollision/CollisionDispatch/btCollisionObject.h" -SphereSphereCollisionAlgorithm::SphereSphereCollisionAlgorithm(PersistentManifold* mf,const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) -: CollisionAlgorithm(ci), +btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) +: btCollisionAlgorithm(ci), m_ownManifold(false), m_manifoldPtr(mf) { @@ -30,7 +30,7 @@ m_manifoldPtr(mf) } } -SphereSphereCollisionAlgorithm::~SphereSphereCollisionAlgorithm() +btSphereSphereCollisionAlgorithm::~btSphereSphereCollisionAlgorithm() { if (m_ownManifold) { @@ -39,42 +39,42 @@ SphereSphereCollisionAlgorithm::~SphereSphereCollisionAlgorithm() } } -void SphereSphereCollisionAlgorithm::ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo) +void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) { if (!m_manifoldPtr) return; - CollisionObject* col0 = static_cast(proxy0->m_clientObject); - CollisionObject* col1 = static_cast(proxy1->m_clientObject); - SphereShape* sphere0 = (SphereShape*)col0->m_collisionShape; - SphereShape* sphere1 = (SphereShape*)col1->m_collisionShape; + btCollisionObject* col0 = static_cast(proxy0->m_clientObject); + btCollisionObject* col1 = static_cast(proxy1->m_clientObject); + btSphereShape* sphere0 = (btSphereShape*)col0->m_collisionShape; + btSphereShape* sphere1 = (btSphereShape*)col1->m_collisionShape; - SimdVector3 diff = col0->m_worldTransform.getOrigin()- col1->m_worldTransform.getOrigin(); + btVector3 diff = col0->m_worldTransform.getOrigin()- col1->m_worldTransform.getOrigin(); float len = diff.length(); - SimdScalar radius0 = sphere0->GetRadius(); - SimdScalar radius1 = sphere1->GetRadius(); + btScalar radius0 = sphere0->GetRadius(); + btScalar radius1 = sphere1->GetRadius(); ///iff distance positive, don't generate a new contact if ( len > (radius0+radius1)) return; ///distance (negative means penetration) - SimdScalar dist = len - (radius0+radius1); + btScalar dist = len - (radius0+radius1); - SimdVector3 normalOnSurfaceB = diff / len; + btVector3 normalOnSurfaceB = diff / len; ///point on A (worldspace) - SimdVector3 pos0 = col0->m_worldTransform.getOrigin() - radius0 * normalOnSurfaceB; + btVector3 pos0 = col0->m_worldTransform.getOrigin() - radius0 * normalOnSurfaceB; ///point on B (worldspace) - SimdVector3 pos1 = col1->m_worldTransform.getOrigin() + radius1* normalOnSurfaceB; + btVector3 pos1 = col1->m_worldTransform.getOrigin() + radius1* normalOnSurfaceB; /// report a contact. internally this will be kept persistent, and contact reduction is done - ManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); + btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); resultOut->AddContactPoint(normalOnSurfaceB,pos1,dist); m_dispatcher->ReleaseManifoldResult(resultOut); } -float SphereSphereCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo) +float btSphereSphereCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) { //not yet return 1.f; diff --git a/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h b/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h index 58647d79e..d0a1a75c0 100644 --- a/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h +++ b/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h @@ -19,33 +19,33 @@ subject to the following restrictions: #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -class PersistentManifold; +class btPersistentManifold; -/// SphereSphereCollisionAlgorithm provides sphere-sphere collision detection. +/// btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection. /// Other features are frame-coherency (persistent data) and collision response. -/// Also provides the most basic sample for custom/user CollisionAlgorithm -class SphereSphereCollisionAlgorithm : public CollisionAlgorithm +/// Also provides the most basic sample for custom/user btCollisionAlgorithm +class btSphereSphereCollisionAlgorithm : public btCollisionAlgorithm { bool m_ownManifold; - PersistentManifold* m_manifoldPtr; + btPersistentManifold* m_manifoldPtr; public: - SphereSphereCollisionAlgorithm(const CollisionAlgorithmConstructionInfo& ci) - : CollisionAlgorithm(ci) {} + btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) + : btCollisionAlgorithm(ci) {} - virtual void ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - virtual float CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const DispatcherInfo& dispatchInfo); + virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); - SphereSphereCollisionAlgorithm(PersistentManifold* mf,const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1); + btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - virtual ~SphereSphereCollisionAlgorithm(); + virtual ~btSphereSphereCollisionAlgorithm(); - struct CreateFunc :public CollisionAlgorithmCreateFunc + struct CreateFunc :public btCollisionAlgorithmCreateFunc { - virtual CollisionAlgorithm* CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo& ci, BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) { - return new SphereSphereCollisionAlgorithm(0,ci,proxy0,proxy1); + return new btSphereSphereCollisionAlgorithm(0,ci,proxy0,proxy1); } }; diff --git a/src/BulletCollision/CollisionDispatch/btUnionFind.cpp b/src/BulletCollision/CollisionDispatch/btUnionFind.cpp index 23602e0f5..7a71d479a 100644 --- a/src/BulletCollision/CollisionDispatch/btUnionFind.cpp +++ b/src/BulletCollision/CollisionDispatch/btUnionFind.cpp @@ -19,28 +19,28 @@ subject to the following restrictions: -UnionFind::~UnionFind() +btUnionFind::~btUnionFind() { Free(); } -UnionFind::UnionFind() +btUnionFind::btUnionFind() { } -void UnionFind::Allocate(int N) +void btUnionFind::Allocate(int N) { m_elements.resize(N); } -void UnionFind::Free() +void btUnionFind::Free() { m_elements.clear(); } -void UnionFind::reset(int N) +void btUnionFind::reset(int N) { Allocate(N); @@ -50,15 +50,15 @@ void UnionFind::reset(int N) } } -bool UnionFindElementSortPredicate(const Element& lhs, const Element& rhs) +bool btUnionFindElementSortPredicate(const btElement& lhs, const btElement& rhs) { return lhs.m_id < rhs.m_id; } -///this is a special operation, destroying the content of UnionFind. +///this is a special operation, destroying the content of btUnionFind. ///it sorts the elements, based on island id, in order to make it easy to iterate over islands -void UnionFind::sortIslands() +void btUnionFind::sortIslands() { //first store the original body index, and islandId @@ -71,7 +71,7 @@ void UnionFind::sortIslands() } // Sort the vector using predicate and std::sort - std::sort(m_elements.begin(), m_elements.end(), UnionFindElementSortPredicate); + std::sort(m_elements.begin(), m_elements.end(), btUnionFindElementSortPredicate); } diff --git a/src/BulletCollision/CollisionDispatch/btUnionFind.h b/src/BulletCollision/CollisionDispatch/btUnionFind.h index ac7071bed..2afe01c16 100644 --- a/src/BulletCollision/CollisionDispatch/btUnionFind.h +++ b/src/BulletCollision/CollisionDispatch/btUnionFind.h @@ -17,7 +17,7 @@ subject to the following restrictions: #define UNION_FIND_H #include -struct Element +struct btElement { int m_id; int m_sz; @@ -26,18 +26,18 @@ struct Element ///UnionFind calculates connected subsets // Implements weighted Quick Union with path compression // optimization: could use short ints instead of ints (halving memory, would limit the number of rigid bodies to 64k, sounds reasonable) -class UnionFind +class btUnionFind { private: - std::vector m_elements; + std::vector m_elements; public: - UnionFind(); - ~UnionFind(); + btUnionFind(); + ~btUnionFind(); - //this is a special operation, destroying the content of UnionFind. + //this is a special operation, destroying the content of btUnionFind. //it sorts the elements, based on island id, in order to make it easy to iterate over islands void sortIslands(); @@ -52,11 +52,11 @@ class UnionFind return (x == m_elements[x].m_id); } - Element& getElement(int index) + btElement& getElement(int index) { return m_elements[index]; } - const Element& getElement(int index) const + const btElement& getElement(int index) const { return m_elements[index]; } diff --git a/src/BulletCollision/CollisionShapes/btBoxShape.cpp b/src/BulletCollision/CollisionShapes/btBoxShape.cpp index 3ffeda648..f08b6248b 100644 --- a/src/BulletCollision/CollisionShapes/btBoxShape.cpp +++ b/src/BulletCollision/CollisionShapes/btBoxShape.cpp @@ -15,23 +15,23 @@ subject to the following restrictions: #include "btBoxShape.h" -SimdVector3 BoxShape::GetHalfExtents() const +btVector3 btBoxShape::GetHalfExtents() const { return m_boxHalfExtents1 * m_localScaling; } //{ -void BoxShape::GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const +void btBoxShape::GetAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const { - SimdVector3 halfExtents = GetHalfExtents(); + btVector3 halfExtents = GetHalfExtents(); - SimdMatrix3x3 abs_b = t.getBasis().absolute(); - SimdPoint3 center = t.getOrigin(); - SimdVector3 extent = SimdVector3(abs_b[0].dot(halfExtents), + btMatrix3x3 abs_b = t.getBasis().absolute(); + btPoint3 center = t.getOrigin(); + btVector3 extent = btVector3(abs_b[0].dot(halfExtents), abs_b[1].dot(halfExtents), abs_b[2].dot(halfExtents)); - extent += SimdVector3(GetMargin(),GetMargin(),GetMargin()); + extent += btVector3(GetMargin(),GetMargin(),GetMargin()); aabbMin = center - extent; aabbMax = center + extent; @@ -40,14 +40,14 @@ void BoxShape::GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& } -void BoxShape::CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia) +void btBoxShape::CalculateLocalInertia(btScalar mass,btVector3& inertia) { //float margin = 0.f; - SimdVector3 halfExtents = GetHalfExtents(); + btVector3 halfExtents = GetHalfExtents(); - SimdScalar lx=2.f*(halfExtents.x()); - SimdScalar ly=2.f*(halfExtents.y()); - SimdScalar lz=2.f*(halfExtents.z()); + btScalar lx=2.f*(halfExtents.x()); + btScalar ly=2.f*(halfExtents.y()); + btScalar lz=2.f*(halfExtents.z()); inertia[0] = mass/(12.0f) * (ly*ly + lz*lz); inertia[1] = mass/(12.0f) * (lx*lx + lz*lz); diff --git a/src/BulletCollision/CollisionShapes/btBoxShape.h b/src/BulletCollision/CollisionShapes/btBoxShape.h index fe8c2579a..dc4990894 100644 --- a/src/BulletCollision/CollisionShapes/btBoxShape.h +++ b/src/BulletCollision/CollisionShapes/btBoxShape.h @@ -19,82 +19,82 @@ subject to the following restrictions: #include "btPolyhedralConvexShape.h" #include "BulletCollision/CollisionShapes/btCollisionMargin.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "LinearMath/SimdPoint3.h" -#include "LinearMath/SimdMinMax.h" +#include "LinearMath/btPoint3.h" +#include "LinearMath/btSimdMinMax.h" ///BoxShape implements both a feature based (vertex/edge/plane) and implicit (getSupportingVertex) Box -class BoxShape: public PolyhedralConvexShape +class btBoxShape: public btPolyhedralConvexShape { - SimdVector3 m_boxHalfExtents1; + btVector3 m_boxHalfExtents1; public: - SimdVector3 GetHalfExtents() const; + btVector3 GetHalfExtents() const; //{ return m_boxHalfExtents1 * m_localScaling;} - //const SimdVector3& GetHalfExtents() const{ return m_boxHalfExtents1;} + //const btVector3& GetHalfExtents() const{ return m_boxHalfExtents1;} virtual int GetShapeType() const { return BOX_SHAPE_PROXYTYPE;} - virtual SimdVector3 LocalGetSupportingVertex(const SimdVector3& vec) const + virtual btVector3 LocalGetSupportingVertex(const btVector3& vec) const { - SimdVector3 halfExtents = GetHalfExtents(); + btVector3 halfExtents = GetHalfExtents(); - SimdVector3 supVertex; - supVertex = SimdPoint3(vec.x() < SimdScalar(0.0f) ? -halfExtents.x() : halfExtents.x(), - vec.y() < SimdScalar(0.0f) ? -halfExtents.y() : halfExtents.y(), - vec.z() < SimdScalar(0.0f) ? -halfExtents.z() : halfExtents.z()); + btVector3 supVertex; + supVertex = btPoint3(vec.x() < btScalar(0.0f) ? -halfExtents.x() : halfExtents.x(), + vec.y() < btScalar(0.0f) ? -halfExtents.y() : halfExtents.y(), + vec.z() < btScalar(0.0f) ? -halfExtents.z() : halfExtents.z()); return supVertex; } - virtual inline SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const + virtual inline btVector3 LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const { - SimdVector3 halfExtents = GetHalfExtents(); - SimdVector3 margin(GetMargin(),GetMargin(),GetMargin()); + btVector3 halfExtents = GetHalfExtents(); + btVector3 margin(GetMargin(),GetMargin(),GetMargin()); halfExtents -= margin; - return SimdVector3(vec.x() < SimdScalar(0.0f) ? -halfExtents.x() : halfExtents.x(), - vec.y() < SimdScalar(0.0f) ? -halfExtents.y() : halfExtents.y(), - vec.z() < SimdScalar(0.0f) ? -halfExtents.z() : halfExtents.z()); + return btVector3(vec.x() < btScalar(0.0f) ? -halfExtents.x() : halfExtents.x(), + vec.y() < btScalar(0.0f) ? -halfExtents.y() : halfExtents.y(), + vec.z() < btScalar(0.0f) ? -halfExtents.z() : halfExtents.z()); } - virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const + virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const { - SimdVector3 halfExtents = GetHalfExtents(); - SimdVector3 margin(GetMargin(),GetMargin(),GetMargin()); + btVector3 halfExtents = GetHalfExtents(); + btVector3 margin(GetMargin(),GetMargin(),GetMargin()); halfExtents -= margin; for (int i=0;i>1)) - halfExtents.y() * ((i&2)>>1), halfExtents.z() * (1-((i&4)>>2)) - halfExtents.z() * ((i&4)>>2)); } - virtual void GetPlaneEquation(SimdVector4& plane,int i) const + virtual void GetPlaneEquation(btVector4& plane,int i) const { - SimdVector3 halfExtents = GetHalfExtents(); + btVector3 halfExtents = GetHalfExtents(); switch (i) { @@ -162,7 +162,7 @@ public: } - virtual void GetEdge(int i,SimdPoint3& pa,SimdPoint3& pb) const + virtual void GetEdge(int i,btPoint3& pa,btPoint3& pb) const //virtual void GetEdge(int i,Edge& edge) const { int edgeVert0 = 0; @@ -233,11 +233,11 @@ public: - virtual bool IsInside(const SimdPoint3& pt,SimdScalar tolerance) const + virtual bool IsInside(const btPoint3& pt,btScalar tolerance) const { - SimdVector3 halfExtents = GetHalfExtents(); + btVector3 halfExtents = GetHalfExtents(); - //SimdScalar minDist = 2*tolerance; + //btScalar minDist = 2*tolerance; bool result = (pt.x() <= (halfExtents.x()+tolerance)) && (pt.x() >= (-halfExtents.x()-tolerance)) && diff --git a/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp b/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp index 065492381..cc8f734e2 100644 --- a/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp +++ b/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp @@ -21,50 +21,50 @@ subject to the following restrictions: ///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization. ///Uses an interface to access the triangles to allow for sharing graphics/physics triangles. -BvhTriangleMeshShape::BvhTriangleMeshShape(StridingMeshInterface* meshInterface) -:TriangleMeshShape(meshInterface) +btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface) +:btTriangleMeshShape(meshInterface) { //construct bvh from meshInterface #ifndef DISABLE_BVH - m_bvh = new OptimizedBvh(); + m_bvh = new btOptimizedBvh(); m_bvh->Build(meshInterface); #endif //DISABLE_BVH } -BvhTriangleMeshShape::~BvhTriangleMeshShape() +btBvhTriangleMeshShape::~btBvhTriangleMeshShape() { delete m_bvh; } //perform bvh tree traversal and report overlapping triangles to 'callback' -void BvhTriangleMeshShape::ProcessAllTriangles(TriangleCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const +void btBvhTriangleMeshShape::ProcessAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const { #ifdef DISABLE_BVH //brute force traverse all triangles - TriangleMeshShape::ProcessAllTriangles(callback,aabbMin,aabbMax); + btTriangleMeshShape::ProcessAllTriangles(callback,aabbMin,aabbMax); #else //first get all the nodes - struct MyNodeOverlapCallback : public NodeOverlapCallback + struct MyNodeOverlapCallback : public btNodeOverlapCallback { - StridingMeshInterface* m_meshInterface; - TriangleCallback* m_callback; - SimdVector3 m_triangle[3]; + btStridingMeshInterface* m_meshInterface; + btTriangleCallback* m_callback; + btVector3 m_triangle[3]; - MyNodeOverlapCallback(TriangleCallback* callback,StridingMeshInterface* meshInterface) + MyNodeOverlapCallback(btTriangleCallback* callback,btStridingMeshInterface* meshInterface) :m_meshInterface(meshInterface), m_callback(callback) { } - virtual void ProcessNode(const OptimizedBvhNode* node) + virtual void ProcessNode(const btOptimizedBvhNode* node) { const unsigned char *vertexbase; int numverts; @@ -89,7 +89,7 @@ void BvhTriangleMeshShape::ProcessAllTriangles(TriangleCallback* callback,const int* gfxbase = (int*)(indexbase+node->m_triangleIndex*indexstride); - const SimdVector3& meshScaling = m_meshInterface->getScaling(); + const btVector3& meshScaling = m_meshInterface->getScaling(); for (int j=2;j>=0;j--) { @@ -99,7 +99,7 @@ void BvhTriangleMeshShape::ProcessAllTriangles(TriangleCallback* callback,const #endif //DEBUG_TRIANGLE_MESH float* graphicsbase = (float*)(vertexbase+graphicsindex*stride); - m_triangle[j] = SimdVector3( + m_triangle[j] = btVector3( graphicsbase[0]*meshScaling.getX(), graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ()); @@ -125,13 +125,13 @@ void BvhTriangleMeshShape::ProcessAllTriangles(TriangleCallback* callback,const } -void BvhTriangleMeshShape::setLocalScaling(const SimdVector3& scaling) +void btBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling) { if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON) { - TriangleMeshShape::setLocalScaling(scaling); + btTriangleMeshShape::setLocalScaling(scaling); delete m_bvh; - m_bvh = new OptimizedBvh(); + m_bvh = new btOptimizedBvh(); m_bvh->Build(m_meshInterface); //rebuild the bvh... } diff --git a/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h b/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h index 7858d5aa4..6e1d23b2f 100644 --- a/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h +++ b/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h @@ -21,16 +21,16 @@ subject to the following restrictions: ///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization. ///Uses an interface to access the triangles to allow for sharing graphics/physics triangles. -class BvhTriangleMeshShape : public TriangleMeshShape +class btBvhTriangleMeshShape : public btTriangleMeshShape { - OptimizedBvh* m_bvh; + btOptimizedBvh* m_bvh; public: - BvhTriangleMeshShape(StridingMeshInterface* meshInterface); + btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface); - virtual ~BvhTriangleMeshShape(); + virtual ~btBvhTriangleMeshShape(); /* @@ -42,14 +42,14 @@ public: - virtual void ProcessAllTriangles(TriangleCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const; + virtual void ProcessAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; //debugging virtual char* GetName()const {return "BVHTRIANGLEMESH";} - virtual void setLocalScaling(const SimdVector3& scaling); + virtual void setLocalScaling(const btVector3& scaling); diff --git a/src/BulletCollision/CollisionShapes/btCollisionShape.cpp b/src/BulletCollision/CollisionShapes/btCollisionShape.cpp index 0e53da838..42d73cf9f 100644 --- a/src/BulletCollision/CollisionShapes/btCollisionShape.cpp +++ b/src/BulletCollision/CollisionShapes/btCollisionShape.cpp @@ -15,11 +15,11 @@ subject to the following restrictions: #include "BulletCollision/CollisionShapes/btCollisionShape.h" -void CollisionShape::GetBoundingSphere(SimdVector3& center,SimdScalar& radius) const +void btCollisionShape::GetBoundingSphere(btVector3& center,btScalar& radius) const { - SimdTransform tr; + btTransform tr; tr.setIdentity(); - SimdVector3 aabbMin,aabbMax; + btVector3 aabbMin,aabbMax; GetAabb(tr,aabbMin,aabbMax); @@ -27,16 +27,16 @@ void CollisionShape::GetBoundingSphere(SimdVector3& center,SimdScalar& radius) c center = (aabbMin+aabbMax)*0.5f; } -float CollisionShape::GetAngularMotionDisc() const +float btCollisionShape::GetAngularMotionDisc() const { - SimdVector3 center; + btVector3 center; float disc; GetBoundingSphere(center,disc); disc += (center).length(); return disc; } -void CollisionShape::CalculateTemporalAabb(const SimdTransform& curTrans,const SimdVector3& linvel,const SimdVector3& angvel,SimdScalar timeStep, SimdVector3& temporalAabbMin,SimdVector3& temporalAabbMax) +void btCollisionShape::CalculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) { //start with static aabb GetAabb(curTrans,temporalAabbMin,temporalAabbMax); @@ -49,7 +49,7 @@ void CollisionShape::CalculateTemporalAabb(const SimdTransform& curTrans,const S float temporalAabbMinz = temporalAabbMin.getZ(); // add linear motion - SimdVector3 linMotion = linvel*timeStep; + btVector3 linMotion = linvel*timeStep; //todo: simd would have a vector max/min operation, instead of per-element access if (linMotion.x() > 0.f) temporalAabbMaxx += linMotion.x(); @@ -65,10 +65,10 @@ void CollisionShape::CalculateTemporalAabb(const SimdTransform& curTrans,const S temporalAabbMinz += linMotion.z(); //add conservative angular motion - SimdScalar angularMotion = angvel.length() * GetAngularMotionDisc() * timeStep; - SimdVector3 angularMotion3d(angularMotion,angularMotion,angularMotion); - temporalAabbMin = SimdVector3(temporalAabbMinx,temporalAabbMiny,temporalAabbMinz); - temporalAabbMax = SimdVector3(temporalAabbMaxx,temporalAabbMaxy,temporalAabbMaxz); + btScalar angularMotion = angvel.length() * GetAngularMotionDisc() * timeStep; + btVector3 angularMotion3d(angularMotion,angularMotion,angularMotion); + temporalAabbMin = btVector3(temporalAabbMinx,temporalAabbMiny,temporalAabbMinz); + temporalAabbMax = btVector3(temporalAabbMaxx,temporalAabbMaxy,temporalAabbMaxz); temporalAabbMin -= angularMotion3d; temporalAabbMax += angularMotion3d; diff --git a/src/BulletCollision/CollisionShapes/btCollisionShape.h b/src/BulletCollision/CollisionShapes/btCollisionShape.h index 9a7fd3044..291a49220 100644 --- a/src/BulletCollision/CollisionShapes/btCollisionShape.h +++ b/src/BulletCollision/CollisionShapes/btCollisionShape.h @@ -16,27 +16,27 @@ subject to the following restrictions: #ifndef COLLISION_SHAPE_H #define COLLISION_SHAPE_H -#include "LinearMath/SimdTransform.h" -#include "LinearMath/SimdVector3.h" -#include -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btTransform.h" +#include "LinearMath/btVector3.h" +#include +#include "LinearMath/btPoint3.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types ///CollisionShape provides generic interface for collidable objects -class CollisionShape +class btCollisionShape { public: - CollisionShape() :m_tempDebug(0) + btCollisionShape() :m_tempDebug(0) { } - virtual ~CollisionShape() + virtual ~btCollisionShape() { } - virtual void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const =0; + virtual void GetAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0; - virtual void GetBoundingSphere(SimdVector3& center,SimdScalar& radius) const; + virtual void GetBoundingSphere(btVector3& center,btScalar& radius) const; virtual float GetAngularMotionDisc() const; @@ -44,30 +44,30 @@ public: ///CalculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep) ///result is conservative - void CalculateTemporalAabb(const SimdTransform& curTrans,const SimdVector3& linvel,const SimdVector3& angvel,SimdScalar timeStep, SimdVector3& temporalAabbMin,SimdVector3& temporalAabbMax); + void CalculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax); inline bool IsPolyhedral() const { - return BroadphaseProxy::IsPolyhedral(GetShapeType()); + return btBroadphaseProxy::IsPolyhedral(GetShapeType()); } inline bool IsConvex() const { - return BroadphaseProxy::IsConvex(GetShapeType()); + return btBroadphaseProxy::IsConvex(GetShapeType()); } inline bool IsConcave() const { - return BroadphaseProxy::IsConcave(GetShapeType()); + return btBroadphaseProxy::IsConcave(GetShapeType()); } inline bool IsCompound() const { - return BroadphaseProxy::IsCompound(GetShapeType()); + return btBroadphaseProxy::IsCompound(GetShapeType()); } - virtual void setLocalScaling(const SimdVector3& scaling) =0; - virtual const SimdVector3& getLocalScaling() const =0; + virtual void setLocalScaling(const btVector3& scaling) =0; + virtual const btVector3& getLocalScaling() const =0; - virtual void CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia) = 0; + virtual void CalculateLocalInertia(btScalar mass,btVector3& inertia) = 0; //debugging support virtual char* GetName()const =0 ; diff --git a/src/BulletCollision/CollisionShapes/btCompoundShape.cpp b/src/BulletCollision/CollisionShapes/btCompoundShape.cpp index 053c1335a..a4453a3ae 100644 --- a/src/BulletCollision/CollisionShapes/btCompoundShape.cpp +++ b/src/BulletCollision/CollisionShapes/btCompoundShape.cpp @@ -19,7 +19,7 @@ subject to the following restrictions: #include "btCollisionShape.h" -CompoundShape::CompoundShape() +btCompoundShape::btCompoundShape() :m_localAabbMin(1e30f,1e30f,1e30f), m_localAabbMax(-1e30f,-1e30f,-1e30f), m_aabbTree(0), @@ -29,17 +29,17 @@ m_localScaling(1.f,1.f,1.f) } -CompoundShape::~CompoundShape() +btCompoundShape::~btCompoundShape() { } -void CompoundShape::AddChildShape(const SimdTransform& localTransform,CollisionShape* shape) +void btCompoundShape::AddChildShape(const btTransform& localTransform,btCollisionShape* shape) { m_childTransforms.push_back(localTransform); m_childShapes.push_back(shape); //extend the local aabbMin/aabbMax - SimdVector3 localAabbMin,localAabbMax; + btVector3 localAabbMin,localAabbMax; shape->GetAabb(localTransform,localAabbMin,localAabbMax); for (int i=0;i<3;i++) { @@ -58,37 +58,37 @@ void CompoundShape::AddChildShape(const SimdTransform& localTransform,CollisionS ///GetAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version -void CompoundShape::GetAabb(const SimdTransform& trans,SimdVector3& aabbMin,SimdVector3& aabbMax) const +void btCompoundShape::GetAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const { - SimdVector3 localHalfExtents = 0.5f*(m_localAabbMax-m_localAabbMin); - SimdVector3 localCenter = 0.5f*(m_localAabbMax+m_localAabbMin); + btVector3 localHalfExtents = 0.5f*(m_localAabbMax-m_localAabbMin); + btVector3 localCenter = 0.5f*(m_localAabbMax+m_localAabbMin); - SimdMatrix3x3 abs_b = trans.getBasis().absolute(); + btMatrix3x3 abs_b = trans.getBasis().absolute(); - SimdPoint3 center = trans(localCenter); + btPoint3 center = trans(localCenter); - SimdVector3 extent = SimdVector3(abs_b[0].dot(localHalfExtents), + btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents), abs_b[1].dot(localHalfExtents), abs_b[2].dot(localHalfExtents)); - extent += SimdVector3(GetMargin(),GetMargin(),GetMargin()); + extent += btVector3(GetMargin(),GetMargin(),GetMargin()); aabbMin = center - extent; aabbMax = center + extent; } -void CompoundShape::CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia) +void btCompoundShape::CalculateLocalInertia(btScalar mass,btVector3& inertia) { //approximation: take the inertia from the aabb for now - SimdTransform ident; + btTransform ident; ident.setIdentity(); - SimdVector3 aabbMin,aabbMax; + btVector3 aabbMin,aabbMax; GetAabb(ident,aabbMin,aabbMax); - SimdVector3 halfExtents = (aabbMax-aabbMin)*0.5f; + btVector3 halfExtents = (aabbMax-aabbMin)*0.5f; - SimdScalar lx=2.f*(halfExtents.x()); - SimdScalar ly=2.f*(halfExtents.y()); - SimdScalar lz=2.f*(halfExtents.z()); + btScalar lx=2.f*(halfExtents.x()); + btScalar ly=2.f*(halfExtents.y()); + btScalar lz=2.f*(halfExtents.z()); inertia[0] = mass/(12.0f) * (ly*ly + lz*lz); inertia[1] = mass/(12.0f) * (lx*lx + lz*lz); diff --git a/src/BulletCollision/CollisionShapes/btCompoundShape.h b/src/BulletCollision/CollisionShapes/btCompoundShape.h index 5d42e14f4..a2428b263 100644 --- a/src/BulletCollision/CollisionShapes/btCompoundShape.h +++ b/src/BulletCollision/CollisionShapes/btCompoundShape.h @@ -18,69 +18,69 @@ subject to the following restrictions: #include "btCollisionShape.h" -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdTransform.h" -#include "LinearMath/SimdMatrix3x3.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btTransform.h" +#include "LinearMath/btMatrix3x3.h" #include #include "BulletCollision/CollisionShapes/btCollisionMargin.h" -class OptimizedBvh; +class btOptimizedBvh; -/// CompoundShape allows to store multiple other CollisionShapes -/// This allows for concave collision objects. This is more general then the Static Concave TriangleMeshShape. -class CompoundShape : public CollisionShape +/// btCompoundShape allows to store multiple other btCollisionShapes +/// This allows for concave collision objects. This is more general then the Static Concave btTriangleMeshShape. +class btCompoundShape : public btCollisionShape { - std::vector m_childTransforms; - std::vector m_childShapes; - SimdVector3 m_localAabbMin; - SimdVector3 m_localAabbMax; + std::vector m_childTransforms; + std::vector m_childShapes; + btVector3 m_localAabbMin; + btVector3 m_localAabbMax; - OptimizedBvh* m_aabbTree; + btOptimizedBvh* m_aabbTree; public: - CompoundShape(); + btCompoundShape(); - virtual ~CompoundShape(); + virtual ~btCompoundShape(); - void AddChildShape(const SimdTransform& localTransform,CollisionShape* shape); + void AddChildShape(const btTransform& localTransform,btCollisionShape* shape); int GetNumChildShapes() const { return m_childShapes.size(); } - CollisionShape* GetChildShape(int index) + btCollisionShape* GetChildShape(int index) { return m_childShapes[index]; } - const CollisionShape* GetChildShape(int index) const + const btCollisionShape* GetChildShape(int index) const { return m_childShapes[index]; } - SimdTransform GetChildTransform(int index) + btTransform GetChildTransform(int index) { return m_childTransforms[index]; } - const SimdTransform GetChildTransform(int index) const + const btTransform GetChildTransform(int index) const { return m_childTransforms[index]; } ///GetAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version - void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const; + void GetAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - virtual void setLocalScaling(const SimdVector3& scaling) + virtual void setLocalScaling(const btVector3& scaling) { m_localScaling = scaling; } - virtual const SimdVector3& getLocalScaling() const + virtual const btVector3& getLocalScaling() const { return m_localScaling; } - virtual void CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia); + virtual void CalculateLocalInertia(btScalar mass,btVector3& inertia); virtual int GetShapeType() const { return COMPOUND_SHAPE_PROXYTYPE;} @@ -100,15 +100,15 @@ public: //this is optional, but should make collision queries faster, by culling non-overlapping nodes void CreateAabbTreeFromChildren(); - const OptimizedBvh* GetAabbTree() const + const btOptimizedBvh* GetAabbTree() const { return m_aabbTree; } private: - SimdScalar m_collisionMargin; + btScalar m_collisionMargin; protected: - SimdVector3 m_localScaling; + btVector3 m_localScaling; }; diff --git a/src/BulletCollision/CollisionShapes/btConcaveShape.h b/src/BulletCollision/CollisionShapes/btConcaveShape.h index 06b5ed91b..7e6816011 100644 --- a/src/BulletCollision/CollisionShapes/btConcaveShape.h +++ b/src/BulletCollision/CollisionShapes/btConcaveShape.h @@ -24,7 +24,7 @@ subject to the following restrictions: ///Concave shape proves an interface concave shapes that can produce triangles that overlapping a given AABB. ///Static triangle mesh, infinite plane, height field/landscapes are example that implement this interface. -class ConcaveShape : public CollisionShape +class ConcaveShape : public btCollisionShape { protected: float m_collisionMargin; @@ -34,7 +34,7 @@ public: virtual ~ConcaveShape(); - virtual void ProcessAllTriangles(TriangleCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const = 0; + virtual void ProcessAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const = 0; virtual float GetMargin() const { return m_collisionMargin; diff --git a/src/BulletCollision/CollisionShapes/btConeShape.cpp b/src/BulletCollision/CollisionShapes/btConeShape.cpp index f8a2658de..c87abacbc 100644 --- a/src/BulletCollision/CollisionShapes/btConeShape.cpp +++ b/src/BulletCollision/CollisionShapes/btConeShape.cpp @@ -14,7 +14,7 @@ subject to the following restrictions: */ #include "btConeShape.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btPoint3.h" #ifdef WIN32 static int coneindices[3] = {1,2,0}; @@ -22,23 +22,23 @@ static int coneindices[3] = {1,2,0}; static int coneindices[3] = {2,1,0}; #endif -ConeShape::ConeShape (SimdScalar radius,SimdScalar height): +btConeShape::btConeShape (btScalar radius,btScalar height): m_radius (radius), m_height(height) { - SimdVector3 halfExtents; + btVector3 halfExtents; m_sinAngle = (m_radius / sqrt(m_radius * m_radius + m_height * m_height)); } -SimdVector3 ConeShape::ConeLocalSupport(const SimdVector3& v) const +btVector3 btConeShape::ConeLocalSupport(const btVector3& v) const { float halfHeight = m_height * 0.5f; if (v[coneindices[1]] > v.length() * m_sinAngle) { - SimdVector3 tmp; + btVector3 tmp; tmp[coneindices[0]] = 0.f; tmp[coneindices[1]] = halfHeight; @@ -46,17 +46,17 @@ SimdVector3 ConeShape::ConeLocalSupport(const SimdVector3& v) const return tmp; } else { - SimdScalar s = SimdSqrt(v[coneindices[0]] * v[coneindices[0]] + v[coneindices[2]] * v[coneindices[2]]); + btScalar s = btSqrt(v[coneindices[0]] * v[coneindices[0]] + v[coneindices[2]] * v[coneindices[2]]); if (s > SIMD_EPSILON) { - SimdScalar d = m_radius / s; - SimdVector3 tmp; + btScalar d = m_radius / s; + btVector3 tmp; tmp[coneindices[0]] = v[coneindices[0]] * d; tmp[coneindices[1]] = -halfHeight; tmp[coneindices[2]] = v[coneindices[2]] * d; return tmp; } else { - SimdVector3 tmp; + btVector3 tmp; tmp[coneindices[0]] = 0.f; tmp[coneindices[1]] = -halfHeight; tmp[coneindices[2]] = 0.f; @@ -66,27 +66,27 @@ SimdVector3 ConeShape::ConeLocalSupport(const SimdVector3& v) const } -SimdVector3 ConeShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec) const +btVector3 btConeShape::LocalGetSupportingVertexWithoutMargin(const btVector3& vec) const { return ConeLocalSupport(vec); } -void ConeShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const +void btConeShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const { for (int i=0;i maxDot) @@ -61,9 +61,9 @@ SimdVector3 ConvexHullShape::LocalGetSupportingVertexWithoutMargin(const SimdVec return supVec; } -void ConvexHullShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const +void btConvexHullShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const { - SimdScalar newDot; + btScalar newDot; //use 'w' component of supportVerticesOut? { for (int i=0;i supportVerticesOut[j][3]) @@ -95,13 +95,13 @@ void ConvexHullShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const Si -SimdVector3 ConvexHullShape::LocalGetSupportingVertex(const SimdVector3& vec)const +btVector3 btConvexHullShape::LocalGetSupportingVertex(const btVector3& vec)const { - SimdVector3 supVertex = LocalGetSupportingVertexWithoutMargin(vec); + btVector3 supVertex = LocalGetSupportingVertexWithoutMargin(vec); if ( GetMargin()!=0.f ) { - SimdVector3 vecnorm = vec; + btVector3 vecnorm = vec; if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) { vecnorm.setValue(-1.f,-1.f,-1.f); @@ -121,18 +121,18 @@ SimdVector3 ConvexHullShape::LocalGetSupportingVertex(const SimdVector3& vec)con //currently just for debugging (drawing), perhaps future support for algebraic continuous collision detection -//Please note that you can debug-draw ConvexHullShape with the Raytracer Demo -int ConvexHullShape::GetNumVertices() const +//Please note that you can debug-draw btConvexHullShape with the Raytracer Demo +int btConvexHullShape::GetNumVertices() const { return m_points.size(); } -int ConvexHullShape::GetNumEdges() const +int btConvexHullShape::GetNumEdges() const { return m_points.size()*m_points.size(); } -void ConvexHullShape::GetEdge(int i,SimdPoint3& pa,SimdPoint3& pb) const +void btConvexHullShape::GetEdge(int i,btPoint3& pa,btPoint3& pb) const { int index0 = i%m_points.size(); @@ -141,23 +141,23 @@ void ConvexHullShape::GetEdge(int i,SimdPoint3& pa,SimdPoint3& pb) const pb = m_points[index1]*m_localScaling; } -void ConvexHullShape::GetVertex(int i,SimdPoint3& vtx) const +void btConvexHullShape::GetVertex(int i,btPoint3& vtx) const { vtx = m_points[i]*m_localScaling; } -int ConvexHullShape::GetNumPlanes() const +int btConvexHullShape::GetNumPlanes() const { return 0; } -void ConvexHullShape::GetPlane(SimdVector3& planeNormal,SimdPoint3& planeSupport,int i ) const +void btConvexHullShape::GetPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const { assert(0); } //not yet -bool ConvexHullShape::IsInside(const SimdPoint3& pt,SimdScalar tolerance) const +bool btConvexHullShape::IsInside(const btPoint3& pt,btScalar tolerance) const { assert(0); return false; diff --git a/src/BulletCollision/CollisionShapes/btConvexHullShape.h b/src/BulletCollision/CollisionShapes/btConvexHullShape.h index 32a332d62..f3550b627 100644 --- a/src/BulletCollision/CollisionShapes/btConvexHullShape.h +++ b/src/BulletCollision/CollisionShapes/btConvexHullShape.h @@ -25,20 +25,20 @@ subject to the following restrictions: ///No connectivity is needed. LocalGetSupportingVertex iterates linearly though all vertices. ///on modern hardware, due to cache coherency this isn't that bad. Complex algorithms tend to trash the cash. ///(memory is much slower then the cpu) -class ConvexHullShape : public PolyhedralConvexShape +class btConvexHullShape : public btPolyhedralConvexShape { - std::vector m_points; + std::vector m_points; public: - ConvexHullShape(SimdPoint3* points,int numPoints, int stride=sizeof(SimdPoint3)); + btConvexHullShape(btPoint3* points,int numPoints, int stride=sizeof(btPoint3)); - void AddPoint(const SimdPoint3& point) + void AddPoint(const btPoint3& point) { m_points.push_back(point); } - virtual SimdVector3 LocalGetSupportingVertex(const SimdVector3& vec)const; - virtual SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const; - virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const; + virtual btVector3 LocalGetSupportingVertex(const btVector3& vec)const; + virtual btVector3 LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const; + virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; virtual int GetShapeType()const { return CONVEX_HULL_SHAPE_PROXYTYPE; } @@ -49,11 +49,11 @@ public: virtual int GetNumVertices() const; virtual int GetNumEdges() const; - virtual void GetEdge(int i,SimdPoint3& pa,SimdPoint3& pb) const; - virtual void GetVertex(int i,SimdPoint3& vtx) const; + virtual void GetEdge(int i,btPoint3& pa,btPoint3& pb) const; + virtual void GetVertex(int i,btPoint3& vtx) const; virtual int GetNumPlanes() const; - virtual void GetPlane(SimdVector3& planeNormal,SimdPoint3& planeSupport,int i ) const; - virtual bool IsInside(const SimdPoint3& pt,SimdScalar tolerance) const; + virtual void GetPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const; + virtual bool IsInside(const btPoint3& pt,btScalar tolerance) const; diff --git a/src/BulletCollision/CollisionShapes/btConvexShape.cpp b/src/BulletCollision/CollisionShapes/btConvexShape.cpp index 585335476..84c1918a3 100644 --- a/src/BulletCollision/CollisionShapes/btConvexShape.cpp +++ b/src/BulletCollision/CollisionShapes/btConvexShape.cpp @@ -15,32 +15,32 @@ subject to the following restrictions: #include "btConvexShape.h" -ConvexShape::ConvexShape() +btConvexShape::btConvexShape() :m_collisionMargin(CONVEX_DISTANCE_MARGIN), m_localScaling(1.f,1.f,1.f) { } -void ConvexShape::setLocalScaling(const SimdVector3& scaling) +void btConvexShape::setLocalScaling(const btVector3& scaling) { m_localScaling = scaling; } -void ConvexShape::GetAabbSlow(const SimdTransform& trans,SimdVector3&minAabb,SimdVector3&maxAabb) const +void btConvexShape::GetAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const { - SimdScalar margin = GetMargin(); + btScalar margin = GetMargin(); for (int i=0;i<3;i++) { - SimdVector3 vec(0.f,0.f,0.f); + btVector3 vec(0.f,0.f,0.f); vec[i] = 1.f; - SimdVector3 sv = LocalGetSupportingVertex(vec*trans.getBasis()); + btVector3 sv = LocalGetSupportingVertex(vec*trans.getBasis()); - SimdVector3 tmp = trans(sv); + btVector3 tmp = trans(sv); maxAabb[i] = tmp[i]+margin; vec[i] = -1.f; tmp = trans(LocalGetSupportingVertex(vec*trans.getBasis())); @@ -48,13 +48,13 @@ void ConvexShape::GetAabbSlow(const SimdTransform& trans,SimdVector3&minAabb,Sim } }; -SimdVector3 ConvexShape::LocalGetSupportingVertex(const SimdVector3& vec)const +btVector3 btConvexShape::LocalGetSupportingVertex(const btVector3& vec)const { - SimdVector3 supVertex = LocalGetSupportingVertexWithoutMargin(vec); + btVector3 supVertex = LocalGetSupportingVertexWithoutMargin(vec); if ( GetMargin()!=0.f ) { - SimdVector3 vecnorm = vec; + btVector3 vecnorm = vec; if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) { vecnorm.setValue(-1.f,-1.f,-1.f); diff --git a/src/BulletCollision/CollisionShapes/btConvexShape.h b/src/BulletCollision/CollisionShapes/btConvexShape.h index 9e5e71fef..2413bca14 100644 --- a/src/BulletCollision/CollisionShapes/btConvexShape.h +++ b/src/BulletCollision/CollisionShapes/btConvexShape.h @@ -18,45 +18,45 @@ subject to the following restrictions: #include "btCollisionShape.h" -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdTransform.h" -#include "LinearMath/SimdMatrix3x3.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btTransform.h" +#include "LinearMath/btMatrix3x3.h" #include #include "BulletCollision/CollisionShapes/btCollisionMargin.h" -//todo: get rid of this ConvexCastResult thing! -struct ConvexCastResult; +//todo: get rid of this btConvexCastResult thing! +struct btConvexCastResult; -/// ConvexShape is an abstract shape interface. +/// btConvexShape is an abstract shape interface. /// The explicit part provides plane-equations, the implicit part provides GetClosestPoint interface. -/// used in combination with GJK or ConvexCast -class ConvexShape : public CollisionShape +/// used in combination with GJK or btConvexCast +class btConvexShape : public btCollisionShape { public: - ConvexShape(); + btConvexShape(); - virtual SimdVector3 LocalGetSupportingVertex(const SimdVector3& vec)const; - virtual SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec) const= 0; + virtual btVector3 LocalGetSupportingVertex(const btVector3& vec)const; + virtual btVector3 LocalGetSupportingVertexWithoutMargin(const btVector3& vec) const= 0; //notice that the vectors should be unit length - virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const= 0; + virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const= 0; // testing for hullnode code ///GetAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version - void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const + void GetAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const { GetAabbSlow(t,aabbMin,aabbMax); } - virtual void GetAabbSlow(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const; + virtual void GetAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - virtual void setLocalScaling(const SimdVector3& scaling); - virtual const SimdVector3& getLocalScaling() const + virtual void setLocalScaling(const btVector3& scaling); + virtual const btVector3& getLocalScaling() const { return m_localScaling; } @@ -71,10 +71,10 @@ public: return m_collisionMargin; } private: - SimdScalar m_collisionMargin; + btScalar m_collisionMargin; //local scaling. collisionMargin is not scaled ! protected: - SimdVector3 m_localScaling; + btVector3 m_localScaling; }; diff --git a/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp b/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp index bd048bd8a..2698fe6aa 100644 --- a/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp +++ b/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp @@ -15,11 +15,11 @@ subject to the following restrictions: #include "btConvexTriangleMeshShape.h" #include "BulletCollision/CollisionShapes/btCollisionMargin.h" -#include "LinearMath/SimdQuaternion.h" +#include "LinearMath/btQuaternion.h" #include "BulletCollision/CollisionShapes/btStridingMeshInterface.h" -ConvexTriangleMeshShape ::ConvexTriangleMeshShape (StridingMeshInterface* meshInterface) +btConvexTriangleMeshShape ::btConvexTriangleMeshShape (btStridingMeshInterface* meshInterface) :m_stridingMesh(meshInterface) { } @@ -29,27 +29,27 @@ ConvexTriangleMeshShape ::ConvexTriangleMeshShape (StridingMeshInterface* meshIn ///It's not nice to have all this virtual function overhead, so perhaps we can also gather the points once ///but then we are duplicating -class LocalSupportVertexCallback: public InternalTriangleIndexCallback +class LocalSupportVertexCallback: public btInternalTriangleIndexCallback { - SimdVector3 m_supportVertexLocal; + btVector3 m_supportVertexLocal; public: - SimdScalar m_maxDot; - SimdVector3 m_supportVecLocal; + btScalar m_maxDot; + btVector3 m_supportVecLocal; - LocalSupportVertexCallback(const SimdVector3& supportVecLocal) + LocalSupportVertexCallback(const btVector3& supportVecLocal) : m_supportVertexLocal(0.f,0.f,0.f), m_maxDot(-1e30f), m_supportVecLocal(supportVecLocal) { } - virtual void InternalProcessTriangleIndex(SimdVector3* triangle,int partId,int triangleIndex) + virtual void InternalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) { for (int i=0;i<3;i++) { - SimdScalar dot = m_supportVecLocal.dot(triangle[i]); + btScalar dot = m_supportVecLocal.dot(triangle[i]); if (dot > m_maxDot) { m_maxDot = dot; @@ -58,7 +58,7 @@ public: } } - SimdVector3 GetSupportVertexLocal() + btVector3 GetSupportVertexLocal() { return m_supportVertexLocal; } @@ -69,30 +69,30 @@ public: -SimdVector3 ConvexTriangleMeshShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec0)const +btVector3 btConvexTriangleMeshShape::LocalGetSupportingVertexWithoutMargin(const btVector3& vec0)const { - SimdVector3 supVec(0.f,0.f,0.f); + btVector3 supVec(0.f,0.f,0.f); - SimdVector3 vec = vec0; - SimdScalar lenSqr = vec.length2(); + btVector3 vec = vec0; + btScalar lenSqr = vec.length2(); if (lenSqr < 0.0001f) { vec.setValue(1,0,0); } else { - float rlen = 1.f / SimdSqrt(lenSqr ); + float rlen = 1.f / btSqrt(lenSqr ); vec *= rlen; } LocalSupportVertexCallback supportCallback(vec); - SimdVector3 aabbMax(1e30f,1e30f,1e30f); + btVector3 aabbMax(1e30f,1e30f,1e30f); m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax); supVec = supportCallback.GetSupportVertexLocal(); return supVec; } -void ConvexTriangleMeshShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const +void btConvexTriangleMeshShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const { //use 'w' component of supportVerticesOut? { @@ -107,9 +107,9 @@ void ConvexTriangleMeshShape::BatchedUnitVectorGetSupportingVertexWithoutMargin( for (int j=0;jInternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax); supportVerticesOut[j] = supportCallback.GetSupportVertexLocal(); } @@ -118,13 +118,13 @@ void ConvexTriangleMeshShape::BatchedUnitVectorGetSupportingVertexWithoutMargin( -SimdVector3 ConvexTriangleMeshShape::LocalGetSupportingVertex(const SimdVector3& vec)const +btVector3 btConvexTriangleMeshShape::LocalGetSupportingVertex(const btVector3& vec)const { - SimdVector3 supVertex = LocalGetSupportingVertexWithoutMargin(vec); + btVector3 supVertex = LocalGetSupportingVertexWithoutMargin(vec); if ( GetMargin()!=0.f ) { - SimdVector3 vecnorm = vec; + btVector3 vecnorm = vec; if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) { vecnorm.setValue(-1.f,-1.f,-1.f); @@ -144,8 +144,8 @@ SimdVector3 ConvexTriangleMeshShape::LocalGetSupportingVertex(const SimdVector3& //currently just for debugging (drawing), perhaps future support for algebraic continuous collision detection -//Please note that you can debug-draw ConvexTriangleMeshShape with the Raytracer Demo -int ConvexTriangleMeshShape::GetNumVertices() const +//Please note that you can debug-draw btConvexTriangleMeshShape with the Raytracer Demo +int btConvexTriangleMeshShape::GetNumVertices() const { //cache this? assert(0); @@ -153,34 +153,34 @@ int ConvexTriangleMeshShape::GetNumVertices() const } -int ConvexTriangleMeshShape::GetNumEdges() const +int btConvexTriangleMeshShape::GetNumEdges() const { assert(0); return 0; } -void ConvexTriangleMeshShape::GetEdge(int i,SimdPoint3& pa,SimdPoint3& pb) const +void btConvexTriangleMeshShape::GetEdge(int i,btPoint3& pa,btPoint3& pb) const { assert(0); } -void ConvexTriangleMeshShape::GetVertex(int i,SimdPoint3& vtx) const +void btConvexTriangleMeshShape::GetVertex(int i,btPoint3& vtx) const { assert(0); } -int ConvexTriangleMeshShape::GetNumPlanes() const +int btConvexTriangleMeshShape::GetNumPlanes() const { return 0; } -void ConvexTriangleMeshShape::GetPlane(SimdVector3& planeNormal,SimdPoint3& planeSupport,int i ) const +void btConvexTriangleMeshShape::GetPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const { assert(0); } //not yet -bool ConvexTriangleMeshShape::IsInside(const SimdPoint3& pt,SimdScalar tolerance) const +bool btConvexTriangleMeshShape::IsInside(const btPoint3& pt,btScalar tolerance) const { assert(0); return false; @@ -188,7 +188,7 @@ bool ConvexTriangleMeshShape::IsInside(const SimdPoint3& pt,SimdScalar tolerance -void ConvexTriangleMeshShape::setLocalScaling(const SimdVector3& scaling) +void btConvexTriangleMeshShape::setLocalScaling(const btVector3& scaling) { m_stridingMesh->setScaling(scaling); } diff --git a/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h b/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h index d2bffe9f7..4d167dbd8 100644 --- a/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h +++ b/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h @@ -7,24 +7,24 @@ #include -/// ConvexTriangleMeshShape is a convex hull of a triangle mesh. If you just have a point cloud, you can use ConvexHullShape instead. -/// It uses the StridingMeshInterface instead of a point cloud. This can avoid the duplication of the triangle mesh data. -class ConvexTriangleMeshShape : public PolyhedralConvexShape +/// btConvexTriangleMeshShape is a convex hull of a triangle mesh. If you just have a point cloud, you can use btConvexHullShape instead. +/// It uses the btStridingMeshInterface instead of a point cloud. This can avoid the duplication of the triangle mesh data. +class btConvexTriangleMeshShape : public btPolyhedralConvexShape { - class StridingMeshInterface* m_stridingMesh; + class btStridingMeshInterface* m_stridingMesh; public: - ConvexTriangleMeshShape(StridingMeshInterface* meshInterface); + btConvexTriangleMeshShape(btStridingMeshInterface* meshInterface); - class StridingMeshInterface* GetStridingMesh() + class btStridingMeshInterface* GetStridingMesh() { return m_stridingMesh; } - virtual SimdVector3 LocalGetSupportingVertex(const SimdVector3& vec)const; - virtual SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const; - virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const; + virtual btVector3 LocalGetSupportingVertex(const btVector3& vec)const; + virtual btVector3 LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const; + virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; virtual int GetShapeType()const { return CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE; } @@ -33,14 +33,14 @@ public: virtual int GetNumVertices() const; virtual int GetNumEdges() const; - virtual void GetEdge(int i,SimdPoint3& pa,SimdPoint3& pb) const; - virtual void GetVertex(int i,SimdPoint3& vtx) const; + virtual void GetEdge(int i,btPoint3& pa,btPoint3& pb) const; + virtual void GetVertex(int i,btPoint3& vtx) const; virtual int GetNumPlanes() const; - virtual void GetPlane(SimdVector3& planeNormal,SimdPoint3& planeSupport,int i ) const; - virtual bool IsInside(const SimdPoint3& pt,SimdScalar tolerance) const; + virtual void GetPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const; + virtual bool IsInside(const btPoint3& pt,btScalar tolerance) const; - void setLocalScaling(const SimdVector3& scaling); + void setLocalScaling(const btVector3& scaling); }; diff --git a/src/BulletCollision/CollisionShapes/btCylinderShape.cpp b/src/BulletCollision/CollisionShapes/btCylinderShape.cpp index a4f3bfe46..aeceed9ae 100644 --- a/src/BulletCollision/CollisionShapes/btCylinderShape.cpp +++ b/src/BulletCollision/CollisionShapes/btCylinderShape.cpp @@ -13,29 +13,29 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ #include "btCylinderShape.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btPoint3.h" -CylinderShape::CylinderShape (const SimdVector3& halfExtents) -:BoxShape(halfExtents) +btCylinderShape::btCylinderShape (const btVector3& halfExtents) +:btBoxShape(halfExtents) { } -CylinderShapeX::CylinderShapeX (const SimdVector3& halfExtents) -:CylinderShape(halfExtents) +btCylinderShapeX::btCylinderShapeX (const btVector3& halfExtents) +:btCylinderShape(halfExtents) { } -CylinderShapeZ::CylinderShapeZ (const SimdVector3& halfExtents) -:CylinderShape(halfExtents) +btCylinderShapeZ::btCylinderShapeZ (const btVector3& halfExtents) +:btCylinderShape(halfExtents) { } -inline SimdVector3 CylinderLocalSupportX(const SimdVector3& halfExtents,const SimdVector3& v) +inline btVector3 CylinderLocalSupportX(const btVector3& halfExtents,const btVector3& v) { const int cylinderUpAxis = 0; const int XX = 1; @@ -50,11 +50,11 @@ const int ZZ = 2; float halfHeight = halfExtents[cylinderUpAxis]; - SimdVector3 tmp; - SimdScalar d ; + btVector3 tmp; + btScalar d ; - SimdScalar s = SimdSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); - if (s != SimdScalar(0.0)) + btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); + if (s != btScalar(0.0)) { d = radius / s; tmp[XX] = v[XX] * d; @@ -66,7 +66,7 @@ const int ZZ = 2; { tmp[XX] = radius; tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = SimdScalar(0.0); + tmp[ZZ] = btScalar(0.0); return tmp; } @@ -78,7 +78,7 @@ const int ZZ = 2; -inline SimdVector3 CylinderLocalSupportY(const SimdVector3& halfExtents,const SimdVector3& v) +inline btVector3 CylinderLocalSupportY(const btVector3& halfExtents,const btVector3& v) { const int cylinderUpAxis = 1; @@ -91,11 +91,11 @@ const int ZZ = 2; float halfHeight = halfExtents[cylinderUpAxis]; - SimdVector3 tmp; - SimdScalar d ; + btVector3 tmp; + btScalar d ; - SimdScalar s = SimdSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); - if (s != SimdScalar(0.0)) + btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); + if (s != btScalar(0.0)) { d = radius / s; tmp[XX] = v[XX] * d; @@ -107,13 +107,13 @@ const int ZZ = 2; { tmp[XX] = radius; tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = SimdScalar(0.0); + tmp[ZZ] = btScalar(0.0); return tmp; } } -inline SimdVector3 CylinderLocalSupportZ(const SimdVector3& halfExtents,const SimdVector3& v) +inline btVector3 CylinderLocalSupportZ(const btVector3& halfExtents,const btVector3& v) { const int cylinderUpAxis = 2; const int XX = 0; @@ -128,11 +128,11 @@ const int ZZ = 1; float halfHeight = halfExtents[cylinderUpAxis]; - SimdVector3 tmp; - SimdScalar d ; + btVector3 tmp; + btScalar d ; - SimdScalar s = SimdSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); - if (s != SimdScalar(0.0)) + btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); + if (s != btScalar(0.0)) { d = radius / s; tmp[XX] = v[XX] * d; @@ -144,29 +144,29 @@ const int ZZ = 1; { tmp[XX] = radius; tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = SimdScalar(0.0); + tmp[ZZ] = btScalar(0.0); return tmp; } } -SimdVector3 CylinderShapeX::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const +btVector3 btCylinderShapeX::LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const { return CylinderLocalSupportX(GetHalfExtents(),vec); } -SimdVector3 CylinderShapeZ::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const +btVector3 btCylinderShapeZ::LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const { return CylinderLocalSupportZ(GetHalfExtents(),vec); } -SimdVector3 CylinderShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const +btVector3 btCylinderShape::LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const { return CylinderLocalSupportY(GetHalfExtents(),vec); } -void CylinderShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const +void btCylinderShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const { for (int i=0;i #include "BulletCollision/CollisionShapes/btCollisionMargin.h" -/// EmptyShape is a collision shape without actual collision detection. +/// btEmptyShape is a collision shape without actual collision detection. ///It can be replaced by another shape during runtime -class EmptyShape : public ConcaveShape +class btEmptyShape : public ConcaveShape { public: - EmptyShape(); + btEmptyShape(); - virtual ~EmptyShape(); + virtual ~btEmptyShape(); ///GetAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version - void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const; + void GetAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - virtual void setLocalScaling(const SimdVector3& scaling) + virtual void setLocalScaling(const btVector3& scaling) { m_localScaling = scaling; } - virtual const SimdVector3& getLocalScaling() const + virtual const btVector3& getLocalScaling() const { return m_localScaling; } - virtual void CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia); + virtual void CalculateLocalInertia(btScalar mass,btVector3& inertia); virtual int GetShapeType() const { return EMPTY_SHAPE_PROXYTYPE;} @@ -62,7 +62,7 @@ public: protected: - SimdVector3 m_localScaling; + btVector3 m_localScaling; }; diff --git a/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp b/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp index 5c6c76fe4..9617a8f9e 100644 --- a/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp +++ b/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp @@ -16,7 +16,7 @@ subject to the following restrictions: #include "btMinkowskiSumShape.h" -MinkowskiSumShape::MinkowskiSumShape(ConvexShape* shapeA,ConvexShape* shapeB) +btMinkowskiSumShape::btMinkowskiSumShape(btConvexShape* shapeA,btConvexShape* shapeB) :m_shapeA(shapeA), m_shapeB(shapeB) { @@ -24,14 +24,14 @@ m_shapeB(shapeB) m_transB.setIdentity(); } -SimdVector3 MinkowskiSumShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const +btVector3 btMinkowskiSumShape::LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const { - SimdVector3 supVertexA = m_transA(m_shapeA->LocalGetSupportingVertexWithoutMargin(vec*m_transA.getBasis())); - SimdVector3 supVertexB = m_transB(m_shapeB->LocalGetSupportingVertexWithoutMargin(vec*m_transB.getBasis())); + btVector3 supVertexA = m_transA(m_shapeA->LocalGetSupportingVertexWithoutMargin(vec*m_transA.getBasis())); + btVector3 supVertexB = m_transB(m_shapeB->LocalGetSupportingVertexWithoutMargin(vec*m_transB.getBasis())); return supVertexA + supVertexB; } -void MinkowskiSumShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const +void btMinkowskiSumShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const { //todo: could make recursive use of batching. probably this shape is not used frequently. for (int i=0;iGetMargin() + m_shapeB->GetMargin(); } -void MinkowskiSumShape::CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia) +void btMinkowskiSumShape::CalculateLocalInertia(btScalar mass,btVector3& inertia) { assert(0); inertia.setValue(0,0,0); diff --git a/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h b/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h index ef959132a..be25cb70d 100644 --- a/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h +++ b/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h @@ -19,39 +19,39 @@ subject to the following restrictions: #include "btConvexShape.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types -/// MinkowskiSumShape represents implicit (getSupportingVertex) based minkowski sum of two convex implicit shapes. -class MinkowskiSumShape : public ConvexShape +/// btMinkowskiSumShape represents implicit (getSupportingVertex) based minkowski sum of two convex implicit shapes. +class btMinkowskiSumShape : public btConvexShape { - SimdTransform m_transA; - SimdTransform m_transB; - ConvexShape* m_shapeA; - ConvexShape* m_shapeB; + btTransform m_transA; + btTransform m_transB; + btConvexShape* m_shapeA; + btConvexShape* m_shapeB; public: - MinkowskiSumShape(ConvexShape* shapeA,ConvexShape* shapeB); + btMinkowskiSumShape(btConvexShape* shapeA,btConvexShape* shapeB); - virtual SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const; + virtual btVector3 LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const; - virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const; + virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - virtual void CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia); + virtual void CalculateLocalInertia(btScalar mass,btVector3& inertia); - void SetTransformA(const SimdTransform& transA) { m_transA = transA;} - void SetTransformB(const SimdTransform& transB) { m_transB = transB;} + void SetTransformA(const btTransform& transA) { m_transA = transA;} + void SetTransformB(const btTransform& transB) { m_transB = transB;} - const SimdTransform& GetTransformA()const { return m_transA;} - const SimdTransform& GetTransformB()const { return m_transB;} + const btTransform& GetTransformA()const { return m_transA;} + const btTransform& GetTransformB()const { return m_transB;} virtual int GetShapeType() const { return MINKOWSKI_SUM_SHAPE_PROXYTYPE; } virtual float GetMargin() const; - const ConvexShape* GetShapeA() const { return m_shapeA;} - const ConvexShape* GetShapeB() const { return m_shapeB;} + const btConvexShape* GetShapeA() const { return m_shapeA;} + const btConvexShape* GetShapeB() const { return m_shapeB;} virtual char* GetName()const { diff --git a/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp b/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp index 4e8f162c6..3ea4fd8a3 100644 --- a/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp +++ b/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp @@ -15,9 +15,9 @@ subject to the following restrictions: #include "btMultiSphereShape.h" #include "BulletCollision/CollisionShapes/btCollisionMargin.h" -#include "LinearMath/SimdQuaternion.h" +#include "LinearMath/btQuaternion.h" -MultiSphereShape::MultiSphereShape (const SimdVector3& inertiaHalfExtents,const SimdVector3* positions,const SimdScalar* radi,int numSpheres) +btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres) :m_inertiaHalfExtents(inertiaHalfExtents) { m_minRadius = 1e30f; @@ -37,30 +37,30 @@ MultiSphereShape::MultiSphereShape (const SimdVector3& inertiaHalfExtents,const - SimdVector3 MultiSphereShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec0)const + btVector3 btMultiSphereShape::LocalGetSupportingVertexWithoutMargin(const btVector3& vec0)const { int i; - SimdVector3 supVec(0,0,0); + btVector3 supVec(0,0,0); - SimdScalar maxDot(-1e30f); + btScalar maxDot(-1e30f); - SimdVector3 vec = vec0; - SimdScalar lenSqr = vec.length2(); + btVector3 vec = vec0; + btScalar lenSqr = vec.length2(); if (lenSqr < 0.0001f) { vec.setValue(1,0,0); } else { - float rlen = 1.f / SimdSqrt(lenSqr ); + float rlen = 1.f / btSqrt(lenSqr ); vec *= rlen; } - SimdVector3 vtx; - SimdScalar newDot; + btVector3 vtx; + btScalar newDot; - const SimdVector3* pos = &m_localPositions[0]; - const SimdScalar* rad = &m_radi[0]; + const btVector3* pos = &m_localPositions[0]; + const btScalar* rad = &m_radi[0]; for (i=0;iInternalProcessAllTriangles(&callback,aabbMin,aabbMax); //now we have an array of leafnodes in m_leafNodes - m_contiguousNodes = new OptimizedBvhNode[2*m_leafNodes.size()]; + m_contiguousNodes = new btOptimizedBvhNode[2*m_leafNodes.size()]; m_curNodeIndex = 0; m_rootNode1 = BuildTree(m_leafNodes,0,m_leafNodes.size()); ///create the leafnodes first -// OptimizedBvhNode* leafNodes = new OptimizedBvhNode; +// btOptimizedBvhNode* leafNodes = new btOptimizedBvhNode; } -OptimizedBvh::~OptimizedBvh() +btOptimizedBvh::~btOptimizedBvh() { if (m_contiguousNodes) delete m_contiguousNodes; } -OptimizedBvhNode* OptimizedBvh::BuildTree (NodeArray& leafNodes,int startIndex,int endIndex) +btOptimizedBvhNode* btOptimizedBvh::BuildTree (NodeArray& leafNodes,int startIndex,int endIndex) { - OptimizedBvhNode* internalNode; + btOptimizedBvhNode* internalNode; int splitAxis, splitIndex, i; int numIndices =endIndex-startIndex; @@ -103,7 +103,7 @@ OptimizedBvhNode* OptimizedBvh::BuildTree (NodeArray& leafNodes,int startIndex,i if (numIndices==1) { - return new (&m_contiguousNodes[m_curNodeIndex++]) OptimizedBvhNode(leafNodes[startIndex]); + return new (&m_contiguousNodes[m_curNodeIndex++]) btOptimizedBvhNode(leafNodes[startIndex]); } //calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'. @@ -132,17 +132,17 @@ OptimizedBvhNode* OptimizedBvh::BuildTree (NodeArray& leafNodes,int startIndex,i return internalNode; } -int OptimizedBvh::SortAndCalcSplittingIndex(NodeArray& leafNodes,int startIndex,int endIndex,int splitAxis) +int btOptimizedBvh::SortAndCalcSplittingIndex(NodeArray& leafNodes,int startIndex,int endIndex,int splitAxis) { int i; int splitIndex =startIndex; int numIndices = endIndex - startIndex; float splitValue; - SimdVector3 means(0.f,0.f,0.f); + btVector3 means(0.f,0.f,0.f); for (i=startIndex;i splitValue) { //swap - OptimizedBvhNode tmp = leafNodes[i]; + btOptimizedBvhNode tmp = leafNodes[i]; leafNodes[i] = leafNodes[splitIndex]; leafNodes[splitIndex] = tmp; splitIndex++; @@ -170,25 +170,25 @@ int OptimizedBvh::SortAndCalcSplittingIndex(NodeArray& leafNodes,int startIndex, } -int OptimizedBvh::CalcSplittingAxis(NodeArray& leafNodes,int startIndex,int endIndex) +int btOptimizedBvh::CalcSplittingAxis(NodeArray& leafNodes,int startIndex,int endIndex) { int i; - SimdVector3 means(0.f,0.f,0.f); - SimdVector3 variance(0.f,0.f,0.f); + btVector3 means(0.f,0.f,0.f); + btVector3 variance(0.f,0.f,0.f); int numIndices = endIndex-startIndex; for (i=startIndex;im_aabbMin,rootNode->m_aabbMax); if (aabbOverlap) @@ -228,7 +228,7 @@ void OptimizedBvh::WalkTree(OptimizedBvhNode* rootNode,NodeOverlapCallback* node int maxIterations = 0; -void OptimizedBvh::WalkStacklessTree(OptimizedBvhNode* rootNode,NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const +void btOptimizedBvh::WalkStacklessTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const { int escapeIndex, curIndex = 0; int walkIterations = 0; @@ -267,7 +267,7 @@ void OptimizedBvh::WalkStacklessTree(OptimizedBvhNode* rootNode,NodeOverlapCallb } -void OptimizedBvh::ReportSphereOverlappingNodex(NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const +void btOptimizedBvh::ReportSphereOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const { } diff --git a/src/BulletCollision/CollisionShapes/btOptimizedBvh.h b/src/BulletCollision/CollisionShapes/btOptimizedBvh.h index 324c6c0af..92431c9dd 100644 --- a/src/BulletCollision/CollisionShapes/btOptimizedBvh.h +++ b/src/BulletCollision/CollisionShapes/btOptimizedBvh.h @@ -15,26 +15,26 @@ subject to the following restrictions: #ifndef OPTIMIZED_BVH_H #define OPTIMIZED_BVH_H -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" #include -class StridingMeshInterface; +class btStridingMeshInterface; -/// OptimizedBvhNode contains both internal and leaf node information. +/// btOptimizedBvhNode contains both internal and leaf node information. /// It hasn't been optimized yet for storage. Some obvious optimizations are: /// Removal of the pointers (can already be done, they are not used for traversal) /// and storing aabbmin/max as quantized integers. /// 'subpart' doesn't need an integer either. It allows to re-use graphics triangle /// meshes stored in a non-uniform way (like batches/subparts of triangle-fans -struct OptimizedBvhNode +struct btOptimizedBvhNode { - SimdVector3 m_aabbMin; - SimdVector3 m_aabbMax; + btVector3 m_aabbMin; + btVector3 m_aabbMax; //these 2 pointers are obsolete, the stackless traversal just uses the escape index - OptimizedBvhNode* m_leftChild; - OptimizedBvhNode* m_rightChild; + btOptimizedBvhNode* m_leftChild; + btOptimizedBvhNode* m_rightChild; int m_escapeIndex; @@ -44,23 +44,23 @@ struct OptimizedBvhNode }; -class NodeOverlapCallback +class btNodeOverlapCallback { public: - virtual ~NodeOverlapCallback() {}; + virtual ~btNodeOverlapCallback() {}; - virtual void ProcessNode(const OptimizedBvhNode* node) = 0; + virtual void ProcessNode(const btOptimizedBvhNode* node) = 0; }; -typedef std::vector NodeArray; +typedef std::vector NodeArray; ///OptimizedBvh store an AABB tree that can be quickly traversed on CPU (and SPU,GPU in future) -class OptimizedBvh +class btOptimizedBvh { - OptimizedBvhNode* m_rootNode1; + btOptimizedBvhNode* m_rootNode1; - OptimizedBvhNode* m_contiguousNodes; + btOptimizedBvhNode* m_contiguousNodes; int m_curNodeIndex; int m_numNodes; @@ -68,29 +68,29 @@ class OptimizedBvh NodeArray m_leafNodes; public: - OptimizedBvh() :m_rootNode1(0), m_numNodes(0) { } - virtual ~OptimizedBvh(); + btOptimizedBvh() :m_rootNode1(0), m_numNodes(0) { } + virtual ~btOptimizedBvh(); - void Build(StridingMeshInterface* triangles); + void Build(btStridingMeshInterface* triangles); - OptimizedBvhNode* BuildTree (NodeArray& leafNodes,int startIndex,int endIndex); + btOptimizedBvhNode* BuildTree (NodeArray& leafNodes,int startIndex,int endIndex); int CalcSplittingAxis(NodeArray& leafNodes,int startIndex,int endIndex); int SortAndCalcSplittingIndex(NodeArray& leafNodes,int startIndex,int endIndex,int splitAxis); - void WalkTree(OptimizedBvhNode* rootNode,NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const; + void WalkTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const; - void WalkStacklessTree(OptimizedBvhNode* rootNode,NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const; + void WalkStacklessTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const; //OptimizedBvhNode* GetRootNode() { return m_rootNode1;} int GetNumNodes() { return m_numNodes;} - void ReportAabbOverlappingNodex(NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const; + void ReportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const; - void ReportSphereOverlappingNodex(NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const; + void ReportSphereOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const; }; diff --git a/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp index a62965e21..99eaf56f0 100644 --- a/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp +++ b/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp @@ -15,7 +15,7 @@ subject to the following restrictions: #include -PolyhedralConvexShape::PolyhedralConvexShape() +btPolyhedralConvexShape::btPolyhedralConvexShape() :m_optionalHull(0) { @@ -23,26 +23,26 @@ PolyhedralConvexShape::PolyhedralConvexShape() -SimdVector3 PolyhedralConvexShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec0)const +btVector3 btPolyhedralConvexShape::LocalGetSupportingVertexWithoutMargin(const btVector3& vec0)const { int i; - SimdVector3 supVec(0,0,0); + btVector3 supVec(0,0,0); - SimdScalar maxDot(-1e30f); + btScalar maxDot(-1e30f); - SimdVector3 vec = vec0; - SimdScalar lenSqr = vec.length2(); + btVector3 vec = vec0; + btScalar lenSqr = vec.length2(); if (lenSqr < 0.0001f) { vec.setValue(1,0,0); } else { - float rlen = 1.f / SimdSqrt(lenSqr ); + float rlen = 1.f / btSqrt(lenSqr ); vec *= rlen; } - SimdVector3 vtx; - SimdScalar newDot; + btVector3 vtx; + btScalar newDot; for (i=0;i -#include +#include +#include #include ///PolyhedralConvexShape is an interface class for feature based (vertex/edge/face) convex shapes. -class PolyhedralConvexShape : public ConvexShape +class btPolyhedralConvexShape : public btConvexShape { public: - PolyhedralConvexShape(); + btPolyhedralConvexShape(); //brute force implementations - virtual SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const; - virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const; + virtual btVector3 LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const; + virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - virtual void CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia); + virtual void CalculateLocalInertia(btScalar mass,btVector3& inertia); virtual int GetNumVertices() const = 0 ; virtual int GetNumEdges() const = 0; - virtual void GetEdge(int i,SimdPoint3& pa,SimdPoint3& pb) const = 0; - virtual void GetVertex(int i,SimdPoint3& vtx) const = 0; + virtual void GetEdge(int i,btPoint3& pa,btPoint3& pb) const = 0; + virtual void GetVertex(int i,btPoint3& vtx) const = 0; virtual int GetNumPlanes() const = 0; - virtual void GetPlane(SimdVector3& planeNormal,SimdPoint3& planeSupport,int i ) const = 0; + virtual void GetPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const = 0; // virtual int GetIndex(int i) const = 0 ; - virtual bool IsInside(const SimdPoint3& pt,SimdScalar tolerance) const = 0; + virtual bool IsInside(const btPoint3& pt,btScalar tolerance) const = 0; /// optional Hull is for optional Separating Axis Test Hull collision detection, see Hull.cpp class Hull* m_optionalHull; diff --git a/src/BulletCollision/CollisionShapes/btSphereShape.cpp b/src/BulletCollision/CollisionShapes/btSphereShape.cpp index 2203f44c0..14b35e7ec 100644 --- a/src/BulletCollision/CollisionShapes/btSphereShape.cpp +++ b/src/BulletCollision/CollisionShapes/btSphereShape.cpp @@ -16,20 +16,20 @@ subject to the following restrictions: #include "btSphereShape.h" #include "BulletCollision/CollisionShapes/btCollisionMargin.h" -#include "LinearMath/SimdQuaternion.h" +#include "LinearMath/btQuaternion.h" -SphereShape ::SphereShape (SimdScalar radius) +btSphereShape ::btSphereShape (btScalar radius) : m_radius(radius) { } -SimdVector3 SphereShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const +btVector3 btSphereShape::LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const { - return SimdVector3(0.f,0.f,0.f); + return btVector3(0.f,0.f,0.f); } -void SphereShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const +void btSphereShape::BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const { for (int i=0;i m_indexedMeshes; + std::vector m_indexedMeshes; public: - TriangleIndexVertexArray() + btTriangleIndexVertexArray() { } //just to be backwards compatible - TriangleIndexVertexArray(int numTriangleIndices,int* triangleIndexBase,int triangleIndexStride,int numVertices,float* vertexBase,int vertexStride); + btTriangleIndexVertexArray(int numTriangleIndices,int* triangleIndexBase,int triangleIndexStride,int numVertices,float* vertexBase,int vertexStride); - void AddIndexedMesh(const IndexedMesh& mesh) + void AddIndexedMesh(const btIndexedMesh& mesh) { m_indexedMeshes.push_back(mesh); } diff --git a/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp b/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp index f7d47dd30..489fe1bbc 100644 --- a/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp +++ b/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp @@ -18,17 +18,17 @@ subject to the following restrictions: static int myindices[3] = {0,1,2}; -TriangleMesh::TriangleMesh () +btTriangleMesh::btTriangleMesh () { } -void TriangleMesh::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) +void btTriangleMesh::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) { numverts = 3; *vertexbase = (unsigned char*)&m_triangles[subpart]; type = PHY_FLOAT; - stride = sizeof(SimdVector3); + stride = sizeof(btVector3); numfaces = 1; @@ -38,12 +38,12 @@ void TriangleMesh::getLockedVertexIndexBase(unsigned char **vertexbase, int& num } -void TriangleMesh::getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) const +void btTriangleMesh::getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) const { numverts = 3; *vertexbase = (unsigned char*)&m_triangles[subpart]; type = PHY_FLOAT; - stride = sizeof(SimdVector3); + stride = sizeof(btVector3); numfaces = 1; @@ -55,7 +55,7 @@ void TriangleMesh::getLockedReadOnlyVertexIndexBase(const unsigned char **vertex -int TriangleMesh::getNumSubParts() const +int btTriangleMesh::getNumSubParts() const { return m_triangles.size(); } diff --git a/src/BulletCollision/CollisionShapes/btTriangleMesh.h b/src/BulletCollision/CollisionShapes/btTriangleMesh.h index 9e86a2c30..b13d76d98 100644 --- a/src/BulletCollision/CollisionShapes/btTriangleMesh.h +++ b/src/BulletCollision/CollisionShapes/btTriangleMesh.h @@ -19,27 +19,27 @@ subject to the following restrictions: #include "BulletCollision/CollisionShapes/btStridingMeshInterface.h" #include -#include +#include -struct MyTriangle +struct btMyTriangle { - SimdVector3 m_vert0; - SimdVector3 m_vert1; - SimdVector3 m_vert2; + btVector3 m_vert0; + btVector3 m_vert1; + btVector3 m_vert2; }; -///TriangleMesh provides storage for a concave triangle mesh. It can be used as data for the TriangleMeshShape. -class TriangleMesh : public StridingMeshInterface +///TriangleMesh provides storage for a concave triangle mesh. It can be used as data for the btTriangleMeshShape. +class btTriangleMesh : public btStridingMeshInterface { - std::vector m_triangles; + std::vector m_triangles; public: - TriangleMesh (); + btTriangleMesh (); - void AddTriangle(const SimdVector3& vertex0,const SimdVector3& vertex1,const SimdVector3& vertex2) + void AddTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2) { - MyTriangle tri; + btMyTriangle tri; tri.m_vert0 = vertex0; tri.m_vert1 = vertex1; tri.m_vert2 = vertex2; diff --git a/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp b/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp index e33b5d8e0..86b60439a 100644 --- a/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp +++ b/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp @@ -14,22 +14,22 @@ subject to the following restrictions: */ #include "btTriangleMeshShape.h" -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdQuaternion.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btQuaternion.h" #include "btStridingMeshInterface.h" -#include "LinearMath/GenAabbUtil2.h" +#include "LinearMath/btAabbUtil2.h" #include "BulletCollision/CollisionShapes/btCollisionMargin.h" #include "stdio.h" -TriangleMeshShape::TriangleMeshShape(StridingMeshInterface* meshInterface) +btTriangleMeshShape::btTriangleMeshShape(btStridingMeshInterface* meshInterface) : m_meshInterface(meshInterface) { RecalcLocalAabb(); } -TriangleMeshShape::~TriangleMeshShape() +btTriangleMeshShape::~btTriangleMeshShape() { } @@ -37,20 +37,20 @@ TriangleMeshShape::~TriangleMeshShape() -void TriangleMeshShape::GetAabb(const SimdTransform& trans,SimdVector3& aabbMin,SimdVector3& aabbMax) const +void btTriangleMeshShape::GetAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const { - SimdVector3 localHalfExtents = 0.5f*(m_localAabbMax-m_localAabbMin); - SimdVector3 localCenter = 0.5f*(m_localAabbMax+m_localAabbMin); + btVector3 localHalfExtents = 0.5f*(m_localAabbMax-m_localAabbMin); + btVector3 localCenter = 0.5f*(m_localAabbMax+m_localAabbMin); - SimdMatrix3x3 abs_b = trans.getBasis().absolute(); + btMatrix3x3 abs_b = trans.getBasis().absolute(); - SimdPoint3 center = trans(localCenter); + btPoint3 center = trans(localCenter); - SimdVector3 extent = SimdVector3(abs_b[0].dot(localHalfExtents), + btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents), abs_b[1].dot(localHalfExtents), abs_b[2].dot(localHalfExtents)); - extent += SimdVector3(GetMargin(),GetMargin(),GetMargin()); + extent += btVector3(GetMargin(),GetMargin(),GetMargin()); aabbMin = center - extent; aabbMax = center + extent; @@ -58,13 +58,13 @@ void TriangleMeshShape::GetAabb(const SimdTransform& trans,SimdVector3& aabbMin, } -void TriangleMeshShape::RecalcLocalAabb() +void btTriangleMeshShape::RecalcLocalAabb() { for (int i=0;i<3;i++) { - SimdVector3 vec(0.f,0.f,0.f); + btVector3 vec(0.f,0.f,0.f); vec[i] = 1.f; - SimdVector3 tmp = LocalGetSupportingVertex(vec); + btVector3 tmp = LocalGetSupportingVertex(vec); m_localAabbMax[i] = tmp[i]+m_collisionMargin; vec[i] = -1.f; tmp = LocalGetSupportingVertex(vec); @@ -74,28 +74,28 @@ void TriangleMeshShape::RecalcLocalAabb() -class SupportVertexCallback : public TriangleCallback +class SupportVertexCallback : public btTriangleCallback { - SimdVector3 m_supportVertexLocal; + btVector3 m_supportVertexLocal; public: - SimdTransform m_worldTrans; - SimdScalar m_maxDot; - SimdVector3 m_supportVecLocal; + btTransform m_worldTrans; + btScalar m_maxDot; + btVector3 m_supportVecLocal; - SupportVertexCallback(const SimdVector3& supportVecWorld,const SimdTransform& trans) + SupportVertexCallback(const btVector3& supportVecWorld,const btTransform& trans) : m_supportVertexLocal(0.f,0.f,0.f), m_worldTrans(trans) ,m_maxDot(-1e30f) { m_supportVecLocal = supportVecWorld * m_worldTrans.getBasis(); } - virtual void ProcessTriangle( SimdVector3* triangle,int partId, int triangleIndex) + virtual void ProcessTriangle( btVector3* triangle,int partId, int triangleIndex) { for (int i=0;i<3;i++) { - SimdScalar dot = m_supportVecLocal.dot(triangle[i]); + btScalar dot = m_supportVecLocal.dot(triangle[i]); if (dot > m_maxDot) { m_maxDot = dot; @@ -104,12 +104,12 @@ public: } } - SimdVector3 GetSupportVertexWorldSpace() + btVector3 GetSupportVertexWorldSpace() { return m_worldTrans(m_supportVertexLocal); } - SimdVector3 GetSupportVertexLocal() + btVector3 GetSupportVertexLocal() { return m_supportVertexLocal; } @@ -117,13 +117,13 @@ public: }; -void TriangleMeshShape::setLocalScaling(const SimdVector3& scaling) +void btTriangleMeshShape::setLocalScaling(const btVector3& scaling) { m_meshInterface->setScaling(scaling); RecalcLocalAabb(); } -const SimdVector3& TriangleMeshShape::getLocalScaling() const +const btVector3& btTriangleMeshShape::getLocalScaling() const { return m_meshInterface->getScaling(); } @@ -136,23 +136,23 @@ const SimdVector3& TriangleMeshShape::getLocalScaling() const //#define DEBUG_TRIANGLE_MESH -void TriangleMeshShape::ProcessAllTriangles(TriangleCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const +void btTriangleMeshShape::ProcessAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const { - struct FilteredCallback : public InternalTriangleIndexCallback + struct FilteredCallback : public btInternalTriangleIndexCallback { - TriangleCallback* m_callback; - SimdVector3 m_aabbMin; - SimdVector3 m_aabbMax; + btTriangleCallback* m_callback; + btVector3 m_aabbMin; + btVector3 m_aabbMax; - FilteredCallback(TriangleCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) + FilteredCallback(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) :m_callback(callback), m_aabbMin(aabbMin), m_aabbMax(aabbMax) { } - virtual void InternalProcessTriangleIndex(SimdVector3* triangle,int partId,int triangleIndex) + virtual void InternalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) { if (TestTriangleAgainstAabb2(&triangle[0],m_aabbMin,m_aabbMax)) { @@ -174,7 +174,7 @@ void TriangleMeshShape::ProcessAllTriangles(TriangleCallback* callback,const Sim -void TriangleMeshShape::CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia) +void btTriangleMeshShape::CalculateLocalInertia(btScalar mass,btVector3& inertia) { //moving concave objects not supported assert(0); @@ -182,16 +182,16 @@ void TriangleMeshShape::CalculateLocalInertia(SimdScalar mass,SimdVector3& inert } -SimdVector3 TriangleMeshShape::LocalGetSupportingVertex(const SimdVector3& vec) const +btVector3 btTriangleMeshShape::LocalGetSupportingVertex(const btVector3& vec) const { - SimdVector3 supportVertex; + btVector3 supportVertex; - SimdTransform ident; + btTransform ident; ident.setIdentity(); SupportVertexCallback supportCallback(vec,ident); - SimdVector3 aabbMax(1e30f,1e30f,1e30f); + btVector3 aabbMax(1e30f,1e30f,1e30f); ProcessAllTriangles(&supportCallback,-aabbMax,aabbMax); diff --git a/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h b/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h index 491736df6..fa305ad12 100644 --- a/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h +++ b/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h @@ -21,22 +21,22 @@ subject to the following restrictions: ///Concave triangle mesh. Uses an interface to access the triangles to allow for sharing graphics/physics triangles. -class TriangleMeshShape : public ConcaveShape +class btTriangleMeshShape : public ConcaveShape { protected: - StridingMeshInterface* m_meshInterface; - SimdVector3 m_localAabbMin; - SimdVector3 m_localAabbMax; + btStridingMeshInterface* m_meshInterface; + btVector3 m_localAabbMin; + btVector3 m_localAabbMax; public: - TriangleMeshShape(StridingMeshInterface* meshInterface); + btTriangleMeshShape(btStridingMeshInterface* meshInterface); - virtual ~TriangleMeshShape(); + virtual ~btTriangleMeshShape(); - virtual SimdVector3 LocalGetSupportingVertex(const SimdVector3& vec) const; + virtual btVector3 LocalGetSupportingVertex(const btVector3& vec) const; - virtual SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const + virtual btVector3 LocalGetSupportingVertexWithoutMargin(const btVector3& vec)const { assert(0); return LocalGetSupportingVertex(vec); @@ -49,14 +49,14 @@ public: return TRIANGLE_MESH_SHAPE_PROXYTYPE; } - virtual void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const; + virtual void GetAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - virtual void ProcessAllTriangles(TriangleCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const; + virtual void ProcessAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; - virtual void CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia); + virtual void CalculateLocalInertia(btScalar mass,btVector3& inertia); - virtual void setLocalScaling(const SimdVector3& scaling); - virtual const SimdVector3& getLocalScaling() const; + virtual void setLocalScaling(const btVector3& scaling); + virtual const btVector3& getLocalScaling() const; //debugging diff --git a/src/BulletCollision/CollisionShapes/btTriangleShape.h b/src/BulletCollision/CollisionShapes/btTriangleShape.h index f0b3944ad..4cc63dd3d 100644 --- a/src/BulletCollision/CollisionShapes/btTriangleShape.h +++ b/src/BulletCollision/CollisionShapes/btTriangleShape.h @@ -19,13 +19,13 @@ subject to the following restrictions: #include "btConvexShape.h" #include "BulletCollision/CollisionShapes/btBoxShape.h" -class TriangleShape : public PolyhedralConvexShape +class btTriangleShape : public btPolyhedralConvexShape { public: - SimdVector3 m_vertices1[3]; + btVector3 m_vertices1[3]; virtual int GetNumVertices() const @@ -33,11 +33,11 @@ public: return 3; } - const SimdVector3& GetVertexPtr(int index) const + const btVector3& GetVertexPtr(int index) const { return m_vertices1[index]; } - virtual void GetVertex(int index,SimdVector3& vert) const + virtual void GetVertex(int index,btVector3& vert) const { vert = m_vertices1[index]; } @@ -51,31 +51,31 @@ public: return 3; } - virtual void GetEdge(int i,SimdPoint3& pa,SimdPoint3& pb) const + virtual void GetEdge(int i,btPoint3& pa,btPoint3& pb) const { GetVertex(i,pa); GetVertex((i+1)%3,pb); } - virtual void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax)const + virtual void GetAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax)const { // ASSERT(0); GetAabbSlow(t,aabbMin,aabbMax); } - SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& dir)const + btVector3 LocalGetSupportingVertexWithoutMargin(const btVector3& dir)const { - SimdVector3 dots(dir.dot(m_vertices1[0]), dir.dot(m_vertices1[1]), dir.dot(m_vertices1[2])); + btVector3 dots(dir.dot(m_vertices1[0]), dir.dot(m_vertices1[1]), dir.dot(m_vertices1[2])); return m_vertices1[dots.maxAxis()]; } - virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const + virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const { for (int i=0;i= -tolerance && dist <= tolerance) { @@ -134,13 +134,13 @@ public: int i; for (i=0;i<3;i++) { - SimdPoint3 pa,pb; + btPoint3 pa,pb; GetEdge(i,pa,pb); - SimdVector3 edge = pb-pa; - SimdVector3 edgeNormal = edge.cross(normal); + btVector3 edge = pb-pa; + btVector3 edgeNormal = edge.cross(normal); edgeNormal.normalize(); - SimdScalar dist = pt.dot( edgeNormal); - SimdScalar edgeConst = pa.dot(edgeNormal); + btScalar dist = pt.dot( edgeNormal); + btScalar edgeConst = pa.dot(edgeNormal); dist -= edgeConst; if (dist < -tolerance) return false; diff --git a/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp b/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp index f7a842f37..2512eeb7e 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp @@ -18,7 +18,7 @@ subject to the following restrictions: #include "BulletCollision/CollisionShapes/btConvexShape.h" #include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h" #include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h" -#include "LinearMath/SimdTransformUtil.h" +#include "LinearMath/btTransformUtil.h" #include "BulletCollision/CollisionShapes/btSphereShape.h" #include "btGjkPairDetector.h" @@ -26,7 +26,7 @@ subject to the following restrictions: -ContinuousConvexCollision::ContinuousConvexCollision ( ConvexShape* convexA,ConvexShape* convexB,SimplexSolverInterface* simplexSolver, ConvexPenetrationDepthSolver* penetrationDepthSolver) +btContinuousConvexCollision::btContinuousConvexCollision ( btConvexShape* convexA,btConvexShape* convexB,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* penetrationDepthSolver) :m_simplexSolver(simplexSolver), m_penetrationDepthSolver(penetrationDepthSolver), m_convexA(convexA),m_convexB(convexB) @@ -37,37 +37,37 @@ m_convexA(convexA),m_convexB(convexB) /// You don't want your game ever to lock-up. #define MAX_ITERATIONS 1000 -bool ContinuousConvexCollision::calcTimeOfImpact( - const SimdTransform& fromA, - const SimdTransform& toA, - const SimdTransform& fromB, - const SimdTransform& toB, +bool btContinuousConvexCollision::calcTimeOfImpact( + const btTransform& fromA, + const btTransform& toA, + const btTransform& fromB, + const btTransform& toB, CastResult& result) { m_simplexSolver->reset(); /// compute linear and angular velocity for this interval, to interpolate - SimdVector3 linVelA,angVelA,linVelB,angVelB; - SimdTransformUtil::CalculateVelocity(fromA,toA,1.f,linVelA,angVelA); - SimdTransformUtil::CalculateVelocity(fromB,toB,1.f,linVelB,angVelB); + btVector3 linVelA,angVelA,linVelB,angVelB; + btTransformUtil::CalculateVelocity(fromA,toA,1.f,linVelA,angVelA); + btTransformUtil::CalculateVelocity(fromB,toB,1.f,linVelB,angVelB); - SimdScalar boundingRadiusA = m_convexA->GetAngularMotionDisc(); - SimdScalar boundingRadiusB = m_convexB->GetAngularMotionDisc(); + btScalar boundingRadiusA = m_convexA->GetAngularMotionDisc(); + btScalar boundingRadiusB = m_convexB->GetAngularMotionDisc(); - SimdScalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB; + btScalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB; float radius = 0.001f; - SimdScalar lambda = 0.f; - SimdVector3 v(1,0,0); + btScalar lambda = 0.f; + btVector3 v(1,0,0); int maxIter = MAX_ITERATIONS; - SimdVector3 n; + btVector3 n; n.setValue(0.f,0.f,0.f); bool hasResult = false; - SimdVector3 c; + btVector3 c; float lastLambda = lambda; //float epsilon = 0.001f; @@ -76,21 +76,21 @@ bool ContinuousConvexCollision::calcTimeOfImpact( //first solution, using GJK - SimdTransform identityTrans; + btTransform identityTrans; identityTrans.setIdentity(); - SphereShape raySphere(0.0f); + btSphereShape raySphere(0.0f); raySphere.SetMargin(0.f); // result.DrawCoordSystem(sphereTr); - PointCollector pointCollector1; + btPointCollector pointCollector1; { - GjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,m_penetrationDepthSolver); - GjkPairDetector::ClosestPointInput input; + btGjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,m_penetrationDepthSolver); + btGjkPairDetector::ClosestPointInput input; //we don't use margins during CCD gjk.SetIgnoreMargin(true); @@ -105,7 +105,7 @@ bool ContinuousConvexCollision::calcTimeOfImpact( if (hasResult) { - SimdScalar dist; + btScalar dist; dist = pointCollector1.m_distance; n = pointCollector1.m_normalOnBInWorld; @@ -143,17 +143,17 @@ bool ContinuousConvexCollision::calcTimeOfImpact( //interpolate to next lambda - SimdTransform interpolatedTransA,interpolatedTransB,relativeTrans; + btTransform interpolatedTransA,interpolatedTransB,relativeTrans; - SimdTransformUtil::IntegrateTransform(fromA,linVelA,angVelA,lambda,interpolatedTransA); - SimdTransformUtil::IntegrateTransform(fromB,linVelB,angVelB,lambda,interpolatedTransB); + btTransformUtil::IntegrateTransform(fromA,linVelA,angVelA,lambda,interpolatedTransA); + btTransformUtil::IntegrateTransform(fromB,linVelB,angVelB,lambda,interpolatedTransB); relativeTrans = interpolatedTransB.inverseTimes(interpolatedTransA); result.DebugDraw( lambda ); - PointCollector pointCollector; - GjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,m_penetrationDepthSolver); - GjkPairDetector::ClosestPointInput input; + btPointCollector pointCollector; + btGjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,m_penetrationDepthSolver); + btGjkPairDetector::ClosestPointInput input; input.m_transformA = interpolatedTransA; input.m_transformB = interpolatedTransB; gjk.GetClosestPoints(input,pointCollector,0); @@ -187,7 +187,7 @@ bool ContinuousConvexCollision::calcTimeOfImpact( /* //todo: //if movement away from normal, discard result - SimdVector3 move = transBLocalTo.getOrigin() - transBLocalFrom.getOrigin(); + btVector3 move = transBLocalTo.getOrigin() - transBLocalFrom.getOrigin(); if (result.m_fraction < 1.f) { if (move.dot(result.m_normal) <= 0.f) diff --git a/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h b/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h index 2c36617f5..9901bab4b 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h +++ b/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h @@ -19,30 +19,30 @@ subject to the following restrictions: #include "btConvexCast.h" #include "btSimplexSolverInterface.h" -class ConvexPenetrationDepthSolver; -class ConvexShape; +class btConvexPenetrationDepthSolver; +class btConvexShape; -/// ContinuousConvexCollision implements angular and linear time of impact for convex objects. +/// btContinuousConvexCollision implements angular and linear time of impact for convex objects. /// Based on Brian Mirtich's Conservative Advancement idea (PhD thesis). /// Algorithm operates in worldspace, in order to keep inbetween motion globally consistent. /// It uses GJK at the moment. Future improvement would use minkowski sum / supporting vertex, merging innerloops -class ContinuousConvexCollision : public ConvexCast +class btContinuousConvexCollision : public btConvexCast { - SimplexSolverInterface* m_simplexSolver; - ConvexPenetrationDepthSolver* m_penetrationDepthSolver; - ConvexShape* m_convexA; - ConvexShape* m_convexB; + btSimplexSolverInterface* m_simplexSolver; + btConvexPenetrationDepthSolver* m_penetrationDepthSolver; + btConvexShape* m_convexA; + btConvexShape* m_convexB; public: - ContinuousConvexCollision (ConvexShape* shapeA,ConvexShape* shapeB ,SimplexSolverInterface* simplexSolver,ConvexPenetrationDepthSolver* penetrationDepthSolver); + btContinuousConvexCollision (btConvexShape* shapeA,btConvexShape* shapeB ,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); virtual bool calcTimeOfImpact( - const SimdTransform& fromA, - const SimdTransform& toA, - const SimdTransform& fromB, - const SimdTransform& toB, + const btTransform& fromA, + const btTransform& toA, + const btTransform& fromB, + const btTransform& toB, CastResult& result); diff --git a/src/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp b/src/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp index a52355c9a..d2a1310b2 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp @@ -15,6 +15,6 @@ subject to the following restrictions: #include "btConvexCast.h" -ConvexCast::~ConvexCast() +btConvexCast::~btConvexCast() { } diff --git a/src/BulletCollision/NarrowPhaseCollision/btConvexCast.h b/src/BulletCollision/NarrowPhaseCollision/btConvexCast.h index 3be6dde27..35e8baf96 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btConvexCast.h +++ b/src/BulletCollision/NarrowPhaseCollision/btConvexCast.h @@ -17,28 +17,28 @@ subject to the following restrictions: #ifndef CONVEX_CAST_H #define CONVEX_CAST_H -#include -#include -#include -class MinkowskiSumShape; -#include "LinearMath/GenIDebugDraw.h" +#include +#include +#include +class btMinkowskiSumShape; +#include "LinearMath/btIDebugDraw.h" -/// ConvexCast is an interface for Casting -class ConvexCast +/// btConvexCast is an interface for Casting +class btConvexCast { public: - virtual ~ConvexCast(); + virtual ~btConvexCast(); ///RayResult stores the closest result /// alternatively, add a callback method to decide about closest/all results struct CastResult { - //virtual bool addRayResult(const SimdVector3& normal,SimdScalar fraction) = 0; + //virtual bool addRayResult(const btVector3& normal,btScalar fraction) = 0; - virtual void DebugDraw(SimdScalar fraction) {} - virtual void DrawCoordSystem(const SimdTransform& trans) {} + virtual void DebugDraw(btScalar fraction) {} + virtual void DrawCoordSystem(const btTransform& trans) {} CastResult() :m_fraction(1e30f), @@ -49,22 +49,22 @@ public: virtual ~CastResult() {}; - SimdVector3 m_normal; - SimdScalar m_fraction; - SimdTransform m_hitTransformA; - SimdTransform m_hitTransformB; + btVector3 m_normal; + btScalar m_fraction; + btTransform m_hitTransformA; + btTransform m_hitTransformB; - IDebugDraw* m_debugDrawer; + btIDebugDraw* m_debugDrawer; }; /// cast a convex against another convex object virtual bool calcTimeOfImpact( - const SimdTransform& fromA, - const SimdTransform& toA, - const SimdTransform& fromB, - const SimdTransform& toB, + const btTransform& fromA, + const btTransform& toA, + const btTransform& fromB, + const btTransform& toB, CastResult& result) = 0; }; diff --git a/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h b/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h index e7409e497..5a5875d61 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h +++ b/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h @@ -17,23 +17,23 @@ subject to the following restrictions: #ifndef CONVEX_PENETRATION_DEPTH_H #define CONVEX_PENETRATION_DEPTH_H -class SimdVector3; +class btVector3; #include "btSimplexSolverInterface.h" -class ConvexShape; -#include "LinearMath/SimdPoint3.h" -class SimdTransform; +class btConvexShape; +#include "LinearMath/btPoint3.h" +class btTransform; ///ConvexPenetrationDepthSolver provides an interface for penetration depth calculation. -class ConvexPenetrationDepthSolver +class btConvexPenetrationDepthSolver { public: - virtual ~ConvexPenetrationDepthSolver() {}; - virtual bool CalcPenDepth( SimplexSolverInterface& simplexSolver, - ConvexShape* convexA,ConvexShape* convexB, - const SimdTransform& transA,const SimdTransform& transB, - SimdVector3& v, SimdPoint3& pa, SimdPoint3& pb, - class IDebugDraw* debugDraw + virtual ~btConvexPenetrationDepthSolver() {}; + virtual bool CalcPenDepth( btSimplexSolverInterface& simplexSolver, + btConvexShape* convexA,btConvexShape* convexB, + const btTransform& transA,const btTransform& transB, + btVector3& v, btPoint3& pa, btPoint3& pb, + class btIDebugDraw* debugDraw ) = 0; diff --git a/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h b/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h index a39b37a4c..9871ef7b2 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h +++ b/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h @@ -16,8 +16,8 @@ subject to the following restrictions: #ifndef DISCRETE_COLLISION_DETECTOR_INTERFACE_H #define DISCRETE_COLLISION_DETECTOR_INTERFACE_H -#include "LinearMath/SimdTransform.h" -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btTransform.h" +#include "LinearMath/btVector3.h" /// This interface is made to be used by an iterative approach to do TimeOfImpact calculations @@ -25,7 +25,7 @@ subject to the following restrictions: /// the closest point is on the second object (B), and the normal points from the surface on B towards A. /// distance is between closest points on B and closest point on A. So you can calculate closest point on A /// by taking closestPointInA = closestPointInB + m_distance * m_normalOnSurfaceB -struct DiscreteCollisionDetectorInterface +struct btDiscreteCollisionDetectorInterface { void operator delete(void* ptr) {}; @@ -37,7 +37,7 @@ struct DiscreteCollisionDetectorInterface ///SetShapeIdentifiers provides experimental support for per-triangle material / custom material combiner virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1)=0; - virtual void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth)=0; + virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)=0; }; struct ClosestPointInput @@ -47,35 +47,35 @@ struct DiscreteCollisionDetectorInterface { } - SimdTransform m_transformA; - SimdTransform m_transformB; - SimdScalar m_maximumDistanceSquared; + btTransform m_transformA; + btTransform m_transformB; + btScalar m_maximumDistanceSquared; }; - virtual ~DiscreteCollisionDetectorInterface() {}; + virtual ~btDiscreteCollisionDetectorInterface() {}; // // give either closest points (distance > 0) or penetration (distance) // the normal always points from B towards A // - virtual void GetClosestPoints(const ClosestPointInput& input,Result& output,class IDebugDraw* debugDraw) = 0; + virtual void GetClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw) = 0; - SimdScalar getCollisionMargin() { return 0.2f;} + btScalar getCollisionMargin() { return 0.2f;} }; -struct StorageResult : public DiscreteCollisionDetectorInterface::Result +struct btStorageResult : public btDiscreteCollisionDetectorInterface::Result { - SimdVector3 m_normalOnSurfaceB; - SimdVector3 m_closestPointInB; - SimdScalar m_distance; //negative means penetration ! + btVector3 m_normalOnSurfaceB; + btVector3 m_closestPointInB; + btScalar m_distance; //negative means penetration ! - StorageResult() : m_distance(1e30f) + btStorageResult() : m_distance(1e30f) { } - virtual ~StorageResult() {}; + virtual ~btStorageResult() {}; - virtual void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth) + virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth) { if (depth < m_distance) { diff --git a/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp b/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp index a9c506f5a..f65ed52f7 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp @@ -22,37 +22,37 @@ subject to the following restrictions: #include "btPointCollector.h" -GjkConvexCast::GjkConvexCast(ConvexShape* convexA,ConvexShape* convexB,SimplexSolverInterface* simplexSolver) +btGjkConvexCast::btGjkConvexCast(btConvexShape* convexA,btConvexShape* convexB,btSimplexSolverInterface* simplexSolver) :m_simplexSolver(simplexSolver), m_convexA(convexA), m_convexB(convexB) { } -bool GjkConvexCast::calcTimeOfImpact( - const SimdTransform& fromA, - const SimdTransform& toA, - const SimdTransform& fromB, - const SimdTransform& toB, +bool btGjkConvexCast::calcTimeOfImpact( + const btTransform& fromA, + const btTransform& toA, + const btTransform& fromB, + const btTransform& toB, CastResult& result) { - MinkowskiSumShape combi(m_convexA,m_convexB); - MinkowskiSumShape* convex = &combi; + btMinkowskiSumShape combi(m_convexA,m_convexB); + btMinkowskiSumShape* convex = &combi; - SimdTransform rayFromLocalA; - SimdTransform rayToLocalA; + btTransform rayFromLocalA; + btTransform rayToLocalA; rayFromLocalA = fromA.inverse()* fromB; rayToLocalA = toA.inverse()* toB; - SimdTransform trA,trB; - trA = SimdTransform(fromA); - trB = SimdTransform(fromB); - trA.setOrigin(SimdPoint3(0,0,0)); - trB.setOrigin(SimdPoint3(0,0,0)); + btTransform trA,trB; + trA = btTransform(fromA); + trB = btTransform(fromB); + trA.setOrigin(btPoint3(0,0,0)); + trB.setOrigin(btPoint3(0,0,0)); convex->SetTransformA(trA); convex->SetTransformB(trB); @@ -62,38 +62,38 @@ bool GjkConvexCast::calcTimeOfImpact( float radius = 0.01f; - SimdScalar lambda = 0.f; - SimdVector3 s = rayFromLocalA.getOrigin(); - SimdVector3 r = rayToLocalA.getOrigin()-rayFromLocalA.getOrigin(); - SimdVector3 x = s; - SimdVector3 n; + btScalar lambda = 0.f; + btVector3 s = rayFromLocalA.getOrigin(); + btVector3 r = rayToLocalA.getOrigin()-rayFromLocalA.getOrigin(); + btVector3 x = s; + btVector3 n; n.setValue(0,0,0); bool hasResult = false; - SimdVector3 c; + btVector3 c; float lastLambda = lambda; //first solution, using GJK //no penetration support for now, perhaps pass a pointer when we really want it - ConvexPenetrationDepthSolver* penSolverPtr = 0; + btConvexPenetrationDepthSolver* penSolverPtr = 0; - SimdTransform identityTrans; + btTransform identityTrans; identityTrans.setIdentity(); - SphereShape raySphere(0.0f); + btSphereShape raySphere(0.0f); raySphere.SetMargin(0.f); - SimdTransform sphereTr; + btTransform sphereTr; sphereTr.setIdentity(); sphereTr.setOrigin( rayFromLocalA.getOrigin()); result.DrawCoordSystem(sphereTr); { - PointCollector pointCollector1; - GjkPairDetector gjk(&raySphere,convex,m_simplexSolver,penSolverPtr); + btPointCollector pointCollector1; + btGjkPairDetector gjk(&raySphere,convex,m_simplexSolver,penSolverPtr); - GjkPairDetector::ClosestPointInput input; + btGjkPairDetector::ClosestPointInput input; input.m_transformA = sphereTr; input.m_transformB = identityTrans; gjk.GetClosestPoints(input,pointCollector1,0); @@ -107,7 +107,7 @@ bool GjkConvexCast::calcTimeOfImpact( if (hasResult) { - SimdScalar dist; + btScalar dist; dist = (c-x).length(); if (dist < radius) { @@ -120,7 +120,7 @@ bool GjkConvexCast::calcTimeOfImpact( { n = x - c; - SimdScalar nDotr = n.dot(r); + btScalar nDotr = n.dot(r); if (nDotr >= -(SIMD_EPSILON*SIMD_EPSILON)) return false; @@ -135,9 +135,9 @@ bool GjkConvexCast::calcTimeOfImpact( sphereTr.setOrigin( x ); result.DrawCoordSystem(sphereTr); - PointCollector pointCollector; - GjkPairDetector gjk(&raySphere,convex,m_simplexSolver,penSolverPtr); - GjkPairDetector::ClosestPointInput input; + btPointCollector pointCollector; + btGjkPairDetector gjk(&raySphere,convex,m_simplexSolver,penSolverPtr); + btGjkPairDetector::ClosestPointInput input; input.m_transformA = sphereTr; input.m_transformB = identityTrans; gjk.GetClosestPoints(input,pointCollector,0); diff --git a/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h b/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h index 00f9ffe48..66b34b883 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h +++ b/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h @@ -20,29 +20,29 @@ subject to the following restrictions: #include -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" #include "btConvexCast.h" -class ConvexShape; -class MinkowskiSumShape; +class btConvexShape; +class btMinkowskiSumShape; #include "btSimplexSolverInterface.h" ///GjkConvexCast performs a raycast on a convex object using support mapping. -class GjkConvexCast : public ConvexCast +class btGjkConvexCast : public btConvexCast { - SimplexSolverInterface* m_simplexSolver; - ConvexShape* m_convexA; - ConvexShape* m_convexB; + btSimplexSolverInterface* m_simplexSolver; + btConvexShape* m_convexA; + btConvexShape* m_convexB; public: - GjkConvexCast(ConvexShape* convexA,ConvexShape* convexB,SimplexSolverInterface* simplexSolver); + btGjkConvexCast(btConvexShape* convexA,btConvexShape* convexB,btSimplexSolverInterface* simplexSolver); /// cast a convex against another convex object virtual bool calcTimeOfImpact( - const SimdTransform& fromA, - const SimdTransform& toA, - const SimdTransform& fromB, - const SimdTransform& toB, + const btTransform& fromA, + const btTransform& toA, + const btTransform& fromB, + const btTransform& toB, CastResult& result); }; diff --git a/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp b/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp index 8e28d1e58..7979b2e5f 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp @@ -22,14 +22,14 @@ subject to the following restrictions: #include //for debug printf #endif -static const SimdScalar rel_error = SimdScalar(1.0e-5); -SimdScalar rel_error2 = rel_error * rel_error; +static const btScalar rel_error = btScalar(1.0e-5); +btScalar rel_error2 = rel_error * rel_error; float maxdist2 = 1.e30f; int gGjkMaxIter=1000; -GjkPairDetector::GjkPairDetector(ConvexShape* objectA,ConvexShape* objectB,SimplexSolverInterface* simplexSolver,ConvexPenetrationDepthSolver* penetrationDepthSolver) +btGjkPairDetector::btGjkPairDetector(btConvexShape* objectA,btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) :m_cachedSeparatingAxis(0.f,0.f,1.f), m_penetrationDepthSolver(penetrationDepthSolver), m_simplexSolver(simplexSolver), @@ -43,11 +43,11 @@ m_index1(-1) { } -void GjkPairDetector::GetClosestPoints(const ClosestPointInput& input,Result& output,class IDebugDraw* debugDraw) +void btGjkPairDetector::GetClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw) { - SimdScalar distance=0.f; - SimdVector3 normalInB(0.f,0.f,0.f); - SimdVector3 pointOnA,pointOnB; + btScalar distance=0.f; + btVector3 normalInB(0.f,0.f,0.f); + btVector3 pointOnA,pointOnB; float marginA = m_minkowskiA->GetMargin(); float marginB = m_minkowskiB->GetMargin(); @@ -66,10 +66,10 @@ int curIter = 0; bool checkPenetration = true; { - SimdScalar squaredDistance = SIMD_INFINITY; - SimdScalar delta = 0.f; + btScalar squaredDistance = SIMD_INFINITY; + btScalar delta = 0.f; - SimdScalar margin = marginA + marginB; + btScalar margin = marginA + marginB; @@ -77,11 +77,11 @@ int curIter = 0; while (true) { - //degeneracy, this is typically due to invalid/uninitialized worldtransforms for a CollisionObject + //degeneracy, this is typically due to invalid/uninitialized worldtransforms for a btCollisionObject if (curIter++ > gGjkMaxIter) { #if defined(DEBUG) || defined (_DEBUG) - printf("GjkPairDetector maxIter exceeded:%i\n",curIter); + printf("btGjkPairDetector maxIter exceeded:%i\n",curIter); printf("sepAxis=(%f,%f,%f), squaredDistance = %f, shapeTypeA=%i,shapeTypeB=%i\n", m_cachedSeparatingAxis.getX(), m_cachedSeparatingAxis.getY(), @@ -94,19 +94,19 @@ int curIter = 0; } - SimdVector3 seperatingAxisInA = (-m_cachedSeparatingAxis)* input.m_transformA.getBasis(); - SimdVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis(); + btVector3 seperatingAxisInA = (-m_cachedSeparatingAxis)* input.m_transformA.getBasis(); + btVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis(); - SimdVector3 pInA = m_minkowskiA->LocalGetSupportingVertexWithoutMargin(seperatingAxisInA); - SimdVector3 qInB = m_minkowskiB->LocalGetSupportingVertexWithoutMargin(seperatingAxisInB); - SimdPoint3 pWorld = input.m_transformA(pInA); - SimdPoint3 qWorld = input.m_transformB(qInB); + btVector3 pInA = m_minkowskiA->LocalGetSupportingVertexWithoutMargin(seperatingAxisInA); + btVector3 qInB = m_minkowskiB->LocalGetSupportingVertexWithoutMargin(seperatingAxisInB); + btPoint3 pWorld = input.m_transformA(pInA); + btPoint3 qWorld = input.m_transformB(qInB); - SimdVector3 w = pWorld - qWorld; + btVector3 w = pWorld - qWorld; delta = m_cachedSeparatingAxis.dot(w); // potential exit, they don't overlap - if ((delta > SimdScalar(0.0)) && (delta * delta > squaredDistance * input.m_maximumDistanceSquared)) + if ((delta > btScalar(0.0)) && (delta * delta > squaredDistance * input.m_maximumDistanceSquared)) { checkPenetration = false; break; @@ -134,7 +134,7 @@ int curIter = 0; break; } - SimdScalar previousSquaredDistance = squaredDistance; + btScalar previousSquaredDistance = squaredDistance; squaredDistance = m_cachedSeparatingAxis.length2(); //redundant m_simplexSolver->compute_points(pointOnA, pointOnB); @@ -165,10 +165,10 @@ int curIter = 0; //valid normal if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON)) { - float rlen = 1.f / SimdSqrt(lenSqr ); + float rlen = 1.f / btSqrt(lenSqr ); normalInB *= rlen; //normalize - SimdScalar s = SimdSqrt(squaredDistance); - ASSERT(s > SimdScalar(0.0)); + btScalar s = btSqrt(squaredDistance); + ASSERT(s > btScalar(0.0)); pointOnA -= m_cachedSeparatingAxis * (marginA / s); pointOnB += m_cachedSeparatingAxis * (marginB / s); distance = ((1.f/rlen) - margin); @@ -198,7 +198,7 @@ int curIter = 0; float lenSqr = normalInB.length2(); if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON)) { - normalInB /= SimdSqrt(lenSqr); + normalInB /= btSqrt(lenSqr); distance = -(pointOnA-pointOnB).length(); } else { diff --git a/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h b/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h index d202586ad..017428f97 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h +++ b/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h @@ -20,24 +20,24 @@ subject to the following restrictions: #define GJK_PAIR_DETECTOR_H #include "btDiscreteCollisionDetectorInterface.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btPoint3.h" #include -class ConvexShape; +class btConvexShape; #include "btSimplexSolverInterface.h" -class ConvexPenetrationDepthSolver; +class btConvexPenetrationDepthSolver; -/// GjkPairDetector uses GJK to implement the DiscreteCollisionDetectorInterface -class GjkPairDetector : public DiscreteCollisionDetectorInterface +/// btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface +class btGjkPairDetector : public btDiscreteCollisionDetectorInterface { - SimdVector3 m_cachedSeparatingAxis; - ConvexPenetrationDepthSolver* m_penetrationDepthSolver; - SimplexSolverInterface* m_simplexSolver; - ConvexShape* m_minkowskiA; - ConvexShape* m_minkowskiB; + btVector3 m_cachedSeparatingAxis; + btConvexPenetrationDepthSolver* m_penetrationDepthSolver; + btSimplexSolverInterface* m_simplexSolver; + btConvexShape* m_minkowskiA; + btConvexShape* m_minkowskiB; bool m_ignoreMargin; @@ -50,26 +50,26 @@ public: int m_partId1; int m_index1; - GjkPairDetector(ConvexShape* objectA,ConvexShape* objectB,SimplexSolverInterface* simplexSolver,ConvexPenetrationDepthSolver* penetrationDepthSolver); - virtual ~GjkPairDetector() {}; + btGjkPairDetector(btConvexShape* objectA,btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); + virtual ~btGjkPairDetector() {}; - virtual void GetClosestPoints(const ClosestPointInput& input,Result& output,class IDebugDraw* debugDraw); + virtual void GetClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw); - void SetMinkowskiA(ConvexShape* minkA) + void SetMinkowskiA(btConvexShape* minkA) { m_minkowskiA = minkA; } - void SetMinkowskiB(ConvexShape* minkB) + void SetMinkowskiB(btConvexShape* minkB) { m_minkowskiB = minkB; } - void SetCachedSeperatingAxis(const SimdVector3& seperatingAxis) + void SetCachedSeperatingAxis(const btVector3& seperatingAxis) { m_cachedSeparatingAxis = seperatingAxis; } - void SetPenetrationDepthSolver(ConvexPenetrationDepthSolver* penetrationDepthSolver) + void SetPenetrationDepthSolver(btConvexPenetrationDepthSolver* penetrationDepthSolver) { m_penetrationDepthSolver = penetrationDepthSolver; } diff --git a/src/BulletCollision/NarrowPhaseCollision/btManifoldContactAddResult.cpp b/src/BulletCollision/NarrowPhaseCollision/btManifoldContactAddResult.cpp index a46bff8a5..44cb994c5 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btManifoldContactAddResult.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btManifoldContactAddResult.cpp @@ -16,7 +16,7 @@ subject to the following restrictions: #include "btManifoldContactAddResult.h" #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -ManifoldContactAddResult::ManifoldContactAddResult(SimdTransform transA,SimdTransform transB,PersistentManifold* manifoldPtr) +btManifoldContactAddResult::btManifoldContactAddResult(btTransform transA,btTransform transB,btPersistentManifold* manifoldPtr) :m_manifoldPtr(manifoldPtr) { m_transAInv = transA.inverse(); @@ -25,16 +25,16 @@ ManifoldContactAddResult::ManifoldContactAddResult(SimdTransform transA,SimdTran } -void ManifoldContactAddResult::AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth) +void btManifoldContactAddResult::AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth) { if (depth > m_manifoldPtr->GetContactBreakingTreshold()) return; - SimdVector3 pointA = pointInWorld + normalOnBInWorld * depth; - SimdVector3 localA = m_transAInv(pointA ); - SimdVector3 localB = m_transBInv(pointInWorld); - ManifoldPoint newPt(localA,localB,normalOnBInWorld,depth); + btVector3 pointA = pointInWorld + normalOnBInWorld * depth; + btVector3 localA = m_transAInv(pointA ); + btVector3 localB = m_transBInv(pointInWorld); + btManifoldPoint newPt(localA,localB,normalOnBInWorld,depth); int insertIndex = m_manifoldPtr->GetCacheEntry(newPt); if (insertIndex >= 0) diff --git a/src/BulletCollision/NarrowPhaseCollision/btManifoldContactAddResult.h b/src/BulletCollision/NarrowPhaseCollision/btManifoldContactAddResult.h index a8e78bccd..e4702d288 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btManifoldContactAddResult.h +++ b/src/BulletCollision/NarrowPhaseCollision/btManifoldContactAddResult.h @@ -18,19 +18,19 @@ subject to the following restrictions: #define MANIFOLD_CONTACT_ADD_RESULT_H #include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" -class PersistentManifold; +class btPersistentManifold; -class ManifoldContactAddResult : public DiscreteCollisionDetectorInterface::Result +class btManifoldContactAddResult : public btDiscreteCollisionDetectorInterface::Result { - PersistentManifold* m_manifoldPtr; - SimdTransform m_transAInv; - SimdTransform m_transBInv; + btPersistentManifold* m_manifoldPtr; + btTransform m_transAInv; + btTransform m_transBInv; public: - ManifoldContactAddResult(SimdTransform transA,SimdTransform transB,PersistentManifold* manifoldPtr); + btManifoldContactAddResult(btTransform transA,btTransform transB,btPersistentManifold* manifoldPtr); - virtual void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth); + virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth); }; diff --git a/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h b/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h index 80ddd9bf3..654779305 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h +++ b/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h @@ -16,8 +16,8 @@ subject to the following restrictions: #ifndef MANIFOLD_CONTACT_POINT_H #define MANIFOLD_CONTACT_POINT_H -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdTransformUtil.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btTransformUtil.h" @@ -25,17 +25,17 @@ subject to the following restrictions: /// ManifoldContactPoint collects and maintains persistent contactpoints. /// used to improve stability and performance of rigidbody dynamics response. -class ManifoldPoint +class btManifoldPoint { public: - ManifoldPoint() + btManifoldPoint() :m_userPersistentData(0) { } - ManifoldPoint( const SimdVector3 &pointA, const SimdVector3 &pointB, - const SimdVector3 &normal, - SimdScalar distance ) : + btManifoldPoint( const btVector3 &pointA, const btVector3 &pointB, + const btVector3 &normal, + btScalar distance ) : m_localPointA( pointA ), m_localPointB( pointB ), m_normalWorldOnB( normal ), @@ -51,12 +51,12 @@ class ManifoldPoint - SimdVector3 m_localPointA; - SimdVector3 m_localPointB; - SimdVector3 m_positionWorldOnB; + btVector3 m_localPointA; + btVector3 m_localPointB; + btVector3 m_positionWorldOnB; ///m_positionWorldOnA is redundant information, see GetPositionWorldOnA(), but for clarity - SimdVector3 m_positionWorldOnA; - SimdVector3 m_normalWorldOnB; + btVector3 m_positionWorldOnA; + btVector3 m_normalWorldOnB; float m_distance1; float m_combinedFriction; @@ -76,12 +76,12 @@ class ManifoldPoint return m_lifeTime; } - SimdVector3 GetPositionWorldOnA() { + btVector3 GetPositionWorldOnA() { return m_positionWorldOnA; // return m_positionWorldOnB + m_normalWorldOnB * m_distance1; } - const SimdVector3& GetPositionWorldOnB() + const btVector3& GetPositionWorldOnB() { return m_positionWorldOnB; } diff --git a/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp b/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp index cead7907a..cd54639dd 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp @@ -20,22 +20,22 @@ subject to the following restrictions: #include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" -struct MyResult : public DiscreteCollisionDetectorInterface::Result +struct MyResult : public btDiscreteCollisionDetectorInterface::Result { MyResult():m_hasResult(false) { } - SimdVector3 m_normalOnBInWorld; - SimdVector3 m_pointInWorld; + btVector3 m_normalOnBInWorld; + btVector3 m_pointInWorld; float m_depth; bool m_hasResult; virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1) { } - void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth) + void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth) { m_normalOnBInWorld = normalOnBInWorld; m_pointInWorld = pointInWorld; @@ -45,80 +45,80 @@ struct MyResult : public DiscreteCollisionDetectorInterface::Result }; #define NUM_UNITSPHERE_POINTS 42 -static SimdVector3 sPenetrationDirections[NUM_UNITSPHERE_POINTS] = +static btVector3 sPenetrationDirections[NUM_UNITSPHERE_POINTS] = { -SimdVector3(0.000000f , -0.000000f,-1.000000f), -SimdVector3(0.723608f , -0.525725f,-0.447219f), -SimdVector3(-0.276388f , -0.850649f,-0.447219f), -SimdVector3(-0.894426f , -0.000000f,-0.447216f), -SimdVector3(-0.276388f , 0.850649f,-0.447220f), -SimdVector3(0.723608f , 0.525725f,-0.447219f), -SimdVector3(0.276388f , -0.850649f,0.447220f), -SimdVector3(-0.723608f , -0.525725f,0.447219f), -SimdVector3(-0.723608f , 0.525725f,0.447219f), -SimdVector3(0.276388f , 0.850649f,0.447219f), -SimdVector3(0.894426f , 0.000000f,0.447216f), -SimdVector3(-0.000000f , 0.000000f,1.000000f), -SimdVector3(0.425323f , -0.309011f,-0.850654f), -SimdVector3(-0.162456f , -0.499995f,-0.850654f), -SimdVector3(0.262869f , -0.809012f,-0.525738f), -SimdVector3(0.425323f , 0.309011f,-0.850654f), -SimdVector3(0.850648f , -0.000000f,-0.525736f), -SimdVector3(-0.525730f , -0.000000f,-0.850652f), -SimdVector3(-0.688190f , -0.499997f,-0.525736f), -SimdVector3(-0.162456f , 0.499995f,-0.850654f), -SimdVector3(-0.688190f , 0.499997f,-0.525736f), -SimdVector3(0.262869f , 0.809012f,-0.525738f), -SimdVector3(0.951058f , 0.309013f,0.000000f), -SimdVector3(0.951058f , -0.309013f,0.000000f), -SimdVector3(0.587786f , -0.809017f,0.000000f), -SimdVector3(0.000000f , -1.000000f,0.000000f), -SimdVector3(-0.587786f , -0.809017f,0.000000f), -SimdVector3(-0.951058f , -0.309013f,-0.000000f), -SimdVector3(-0.951058f , 0.309013f,-0.000000f), -SimdVector3(-0.587786f , 0.809017f,-0.000000f), -SimdVector3(-0.000000f , 1.000000f,-0.000000f), -SimdVector3(0.587786f , 0.809017f,-0.000000f), -SimdVector3(0.688190f , -0.499997f,0.525736f), -SimdVector3(-0.262869f , -0.809012f,0.525738f), -SimdVector3(-0.850648f , 0.000000f,0.525736f), -SimdVector3(-0.262869f , 0.809012f,0.525738f), -SimdVector3(0.688190f , 0.499997f,0.525736f), -SimdVector3(0.525730f , 0.000000f,0.850652f), -SimdVector3(0.162456f , -0.499995f,0.850654f), -SimdVector3(-0.425323f , -0.309011f,0.850654f), -SimdVector3(-0.425323f , 0.309011f,0.850654f), -SimdVector3(0.162456f , 0.499995f,0.850654f) +btVector3(0.000000f , -0.000000f,-1.000000f), +btVector3(0.723608f , -0.525725f,-0.447219f), +btVector3(-0.276388f , -0.850649f,-0.447219f), +btVector3(-0.894426f , -0.000000f,-0.447216f), +btVector3(-0.276388f , 0.850649f,-0.447220f), +btVector3(0.723608f , 0.525725f,-0.447219f), +btVector3(0.276388f , -0.850649f,0.447220f), +btVector3(-0.723608f , -0.525725f,0.447219f), +btVector3(-0.723608f , 0.525725f,0.447219f), +btVector3(0.276388f , 0.850649f,0.447219f), +btVector3(0.894426f , 0.000000f,0.447216f), +btVector3(-0.000000f , 0.000000f,1.000000f), +btVector3(0.425323f , -0.309011f,-0.850654f), +btVector3(-0.162456f , -0.499995f,-0.850654f), +btVector3(0.262869f , -0.809012f,-0.525738f), +btVector3(0.425323f , 0.309011f,-0.850654f), +btVector3(0.850648f , -0.000000f,-0.525736f), +btVector3(-0.525730f , -0.000000f,-0.850652f), +btVector3(-0.688190f , -0.499997f,-0.525736f), +btVector3(-0.162456f , 0.499995f,-0.850654f), +btVector3(-0.688190f , 0.499997f,-0.525736f), +btVector3(0.262869f , 0.809012f,-0.525738f), +btVector3(0.951058f , 0.309013f,0.000000f), +btVector3(0.951058f , -0.309013f,0.000000f), +btVector3(0.587786f , -0.809017f,0.000000f), +btVector3(0.000000f , -1.000000f,0.000000f), +btVector3(-0.587786f , -0.809017f,0.000000f), +btVector3(-0.951058f , -0.309013f,-0.000000f), +btVector3(-0.951058f , 0.309013f,-0.000000f), +btVector3(-0.587786f , 0.809017f,-0.000000f), +btVector3(-0.000000f , 1.000000f,-0.000000f), +btVector3(0.587786f , 0.809017f,-0.000000f), +btVector3(0.688190f , -0.499997f,0.525736f), +btVector3(-0.262869f , -0.809012f,0.525738f), +btVector3(-0.850648f , 0.000000f,0.525736f), +btVector3(-0.262869f , 0.809012f,0.525738f), +btVector3(0.688190f , 0.499997f,0.525736f), +btVector3(0.525730f , 0.000000f,0.850652f), +btVector3(0.162456f , -0.499995f,0.850654f), +btVector3(-0.425323f , -0.309011f,0.850654f), +btVector3(-0.425323f , 0.309011f,0.850654f), +btVector3(0.162456f , 0.499995f,0.850654f) }; -bool MinkowskiPenetrationDepthSolver::CalcPenDepth(SimplexSolverInterface& simplexSolver, - ConvexShape* convexA,ConvexShape* convexB, - const SimdTransform& transA,const SimdTransform& transB, - SimdVector3& v, SimdPoint3& pa, SimdPoint3& pb, - class IDebugDraw* debugDraw +bool btMinkowskiPenetrationDepthSolver::CalcPenDepth(btSimplexSolverInterface& simplexSolver, + btConvexShape* convexA,btConvexShape* convexB, + const btTransform& transA,const btTransform& transB, + btVector3& v, btPoint3& pa, btPoint3& pb, + class btIDebugDraw* debugDraw ) { //just take fixed number of orientation, and sample the penetration depth in that direction float minProj = 1e30f; - SimdVector3 minNorm; - SimdVector3 minVertex; - SimdVector3 minA,minB; - SimdVector3 seperatingAxisInA,seperatingAxisInB; - SimdVector3 pInA,qInB,pWorld,qWorld,w; + btVector3 minNorm; + btVector3 minVertex; + btVector3 minA,minB; + btVector3 seperatingAxisInA,seperatingAxisInB; + btVector3 pInA,qInB,pWorld,qWorld,w; #define USE_BATCHED_SUPPORT 1 #ifdef USE_BATCHED_SUPPORT - SimdVector3 supportVerticesABatch[NUM_UNITSPHERE_POINTS]; - SimdVector3 supportVerticesBBatch[NUM_UNITSPHERE_POINTS]; - SimdVector3 seperatingAxisInABatch[NUM_UNITSPHERE_POINTS]; - SimdVector3 seperatingAxisInBBatch[NUM_UNITSPHERE_POINTS]; + btVector3 supportVerticesABatch[NUM_UNITSPHERE_POINTS]; + btVector3 supportVerticesBBatch[NUM_UNITSPHERE_POINTS]; + btVector3 seperatingAxisInABatch[NUM_UNITSPHERE_POINTS]; + btVector3 seperatingAxisInBBatch[NUM_UNITSPHERE_POINTS]; int i; for (i=0;iBatchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInBBatch,supportVerticesBBatch,NUM_UNITSPHERE_POINTS); for (i=0;iLocalGetSupportingVertexWithoutMargin(seperatingAxisInA); @@ -183,10 +183,10 @@ bool MinkowskiPenetrationDepthSolver::CalcPenDepth(SimplexSolverInterface& simpl #ifdef DEBUG_DRAW if (debugDraw) { - SimdVector3 color(0,1,0); + btVector3 color(0,1,0); debugDraw->DrawLine(minA,minB,color); - color = SimdVector3 (1,1,1); - SimdVector3 vec = minB-minA; + color = btVector3 (1,1,1); + btVector3 vec = minB-minA; float prj2 = minNorm.dot(vec); debugDraw->DrawLine(minA,minA+(minNorm*minProj),color); @@ -195,18 +195,18 @@ bool MinkowskiPenetrationDepthSolver::CalcPenDepth(SimplexSolverInterface& simpl - GjkPairDetector gjkdet(convexA,convexB,&simplexSolver,0); + btGjkPairDetector gjkdet(convexA,convexB,&simplexSolver,0); - SimdScalar offsetDist = minProj; - SimdVector3 offset = minNorm * offsetDist; + btScalar offsetDist = minProj; + btVector3 offset = minNorm * offsetDist; - GjkPairDetector::ClosestPointInput input; + btGjkPairDetector::ClosestPointInput input; - SimdVector3 newOrg = transA.getOrigin() + offset; + btVector3 newOrg = transA.getOrigin() + offset; - SimdTransform displacedTrans = transA; + btTransform displacedTrans = transA; displacedTrans.setOrigin(newOrg); input.m_transformA = displacedTrans; @@ -232,7 +232,7 @@ bool MinkowskiPenetrationDepthSolver::CalcPenDepth(SimplexSolverInterface& simpl #ifdef DEBUG_DRAW if (debugDraw) { - SimdVector3 color(1,0,0); + btVector3 color(1,0,0); debugDraw->DrawLine(pa,pb,color); } #endif//DEBUG_DRAW diff --git a/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h b/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h index ae9f6b975..4009f7c63 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h +++ b/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h @@ -20,15 +20,15 @@ subject to the following restrictions: ///MinkowskiPenetrationDepthSolver implements bruteforce penetration depth estimation. ///Implementation is based on sampling the depth using support mapping, and using GJK step to get the witness points. -class MinkowskiPenetrationDepthSolver : public ConvexPenetrationDepthSolver +class btMinkowskiPenetrationDepthSolver : public btConvexPenetrationDepthSolver { public: - virtual bool CalcPenDepth( SimplexSolverInterface& simplexSolver, - ConvexShape* convexA,ConvexShape* convexB, - const SimdTransform& transA,const SimdTransform& transB, - SimdVector3& v, SimdPoint3& pa, SimdPoint3& pb, - class IDebugDraw* debugDraw + virtual bool CalcPenDepth( btSimplexSolverInterface& simplexSolver, + btConvexShape* convexA,btConvexShape* convexB, + const btTransform& transA,const btTransform& transB, + btVector3& v, btPoint3& pa, btPoint3& pb, + class btIDebugDraw* debugDraw ); }; diff --git a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp index 590d0e9c3..a3e48849c 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp @@ -15,7 +15,7 @@ subject to the following restrictions: #include "btPersistentManifold.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btTransform.h" #include float gContactBreakingTreshold = 0.02f; @@ -23,7 +23,7 @@ ContactDestroyedCallback gContactDestroyedCallback = 0; -PersistentManifold::PersistentManifold() +btPersistentManifold::btPersistentManifold() :m_body0(0), m_body1(0), m_cachedPoints (0), @@ -32,7 +32,7 @@ m_index1(0) } -void PersistentManifold::ClearManifold() +void btPersistentManifold::ClearManifold() { int i; for (i=0;i -void PersistentManifold::DebugPersistency() +void btPersistentManifold::DebugPersistency() { int i; printf("DebugPersistency : numPoints %d\n",m_cachedPoints); @@ -55,7 +55,7 @@ void PersistentManifold::DebugPersistency() } #endif //DEBUG_PERSISTENCY -void PersistentManifold::ClearUserCache(ManifoldPoint& pt) +void btPersistentManifold::ClearUserCache(btManifoldPoint& pt) { void* oldPtr = pt.m_userPersistentData; @@ -91,7 +91,7 @@ void PersistentManifold::ClearUserCache(ManifoldPoint& pt) } -int PersistentManifold::SortCachedPoints(const ManifoldPoint& pt) +int btPersistentManifold::SortCachedPoints(const btManifoldPoint& pt) { //calculate 4 possible cases areas, and take biggest area @@ -111,55 +111,55 @@ int PersistentManifold::SortCachedPoints(const ManifoldPoint& pt) } #endif //KEEP_DEEPEST_POINT - SimdScalar res0(0.f),res1(0.f),res2(0.f),res3(0.f); + btScalar res0(0.f),res1(0.f),res2(0.f),res3(0.f); if (maxPenetrationIndex != 0) { - SimdVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA; - SimdVector3 b0 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; - SimdVector3 cross = a0.cross(b0); + btVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA; + btVector3 b0 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; + btVector3 cross = a0.cross(b0); res0 = cross.length2(); } if (maxPenetrationIndex != 1) { - SimdVector3 a1 = pt.m_localPointA-m_pointCache[0].m_localPointA; - SimdVector3 b1 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; - SimdVector3 cross = a1.cross(b1); + btVector3 a1 = pt.m_localPointA-m_pointCache[0].m_localPointA; + btVector3 b1 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; + btVector3 cross = a1.cross(b1); res1 = cross.length2(); } if (maxPenetrationIndex != 2) { - SimdVector3 a2 = pt.m_localPointA-m_pointCache[0].m_localPointA; - SimdVector3 b2 = m_pointCache[3].m_localPointA-m_pointCache[1].m_localPointA; - SimdVector3 cross = a2.cross(b2); + btVector3 a2 = pt.m_localPointA-m_pointCache[0].m_localPointA; + btVector3 b2 = m_pointCache[3].m_localPointA-m_pointCache[1].m_localPointA; + btVector3 cross = a2.cross(b2); res2 = cross.length2(); } if (maxPenetrationIndex != 3) { - SimdVector3 a3 = pt.m_localPointA-m_pointCache[0].m_localPointA; - SimdVector3 b3 = m_pointCache[2].m_localPointA-m_pointCache[1].m_localPointA; - SimdVector3 cross = a3.cross(b3); + btVector3 a3 = pt.m_localPointA-m_pointCache[0].m_localPointA; + btVector3 b3 = m_pointCache[2].m_localPointA-m_pointCache[1].m_localPointA; + btVector3 cross = a3.cross(b3); res3 = cross.length2(); } - SimdVector4 maxvec(res0,res1,res2,res3); + btVector4 maxvec(res0,res1,res2,res3); int biggestarea = maxvec.closestAxis4(); return biggestarea; } -int PersistentManifold::GetCacheEntry(const ManifoldPoint& newPoint) const +int btPersistentManifold::GetCacheEntry(const btManifoldPoint& newPoint) const { - SimdScalar shortestDist = GetContactBreakingTreshold() * GetContactBreakingTreshold(); + btScalar shortestDist = GetContactBreakingTreshold() * GetContactBreakingTreshold(); int size = GetNumContacts(); int nearestPoint = -1; for( int i = 0; i < size; i++ ) { - const ManifoldPoint &mp = m_pointCache[i]; + const btManifoldPoint &mp = m_pointCache[i]; - SimdVector3 diffA = mp.m_localPointA- newPoint.m_localPointA; - const SimdScalar distToManiPoint = diffA.dot(diffA); + btVector3 diffA = mp.m_localPointA- newPoint.m_localPointA; + const btScalar distToManiPoint = diffA.dot(diffA); if( distToManiPoint < shortestDist ) { shortestDist = distToManiPoint; @@ -169,7 +169,7 @@ int PersistentManifold::GetCacheEntry(const ManifoldPoint& newPoint) const return nearestPoint; } -void PersistentManifold::AddManifoldPoint(const ManifoldPoint& newPoint) +void btPersistentManifold::AddManifoldPoint(const btManifoldPoint& newPoint) { assert(ValidContactDistance(newPoint)); @@ -193,19 +193,19 @@ void PersistentManifold::AddManifoldPoint(const ManifoldPoint& newPoint) ReplaceContactPoint(newPoint,insertIndex); } -float PersistentManifold::GetContactBreakingTreshold() const +float btPersistentManifold::GetContactBreakingTreshold() const { return gContactBreakingTreshold; } -void PersistentManifold::RefreshContactPoints(const SimdTransform& trA,const SimdTransform& trB) +void btPersistentManifold::RefreshContactPoints(const btTransform& trA,const btTransform& trB) { int i; /// first refresh worldspace positions and distance for (i=GetNumContacts()-1;i>=0;i--) { - ManifoldPoint &manifoldPoint = m_pointCache[i]; + btManifoldPoint &manifoldPoint = m_pointCache[i]; manifoldPoint.m_positionWorldOnA = trA( manifoldPoint.m_localPointA ); manifoldPoint.m_positionWorldOnB = trB( manifoldPoint.m_localPointB ); manifoldPoint.m_distance1 = (manifoldPoint.m_positionWorldOnA - manifoldPoint.m_positionWorldOnB).dot(manifoldPoint.m_normalWorldOnB); @@ -213,12 +213,12 @@ void PersistentManifold::RefreshContactPoints(const SimdTransform& trA,const Sim } /// then - SimdScalar distance2d; - SimdVector3 projectedDifference,projectedPoint; + btScalar distance2d; + btVector3 projectedDifference,projectedPoint; for (i=GetNumContacts()-1;i>=0;i--) { - ManifoldPoint &manifoldPoint = m_pointCache[i]; + btManifoldPoint &manifoldPoint = m_pointCache[i]; //contact becomes invalid when signed distance exceeds margin (projected on contactnormal direction) if (!ValidContactDistance(manifoldPoint)) { diff --git a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h index f0093fdfb..00012d218 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h +++ b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h @@ -17,11 +17,11 @@ subject to the following restrictions: #define PERSISTENT_MANIFOLD_H -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btTransform.h" #include "btManifoldPoint.h" -struct CollisionResult; +struct btCollisionResult; ///contact breaking and merging treshold extern float gContactBreakingTreshold; @@ -36,10 +36,10 @@ extern ContactDestroyedCallback gContactDestroyedCallback; ///PersistentManifold maintains contact points, and reduces them to 4. ///It does contact filtering/contact reduction. -class PersistentManifold +class btPersistentManifold { - ManifoldPoint m_pointCache[MANIFOLD_CACHE_SIZE]; + btManifoldPoint m_pointCache[MANIFOLD_CACHE_SIZE]; /// this two body pointers can point to the physics rigidbody class. /// void* will allow any rigidbody class @@ -49,17 +49,17 @@ class PersistentManifold /// sort cached points so most isolated points come first - int SortCachedPoints(const ManifoldPoint& pt); + int SortCachedPoints(const btManifoldPoint& pt); - int FindContactPoint(const ManifoldPoint* unUsed, int numUnused,const ManifoldPoint& pt); + int FindContactPoint(const btManifoldPoint* unUsed, int numUnused,const btManifoldPoint& pt); public: int m_index1; - PersistentManifold(); + btPersistentManifold(); - PersistentManifold(void* body0,void* body1) + btPersistentManifold(void* body0,void* body1) : m_body0(body0),m_body1(body1),m_cachedPoints(0) { } @@ -76,7 +76,7 @@ public: m_body1 = body1; } - void ClearUserCache(ManifoldPoint& pt); + void ClearUserCache(btManifoldPoint& pt); #ifdef DEBUG_PERSISTENCY void DebugPersistency(); @@ -84,13 +84,13 @@ public: inline int GetNumContacts() const { return m_cachedPoints;} - inline const ManifoldPoint& GetContactPoint(int index) const + inline const btManifoldPoint& GetContactPoint(int index) const { ASSERT(index < m_cachedPoints); return m_pointCache[index]; } - inline ManifoldPoint& GetContactPoint(int index) + inline btManifoldPoint& GetContactPoint(int index) { ASSERT(index < m_cachedPoints); return m_pointCache[index]; @@ -99,9 +99,9 @@ public: /// todo: get this margin from the current physics / collision environment float GetContactBreakingTreshold() const; - int GetCacheEntry(const ManifoldPoint& newPoint) const; + int GetCacheEntry(const btManifoldPoint& newPoint) const; - void AddManifoldPoint( const ManifoldPoint& newPoint); + void AddManifoldPoint( const btManifoldPoint& newPoint); void RemoveContactPoint (int index) { @@ -113,7 +113,7 @@ public: m_pointCache[lastUsedIndex].m_userPersistentData = 0; m_cachedPoints--; } - void ReplaceContactPoint(const ManifoldPoint& newPoint,int insertIndex) + void ReplaceContactPoint(const btManifoldPoint& newPoint,int insertIndex) { assert(ValidContactDistance(newPoint)); @@ -122,12 +122,12 @@ public: m_pointCache[insertIndex] = newPoint; } - bool ValidContactDistance(const ManifoldPoint& pt) const + bool ValidContactDistance(const btManifoldPoint& pt) const { return pt.m_distance1 <= GetContactBreakingTreshold(); } /// calculated new worldspace coordinates and depth, and reject points that exceed the collision margin - void RefreshContactPoints( const SimdTransform& trA,const SimdTransform& trB); + void RefreshContactPoints( const btTransform& trA,const btTransform& trB); void ClearManifold(); diff --git a/src/BulletCollision/NarrowPhaseCollision/btPointCollector.h b/src/BulletCollision/NarrowPhaseCollision/btPointCollector.h index 16a570161..0e25f19bd 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btPointCollector.h +++ b/src/BulletCollision/NarrowPhaseCollision/btPointCollector.h @@ -20,17 +20,17 @@ subject to the following restrictions: -struct PointCollector : public DiscreteCollisionDetectorInterface::Result +struct btPointCollector : public btDiscreteCollisionDetectorInterface::Result { - SimdVector3 m_normalOnBInWorld; - SimdVector3 m_pointInWorld; - SimdScalar m_distance;//negative means penetration + btVector3 m_normalOnBInWorld; + btVector3 m_pointInWorld; + btScalar m_distance;//negative means penetration bool m_hasResult; - PointCollector () + btPointCollector () : m_distance(1e30f),m_hasResult(false) { } @@ -40,7 +40,7 @@ struct PointCollector : public DiscreteCollisionDetectorInterface::Result //?? } - virtual void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth) + virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth) { if (depth< m_distance) { diff --git a/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp b/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp index 926a47cf6..5c4460b19 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp @@ -16,7 +16,7 @@ subject to the following restrictions: #include "btRaycastCallback.h" -TriangleRaycastCallback::TriangleRaycastCallback(const SimdVector3& from,const SimdVector3& to) +btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to) : m_from(from), m_to(to), @@ -27,18 +27,18 @@ TriangleRaycastCallback::TriangleRaycastCallback(const SimdVector3& from,const S -void TriangleRaycastCallback::ProcessTriangle(SimdVector3* triangle,int partId, int triangleIndex) +void btTriangleRaycastCallback::ProcessTriangle(btVector3* triangle,int partId, int triangleIndex) { - const SimdVector3 &vert0=triangle[0]; - const SimdVector3 &vert1=triangle[1]; - const SimdVector3 &vert2=triangle[2]; + const btVector3 &vert0=triangle[0]; + const btVector3 &vert1=triangle[1]; + const btVector3 &vert2=triangle[2]; - SimdVector3 v10; v10 = vert1 - vert0 ; - SimdVector3 v20; v20 = vert2 - vert0 ; + btVector3 v10; v10 = vert1 - vert0 ; + btVector3 v20; v20 = vert2 - vert0 ; - SimdVector3 triangleNormal; triangleNormal = v10.cross( v20 ); + btVector3 triangleNormal; triangleNormal = v10.cross( v20 ); const float dist = vert0.dot(triangleNormal); float dist_a = triangleNormal.dot(m_from) ; @@ -64,22 +64,22 @@ void TriangleRaycastCallback::ProcessTriangle(SimdVector3* triangle,int partId, float edge_tolerance =triangleNormal.length2(); edge_tolerance *= -0.0001f; - SimdVector3 point; point.setInterpolate3( m_from, m_to, distance); + btVector3 point; point.setInterpolate3( m_from, m_to, distance); { - SimdVector3 v0p; v0p = vert0 - point; - SimdVector3 v1p; v1p = vert1 - point; - SimdVector3 cp0; cp0 = v0p.cross( v1p ); + btVector3 v0p; v0p = vert0 - point; + btVector3 v1p; v1p = vert1 - point; + btVector3 cp0; cp0 = v0p.cross( v1p ); if ( (float)(cp0.dot(triangleNormal)) >=edge_tolerance) { - SimdVector3 v2p; v2p = vert2 - point; - SimdVector3 cp1; + btVector3 v2p; v2p = vert2 - point; + btVector3 cp1; cp1 = v1p.cross( v2p); if ( (float)(cp1.dot(triangleNormal)) >=edge_tolerance) { - SimdVector3 cp2; + btVector3 cp2; cp2 = v2p.cross(v0p); if ( (float)(cp2.dot(triangleNormal)) >=edge_tolerance) diff --git a/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h b/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h index a4f132b76..86e344e5c 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h +++ b/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h @@ -17,24 +17,24 @@ subject to the following restrictions: #define RAYCAST_TRI_CALLBACK_H #include "BulletCollision/CollisionShapes/btTriangleCallback.h" -struct BroadphaseProxy; +struct btBroadphaseProxy; -class TriangleRaycastCallback: public TriangleCallback +class btTriangleRaycastCallback: public btTriangleCallback { public: //input - SimdVector3 m_from; - SimdVector3 m_to; + btVector3 m_from; + btVector3 m_to; float m_hitFraction; - TriangleRaycastCallback(const SimdVector3& from,const SimdVector3& to); + btTriangleRaycastCallback(const btVector3& from,const btVector3& to); - virtual void ProcessTriangle(SimdVector3* triangle, int partId, int triangleIndex); + virtual void ProcessTriangle(btVector3* triangle, int partId, int triangleIndex); - virtual float ReportHit(const SimdVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex ) = 0; + virtual float ReportHit(const btVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex ) = 0; }; diff --git a/src/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h b/src/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h index f773fe606..cf65f4650 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h +++ b/src/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h @@ -18,42 +18,42 @@ subject to the following restrictions: #ifndef SIMPLEX_SOLVER_INTERFACE_H #define SIMPLEX_SOLVER_INTERFACE_H -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdPoint3.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btPoint3.h" #define NO_VIRTUAL_INTERFACE 1 #ifdef NO_VIRTUAL_INTERFACE #include "btVoronoiSimplexSolver.h" -#define SimplexSolverInterface VoronoiSimplexSolver +#define btSimplexSolverInterface btVoronoiSimplexSolver #else -/// SimplexSolverInterface can incrementally calculate distance between origin and up to 4 vertices +/// btSimplexSolverInterface can incrementally calculate distance between origin and up to 4 vertices /// Used by GJK or Linear Casting. Can be implemented by the Johnson-algorithm or alternative approaches based on /// voronoi regions or barycentric coordinates -class SimplexSolverInterface +class btSimplexSolverInterface { public: - virtual ~SimplexSolverInterface() {}; + virtual ~btSimplexSolverInterface() {}; virtual void reset() = 0; - virtual void addVertex(const SimdVector3& w, const SimdPoint3& p, const SimdPoint3& q) = 0; + virtual void addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q) = 0; - virtual bool closest(SimdVector3& v) = 0; + virtual bool closest(btVector3& v) = 0; - virtual SimdScalar maxVertex() = 0; + virtual btScalar maxVertex() = 0; virtual bool fullSimplex() const = 0; - virtual int getSimplex(SimdPoint3 *pBuf, SimdPoint3 *qBuf, SimdVector3 *yBuf) const = 0; + virtual int getSimplex(btPoint3 *pBuf, btPoint3 *qBuf, btVector3 *yBuf) const = 0; - virtual bool inSimplex(const SimdVector3& w) = 0; + virtual bool inSimplex(const btVector3& w) = 0; - virtual void backup_closest(SimdVector3& v) = 0; + virtual void backup_closest(btVector3& v) = 0; virtual bool emptySimplex() const = 0; - virtual void compute_points(SimdPoint3& p1, SimdPoint3& p2) = 0; + virtual void compute_points(btPoint3& p1, btPoint3& p2) = 0; virtual int numVertices() const =0; diff --git a/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp b/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp index 8a3733c1f..55fef5f05 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp @@ -20,7 +20,7 @@ subject to the following restrictions: #include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h" -SubsimplexConvexCast::SubsimplexConvexCast (ConvexShape* convexA,ConvexShape* convexB,SimplexSolverInterface* simplexSolver) +btSubsimplexConvexCast::btSubsimplexConvexCast (btConvexShape* convexA,btConvexShape* convexB,btSimplexSolverInterface* simplexSolver) :m_simplexSolver(simplexSolver), m_convexA(convexA),m_convexB(convexB) { @@ -29,19 +29,19 @@ m_convexA(convexA),m_convexB(convexB) #define MAX_ITERATIONS 1000 -bool SubsimplexConvexCast::calcTimeOfImpact( - const SimdTransform& fromA, - const SimdTransform& toA, - const SimdTransform& fromB, - const SimdTransform& toB, +bool btSubsimplexConvexCast::calcTimeOfImpact( + const btTransform& fromA, + const btTransform& toA, + const btTransform& fromB, + const btTransform& toB, CastResult& result) { - MinkowskiSumShape combi(m_convexA,m_convexB); - MinkowskiSumShape* convex = &combi; + btMinkowskiSumShape combi(m_convexA,m_convexB); + btMinkowskiSumShape* convex = &combi; - SimdTransform rayFromLocalA; - SimdTransform rayToLocalA; + btTransform rayFromLocalA; + btTransform rayToLocalA; rayFromLocalA = fromA.inverse()* fromB; rayToLocalA = toA.inverse()* toB; @@ -49,28 +49,28 @@ bool SubsimplexConvexCast::calcTimeOfImpact( m_simplexSolver->reset(); - convex->SetTransformB(SimdTransform(rayFromLocalA.getBasis())); + convex->SetTransformB(btTransform(rayFromLocalA.getBasis())); //float radius = 0.01f; - SimdScalar lambda = 0.f; + btScalar lambda = 0.f; //todo: need to verify this: //because of minkowski difference, we need the inverse direction - SimdVector3 s = -rayFromLocalA.getOrigin(); - SimdVector3 r = -(rayToLocalA.getOrigin()-rayFromLocalA.getOrigin()); - SimdVector3 x = s; - SimdVector3 v; - SimdVector3 arbitraryPoint = convex->LocalGetSupportingVertex(r); + btVector3 s = -rayFromLocalA.getOrigin(); + btVector3 r = -(rayToLocalA.getOrigin()-rayFromLocalA.getOrigin()); + btVector3 x = s; + btVector3 v; + btVector3 arbitraryPoint = convex->LocalGetSupportingVertex(r); v = x - arbitraryPoint; int maxIter = MAX_ITERATIONS; - SimdVector3 n; + btVector3 n; n.setValue(0.f,0.f,0.f); bool hasResult = false; - SimdVector3 c; + btVector3 c; float lastLambda = lambda; @@ -78,7 +78,7 @@ bool SubsimplexConvexCast::calcTimeOfImpact( float dist2 = v.length2(); float epsilon = 0.0001f; - SimdVector3 w,p; + btVector3 w,p; float VdotR; while ( (dist2 > epsilon) && maxIter--) diff --git a/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h b/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h index 6908cfed2..a2a3193b0 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h +++ b/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h @@ -19,30 +19,30 @@ subject to the following restrictions: #include "btConvexCast.h" #include "btSimplexSolverInterface.h" -class ConvexShape; +class btConvexShape; -/// SubsimplexConvexCast implements Gino van den Bergens' paper -///"Ray Casting against General Convex Objects with Application to Continuous Collision Detection" +/// btSubsimplexConvexCast implements Gino van den Bergens' paper +///"Ray Casting against bteral Convex Objects with Application to Continuous Collision Detection" /// GJK based Ray Cast, optimized version /// Objects should not start in overlap, otherwise results are not defined. -class SubsimplexConvexCast : public ConvexCast +class btSubsimplexConvexCast : public btConvexCast { - SimplexSolverInterface* m_simplexSolver; - ConvexShape* m_convexA; - ConvexShape* m_convexB; + btSimplexSolverInterface* m_simplexSolver; + btConvexShape* m_convexA; + btConvexShape* m_convexB; public: - SubsimplexConvexCast (ConvexShape* shapeA,ConvexShape* shapeB,SimplexSolverInterface* simplexSolver); + btSubsimplexConvexCast (btConvexShape* shapeA,btConvexShape* shapeB,btSimplexSolverInterface* simplexSolver); - //virtual ~SubsimplexConvexCast(); + //virtual ~btSubsimplexConvexCast(); ///SimsimplexConvexCast calculateTimeOfImpact calculates the time of impact+normal for the linear cast (sweep) between two moving objects. - ///Precondition is that objects should not penetration/overlap at the start from the interval. Overlap can be tested using GjkPairDetector. + ///Precondition is that objects should not penetration/overlap at the start from the interval. Overlap can be tested using btGjkPairDetector. virtual bool calcTimeOfImpact( - const SimdTransform& fromA, - const SimdTransform& toA, - const SimdTransform& fromB, - const SimdTransform& toB, + const btTransform& fromA, + const btTransform& toA, + const btTransform& fromB, + const btTransform& toB, CastResult& result); }; diff --git a/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp b/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp index ee01f230a..d72ac545e 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp @@ -34,7 +34,7 @@ subject to the following restrictions: #define VERTD 3 #define CATCH_DEGENERATE_TETRAHEDRON 1 -void VoronoiSimplexSolver::removeVertex(int index) +void btVoronoiSimplexSolver::removeVertex(int index) { assert(m_numVertices>0); @@ -44,7 +44,7 @@ void VoronoiSimplexSolver::removeVertex(int index) m_simplexPointsQ[index] = m_simplexPointsQ[m_numVertices]; } -void VoronoiSimplexSolver::ReduceVertices (const UsageBitfield& usedVerts) +void btVoronoiSimplexSolver::ReduceVertices (const btUsageBitfield& usedVerts) { if ((numVertices() >= 4) && (!usedVerts.usedVertexD)) removeVertex(3); @@ -65,19 +65,19 @@ void VoronoiSimplexSolver::ReduceVertices (const UsageBitfield& usedVerts) //clear the simplex, remove all the vertices -void VoronoiSimplexSolver::reset() +void btVoronoiSimplexSolver::reset() { m_cachedValidClosest = false; m_numVertices = 0; m_needsUpdate = true; - m_lastW = SimdVector3(1e30f,1e30f,1e30f); + m_lastW = btVector3(1e30f,1e30f,1e30f); m_cachedBC.Reset(); } //add a vertex -void VoronoiSimplexSolver::addVertex(const SimdVector3& w, const SimdPoint3& p, const SimdPoint3& q) +void btVoronoiSimplexSolver::addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q) { m_lastW = w; m_needsUpdate = true; @@ -89,7 +89,7 @@ void VoronoiSimplexSolver::addVertex(const SimdVector3& w, const SimdPoint3& p, m_numVertices++; } -bool VoronoiSimplexSolver::UpdateClosestVectorAndPoints() +bool btVoronoiSimplexSolver::UpdateClosestVectorAndPoints() { if (m_needsUpdate) @@ -116,13 +116,13 @@ bool VoronoiSimplexSolver::UpdateClosestVectorAndPoints() case 2: { //closest point origin from line segment - const SimdVector3& from = m_simplexVectorW[0]; - const SimdVector3& to = m_simplexVectorW[1]; - SimdVector3 nearest; + const btVector3& from = m_simplexVectorW[0]; + const btVector3& to = m_simplexVectorW[1]; + btVector3 nearest; - SimdVector3 p (0.f,0.f,0.f); - SimdVector3 diff = p - from; - SimdVector3 v = to - from; + btVector3 p (0.f,0.f,0.f); + btVector3 diff = p - from; + btVector3 v = to - from; float t = v.dot(diff); if (t > 0) { @@ -159,11 +159,11 @@ bool VoronoiSimplexSolver::UpdateClosestVectorAndPoints() case 3: { //closest point origin from triangle - SimdVector3 p (0.f,0.f,0.f); + btVector3 p (0.f,0.f,0.f); - const SimdVector3& a = m_simplexVectorW[0]; - const SimdVector3& b = m_simplexVectorW[1]; - const SimdVector3& c = m_simplexVectorW[2]; + const btVector3& a = m_simplexVectorW[0]; + const btVector3& b = m_simplexVectorW[1]; + const btVector3& c = m_simplexVectorW[2]; ClosestPtPointTriangle(p,a,b,c,m_cachedBC); m_cachedP1 = m_simplexPointsP[0] * m_cachedBC.m_barycentricCoords[0] + @@ -187,12 +187,12 @@ bool VoronoiSimplexSolver::UpdateClosestVectorAndPoints() { - SimdVector3 p (0.f,0.f,0.f); + btVector3 p (0.f,0.f,0.f); - const SimdVector3& a = m_simplexVectorW[0]; - const SimdVector3& b = m_simplexVectorW[1]; - const SimdVector3& c = m_simplexVectorW[2]; - const SimdVector3& d = m_simplexVectorW[3]; + const btVector3& a = m_simplexVectorW[0]; + const btVector3& b = m_simplexVectorW[1]; + const btVector3& c = m_simplexVectorW[2]; + const btVector3& d = m_simplexVectorW[3]; bool hasSeperation = ClosestPtPointTetrahedron(p,a,b,c,d,m_cachedBC); @@ -244,7 +244,7 @@ bool VoronoiSimplexSolver::UpdateClosestVectorAndPoints() } //return/calculate the closest vertex -bool VoronoiSimplexSolver::closest(SimdVector3& v) +bool btVoronoiSimplexSolver::closest(btVector3& v) { bool succes = UpdateClosestVectorAndPoints(); v = m_cachedV; @@ -253,13 +253,13 @@ bool VoronoiSimplexSolver::closest(SimdVector3& v) -SimdScalar VoronoiSimplexSolver::maxVertex() +btScalar btVoronoiSimplexSolver::maxVertex() { int i, numverts = numVertices(); - SimdScalar maxV = 0.f; + btScalar maxV = 0.f; for (i=0;i= 0.0f && d4 <= d3) @@ -370,7 +370,7 @@ bool VoronoiSimplexSolver::ClosestPtPointTriangle(const SimdPoint3& p, const Sim } // Check if P in vertex region outside C - SimdVector3 cp = p - c; + btVector3 cp = p - c; float d5 = ab.dot(cp); float d6 = ac.dot(cp); if (d6 >= 0.0f && d5 <= d6) @@ -427,9 +427,9 @@ bool VoronoiSimplexSolver::ClosestPtPointTriangle(const SimdPoint3& p, const Sim /// Test if point p and d lie on opposite sides of plane through abc -int VoronoiSimplexSolver::PointOutsideOfPlane(const SimdPoint3& p, const SimdPoint3& a, const SimdPoint3& b, const SimdPoint3& c, const SimdPoint3& d) +int btVoronoiSimplexSolver::PointOutsideOfPlane(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c, const btPoint3& d) { - SimdVector3 normal = (b-a).cross(c-a); + btVector3 normal = (b-a).cross(c-a); float signp = (p - a).dot(normal); // [AP AB AC] float signd = (d - a).dot( normal); // [AD AB AC] @@ -446,9 +446,9 @@ int VoronoiSimplexSolver::PointOutsideOfPlane(const SimdPoint3& p, const SimdPoi } -bool VoronoiSimplexSolver::ClosestPtPointTetrahedron(const SimdPoint3& p, const SimdPoint3& a, const SimdPoint3& b, const SimdPoint3& c, const SimdPoint3& d, SubSimplexClosestResult& finalResult) +bool btVoronoiSimplexSolver::ClosestPtPointTetrahedron(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c, const btPoint3& d, btSubSimplexClosestResult& finalResult) { - SubSimplexClosestResult tempResult; + btSubSimplexClosestResult tempResult; // Start out assuming point inside all halfspaces, so closest to itself finalResult.m_closestPointOnSimplex = p; @@ -480,7 +480,7 @@ bool VoronoiSimplexSolver::ClosestPtPointTetrahedron(const SimdPoint3& p, const if (pointOutsideABC) { ClosestPtPointTriangle(p, a, b, c,tempResult); - SimdPoint3 q = tempResult.m_closestPointOnSimplex; + btPoint3 q = tempResult.m_closestPointOnSimplex; float sqDist = (q - p).dot( q - p); // Update best closest point if (squared) distance is less than current best @@ -507,7 +507,7 @@ bool VoronoiSimplexSolver::ClosestPtPointTetrahedron(const SimdPoint3& p, const if (pointOutsideACD) { ClosestPtPointTriangle(p, a, c, d,tempResult); - SimdPoint3 q = tempResult.m_closestPointOnSimplex; + btPoint3 q = tempResult.m_closestPointOnSimplex; //convert result bitmask! float sqDist = (q - p).dot( q - p); @@ -534,7 +534,7 @@ bool VoronoiSimplexSolver::ClosestPtPointTetrahedron(const SimdPoint3& p, const if (pointOutsideADB) { ClosestPtPointTriangle(p, a, d, b,tempResult); - SimdPoint3 q = tempResult.m_closestPointOnSimplex; + btPoint3 q = tempResult.m_closestPointOnSimplex; //convert result bitmask! float sqDist = (q - p).dot( q - p); @@ -561,7 +561,7 @@ bool VoronoiSimplexSolver::ClosestPtPointTetrahedron(const SimdPoint3& p, const if (pointOutsideBDC) { ClosestPtPointTriangle(p, b, d, c,tempResult); - SimdPoint3 q = tempResult.m_closestPointOnSimplex; + btPoint3 q = tempResult.m_closestPointOnSimplex; //convert result bitmask! float sqDist = (q - p).dot( q - p); if (sqDist < bestSqDist) diff --git a/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h b/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h index 0d1ac72bf..da6aa9680 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h +++ b/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h @@ -15,8 +15,8 @@ subject to the following restrictions: -#ifndef VoronoiSimplexSolver_H -#define VoronoiSimplexSolver_H +#ifndef btVoronoiSimplexSolver_H +#define btVoronoiSimplexSolver_H #include "btSimplexSolverInterface.h" @@ -24,8 +24,8 @@ subject to the following restrictions: #define VORONOI_SIMPLEX_MAX_VERTS 5 -struct UsageBitfield{ - UsageBitfield() +struct btUsageBitfield{ + btUsageBitfield() { reset(); } @@ -48,13 +48,13 @@ struct UsageBitfield{ }; -struct SubSimplexClosestResult +struct btSubSimplexClosestResult { - SimdPoint3 m_closestPointOnSimplex; + btPoint3 m_closestPointOnSimplex; //MASK for m_usedVertices //stores the simplex vertex-usage, using the MASK, // if m_usedVertices & MASK then the related vertex is used - UsageBitfield m_usedVertices; + btUsageBitfield m_usedVertices; float m_barycentricCoords[4]; bool m_degenerate; @@ -84,67 +84,67 @@ struct SubSimplexClosestResult }; -/// VoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points simplex to the origin. +/// btVoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points simplex to the origin. /// Can be used with GJK, as an alternative to Johnson distance algorithm. #ifdef NO_VIRTUAL_INTERFACE -class VoronoiSimplexSolver +class btVoronoiSimplexSolver #else -class VoronoiSimplexSolver : public SimplexSolverInterface +class btVoronoiSimplexSolver : public btSimplexSolverInterface #endif { public: int m_numVertices; - SimdVector3 m_simplexVectorW[VORONOI_SIMPLEX_MAX_VERTS]; - SimdPoint3 m_simplexPointsP[VORONOI_SIMPLEX_MAX_VERTS]; - SimdPoint3 m_simplexPointsQ[VORONOI_SIMPLEX_MAX_VERTS]; + btVector3 m_simplexVectorW[VORONOI_SIMPLEX_MAX_VERTS]; + btPoint3 m_simplexPointsP[VORONOI_SIMPLEX_MAX_VERTS]; + btPoint3 m_simplexPointsQ[VORONOI_SIMPLEX_MAX_VERTS]; - SimdPoint3 m_cachedP1; - SimdPoint3 m_cachedP2; - SimdVector3 m_cachedV; - SimdVector3 m_lastW; + btPoint3 m_cachedP1; + btPoint3 m_cachedP2; + btVector3 m_cachedV; + btVector3 m_lastW; bool m_cachedValidClosest; - SubSimplexClosestResult m_cachedBC; + btSubSimplexClosestResult m_cachedBC; bool m_needsUpdate; void removeVertex(int index); - void ReduceVertices (const UsageBitfield& usedVerts); + void ReduceVertices (const btUsageBitfield& usedVerts); bool UpdateClosestVectorAndPoints(); - bool ClosestPtPointTetrahedron(const SimdPoint3& p, const SimdPoint3& a, const SimdPoint3& b, const SimdPoint3& c, const SimdPoint3& d, SubSimplexClosestResult& finalResult); - int PointOutsideOfPlane(const SimdPoint3& p, const SimdPoint3& a, const SimdPoint3& b, const SimdPoint3& c, const SimdPoint3& d); - bool ClosestPtPointTriangle(const SimdPoint3& p, const SimdPoint3& a, const SimdPoint3& b, const SimdPoint3& c,SubSimplexClosestResult& result); + bool ClosestPtPointTetrahedron(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c, const btPoint3& d, btSubSimplexClosestResult& finalResult); + int PointOutsideOfPlane(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c, const btPoint3& d); + bool ClosestPtPointTriangle(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c,btSubSimplexClosestResult& result); public: void reset(); - void addVertex(const SimdVector3& w, const SimdPoint3& p, const SimdPoint3& q); + void addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q); - bool closest(SimdVector3& v); + bool closest(btVector3& v); - SimdScalar maxVertex(); + btScalar maxVertex(); bool fullSimplex() const { return (m_numVertices == 4); } - int getSimplex(SimdPoint3 *pBuf, SimdPoint3 *qBuf, SimdVector3 *yBuf) const; + int getSimplex(btPoint3 *pBuf, btPoint3 *qBuf, btVector3 *yBuf) const; - bool inSimplex(const SimdVector3& w); + bool inSimplex(const btVector3& w); - void backup_closest(SimdVector3& v) ; + void backup_closest(btVector3& v) ; bool emptySimplex() const ; - void compute_points(SimdPoint3& p1, SimdPoint3& p2) ; + void compute_points(btPoint3& p1, btPoint3& p2) ; int numVertices() const { diff --git a/src/BulletDynamics/CMakeLists.txt b/src/BulletDynamics/CMakeLists.txt index 3dfa71950..79e07b7f7 100644 --- a/src/BulletDynamics/CMakeLists.txt +++ b/src/BulletDynamics/CMakeLists.txt @@ -11,6 +11,8 @@ ADD_LIBRARY(LibBulletDynamics ConstraintSolver/btSequentialImpulseConstraintSolver.cpp ConstraintSolver/btSolve2LinearConstraint.cpp ConstraintSolver/btTypedConstraint.cpp + Dynamics/btDiscreteDynamicsWorld.cpp + Dynamics/btSimpleDynamicsWorld.cpp Dynamics/btRigidBody.cpp Vehicle/btRaycastVehicle.cpp Vehicle/btWheelInfo.cpp diff --git a/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h b/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h index a1975c187..52c7abbfe 100644 --- a/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h +++ b/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h @@ -16,22 +16,22 @@ subject to the following restrictions: #ifndef CONSTRAINT_SOLVER_H #define CONSTRAINT_SOLVER_H -class PersistentManifold; -class RigidBody; +class btPersistentManifold; +class btRigidBody; -struct ContactSolverInfo; -struct BroadphaseProxy; -class IDebugDraw; +struct btContactSolverInfo; +struct btBroadphaseProxy; +class btIDebugDraw; -/// ConstraintSolver provides solver interface -class ConstraintSolver +/// btConstraintSolver provides solver interface +class btConstraintSolver { public: - virtual ~ConstraintSolver() {} + virtual ~btConstraintSolver() {} - virtual float SolveGroup(PersistentManifold** manifold,int numManifolds,const ContactSolverInfo& info,class IDebugDraw* debugDrawer = 0) = 0; + virtual float SolveGroup(btPersistentManifold** manifold,int numManifolds,const btContactSolverInfo& info,class btIDebugDraw* debugDrawer = 0) = 0; }; diff --git a/src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp b/src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp index 617a1ec0a..f468d2755 100644 --- a/src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp +++ b/src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp @@ -16,10 +16,10 @@ subject to the following restrictions: #include "btContactConstraint.h" #include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" #include "btJacobianEntry.h" #include "btContactSolverInfo.h" -#include "LinearMath/GenMinMax.h" +#include "LinearMath/btMinMax.h" #include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h" #define ASSERT2 assert @@ -27,8 +27,8 @@ subject to the following restrictions: //some values to find stable tresholds float useGlobalSettingContacts = false;//true; -SimdScalar contactDamping = 0.2f; -SimdScalar contactTau = .02f;//0.02f;//*0.02f; +btScalar contactDamping = 0.2f; +btScalar contactTau = .02f;//0.02f;//*0.02f; @@ -37,9 +37,9 @@ SimdScalar contactTau = .02f;//0.02f;//*0.02f; //bilateral constraint between two dynamic objects -void resolveSingleBilateral(RigidBody& body1, const SimdVector3& pos1, - RigidBody& body2, const SimdVector3& pos2, - SimdScalar distance, const SimdVector3& normal,SimdScalar& impulse ,float timeStep) +void resolveSingleBilateral(btRigidBody& body1, const btVector3& pos1, + btRigidBody& body2, const btVector3& pos2, + btScalar distance, const btVector3& normal,btScalar& impulse ,float timeStep) { float normalLenSqr = normal.length2(); ASSERT2(fabs(normalLenSqr) < 1.1f); @@ -48,24 +48,24 @@ void resolveSingleBilateral(RigidBody& body1, const SimdVector3& pos1, impulse = 0.f; return; } - SimdVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); - SimdVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition(); + btVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); + btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition(); //this jacobian entry could be re-used for all iterations - SimdVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); - SimdVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); - SimdVector3 vel = vel1 - vel2; + btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); + btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); + btVector3 vel = vel1 - vel2; - JacobianEntry jac(body1.getCenterOfMassTransform().getBasis().transpose(), + btJacobianEntry jac(body1.getCenterOfMassTransform().getBasis().transpose(), body2.getCenterOfMassTransform().getBasis().transpose(), rel_pos1,rel_pos2,normal,body1.getInvInertiaDiagLocal(),body1.getInvMass(), body2.getInvInertiaDiagLocal(),body2.getInvMass()); - SimdScalar jacDiagAB = jac.getDiagonal(); - SimdScalar jacDiagABInv = 1.f / jacDiagAB; + btScalar jacDiagAB = jac.getDiagonal(); + btScalar jacDiagABInv = 1.f / jacDiagAB; - SimdScalar rel_vel = jac.getRelativeVelocity( + btScalar rel_vel = jac.getRelativeVelocity( body1.getLinearVelocity(), body1.getCenterOfMassTransform().getBasis().transpose() * body1.getAngularVelocity(), body2.getLinearVelocity(), @@ -78,10 +78,10 @@ void resolveSingleBilateral(RigidBody& body1, const SimdVector3& pos1, #ifdef ONLY_USE_LINEAR_MASS - SimdScalar massTerm = 1.f / (body1.getInvMass() + body2.getInvMass()); + btScalar massTerm = 1.f / (body1.getInvMass() + body2.getInvMass()); impulse = - contactDamping * rel_vel * massTerm; #else - SimdScalar velocityImpulse = -contactDamping * rel_vel * jacDiagABInv; + btScalar velocityImpulse = -contactDamping * rel_vel * jacDiagABInv; impulse = velocityImpulse; #endif } @@ -92,33 +92,33 @@ void resolveSingleBilateral(RigidBody& body1, const SimdVector3& pos1, //velocity + friction //response between two dynamic objects with friction float resolveSingleCollision( - RigidBody& body1, - RigidBody& body2, - ManifoldPoint& contactPoint, - const ContactSolverInfo& solverInfo + btRigidBody& body1, + btRigidBody& body2, + btManifoldPoint& contactPoint, + const btContactSolverInfo& solverInfo ) { - const SimdVector3& pos1 = contactPoint.GetPositionWorldOnA(); - const SimdVector3& pos2 = contactPoint.GetPositionWorldOnB(); + const btVector3& pos1 = contactPoint.GetPositionWorldOnA(); + const btVector3& pos2 = contactPoint.GetPositionWorldOnB(); // printf("distance=%f\n",distance); - const SimdVector3& normal = contactPoint.m_normalWorldOnB; + const btVector3& normal = contactPoint.m_normalWorldOnB; - SimdVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); - SimdVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition(); + btVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); + btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition(); - SimdVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); - SimdVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); - SimdVector3 vel = vel1 - vel2; - SimdScalar rel_vel; + btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); + btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); + btVector3 vel = vel1 - vel2; + btScalar rel_vel; rel_vel = normal.dot(vel); - SimdScalar Kfps = 1.f / solverInfo.m_timeStep ; + btScalar Kfps = 1.f / solverInfo.m_timeStep ; float damping = solverInfo.m_damping ; float Kerp = solverInfo.m_erp; @@ -133,23 +133,23 @@ float resolveSingleCollision( //printf("dist=%f\n",distance); - ConstraintPersistentData* cpd = (ConstraintPersistentData*) contactPoint.m_userPersistentData; + btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData; assert(cpd); - SimdScalar distance = cpd->m_penetration;//contactPoint.GetDistance(); + btScalar distance = cpd->m_penetration;//contactPoint.GetDistance(); //distance = 0.f; - SimdScalar positionalError = Kcor *-distance; + btScalar positionalError = Kcor *-distance; //jacDiagABInv; - SimdScalar velocityError = cpd->m_restitution - rel_vel;// * damping; + btScalar velocityError = cpd->m_restitution - rel_vel;// * damping; - SimdScalar penetrationImpulse = positionalError * cpd->m_jacDiagABInv; + btScalar penetrationImpulse = positionalError * cpd->m_jacDiagABInv; - SimdScalar velocityImpulse = velocityError * cpd->m_jacDiagABInv; + btScalar velocityImpulse = velocityError * cpd->m_jacDiagABInv; - SimdScalar normalImpulse = penetrationImpulse+velocityImpulse; + btScalar normalImpulse = penetrationImpulse+velocityImpulse; // See Erin Catto's GDC 2006 paper: Clamp the accumulated impulse float oldNormalImpulse = cpd->m_appliedImpulse; @@ -166,26 +166,26 @@ float resolveSingleCollision( float resolveSingleFriction( - RigidBody& body1, - RigidBody& body2, - ManifoldPoint& contactPoint, - const ContactSolverInfo& solverInfo + btRigidBody& body1, + btRigidBody& body2, + btManifoldPoint& contactPoint, + const btContactSolverInfo& solverInfo ) { - const SimdVector3& pos1 = contactPoint.GetPositionWorldOnA(); - const SimdVector3& pos2 = contactPoint.GetPositionWorldOnB(); + const btVector3& pos1 = contactPoint.GetPositionWorldOnA(); + const btVector3& pos2 = contactPoint.GetPositionWorldOnB(); - SimdVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); - SimdVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition(); + btVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); + btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition(); - ConstraintPersistentData* cpd = (ConstraintPersistentData*) contactPoint.m_userPersistentData; + btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData; assert(cpd); float combinedFriction = cpd->m_friction; - SimdScalar limit = cpd->m_appliedImpulse * combinedFriction; + btScalar limit = cpd->m_appliedImpulse * combinedFriction; //if (contactPoint.m_appliedImpulse>0.f) //friction { @@ -193,14 +193,14 @@ float resolveSingleFriction( { // 1st tangent - SimdVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); - SimdVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); - SimdVector3 vel = vel1 - vel2; + btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); + btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); + btVector3 vel = vel1 - vel2; - SimdScalar vrel = cpd->m_frictionWorldTangential0.dot(vel); + btScalar vrel = cpd->m_frictionWorldTangential0.dot(vel); // calculate j that moves us to zero relative velocity - SimdScalar j = -vrel * cpd->m_jacDiagABInvTangent0; + btScalar j = -vrel * cpd->m_jacDiagABInvTangent0; float total = cpd->m_accumulatedTangentImpulse0 + j; GEN_set_min(total, limit); GEN_set_max(total, -limit); @@ -213,14 +213,14 @@ float resolveSingleFriction( { // 2nd tangent - SimdVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); - SimdVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); - SimdVector3 vel = vel1 - vel2; + btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); + btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); + btVector3 vel = vel1 - vel2; - SimdScalar vrel = cpd->m_frictionWorldTangential1.dot(vel); + btScalar vrel = cpd->m_frictionWorldTangential1.dot(vel); // calculate j that moves us to zero relative velocity - SimdScalar j = -vrel * cpd->m_jacDiagABInvTangent1; + btScalar j = -vrel * cpd->m_jacDiagABInvTangent1; float total = cpd->m_accumulatedTangentImpulse1 + j; GEN_set_min(total, limit); GEN_set_max(total, -limit); diff --git a/src/BulletDynamics/ConstraintSolver/btContactConstraint.h b/src/BulletDynamics/ConstraintSolver/btContactConstraint.h index 1cb7a9642..f7dbde5f9 100644 --- a/src/BulletDynamics/ConstraintSolver/btContactConstraint.h +++ b/src/BulletDynamics/ConstraintSolver/btContactConstraint.h @@ -18,11 +18,11 @@ subject to the following restrictions: //todo: make into a proper class working with the iterative constraint solver -class RigidBody; -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdScalar.h" -struct ContactSolverInfo; -class ManifoldPoint; +class btRigidBody; +#include "LinearMath/btVector3.h" +#include "LinearMath/btScalar.h" +struct btContactSolverInfo; +class btManifoldPoint; enum { DEFAULT_CONTACT_SOLVER_TYPE=0, @@ -33,14 +33,14 @@ enum { }; -typedef float (*ContactSolverFunc)(RigidBody& body1, - RigidBody& body2, - class ManifoldPoint& contactPoint, - const ContactSolverInfo& info); +typedef float (*ContactSolverFunc)(btRigidBody& body1, + btRigidBody& body2, + class btManifoldPoint& contactPoint, + const btContactSolverInfo& info); -struct ConstraintPersistentData +struct btConstraintPersistentData { - inline ConstraintPersistentData() + inline btConstraintPersistentData() :m_appliedImpulse(0.f), m_prevAppliedImpulse(0.f), m_accumulatedTangentImpulse0(0.f), @@ -69,8 +69,8 @@ struct ConstraintPersistentData float m_restitution; float m_friction; float m_penetration; - SimdVector3 m_frictionWorldTangential0; - SimdVector3 m_frictionWorldTangential1; + btVector3 m_frictionWorldTangential0; + btVector3 m_frictionWorldTangential1; ContactSolverFunc m_contactSolverFunc; ContactSolverFunc m_frictionSolverFunc; @@ -79,25 +79,25 @@ struct ConstraintPersistentData ///bilateral constraint between two dynamic objects ///positive distance = separation, negative distance = penetration -void resolveSingleBilateral(RigidBody& body1, const SimdVector3& pos1, - RigidBody& body2, const SimdVector3& pos2, - SimdScalar distance, const SimdVector3& normal,SimdScalar& impulse ,float timeStep); +void resolveSingleBilateral(btRigidBody& body1, const btVector3& pos1, + btRigidBody& body2, const btVector3& pos2, + btScalar distance, const btVector3& normal,btScalar& impulse ,float timeStep); ///contact constraint resolution: ///calculate and apply impulse to satisfy non-penetration and non-negative relative velocity constraint ///positive distance = separation, negative distance = penetration float resolveSingleCollision( - RigidBody& body1, - RigidBody& body2, - ManifoldPoint& contactPoint, - const ContactSolverInfo& info); + btRigidBody& body1, + btRigidBody& body2, + btManifoldPoint& contactPoint, + const btContactSolverInfo& info); float resolveSingleFriction( - RigidBody& body1, - RigidBody& body2, - ManifoldPoint& contactPoint, - const ContactSolverInfo& solverInfo + btRigidBody& body1, + btRigidBody& body2, + btManifoldPoint& contactPoint, + const btContactSolverInfo& solverInfo ); #endif //CONTACT_CONSTRAINT_H diff --git a/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h b/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h index 2ec9b7f6c..ed1ba6ac1 100644 --- a/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h +++ b/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h @@ -17,10 +17,10 @@ subject to the following restrictions: #define CONTACT_SOLVER_INFO -struct ContactSolverInfo +struct btContactSolverInfo { - inline ContactSolverInfo() + inline btContactSolverInfo() { m_tau = 0.6f; m_damping = 1.0f; diff --git a/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp b/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp index 0cf85232a..0422a62c5 100644 --- a/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp +++ b/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp @@ -17,18 +17,18 @@ subject to the following restrictions: #include "btGeneric6DofConstraint.h" #include "BulletDynamics/Dynamics/btRigidBody.h" #include "BulletDynamics/Dynamics/btMassProps.h" -#include "LinearMath/SimdTransformUtil.h" +#include "LinearMath/btTransformUtil.h" -static const SimdScalar kSign[] = { 1.0f, -1.0f, 1.0f }; +static const btScalar kSign[] = { 1.0f, -1.0f, 1.0f }; static const int kAxisA[] = { 1, 0, 0 }; static const int kAxisB[] = { 2, 2, 1 }; -Generic6DofConstraint::Generic6DofConstraint() +btGeneric6DofConstraint::btGeneric6DofConstraint() { } -Generic6DofConstraint::Generic6DofConstraint(RigidBody& rbA, RigidBody& rbB, const SimdTransform& frameInA, const SimdTransform& frameInB) -: TypedConstraint(rbA, rbB) +btGeneric6DofConstraint::btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB) +: btTypedConstraint(rbA, rbB) , m_frameInA(frameInA) , m_frameInB(frameInB) { @@ -46,18 +46,18 @@ Generic6DofConstraint::Generic6DofConstraint(RigidBody& rbA, RigidBody& rbB, con } -void Generic6DofConstraint::BuildJacobian() +void btGeneric6DofConstraint::BuildJacobian() { - SimdVector3 normal(0,0,0); + btVector3 normal(0,0,0); - const SimdVector3& pivotInA = m_frameInA.getOrigin(); - const SimdVector3& pivotInB = m_frameInB.getOrigin(); + const btVector3& pivotInA = m_frameInA.getOrigin(); + const btVector3& pivotInB = m_frameInB.getOrigin(); - SimdVector3 pivotAInW = m_rbA.getCenterOfMassTransform() * m_frameInA.getOrigin(); - SimdVector3 pivotBInW = m_rbB.getCenterOfMassTransform() * m_frameInB.getOrigin(); + btVector3 pivotAInW = m_rbA.getCenterOfMassTransform() * m_frameInA.getOrigin(); + btVector3 pivotBInW = m_rbB.getCenterOfMassTransform() * m_frameInB.getOrigin(); - SimdVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); - SimdVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); + btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); + btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); int i; //linear part @@ -68,7 +68,7 @@ void Generic6DofConstraint::BuildJacobian() normal[i] = 1; // Create linear atom - new (&m_jacLinear[i]) JacobianEntry( + new (&m_jacLinear[i]) btJacobianEntry( m_rbA.getCenterOfMassTransform().getBasis().transpose(), m_rbB.getCenterOfMassTransform().getBasis().transpose(), m_rbA.getCenterOfMassTransform()*pivotInA - m_rbA.getCenterOfMassPosition(), @@ -80,7 +80,7 @@ void Generic6DofConstraint::BuildJacobian() m_rbB.getInvMass()); // Apply accumulated impulse - SimdVector3 impulse_vector = m_accumulatedImpulse[i] * normal; + btVector3 impulse_vector = m_accumulatedImpulse[i] * normal; m_rbA.applyImpulse( impulse_vector, rel_pos1); m_rbB.applyImpulse(-impulse_vector, rel_pos2); @@ -94,21 +94,21 @@ void Generic6DofConstraint::BuildJacobian() { if (isLimited(i+3)) { - SimdVector3 axisA = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn( kAxisA[i] ); - SimdVector3 axisB = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn( kAxisB[i] ); + btVector3 axisA = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn( kAxisA[i] ); + btVector3 axisB = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn( kAxisB[i] ); // Dirk: This is IMO mathematically the correct way, but we should consider axisA and axisB being near parallel maybe - SimdVector3 axis = kSign[i] * axisA.cross(axisB); + btVector3 axis = kSign[i] * axisA.cross(axisB); // Create angular atom - new (&m_jacAng[i]) JacobianEntry(axis, + new (&m_jacAng[i]) btJacobianEntry(axis, m_rbA.getCenterOfMassTransform().getBasis().transpose(), m_rbB.getCenterOfMassTransform().getBasis().transpose(), m_rbA.getInvInertiaDiagLocal(), m_rbB.getInvInertiaDiagLocal()); // Apply accumulated impulse - SimdVector3 impulse_vector = m_accumulatedImpulse[i + 3] * axis; + btVector3 impulse_vector = m_accumulatedImpulse[i + 3] * axis; m_rbA.applyTorqueImpulse( impulse_vector); m_rbB.applyTorqueImpulse(-impulse_vector); @@ -116,18 +116,18 @@ void Generic6DofConstraint::BuildJacobian() } } -void Generic6DofConstraint::SolveConstraint(SimdScalar timeStep) +void btGeneric6DofConstraint::SolveConstraint(btScalar timeStep) { - SimdScalar tau = 0.1f; - SimdScalar damping = 1.0f; + btScalar tau = 0.1f; + btScalar damping = 1.0f; - SimdVector3 pivotAInW = m_rbA.getCenterOfMassTransform() * m_frameInA.getOrigin(); - SimdVector3 pivotBInW = m_rbB.getCenterOfMassTransform() * m_frameInB.getOrigin(); + btVector3 pivotAInW = m_rbA.getCenterOfMassTransform() * m_frameInA.getOrigin(); + btVector3 pivotBInW = m_rbB.getCenterOfMassTransform() * m_frameInB.getOrigin(); - SimdVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); - SimdVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); + btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); + btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); - SimdVector3 normal(0,0,0); + btVector3 normal(0,0,0); int i; // linear @@ -135,24 +135,24 @@ void Generic6DofConstraint::SolveConstraint(SimdScalar timeStep) { if (isLimited(i)) { - SimdVector3 angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); - SimdVector3 angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); + btVector3 angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); + btVector3 angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); normal[i] = 1; - SimdScalar jacDiagABInv = 1.f / m_jacLinear[i].getDiagonal(); + btScalar jacDiagABInv = 1.f / m_jacLinear[i].getDiagonal(); //velocity error (first order error) - SimdScalar rel_vel = m_jacLinear[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, + btScalar rel_vel = m_jacLinear[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, m_rbB.getLinearVelocity(),angvelB); //positional error (zeroth order error) - SimdScalar depth = -(pivotAInW - pivotBInW).dot(normal); + btScalar depth = -(pivotAInW - pivotBInW).dot(normal); - SimdScalar impulse = (tau*depth/timeStep - damping*rel_vel) * jacDiagABInv; + btScalar impulse = (tau*depth/timeStep - damping*rel_vel) * jacDiagABInv; m_accumulatedImpulse[i] += impulse; - SimdVector3 impulse_vector = normal * impulse; + btVector3 impulse_vector = normal * impulse; m_rbA.applyImpulse( impulse_vector, rel_pos1); m_rbB.applyImpulse(-impulse_vector, rel_pos2); @@ -165,28 +165,28 @@ void Generic6DofConstraint::SolveConstraint(SimdScalar timeStep) { if (isLimited(i+3)) { - SimdVector3 angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); - SimdVector3 angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); + btVector3 angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); + btVector3 angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); - SimdScalar jacDiagABInv = 1.f / m_jacAng[i].getDiagonal(); + btScalar jacDiagABInv = 1.f / m_jacAng[i].getDiagonal(); //velocity error (first order error) - SimdScalar rel_vel = m_jacAng[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, + btScalar rel_vel = m_jacAng[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, m_rbB.getLinearVelocity(),angvelB); //positional error (zeroth order error) - SimdVector3 axisA = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn( kAxisA[i] ); - SimdVector3 axisB = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn( kAxisB[i] ); + btVector3 axisA = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn( kAxisA[i] ); + btVector3 axisB = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn( kAxisB[i] ); - SimdScalar rel_pos = kSign[i] * axisA.dot(axisB); + btScalar rel_pos = kSign[i] * axisA.dot(axisB); //impulse - SimdScalar impulse = -(tau*rel_pos/timeStep + damping*rel_vel) * jacDiagABInv; + btScalar impulse = -(tau*rel_pos/timeStep + damping*rel_vel) * jacDiagABInv; m_accumulatedImpulse[i + 3] += impulse; // Dirk: Not needed - we could actually project onto Jacobian entry here (same as above) - SimdVector3 axis = kSign[i] * axisA.cross(axisB); - SimdVector3 impulse_vector = axis * impulse; + btVector3 axis = kSign[i] * axisA.cross(axisB); + btVector3 impulse_vector = axis * impulse; m_rbA.applyTorqueImpulse( impulse_vector); m_rbB.applyTorqueImpulse(-impulse_vector); @@ -194,53 +194,53 @@ void Generic6DofConstraint::SolveConstraint(SimdScalar timeStep) } } -void Generic6DofConstraint::UpdateRHS(SimdScalar timeStep) +void btGeneric6DofConstraint::UpdateRHS(btScalar timeStep) { } -SimdScalar Generic6DofConstraint::ComputeAngle(int axis) const +btScalar btGeneric6DofConstraint::ComputeAngle(int axis) const { - SimdScalar angle; + btScalar angle; switch (axis) { case 0: { - SimdVector3 v1 = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn(1); - SimdVector3 v2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(1); - SimdVector3 w2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(2); + btVector3 v1 = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn(1); + btVector3 v2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(1); + btVector3 w2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(2); - SimdScalar s = v1.dot(w2); - SimdScalar c = v1.dot(v2); + btScalar s = v1.dot(w2); + btScalar c = v1.dot(v2); - angle = SimdAtan2( s, c ); + angle = btAtan2( s, c ); } break; case 1: { - SimdVector3 w1 = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn(2); - SimdVector3 w2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(2); - SimdVector3 u2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(0); + btVector3 w1 = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn(2); + btVector3 w2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(2); + btVector3 u2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(0); - SimdScalar s = w1.dot(u2); - SimdScalar c = w1.dot(w2); + btScalar s = w1.dot(u2); + btScalar c = w1.dot(w2); - angle = SimdAtan2( s, c ); + angle = btAtan2( s, c ); } break; case 2: { - SimdVector3 u1 = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn(0); - SimdVector3 u2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(0); - SimdVector3 v2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(1); + btVector3 u1 = m_rbA.getCenterOfMassTransform().getBasis() * m_frameInA.getBasis().getColumn(0); + btVector3 u2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(0); + btVector3 v2 = m_rbB.getCenterOfMassTransform().getBasis() * m_frameInB.getBasis().getColumn(1); - SimdScalar s = u1.dot(v2); - SimdScalar c = u1.dot(u2); + btScalar s = u1.dot(v2); + btScalar c = u1.dot(u2); - angle = SimdAtan2( s, c ); + angle = btAtan2( s, c ); } break; default: assert ( 0 ) ; break ; diff --git a/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h b/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h index e697fc938..ec31df72a 100644 --- a/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h +++ b/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h @@ -16,67 +16,67 @@ subject to the following restrictions: #ifndef GENERIC_6DOF_CONSTRAINT_H #define GENERIC_6DOF_CONSTRAINT_H -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" #include "BulletDynamics/ConstraintSolver/btJacobianEntry.h" #include "btTypedConstraint.h" -class RigidBody; +class btRigidBody; -/// Generic6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space -/// Generic6DofConstraint can leave any of the 6 degree of freedom 'free' or 'locked' +/// btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space +/// btGeneric6DofConstraint can leave any of the 6 degree of freedom 'free' or 'locked' /// Work in progress (is still a Hinge actually) -class Generic6DofConstraint : public TypedConstraint +class btGeneric6DofConstraint : public btTypedConstraint { - JacobianEntry m_jacLinear[3]; // 3 orthogonal linear constraints - JacobianEntry m_jacAng[3]; // 3 orthogonal angular constraints + btJacobianEntry m_jacLinear[3]; // 3 orthogonal linear constraints + btJacobianEntry m_jacAng[3]; // 3 orthogonal angular constraints - SimdTransform m_frameInA; // the constraint space w.r.t body A - SimdTransform m_frameInB; // the constraint space w.r.t body B + btTransform m_frameInA; // the constraint space w.r.t body A + btTransform m_frameInB; // the constraint space w.r.t body B - SimdScalar m_lowerLimit[6]; // the constraint lower limits - SimdScalar m_upperLimit[6]; // the constraint upper limits + btScalar m_lowerLimit[6]; // the constraint lower limits + btScalar m_upperLimit[6]; // the constraint upper limits - SimdScalar m_accumulatedImpulse[6]; + btScalar m_accumulatedImpulse[6]; public: - Generic6DofConstraint(RigidBody& rbA, RigidBody& rbB, const SimdTransform& frameInA, const SimdTransform& frameInB ); + btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ); - Generic6DofConstraint(); + btGeneric6DofConstraint(); virtual void BuildJacobian(); - virtual void SolveConstraint(SimdScalar timeStep); + virtual void SolveConstraint(btScalar timeStep); - void UpdateRHS(SimdScalar timeStep); + void UpdateRHS(btScalar timeStep); - SimdScalar ComputeAngle(int axis) const; + btScalar ComputeAngle(int axis) const; - void setLinearLowerLimit(const SimdVector3& linearLower) + void setLinearLowerLimit(const btVector3& linearLower) { m_lowerLimit[0] = linearLower.getX(); m_lowerLimit[1] = linearLower.getY(); m_lowerLimit[2] = linearLower.getZ(); } - void setLinearUpperLimit(const SimdVector3& linearUpper) + void setLinearUpperLimit(const btVector3& linearUpper) { m_upperLimit[0] = linearUpper.getX(); m_upperLimit[1] = linearUpper.getY(); m_upperLimit[2] = linearUpper.getZ(); } - void setAngularLowerLimit(const SimdVector3& angularLower) + void setAngularLowerLimit(const btVector3& angularLower) { m_lowerLimit[3] = angularLower.getX(); m_lowerLimit[4] = angularLower.getY(); m_lowerLimit[5] = angularLower.getZ(); } - void setAngularUpperLimit(const SimdVector3& angularUpper) + void setAngularUpperLimit(const btVector3& angularUpper) { m_upperLimit[3] = angularUpper.getX(); m_upperLimit[4] = angularUpper.getY(); @@ -84,7 +84,7 @@ public: } //first 3 are linear, next 3 are angular - void SetLimit(int axis, SimdScalar lo, SimdScalar hi) + void SetLimit(int axis, btScalar lo, btScalar hi) { m_lowerLimit[axis] = lo; m_upperLimit[axis] = hi; @@ -99,11 +99,11 @@ public: return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]); } - const RigidBody& GetRigidBodyA() const + const btRigidBody& GetRigidBodyA() const { return m_rbA; } - const RigidBody& GetRigidBodyB() const + const btRigidBody& GetRigidBodyB() const { return m_rbB; } diff --git a/src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp b/src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp index eaf84b632..b359ca0b4 100644 --- a/src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp +++ b/src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp @@ -17,16 +17,16 @@ subject to the following restrictions: #include "btHingeConstraint.h" #include "BulletDynamics/Dynamics/btRigidBody.h" #include "BulletDynamics/Dynamics/btMassProps.h" -#include "LinearMath/SimdTransformUtil.h" +#include "LinearMath/btTransformUtil.h" -HingeConstraint::HingeConstraint() +btHingeConstraint::btHingeConstraint() { } -HingeConstraint::HingeConstraint(RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB, - SimdVector3& axisInA,SimdVector3& axisInB) -:TypedConstraint(rbA,rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB), +btHingeConstraint::btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB, + btVector3& axisInA,btVector3& axisInB) +:btTypedConstraint(rbA,rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB), m_axisInA(axisInA), m_axisInB(-axisInB), m_angularOnly(false) @@ -35,8 +35,8 @@ m_angularOnly(false) } -HingeConstraint::HingeConstraint(RigidBody& rbA,const SimdVector3& pivotInA,SimdVector3& axisInA) -:TypedConstraint(rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA)), +btHingeConstraint::btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA) +:btTypedConstraint(rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA)), m_axisInA(axisInA), //fixed axis in worldspace m_axisInB(rbA.getCenterOfMassTransform().getBasis() * -axisInA), @@ -45,18 +45,18 @@ m_angularOnly(false) } -void HingeConstraint::BuildJacobian() +void btHingeConstraint::BuildJacobian() { m_appliedImpulse = 0.f; - SimdVector3 normal(0,0,0); + btVector3 normal(0,0,0); if (!m_angularOnly) { for (int i=0;i<3;i++) { normal[i] = 1; - new (&m_jac[i]) JacobianEntry( + new (&m_jac[i]) btJacobianEntry( m_rbA.getCenterOfMassTransform().getBasis().transpose(), m_rbB.getCenterOfMassTransform().getBasis().transpose(), m_rbA.getCenterOfMassTransform()*m_pivotInA - m_rbA.getCenterOfMassPosition(), @@ -74,18 +74,18 @@ void HingeConstraint::BuildJacobian() //these two jointAxis require equal angular velocities for both bodies //this is unused for now, it's a todo - SimdVector3 axisWorldA = GetRigidBodyA().getCenterOfMassTransform().getBasis() * m_axisInA; - SimdVector3 jointAxis0; - SimdVector3 jointAxis1; - SimdPlaneSpace1(axisWorldA,jointAxis0,jointAxis1); + btVector3 axisWorldA = GetRigidBodyA().getCenterOfMassTransform().getBasis() * m_axisInA; + btVector3 jointAxis0; + btVector3 jointAxis1; + btPlaneSpace1(axisWorldA,jointAxis0,jointAxis1); - new (&m_jacAng[0]) JacobianEntry(jointAxis0, + new (&m_jacAng[0]) btJacobianEntry(jointAxis0, m_rbA.getCenterOfMassTransform().getBasis().transpose(), m_rbB.getCenterOfMassTransform().getBasis().transpose(), m_rbA.getInvInertiaDiagLocal(), m_rbB.getInvInertiaDiagLocal()); - new (&m_jacAng[1]) JacobianEntry(jointAxis1, + new (&m_jacAng[1]) btJacobianEntry(jointAxis1, m_rbA.getCenterOfMassTransform().getBasis().transpose(), m_rbB.getCenterOfMassTransform().getBasis().transpose(), m_rbA.getInvInertiaDiagLocal(), @@ -94,52 +94,52 @@ void HingeConstraint::BuildJacobian() } -void HingeConstraint::SolveConstraint(SimdScalar timeStep) +void btHingeConstraint::SolveConstraint(btScalar timeStep) { //#define NEW_IMPLEMENTATION #ifdef NEW_IMPLEMENTATION - SimdScalar tau = 0.3f; - SimdScalar damping = 1.f; + btScalar tau = 0.3f; + btScalar damping = 1.f; - SimdVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_pivotInA; - SimdVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_pivotInB; + btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_pivotInA; + btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_pivotInB; // Dirk: Don't we need to update this after each applied impulse - SimdVector3 angvelA; // = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); - SimdVector3 angvelB; // = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); + btVector3 angvelA; // = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); + btVector3 angvelB; // = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); if (!m_angularOnly) { - SimdVector3 normal(0,0,0); + btVector3 normal(0,0,0); for (int i=0;i<3;i++) { normal[i] = 1; - SimdScalar jacDiagABInv = 1.f / m_jac[i].getDiagonal(); + btScalar jacDiagABInv = 1.f / m_jac[i].getDiagonal(); - SimdVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); - SimdVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); + btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); + btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); - SimdVector3 vel1 = m_rbA.getVelocityInLocalPoint(rel_pos1); - SimdVector3 vel2 = m_rbB.getVelocityInLocalPoint(rel_pos2); - SimdVector3 vel = vel1 - vel2; + btVector3 vel1 = m_rbA.getVelocityInLocalPoint(rel_pos1); + btVector3 vel2 = m_rbB.getVelocityInLocalPoint(rel_pos2); + btVector3 vel = vel1 - vel2; // Dirk: Get new angular velocity since it changed after applying an impulse angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); //velocity error (first order error) - SimdScalar rel_vel = m_jac[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, + btScalar rel_vel = m_jac[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, m_rbB.getLinearVelocity(),angvelB); //positional error (zeroth order error) - SimdScalar depth = -(pivotAInW - pivotBInW).dot(normal); + btScalar depth = -(pivotAInW - pivotBInW).dot(normal); - SimdScalar impulse = tau*depth/timeStep * jacDiagABInv - damping * rel_vel * jacDiagABInv; + btScalar impulse = tau*depth/timeStep * jacDiagABInv - damping * rel_vel * jacDiagABInv; - SimdVector3 impulse_vector = normal * impulse; + btVector3 impulse_vector = normal * impulse; m_rbA.applyImpulse( impulse_vector, pivotAInW - m_rbA.getCenterOfMassPosition()); m_rbB.applyImpulse(-impulse_vector, pivotBInW - m_rbB.getCenterOfMassPosition()); @@ -150,26 +150,26 @@ void HingeConstraint::SolveConstraint(SimdScalar timeStep) ///solve angular part // get axes in world space - SimdVector3 axisA = GetRigidBodyA().getCenterOfMassTransform().getBasis() * m_axisInA; - SimdVector3 axisB = GetRigidBodyB().getCenterOfMassTransform().getBasis() * m_axisInB; + btVector3 axisA = GetRigidBodyA().getCenterOfMassTransform().getBasis() * m_axisInA; + btVector3 axisB = GetRigidBodyB().getCenterOfMassTransform().getBasis() * m_axisInB; // constraint axes in world space - SimdVector3 jointAxis0; - SimdVector3 jointAxis1; - SimdPlaneSpace1(axisA,jointAxis0,jointAxis1); + btVector3 jointAxis0; + btVector3 jointAxis1; + btPlaneSpace1(axisA,jointAxis0,jointAxis1); // Dirk: Get new angular velocity since it changed after applying an impulse angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); - SimdScalar jacDiagABInv0 = 1.f / m_jacAng[0].getDiagonal(); - SimdScalar rel_vel0 = m_jacAng[0].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, + btScalar jacDiagABInv0 = 1.f / m_jacAng[0].getDiagonal(); + btScalar rel_vel0 = m_jacAng[0].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, m_rbB.getLinearVelocity(),angvelB); float tau1 = tau;//0.f; - SimdScalar impulse0 = (tau1 * axisB.dot(jointAxis1) / timeStep - damping * rel_vel0) * jacDiagABInv0; - SimdVector3 angular_impulse0 = jointAxis0 * impulse0; + btScalar impulse0 = (tau1 * axisB.dot(jointAxis1) / timeStep - damping * rel_vel0) * jacDiagABInv0; + btVector3 angular_impulse0 = jointAxis0 * impulse0; m_rbA.applyTorqueImpulse( angular_impulse0); m_rbB.applyTorqueImpulse(-angular_impulse0); @@ -180,12 +180,12 @@ void HingeConstraint::SolveConstraint(SimdScalar timeStep) angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); - SimdScalar jacDiagABInv1 = 1.f / m_jacAng[1].getDiagonal(); - SimdScalar rel_vel1 = m_jacAng[1].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, + btScalar jacDiagABInv1 = 1.f / m_jacAng[1].getDiagonal(); + btScalar rel_vel1 = m_jacAng[1].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, m_rbB.getLinearVelocity(),angvelB);; - SimdScalar impulse1 = -(tau1 * axisB.dot(jointAxis0) / timeStep + damping * rel_vel1) * jacDiagABInv1; - SimdVector3 angular_impulse1 = jointAxis1 * impulse1; + btScalar impulse1 = -(tau1 * axisB.dot(jointAxis0) / timeStep + damping * rel_vel1) * jacDiagABInv1; + btVector3 angular_impulse1 = jointAxis1 * impulse1; m_rbA.applyTorqueImpulse( angular_impulse1); m_rbB.applyTorqueImpulse(-angular_impulse1); @@ -193,33 +193,33 @@ void HingeConstraint::SolveConstraint(SimdScalar timeStep) #else - SimdVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_pivotInA; - SimdVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_pivotInB; + btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_pivotInA; + btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_pivotInB; - SimdVector3 normal(0,0,0); - SimdScalar tau = 0.3f; - SimdScalar damping = 1.f; + btVector3 normal(0,0,0); + btScalar tau = 0.3f; + btScalar damping = 1.f; //linear part { for (int i=0;i<3;i++) { normal[i] = 1; - SimdScalar jacDiagABInv = 1.f / m_jac[i].getDiagonal(); + btScalar jacDiagABInv = 1.f / m_jac[i].getDiagonal(); - SimdVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); - SimdVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); + btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); + btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); - SimdVector3 vel1 = m_rbA.getVelocityInLocalPoint(rel_pos1); - SimdVector3 vel2 = m_rbB.getVelocityInLocalPoint(rel_pos2); - SimdVector3 vel = vel1 - vel2; - SimdScalar rel_vel; + btVector3 vel1 = m_rbA.getVelocityInLocalPoint(rel_pos1); + btVector3 vel2 = m_rbB.getVelocityInLocalPoint(rel_pos2); + btVector3 vel = vel1 - vel2; + btScalar rel_vel; rel_vel = normal.dot(vel); //positional error (zeroth order error) - SimdScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal - SimdScalar impulse = depth*tau/timeStep * jacDiagABInv - damping * rel_vel * jacDiagABInv * damping; + btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal + btScalar impulse = depth*tau/timeStep * jacDiagABInv - damping * rel_vel * jacDiagABInv * damping; m_appliedImpulse += impulse; - SimdVector3 impulse_vector = normal * impulse; + btVector3 impulse_vector = normal * impulse; m_rbA.applyImpulse(impulse_vector, pivotAInW - m_rbA.getCenterOfMassPosition()); m_rbB.applyImpulse(-impulse_vector, pivotBInW - m_rbB.getCenterOfMassPosition()); @@ -230,21 +230,21 @@ void HingeConstraint::SolveConstraint(SimdScalar timeStep) ///solve angular part // get axes in world space - SimdVector3 axisA = GetRigidBodyA().getCenterOfMassTransform().getBasis() * m_axisInA; - SimdVector3 axisB = GetRigidBodyB().getCenterOfMassTransform().getBasis() * m_axisInB; + btVector3 axisA = GetRigidBodyA().getCenterOfMassTransform().getBasis() * m_axisInA; + btVector3 axisB = GetRigidBodyB().getCenterOfMassTransform().getBasis() * m_axisInB; - const SimdVector3& angVelA = GetRigidBodyA().getAngularVelocity(); - const SimdVector3& angVelB = GetRigidBodyB().getAngularVelocity(); - SimdVector3 angA = angVelA - axisA * axisA.dot(angVelA); - SimdVector3 angB = angVelB - axisB * axisB.dot(angVelB); - SimdVector3 velrel = angA-angB; + const btVector3& angVelA = GetRigidBodyA().getAngularVelocity(); + const btVector3& angVelB = GetRigidBodyB().getAngularVelocity(); + btVector3 angA = angVelA - axisA * axisA.dot(angVelA); + btVector3 angB = angVelB - axisB * axisB.dot(angVelB); + btVector3 velrel = angA-angB; //solve angular velocity correction float relaxation = 1.f; float len = velrel.length(); if (len > 0.00001f) { - SimdVector3 normal = velrel.normalized(); + btVector3 normal = velrel.normalized(); float denom = GetRigidBodyA().ComputeAngularImpulseDenominator(normal) + GetRigidBodyB().ComputeAngularImpulseDenominator(normal); // scale for mass and relaxation @@ -252,11 +252,11 @@ void HingeConstraint::SolveConstraint(SimdScalar timeStep) } //solve angular positional correction - SimdVector3 angularError = -axisA.cross(axisB) *(1.f/timeStep); + btVector3 angularError = -axisA.cross(axisB) *(1.f/timeStep); float len2 = angularError.length(); if (len2>0.00001f) { - SimdVector3 normal2 = angularError.normalized(); + btVector3 normal2 = angularError.normalized(); float denom2 = GetRigidBodyA().ComputeAngularImpulseDenominator(normal2) + GetRigidBodyB().ComputeAngularImpulseDenominator(normal2); angularError *= (1.f/denom2) * relaxation; @@ -269,7 +269,7 @@ void HingeConstraint::SolveConstraint(SimdScalar timeStep) } -void HingeConstraint::UpdateRHS(SimdScalar timeStep) +void btHingeConstraint::UpdateRHS(btScalar timeStep) { } diff --git a/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h b/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h index 8144cfd81..8b9dfae46 100644 --- a/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h +++ b/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h @@ -16,47 +16,47 @@ subject to the following restrictions: #ifndef HINGECONSTRAINT_H #define HINGECONSTRAINT_H -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" #include "BulletDynamics/ConstraintSolver/btJacobianEntry.h" #include "btTypedConstraint.h" -class RigidBody; +class btRigidBody; /// hinge constraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space /// axis defines the orientation of the hinge axis -class HingeConstraint : public TypedConstraint +class btHingeConstraint : public btTypedConstraint { - JacobianEntry m_jac[3]; //3 orthogonal linear constraints - JacobianEntry m_jacAng[2]; //2 orthogonal angular constraints + btJacobianEntry m_jac[3]; //3 orthogonal linear constraints + btJacobianEntry m_jacAng[2]; //2 orthogonal angular constraints - SimdVector3 m_pivotInA; - SimdVector3 m_pivotInB; - SimdVector3 m_axisInA; - SimdVector3 m_axisInB; + btVector3 m_pivotInA; + btVector3 m_pivotInB; + btVector3 m_axisInA; + btVector3 m_axisInB; bool m_angularOnly; public: - HingeConstraint(RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB,SimdVector3& axisInA,SimdVector3& axisInB); + btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB,btVector3& axisInA,btVector3& axisInB); - HingeConstraint(RigidBody& rbA,const SimdVector3& pivotInA,SimdVector3& axisInA); + btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA); - HingeConstraint(); + btHingeConstraint(); virtual void BuildJacobian(); - virtual void SolveConstraint(SimdScalar timeStep); + virtual void SolveConstraint(btScalar timeStep); - void UpdateRHS(SimdScalar timeStep); + void UpdateRHS(btScalar timeStep); - const RigidBody& GetRigidBodyA() const + const btRigidBody& GetRigidBodyA() const { return m_rbA; } - const RigidBody& GetRigidBodyB() const + const btRigidBody& GetRigidBodyB() const { return m_rbB; } diff --git a/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h b/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h index 55b87e62a..bb2aecfb6 100644 --- a/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h +++ b/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h @@ -16,32 +16,32 @@ subject to the following restrictions: #ifndef JACOBIAN_ENTRY_H #define JACOBIAN_ENTRY_H -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" #include "BulletDynamics/Dynamics/btRigidBody.h" //notes: // Another memory optimization would be to store m_1MinvJt in the remaining 3 w components -// which makes the JacobianEntry memory layout 16 bytes +// which makes the btJacobianEntry memory layout 16 bytes // if you only are interested in angular part, just feed massInvA and massInvB zero /// Jacobian entry is an abstraction that allows to describe constraints /// it can be used in combination with a constraint solver /// Can be used to relate the effect of an impulse to the constraint error -class JacobianEntry +class btJacobianEntry { public: - JacobianEntry() {}; + btJacobianEntry() {}; //constraint between two different rigidbodies - JacobianEntry( - const SimdMatrix3x3& world2A, - const SimdMatrix3x3& world2B, - const SimdVector3& rel_pos1,const SimdVector3& rel_pos2, - const SimdVector3& jointAxis, - const SimdVector3& inertiaInvA, - const SimdScalar massInvA, - const SimdVector3& inertiaInvB, - const SimdScalar massInvB) + btJacobianEntry( + const btMatrix3x3& world2A, + const btMatrix3x3& world2B, + const btVector3& rel_pos1,const btVector3& rel_pos2, + const btVector3& jointAxis, + const btVector3& inertiaInvA, + const btScalar massInvA, + const btVector3& inertiaInvB, + const btScalar massInvB) :m_linearJointAxis(jointAxis) { m_aJ = world2A*(rel_pos1.cross(m_linearJointAxis)); @@ -54,12 +54,12 @@ public: } //angular constraint between two different rigidbodies - JacobianEntry(const SimdVector3& jointAxis, - const SimdMatrix3x3& world2A, - const SimdMatrix3x3& world2B, - const SimdVector3& inertiaInvA, - const SimdVector3& inertiaInvB) - :m_linearJointAxis(SimdVector3(0.f,0.f,0.f)) + btJacobianEntry(const btVector3& jointAxis, + const btMatrix3x3& world2A, + const btMatrix3x3& world2B, + const btVector3& inertiaInvA, + const btVector3& inertiaInvB) + :m_linearJointAxis(btVector3(0.f,0.f,0.f)) { m_aJ= world2A*jointAxis; m_bJ = world2B*-jointAxis; @@ -71,11 +71,11 @@ public: } //angular constraint between two different rigidbodies - JacobianEntry(const SimdVector3& axisInA, - const SimdVector3& axisInB, - const SimdVector3& inertiaInvA, - const SimdVector3& inertiaInvB) - : m_linearJointAxis(SimdVector3(0.f,0.f,0.f)) + btJacobianEntry(const btVector3& axisInA, + const btVector3& axisInB, + const btVector3& inertiaInvA, + const btVector3& inertiaInvB) + : m_linearJointAxis(btVector3(0.f,0.f,0.f)) , m_aJ(axisInA) , m_bJ(-axisInB) { @@ -87,69 +87,69 @@ public: } //constraint on one rigidbody - JacobianEntry( - const SimdMatrix3x3& world2A, - const SimdVector3& rel_pos1,const SimdVector3& rel_pos2, - const SimdVector3& jointAxis, - const SimdVector3& inertiaInvA, - const SimdScalar massInvA) + btJacobianEntry( + const btMatrix3x3& world2A, + const btVector3& rel_pos1,const btVector3& rel_pos2, + const btVector3& jointAxis, + const btVector3& inertiaInvA, + const btScalar massInvA) :m_linearJointAxis(jointAxis) { m_aJ= world2A*(rel_pos1.cross(jointAxis)); m_bJ = world2A*(rel_pos2.cross(-jointAxis)); m_0MinvJt = inertiaInvA * m_aJ; - m_1MinvJt = SimdVector3(0.f,0.f,0.f); + m_1MinvJt = btVector3(0.f,0.f,0.f); m_Adiag = massInvA + m_0MinvJt.dot(m_aJ); ASSERT(m_Adiag > 0.0f); } - SimdScalar getDiagonal() const { return m_Adiag; } + btScalar getDiagonal() const { return m_Adiag; } // for two constraints on the same rigidbody (for example vehicle friction) - SimdScalar getNonDiagonal(const JacobianEntry& jacB, const SimdScalar massInvA) const + btScalar getNonDiagonal(const btJacobianEntry& jacB, const btScalar massInvA) const { - const JacobianEntry& jacA = *this; - SimdScalar lin = massInvA * jacA.m_linearJointAxis.dot(jacB.m_linearJointAxis); - SimdScalar ang = jacA.m_0MinvJt.dot(jacB.m_aJ); + const btJacobianEntry& jacA = *this; + btScalar lin = massInvA * jacA.m_linearJointAxis.dot(jacB.m_linearJointAxis); + btScalar ang = jacA.m_0MinvJt.dot(jacB.m_aJ); return lin + ang; } // for two constraints on sharing two same rigidbodies (for example two contact points between two rigidbodies) - SimdScalar getNonDiagonal(const JacobianEntry& jacB,const SimdScalar massInvA,const SimdScalar massInvB) const + btScalar getNonDiagonal(const btJacobianEntry& jacB,const btScalar massInvA,const btScalar massInvB) const { - const JacobianEntry& jacA = *this; - SimdVector3 lin = jacA.m_linearJointAxis * jacB.m_linearJointAxis; - SimdVector3 ang0 = jacA.m_0MinvJt * jacB.m_aJ; - SimdVector3 ang1 = jacA.m_1MinvJt * jacB.m_bJ; - SimdVector3 lin0 = massInvA * lin ; - SimdVector3 lin1 = massInvB * lin; - SimdVector3 sum = ang0+ang1+lin0+lin1; + const btJacobianEntry& jacA = *this; + btVector3 lin = jacA.m_linearJointAxis * jacB.m_linearJointAxis; + btVector3 ang0 = jacA.m_0MinvJt * jacB.m_aJ; + btVector3 ang1 = jacA.m_1MinvJt * jacB.m_bJ; + btVector3 lin0 = massInvA * lin ; + btVector3 lin1 = massInvB * lin; + btVector3 sum = ang0+ang1+lin0+lin1; return sum[0]+sum[1]+sum[2]; } - SimdScalar getRelativeVelocity(const SimdVector3& linvelA,const SimdVector3& angvelA,const SimdVector3& linvelB,const SimdVector3& angvelB) + btScalar getRelativeVelocity(const btVector3& linvelA,const btVector3& angvelA,const btVector3& linvelB,const btVector3& angvelB) { - SimdVector3 linrel = linvelA - linvelB; - SimdVector3 angvela = angvelA * m_aJ; - SimdVector3 angvelb = angvelB * m_bJ; + btVector3 linrel = linvelA - linvelB; + btVector3 angvela = angvelA * m_aJ; + btVector3 angvelb = angvelB * m_bJ; linrel *= m_linearJointAxis; angvela += angvelb; angvela += linrel; - SimdScalar rel_vel2 = angvela[0]+angvela[1]+angvela[2]; + btScalar rel_vel2 = angvela[0]+angvela[1]+angvela[2]; return rel_vel2 + SIMD_EPSILON; } //private: - SimdVector3 m_linearJointAxis; - SimdVector3 m_aJ; - SimdVector3 m_bJ; - SimdVector3 m_0MinvJt; - SimdVector3 m_1MinvJt; + btVector3 m_linearJointAxis; + btVector3 m_aJ; + btVector3 m_bJ; + btVector3 m_0MinvJt; + btVector3 m_1MinvJt; //Optimization: can be stored in the w/last component of one of the vectors - SimdScalar m_Adiag; + btScalar m_Adiag; }; diff --git a/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp b/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp index 9dbfa32a4..4c436ad32 100644 --- a/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp +++ b/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp @@ -21,33 +21,33 @@ subject to the following restrictions: -Point2PointConstraint::Point2PointConstraint() +btPoint2PointConstraint::btPoint2PointConstraint() { } -Point2PointConstraint::Point2PointConstraint(RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB) -:TypedConstraint(rbA,rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB) +btPoint2PointConstraint::btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB) +:btTypedConstraint(rbA,rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB) { } -Point2PointConstraint::Point2PointConstraint(RigidBody& rbA,const SimdVector3& pivotInA) -:TypedConstraint(rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA)) +btPoint2PointConstraint::btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA) +:btTypedConstraint(rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA)) { } -void Point2PointConstraint::BuildJacobian() +void btPoint2PointConstraint::BuildJacobian() { m_appliedImpulse = 0.f; - SimdVector3 normal(0,0,0); + btVector3 normal(0,0,0); for (int i=0;i<3;i++) { normal[i] = 1; - new (&m_jac[i]) JacobianEntry( + new (&m_jac[i]) btJacobianEntry( m_rbA.getCenterOfMassTransform().getBasis().transpose(), m_rbB.getCenterOfMassTransform().getBasis().transpose(), m_rbA.getCenterOfMassTransform()*m_pivotInA - m_rbA.getCenterOfMassPosition(), @@ -62,46 +62,46 @@ void Point2PointConstraint::BuildJacobian() } -void Point2PointConstraint::SolveConstraint(SimdScalar timeStep) +void btPoint2PointConstraint::SolveConstraint(btScalar timeStep) { - SimdVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_pivotInA; - SimdVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_pivotInB; + btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_pivotInA; + btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_pivotInB; - SimdVector3 normal(0,0,0); + btVector3 normal(0,0,0); -// SimdVector3 angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); -// SimdVector3 angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); +// btVector3 angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); +// btVector3 angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); for (int i=0;i<3;i++) { normal[i] = 1; - SimdScalar jacDiagABInv = 1.f / m_jac[i].getDiagonal(); + btScalar jacDiagABInv = 1.f / m_jac[i].getDiagonal(); - SimdVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); - SimdVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); + btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); + btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); //this jacobian entry could be re-used for all iterations - SimdVector3 vel1 = m_rbA.getVelocityInLocalPoint(rel_pos1); - SimdVector3 vel2 = m_rbB.getVelocityInLocalPoint(rel_pos2); - SimdVector3 vel = vel1 - vel2; + btVector3 vel1 = m_rbA.getVelocityInLocalPoint(rel_pos1); + btVector3 vel2 = m_rbB.getVelocityInLocalPoint(rel_pos2); + btVector3 vel = vel1 - vel2; - SimdScalar rel_vel; + btScalar rel_vel; rel_vel = normal.dot(vel); /* //velocity error (first order error) - SimdScalar rel_vel = m_jac[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, + btScalar rel_vel = m_jac[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, m_rbB.getLinearVelocity(),angvelB); */ //positional error (zeroth order error) - SimdScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal + btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal - SimdScalar impulse = depth*m_setting.m_tau/timeStep * jacDiagABInv - m_setting.m_damping * rel_vel * jacDiagABInv; + btScalar impulse = depth*m_setting.m_tau/timeStep * jacDiagABInv - m_setting.m_damping * rel_vel * jacDiagABInv; m_appliedImpulse+=impulse; - SimdVector3 impulse_vector = normal * impulse; + btVector3 impulse_vector = normal * impulse; m_rbA.applyImpulse(impulse_vector, pivotAInW - m_rbA.getCenterOfMassPosition()); m_rbB.applyImpulse(-impulse_vector, pivotBInW - m_rbB.getCenterOfMassPosition()); @@ -109,7 +109,7 @@ void Point2PointConstraint::SolveConstraint(SimdScalar timeStep) } } -void Point2PointConstraint::UpdateRHS(SimdScalar timeStep) +void btPoint2PointConstraint::UpdateRHS(btScalar timeStep) { } diff --git a/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h b/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h index af38c9792..eea32b01d 100644 --- a/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h +++ b/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h @@ -16,16 +16,16 @@ subject to the following restrictions: #ifndef POINT2POINTCONSTRAINT_H #define POINT2POINTCONSTRAINT_H -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" #include "BulletDynamics/ConstraintSolver/btJacobianEntry.h" #include "btTypedConstraint.h" -class RigidBody; +class btRigidBody; -struct ConstraintSetting +struct btConstraintSetting { - ConstraintSetting() : + btConstraintSetting() : m_tau(0.3f), m_damping(1.f) { @@ -35,38 +35,38 @@ struct ConstraintSetting }; /// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space -class Point2PointConstraint : public TypedConstraint +class btPoint2PointConstraint : public btTypedConstraint { - JacobianEntry m_jac[3]; //3 orthogonal linear constraints + btJacobianEntry m_jac[3]; //3 orthogonal linear constraints - SimdVector3 m_pivotInA; - SimdVector3 m_pivotInB; + btVector3 m_pivotInA; + btVector3 m_pivotInB; public: - ConstraintSetting m_setting; + btConstraintSetting m_setting; - Point2PointConstraint(RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB); + btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB); - Point2PointConstraint(RigidBody& rbA,const SimdVector3& pivotInA); + btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA); - Point2PointConstraint(); + btPoint2PointConstraint(); virtual void BuildJacobian(); - virtual void SolveConstraint(SimdScalar timeStep); + virtual void SolveConstraint(btScalar timeStep); - void UpdateRHS(SimdScalar timeStep); + void UpdateRHS(btScalar timeStep); - void SetPivotA(const SimdVector3& pivotA) + void SetPivotA(const btVector3& pivotA) { m_pivotInA = pivotA; } - void SetPivotB(const SimdVector3& pivotB) + void SetPivotB(const btVector3& pivotB) { m_pivotInB = pivotB; } diff --git a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp index 01a80fc79..763a3a3e9 100644 --- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp +++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp @@ -20,12 +20,12 @@ subject to the following restrictions: #include "btContactConstraint.h" #include "btSolve2LinearConstraint.h" #include "btContactSolverInfo.h" -#include "LinearMath/GenIDebugDraw.h" +#include "LinearMath/btIDebugDraw.h" #include "btJacobianEntry.h" -#include "LinearMath/GenMinMax.h" +#include "LinearMath/btMinMax.h" #ifdef USE_PROFILE -#include "LinearMath/GenQuickprof.h" +#include "LinearMath/btQuickprof.h" #endif //USE_PROFILE int totalCpd = 0; @@ -35,7 +35,7 @@ int gTotalContactPoints = 0; bool MyContactDestroyedCallback(void* userPersistentData) { assert (userPersistentData); - ConstraintPersistentData* cpd = (ConstraintPersistentData*)userPersistentData; + btConstraintPersistentData* cpd = (btConstraintPersistentData*)userPersistentData; delete cpd; totalCpd--; //printf("totalCpd = %i. DELETED Ptr %x\n",totalCpd,userPersistentData); @@ -43,7 +43,7 @@ bool MyContactDestroyedCallback(void* userPersistentData) } -SequentialImpulseConstraintSolver::SequentialImpulseConstraintSolver() +btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver() { gContactDestroyedCallback = &MyContactDestroyedCallback; @@ -58,15 +58,15 @@ SequentialImpulseConstraintSolver::SequentialImpulseConstraintSolver() } } -/// SequentialImpulseConstraintSolver Sequentially applies impulses -float SequentialImpulseConstraintSolver::SolveGroup(PersistentManifold** manifoldPtr, int numManifolds,const ContactSolverInfo& infoGlobal,IDebugDraw* debugDrawer) +/// btSequentialImpulseConstraintSolver Sequentially applies impulses +float btSequentialImpulseConstraintSolver::SolveGroup(btPersistentManifold** manifoldPtr, int numManifolds,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer) { - ContactSolverInfo info = infoGlobal; + btContactSolverInfo info = infoGlobal; int numiter = infoGlobal.m_numIterations; #ifdef USE_PROFILE - Profiler::beginBlock("Solve"); + btProfiler::beginBlock("Solve"); #endif //USE_PROFILE { @@ -98,9 +98,9 @@ float SequentialImpulseConstraintSolver::SolveGroup(PersistentManifold** manifol } #ifdef USE_PROFILE - Profiler::endBlock("Solve"); + btProfiler::endBlock("Solve"); - Profiler::beginBlock("SolveFriction"); + btProfiler::beginBlock("SolveFriction"); #endif //USE_PROFILE //now solve the friction @@ -116,7 +116,7 @@ float SequentialImpulseConstraintSolver::SolveGroup(PersistentManifold** manifol } } #ifdef USE_PROFILE - Profiler::endBlock("SolveFriction"); + btProfiler::endBlock("SolveFriction"); #endif //USE_PROFILE return 0.f; @@ -124,18 +124,18 @@ float SequentialImpulseConstraintSolver::SolveGroup(PersistentManifold** manifol float penetrationResolveFactor = 0.9f; -SimdScalar restitutionCurve(SimdScalar rel_vel, SimdScalar restitution) +btScalar restitutionCurve(btScalar rel_vel, btScalar restitution) { - SimdScalar rest = restitution * -rel_vel; + btScalar rest = restitution * -rel_vel; return rest; } -void SequentialImpulseConstraintSolver::PrepareConstraints(PersistentManifold* manifoldPtr, const ContactSolverInfo& info,IDebugDraw* debugDrawer) +void btSequentialImpulseConstraintSolver::PrepareConstraints(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,btIDebugDraw* debugDrawer) { - RigidBody* body0 = (RigidBody*)manifoldPtr->GetBody0(); - RigidBody* body1 = (RigidBody*)manifoldPtr->GetBody1(); + btRigidBody* body0 = (btRigidBody*)manifoldPtr->GetBody0(); + btRigidBody* body1 = (btRigidBody*)manifoldPtr->GetBody1(); //only necessary to refresh the manifold once (first iteration). The integration is done outside the loop @@ -146,29 +146,29 @@ void SequentialImpulseConstraintSolver::PrepareConstraints(PersistentManifold* m gTotalContactPoints += numpoints; - SimdVector3 color(0,1,0); + btVector3 color(0,1,0); for (int i=0;iGetContactPoint(i); + btManifoldPoint& cp = manifoldPtr->GetContactPoint(i); if (cp.GetDistance() <= 0.f) { - const SimdVector3& pos1 = cp.GetPositionWorldOnA(); - const SimdVector3& pos2 = cp.GetPositionWorldOnB(); + const btVector3& pos1 = cp.GetPositionWorldOnA(); + const btVector3& pos2 = cp.GetPositionWorldOnB(); - SimdVector3 rel_pos1 = pos1 - body0->getCenterOfMassPosition(); - SimdVector3 rel_pos2 = pos2 - body1->getCenterOfMassPosition(); + btVector3 rel_pos1 = pos1 - body0->getCenterOfMassPosition(); + btVector3 rel_pos2 = pos2 - body1->getCenterOfMassPosition(); //this jacobian entry is re-used for all iterations - JacobianEntry jac(body0->getCenterOfMassTransform().getBasis().transpose(), + btJacobianEntry jac(body0->getCenterOfMassTransform().getBasis().transpose(), body1->getCenterOfMassTransform().getBasis().transpose(), rel_pos1,rel_pos2,cp.m_normalWorldOnB,body0->getInvInertiaDiagLocal(),body0->getInvMass(), body1->getInvInertiaDiagLocal(),body1->getInvMass()); - SimdScalar jacDiagAB = jac.getDiagonal(); + btScalar jacDiagAB = jac.getDiagonal(); - ConstraintPersistentData* cpd = (ConstraintPersistentData*) cp.m_userPersistentData; + btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData; if (cpd) { //might be invalid @@ -176,7 +176,7 @@ void SequentialImpulseConstraintSolver::PrepareConstraints(PersistentManifold* m if (cpd->m_persistentLifeTime != cp.GetLifeTime()) { //printf("Invalid: cpd->m_persistentLifeTime = %i cp.GetLifeTime() = %i\n",cpd->m_persistentLifeTime,cp.GetLifeTime()); - new (cpd) ConstraintPersistentData; + new (cpd) btConstraintPersistentData; cpd->m_persistentLifeTime = cp.GetLifeTime(); } else @@ -187,7 +187,7 @@ void SequentialImpulseConstraintSolver::PrepareConstraints(PersistentManifold* m } else { - cpd = new ConstraintPersistentData(); + cpd = new btConstraintPersistentData(); totalCpd ++; //printf("totalCpd = %i Created Ptr %x\n",totalCpd,cpd); cp.m_userPersistentData = cpd; @@ -205,10 +205,10 @@ void SequentialImpulseConstraintSolver::PrepareConstraints(PersistentManifold* m cpd->m_frictionSolverFunc = m_frictionDispatch[body0->m_frictionSolverType][body1->m_frictionSolverType]; cpd->m_contactSolverFunc = m_contactDispatch[body0->m_contactSolverType][body1->m_contactSolverType]; - SimdVector3 vel1 = body0->getVelocityInLocalPoint(rel_pos1); - SimdVector3 vel2 = body1->getVelocityInLocalPoint(rel_pos2); - SimdVector3 vel = vel1 - vel2; - SimdScalar rel_vel; + btVector3 vel1 = body0->getVelocityInLocalPoint(rel_pos1); + btVector3 vel2 = body1->getVelocityInLocalPoint(rel_pos2); + btVector3 vel = vel1 - vel2; + btScalar rel_vel; rel_vel = cp.m_normalWorldOnB.dot(vel); float combinedRestitution = cp.m_combinedRestitution; @@ -225,7 +225,7 @@ void SequentialImpulseConstraintSolver::PrepareConstraints(PersistentManifold* m //restitution and penetration work in same direction so //rel_vel - SimdScalar penVel = -cpd->m_penetration/info.m_timeStep; + btScalar penVel = -cpd->m_penetration/info.m_timeStep; if (cpd->m_restitution >= penVel) { @@ -239,7 +239,7 @@ void SequentialImpulseConstraintSolver::PrepareConstraints(PersistentManifold* m cpd->m_prevAppliedImpulse = cpd->m_appliedImpulse; //re-calculate friction direction every frame, todo: check if this is really needed - SimdPlaneSpace1(cp.m_normalWorldOnB,cpd->m_frictionWorldTangential0,cpd->m_frictionWorldTangential1); + btPlaneSpace1(cp.m_normalWorldOnB,cpd->m_frictionWorldTangential0,cpd->m_frictionWorldTangential1); #define NO_FRICTION_WARMSTART 1 @@ -259,7 +259,7 @@ void SequentialImpulseConstraintSolver::PrepareConstraints(PersistentManifold* m denom = relaxation/(denom0+denom1); cpd->m_jacDiagABInvTangent1 = denom; - SimdVector3 totalImpulse = + btVector3 totalImpulse = #ifndef NO_FRICTION_WARMSTART cp.m_frictionWorldTangential0*cp.m_accumulatedTangentImpulse0+ cp.m_frictionWorldTangential1*cp.m_accumulatedTangentImpulse1+ @@ -275,18 +275,18 @@ void SequentialImpulseConstraintSolver::PrepareConstraints(PersistentManifold* m } } -float SequentialImpulseConstraintSolver::Solve(PersistentManifold* manifoldPtr, const ContactSolverInfo& info,int iter,IDebugDraw* debugDrawer) +float btSequentialImpulseConstraintSolver::Solve(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer) { - RigidBody* body0 = (RigidBody*)manifoldPtr->GetBody0(); - RigidBody* body1 = (RigidBody*)manifoldPtr->GetBody1(); + btRigidBody* body0 = (btRigidBody*)manifoldPtr->GetBody0(); + btRigidBody* body1 = (btRigidBody*)manifoldPtr->GetBody1(); float maxImpulse = 0.f; { const int numpoints = manifoldPtr->GetNumContacts(); - SimdVector3 color(0,1,0); + btVector3 color(0,1,0); for (int i=0;iGetContactPoint(j); + btManifoldPoint& cp = manifoldPtr->GetContactPoint(j); if (cp.GetDistance() <= 0.f) { @@ -308,7 +308,7 @@ float SequentialImpulseConstraintSolver::Solve(PersistentManifold* manifoldPtr, { - ConstraintPersistentData* cpd = (ConstraintPersistentData*) cp.m_userPersistentData; + btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData; float impulse = cpd->m_contactSolverFunc( *body0,*body1, cp, @@ -324,16 +324,16 @@ float SequentialImpulseConstraintSolver::Solve(PersistentManifold* manifoldPtr, return maxImpulse; } -float SequentialImpulseConstraintSolver::SolveFriction(PersistentManifold* manifoldPtr, const ContactSolverInfo& info,int iter,IDebugDraw* debugDrawer) +float btSequentialImpulseConstraintSolver::SolveFriction(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer) { - RigidBody* body0 = (RigidBody*)manifoldPtr->GetBody0(); - RigidBody* body1 = (RigidBody*)manifoldPtr->GetBody1(); + btRigidBody* body0 = (btRigidBody*)manifoldPtr->GetBody0(); + btRigidBody* body1 = (btRigidBody*)manifoldPtr->GetBody1(); { const int numpoints = manifoldPtr->GetNumContacts(); - SimdVector3 color(0,1,0); + btVector3 color(0,1,0); for (int i=0;iGetContactPoint(j); + btManifoldPoint& cp = manifoldPtr->GetContactPoint(j); if (cp.GetDistance() <= 0.f) { - ConstraintPersistentData* cpd = (ConstraintPersistentData*) cp.m_userPersistentData; + btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData; cpd->m_frictionSolverFunc( *body0,*body1, cp, diff --git a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h index df39ed351..9d630ff00 100644 --- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h +++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h @@ -17,46 +17,46 @@ subject to the following restrictions: #define SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H #include "btConstraintSolver.h" -class IDebugDraw; +class btIDebugDraw; #include "btContactConstraint.h" -/// SequentialImpulseConstraintSolver uses a Propagation Method and Sequentially applies impulses +/// btSequentialImpulseConstraintSolver uses a Propagation Method and Sequentially applies impulses /// The approach is the 3D version of Erin Catto's GDC 2006 tutorial. See http://www.gphysics.com /// Although Sequential Impulse is more intuitive, it is mathematically equivalent to Projected Successive Overrelaxation (iterative LCP) /// Applies impulses for combined restitution and penetration recovery and to simulate friction -class SequentialImpulseConstraintSolver : public ConstraintSolver +class btSequentialImpulseConstraintSolver : public btConstraintSolver { - float Solve(PersistentManifold* manifold, const ContactSolverInfo& info,int iter,IDebugDraw* debugDrawer); - float SolveFriction(PersistentManifold* manifoldPtr, const ContactSolverInfo& info,int iter,IDebugDraw* debugDrawer); - void PrepareConstraints(PersistentManifold* manifoldPtr, const ContactSolverInfo& info,IDebugDraw* debugDrawer); + float Solve(btPersistentManifold* manifold, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer); + float SolveFriction(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer); + void PrepareConstraints(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,btIDebugDraw* debugDrawer); ContactSolverFunc m_contactDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES]; ContactSolverFunc m_frictionDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES]; public: - SequentialImpulseConstraintSolver(); + btSequentialImpulseConstraintSolver(); ///Advanced: Override the default contact solving function for contacts, for certain types of rigidbody - ///See RigidBody::m_contactSolverType and RigidBody::m_frictionSolverType + ///See btRigidBody::m_contactSolverType and btRigidBody::m_frictionSolverType void SetContactSolverFunc(ContactSolverFunc func,int type0,int type1) { m_contactDispatch[type0][type1] = func; } ///Advanced: Override the default friction solving function for contacts, for certain types of rigidbody - ///See RigidBody::m_contactSolverType and RigidBody::m_frictionSolverType + ///See btRigidBody::m_contactSolverType and btRigidBody::m_frictionSolverType void SetFrictionSolverFunc(ContactSolverFunc func,int type0,int type1) { m_frictionDispatch[type0][type1] = func; } - virtual ~SequentialImpulseConstraintSolver() {} + virtual ~btSequentialImpulseConstraintSolver() {} - virtual float SolveGroup(PersistentManifold** manifold,int numManifolds,const ContactSolverInfo& info, IDebugDraw* debugDrawer=0); + virtual float SolveGroup(btPersistentManifold** manifold,int numManifolds,const btContactSolverInfo& info, btIDebugDraw* debugDrawer=0); }; diff --git a/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp b/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp index 788fdfca8..bf92434b6 100644 --- a/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp +++ b/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp @@ -18,36 +18,36 @@ subject to the following restrictions: #include "btSolve2LinearConstraint.h" #include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" #include "btJacobianEntry.h" -void Solve2LinearConstraint::resolveUnilateralPairConstraint( - RigidBody* body1, - RigidBody* body2, +void btSolve2LinearConstraint::resolveUnilateralPairConstraint( + btRigidBody* body1, + btRigidBody* body2, - const SimdMatrix3x3& world2A, - const SimdMatrix3x3& world2B, + const btMatrix3x3& world2A, + const btMatrix3x3& world2B, - const SimdVector3& invInertiaADiag, - const SimdScalar invMassA, - const SimdVector3& linvelA,const SimdVector3& angvelA, - const SimdVector3& rel_posA1, - const SimdVector3& invInertiaBDiag, - const SimdScalar invMassB, - const SimdVector3& linvelB,const SimdVector3& angvelB, - const SimdVector3& rel_posA2, + const btVector3& invInertiaADiag, + const btScalar invMassA, + const btVector3& linvelA,const btVector3& angvelA, + const btVector3& rel_posA1, + const btVector3& invInertiaBDiag, + const btScalar invMassB, + const btVector3& linvelB,const btVector3& angvelB, + const btVector3& rel_posA2, - SimdScalar depthA, const SimdVector3& normalA, - const SimdVector3& rel_posB1,const SimdVector3& rel_posB2, - SimdScalar depthB, const SimdVector3& normalB, - SimdScalar& imp0,SimdScalar& imp1) + btScalar depthA, const btVector3& normalA, + const btVector3& rel_posB1,const btVector3& rel_posB2, + btScalar depthB, const btVector3& normalB, + btScalar& imp0,btScalar& imp1) { imp0 = 0.f; imp1 = 0.f; - SimdScalar len = fabs(normalA.length())-1.f; + btScalar len = fabs(normalA.length())-1.f; if (fabs(len) >= SIMD_EPSILON) return; @@ -55,24 +55,24 @@ void Solve2LinearConstraint::resolveUnilateralPairConstraint( //this jacobian entry could be re-used for all iterations - JacobianEntry jacA(world2A,world2B,rel_posA1,rel_posA2,normalA,invInertiaADiag,invMassA, + btJacobianEntry jacA(world2A,world2B,rel_posA1,rel_posA2,normalA,invInertiaADiag,invMassA, invInertiaBDiag,invMassB); - JacobianEntry jacB(world2A,world2B,rel_posB1,rel_posB2,normalB,invInertiaADiag,invMassA, + btJacobianEntry jacB(world2A,world2B,rel_posB1,rel_posB2,normalB,invInertiaADiag,invMassA, invInertiaBDiag,invMassB); - //const SimdScalar vel0 = jacA.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); - //const SimdScalar vel1 = jacB.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); + //const btScalar vel0 = jacA.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); + //const btScalar vel1 = jacB.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); - const SimdScalar vel0 = normalA.dot(body1->getVelocityInLocalPoint(rel_posA1)-body2->getVelocityInLocalPoint(rel_posA1)); - const SimdScalar vel1 = normalB.dot(body1->getVelocityInLocalPoint(rel_posB1)-body2->getVelocityInLocalPoint(rel_posB1)); + const btScalar vel0 = normalA.dot(body1->getVelocityInLocalPoint(rel_posA1)-body2->getVelocityInLocalPoint(rel_posA1)); + const btScalar vel1 = normalB.dot(body1->getVelocityInLocalPoint(rel_posB1)-body2->getVelocityInLocalPoint(rel_posB1)); -// SimdScalar penetrationImpulse = (depth*contactTau*timeCorrection) * massTerm;//jacDiagABInv - SimdScalar massTerm = 1.f / (invMassA + invMassB); +// btScalar penetrationImpulse = (depth*contactTau*timeCorrection) * massTerm;//jacDiagABInv + btScalar massTerm = 1.f / (invMassA + invMassB); // calculate rhs (or error) terms - const SimdScalar dv0 = depthA * m_tau * massTerm - vel0 * m_damping; - const SimdScalar dv1 = depthB * m_tau * massTerm - vel1 * m_damping; + const btScalar dv0 = depthA * m_tau * massTerm - vel0 * m_damping; + const btScalar dv1 = depthB * m_tau * massTerm - vel1 * m_damping; // dC/dv * dv = -C @@ -86,8 +86,8 @@ void Solve2LinearConstraint::resolveUnilateralPairConstraint( // - SimdScalar nonDiag = jacA.getNonDiagonal(jacB,invMassA,invMassB); - SimdScalar invDet = 1.0f / (jacA.getDiagonal() * jacB.getDiagonal() - nonDiag * nonDiag ); + btScalar nonDiag = jacA.getNonDiagonal(jacB,invMassA,invMassB); + btScalar invDet = 1.0f / (jacA.getDiagonal() * jacB.getDiagonal() - nonDiag * nonDiag ); //imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet; //imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet; @@ -105,31 +105,31 @@ void Solve2LinearConstraint::resolveUnilateralPairConstraint( -void Solve2LinearConstraint::resolveBilateralPairConstraint( - RigidBody* body1, - RigidBody* body2, - const SimdMatrix3x3& world2A, - const SimdMatrix3x3& world2B, +void btSolve2LinearConstraint::resolveBilateralPairConstraint( + btRigidBody* body1, + btRigidBody* body2, + const btMatrix3x3& world2A, + const btMatrix3x3& world2B, - const SimdVector3& invInertiaADiag, - const SimdScalar invMassA, - const SimdVector3& linvelA,const SimdVector3& angvelA, - const SimdVector3& rel_posA1, - const SimdVector3& invInertiaBDiag, - const SimdScalar invMassB, - const SimdVector3& linvelB,const SimdVector3& angvelB, - const SimdVector3& rel_posA2, + const btVector3& invInertiaADiag, + const btScalar invMassA, + const btVector3& linvelA,const btVector3& angvelA, + const btVector3& rel_posA1, + const btVector3& invInertiaBDiag, + const btScalar invMassB, + const btVector3& linvelB,const btVector3& angvelB, + const btVector3& rel_posA2, - SimdScalar depthA, const SimdVector3& normalA, - const SimdVector3& rel_posB1,const SimdVector3& rel_posB2, - SimdScalar depthB, const SimdVector3& normalB, - SimdScalar& imp0,SimdScalar& imp1) + btScalar depthA, const btVector3& normalA, + const btVector3& rel_posB1,const btVector3& rel_posB2, + btScalar depthB, const btVector3& normalB, + btScalar& imp0,btScalar& imp1) { imp0 = 0.f; imp1 = 0.f; - SimdScalar len = fabs(normalA.length())-1.f; + btScalar len = fabs(normalA.length())-1.f; if (fabs(len) >= SIMD_EPSILON) return; @@ -137,20 +137,20 @@ void Solve2LinearConstraint::resolveBilateralPairConstraint( //this jacobian entry could be re-used for all iterations - JacobianEntry jacA(world2A,world2B,rel_posA1,rel_posA2,normalA,invInertiaADiag,invMassA, + btJacobianEntry jacA(world2A,world2B,rel_posA1,rel_posA2,normalA,invInertiaADiag,invMassA, invInertiaBDiag,invMassB); - JacobianEntry jacB(world2A,world2B,rel_posB1,rel_posB2,normalB,invInertiaADiag,invMassA, + btJacobianEntry jacB(world2A,world2B,rel_posB1,rel_posB2,normalB,invInertiaADiag,invMassA, invInertiaBDiag,invMassB); - //const SimdScalar vel0 = jacA.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); - //const SimdScalar vel1 = jacB.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); + //const btScalar vel0 = jacA.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); + //const btScalar vel1 = jacB.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); - const SimdScalar vel0 = normalA.dot(body1->getVelocityInLocalPoint(rel_posA1)-body2->getVelocityInLocalPoint(rel_posA1)); - const SimdScalar vel1 = normalB.dot(body1->getVelocityInLocalPoint(rel_posB1)-body2->getVelocityInLocalPoint(rel_posB1)); + const btScalar vel0 = normalA.dot(body1->getVelocityInLocalPoint(rel_posA1)-body2->getVelocityInLocalPoint(rel_posA1)); + const btScalar vel1 = normalB.dot(body1->getVelocityInLocalPoint(rel_posB1)-body2->getVelocityInLocalPoint(rel_posB1)); // calculate rhs (or error) terms - const SimdScalar dv0 = depthA * m_tau - vel0 * m_damping; - const SimdScalar dv1 = depthB * m_tau - vel1 * m_damping; + const btScalar dv0 = depthA * m_tau - vel0 * m_damping; + const btScalar dv1 = depthB * m_tau - vel1 * m_damping; // dC/dv * dv = -C @@ -163,8 +163,8 @@ void Solve2LinearConstraint::resolveBilateralPairConstraint( // - SimdScalar nonDiag = jacA.getNonDiagonal(jacB,invMassA,invMassB); - SimdScalar invDet = 1.0f / (jacA.getDiagonal() * jacB.getDiagonal() - nonDiag * nonDiag ); + btScalar nonDiag = jacA.getNonDiagonal(jacB,invMassA,invMassB); + btScalar invDet = 1.0f / (jacA.getDiagonal() * jacB.getDiagonal() - nonDiag * nonDiag ); //imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet; //imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet; @@ -222,19 +222,19 @@ void Solve2LinearConstraint::resolveBilateralPairConstraint( -void Solve2LinearConstraint::resolveAngularConstraint( const SimdMatrix3x3& invInertiaAWS, - const SimdScalar invMassA, - const SimdVector3& linvelA,const SimdVector3& angvelA, - const SimdVector3& rel_posA1, - const SimdMatrix3x3& invInertiaBWS, - const SimdScalar invMassB, - const SimdVector3& linvelB,const SimdVector3& angvelB, - const SimdVector3& rel_posA2, +void btSolve2LinearConstraint::resolveAngularConstraint( const btMatrix3x3& invInertiaAWS, + const btScalar invMassA, + const btVector3& linvelA,const btVector3& angvelA, + const btVector3& rel_posA1, + const btMatrix3x3& invInertiaBWS, + const btScalar invMassB, + const btVector3& linvelB,const btVector3& angvelB, + const btVector3& rel_posA2, - SimdScalar depthA, const SimdVector3& normalA, - const SimdVector3& rel_posB1,const SimdVector3& rel_posB2, - SimdScalar depthB, const SimdVector3& normalB, - SimdScalar& imp0,SimdScalar& imp1) + btScalar depthA, const btVector3& normalA, + const btVector3& rel_posB1,const btVector3& rel_posB2, + btScalar depthB, const btVector3& normalB, + btScalar& imp0,btScalar& imp1) { } diff --git a/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h b/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h index 2ca9b08bd..639e4c943 100644 --- a/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h +++ b/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h @@ -16,23 +16,23 @@ subject to the following restrictions: #ifndef SOLVE_2LINEAR_CONSTRAINT_H #define SOLVE_2LINEAR_CONSTRAINT_H -#include "LinearMath/SimdMatrix3x3.h" -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btMatrix3x3.h" +#include "LinearMath/btVector3.h" -class RigidBody; +class btRigidBody; /// constraint class used for lateral tyre friction. -class Solve2LinearConstraint +class btSolve2LinearConstraint { - SimdScalar m_tau; - SimdScalar m_damping; + btScalar m_tau; + btScalar m_damping; public: - Solve2LinearConstraint(SimdScalar tau,SimdScalar damping) + btSolve2LinearConstraint(btScalar tau,btScalar damping) { m_tau = tau; m_damping = damping; @@ -41,64 +41,64 @@ public: // solve unilateral constraint (equality, direct method) // void resolveUnilateralPairConstraint( - RigidBody* body0, - RigidBody* body1, + btRigidBody* body0, + btRigidBody* body1, - const SimdMatrix3x3& world2A, - const SimdMatrix3x3& world2B, + const btMatrix3x3& world2A, + const btMatrix3x3& world2B, - const SimdVector3& invInertiaADiag, - const SimdScalar invMassA, - const SimdVector3& linvelA,const SimdVector3& angvelA, - const SimdVector3& rel_posA1, - const SimdVector3& invInertiaBDiag, - const SimdScalar invMassB, - const SimdVector3& linvelB,const SimdVector3& angvelB, - const SimdVector3& rel_posA2, + const btVector3& invInertiaADiag, + const btScalar invMassA, + const btVector3& linvelA,const btVector3& angvelA, + const btVector3& rel_posA1, + const btVector3& invInertiaBDiag, + const btScalar invMassB, + const btVector3& linvelB,const btVector3& angvelB, + const btVector3& rel_posA2, - SimdScalar depthA, const SimdVector3& normalA, - const SimdVector3& rel_posB1,const SimdVector3& rel_posB2, - SimdScalar depthB, const SimdVector3& normalB, - SimdScalar& imp0,SimdScalar& imp1); + btScalar depthA, const btVector3& normalA, + const btVector3& rel_posB1,const btVector3& rel_posB2, + btScalar depthB, const btVector3& normalB, + btScalar& imp0,btScalar& imp1); // // solving 2x2 lcp problem (inequality, direct solution ) // void resolveBilateralPairConstraint( - RigidBody* body0, - RigidBody* body1, - const SimdMatrix3x3& world2A, - const SimdMatrix3x3& world2B, + btRigidBody* body0, + btRigidBody* body1, + const btMatrix3x3& world2A, + const btMatrix3x3& world2B, - const SimdVector3& invInertiaADiag, - const SimdScalar invMassA, - const SimdVector3& linvelA,const SimdVector3& angvelA, - const SimdVector3& rel_posA1, - const SimdVector3& invInertiaBDiag, - const SimdScalar invMassB, - const SimdVector3& linvelB,const SimdVector3& angvelB, - const SimdVector3& rel_posA2, + const btVector3& invInertiaADiag, + const btScalar invMassA, + const btVector3& linvelA,const btVector3& angvelA, + const btVector3& rel_posA1, + const btVector3& invInertiaBDiag, + const btScalar invMassB, + const btVector3& linvelB,const btVector3& angvelB, + const btVector3& rel_posA2, - SimdScalar depthA, const SimdVector3& normalA, - const SimdVector3& rel_posB1,const SimdVector3& rel_posB2, - SimdScalar depthB, const SimdVector3& normalB, - SimdScalar& imp0,SimdScalar& imp1); + btScalar depthA, const btVector3& normalA, + const btVector3& rel_posB1,const btVector3& rel_posB2, + btScalar depthB, const btVector3& normalB, + btScalar& imp0,btScalar& imp1); - void resolveAngularConstraint( const SimdMatrix3x3& invInertiaAWS, - const SimdScalar invMassA, - const SimdVector3& linvelA,const SimdVector3& angvelA, - const SimdVector3& rel_posA1, - const SimdMatrix3x3& invInertiaBWS, - const SimdScalar invMassB, - const SimdVector3& linvelB,const SimdVector3& angvelB, - const SimdVector3& rel_posA2, + void resolveAngularConstraint( const btMatrix3x3& invInertiaAWS, + const btScalar invMassA, + const btVector3& linvelA,const btVector3& angvelA, + const btVector3& rel_posA1, + const btMatrix3x3& invInertiaBWS, + const btScalar invMassB, + const btVector3& linvelB,const btVector3& angvelB, + const btVector3& rel_posA2, - SimdScalar depthA, const SimdVector3& normalA, - const SimdVector3& rel_posB1,const SimdVector3& rel_posB2, - SimdScalar depthB, const SimdVector3& normalB, - SimdScalar& imp0,SimdScalar& imp1); + btScalar depthA, const btVector3& normalA, + const btVector3& rel_posB1,const btVector3& rel_posB2, + btScalar depthB, const btVector3& normalB, + btScalar& imp0,btScalar& imp1); }; diff --git a/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp b/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp index 490a6f570..2a899dd06 100644 --- a/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp +++ b/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp @@ -18,37 +18,37 @@ subject to the following restrictions: #include "BulletDynamics/Dynamics/btRigidBody.h" #include "BulletDynamics/Dynamics/btMassProps.h" -static RigidBody s_fixed(MassProps(0,SimdVector3(0.f,0.f,0.f)),0.f,0.f,1.f,1.f); +static btRigidBody s_fixed(btMassProps(0,btVector3(0.f,0.f,0.f)),0.f,0.f,1.f,1.f); -TypedConstraint::TypedConstraint() +btTypedConstraint::btTypedConstraint() : m_userConstraintType(-1), m_userConstraintId(-1), m_rbA(s_fixed), m_rbB(s_fixed), m_appliedImpulse(0.f) { - s_fixed.setMassProps(0.f,SimdVector3(0.f,0.f,0.f)); + s_fixed.setMassProps(0.f,btVector3(0.f,0.f,0.f)); } -TypedConstraint::TypedConstraint(RigidBody& rbA) +btTypedConstraint::btTypedConstraint(btRigidBody& rbA) : m_userConstraintType(-1), m_userConstraintId(-1), m_rbA(rbA), m_rbB(s_fixed), m_appliedImpulse(0.f) { - s_fixed.setMassProps(0.f,SimdVector3(0.f,0.f,0.f)); + s_fixed.setMassProps(0.f,btVector3(0.f,0.f,0.f)); } -TypedConstraint::TypedConstraint(RigidBody& rbA,RigidBody& rbB) +btTypedConstraint::btTypedConstraint(btRigidBody& rbA,btRigidBody& rbB) : m_userConstraintType(-1), m_userConstraintId(-1), m_rbA(rbA), m_rbB(rbB), m_appliedImpulse(0.f) { - s_fixed.setMassProps(0.f,SimdVector3(0.f,0.f,0.f)); + s_fixed.setMassProps(0.f,btVector3(0.f,0.f,0.f)); } diff --git a/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h b/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h index 05ef88188..84fc4ae68 100644 --- a/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h +++ b/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h @@ -16,48 +16,48 @@ subject to the following restrictions: #ifndef TYPED_CONSTRAINT_H #define TYPED_CONSTRAINT_H -class RigidBody; -#include "LinearMath/SimdScalar.h" +class btRigidBody; +#include "LinearMath/btScalar.h" //TypedConstraint is the baseclass for Bullet constraints and vehicles -class TypedConstraint +class btTypedConstraint { int m_userConstraintType; int m_userConstraintId; protected: - RigidBody& m_rbA; - RigidBody& m_rbB; + btRigidBody& m_rbA; + btRigidBody& m_rbB; float m_appliedImpulse; public: - TypedConstraint(); - virtual ~TypedConstraint() {}; - TypedConstraint(RigidBody& rbA); + btTypedConstraint(); + virtual ~btTypedConstraint() {}; + btTypedConstraint(btRigidBody& rbA); - TypedConstraint(RigidBody& rbA,RigidBody& rbB); + btTypedConstraint(btRigidBody& rbA,btRigidBody& rbB); virtual void BuildJacobian() = 0; - virtual void SolveConstraint(SimdScalar timeStep) = 0; + virtual void SolveConstraint(btScalar timeStep) = 0; - const RigidBody& GetRigidBodyA() const + const btRigidBody& GetRigidBodyA() const { return m_rbA; } - const RigidBody& GetRigidBodyB() const + const btRigidBody& GetRigidBodyB() const { return m_rbB; } - RigidBody& GetRigidBodyA() + btRigidBody& GetRigidBodyA() { return m_rbA; } - RigidBody& GetRigidBodyB() + btRigidBody& GetRigidBodyB() { return m_rbB; } diff --git a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp index 310589e89..72ecfdc02 100644 --- a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp +++ b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp @@ -321,4 +321,328 @@ void btDiscreteDynamicsWorld::predictUnconstraintMotion(float timeStep) } } } -} \ No newline at end of file +}======= + +#include "btDiscreteDynamicsWorld.h" + +//collision detection +#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" +#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" +#include "BulletCollision/CollisionShapes/btCollisionShape.h" +#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" + +//rigidbody & constraints +#include "BulletDynamics/Dynamics/btRigidBody.h" +#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" +#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" +#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" + +//vehicle +#include "BulletDynamics/Vehicle/btRaycastVehicle.h" +#include "BulletDynamics/Vehicle/btVehicleRaycaster.h" +#include "BulletDynamics/Vehicle/btWheelInfo.h" + +#include + +btDiscreteDynamicsWorld::btDiscreteDynamicsWorld() +:btDynamicsWorld(new btCollisionDispatcher(),new btSimpleBroadphase()), +m_constraintSolver(new btSequentialImpulseConstraintSolver) +{ + m_islandManager = new btSimulationIslandManager(); +} + +btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver) +:btDynamicsWorld(dispatcher,pairCache), +m_constraintSolver(constraintSolver) +{ + m_islandManager = new btSimulationIslandManager(); +} + + +btDiscreteDynamicsWorld::~btDiscreteDynamicsWorld() +{ + delete m_islandManager ; + + delete m_constraintSolver; + + //delete the dispatcher and paircache + delete m_dispatcher1; + m_dispatcher1 = 0; + delete m_pairCache; + m_pairCache = 0; +} + +void btDiscreteDynamicsWorld::stepSimulation(float timeStep) +{ + ///update aabbs information + updateAabbs(); + + ///apply gravity, predict motion + predictUnconstraintMotion(timeStep); + + ///perform collision detection + PerformDiscreteCollisionDetection(); + + calculateSimulationIslands(); + + btContactSolverInfo infoGlobal; + infoGlobal.m_timeStep = timeStep; + + ///solve non-contact constraints + solveNoncontactConstraints(infoGlobal); + + ///solve contact constraints + solveContactConstraints(infoGlobal); + + ///update vehicle simulation + updateVehicles(timeStep); + + ///CallbackTriggers(); + + ///integrate transforms + integrateTransforms(timeStep); + + updateActivationState( timeStep ); + + + +} + +void btDiscreteDynamicsWorld::updateVehicles(float timeStep) +{ + for (int i=0;iUpdateVehicle( timeStep); + } +} + +void btDiscreteDynamicsWorld::updateActivationState(float timeStep) +{ + for (int i=0;im_internalOwner) + { + btRigidBody* body = (btRigidBody*)colObj->m_internalOwner; + + body->updateDeactivation(timeStep); + + if (body->wantsSleeping()) + { + if (body->GetActivationState() == ACTIVE_TAG) + body->SetActivationState( WANTS_DEACTIVATION ); + } else + { + if (body->GetActivationState() != DISABLE_DEACTIVATION) + body->SetActivationState( ACTIVE_TAG ); + } + } + } +} + +void btDiscreteDynamicsWorld::addConstraint(btTypedConstraint* constraint) +{ + m_constraints.push_back(constraint); +} + +void btDiscreteDynamicsWorld::removeConstraint(btTypedConstraint* constraint) +{ + std::vector::iterator cit = std::find(m_constraints.begin(),m_constraints.end(),constraint); + if (!(cit==m_constraints.end())) + { + m_constraints.erase(cit); + } +} + +void btDiscreteDynamicsWorld::addVehicle(btRaycastVehicle* vehicle) +{ + m_vehicles.push_back(vehicle); +} + +void btDiscreteDynamicsWorld::removeVehicle(btRaycastVehicle* vehicle) +{ + std::vector::iterator vit = std::find(m_vehicles.begin(),m_vehicles.end(),vehicle); + if (!(vit==m_vehicles.end())) + { + m_vehicles.erase(vit); + } +} + + +void btDiscreteDynamicsWorld::solveContactConstraints(btContactSolverInfo& solverInfo) +{ + + struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCallback + { + + btContactSolverInfo& m_solverInfo; + btConstraintSolver* m_solver; + btIDebugDraw* m_debugDrawer; + + InplaceSolverIslandCallback( + btContactSolverInfo& solverInfo, + btConstraintSolver* solver, + btIDebugDraw* debugDrawer) + :m_solverInfo(solverInfo), + m_solver(solver), + m_debugDrawer(debugDrawer) + { + + } + + virtual void ProcessIsland(btPersistentManifold** manifolds,int numManifolds) + { + m_solver->SolveGroup( manifolds, numManifolds,m_solverInfo,m_debugDrawer); + } + + }; + + btIDebugDraw* debugDraw = 0; + InplaceSolverIslandCallback solverCallback( solverInfo, m_constraintSolver, debugDraw); + + + /// solve all the contact points and contact friction + m_islandManager->BuildAndProcessIslands(GetCollisionWorld()->GetDispatcher(),GetCollisionWorld()->GetCollisionObjectArray(),&solverCallback); + + +} + + +void btDiscreteDynamicsWorld::solveNoncontactConstraints(btContactSolverInfo& solverInfo) +{ + #ifdef USE_QUICKPROF + Profiler::beginBlock("SolveConstraint"); +#endif //USE_QUICKPROF + + + + int i; + int numConstraints = m_constraints.size(); + + ///constraint preparation: building jacobians + for (i=0;i< numConstraints ; i++ ) + { + btTypedConstraint* constraint = m_constraints[i]; + constraint->BuildJacobian(); + } + + //solve the regular non-contact constraints (point 2 point, hinge, generic d6) + for (int g=0;gSolveConstraint( solverInfo.m_timeStep ); + } + } + +#ifdef USE_QUICKPROF + Profiler::endBlock("SolveConstraint"); +#endif //USE_QUICKPROF + +} + +void btDiscreteDynamicsWorld::calculateSimulationIslands() +{ + +#ifdef USE_QUICKPROF + Profiler::beginBlock("IslandUnionFind"); +#endif //USE_QUICKPROF + + GetSimulationIslandManager()->UpdateActivationState(GetCollisionWorld(),GetCollisionWorld()->GetDispatcher()); + + { + int i; + int numConstraints = m_constraints.size(); + for (i=0;i< numConstraints ; i++ ) + { + btTypedConstraint* constraint = m_constraints[i]; + + const btRigidBody* colObj0 = &constraint->GetRigidBodyA(); + const btRigidBody* colObj1 = &constraint->GetRigidBodyB(); + + if (((colObj0) && ((colObj0)->mergesSimulationIslands())) && + ((colObj1) && ((colObj1)->mergesSimulationIslands()))) + { + if (colObj0->IsActive() || colObj1->IsActive()) + { + + GetSimulationIslandManager()->GetUnionFind().unite((colObj0)->m_islandTag1, + (colObj1)->m_islandTag1); + } + } + } + } + + //Store the island id in each body + GetSimulationIslandManager()->StoreIslandActivationState(GetCollisionWorld()); + +#ifdef USE_QUICKPROF + Profiler::endBlock("IslandUnionFind"); +#endif //USE_QUICKPROF + +} + +void btDiscreteDynamicsWorld::updateAabbs() +{ + btTransform predictedTrans; + for (int i=0;im_internalOwner) + { + btRigidBody* body = (btRigidBody*)colObj->m_internalOwner; + if (body->IsActive() && (!body->IsStatic())) + { + btPoint3 minAabb,maxAabb; + colObj->m_collisionShape->GetAabb(colObj->m_worldTransform, minAabb,maxAabb); + btSimpleBroadphase* bp = (btSimpleBroadphase*)m_pairCache; + bp->SetAabb(body->m_broadphaseHandle,minAabb,maxAabb); + } + } + } +} + +void btDiscreteDynamicsWorld::integrateTransforms(float timeStep) +{ + btTransform predictedTrans; + for (int i=0;im_internalOwner) + { + btRigidBody* body = (btRigidBody*)colObj->m_internalOwner; + if (body->IsActive() && (!body->IsStatic())) + { + body->predictIntegratedTransform(timeStep, predictedTrans); + body->proceedToTransform( predictedTrans); + } + } + } +} + + + +void btDiscreteDynamicsWorld::predictUnconstraintMotion(float timeStep) +{ + for (int i=0;im_internalOwner) + { + btRigidBody* body = (btRigidBody*)colObj->m_internalOwner; + body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse(); + if (body->IsActive() && (!body->IsStatic())) + { + body->applyForces( timeStep); + body->integrateVelocities( timeStep); + body->predictIntegratedTransform(timeStep,body->m_interpolationWorldTransform); + + } + } + } +} diff --git a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h index e50a78f8c..194b75e40 100644 --- a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h +++ b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h @@ -94,4 +94,101 @@ public: }; -#endif //BT_DISCRETE_DYNAMICS_WORLD_H \ No newline at end of file +#endif //BT_DISCRETE_DYNAMICS_WORLD_H======= +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. 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. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_DISCRETE_DYNAMICS_WORLD_H +#define BT_DISCRETE_DYNAMICS_WORLD_H + +#include "btDynamicsWorld.h" + +class btDispatcher; +class btOverlappingPairCache; +class btConstraintSolver; +class btSimulationIslandManager; +class btTypedConstraint; +struct btContactSolverInfo; +class btRaycastVehicle; + +#include + +///btDiscreteDynamicsWorld provides discrete rigid body simulation +///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController +class btDiscreteDynamicsWorld : public btDynamicsWorld +{ +protected: + + btConstraintSolver* m_constraintSolver; + + btSimulationIslandManager* m_islandManager; + + std::vector m_constraints; + + std::vector m_vehicles; + + void predictUnconstraintMotion(float timeStep); + + void integrateTransforms(float timeStep); + + void updateAabbs(); + + void calculateSimulationIslands(); + + void solveNoncontactConstraints(btContactSolverInfo& solverInfo); + + void solveContactConstraints(btContactSolverInfo& solverInfo); + + void updateActivationState(float timeStep); + + void updateVehicles(float timeStep); + +public: + + + btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver); + + btDiscreteDynamicsWorld(); + + virtual ~btDiscreteDynamicsWorld(); + + virtual void stepSimulation( float timeStep); + + void addConstraint(btTypedConstraint* constraint); + + void removeConstraint(btTypedConstraint* constraint); + + void addVehicle(btRaycastVehicle* vehicle); + + void removeVehicle(btRaycastVehicle* vehicle); + + btSimulationIslandManager* GetSimulationIslandManager() + { + return m_islandManager; + } + + const btSimulationIslandManager* GetSimulationIslandManager() const + { + return m_islandManager; + } + + btCollisionWorld* GetCollisionWorld() + { + return this; + } + +}; + +#endif //BT_DISCRETE_DYNAMICS_WORLD_H diff --git a/src/BulletDynamics/Dynamics/btDynamicsWorld.h b/src/BulletDynamics/Dynamics/btDynamicsWorld.h index 7621b84f3..de7813fc4 100644 --- a/src/BulletDynamics/Dynamics/btDynamicsWorld.h +++ b/src/BulletDynamics/Dynamics/btDynamicsWorld.h @@ -1,3 +1,4 @@ +<<<<<<< .working /* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ @@ -43,4 +44,50 @@ class btDynamicsWorld : public CollisionWorld }; -#endif //BT_DYNAMICS_WORLD_H \ No newline at end of file +#endif //BT_DYNAMICS_WORLD_H======= +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. 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. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_DYNAMICS_WORLD_H +#define BT_DYNAMICS_WORLD_H + +#include "BulletCollision/CollisionDispatch/btCollisionWorld.h" +class btTypedConstraint; + +///btDynamicsWorld is the baseclass for several dynamics implementation, basic, discrete, parallel, and continuous +class btDynamicsWorld : public btCollisionWorld +{ + public: + + btDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache) + :btCollisionWorld(dispatcher,pairCache) + { + + } + virtual ~btDynamicsWorld() + { + } + + ///stepSimulation proceeds the simulation over timeStep units + virtual void stepSimulation( float timeStep) = 0; + + + virtual void addConstraint(btTypedConstraint* constraint) {}; + + virtual void removeConstraint(btTypedConstraint* constraint) {}; + +}; + +#endif //BT_DYNAMICS_WORLD_H>>>>>>> .merge-right.r324 diff --git a/src/BulletDynamics/Dynamics/btMassProps.h b/src/BulletDynamics/Dynamics/btMassProps.h index 93ecb4cf6..48c6e7ddb 100644 --- a/src/BulletDynamics/Dynamics/btMassProps.h +++ b/src/BulletDynamics/Dynamics/btMassProps.h @@ -16,16 +16,16 @@ subject to the following restrictions: #ifndef MASS_PROPS_H #define MASS_PROPS_H -#include +#include -struct MassProps { - MassProps(float mass,const SimdVector3& inertiaLocal): +struct btMassProps { + btMassProps(float mass,const btVector3& inertiaLocal): m_mass(mass), m_inertiaLocal(inertiaLocal) { } float m_mass; - SimdVector3 m_inertiaLocal; + btVector3 m_inertiaLocal; }; diff --git a/src/BulletDynamics/Dynamics/btRigidBody.cpp b/src/BulletDynamics/Dynamics/btRigidBody.cpp index 41abca406..d4d57534e 100644 --- a/src/BulletDynamics/Dynamics/btRigidBody.cpp +++ b/src/BulletDynamics/Dynamics/btRigidBody.cpp @@ -16,14 +16,14 @@ subject to the following restrictions: #include "btRigidBody.h" #include "btMassProps.h" #include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "LinearMath/GenMinMax.h" -#include +#include "LinearMath/btMinMax.h" +#include float gLinearAirDamping = 1.f; static int uniqueId = 0; -RigidBody::RigidBody( const MassProps& massProps,SimdScalar linearDamping,SimdScalar angularDamping,SimdScalar friction,SimdScalar restitution) +btRigidBody::btRigidBody( const btMassProps& massProps,btScalar linearDamping,btScalar angularDamping,btScalar friction,btScalar restitution) : m_gravity(0.0f, 0.0f, 0.0f), m_totalForce(0.0f, 0.0f, 0.0f), @@ -37,7 +37,7 @@ RigidBody::RigidBody( const MassProps& massProps,SimdScalar linearDamping,SimdSc m_frictionSolverType(0) { - //moved to CollisionObject + //moved to btCollisionObject m_friction = friction; m_restitution = restitution; @@ -51,25 +51,25 @@ RigidBody::RigidBody( const MassProps& massProps,SimdScalar linearDamping,SimdSc } -void RigidBody::setLinearVelocity(const SimdVector3& lin_vel) +void btRigidBody::setLinearVelocity(const btVector3& lin_vel) { m_linearVelocity = lin_vel; } -void RigidBody::predictIntegratedTransform(SimdScalar timeStep,SimdTransform& predictedTransform) const +void btRigidBody::predictIntegratedTransform(btScalar timeStep,btTransform& predictedTransform) const { - SimdTransformUtil::IntegrateTransform(m_worldTransform,m_linearVelocity,m_angularVelocity,timeStep,predictedTransform); + btTransformUtil::IntegrateTransform(m_worldTransform,m_linearVelocity,m_angularVelocity,timeStep,predictedTransform); } -void RigidBody::saveKinematicState(SimdScalar timeStep) +void btRigidBody::saveKinematicState(btScalar timeStep) { if (m_kinematicTimeStep) { - SimdVector3 linVel,angVel; - SimdTransformUtil::CalculateVelocity(m_interpolationWorldTransform,m_worldTransform,m_kinematicTimeStep,m_linearVelocity,m_angularVelocity); + btVector3 linVel,angVel; + btTransformUtil::CalculateVelocity(m_interpolationWorldTransform,m_worldTransform,m_kinematicTimeStep,m_linearVelocity,m_angularVelocity); //printf("angular = %f %f %f\n",m_angularVelocity.getX(),m_angularVelocity.getY(),m_angularVelocity.getZ()); } @@ -79,7 +79,7 @@ void RigidBody::saveKinematicState(SimdScalar timeStep) m_kinematicTimeStep = timeStep; } -void RigidBody::getAabb(SimdVector3& aabbMin,SimdVector3& aabbMax) const +void btRigidBody::getAabb(btVector3& aabbMin,btVector3& aabbMax) const { GetCollisionShape()->GetAabb(m_worldTransform,aabbMin,aabbMax); } @@ -87,7 +87,7 @@ void RigidBody::getAabb(SimdVector3& aabbMin,SimdVector3& aabbMax) const -void RigidBody::setGravity(const SimdVector3& acceleration) +void btRigidBody::setGravity(const btVector3& acceleration) { if (m_inverseMass != 0.0f) { @@ -100,7 +100,7 @@ void RigidBody::setGravity(const SimdVector3& acceleration) -void RigidBody::setDamping(SimdScalar lin_damping, SimdScalar ang_damping) +void btRigidBody::setDamping(btScalar lin_damping, btScalar ang_damping) { m_linearDamping = GEN_clamped(lin_damping, 0.0f, 1.0f); m_angularDamping = GEN_clamped(ang_damping, 0.0f, 1.0f); @@ -111,7 +111,7 @@ void RigidBody::setDamping(SimdScalar lin_damping, SimdScalar ang_damping) #include -void RigidBody::applyForces(SimdScalar step) +void btRigidBody::applyForces(btScalar step) { if (IsStatic()) return; @@ -130,7 +130,7 @@ void RigidBody::applyForces(SimdScalar step) float dampVel = 0.005f; if (speed > dampVel) { - SimdVector3 dir = m_linearVelocity.normalized(); + btVector3 dir = m_linearVelocity.normalized(); m_linearVelocity -= dir * dampVel; } else { @@ -144,7 +144,7 @@ void RigidBody::applyForces(SimdScalar step) float angDampVel = 0.005f; if (angSpeed > angDampVel) { - SimdVector3 dir = m_angularVelocity.normalized(); + btVector3 dir = m_angularVelocity.normalized(); m_angularVelocity -= dir * angDampVel; } else { @@ -155,17 +155,17 @@ void RigidBody::applyForces(SimdScalar step) } -void RigidBody::proceedToTransform(const SimdTransform& newTrans) +void btRigidBody::proceedToTransform(const btTransform& newTrans) { setCenterOfMassTransform( newTrans ); } -void RigidBody::setMassProps(SimdScalar mass, const SimdVector3& inertia) +void btRigidBody::setMassProps(btScalar mass, const btVector3& inertia) { if (mass == 0.f) { - m_collisionFlags = CollisionObject::isStatic; + m_collisionFlags = btCollisionObject::isStatic; m_inverseMass = 0.f; } else { @@ -182,13 +182,13 @@ void RigidBody::setMassProps(SimdScalar mass, const SimdVector3& inertia) -void RigidBody::updateInertiaTensor() +void btRigidBody::updateInertiaTensor() { m_invInertiaTensorWorld = m_worldTransform.getBasis().scaled(m_invInertiaLocal) * m_worldTransform.getBasis().transpose(); } -void RigidBody::integrateVelocities(SimdScalar step) +void btRigidBody::integrateVelocities(btScalar step) { if (IsStatic()) return; @@ -207,15 +207,15 @@ void RigidBody::integrateVelocities(SimdScalar step) clearForces(); } -SimdQuaternion RigidBody::getOrientation() const +btQuaternion btRigidBody::getOrientation() const { - SimdQuaternion orn; + btQuaternion orn; m_worldTransform.getBasis().getRotation(orn); return orn; } -void RigidBody::setCenterOfMassTransform(const SimdTransform& xform) +void btRigidBody::setCenterOfMassTransform(const btTransform& xform) { m_worldTransform = xform; updateInertiaTensor(); diff --git a/src/BulletDynamics/Dynamics/btRigidBody.h b/src/BulletDynamics/Dynamics/btRigidBody.h index a798e0941..88d1777b2 100644 --- a/src/BulletDynamics/Dynamics/btRigidBody.h +++ b/src/BulletDynamics/Dynamics/btRigidBody.h @@ -17,25 +17,29 @@ subject to the following restrictions: #define RIGIDBODY_H #include -#include -#include +#include +#include #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" #include "BulletCollision/CollisionDispatch/btCollisionObject.h" -class CollisionShape; -struct MassProps; -typedef SimdScalar dMatrix3[4*3]; +class btCollisionShape; +struct btMassProps; +typedef btScalar dMatrix3[4*3]; extern float gLinearAirDamping; extern bool gUseEpa; +extern float gDeactivationTime; +extern bool gDisableDeactivation; +extern float gLinearSleepingTreshold; +extern float gAngularSleepingTreshold; -/// RigidBody class for RigidBody Dynamics +/// btRigidBody class for btRigidBody Dynamics /// -class RigidBody : public CollisionObject +class btRigidBody : public btCollisionObject { SimdMatrix3x3 m_invInertiaTensorWorld; @@ -57,81 +61,81 @@ class RigidBody : public CollisionObject public: - RigidBody(const MassProps& massProps,SimdScalar linearDamping,SimdScalar angularDamping,SimdScalar friction,SimdScalar restitution); + btRigidBody(const btMassProps& massProps,btScalar linearDamping=0.f,btScalar angularDamping=0.f,btScalar friction=0.5f,btScalar restitution=0.f); - void proceedToTransform(const SimdTransform& newTrans); + void proceedToTransform(const btTransform& newTrans); /// continuous collision detection needs prediction - void predictIntegratedTransform(SimdScalar step, SimdTransform& predictedTransform) const; + void predictIntegratedTransform(btScalar step, btTransform& predictedTransform) const; - void saveKinematicState(SimdScalar step); + void saveKinematicState(btScalar step); - void applyForces(SimdScalar step); + void applyForces(btScalar step); - void setGravity(const SimdVector3& acceleration); + void setGravity(const btVector3& acceleration); - void setDamping(SimdScalar lin_damping, SimdScalar ang_damping); + void setDamping(btScalar lin_damping, btScalar ang_damping); - inline const CollisionShape* GetCollisionShape() const { + inline const btCollisionShape* GetCollisionShape() const { return m_collisionShape; } - inline CollisionShape* GetCollisionShape() { + inline btCollisionShape* GetCollisionShape() { return m_collisionShape; } - void setMassProps(SimdScalar mass, const SimdVector3& inertia); + void setMassProps(btScalar mass, const btVector3& inertia); - SimdScalar getInvMass() const { return m_inverseMass; } - const SimdMatrix3x3& getInvInertiaTensorWorld() const { + btScalar getInvMass() const { return m_inverseMass; } + const btMatrix3x3& getInvInertiaTensorWorld() const { return m_invInertiaTensorWorld; } - void integrateVelocities(SimdScalar step); + void integrateVelocities(btScalar step); - void setCenterOfMassTransform(const SimdTransform& xform); + void setCenterOfMassTransform(const btTransform& xform); - void applyCentralForce(const SimdVector3& force) + void applyCentralForce(const btVector3& force) { m_totalForce += force; } - const SimdVector3& getInvInertiaDiagLocal() + const btVector3& getInvInertiaDiagLocal() { return m_invInertiaLocal; }; - void setInvInertiaDiagLocal(const SimdVector3& diagInvInertia) + void setInvInertiaDiagLocal(const btVector3& diagInvInertia) { m_invInertiaLocal = diagInvInertia; } - void applyTorque(const SimdVector3& torque) + void applyTorque(const btVector3& torque) { m_totalTorque += torque; } - void applyForce(const SimdVector3& force, const SimdVector3& rel_pos) + void applyForce(const btVector3& force, const btVector3& rel_pos) { applyCentralForce(force); applyTorque(rel_pos.cross(force)); } - void applyCentralImpulse(const SimdVector3& impulse) + void applyCentralImpulse(const btVector3& impulse) { m_linearVelocity += impulse * m_inverseMass; } - void applyTorqueImpulse(const SimdVector3& torque) + void applyTorqueImpulse(const btVector3& torque) { if (!IsStatic()) m_angularVelocity += m_invInertiaTensorWorld * torque; } - void applyImpulse(const SimdVector3& impulse, const SimdVector3& rel_pos) + void applyImpulse(const btVector3& impulse, const btVector3& rel_pos) { if (m_inverseMass != 0.f) { @@ -148,31 +152,31 @@ public: void updateInertiaTensor(); - const SimdPoint3& getCenterOfMassPosition() const { + const btPoint3& getCenterOfMassPosition() const { return m_worldTransform.getOrigin(); } - SimdQuaternion getOrientation() const; + btQuaternion getOrientation() const; - const SimdTransform& getCenterOfMassTransform() const { + const btTransform& getCenterOfMassTransform() const { return m_worldTransform; } - const SimdVector3& getLinearVelocity() const { + const btVector3& getLinearVelocity() const { return m_linearVelocity; } - const SimdVector3& getAngularVelocity() const { + const btVector3& getAngularVelocity() const { return m_angularVelocity; } - void setLinearVelocity(const SimdVector3& lin_vel); - void setAngularVelocity(const SimdVector3& ang_vel) { + void setLinearVelocity(const btVector3& lin_vel); + void setAngularVelocity(const btVector3& ang_vel) { if (!IsStatic()) { m_angularVelocity = ang_vel; } } - SimdVector3 getVelocityInLocalPoint(const SimdVector3& rel_pos) const + btVector3 getVelocityInLocalPoint(const btVector3& rel_pos) const { //we also calculate lin/ang velocity for kinematic objects return m_linearVelocity + m_angularVelocity.cross(rel_pos); @@ -181,52 +185,84 @@ public: // return (m_worldTransform(rel_pos) - m_interpolationWorldTransform(rel_pos)) / m_kinematicTimeStep; } - void translate(const SimdVector3& v) + void translate(const btVector3& v) { m_worldTransform.getOrigin() += v; } - void getAabb(SimdVector3& aabbMin,SimdVector3& aabbMax) const; + void getAabb(btVector3& aabbMin,btVector3& aabbMax) const; - inline float ComputeImpulseDenominator(const SimdPoint3& pos, const SimdVector3& normal) const + inline float ComputeImpulseDenominator(const btPoint3& pos, const btVector3& normal) const { - SimdVector3 r0 = pos - getCenterOfMassPosition(); + btVector3 r0 = pos - getCenterOfMassPosition(); - SimdVector3 c0 = (r0).cross(normal); + btVector3 c0 = (r0).cross(normal); - SimdVector3 vec = (c0 * getInvInertiaTensorWorld()).cross(r0); + btVector3 vec = (c0 * getInvInertiaTensorWorld()).cross(r0); return m_inverseMass + normal.dot(vec); } - inline float ComputeAngularImpulseDenominator(const SimdVector3& axis) const + inline float ComputeAngularImpulseDenominator(const btVector3& axis) const { - SimdVector3 vec = axis * getInvInertiaTensorWorld(); + btVector3 vec = axis * getInvInertiaTensorWorld(); return axis.dot(vec); } + inline void updateDeactivation(float timeStep) + { + if ( (GetActivationState() == ISLAND_SLEEPING) || (GetActivationState() == DISABLE_DEACTIVATION)) + return; + if ((getLinearVelocity().length2() < gLinearSleepingTreshold*gLinearSleepingTreshold) && + (getAngularVelocity().length2() < gAngularSleepingTreshold*gAngularSleepingTreshold)) + { + m_deactivationTime += timeStep; + } else + { + m_deactivationTime=0.f; + SetActivationState(0); + } + + } + + inline bool wantsSleeping() + { + + if (GetActivationState() == DISABLE_DEACTIVATION) + return false; + + //disable deactivation + if (gDisableDeactivation || (gDeactivationTime == 0.f)) + return false; + + if ( (GetActivationState() == ISLAND_SLEEPING) || (GetActivationState() == WANTS_DEACTIVATION)) + return true; + + if (m_deactivationTime> gDeactivationTime) + { + return true; + } + return false; + } -private: - -public: - const BroadphaseProxy* GetBroadphaseProxy() const + const btBroadphaseProxy* GetBroadphaseProxy() const { return m_broadphaseProxy; } - BroadphaseProxy* GetBroadphaseProxy() + btBroadphaseProxy* GetBroadphaseProxy() { return m_broadphaseProxy; } - void SetBroadphaseProxy(BroadphaseProxy* broadphaseProxy) + void SetBroadphaseProxy(btBroadphaseProxy* broadphaseProxy) { m_broadphaseProxy = broadphaseProxy; } @@ -235,18 +271,6 @@ public: int m_contactSolverType; int m_frictionSolverType; -/* -//unused - /// for ode solver-binding - dMatrix3 m_R;//temp - dMatrix3 m_I; - dMatrix3 m_invI; - - int m_odeTag; - - SimdVector3 m_tacc;//temp - SimdVector3 m_facc; -*/ int m_debugBodyId; diff --git a/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp b/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp index b4ace618a..96e448c5e 100644 --- a/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp +++ b/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp @@ -117,4 +117,124 @@ void btSimpleDynamicsWorld::predictUnconstraintMotion(float timeStep) } } } -} \ No newline at end of file +}======= + +#include "btSimpleDynamicsWorld.h" +#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" +#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" +#include "BulletCollision/CollisionShapes/btCollisionShape.h" +#include "BulletDynamics/Dynamics/btRigidBody.h" +#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" +#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" + + +btSimpleDynamicsWorld::btSimpleDynamicsWorld() +:btDynamicsWorld(new btCollisionDispatcher(),new btSimpleBroadphase()), +m_constraintSolver(new btSequentialImpulseConstraintSolver) +{ + +} + +btSimpleDynamicsWorld::btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver) +:btDynamicsWorld(dispatcher,pairCache), +m_constraintSolver(constraintSolver) +{ + +} + + +btSimpleDynamicsWorld::~btSimpleDynamicsWorld() +{ + delete m_constraintSolver; + + //delete the dispatcher and paircache + delete m_dispatcher1; + m_dispatcher1 = 0; + delete m_pairCache; + m_pairCache = 0; +} + +void btSimpleDynamicsWorld::stepSimulation(float timeStep) +{ + ///apply gravity, predict motion + predictUnconstraintMotion(timeStep); + + ///perform collision detection + PerformDiscreteCollisionDetection(); + + ///solve contact constraints + btPersistentManifold** manifoldPtr = ((btCollisionDispatcher*)m_dispatcher1)->getInternalManifoldPointer(); + int numManifolds = m_dispatcher1->GetNumManifolds(); + btContactSolverInfo infoGlobal; + infoGlobal.m_timeStep = timeStep; + btIDebugDraw* debugDrawer=0; + m_constraintSolver->SolveGroup(manifoldPtr, numManifolds,infoGlobal,debugDrawer); + + ///integrate transforms + integrateTransforms(timeStep); + + updateAabbs(); + +} + + + +void btSimpleDynamicsWorld::updateAabbs() +{ + btTransform predictedTrans; + for (int i=0;im_internalOwner) + { + btRigidBody* body = (btRigidBody*)colObj->m_internalOwner; + if (body->IsActive() && (!body->IsStatic())) + { + btPoint3 minAabb,maxAabb; + colObj->m_collisionShape->GetAabb(colObj->m_worldTransform, minAabb,maxAabb); + btSimpleBroadphase* bp = (btSimpleBroadphase*)m_pairCache; + bp->SetAabb(body->m_broadphaseHandle,minAabb,maxAabb); + } + } + } +} + +void btSimpleDynamicsWorld::integrateTransforms(float timeStep) +{ + btTransform predictedTrans; + for (int i=0;im_internalOwner) + { + btRigidBody* body = (btRigidBody*)colObj->m_internalOwner; + if (body->IsActive() && (!body->IsStatic())) + { + body->predictIntegratedTransform(timeStep, predictedTrans); + body->proceedToTransform( predictedTrans); + } + } + } +} + + + +void btSimpleDynamicsWorld::predictUnconstraintMotion(float timeStep) +{ + for (int i=0;im_internalOwner) + { + btRigidBody* body = (btRigidBody*)colObj->m_internalOwner; + body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse(); + if (body->IsActive() && (!body->IsStatic())) + { + body->applyForces( timeStep); + body->integrateVelocities( timeStep); + body->predictIntegratedTransform(timeStep,body->m_interpolationWorldTransform); + + } + } + } +} diff --git a/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h b/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h index 07b58701d..c07e23e54 100644 --- a/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h +++ b/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h @@ -52,4 +52,59 @@ public: }; -#endif //BT_SIMPLE_DYNAMICS_WORLD_H \ No newline at end of file +#endif //BT_SIMPLE_DYNAMICS_WORLD_H======= +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. 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. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_SIMPLE_DYNAMICS_WORLD_H +#define BT_SIMPLE_DYNAMICS_WORLD_H + +#include "btDynamicsWorld.h" + +class btDispatcher; +class btOverlappingPairCache; +class btConstraintSolver; + +///btSimpleDynamicsWorld demonstrates very basic usage of Bullet rigid body dynamics +///It can be used for basic simulations, and as a starting point for porting Bullet +///btSimpleDynamicsWorld lacks object deactivation, island management and other concepts. +///For more complicated simulations, btDiscreteDynamicsWorld and btContinuousDynamicsWorld are recommended +///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController +class btSimpleDynamicsWorld : public btDynamicsWorld +{ +protected: + + btConstraintSolver* m_constraintSolver; + + void predictUnconstraintMotion(float timeStep); + + void integrateTransforms(float timeStep); + + void updateAabbs(); + +public: + + + btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver); + + btSimpleDynamicsWorld(); + + virtual ~btSimpleDynamicsWorld(); + + virtual void stepSimulation( float timeStep); + +}; + +#endif //BT_SIMPLE_DYNAMICS_WORLD_H diff --git a/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp b/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp index b062d4215..1ad55c663 100644 --- a/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp +++ b/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp @@ -12,8 +12,8 @@ #include "btRaycastVehicle.h" #include "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h" #include "BulletDynamics/ConstraintSolver/btJacobianEntry.h" -#include "LinearMath/SimdQuaternion.h" -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btQuaternion.h" +#include "LinearMath/btVector3.h" #include "btVehicleRaycaster.h" #include "btWheelInfo.h" @@ -23,9 +23,9 @@ -static RigidBody s_fixedObject( MassProps ( 0.0f, SimdVector3(0,0,0) ),0.f,0.f,0.f,0.f); +static btRigidBody s_fixedObject( btMassProps ( 0.0f, btVector3(0,0,0) ),0.f,0.f,0.f,0.f); -RaycastVehicle::RaycastVehicle(const VehicleTuning& tuning,RigidBody* chassis, VehicleRaycaster* raycaster ) +btRaycastVehicle::btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster ) :m_vehicleRaycaster(raycaster), m_pitchControl(0.f) { @@ -37,7 +37,7 @@ m_pitchControl(0.f) } -void RaycastVehicle::DefaultInit(const VehicleTuning& tuning) +void btRaycastVehicle::DefaultInit(const btVehicleTuning& tuning) { m_currentVehicleSpeedKmHour = 0.f; m_steeringValue = 0.f; @@ -46,7 +46,7 @@ void RaycastVehicle::DefaultInit(const VehicleTuning& tuning) -RaycastVehicle::~RaycastVehicle() +btRaycastVehicle::~btRaycastVehicle() { } @@ -54,10 +54,10 @@ RaycastVehicle::~RaycastVehicle() // // basically most of the code is general for 2 or 4 wheel vehicles, but some of it needs to be reviewed // -WheelInfo& RaycastVehicle::AddWheel( const SimdVector3& connectionPointCS, const SimdVector3& wheelDirectionCS0,const SimdVector3& wheelAxleCS, SimdScalar suspensionRestLength, SimdScalar wheelRadius,const VehicleTuning& tuning, bool isFrontWheel) +btWheelInfo& btRaycastVehicle::AddWheel( const btVector3& connectionPointCS, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS, btScalar suspensionRestLength, btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel) { - WheelInfoConstructionInfo ci; + btWheelInfoConstructionInfo ci; ci.m_chassisConnectionCS = connectionPointCS; ci.m_wheelDirectionCS = wheelDirectionCS0; @@ -71,9 +71,9 @@ WheelInfo& RaycastVehicle::AddWheel( const SimdVector3& connectionPointCS, const ci.m_bIsFrontWheel = isFrontWheel; ci.m_maxSuspensionTravelCm = tuning.m_maxSuspensionTravelCm; - m_wheelInfo.push_back( WheelInfo(ci)); + m_wheelInfo.push_back( btWheelInfo(ci)); - WheelInfo& wheel = m_wheelInfo[GetNumWheels()-1]; + btWheelInfo& wheel = m_wheelInfo[GetNumWheels()-1]; UpdateWheelTransformsWS( wheel ); UpdateWheelTransform(GetNumWheels()-1); @@ -83,33 +83,33 @@ WheelInfo& RaycastVehicle::AddWheel( const SimdVector3& connectionPointCS, const -const SimdTransform& RaycastVehicle::GetWheelTransformWS( int wheelIndex ) const +const btTransform& btRaycastVehicle::GetWheelTransformWS( int wheelIndex ) const { assert(wheelIndex < GetNumWheels()); - const WheelInfo& wheel = m_wheelInfo[wheelIndex]; + const btWheelInfo& wheel = m_wheelInfo[wheelIndex]; return wheel.m_worldTransform; } -void RaycastVehicle::UpdateWheelTransform( int wheelIndex ) +void btRaycastVehicle::UpdateWheelTransform( int wheelIndex ) { - WheelInfo& wheel = m_wheelInfo[ wheelIndex ]; + btWheelInfo& wheel = m_wheelInfo[ wheelIndex ]; UpdateWheelTransformsWS(wheel); - SimdVector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS; - const SimdVector3& right = wheel.m_raycastInfo.m_wheelAxleWS; - SimdVector3 fwd = up.cross(right); + btVector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS; + const btVector3& right = wheel.m_raycastInfo.m_wheelAxleWS; + btVector3 fwd = up.cross(right); fwd = fwd.normalize(); //rotate around steering over de wheelAxleWS float steering = wheel.m_steering; - SimdQuaternion steeringOrn(up,steering);//wheel.m_steering); - SimdMatrix3x3 steeringMat(steeringOrn); + btQuaternion steeringOrn(up,steering);//wheel.m_steering); + btMatrix3x3 steeringMat(steeringOrn); - SimdQuaternion rotatingOrn(right,wheel.m_rotation); - SimdMatrix3x3 rotatingMat(rotatingOrn); + btQuaternion rotatingOrn(right,wheel.m_rotation); + btMatrix3x3 rotatingMat(rotatingOrn); - SimdMatrix3x3 basis2( + btMatrix3x3 basis2( right[0],fwd[0],up[0], right[1],fwd[1],up[1], right[2],fwd[2],up[2] @@ -121,14 +121,14 @@ void RaycastVehicle::UpdateWheelTransform( int wheelIndex ) ); } -void RaycastVehicle::ResetSuspension() +void btRaycastVehicle::ResetSuspension() { - std::vector::iterator wheelIt; + std::vector::iterator wheelIt; for (wheelIt = m_wheelInfo.begin(); !(wheelIt == m_wheelInfo.end());wheelIt++) { - WheelInfo& wheel = *wheelIt; + btWheelInfo& wheel = *wheelIt; wheel.m_raycastInfo.m_suspensionLength = wheel.GetSuspensionRestLength(); wheel.m_suspensionRelativeVelocity = 0.0f; @@ -138,34 +138,34 @@ void RaycastVehicle::ResetSuspension() } } -void RaycastVehicle::UpdateWheelTransformsWS(WheelInfo& wheel ) +void btRaycastVehicle::UpdateWheelTransformsWS(btWheelInfo& wheel ) { wheel.m_raycastInfo.m_isInContact = false; - const SimdTransform& chassisTrans = GetRigidBody()->getCenterOfMassTransform(); + const btTransform& chassisTrans = GetRigidBody()->getCenterOfMassTransform(); wheel.m_raycastInfo.m_hardPointWS = chassisTrans( wheel.m_chassisConnectionPointCS ); wheel.m_raycastInfo.m_wheelDirectionWS = chassisTrans.getBasis() * wheel.m_wheelDirectionCS ; wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.getBasis() * wheel.m_wheelAxleCS; } -SimdScalar RaycastVehicle::Raycast(WheelInfo& wheel) +btScalar btRaycastVehicle::Raycast(btWheelInfo& wheel) { UpdateWheelTransformsWS( wheel ); - SimdScalar depth = -1; + btScalar depth = -1; - SimdScalar raylen = wheel.GetSuspensionRestLength()+wheel.m_wheelsRadius; + btScalar raylen = wheel.GetSuspensionRestLength()+wheel.m_wheelsRadius; - SimdVector3 rayvector = wheel.m_raycastInfo.m_wheelDirectionWS * (raylen); - const SimdVector3& source = wheel.m_raycastInfo.m_hardPointWS; + btVector3 rayvector = wheel.m_raycastInfo.m_wheelDirectionWS * (raylen); + const btVector3& source = wheel.m_raycastInfo.m_hardPointWS; wheel.m_raycastInfo.m_contactPointWS = source + rayvector; - const SimdVector3& target = wheel.m_raycastInfo.m_contactPointWS; + const btVector3& target = wheel.m_raycastInfo.m_contactPointWS; - SimdScalar param = 0.f; + btScalar param = 0.f; - VehicleRaycaster::VehicleRaycasterResult rayResults; + btVehicleRaycaster::btVehicleRaycasterResult rayResults; void* object = m_vehicleRaycaster->CastRay(source,target,rayResults); @@ -182,7 +182,7 @@ SimdScalar RaycastVehicle::Raycast(WheelInfo& wheel) //wheel.m_raycastInfo.m_groundObject = object; - SimdScalar hitDistance = param*raylen; + btScalar hitDistance = param*raylen; wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelsRadius; //clamp on max suspension travel @@ -199,14 +199,14 @@ SimdScalar RaycastVehicle::Raycast(WheelInfo& wheel) wheel.m_raycastInfo.m_contactPointWS = rayResults.m_hitPointInWorld; - SimdScalar denominator= wheel.m_raycastInfo.m_contactNormalWS.dot( wheel.m_raycastInfo.m_wheelDirectionWS ); + btScalar denominator= wheel.m_raycastInfo.m_contactNormalWS.dot( wheel.m_raycastInfo.m_wheelDirectionWS ); - SimdVector3 chassis_velocity_at_contactPoint; - SimdVector3 relpos = wheel.m_raycastInfo.m_contactPointWS-GetRigidBody()->getCenterOfMassPosition(); + btVector3 chassis_velocity_at_contactPoint; + btVector3 relpos = wheel.m_raycastInfo.m_contactPointWS-GetRigidBody()->getCenterOfMassPosition(); chassis_velocity_at_contactPoint = GetRigidBody()->getVelocityInLocalPoint(relpos); - SimdScalar projVel = wheel.m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint ); + btScalar projVel = wheel.m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint ); if ( denominator >= -0.1f) { @@ -215,7 +215,7 @@ SimdScalar RaycastVehicle::Raycast(WheelInfo& wheel) } else { - SimdScalar inv = -1.f / denominator; + btScalar inv = -1.f / denominator; wheel.m_suspensionRelativeVelocity = projVel * inv; wheel.m_clippedInvContactDotSuspension = inv; } @@ -233,13 +233,13 @@ SimdScalar RaycastVehicle::Raycast(WheelInfo& wheel) } -void RaycastVehicle::UpdateVehicle( SimdScalar step ) +void btRaycastVehicle::UpdateVehicle( btScalar step ) { m_currentVehicleSpeedKmHour = 3.6f * GetRigidBody()->getLinearVelocity().length(); - const SimdTransform& chassisTrans = GetRigidBody()->getCenterOfMassTransform(); - SimdVector3 forwardW ( + const btTransform& chassisTrans = GetRigidBody()->getCenterOfMassTransform(); + btVector3 forwardW ( chassisTrans.getBasis()[0][m_indexForwardAxis], chassisTrans.getBasis()[1][m_indexForwardAxis], chassisTrans.getBasis()[2][m_indexForwardAxis]); @@ -252,12 +252,12 @@ void RaycastVehicle::UpdateVehicle( SimdScalar step ) // // simulate suspension // - std::vector::iterator wheelIt; + std::vector::iterator wheelIt; int i=0; for (wheelIt = m_wheelInfo.begin(); !(wheelIt == m_wheelInfo.end());wheelIt++,i++) { - SimdScalar depth; + btScalar depth; depth = Raycast( *wheelIt ); } @@ -268,7 +268,7 @@ void RaycastVehicle::UpdateVehicle( SimdScalar step ) !(wheelIt == m_wheelInfo.end());wheelIt++) { //apply suspension force - WheelInfo& wheel = *wheelIt; + btWheelInfo& wheel = *wheelIt; float suspensionForce = wheel.m_wheelsSuspensionForce; @@ -277,8 +277,8 @@ void RaycastVehicle::UpdateVehicle( SimdScalar step ) { suspensionForce = gMaxSuspensionForce; } - SimdVector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step; - SimdVector3 relpos = wheel.m_raycastInfo.m_contactPointWS - GetRigidBody()->getCenterOfMassPosition(); + btVector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step; + btVector3 relpos = wheel.m_raycastInfo.m_contactPointWS - GetRigidBody()->getCenterOfMassPosition(); GetRigidBody()->applyImpulse(impulse, relpos); @@ -292,21 +292,21 @@ void RaycastVehicle::UpdateVehicle( SimdScalar step ) for (wheelIt = m_wheelInfo.begin(); !(wheelIt == m_wheelInfo.end());wheelIt++) { - WheelInfo& wheel = *wheelIt; - SimdVector3 relpos = wheel.m_raycastInfo.m_hardPointWS - GetRigidBody()->getCenterOfMassPosition(); - SimdVector3 vel = GetRigidBody()->getVelocityInLocalPoint( relpos ); + btWheelInfo& wheel = *wheelIt; + btVector3 relpos = wheel.m_raycastInfo.m_hardPointWS - GetRigidBody()->getCenterOfMassPosition(); + btVector3 vel = GetRigidBody()->getVelocityInLocalPoint( relpos ); if (wheel.m_raycastInfo.m_isInContact) { - SimdVector3 fwd ( + btVector3 fwd ( GetRigidBody()->getCenterOfMassTransform().getBasis()[0][m_indexForwardAxis], GetRigidBody()->getCenterOfMassTransform().getBasis()[1][m_indexForwardAxis], GetRigidBody()->getCenterOfMassTransform().getBasis()[2][m_indexForwardAxis]); - SimdScalar proj = fwd.dot(wheel.m_raycastInfo.m_contactNormalWS); + btScalar proj = fwd.dot(wheel.m_raycastInfo.m_contactNormalWS); fwd -= wheel.m_raycastInfo.m_contactNormalWS * proj; - SimdScalar proj2 = fwd.dot(vel); + btScalar proj2 = fwd.dot(vel); wheel.m_deltaRotation = (proj2 * step) / (wheel.m_wheelsRadius); wheel.m_rotation += wheel.m_deltaRotation; @@ -325,69 +325,69 @@ void RaycastVehicle::UpdateVehicle( SimdScalar step ) } -void RaycastVehicle::SetSteeringValue(SimdScalar steering,int wheel) +void btRaycastVehicle::SetSteeringValue(btScalar steering,int wheel) { assert(wheel>=0 && wheel < GetNumWheels()); - WheelInfo& wheelInfo = GetWheelInfo(wheel); + btWheelInfo& wheelInfo = GetWheelInfo(wheel); wheelInfo.m_steering = steering; } -SimdScalar RaycastVehicle::GetSteeringValue(int wheel) const +btScalar btRaycastVehicle::GetSteeringValue(int wheel) const { return GetWheelInfo(wheel).m_steering; } -void RaycastVehicle::ApplyEngineForce(SimdScalar force, int wheel) +void btRaycastVehicle::ApplyEngineForce(btScalar force, int wheel) { assert(wheel>=0 && wheel < GetNumWheels()); - WheelInfo& wheelInfo = GetWheelInfo(wheel); + btWheelInfo& wheelInfo = GetWheelInfo(wheel); wheelInfo.m_engineForce = force; } -const WheelInfo& RaycastVehicle::GetWheelInfo(int index) const +const btWheelInfo& btRaycastVehicle::GetWheelInfo(int index) const { ASSERT((index >= 0) && (index < GetNumWheels())); return m_wheelInfo[index]; } -WheelInfo& RaycastVehicle::GetWheelInfo(int index) +btWheelInfo& btRaycastVehicle::GetWheelInfo(int index) { ASSERT((index >= 0) && (index < GetNumWheels())); return m_wheelInfo[index]; } -void RaycastVehicle::SetBrake(float brake,int wheelIndex) +void btRaycastVehicle::SetBrake(float brake,int wheelIndex) { ASSERT((wheelIndex >= 0) && (wheelIndex < GetNumWheels())); GetWheelInfo(wheelIndex).m_brake; } -void RaycastVehicle::UpdateSuspension(SimdScalar deltaTime) +void btRaycastVehicle::UpdateSuspension(btScalar deltaTime) { - SimdScalar chassisMass = 1.f / m_chassisBody->getInvMass(); + btScalar chassisMass = 1.f / m_chassisBody->getInvMass(); for (int w_it=0; w_itgetCenterOfMassPosition(); if (forwardImpulse[wheel] != 0.f) @@ -572,13 +572,13 @@ void RaycastVehicle::UpdateFriction(SimdScalar timeStep) } if (sideImpulse[wheel] != 0.f) { - class RigidBody* groundObject = (class RigidBody*) m_wheelInfo[wheel].m_raycastInfo.m_groundObject; + class btRigidBody* groundObject = (class btRigidBody*) m_wheelInfo[wheel].m_raycastInfo.m_groundObject; - SimdVector3 rel_pos2 = wheelInfo.m_raycastInfo.m_contactPointWS - + btVector3 rel_pos2 = wheelInfo.m_raycastInfo.m_contactPointWS - groundObject->getCenterOfMassPosition(); - SimdVector3 sideImp = axle[wheel] * sideImpulse[wheel]; + btVector3 sideImp = axle[wheel] * sideImpulse[wheel]; rel_pos[2] *= wheelInfo.m_rollInfluence; m_chassisBody->applyImpulse(sideImp,rel_pos); diff --git a/src/BulletDynamics/Vehicle/btRaycastVehicle.h b/src/BulletDynamics/Vehicle/btRaycastVehicle.h index dc65bea85..dc55fe97b 100644 --- a/src/BulletDynamics/Vehicle/btRaycastVehicle.h +++ b/src/BulletDynamics/Vehicle/btRaycastVehicle.h @@ -14,21 +14,21 @@ #include "BulletDynamics/Dynamics/btRigidBody.h" #include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" -struct MassProps; +struct btMassProps; #include "btWheelInfo.h" -struct VehicleRaycaster; -class VehicleTuning; +struct btVehicleRaycaster; +class btVehicleTuning; ///Raycast vehicle, very special constraint that turn a rigidbody into a vehicle. -class RaycastVehicle : public TypedConstraint +class btRaycastVehicle : public btTypedConstraint { public: - class VehicleTuning + class btVehicleTuning { public: - VehicleTuning() + btVehicleTuning() :m_suspensionStiffness(5.88f), m_suspensionCompression(0.83f), m_suspensionDamping(0.88f), @@ -45,65 +45,65 @@ public: }; private: - SimdScalar m_tau; - SimdScalar m_damping; - VehicleRaycaster* m_vehicleRaycaster; + btScalar m_tau; + btScalar m_damping; + btVehicleRaycaster* m_vehicleRaycaster; float m_pitchControl; float m_steeringValue; float m_currentVehicleSpeedKmHour; - RigidBody* m_chassisBody; + btRigidBody* m_chassisBody; int m_indexRightAxis; int m_indexUpAxis; int m_indexForwardAxis; - void DefaultInit(const VehicleTuning& tuning); + void DefaultInit(const btVehicleTuning& tuning); public: //constructor to create a car from an existing rigidbody - RaycastVehicle(const VehicleTuning& tuning,RigidBody* chassis, VehicleRaycaster* raycaster ); + btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster ); - virtual ~RaycastVehicle() ; + virtual ~btRaycastVehicle() ; - SimdScalar Raycast(WheelInfo& wheel); + btScalar Raycast(btWheelInfo& wheel); - virtual void UpdateVehicle(SimdScalar step); + virtual void UpdateVehicle(btScalar step); void ResetSuspension(); - SimdScalar GetSteeringValue(int wheel) const; + btScalar GetSteeringValue(int wheel) const; - void SetSteeringValue(SimdScalar steering,int wheel); + void SetSteeringValue(btScalar steering,int wheel); - void ApplyEngineForce(SimdScalar force, int wheel); + void ApplyEngineForce(btScalar force, int wheel); - const SimdTransform& GetWheelTransformWS( int wheelIndex ) const; + const btTransform& GetWheelTransformWS( int wheelIndex ) const; void UpdateWheelTransform( int wheelIndex ); - void SetRaycastWheelInfo( int wheelIndex , bool isInContact, const SimdVector3& hitPoint, const SimdVector3& hitNormal,SimdScalar depth); + void SetRaycastWheelInfo( int wheelIndex , bool isInContact, const btVector3& hitPoint, const btVector3& hitNormal,btScalar depth); - WheelInfo& AddWheel( const SimdVector3& connectionPointCS0, const SimdVector3& wheelDirectionCS0,const SimdVector3& wheelAxleCS,SimdScalar suspensionRestLength,SimdScalar wheelRadius,const VehicleTuning& tuning, bool isFrontWheel); + btWheelInfo& AddWheel( const btVector3& connectionPointCS0, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS,btScalar suspensionRestLength,btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel); inline int GetNumWheels() const { return m_wheelInfo.size(); } - std::vector m_wheelInfo; + std::vector m_wheelInfo; - const WheelInfo& GetWheelInfo(int index) const; + const btWheelInfo& GetWheelInfo(int index) const; - WheelInfo& GetWheelInfo(int index); + btWheelInfo& GetWheelInfo(int index); - void UpdateWheelTransformsWS(WheelInfo& wheel ); + void UpdateWheelTransformsWS(btWheelInfo& wheel ); void SetBrake(float brake,int wheelIndex); @@ -113,18 +113,18 @@ public: m_pitchControl = pitch; } - void UpdateSuspension(SimdScalar deltaTime); + void UpdateSuspension(btScalar deltaTime); - void UpdateFriction(SimdScalar timeStep); + void UpdateFriction(btScalar timeStep); - inline RigidBody* GetRigidBody() + inline btRigidBody* GetRigidBody() { return m_chassisBody; } - const RigidBody* GetRigidBody() const + const btRigidBody* GetRigidBody() const { return m_chassisBody; } @@ -155,7 +155,7 @@ public: //not yet } - virtual void SolveConstraint(SimdScalar timeStep) + virtual void SolveConstraint(btScalar timeStep) { //not yet } diff --git a/src/BulletDynamics/Vehicle/btVehicleRaycaster.h b/src/BulletDynamics/Vehicle/btVehicleRaycaster.h index 5abc5b9fb..fe1fd5c88 100644 --- a/src/BulletDynamics/Vehicle/btVehicleRaycaster.h +++ b/src/BulletDynamics/Vehicle/btVehicleRaycaster.h @@ -11,23 +11,23 @@ #ifndef VEHICLE_RAYCASTER_H #define VEHICLE_RAYCASTER_H -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" -/// VehicleRaycaster is provides interface for between vehicle simulation and raycasting -struct VehicleRaycaster +/// btVehicleRaycaster is provides interface for between vehicle simulation and raycasting +struct btVehicleRaycaster { -virtual ~VehicleRaycaster() +virtual ~btVehicleRaycaster() { } - struct VehicleRaycasterResult + struct btVehicleRaycasterResult { - VehicleRaycasterResult() :m_distFraction(-1.f){}; - SimdVector3 m_hitPointInWorld; - SimdVector3 m_hitNormalInWorld; - SimdScalar m_distFraction; + btVehicleRaycasterResult() :m_distFraction(-1.f){}; + btVector3 m_hitPointInWorld; + btVector3 m_hitNormalInWorld; + btScalar m_distFraction; }; - virtual void* CastRay(const SimdVector3& from,const SimdVector3& to, VehicleRaycasterResult& result) = 0; + virtual void* CastRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result) = 0; }; diff --git a/src/BulletDynamics/Vehicle/btWheelInfo.cpp b/src/BulletDynamics/Vehicle/btWheelInfo.cpp index 1a99b4d34..7dd390542 100644 --- a/src/BulletDynamics/Vehicle/btWheelInfo.cpp +++ b/src/BulletDynamics/Vehicle/btWheelInfo.cpp @@ -12,25 +12,25 @@ #include "BulletDynamics/Dynamics/btRigidBody.h" // for pointvelocity -SimdScalar WheelInfo::GetSuspensionRestLength() const +btScalar btWheelInfo::GetSuspensionRestLength() const { return m_suspensionRestLength1; } -void WheelInfo::UpdateWheel(const RigidBody& chassis,RaycastInfo& raycastInfo) +void btWheelInfo::UpdateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo) { if (m_raycastInfo.m_isInContact) { - SimdScalar project= m_raycastInfo.m_contactNormalWS.dot( m_raycastInfo.m_wheelDirectionWS ); - SimdVector3 chassis_velocity_at_contactPoint; - SimdVector3 relpos = m_raycastInfo.m_contactPointWS - chassis.getCenterOfMassPosition(); + btScalar project= m_raycastInfo.m_contactNormalWS.dot( m_raycastInfo.m_wheelDirectionWS ); + btVector3 chassis_velocity_at_contactPoint; + btVector3 relpos = m_raycastInfo.m_contactPointWS - chassis.getCenterOfMassPosition(); chassis_velocity_at_contactPoint = chassis.getVelocityInLocalPoint( relpos ); - SimdScalar projVel = m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint ); + btScalar projVel = m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint ); if ( project >= -0.1f) { m_suspensionRelativeVelocity = 0.0f; @@ -38,7 +38,7 @@ void WheelInfo::UpdateWheel(const RigidBody& chassis,RaycastInfo& raycastInfo) } else { - SimdScalar inv = -1.f / project; + btScalar inv = -1.f / project; m_suspensionRelativeVelocity = projVel * inv; m_clippedInvContactDotSuspension = inv; } diff --git a/src/BulletDynamics/Vehicle/btWheelInfo.h b/src/BulletDynamics/Vehicle/btWheelInfo.h index c1c43c92f..16b54abd4 100644 --- a/src/BulletDynamics/Vehicle/btWheelInfo.h +++ b/src/BulletDynamics/Vehicle/btWheelInfo.h @@ -11,19 +11,19 @@ #ifndef WHEEL_INFO_H #define WHEEL_INFO_H -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btTransform.h" -class RigidBody; +class btRigidBody; -struct WheelInfoConstructionInfo +struct btWheelInfoConstructionInfo { - SimdVector3 m_chassisConnectionCS; - SimdVector3 m_wheelDirectionCS; - SimdVector3 m_wheelAxleCS; - SimdScalar m_suspensionRestLength; - SimdScalar m_maxSuspensionTravelCm; - SimdScalar m_wheelRadius; + btVector3 m_chassisConnectionCS; + btVector3 m_wheelDirectionCS; + btVector3 m_wheelAxleCS; + btScalar m_suspensionRestLength; + btScalar m_maxSuspensionTravelCm; + btScalar m_wheelRadius; float m_suspensionStiffness; float m_wheelsDampingCompression; @@ -33,51 +33,51 @@ struct WheelInfoConstructionInfo }; -/// WheelInfo contains information per wheel about friction and suspension. -struct WheelInfo +/// btWheelInfo contains information per wheel about friction and suspension. +struct btWheelInfo { struct RaycastInfo { //set by raycaster - SimdVector3 m_contactNormalWS;//contactnormal - SimdVector3 m_contactPointWS;//raycast hitpoint - SimdScalar m_suspensionLength; - SimdVector3 m_hardPointWS;//raycast starting point - SimdVector3 m_wheelDirectionWS; //direction in worldspace - SimdVector3 m_wheelAxleWS; // axle in worldspace + btVector3 m_contactNormalWS;//contactnormal + btVector3 m_contactPointWS;//raycast hitpoint + btScalar m_suspensionLength; + btVector3 m_hardPointWS;//raycast starting point + btVector3 m_wheelDirectionWS; //direction in worldspace + btVector3 m_wheelAxleWS; // axle in worldspace bool m_isInContact; void* m_groundObject; //could be general void* ptr }; RaycastInfo m_raycastInfo; - SimdTransform m_worldTransform; + btTransform m_worldTransform; - SimdVector3 m_chassisConnectionPointCS; //const - SimdVector3 m_wheelDirectionCS;//const - SimdVector3 m_wheelAxleCS; // const or modified by steering - SimdScalar m_suspensionRestLength1;//const - SimdScalar m_maxSuspensionTravelCm; - SimdScalar GetSuspensionRestLength() const; - SimdScalar m_wheelsRadius;//const - SimdScalar m_suspensionStiffness;//const - SimdScalar m_wheelsDampingCompression;//const - SimdScalar m_wheelsDampingRelaxation;//const - SimdScalar m_frictionSlip; - SimdScalar m_steering; - SimdScalar m_rotation; - SimdScalar m_deltaRotation; - SimdScalar m_rollInfluence; + btVector3 m_chassisConnectionPointCS; //const + btVector3 m_wheelDirectionCS;//const + btVector3 m_wheelAxleCS; // const or modified by steering + btScalar m_suspensionRestLength1;//const + btScalar m_maxSuspensionTravelCm; + btScalar GetSuspensionRestLength() const; + btScalar m_wheelsRadius;//const + btScalar m_suspensionStiffness;//const + btScalar m_wheelsDampingCompression;//const + btScalar m_wheelsDampingRelaxation;//const + btScalar m_frictionSlip; + btScalar m_steering; + btScalar m_rotation; + btScalar m_deltaRotation; + btScalar m_rollInfluence; - SimdScalar m_engineForce; + btScalar m_engineForce; - SimdScalar m_brake; + btScalar m_brake; bool m_bIsFrontWheel; void* m_clientInfo;//can be used to store pointer to sync transforms... - WheelInfo(WheelInfoConstructionInfo& ci) + btWheelInfo(btWheelInfoConstructionInfo& ci) { @@ -102,13 +102,13 @@ struct WheelInfo } - void UpdateWheel(const RigidBody& chassis,RaycastInfo& raycastInfo); + void UpdateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo); - SimdScalar m_clippedInvContactDotSuspension; - SimdScalar m_suspensionRelativeVelocity; + btScalar m_clippedInvContactDotSuspension; + btScalar m_suspensionRelativeVelocity; //calculated by suspension - SimdScalar m_wheelsSuspensionForce; - SimdScalar m_skidInfo; + btScalar m_wheelsSuspensionForce; + btScalar m_skidInfo; }; diff --git a/src/LinearMath/SimdMatrix3x3.h b/src/LinearMath/SimdMatrix3x3.h deleted file mode 100644 index 11efb8998..000000000 --- a/src/LinearMath/SimdMatrix3x3.h +++ /dev/null @@ -1,395 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. 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. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef SimdMatrix3x3_H -#define SimdMatrix3x3_H - -#include "LinearMath/SimdScalar.h" - -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdQuaternion.h" - - -class SimdMatrix3x3 { - public: - SimdMatrix3x3 () {} - -// explicit SimdMatrix3x3(const SimdScalar *m) { setFromOpenGLSubMatrix(m); } - - explicit SimdMatrix3x3(const SimdQuaternion& q) { setRotation(q); } - /* - template - Matrix3x3(const SimdScalar& yaw, const SimdScalar& pitch, const SimdScalar& roll) - { - setEulerYPR(yaw, pitch, roll); - } - */ - SimdMatrix3x3(const SimdScalar& xx, const SimdScalar& xy, const SimdScalar& xz, - const SimdScalar& yx, const SimdScalar& yy, const SimdScalar& yz, - const SimdScalar& zx, const SimdScalar& zy, const SimdScalar& zz) - { - setValue(xx, xy, xz, - yx, yy, yz, - zx, zy, zz); - } - - SimdVector3 getColumn(int i) const - { - return SimdVector3(m_el[0][i],m_el[1][i],m_el[2][i]); - } - - const SimdVector3& getRow(int i) const - { - return m_el[i]; - } - - - SIMD_FORCE_INLINE SimdVector3& operator[](int i) - { - assert(0 <= i && i < 3); - return m_el[i]; - } - - const SimdVector3& operator[](int i) const - { - assert(0 <= i && i < 3); - return m_el[i]; - } - - SimdMatrix3x3& operator*=(const SimdMatrix3x3& m); - - - void setFromOpenGLSubMatrix(const SimdScalar *m) - { - m_el[0][0] = (m[0]); - m_el[1][0] = (m[1]); - m_el[2][0] = (m[2]); - m_el[0][1] = (m[4]); - m_el[1][1] = (m[5]); - m_el[2][1] = (m[6]); - m_el[0][2] = (m[8]); - m_el[1][2] = (m[9]); - m_el[2][2] = (m[10]); - } - - void setValue(const SimdScalar& xx, const SimdScalar& xy, const SimdScalar& xz, - const SimdScalar& yx, const SimdScalar& yy, const SimdScalar& yz, - const SimdScalar& zx, const SimdScalar& zy, const SimdScalar& zz) - { - m_el[0][0] = SimdScalar(xx); - m_el[0][1] = SimdScalar(xy); - m_el[0][2] = SimdScalar(xz); - m_el[1][0] = SimdScalar(yx); - m_el[1][1] = SimdScalar(yy); - m_el[1][2] = SimdScalar(yz); - m_el[2][0] = SimdScalar(zx); - m_el[2][1] = SimdScalar(zy); - m_el[2][2] = SimdScalar(zz); - } - - void setRotation(const SimdQuaternion& q) - { - SimdScalar d = q.length2(); - assert(d != SimdScalar(0.0)); - SimdScalar s = SimdScalar(2.0) / d; - SimdScalar xs = q[0] * s, ys = q[1] * s, zs = q[2] * s; - SimdScalar wx = q[3] * xs, wy = q[3] * ys, wz = q[3] * zs; - SimdScalar xx = q[0] * xs, xy = q[0] * ys, xz = q[0] * zs; - SimdScalar yy = q[1] * ys, yz = q[1] * zs, zz = q[2] * zs; - setValue(SimdScalar(1.0) - (yy + zz), xy - wz, xz + wy, - xy + wz, SimdScalar(1.0) - (xx + zz), yz - wx, - xz - wy, yz + wx, SimdScalar(1.0) - (xx + yy)); - } - - - - void setEulerYPR(const SimdScalar& yaw, const SimdScalar& pitch, const SimdScalar& roll) - { - - SimdScalar cy(SimdCos(yaw)); - SimdScalar sy(SimdSin(yaw)); - SimdScalar cp(SimdCos(pitch)); - SimdScalar sp(SimdSin(pitch)); - SimdScalar cr(SimdCos(roll)); - SimdScalar sr(SimdSin(roll)); - SimdScalar cc = cy * cr; - SimdScalar cs = cy * sr; - SimdScalar sc = sy * cr; - SimdScalar ss = sy * sr; - setValue(cc - sp * ss, -cs - sp * sc, -sy * cp, - cp * sr, cp * cr, -sp, - sc + sp * cs, -ss + sp * cc, cy * cp); - - } - - /** - * setEulerZYX - * @param euler a const reference to a SimdVector3 of euler angles - * These angles are used to produce a rotation matrix. The euler - * angles are applied in ZYX order. I.e a vector is first rotated - * about X then Y and then Z - **/ - - void setEulerZYX(SimdScalar eulerX,SimdScalar eulerY,SimdScalar eulerZ) { - SimdScalar ci ( SimdCos(eulerX)); - SimdScalar cj ( SimdCos(eulerY)); - SimdScalar ch ( SimdCos(eulerZ)); - SimdScalar si ( SimdSin(eulerX)); - SimdScalar sj ( SimdSin(eulerY)); - SimdScalar sh ( SimdSin(eulerZ)); - SimdScalar cc = ci * ch; - SimdScalar cs = ci * sh; - SimdScalar sc = si * ch; - SimdScalar ss = si * sh; - - setValue(cj * ch, sj * sc - cs, sj * cc + ss, - cj * sh, sj * ss + cc, sj * cs - sc, - -sj, cj * si, cj * ci); - } - - void setIdentity() - { - setValue(SimdScalar(1.0), SimdScalar(0.0), SimdScalar(0.0), - SimdScalar(0.0), SimdScalar(1.0), SimdScalar(0.0), - SimdScalar(0.0), SimdScalar(0.0), SimdScalar(1.0)); - } - - void getOpenGLSubMatrix(SimdScalar *m) const - { - m[0] = SimdScalar(m_el[0][0]); - m[1] = SimdScalar(m_el[1][0]); - m[2] = SimdScalar(m_el[2][0]); - m[3] = SimdScalar(0.0); - m[4] = SimdScalar(m_el[0][1]); - m[5] = SimdScalar(m_el[1][1]); - m[6] = SimdScalar(m_el[2][1]); - m[7] = SimdScalar(0.0); - m[8] = SimdScalar(m_el[0][2]); - m[9] = SimdScalar(m_el[1][2]); - m[10] = SimdScalar(m_el[2][2]); - m[11] = SimdScalar(0.0); - } - - void getRotation(SimdQuaternion& q) const - { - SimdScalar trace = m_el[0][0] + m_el[1][1] + m_el[2][2]; - - if (trace > SimdScalar(0.0)) - { - SimdScalar s = SimdSqrt(trace + SimdScalar(1.0)); - q[3] = s * SimdScalar(0.5); - s = SimdScalar(0.5) / s; - - q[0] = (m_el[2][1] - m_el[1][2]) * s; - q[1] = (m_el[0][2] - m_el[2][0]) * s; - q[2] = (m_el[1][0] - m_el[0][1]) * s; - } - else - { - int i = m_el[0][0] < m_el[1][1] ? - (m_el[1][1] < m_el[2][2] ? 2 : 1) : - (m_el[0][0] < m_el[2][2] ? 2 : 0); - int j = (i + 1) % 3; - int k = (i + 2) % 3; - - SimdScalar s = SimdSqrt(m_el[i][i] - m_el[j][j] - m_el[k][k] + SimdScalar(1.0)); - q[i] = s * SimdScalar(0.5); - s = SimdScalar(0.5) / s; - - q[3] = (m_el[k][j] - m_el[j][k]) * s; - q[j] = (m_el[j][i] + m_el[i][j]) * s; - q[k] = (m_el[k][i] + m_el[i][k]) * s; - } - } - - - - void getEuler(SimdScalar& yaw, SimdScalar& pitch, SimdScalar& roll) const - { - pitch = SimdScalar(SimdAsin(-m_el[2][0])); - if (pitch < SIMD_2_PI) - { - if (pitch > SIMD_2_PI) - { - yaw = SimdScalar(SimdAtan2(m_el[1][0], m_el[0][0])); - roll = SimdScalar(SimdAtan2(m_el[2][1], m_el[2][2])); - } - else - { - yaw = SimdScalar(-SimdAtan2(-m_el[0][1], m_el[0][2])); - roll = SimdScalar(0.0); - } - } - else - { - yaw = SimdScalar(SimdAtan2(-m_el[0][1], m_el[0][2])); - roll = SimdScalar(0.0); - } - } - - SimdVector3 getScaling() const - { - return SimdVector3(m_el[0][0] * m_el[0][0] + m_el[1][0] * m_el[1][0] + m_el[2][0] * m_el[2][0], - m_el[0][1] * m_el[0][1] + m_el[1][1] * m_el[1][1] + m_el[2][1] * m_el[2][1], - m_el[0][2] * m_el[0][2] + m_el[1][2] * m_el[1][2] + m_el[2][2] * m_el[2][2]); - } - - - SimdMatrix3x3 scaled(const SimdVector3& s) const - { - return SimdMatrix3x3(m_el[0][0] * s[0], m_el[0][1] * s[1], m_el[0][2] * s[2], - m_el[1][0] * s[0], m_el[1][1] * s[1], m_el[1][2] * s[2], - m_el[2][0] * s[0], m_el[2][1] * s[1], m_el[2][2] * s[2]); - } - - SimdScalar determinant() const; - SimdMatrix3x3 adjoint() const; - SimdMatrix3x3 absolute() const; - SimdMatrix3x3 transpose() const; - SimdMatrix3x3 inverse() const; - - SimdMatrix3x3 transposeTimes(const SimdMatrix3x3& m) const; - SimdMatrix3x3 timesTranspose(const SimdMatrix3x3& m) const; - - SimdScalar tdot(int c, const SimdVector3& v) const - { - return m_el[0][c] * v[0] + m_el[1][c] * v[1] + m_el[2][c] * v[2]; - } - - protected: - SimdScalar cofac(int r1, int c1, int r2, int c2) const - { - return m_el[r1][c1] * m_el[r2][c2] - m_el[r1][c2] * m_el[r2][c1]; - } - - SimdVector3 m_el[3]; - }; - - SIMD_FORCE_INLINE SimdMatrix3x3& - SimdMatrix3x3::operator*=(const SimdMatrix3x3& m) - { - setValue(m.tdot(0, m_el[0]), m.tdot(1, m_el[0]), m.tdot(2, m_el[0]), - m.tdot(0, m_el[1]), m.tdot(1, m_el[1]), m.tdot(2, m_el[1]), - m.tdot(0, m_el[2]), m.tdot(1, m_el[2]), m.tdot(2, m_el[2])); - return *this; - } - - SIMD_FORCE_INLINE SimdScalar - SimdMatrix3x3::determinant() const - { - return triple((*this)[0], (*this)[1], (*this)[2]); - } - - - SIMD_FORCE_INLINE SimdMatrix3x3 - SimdMatrix3x3::absolute() const - { - return SimdMatrix3x3( - SimdFabs(m_el[0][0]), SimdFabs(m_el[0][1]), SimdFabs(m_el[0][2]), - SimdFabs(m_el[1][0]), SimdFabs(m_el[1][1]), SimdFabs(m_el[1][2]), - SimdFabs(m_el[2][0]), SimdFabs(m_el[2][1]), SimdFabs(m_el[2][2])); - } - - SIMD_FORCE_INLINE SimdMatrix3x3 - SimdMatrix3x3::transpose() const - { - return SimdMatrix3x3(m_el[0][0], m_el[1][0], m_el[2][0], - m_el[0][1], m_el[1][1], m_el[2][1], - m_el[0][2], m_el[1][2], m_el[2][2]); - } - - SIMD_FORCE_INLINE SimdMatrix3x3 - SimdMatrix3x3::adjoint() const - { - return SimdMatrix3x3(cofac(1, 1, 2, 2), cofac(0, 2, 2, 1), cofac(0, 1, 1, 2), - cofac(1, 2, 2, 0), cofac(0, 0, 2, 2), cofac(0, 2, 1, 0), - cofac(1, 0, 2, 1), cofac(0, 1, 2, 0), cofac(0, 0, 1, 1)); - } - - SIMD_FORCE_INLINE SimdMatrix3x3 - SimdMatrix3x3::inverse() const - { - SimdVector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1)); - SimdScalar det = (*this)[0].dot(co); - assert(det != SimdScalar(0.0f)); - SimdScalar s = SimdScalar(1.0f) / det; - return SimdMatrix3x3(co[0] * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s, - co[1] * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s, - co[2] * s, cofac(0, 1, 2, 0) * s, cofac(0, 0, 1, 1) * s); - } - - SIMD_FORCE_INLINE SimdMatrix3x3 - SimdMatrix3x3::transposeTimes(const SimdMatrix3x3& m) const - { - return SimdMatrix3x3( - m_el[0][0] * m[0][0] + m_el[1][0] * m[1][0] + m_el[2][0] * m[2][0], - m_el[0][0] * m[0][1] + m_el[1][0] * m[1][1] + m_el[2][0] * m[2][1], - m_el[0][0] * m[0][2] + m_el[1][0] * m[1][2] + m_el[2][0] * m[2][2], - m_el[0][1] * m[0][0] + m_el[1][1] * m[1][0] + m_el[2][1] * m[2][0], - m_el[0][1] * m[0][1] + m_el[1][1] * m[1][1] + m_el[2][1] * m[2][1], - m_el[0][1] * m[0][2] + m_el[1][1] * m[1][2] + m_el[2][1] * m[2][2], - m_el[0][2] * m[0][0] + m_el[1][2] * m[1][0] + m_el[2][2] * m[2][0], - m_el[0][2] * m[0][1] + m_el[1][2] * m[1][1] + m_el[2][2] * m[2][1], - m_el[0][2] * m[0][2] + m_el[1][2] * m[1][2] + m_el[2][2] * m[2][2]); - } - - SIMD_FORCE_INLINE SimdMatrix3x3 - SimdMatrix3x3::timesTranspose(const SimdMatrix3x3& m) const - { - return SimdMatrix3x3( - m_el[0].dot(m[0]), m_el[0].dot(m[1]), m_el[0].dot(m[2]), - m_el[1].dot(m[0]), m_el[1].dot(m[1]), m_el[1].dot(m[2]), - m_el[2].dot(m[0]), m_el[2].dot(m[1]), m_el[2].dot(m[2])); - - } - - SIMD_FORCE_INLINE SimdVector3 - operator*(const SimdMatrix3x3& m, const SimdVector3& v) - { - return SimdVector3(m[0].dot(v), m[1].dot(v), m[2].dot(v)); - } - - - SIMD_FORCE_INLINE SimdVector3 - operator*(const SimdVector3& v, const SimdMatrix3x3& m) - { - return SimdVector3(m.tdot(0, v), m.tdot(1, v), m.tdot(2, v)); - } - - SIMD_FORCE_INLINE SimdMatrix3x3 - operator*(const SimdMatrix3x3& m1, const SimdMatrix3x3& m2) - { - return SimdMatrix3x3( - m2.tdot(0, m1[0]), m2.tdot(1, m1[0]), m2.tdot(2, m1[0]), - m2.tdot(0, m1[1]), m2.tdot(1, m1[1]), m2.tdot(2, m1[1]), - m2.tdot(0, m1[2]), m2.tdot(1, m1[2]), m2.tdot(2, m1[2])); - } - - - SIMD_FORCE_INLINE SimdMatrix3x3 SimdMultTransposeLeft(const SimdMatrix3x3& m1, const SimdMatrix3x3& m2) { - return SimdMatrix3x3( - m1[0][0] * m2[0][0] + m1[1][0] * m2[1][0] + m1[2][0] * m2[2][0], - m1[0][0] * m2[0][1] + m1[1][0] * m2[1][1] + m1[2][0] * m2[2][1], - m1[0][0] * m2[0][2] + m1[1][0] * m2[1][2] + m1[2][0] * m2[2][2], - m1[0][1] * m2[0][0] + m1[1][1] * m2[1][0] + m1[2][1] * m2[2][0], - m1[0][1] * m2[0][1] + m1[1][1] * m2[1][1] + m1[2][1] * m2[2][1], - m1[0][1] * m2[0][2] + m1[1][1] * m2[1][2] + m1[2][1] * m2[2][2], - m1[0][2] * m2[0][0] + m1[1][2] * m2[1][0] + m1[2][2] * m2[2][0], - m1[0][2] * m2[0][1] + m1[1][2] * m2[1][1] + m1[2][2] * m2[2][1], - m1[0][2] * m2[0][2] + m1[1][2] * m2[1][2] + m1[2][2] * m2[2][2]); -} - - -#endif diff --git a/src/LinearMath/SimdQuaternion.h b/src/LinearMath/SimdQuaternion.h deleted file mode 100644 index b10960951..000000000 --- a/src/LinearMath/SimdQuaternion.h +++ /dev/null @@ -1,290 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. 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. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef SIMD__QUATERNION_H_ -#define SIMD__QUATERNION_H_ - -#include "LinearMath/SimdVector3.h" - -class SimdQuaternion : public SimdQuadWord { -public: - SimdQuaternion() {} - - // template - // explicit Quaternion(const SimdScalar *v) : Tuple4(v) {} - - SimdQuaternion(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z, const SimdScalar& w) - : SimdQuadWord(x, y, z, w) - {} - - SimdQuaternion(const SimdVector3& axis, const SimdScalar& angle) - { - setRotation(axis, angle); - } - - SimdQuaternion(const SimdScalar& yaw, const SimdScalar& pitch, const SimdScalar& roll) - { - setEuler(yaw, pitch, roll); - } - - void setRotation(const SimdVector3& axis, const SimdScalar& angle) - { - SimdScalar d = axis.length(); - assert(d != SimdScalar(0.0)); - SimdScalar s = SimdSin(angle * SimdScalar(0.5)) / d; - setValue(axis.x() * s, axis.y() * s, axis.z() * s, - SimdCos(angle * SimdScalar(0.5))); - } - - void setEuler(const SimdScalar& yaw, const SimdScalar& pitch, const SimdScalar& roll) - { - SimdScalar halfYaw = SimdScalar(yaw) * SimdScalar(0.5); - SimdScalar halfPitch = SimdScalar(pitch) * SimdScalar(0.5); - SimdScalar halfRoll = SimdScalar(roll) * SimdScalar(0.5); - SimdScalar cosYaw = SimdCos(halfYaw); - SimdScalar sinYaw = SimdSin(halfYaw); - SimdScalar cosPitch = SimdCos(halfPitch); - SimdScalar sinPitch = SimdSin(halfPitch); - SimdScalar cosRoll = SimdCos(halfRoll); - SimdScalar sinRoll = SimdSin(halfRoll); - setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw, - cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw, - sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw, - cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw); - } - - SimdQuaternion& operator+=(const SimdQuaternion& q) - { - m_x += q.x(); m_y += q.y(); m_z += q.z(); m_unusedW += q[3]; - return *this; - } - - SimdQuaternion& operator-=(const SimdQuaternion& q) - { - m_x -= q.x(); m_y -= q.y(); m_z -= q.z(); m_unusedW -= q[3]; - return *this; - } - - SimdQuaternion& operator*=(const SimdScalar& s) - { - m_x *= s; m_y *= s; m_z *= s; m_unusedW *= s; - return *this; - } - - - SimdQuaternion& operator*=(const SimdQuaternion& q) - { - setValue(m_unusedW * q.x() + m_x * q[3] + m_y * q.z() - m_z * q.y(), - m_unusedW * q.y() + m_y * q[3] + m_z * q.x() - m_x * q.z(), - m_unusedW * q.z() + m_z * q[3] + m_x * q.y() - m_y * q.x(), - m_unusedW * q[3] - m_x * q.x() - m_y * q.y() - m_z * q.z()); - return *this; - } - - SimdScalar dot(const SimdQuaternion& q) const - { - return m_x * q.x() + m_y * q.y() + m_z * q.z() + m_unusedW * q[3]; - } - - SimdScalar length2() const - { - return dot(*this); - } - - SimdScalar length() const - { - return SimdSqrt(length2()); - } - - SimdQuaternion& normalize() - { - return *this /= length(); - } - - SIMD_FORCE_INLINE SimdQuaternion - operator*(const SimdScalar& s) const - { - return SimdQuaternion(x() * s, y() * s, z() * s, m_unusedW * s); - } - - - - SimdQuaternion operator/(const SimdScalar& s) const - { - assert(s != SimdScalar(0.0)); - return *this * (SimdScalar(1.0) / s); - } - - - SimdQuaternion& operator/=(const SimdScalar& s) - { - assert(s != SimdScalar(0.0)); - return *this *= SimdScalar(1.0) / s; - } - - - SimdQuaternion normalized() const - { - return *this / length(); - } - - SimdScalar angle(const SimdQuaternion& q) const - { - SimdScalar s = SimdSqrt(length2() * q.length2()); - assert(s != SimdScalar(0.0)); - return SimdAcos(dot(q) / s); - } - - SimdScalar getAngle() const - { - SimdScalar s = 2.f * SimdAcos(m_unusedW); - return s; - } - - - - SimdQuaternion inverse() const - { - return SimdQuaternion(m_x, m_y, m_z, -m_unusedW); - } - - SIMD_FORCE_INLINE SimdQuaternion - operator+(const SimdQuaternion& q2) const - { - const SimdQuaternion& q1 = *this; - return SimdQuaternion(q1.x() + q2.x(), q1.y() + q2.y(), q1.z() + q2.z(), q1[3] + q2[3]); - } - - SIMD_FORCE_INLINE SimdQuaternion - operator-(const SimdQuaternion& q2) const - { - const SimdQuaternion& q1 = *this; - return SimdQuaternion(q1.x() - q2.x(), q1.y() - q2.y(), q1.z() - q2.z(), q1[3] - q2[3]); - } - - SIMD_FORCE_INLINE SimdQuaternion operator-() const - { - const SimdQuaternion& q2 = *this; - return SimdQuaternion( - q2.x(), - q2.y(), - q2.z(), - q2[3]); - } - - SIMD_FORCE_INLINE SimdQuaternion farthest( const SimdQuaternion& qd) const - { - SimdQuaternion diff,sum; - diff = *this - qd; - sum = *this + qd; - if( diff.dot(diff) > sum.dot(sum) ) - return qd; - return (-qd); - } - - SimdQuaternion slerp(const SimdQuaternion& q, const SimdScalar& t) const - { - SimdScalar theta = angle(q); - if (theta != SimdScalar(0.0)) - { - SimdScalar d = SimdScalar(1.0) / SimdSin(theta); - SimdScalar s0 = SimdSin((SimdScalar(1.0) - t) * theta); - SimdScalar s1 = SimdSin(t * theta); - return SimdQuaternion((m_x * s0 + q.x() * s1) * d, - (m_y * s0 + q.y() * s1) * d, - (m_z * s0 + q.z() * s1) * d, - (m_unusedW * s0 + q[3] * s1) * d); - } - else - { - return *this; - } - } - - - -}; - - - -SIMD_FORCE_INLINE SimdQuaternion -operator-(const SimdQuaternion& q) -{ - return SimdQuaternion(-q.x(), -q.y(), -q.z(), -q[3]); -} - - - - -SIMD_FORCE_INLINE SimdQuaternion -operator*(const SimdQuaternion& q1, const SimdQuaternion& q2) { - return SimdQuaternion(q1[3] * q2.x() + q1.x() * q2[3] + q1.y() * q2.z() - q1.z() * q2.y(), - q1[3] * q2.y() + q1.y() * q2[3] + q1.z() * q2.x() - q1.x() * q2.z(), - q1[3] * q2.z() + q1.z() * q2[3] + q1.x() * q2.y() - q1.y() * q2.x(), - q1[3] * q2[3] - q1.x() * q2.x() - q1.y() * q2.y() - q1.z() * q2.z()); -} - -SIMD_FORCE_INLINE SimdQuaternion -operator*(const SimdQuaternion& q, const SimdVector3& w) -{ - return SimdQuaternion( q[3] * w.x() + q.y() * w.z() - q.z() * w.y(), - q[3] * w.y() + q.z() * w.x() - q.x() * w.z(), - q[3] * w.z() + q.x() * w.y() - q.y() * w.x(), - -q.x() * w.x() - q.y() * w.y() - q.z() * w.z()); -} - -SIMD_FORCE_INLINE SimdQuaternion -operator*(const SimdVector3& w, const SimdQuaternion& q) -{ - return SimdQuaternion( w.x() * q[3] + w.y() * q.z() - w.z() * q.y(), - w.y() * q[3] + w.z() * q.x() - w.x() * q.z(), - w.z() * q[3] + w.x() * q.y() - w.y() * q.x(), - -w.x() * q.x() - w.y() * q.y() - w.z() * q.z()); -} - -SIMD_FORCE_INLINE SimdScalar -dot(const SimdQuaternion& q1, const SimdQuaternion& q2) -{ - return q1.dot(q2); -} - - -SIMD_FORCE_INLINE SimdScalar -length(const SimdQuaternion& q) -{ - return q.length(); -} - -SIMD_FORCE_INLINE SimdScalar -angle(const SimdQuaternion& q1, const SimdQuaternion& q2) -{ - return q1.angle(q2); -} - - -SIMD_FORCE_INLINE SimdQuaternion -inverse(const SimdQuaternion& q) -{ - return q.inverse(); -} - -SIMD_FORCE_INLINE SimdQuaternion -slerp(const SimdQuaternion& q1, const SimdQuaternion& q2, const SimdScalar& t) -{ - return q1.slerp(q2, t); -} - - -#endif - - - diff --git a/src/LinearMath/SimdScalar.h b/src/LinearMath/SimdScalar.h deleted file mode 100644 index e866382c0..000000000 --- a/src/LinearMath/SimdScalar.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. 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. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef SIMD___SCALAR_H -#define SIMD___SCALAR_H - -#include -#undef max - - - -#include -#include -#include - -#ifdef WIN32 - - #if defined(__MINGW32__) || defined(__CYGWIN__) - #define SIMD_FORCE_INLINE inline - #else - #pragma warning(disable:4530) - #pragma warning(disable:4996) - #define SIMD_FORCE_INLINE __forceinline - #endif //__MINGW32__ - - //#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a - #define ATTRIBUTE_ALIGNED16(a) a - #include - #define ASSERT assert -#else - - //non-windows systems - - #define SIMD_FORCE_INLINE inline - #define ATTRIBUTE_ALIGNED16(a) a - #ifndef assert - #include - #endif - #define ASSERT assert -#endif - - - -typedef float SimdScalar; - -#if defined (__sun) || defined (__sun__) || defined (__sparc) || defined (__APPLE__) -//use double float precision operation on those platforms for Blender - -SIMD_FORCE_INLINE SimdScalar SimdSqrt(SimdScalar x) { return sqrt(x); } -SIMD_FORCE_INLINE SimdScalar SimdFabs(SimdScalar x) { return fabs(x); } -SIMD_FORCE_INLINE SimdScalar SimdCos(SimdScalar x) { return cos(x); } -SIMD_FORCE_INLINE SimdScalar SimdSin(SimdScalar x) { return sin(x); } -SIMD_FORCE_INLINE SimdScalar SimdTan(SimdScalar x) { return tan(x); } -SIMD_FORCE_INLINE SimdScalar SimdAcos(SimdScalar x) { return acos(x); } -SIMD_FORCE_INLINE SimdScalar SimdAsin(SimdScalar x) { return asin(x); } -SIMD_FORCE_INLINE SimdScalar SimdAtan(SimdScalar x) { return atan(x); } -SIMD_FORCE_INLINE SimdScalar SimdAtan2(SimdScalar x, SimdScalar y) { return atan2(x, y); } -SIMD_FORCE_INLINE SimdScalar SimdExp(SimdScalar x) { return exp(x); } -SIMD_FORCE_INLINE SimdScalar SimdLog(SimdScalar x) { return log(x); } -SIMD_FORCE_INLINE SimdScalar SimdPow(SimdScalar x,SimdScalar y) { return pow(x,y); } - -#else - -SIMD_FORCE_INLINE SimdScalar SimdSqrt(SimdScalar x) { return sqrtf(x); } -SIMD_FORCE_INLINE SimdScalar SimdFabs(SimdScalar x) { return fabsf(x); } -SIMD_FORCE_INLINE SimdScalar SimdCos(SimdScalar x) { return cosf(x); } -SIMD_FORCE_INLINE SimdScalar SimdSin(SimdScalar x) { return sinf(x); } -SIMD_FORCE_INLINE SimdScalar SimdTan(SimdScalar x) { return tanf(x); } -SIMD_FORCE_INLINE SimdScalar SimdAcos(SimdScalar x) { return acosf(x); } -SIMD_FORCE_INLINE SimdScalar SimdAsin(SimdScalar x) { return asinf(x); } -SIMD_FORCE_INLINE SimdScalar SimdAtan(SimdScalar x) { return atanf(x); } -SIMD_FORCE_INLINE SimdScalar SimdAtan2(SimdScalar x, SimdScalar y) { return atan2f(x, y); } -SIMD_FORCE_INLINE SimdScalar SimdExp(SimdScalar x) { return expf(x); } -SIMD_FORCE_INLINE SimdScalar SimdLog(SimdScalar x) { return logf(x); } -SIMD_FORCE_INLINE SimdScalar SimdPow(SimdScalar x,SimdScalar y) { return powf(x,y); } - -#endif - - -const SimdScalar SIMD_2_PI = 6.283185307179586232f; -const SimdScalar SIMD_PI = SIMD_2_PI * SimdScalar(0.5f); -const SimdScalar SIMD_HALF_PI = SIMD_2_PI * SimdScalar(0.25f); -const SimdScalar SIMD_RADS_PER_DEG = SIMD_2_PI / SimdScalar(360.0f); -const SimdScalar SIMD_DEGS_PER_RAD = SimdScalar(360.0f) / SIMD_2_PI; -const SimdScalar SIMD_EPSILON = FLT_EPSILON; -const SimdScalar SIMD_INFINITY = FLT_MAX; - -SIMD_FORCE_INLINE bool SimdFuzzyZero(SimdScalar x) { return SimdFabs(x) < SIMD_EPSILON; } - -SIMD_FORCE_INLINE bool SimdEqual(SimdScalar a, SimdScalar eps) { - return (((a) <= eps) && !((a) < -eps)); -} -SIMD_FORCE_INLINE bool SimdGreaterEqual (SimdScalar a, SimdScalar eps) { - return (!((a) <= eps)); -} - -/*SIMD_FORCE_INLINE SimdScalar SimdCos(SimdScalar x) { return cosf(x); } -SIMD_FORCE_INLINE SimdScalar SimdSin(SimdScalar x) { return sinf(x); } -SIMD_FORCE_INLINE SimdScalar SimdTan(SimdScalar x) { return tanf(x); } -SIMD_FORCE_INLINE SimdScalar SimdAcos(SimdScalar x) { return acosf(x); } -SIMD_FORCE_INLINE SimdScalar SimdAsin(SimdScalar x) { return asinf(x); } -SIMD_FORCE_INLINE SimdScalar SimdAtan(SimdScalar x) { return atanf(x); } -SIMD_FORCE_INLINE SimdScalar SimdAtan2(SimdScalar x, SimdScalar y) { return atan2f(x, y); } -*/ - -SIMD_FORCE_INLINE int SimdSign(SimdScalar x) { - return x < 0.0f ? -1 : x > 0.0f ? 1 : 0; -} - -SIMD_FORCE_INLINE SimdScalar SimdRadians(SimdScalar x) { return x * SIMD_RADS_PER_DEG; } -SIMD_FORCE_INLINE SimdScalar SimdDegrees(SimdScalar x) { return x * SIMD_DEGS_PER_RAD; } - - - -#endif //SIMD___SCALAR_H diff --git a/src/LinearMath/SimdTransform.h b/src/LinearMath/SimdTransform.h deleted file mode 100644 index aad411901..000000000 --- a/src/LinearMath/SimdTransform.h +++ /dev/null @@ -1,283 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. 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. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef SimdTransform_H -#define SimdTransform_H - -#include "LinearMath/SimdVector3.h" -#include "LinearMath/SimdMatrix3x3.h" - - -#define IGNORE_TYPE 1 - -class SimdTransform { - - -public: - - enum { - TRANSLATION = 0x01, - ROTATION = 0x02, - RIGID = TRANSLATION | ROTATION, - SCALING = 0x04, - LINEAR = ROTATION | SCALING, - AFFINE = TRANSLATION | LINEAR - }; - - SimdTransform() {} - - explicit SIMD_FORCE_INLINE SimdTransform(const SimdQuaternion& q, - const SimdVector3& c = SimdVector3(SimdScalar(0), SimdScalar(0), SimdScalar(0))) - : m_basis(q), - m_origin(c) -#ifndef IGNORE_TYPE - , m_type(RIGID) -#endif //IGNORE_TYPE - {} - - explicit SIMD_FORCE_INLINE SimdTransform(const SimdMatrix3x3& b, - const SimdVector3& c = SimdVector3(SimdScalar(0), SimdScalar(0), SimdScalar(0)), - unsigned int type = AFFINE) - : m_basis(b), - m_origin(c) -#ifndef IGNORE_TYPE - , m_type(type) -#endif //IGNORE_TYPE - {} - - - SIMD_FORCE_INLINE void mult(const SimdTransform& t1, const SimdTransform& t2) { - m_basis = t1.m_basis * t2.m_basis; - m_origin = t1(t2.m_origin); -#ifndef IGNORE_TYPE - m_type = t1.m_type | t2.m_type; -#endif //IGNORE_TYPE - } - - void multInverseLeft(const SimdTransform& t1, const SimdTransform& t2) { - SimdVector3 v = t2.m_origin - t1.m_origin; -#ifndef IGNORE_TYPE - if (t1.m_type & SCALING) { - SimdMatrix3x3 inv = t1.m_basis.inverse(); - m_basis = inv * t2.m_basis; - m_origin = inv * v; - } - else -#else - { - m_basis = SimdMultTransposeLeft(t1.m_basis, t2.m_basis); - m_origin = v * t1.m_basis; -#endif //IGNORE_TYPE - } -#ifndef IGNORE_TYPE - m_type = t1.m_type | t2.m_type; -#endif //IGNORE_TYPE - } - - SIMD_FORCE_INLINE SimdVector3 operator()(const SimdVector3& x) const - { - return SimdVector3(m_basis[0].dot(x) + m_origin[0], - m_basis[1].dot(x) + m_origin[1], - m_basis[2].dot(x) + m_origin[2]); - } - - SIMD_FORCE_INLINE SimdVector3 operator*(const SimdVector3& x) const - { - return (*this)(x); - } - - SIMD_FORCE_INLINE SimdMatrix3x3& getBasis() { return m_basis; } - SIMD_FORCE_INLINE const SimdMatrix3x3& getBasis() const { return m_basis; } - - SIMD_FORCE_INLINE SimdVector3& getOrigin() { return m_origin; } - SIMD_FORCE_INLINE const SimdVector3& getOrigin() const { return m_origin; } - - SimdQuaternion getRotation() const { - SimdQuaternion q; - m_basis.getRotation(q); - return q; - } - template - void setValue(const Scalar2 *m) - { - m_basis.setValue(m); - m_origin.setValue(&m[12]); -#ifndef IGNORE_TYPE - m_type = AFFINE; -#endif //IGNORE_TYPE - } - - - void setFromOpenGLMatrix(const SimdScalar *m) - { - m_basis.setFromOpenGLSubMatrix(m); - m_origin[0] = m[12]; - m_origin[1] = m[13]; - m_origin[2] = m[14]; - } - - void getOpenGLMatrix(SimdScalar *m) const - { - m_basis.getOpenGLSubMatrix(m); - m[12] = m_origin[0]; - m[13] = m_origin[1]; - m[14] = m_origin[2]; - m[15] = SimdScalar(1.0f); - } - - SIMD_FORCE_INLINE void setOrigin(const SimdVector3& origin) - { - m_origin = origin; -#ifndef IGNORE_TYPE - m_type |= TRANSLATION; -#endif //IGNORE_TYPE - } - - SIMD_FORCE_INLINE SimdVector3 invXform(const SimdVector3& inVec) const; - - - - SIMD_FORCE_INLINE void setBasis(const SimdMatrix3x3& basis) - { - m_basis = basis; -#ifndef IGNORE_TYPE - m_type |= LINEAR; -#endif //IGNORE_TYPE - } - - SIMD_FORCE_INLINE void setRotation(const SimdQuaternion& q) - { - m_basis.setRotation(q); -#ifndef IGNORE_TYPE - m_type = (m_type & ~LINEAR) | ROTATION; -#endif //IGNORE_TYPE - } - - SIMD_FORCE_INLINE void scale(const SimdVector3& scaling) - { - m_basis = m_basis.scaled(scaling); -#ifndef IGNORE_TYPE - m_type |= SCALING; -#endif //IGNORE_TYPE - } - - void setIdentity() - { - m_basis.setIdentity(); - m_origin.setValue(SimdScalar(0.0), SimdScalar(0.0), SimdScalar(0.0)); -#ifndef IGNORE_TYPE - m_type = 0x0; -#endif //IGNORE_TYPE - } - - SIMD_FORCE_INLINE bool isIdentity() const { -#ifdef IGNORE_TYPE - return false; -#else - return m_type == 0x0; -#endif - } - - SimdTransform& operator*=(const SimdTransform& t) - { - m_origin += m_basis * t.m_origin; - m_basis *= t.m_basis; -#ifndef IGNORE_TYPE - m_type |= t.m_type; -#endif //IGNORE_TYPE - return *this; - } - - SimdTransform inverse() const - { -#ifdef IGNORE_TYPE - SimdMatrix3x3 inv = m_basis.transpose(); - return SimdTransform(inv, inv * -m_origin, 0); -#else - if (m_type) - { - SimdMatrix3x3 inv = (m_type & SCALING) ? - m_basis.inverse() : - m_basis.transpose(); - - return SimdTransform(inv, inv * -m_origin, m_type); - } - - return *this; -#endif //IGNORE_TYPE - } - - SimdTransform inverseTimes(const SimdTransform& t) const; - - SimdTransform operator*(const SimdTransform& t) const; - -private: - - SimdMatrix3x3 m_basis; - SimdVector3 m_origin; -#ifndef IGNORE_TYPE - unsigned int m_type; -#endif //IGNORE_TYPE -}; - - -SIMD_FORCE_INLINE SimdVector3 -SimdTransform::invXform(const SimdVector3& inVec) const -{ - SimdVector3 v = inVec - m_origin; - return (m_basis.transpose() * v); -} - -SIMD_FORCE_INLINE SimdTransform -SimdTransform::inverseTimes(const SimdTransform& t) const -{ - SimdVector3 v = t.getOrigin() - m_origin; -#ifndef IGNORE_TYPE - if (m_type & SCALING) - { - SimdMatrix3x3 inv = m_basis.inverse(); - return SimdTransform(inv * t.getBasis(), inv * v, - m_type | t.m_type); - } - else -#else - { - return SimdTransform(m_basis.transposeTimes(t.m_basis), - v * m_basis, 0); - } -#endif //IGNORE_TYPE -} - -SIMD_FORCE_INLINE SimdTransform -SimdTransform::operator*(const SimdTransform& t) const -{ - return SimdTransform(m_basis * t.m_basis, - (*this)(t.m_origin), -#ifndef IGNORE_TYPE - m_type | t.m_type); -#else - 0); -#endif -} - - - -#endif - - - - - diff --git a/src/LinearMath/SimdVector3.h b/src/LinearMath/SimdVector3.h deleted file mode 100644 index b44ef6c09..000000000 --- a/src/LinearMath/SimdVector3.h +++ /dev/null @@ -1,403 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. 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. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef SIMD__VECTOR3_H -#define SIMD__VECTOR3_H - -#include "SimdQuadWord.h" - - -///SimdVector3 is 16byte aligned, and has an extra unused component m_w -///this extra component can be used by derived classes (Quaternion?) or by user -class SimdVector3 : public SimdQuadWord { - - -public: - SIMD_FORCE_INLINE SimdVector3() {} - - - - SIMD_FORCE_INLINE SimdVector3(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z) - :SimdQuadWord(x,y,z,0.f) - { - } - -// SIMD_FORCE_INLINE SimdVector3(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z,const SimdScalar& w) -// : SimdQuadWord(x,y,z,w) -// { -// } - - - - SIMD_FORCE_INLINE SimdVector3& operator+=(const SimdVector3& v) - { - m_x += v.x(); m_y += v.y(); m_z += v.z(); - return *this; - } - - - - SIMD_FORCE_INLINE SimdVector3& operator-=(const SimdVector3& v) - { - m_x -= v.x(); m_y -= v.y(); m_z -= v.z(); - return *this; - } - - SIMD_FORCE_INLINE SimdVector3& operator*=(const SimdScalar& s) - { - m_x *= s; m_y *= s; m_z *= s; - return *this; - } - - SIMD_FORCE_INLINE SimdVector3& operator/=(const SimdScalar& s) - { - assert(s != SimdScalar(0.0)); - return *this *= SimdScalar(1.0) / s; - } - - SIMD_FORCE_INLINE SimdScalar dot(const SimdVector3& v) const - { - return m_x * v.x() + m_y * v.y() + m_z * v.z(); - } - - SIMD_FORCE_INLINE SimdScalar length2() const - { - return dot(*this); - } - - SIMD_FORCE_INLINE SimdScalar length() const - { - return SimdSqrt(length2()); - } - - SIMD_FORCE_INLINE SimdScalar distance2(const SimdVector3& v) const; - - SIMD_FORCE_INLINE SimdScalar distance(const SimdVector3& v) const; - - SIMD_FORCE_INLINE SimdVector3& normalize() - { - return *this /= length(); - } - - SIMD_FORCE_INLINE SimdVector3 normalized() const; - - SIMD_FORCE_INLINE SimdVector3 rotate( const SimdVector3& wAxis, const SimdScalar angle ); - - SIMD_FORCE_INLINE SimdScalar angle(const SimdVector3& v) const - { - SimdScalar s = SimdSqrt(length2() * v.length2()); - assert(s != SimdScalar(0.0)); - return SimdAcos(dot(v) / s); - } - - SIMD_FORCE_INLINE SimdVector3 absolute() const - { - return SimdVector3( - SimdFabs(m_x), - SimdFabs(m_y), - SimdFabs(m_z)); - } - - SIMD_FORCE_INLINE SimdVector3 cross(const SimdVector3& v) const - { - return SimdVector3( - m_y * v.z() - m_z * v.y(), - m_z * v.x() - m_x * v.z(), - m_x * v.y() - m_y * v.x()); - } - - SIMD_FORCE_INLINE SimdScalar triple(const SimdVector3& v1, const SimdVector3& v2) const - { - return m_x * (v1.y() * v2.z() - v1.z() * v2.y()) + - m_y * (v1.z() * v2.x() - v1.x() * v2.z()) + - m_z * (v1.x() * v2.y() - v1.y() * v2.x()); - } - - SIMD_FORCE_INLINE int minAxis() const - { - return m_x < m_y ? (m_x < m_z ? 0 : 2) : (m_y < m_z ? 1 : 2); - } - - SIMD_FORCE_INLINE int maxAxis() const - { - return m_x < m_y ? (m_y < m_z ? 2 : 1) : (m_x < m_z ? 2 : 0); - } - - SIMD_FORCE_INLINE int furthestAxis() const - { - return absolute().minAxis(); - } - - SIMD_FORCE_INLINE int closestAxis() const - { - return absolute().maxAxis(); - } - - SIMD_FORCE_INLINE void setInterpolate3(const SimdVector3& v0, const SimdVector3& v1, SimdScalar rt) - { - SimdScalar s = 1.0f - rt; - m_x = s * v0[0] + rt * v1.x(); - m_y = s * v0[1] + rt * v1.y(); - m_z = s * v0[2] + rt * v1.z(); - //don't do the unused w component - // m_co[3] = s * v0[3] + rt * v1[3]; - } - - SIMD_FORCE_INLINE SimdVector3 lerp(const SimdVector3& v, const SimdScalar& t) const - { - return SimdVector3(m_x + (v.x() - m_x) * t, - m_y + (v.y() - m_y) * t, - m_z + (v.z() - m_z) * t); - } - - - SIMD_FORCE_INLINE SimdVector3& operator*=(const SimdVector3& v) - { - m_x *= v.x(); m_y *= v.y(); m_z *= v.z(); - return *this; - } - - - -}; - -SIMD_FORCE_INLINE SimdVector3 -operator+(const SimdVector3& v1, const SimdVector3& v2) -{ - return SimdVector3(v1.x() + v2.x(), v1.y() + v2.y(), v1.z() + v2.z()); -} - -SIMD_FORCE_INLINE SimdVector3 -operator*(const SimdVector3& v1, const SimdVector3& v2) -{ - return SimdVector3(v1.x() * v2.x(), v1.y() * v2.y(), v1.z() * v2.z()); -} - -SIMD_FORCE_INLINE SimdVector3 -operator-(const SimdVector3& v1, const SimdVector3& v2) -{ - return SimdVector3(v1.x() - v2.x(), v1.y() - v2.y(), v1.z() - v2.z()); -} - -SIMD_FORCE_INLINE SimdVector3 -operator-(const SimdVector3& v) -{ - return SimdVector3(-v.x(), -v.y(), -v.z()); -} - -SIMD_FORCE_INLINE SimdVector3 -operator*(const SimdVector3& v, const SimdScalar& s) -{ - return SimdVector3(v.x() * s, v.y() * s, v.z() * s); -} - -SIMD_FORCE_INLINE SimdVector3 -operator*(const SimdScalar& s, const SimdVector3& v) -{ - return v * s; -} - -SIMD_FORCE_INLINE SimdVector3 -operator/(const SimdVector3& v, const SimdScalar& s) -{ - assert(s != SimdScalar(0.0)); - return v * (SimdScalar(1.0) / s); -} - -SIMD_FORCE_INLINE SimdVector3 -operator/(const SimdVector3& v1, const SimdVector3& v2) -{ - return SimdVector3(v1.x() / v2.x(),v1.y() / v2.y(),v1.z() / v2.z()); -} - -SIMD_FORCE_INLINE SimdScalar -dot(const SimdVector3& v1, const SimdVector3& v2) -{ - return v1.dot(v2); -} - - - -SIMD_FORCE_INLINE SimdScalar -distance2(const SimdVector3& v1, const SimdVector3& v2) -{ - return v1.distance2(v2); -} - - -SIMD_FORCE_INLINE SimdScalar -distance(const SimdVector3& v1, const SimdVector3& v2) -{ - return v1.distance(v2); -} - -SIMD_FORCE_INLINE SimdScalar -angle(const SimdVector3& v1, const SimdVector3& v2) -{ - return v1.angle(v2); -} - -SIMD_FORCE_INLINE SimdVector3 -cross(const SimdVector3& v1, const SimdVector3& v2) -{ - return v1.cross(v2); -} - -SIMD_FORCE_INLINE SimdScalar -triple(const SimdVector3& v1, const SimdVector3& v2, const SimdVector3& v3) -{ - return v1.triple(v2, v3); -} - -SIMD_FORCE_INLINE SimdVector3 -lerp(const SimdVector3& v1, const SimdVector3& v2, const SimdScalar& t) -{ - return v1.lerp(v2, t); -} - - -SIMD_FORCE_INLINE bool operator==(const SimdVector3& p1, const SimdVector3& p2) -{ - return p1[0] == p2[0] && p1[1] == p2[1] && p1[2] == p2[2]; -} - -SIMD_FORCE_INLINE SimdScalar SimdVector3::distance2(const SimdVector3& v) const -{ - return (v - *this).length2(); -} - -SIMD_FORCE_INLINE SimdScalar SimdVector3::distance(const SimdVector3& v) const -{ - return (v - *this).length(); -} - -SIMD_FORCE_INLINE SimdVector3 SimdVector3::normalized() const -{ - return *this / length(); -} - -SIMD_FORCE_INLINE SimdVector3 SimdVector3::rotate( const SimdVector3& wAxis, const SimdScalar angle ) -{ - // wAxis must be a unit lenght vector - - SimdVector3 o = wAxis * wAxis.dot( *this ); - SimdVector3 x = *this - o; - SimdVector3 y; - - y = wAxis.cross( *this ); - - return ( o + x * SimdCos( angle ) + y * SimdSin( angle ) ); -} - -class SimdVector4 : public SimdVector3 -{ -public: - - SIMD_FORCE_INLINE SimdVector4() {} - - - SIMD_FORCE_INLINE SimdVector4(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z,const SimdScalar& w) - : SimdVector3(x,y,z) - { - m_unusedW = w; - } - - - SIMD_FORCE_INLINE SimdVector4 absolute4() const - { - return SimdVector4( - SimdFabs(m_x), - SimdFabs(m_y), - SimdFabs(m_z), - SimdFabs(m_unusedW)); - } - - - - float getW() const { return m_unusedW;} - - - SIMD_FORCE_INLINE int maxAxis4() const - { - int maxIndex = -1; - float maxVal = -1e30f; - if (m_x > maxVal) - { - maxIndex = 0; - maxVal = m_x; - } - if (m_y > maxVal) - { - maxIndex = 1; - maxVal = m_y; - } - if (m_z > maxVal) - { - maxIndex = 2; - maxVal = m_z; - } - if (m_unusedW > maxVal) - { - maxIndex = 3; - maxVal = m_unusedW; - } - - - - - return maxIndex; - - } - - - SIMD_FORCE_INLINE int minAxis4() const - { - int minIndex = -1; - float minVal = 1e30f; - if (m_x < minVal) - { - minIndex = 0; - minVal = m_x; - } - if (m_y < minVal) - { - minIndex = 1; - minVal = m_y; - } - if (m_z < minVal) - { - minIndex = 2; - minVal = m_z; - } - if (m_unusedW < minVal) - { - minIndex = 3; - minVal = m_unusedW; - } - - return minIndex; - - } - - - SIMD_FORCE_INLINE int closestAxis4() const - { - return absolute4().maxAxis4(); - } - -}; - -#endif //SIMD__VECTOR3_H diff --git a/src/LinearMath/GenAabbUtil2.h b/src/LinearMath/btAabbUtil2.h similarity index 59% rename from src/LinearMath/GenAabbUtil2.h rename to src/LinearMath/btAabbUtil2.h index 4937e760a..1cc7d4ebd 100644 --- a/src/LinearMath/GenAabbUtil2.h +++ b/src/LinearMath/btAabbUtil2.h @@ -17,15 +17,15 @@ subject to the following restrictions: #ifndef AABB_UTIL2 #define AABB_UTIL2 -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" -#define SimdMin(a,b) ((a < b ? a : b)) -#define SimdMax(a,b) ((a > b ? a : b)) +#define btMin(a,b) ((a < b ? a : b)) +#define btMax(a,b) ((a > b ? a : b)) /// conservative test for overlap between two aabbs -SIMD_FORCE_INLINE bool TestAabbAgainstAabb2(const SimdVector3 &aabbMin1, const SimdVector3 &aabbMax1, - const SimdVector3 &aabbMin2, const SimdVector3 &aabbMax2) +SIMD_FORCE_INLINE bool TestAabbAgainstAabb2(const btVector3 &aabbMin1, const btVector3 &aabbMax1, + const btVector3 &aabbMin2, const btVector3 &aabbMax2) { bool overlap = true; overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap; @@ -35,21 +35,21 @@ SIMD_FORCE_INLINE bool TestAabbAgainstAabb2(const SimdVector3 &aabbMin1, const S } /// conservative test for overlap between triangle and aabb -SIMD_FORCE_INLINE bool TestTriangleAgainstAabb2(const SimdVector3 *vertices, - const SimdVector3 &aabbMin, const SimdVector3 &aabbMax) +SIMD_FORCE_INLINE bool TestTriangleAgainstAabb2(const btVector3 *vertices, + const btVector3 &aabbMin, const btVector3 &aabbMax) { - const SimdVector3 &p1 = vertices[0]; - const SimdVector3 &p2 = vertices[1]; - const SimdVector3 &p3 = vertices[2]; + const btVector3 &p1 = vertices[0]; + const btVector3 &p2 = vertices[1]; + const btVector3 &p3 = vertices[2]; - if (SimdMin(SimdMin(p1[0], p2[0]), p3[0]) > aabbMax[0]) return false; - if (SimdMax(SimdMax(p1[0], p2[0]), p3[0]) < aabbMin[0]) return false; + if (btMin(btMin(p1[0], p2[0]), p3[0]) > aabbMax[0]) return false; + if (btMax(btMax(p1[0], p2[0]), p3[0]) < aabbMin[0]) return false; - if (SimdMin(SimdMin(p1[2], p2[2]), p3[2]) > aabbMax[2]) return false; - if (SimdMax(SimdMax(p1[2], p2[2]), p3[2]) < aabbMin[2]) return false; + if (btMin(btMin(p1[2], p2[2]), p3[2]) > aabbMax[2]) return false; + if (btMax(btMax(p1[2], p2[2]), p3[2]) < aabbMin[2]) return false; - if (SimdMin(SimdMin(p1[1], p2[1]), p3[1]) > aabbMax[1]) return false; - if (SimdMax(SimdMax(p1[1], p2[1]), p3[1]) < aabbMin[1]) return false; + if (btMin(btMin(p1[1], p2[1]), p3[1]) > aabbMax[1]) return false; + if (btMax(btMax(p1[1], p2[1]), p3[1]) < aabbMin[1]) return false; return true; } diff --git a/src/LinearMath/GenIDebugDraw.h b/src/LinearMath/btIDebugDraw.h similarity index 85% rename from src/LinearMath/GenIDebugDraw.h rename to src/LinearMath/btIDebugDraw.h index 8e3e96a56..caa43fac4 100644 --- a/src/LinearMath/GenIDebugDraw.h +++ b/src/LinearMath/btIDebugDraw.h @@ -28,10 +28,10 @@ DEALINGS IN THE SOFTWARE. #ifndef IDEBUG_DRAW__H #define IDEBUG_DRAW__H -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" -class IDebugDraw +class btIDebugDraw { public: @@ -52,11 +52,11 @@ class IDebugDraw DBG_MAX_DEBUG_DRAW_MODE }; - virtual ~IDebugDraw() {}; + virtual ~btIDebugDraw() {}; - virtual void DrawLine(const SimdVector3& from,const SimdVector3& to,const SimdVector3& color)=0; + virtual void DrawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0; - virtual void DrawContactPoint(const SimdVector3& PointOnB,const SimdVector3& normalOnB,float distance,int lifeTime,const SimdVector3& color)=0; + virtual void DrawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)=0; virtual void SetDebugMode(int debugMode) =0; diff --git a/src/LinearMath/GenList.h b/src/LinearMath/btList.h similarity index 66% rename from src/LinearMath/GenList.h rename to src/LinearMath/btList.h index 9fc2a5233..c87b47faf 100644 --- a/src/LinearMath/GenList.h +++ b/src/LinearMath/btList.h @@ -17,25 +17,25 @@ subject to the following restrictions: #ifndef GEN_LIST_H #define GEN_LIST_H -class GEN_Link { +class btGEN_Link { public: - GEN_Link() : m_next(0), m_prev(0) {} - GEN_Link(GEN_Link *next, GEN_Link *prev) : m_next(next), m_prev(prev) {} + btGEN_Link() : m_next(0), m_prev(0) {} + btGEN_Link(btGEN_Link *next, btGEN_Link *prev) : m_next(next), m_prev(prev) {} - GEN_Link *getNext() const { return m_next; } - GEN_Link *getPrev() const { return m_prev; } + btGEN_Link *getNext() const { return m_next; } + btGEN_Link *getPrev() const { return m_prev; } bool isHead() const { return m_prev == 0; } bool isTail() const { return m_next == 0; } - void insertBefore(GEN_Link *link) { + void insertBefore(btGEN_Link *link) { m_next = link; m_prev = link->m_prev; m_next->m_prev = this; m_prev->m_next = this; } - void insertAfter(GEN_Link *link) { + void insertAfter(btGEN_Link *link) { m_next = link->m_next; m_prev = link; m_next->m_prev = this; @@ -48,23 +48,23 @@ public: } private: - GEN_Link *m_next; - GEN_Link *m_prev; + btGEN_Link *m_next; + btGEN_Link *m_prev; }; -class GEN_List { +class btGEN_List { public: - GEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {} + btGEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {} - GEN_Link *getHead() const { return m_head.getNext(); } - GEN_Link *getTail() const { return m_tail.getPrev(); } + btGEN_Link *getHead() const { return m_head.getNext(); } + btGEN_Link *getTail() const { return m_tail.getPrev(); } - void addHead(GEN_Link *link) { link->insertAfter(&m_head); } - void addTail(GEN_Link *link) { link->insertBefore(&m_tail); } + void addHead(btGEN_Link *link) { link->insertAfter(&m_head); } + void addTail(btGEN_Link *link) { link->insertBefore(&m_tail); } private: - GEN_Link m_head; - GEN_Link m_tail; + btGEN_Link m_head; + btGEN_Link m_tail; }; #endif diff --git a/src/LinearMath/btMatrix3x3.h b/src/LinearMath/btMatrix3x3.h new file mode 100644 index 000000000..c3cc90a82 --- /dev/null +++ b/src/LinearMath/btMatrix3x3.h @@ -0,0 +1,395 @@ +/* +Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. 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. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + + +#ifndef btMatrix3x3_H +#define btMatrix3x3_H + +#include "LinearMath/btScalar.h" + +#include "LinearMath/btVector3.h" +#include "LinearMath/btQuaternion.h" + + +class btMatrix3x3 { + public: + btMatrix3x3 () {} + +// explicit btMatrix3x3(const btScalar *m) { setFromOpenGLSubMatrix(m); } + + explicit btMatrix3x3(const btQuaternion& q) { setRotation(q); } + /* + template + Matrix3x3(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) + { + setEulerYPR(yaw, pitch, roll); + } + */ + btMatrix3x3(const btScalar& xx, const btScalar& xy, const btScalar& xz, + const btScalar& yx, const btScalar& yy, const btScalar& yz, + const btScalar& zx, const btScalar& zy, const btScalar& zz) + { + setValue(xx, xy, xz, + yx, yy, yz, + zx, zy, zz); + } + + btVector3 getColumn(int i) const + { + return btVector3(m_el[0][i],m_el[1][i],m_el[2][i]); + } + + const btVector3& getRow(int i) const + { + return m_el[i]; + } + + + SIMD_FORCE_INLINE btVector3& operator[](int i) + { + assert(0 <= i && i < 3); + return m_el[i]; + } + + const btVector3& operator[](int i) const + { + assert(0 <= i && i < 3); + return m_el[i]; + } + + btMatrix3x3& operator*=(const btMatrix3x3& m); + + + void setFromOpenGLSubMatrix(const btScalar *m) + { + m_el[0][0] = (m[0]); + m_el[1][0] = (m[1]); + m_el[2][0] = (m[2]); + m_el[0][1] = (m[4]); + m_el[1][1] = (m[5]); + m_el[2][1] = (m[6]); + m_el[0][2] = (m[8]); + m_el[1][2] = (m[9]); + m_el[2][2] = (m[10]); + } + + void setValue(const btScalar& xx, const btScalar& xy, const btScalar& xz, + const btScalar& yx, const btScalar& yy, const btScalar& yz, + const btScalar& zx, const btScalar& zy, const btScalar& zz) + { + m_el[0][0] = btScalar(xx); + m_el[0][1] = btScalar(xy); + m_el[0][2] = btScalar(xz); + m_el[1][0] = btScalar(yx); + m_el[1][1] = btScalar(yy); + m_el[1][2] = btScalar(yz); + m_el[2][0] = btScalar(zx); + m_el[2][1] = btScalar(zy); + m_el[2][2] = btScalar(zz); + } + + void setRotation(const btQuaternion& q) + { + btScalar d = q.length2(); + assert(d != btScalar(0.0)); + btScalar s = btScalar(2.0) / d; + btScalar xs = q[0] * s, ys = q[1] * s, zs = q[2] * s; + btScalar wx = q[3] * xs, wy = q[3] * ys, wz = q[3] * zs; + btScalar xx = q[0] * xs, xy = q[0] * ys, xz = q[0] * zs; + btScalar yy = q[1] * ys, yz = q[1] * zs, zz = q[2] * zs; + setValue(btScalar(1.0) - (yy + zz), xy - wz, xz + wy, + xy + wz, btScalar(1.0) - (xx + zz), yz - wx, + xz - wy, yz + wx, btScalar(1.0) - (xx + yy)); + } + + + + void setEulerYPR(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) + { + + btScalar cy(btCos(yaw)); + btScalar sy(btSin(yaw)); + btScalar cp(btCos(pitch)); + btScalar sp(btSin(pitch)); + btScalar cr(btCos(roll)); + btScalar sr(btSin(roll)); + btScalar cc = cy * cr; + btScalar cs = cy * sr; + btScalar sc = sy * cr; + btScalar ss = sy * sr; + setValue(cc - sp * ss, -cs - sp * sc, -sy * cp, + cp * sr, cp * cr, -sp, + sc + sp * cs, -ss + sp * cc, cy * cp); + + } + + /** + * setEulerZYX + * @param euler a const reference to a btVector3 of euler angles + * These angles are used to produce a rotation matrix. The euler + * angles are applied in ZYX order. I.e a vector is first rotated + * about X then Y and then Z + **/ + + void setEulerZYX(btScalar eulerX,btScalar eulerY,btScalar eulerZ) { + btScalar ci ( btCos(eulerX)); + btScalar cj ( btCos(eulerY)); + btScalar ch ( btCos(eulerZ)); + btScalar si ( btSin(eulerX)); + btScalar sj ( btSin(eulerY)); + btScalar sh ( btSin(eulerZ)); + btScalar cc = ci * ch; + btScalar cs = ci * sh; + btScalar sc = si * ch; + btScalar ss = si * sh; + + setValue(cj * ch, sj * sc - cs, sj * cc + ss, + cj * sh, sj * ss + cc, sj * cs - sc, + -sj, cj * si, cj * ci); + } + + void setIdentity() + { + setValue(btScalar(1.0), btScalar(0.0), btScalar(0.0), + btScalar(0.0), btScalar(1.0), btScalar(0.0), + btScalar(0.0), btScalar(0.0), btScalar(1.0)); + } + + void getOpenGLSubMatrix(btScalar *m) const + { + m[0] = btScalar(m_el[0][0]); + m[1] = btScalar(m_el[1][0]); + m[2] = btScalar(m_el[2][0]); + m[3] = btScalar(0.0); + m[4] = btScalar(m_el[0][1]); + m[5] = btScalar(m_el[1][1]); + m[6] = btScalar(m_el[2][1]); + m[7] = btScalar(0.0); + m[8] = btScalar(m_el[0][2]); + m[9] = btScalar(m_el[1][2]); + m[10] = btScalar(m_el[2][2]); + m[11] = btScalar(0.0); + } + + void getRotation(btQuaternion& q) const + { + btScalar trace = m_el[0][0] + m_el[1][1] + m_el[2][2]; + + if (trace > btScalar(0.0)) + { + btScalar s = btSqrt(trace + btScalar(1.0)); + q[3] = s * btScalar(0.5); + s = btScalar(0.5) / s; + + q[0] = (m_el[2][1] - m_el[1][2]) * s; + q[1] = (m_el[0][2] - m_el[2][0]) * s; + q[2] = (m_el[1][0] - m_el[0][1]) * s; + } + else + { + int i = m_el[0][0] < m_el[1][1] ? + (m_el[1][1] < m_el[2][2] ? 2 : 1) : + (m_el[0][0] < m_el[2][2] ? 2 : 0); + int j = (i + 1) % 3; + int k = (i + 2) % 3; + + btScalar s = btSqrt(m_el[i][i] - m_el[j][j] - m_el[k][k] + btScalar(1.0)); + q[i] = s * btScalar(0.5); + s = btScalar(0.5) / s; + + q[3] = (m_el[k][j] - m_el[j][k]) * s; + q[j] = (m_el[j][i] + m_el[i][j]) * s; + q[k] = (m_el[k][i] + m_el[i][k]) * s; + } + } + + + + void getEuler(btScalar& yaw, btScalar& pitch, btScalar& roll) const + { + pitch = btScalar(btAsin(-m_el[2][0])); + if (pitch < SIMD_2_PI) + { + if (pitch > SIMD_2_PI) + { + yaw = btScalar(btAtan2(m_el[1][0], m_el[0][0])); + roll = btScalar(btAtan2(m_el[2][1], m_el[2][2])); + } + else + { + yaw = btScalar(-btAtan2(-m_el[0][1], m_el[0][2])); + roll = btScalar(0.0); + } + } + else + { + yaw = btScalar(btAtan2(-m_el[0][1], m_el[0][2])); + roll = btScalar(0.0); + } + } + + btVector3 getScaling() const + { + return btVector3(m_el[0][0] * m_el[0][0] + m_el[1][0] * m_el[1][0] + m_el[2][0] * m_el[2][0], + m_el[0][1] * m_el[0][1] + m_el[1][1] * m_el[1][1] + m_el[2][1] * m_el[2][1], + m_el[0][2] * m_el[0][2] + m_el[1][2] * m_el[1][2] + m_el[2][2] * m_el[2][2]); + } + + + btMatrix3x3 scaled(const btVector3& s) const + { + return btMatrix3x3(m_el[0][0] * s[0], m_el[0][1] * s[1], m_el[0][2] * s[2], + m_el[1][0] * s[0], m_el[1][1] * s[1], m_el[1][2] * s[2], + m_el[2][0] * s[0], m_el[2][1] * s[1], m_el[2][2] * s[2]); + } + + btScalar determinant() const; + btMatrix3x3 adjoint() const; + btMatrix3x3 absolute() const; + btMatrix3x3 transpose() const; + btMatrix3x3 inverse() const; + + btMatrix3x3 transposeTimes(const btMatrix3x3& m) const; + btMatrix3x3 timesTranspose(const btMatrix3x3& m) const; + + btScalar tdot(int c, const btVector3& v) const + { + return m_el[0][c] * v[0] + m_el[1][c] * v[1] + m_el[2][c] * v[2]; + } + + protected: + btScalar cofac(int r1, int c1, int r2, int c2) const + { + return m_el[r1][c1] * m_el[r2][c2] - m_el[r1][c2] * m_el[r2][c1]; + } + + btVector3 m_el[3]; + }; + + SIMD_FORCE_INLINE btMatrix3x3& + btMatrix3x3::operator*=(const btMatrix3x3& m) + { + setValue(m.tdot(0, m_el[0]), m.tdot(1, m_el[0]), m.tdot(2, m_el[0]), + m.tdot(0, m_el[1]), m.tdot(1, m_el[1]), m.tdot(2, m_el[1]), + m.tdot(0, m_el[2]), m.tdot(1, m_el[2]), m.tdot(2, m_el[2])); + return *this; + } + + SIMD_FORCE_INLINE btScalar + btMatrix3x3::determinant() const + { + return triple((*this)[0], (*this)[1], (*this)[2]); + } + + + SIMD_FORCE_INLINE btMatrix3x3 + btMatrix3x3::absolute() const + { + return btMatrix3x3( + btFabs(m_el[0][0]), btFabs(m_el[0][1]), btFabs(m_el[0][2]), + btFabs(m_el[1][0]), btFabs(m_el[1][1]), btFabs(m_el[1][2]), + btFabs(m_el[2][0]), btFabs(m_el[2][1]), btFabs(m_el[2][2])); + } + + SIMD_FORCE_INLINE btMatrix3x3 + btMatrix3x3::transpose() const + { + return btMatrix3x3(m_el[0][0], m_el[1][0], m_el[2][0], + m_el[0][1], m_el[1][1], m_el[2][1], + m_el[0][2], m_el[1][2], m_el[2][2]); + } + + SIMD_FORCE_INLINE btMatrix3x3 + btMatrix3x3::adjoint() const + { + return btMatrix3x3(cofac(1, 1, 2, 2), cofac(0, 2, 2, 1), cofac(0, 1, 1, 2), + cofac(1, 2, 2, 0), cofac(0, 0, 2, 2), cofac(0, 2, 1, 0), + cofac(1, 0, 2, 1), cofac(0, 1, 2, 0), cofac(0, 0, 1, 1)); + } + + SIMD_FORCE_INLINE btMatrix3x3 + btMatrix3x3::inverse() const + { + btVector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1)); + btScalar det = (*this)[0].dot(co); + assert(det != btScalar(0.0f)); + btScalar s = btScalar(1.0f) / det; + return btMatrix3x3(co[0] * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s, + co[1] * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s, + co[2] * s, cofac(0, 1, 2, 0) * s, cofac(0, 0, 1, 1) * s); + } + + SIMD_FORCE_INLINE btMatrix3x3 + btMatrix3x3::transposeTimes(const btMatrix3x3& m) const + { + return btMatrix3x3( + m_el[0][0] * m[0][0] + m_el[1][0] * m[1][0] + m_el[2][0] * m[2][0], + m_el[0][0] * m[0][1] + m_el[1][0] * m[1][1] + m_el[2][0] * m[2][1], + m_el[0][0] * m[0][2] + m_el[1][0] * m[1][2] + m_el[2][0] * m[2][2], + m_el[0][1] * m[0][0] + m_el[1][1] * m[1][0] + m_el[2][1] * m[2][0], + m_el[0][1] * m[0][1] + m_el[1][1] * m[1][1] + m_el[2][1] * m[2][1], + m_el[0][1] * m[0][2] + m_el[1][1] * m[1][2] + m_el[2][1] * m[2][2], + m_el[0][2] * m[0][0] + m_el[1][2] * m[1][0] + m_el[2][2] * m[2][0], + m_el[0][2] * m[0][1] + m_el[1][2] * m[1][1] + m_el[2][2] * m[2][1], + m_el[0][2] * m[0][2] + m_el[1][2] * m[1][2] + m_el[2][2] * m[2][2]); + } + + SIMD_FORCE_INLINE btMatrix3x3 + btMatrix3x3::timesTranspose(const btMatrix3x3& m) const + { + return btMatrix3x3( + m_el[0].dot(m[0]), m_el[0].dot(m[1]), m_el[0].dot(m[2]), + m_el[1].dot(m[0]), m_el[1].dot(m[1]), m_el[1].dot(m[2]), + m_el[2].dot(m[0]), m_el[2].dot(m[1]), m_el[2].dot(m[2])); + + } + + SIMD_FORCE_INLINE btVector3 + operator*(const btMatrix3x3& m, const btVector3& v) + { + return btVector3(m[0].dot(v), m[1].dot(v), m[2].dot(v)); + } + + + SIMD_FORCE_INLINE btVector3 + operator*(const btVector3& v, const btMatrix3x3& m) + { + return btVector3(m.tdot(0, v), m.tdot(1, v), m.tdot(2, v)); + } + + SIMD_FORCE_INLINE btMatrix3x3 + operator*(const btMatrix3x3& m1, const btMatrix3x3& m2) + { + return btMatrix3x3( + m2.tdot(0, m1[0]), m2.tdot(1, m1[0]), m2.tdot(2, m1[0]), + m2.tdot(0, m1[1]), m2.tdot(1, m1[1]), m2.tdot(2, m1[1]), + m2.tdot(0, m1[2]), m2.tdot(1, m1[2]), m2.tdot(2, m1[2])); + } + + + SIMD_FORCE_INLINE btMatrix3x3 btMultTransposeLeft(const btMatrix3x3& m1, const btMatrix3x3& m2) { + return btMatrix3x3( + m1[0][0] * m2[0][0] + m1[1][0] * m2[1][0] + m1[2][0] * m2[2][0], + m1[0][0] * m2[0][1] + m1[1][0] * m2[1][1] + m1[2][0] * m2[2][1], + m1[0][0] * m2[0][2] + m1[1][0] * m2[1][2] + m1[2][0] * m2[2][2], + m1[0][1] * m2[0][0] + m1[1][1] * m2[1][0] + m1[2][1] * m2[2][0], + m1[0][1] * m2[0][1] + m1[1][1] * m2[1][1] + m1[2][1] * m2[2][1], + m1[0][1] * m2[0][2] + m1[1][1] * m2[1][2] + m1[2][1] * m2[2][2], + m1[0][2] * m2[0][0] + m1[1][2] * m2[1][0] + m1[2][2] * m2[2][0], + m1[0][2] * m2[0][1] + m1[1][2] * m2[1][1] + m1[2][2] * m2[2][1], + m1[0][2] * m2[0][2] + m1[1][2] * m2[1][2] + m1[2][2] * m2[2][2]); +} + + +#endif diff --git a/src/LinearMath/GenMinMax.h b/src/LinearMath/btMinMax.h similarity index 100% rename from src/LinearMath/GenMinMax.h rename to src/LinearMath/btMinMax.h diff --git a/src/LinearMath/SimdPoint3.h b/src/LinearMath/btPoint3.h similarity index 89% rename from src/LinearMath/SimdPoint3.h rename to src/LinearMath/btPoint3.h index 058563ae2..4be7e9015 100644 --- a/src/LinearMath/SimdPoint3.h +++ b/src/LinearMath/btPoint3.h @@ -14,11 +14,11 @@ subject to the following restrictions: -#ifndef SimdPoint3_H -#define SimdPoint3_H +#ifndef btPoint3_H +#define btPoint3_H -#include "LinearMath/SimdVector3.h" +#include "LinearMath/btVector3.h" -typedef SimdVector3 SimdPoint3; +typedef btVector3 btPoint3; #endif diff --git a/src/LinearMath/SimdQuadWord.h b/src/LinearMath/btQuadWord.h similarity index 57% rename from src/LinearMath/SimdQuadWord.h rename to src/LinearMath/btQuadWord.h index 12a91bd55..28bb2051d 100644 --- a/src/LinearMath/SimdQuadWord.h +++ b/src/LinearMath/btQuadWord.h @@ -16,30 +16,30 @@ subject to the following restrictions: #ifndef SIMD_QUADWORD_H #define SIMD_QUADWORD_H -#include "LinearMath/SimdScalar.h" +#include "LinearMath/btScalar.h" -class SimdQuadWord +class btQuadWord { protected: - ATTRIBUTE_ALIGNED16 (SimdScalar m_x); - SimdScalar m_y; - SimdScalar m_z; - SimdScalar m_unusedW; + ATTRIBUTE_ALIGNED16 (btScalar m_x); + btScalar m_y; + btScalar m_z; + btScalar m_unusedW; public: - SIMD_FORCE_INLINE SimdScalar& operator[](int i) { return (&m_x)[i]; } - SIMD_FORCE_INLINE const SimdScalar& operator[](int i) const { return (&m_x)[i]; } + SIMD_FORCE_INLINE btScalar& operator[](int i) { return (&m_x)[i]; } + SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_x)[i]; } - SIMD_FORCE_INLINE const SimdScalar& getX() const { return m_x; } + SIMD_FORCE_INLINE const btScalar& getX() const { return m_x; } - SIMD_FORCE_INLINE const SimdScalar& getY() const { return m_y; } + SIMD_FORCE_INLINE const btScalar& getY() const { return m_y; } - SIMD_FORCE_INLINE const SimdScalar& getZ() const { return m_z; } + SIMD_FORCE_INLINE const btScalar& getZ() const { return m_z; } SIMD_FORCE_INLINE void setX(float x) { m_x = x;}; @@ -47,31 +47,31 @@ class SimdQuadWord SIMD_FORCE_INLINE void setZ(float z) { m_z = z;}; - SIMD_FORCE_INLINE const SimdScalar& x() const { return m_x; } + SIMD_FORCE_INLINE const btScalar& x() const { return m_x; } - SIMD_FORCE_INLINE const SimdScalar& y() const { return m_y; } + SIMD_FORCE_INLINE const btScalar& y() const { return m_y; } - SIMD_FORCE_INLINE const SimdScalar& z() const { return m_z; } + SIMD_FORCE_INLINE const btScalar& z() const { return m_z; } - operator SimdScalar *() { return &m_x; } - operator const SimdScalar *() const { return &m_x; } + operator btScalar *() { return &m_x; } + operator const btScalar *() const { return &m_x; } - SIMD_FORCE_INLINE void setValue(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z) + SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z) { m_x=x; m_y=y; m_z=z; } -/* void getValue(SimdScalar *m) const +/* void getValue(btScalar *m) const { m[0] = m_x; m[1] = m_y; m[2] = m_z; } */ - SIMD_FORCE_INLINE void setValue(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z,const SimdScalar& w) + SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) { m_x=x; m_y=y; @@ -79,25 +79,25 @@ class SimdQuadWord m_unusedW=w; } - SIMD_FORCE_INLINE SimdQuadWord() : + SIMD_FORCE_INLINE btQuadWord() : m_x(0.f),m_y(0.f),m_z(0.f),m_unusedW(0.f) { } - SIMD_FORCE_INLINE SimdQuadWord(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z) + SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z) :m_x(x),m_y(y),m_z(z) //todo, remove this in release/simd ? ,m_unusedW(0.f) { } - SIMD_FORCE_INLINE SimdQuadWord(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z,const SimdScalar& w) + SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) :m_x(x),m_y(y),m_z(z),m_unusedW(w) { } - SIMD_FORCE_INLINE void setMax(const SimdQuadWord& other) + SIMD_FORCE_INLINE void setMax(const btQuadWord& other) { if (other.m_x > m_x) m_x = other.m_x; @@ -112,7 +112,7 @@ class SimdQuadWord m_unusedW = other.m_unusedW; } - SIMD_FORCE_INLINE void setMin(const SimdQuadWord& other) + SIMD_FORCE_INLINE void setMin(const btQuadWord& other) { if (other.m_x < m_x) m_x = other.m_x; diff --git a/src/LinearMath/btQuaternion.h b/src/LinearMath/btQuaternion.h new file mode 100644 index 000000000..7f7a813c4 --- /dev/null +++ b/src/LinearMath/btQuaternion.h @@ -0,0 +1,290 @@ +/* +Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. 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. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + + + +#ifndef SIMD__QUATERNION_H_ +#define SIMD__QUATERNION_H_ + +#include "LinearMath/btVector3.h" + +class btQuaternion : public btQuadWord { +public: + btQuaternion() {} + + // template + // explicit Quaternion(const btScalar *v) : Tuple4(v) {} + + btQuaternion(const btScalar& x, const btScalar& y, const btScalar& z, const btScalar& w) + : btQuadWord(x, y, z, w) + {} + + btQuaternion(const btVector3& axis, const btScalar& angle) + { + setRotation(axis, angle); + } + + btQuaternion(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) + { + setEuler(yaw, pitch, roll); + } + + void setRotation(const btVector3& axis, const btScalar& angle) + { + btScalar d = axis.length(); + assert(d != btScalar(0.0)); + btScalar s = btSin(angle * btScalar(0.5)) / d; + setValue(axis.x() * s, axis.y() * s, axis.z() * s, + btCos(angle * btScalar(0.5))); + } + + void setEuler(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) + { + btScalar halfYaw = btScalar(yaw) * btScalar(0.5); + btScalar halfPitch = btScalar(pitch) * btScalar(0.5); + btScalar halfRoll = btScalar(roll) * btScalar(0.5); + btScalar cosYaw = btCos(halfYaw); + btScalar sinYaw = btSin(halfYaw); + btScalar cosPitch = btCos(halfPitch); + btScalar sinPitch = btSin(halfPitch); + btScalar cosRoll = btCos(halfRoll); + btScalar sinRoll = btSin(halfRoll); + setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw, + cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw, + sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw, + cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw); + } + + btQuaternion& operator+=(const btQuaternion& q) + { + m_x += q.x(); m_y += q.y(); m_z += q.z(); m_unusedW += q[3]; + return *this; + } + + btQuaternion& operator-=(const btQuaternion& q) + { + m_x -= q.x(); m_y -= q.y(); m_z -= q.z(); m_unusedW -= q[3]; + return *this; + } + + btQuaternion& operator*=(const btScalar& s) + { + m_x *= s; m_y *= s; m_z *= s; m_unusedW *= s; + return *this; + } + + + btQuaternion& operator*=(const btQuaternion& q) + { + setValue(m_unusedW * q.x() + m_x * q[3] + m_y * q.z() - m_z * q.y(), + m_unusedW * q.y() + m_y * q[3] + m_z * q.x() - m_x * q.z(), + m_unusedW * q.z() + m_z * q[3] + m_x * q.y() - m_y * q.x(), + m_unusedW * q[3] - m_x * q.x() - m_y * q.y() - m_z * q.z()); + return *this; + } + + btScalar dot(const btQuaternion& q) const + { + return m_x * q.x() + m_y * q.y() + m_z * q.z() + m_unusedW * q[3]; + } + + btScalar length2() const + { + return dot(*this); + } + + btScalar length() const + { + return btSqrt(length2()); + } + + btQuaternion& normalize() + { + return *this /= length(); + } + + SIMD_FORCE_INLINE btQuaternion + operator*(const btScalar& s) const + { + return btQuaternion(x() * s, y() * s, z() * s, m_unusedW * s); + } + + + + btQuaternion operator/(const btScalar& s) const + { + assert(s != btScalar(0.0)); + return *this * (btScalar(1.0) / s); + } + + + btQuaternion& operator/=(const btScalar& s) + { + assert(s != btScalar(0.0)); + return *this *= btScalar(1.0) / s; + } + + + btQuaternion normalized() const + { + return *this / length(); + } + + btScalar angle(const btQuaternion& q) const + { + btScalar s = btSqrt(length2() * q.length2()); + assert(s != btScalar(0.0)); + return btAcos(dot(q) / s); + } + + btScalar getAngle() const + { + btScalar s = 2.f * btAcos(m_unusedW); + return s; + } + + + + btQuaternion inverse() const + { + return btQuaternion(m_x, m_y, m_z, -m_unusedW); + } + + SIMD_FORCE_INLINE btQuaternion + operator+(const btQuaternion& q2) const + { + const btQuaternion& q1 = *this; + return btQuaternion(q1.x() + q2.x(), q1.y() + q2.y(), q1.z() + q2.z(), q1[3] + q2[3]); + } + + SIMD_FORCE_INLINE btQuaternion + operator-(const btQuaternion& q2) const + { + const btQuaternion& q1 = *this; + return btQuaternion(q1.x() - q2.x(), q1.y() - q2.y(), q1.z() - q2.z(), q1[3] - q2[3]); + } + + SIMD_FORCE_INLINE btQuaternion operator-() const + { + const btQuaternion& q2 = *this; + return btQuaternion( - q2.x(), - q2.y(), - q2.z(), - q2[3]); + } + + SIMD_FORCE_INLINE btQuaternion farthest( const btQuaternion& qd) const + { + btQuaternion diff,sum; + diff = *this - qd; + sum = *this + qd; + if( diff.dot(diff) > sum.dot(sum) ) + return qd; + return (-qd); + } + + btQuaternion slerp(const btQuaternion& q, const btScalar& t) const + { + btScalar theta = angle(q); + if (theta != btScalar(0.0)) + { + btScalar d = btScalar(1.0) / btSin(theta); + btScalar s0 = btSin((btScalar(1.0) - t) * theta); + btScalar s1 = btSin(t * theta); + return btQuaternion((m_x * s0 + q.x() * s1) * d, + (m_y * s0 + q.y() * s1) * d, + (m_z * s0 + q.z() * s1) * d, + (m_unusedW * s0 + q[3] * s1) * d); + } + else + { + return *this; + } + } + + + +}; + + + +SIMD_FORCE_INLINE btQuaternion +operator-(const btQuaternion& q) +{ + return btQuaternion(-q.x(), -q.y(), -q.z(), -q[3]); +} + + + + +SIMD_FORCE_INLINE btQuaternion +operator*(const btQuaternion& q1, const btQuaternion& q2) { + return btQuaternion(q1[3] * q2.x() + q1.x() * q2[3] + q1.y() * q2.z() - q1.z() * q2.y(), + q1[3] * q2.y() + q1.y() * q2[3] + q1.z() * q2.x() - q1.x() * q2.z(), + q1[3] * q2.z() + q1.z() * q2[3] + q1.x() * q2.y() - q1.y() * q2.x(), + q1[3] * q2[3] - q1.x() * q2.x() - q1.y() * q2.y() - q1.z() * q2.z()); +} + +SIMD_FORCE_INLINE btQuaternion +operator*(const btQuaternion& q, const btVector3& w) +{ + return btQuaternion( q[3] * w.x() + q.y() * w.z() - q.z() * w.y(), + q[3] * w.y() + q.z() * w.x() - q.x() * w.z(), + q[3] * w.z() + q.x() * w.y() - q.y() * w.x(), + -q.x() * w.x() - q.y() * w.y() - q.z() * w.z()); +} + +SIMD_FORCE_INLINE btQuaternion +operator*(const btVector3& w, const btQuaternion& q) +{ + return btQuaternion( w.x() * q[3] + w.y() * q.z() - w.z() * q.y(), + w.y() * q[3] + w.z() * q.x() - w.x() * q.z(), + w.z() * q[3] + w.x() * q.y() - w.y() * q.x(), + -w.x() * q.x() - w.y() * q.y() - w.z() * q.z()); +} + +SIMD_FORCE_INLINE btScalar +dot(const btQuaternion& q1, const btQuaternion& q2) +{ + return q1.dot(q2); +} + + +SIMD_FORCE_INLINE btScalar +length(const btQuaternion& q) +{ + return q.length(); +} + +SIMD_FORCE_INLINE btScalar +angle(const btQuaternion& q1, const btQuaternion& q2) +{ + return q1.angle(q2); +} + + +SIMD_FORCE_INLINE btQuaternion +inverse(const btQuaternion& q) +{ + return q.inverse(); +} + +SIMD_FORCE_INLINE btQuaternion +slerp(const btQuaternion& q1, const btQuaternion& q2, const btScalar& t) +{ + return q1.slerp(q2, t); +} + + +#endif + + + diff --git a/src/LinearMath/GenQuickprof.cpp b/src/LinearMath/btQuickprof.cpp similarity index 73% rename from src/LinearMath/GenQuickprof.cpp rename to src/LinearMath/btQuickprof.cpp index 6ac0b6d26..23b8b8b2c 100644 --- a/src/LinearMath/GenQuickprof.cpp +++ b/src/LinearMath/btQuickprof.cpp @@ -7,10 +7,10 @@ * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * -* (1) The GNU Lesser General Public License as published by the Free * +* (1) The GNU Lesser bteral Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * -* General Public License is included with this library in the * +* bteral Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * @@ -27,19 +27,19 @@ // Credits: The Clock class was inspired by the Timer classes in // Ogre (www.ogre3d.org). -#include "LinearMath/GenQuickprof.h" +#include "LinearMath/btQuickprof.h" #ifdef USE_QUICKPROF // Note: We must declare these private static variables again here to // avoid link errors. -bool Profiler::mEnabled = false; -hidden::Clock Profiler::mClock; -unsigned long int Profiler::mCurrentCycleStartMicroseconds = 0; -unsigned long int Profiler::mLastCycleDurationMicroseconds = 0; -std::map Profiler::mProfileBlocks; -std::ofstream Profiler::mOutputFile; -bool Profiler::mFirstFileOutput = true; -Profiler::BlockTimingMethod Profiler::mFileOutputMethod; -unsigned long int Profiler::mCycleNumber = 0; +bool btProfiler::mEnabled = false; +hidden::Clock btProfiler::mClock; +unsigned long int btProfiler::mCurrentCycleStartMicroseconds = 0; +unsigned long int btProfiler::mLastCycleDurationMicroseconds = 0; +std::map btProfiler::mProfileBlocks; +std::ofstream btProfiler::mOutputFile; +bool btProfiler::mFirstFileOutput = true; +btProfiler::BlockTimingMethod btProfiler::mFileOutputMethod; +unsigned long int btProfiler::mCycleNumber = 0; #endif //USE_QUICKPROF diff --git a/src/LinearMath/GenQuickprof.h b/src/LinearMath/btQuickprof.h similarity index 95% rename from src/LinearMath/GenQuickprof.h rename to src/LinearMath/btQuickprof.h index 86774d1bb..619ada56c 100644 --- a/src/LinearMath/GenQuickprof.h +++ b/src/LinearMath/btQuickprof.h @@ -7,10 +7,10 @@ * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * -* (1) The GNU Lesser General Public License as published by the Free * +* (1) The GNU Lesser bteral Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * -* General Public License is included with this library in the * +* bteral Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * @@ -255,7 +255,7 @@ namespace hidden }; /// A static class that manages timing for a set of profiling blocks. -class Profiler +class btProfiler { public: /// A set of ways to retrieve block timing data. @@ -333,9 +333,9 @@ public: BlockTimingMethod method=BLOCK_TOTAL_PERCENT); //private: - inline Profiler(); + inline btProfiler(); - inline ~Profiler(); + inline ~btProfiler(); /// Prints an error message to standard output. inline static void printError(const std::string& msg) @@ -372,19 +372,19 @@ public: }; -Profiler::Profiler() +btProfiler::btProfiler() { - // This never gets called because a Profiler instance is never + // This never gets called because a btProfiler instance is never // created. } -Profiler::~Profiler() +btProfiler::~btProfiler() { - // This never gets called because a Profiler instance is never + // This never gets called because a btProfiler instance is never // created. } -void Profiler::init(const std::string outputFilename, +void btProfiler::init(const std::string outputFilename, BlockTimingMethod outputMethod) { mEnabled = true; @@ -402,7 +402,7 @@ void Profiler::init(const std::string outputFilename, mCurrentCycleStartMicroseconds = mClock.getTimeMicroseconds(); } -void Profiler::destroy() +void btProfiler::destroy() { if (!mEnabled) { @@ -422,7 +422,7 @@ void Profiler::destroy() } } -void Profiler::beginBlock(const std::string& name) +void btProfiler::beginBlock(const std::string& name) { if (!mEnabled) { @@ -448,7 +448,7 @@ void Profiler::beginBlock(const std::string& name) block->currentBlockStartMicroseconds = mClock.getTimeMicroseconds(); } -void Profiler::endBlock(const std::string& name) +void btProfiler::endBlock(const std::string& name) { if (!mEnabled) { @@ -474,7 +474,7 @@ void Profiler::endBlock(const std::string& name) block->totalMicroseconds += blockDuration; } -double Profiler::getBlockTime(const std::string& name, +double btProfiler::getBlockTime(const std::string& name, BlockTimingMethod method) { if (!mEnabled) @@ -552,7 +552,7 @@ double Profiler::getBlockTime(const std::string& name, return result; } -void Profiler::endProfilingCycle() +void btProfiler::endProfilingCycle() { if (!mEnabled) { @@ -608,7 +608,7 @@ void Profiler::endProfilingCycle() mCurrentCycleStartMicroseconds = mClock.getTimeMicroseconds(); } -std::string Profiler::createStatsString(BlockTimingMethod method) +std::string btProfiler::createStatsString(BlockTimingMethod method) { if (!mEnabled) { diff --git a/src/LinearMath/GenRandom.h b/src/LinearMath/btRandom.h similarity index 100% rename from src/LinearMath/GenRandom.h rename to src/LinearMath/btRandom.h diff --git a/src/LinearMath/btScalar.h b/src/LinearMath/btScalar.h new file mode 100644 index 000000000..35f452665 --- /dev/null +++ b/src/LinearMath/btScalar.h @@ -0,0 +1,128 @@ +/* +Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. 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. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + + + +#ifndef SIMD___SCALAR_H +#define SIMD___SCALAR_H + +#include +#undef max + + + +#include +#include +#include + +#ifdef WIN32 + + #if defined(__MINGW32__) || defined(__CYGWIN__) + #define SIMD_FORCE_INLINE inline + #else + #pragma warning(disable:4530) + #pragma warning(disable:4996) + #define SIMD_FORCE_INLINE __forceinline + #endif //__MINGW32__ + + //#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a + #define ATTRIBUTE_ALIGNED16(a) a + #include + #define ASSERT assert +#else + + //non-windows systems + + #define SIMD_FORCE_INLINE inline + #define ATTRIBUTE_ALIGNED16(a) a + #ifndef assert + #include + #endif + #define ASSERT assert +#endif + + + +typedef float btScalar; + +#if defined (__sun) || defined (__sun__) || defined (__sparc) || defined (__APPLE__) +//use double float precision operation on those platforms for Blender + +SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrt(x); } +SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabs(x); } +SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cos(x); } +SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sin(x); } +SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tan(x); } +SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { return acos(x); } +SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { return asin(x); } +SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atan(x); } +SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2(x, y); } +SIMD_FORCE_INLINE btScalar btExp(btScalar x) { return exp(x); } +SIMD_FORCE_INLINE btScalar btLog(btScalar x) { return log(x); } +SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return pow(x,y); } + +#else + +SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrtf(x); } +SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabsf(x); } +SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cosf(x); } +SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sinf(x); } +SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tanf(x); } +SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { return acosf(x); } +SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { return asinf(x); } +SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atanf(x); } +SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2f(x, y); } +SIMD_FORCE_INLINE btScalar btExp(btScalar x) { return expf(x); } +SIMD_FORCE_INLINE btScalar btLog(btScalar x) { return logf(x); } +SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return powf(x,y); } + +#endif + + +const btScalar SIMD_2_PI = 6.283185307179586232f; +const btScalar SIMD_PI = SIMD_2_PI * btScalar(0.5f); +const btScalar SIMD_HALF_PI = SIMD_2_PI * btScalar(0.25f); +const btScalar SIMD_RADS_PER_DEG = SIMD_2_PI / btScalar(360.0f); +const btScalar SIMD_DEGS_PER_RAD = btScalar(360.0f) / SIMD_2_PI; +const btScalar SIMD_EPSILON = FLT_EPSILON; +const btScalar SIMD_INFINITY = FLT_MAX; + +SIMD_FORCE_INLINE bool btFuzzyZero(btScalar x) { return btFabs(x) < SIMD_EPSILON; } + +SIMD_FORCE_INLINE bool btEqual(btScalar a, btScalar eps) { + return (((a) <= eps) && !((a) < -eps)); +} +SIMD_FORCE_INLINE bool btGreaterEqual (btScalar a, btScalar eps) { + return (!((a) <= eps)); +} + +/*SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cosf(x); } +SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sinf(x); } +SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tanf(x); } +SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { return acosf(x); } +SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { return asinf(x); } +SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atanf(x); } +SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2f(x, y); } +*/ + +SIMD_FORCE_INLINE int btSign(btScalar x) { + return x < 0.0f ? -1 : x > 0.0f ? 1 : 0; +} + +SIMD_FORCE_INLINE btScalar btRadians(btScalar x) { return x * SIMD_RADS_PER_DEG; } +SIMD_FORCE_INLINE btScalar btDegrees(btScalar x) { return x * SIMD_DEGS_PER_RAD; } + + + +#endif //SIMD___SCALAR_H diff --git a/src/LinearMath/SimdMinMax.h b/src/LinearMath/btSimdMinMax.h similarity index 83% rename from src/LinearMath/SimdMinMax.h rename to src/LinearMath/btSimdMinMax.h index 693cb2b7e..16c31552f 100644 --- a/src/LinearMath/SimdMinMax.h +++ b/src/LinearMath/btSimdMinMax.h @@ -18,22 +18,22 @@ subject to the following restrictions: #define SIMD_MINMAX_H template -SIMD_FORCE_INLINE const T& SimdMin(const T& a, const T& b) { +SIMD_FORCE_INLINE const T& btMin(const T& a, const T& b) { return b < a ? b : a; } template -SIMD_FORCE_INLINE const T& SimdMax(const T& a, const T& b) { +SIMD_FORCE_INLINE const T& btMax(const T& a, const T& b) { return a < b ? b : a; } template -SIMD_FORCE_INLINE void SimdSetMin(T& a, const T& b) { +SIMD_FORCE_INLINE void btSetMin(T& a, const T& b) { if (a > b) a = b; } template -SIMD_FORCE_INLINE void SimdSetMax(T& a, const T& b) { +SIMD_FORCE_INLINE void btSetMax(T& a, const T& b) { if (a < b) a = b; } diff --git a/src/LinearMath/btTransform.h b/src/LinearMath/btTransform.h new file mode 100644 index 000000000..baeb0337a --- /dev/null +++ b/src/LinearMath/btTransform.h @@ -0,0 +1,236 @@ +/* +Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. 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. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + + + +#ifndef btTransform_H +#define btTransform_H + +#include "LinearMath/btVector3.h" +#include "LinearMath/btMatrix3x3.h" + + + +class btTransform { + + +public: + + enum { + TRANSLATION = 0x01, + ROTATION = 0x02, + RIGID = TRANSLATION | ROTATION, + SCALING = 0x04, + LINEAR = ROTATION | SCALING, + AFFINE = TRANSLATION | LINEAR + }; + + btTransform() {} + + explicit SIMD_FORCE_INLINE btTransform(const btQuaternion& q, + const btVector3& c = btVector3(btScalar(0), btScalar(0), btScalar(0))) + : m_basis(q), + m_origin(c), + m_type(RIGID) + {} + + explicit SIMD_FORCE_INLINE btTransform(const btMatrix3x3& b, + const btVector3& c = btVector3(btScalar(0), btScalar(0), btScalar(0)), + unsigned int type = AFFINE) + : m_basis(b), + m_origin(c), + m_type(type) + {} + + + SIMD_FORCE_INLINE void mult(const btTransform& t1, const btTransform& t2) { + m_basis = t1.m_basis * t2.m_basis; + m_origin = t1(t2.m_origin); + m_type = t1.m_type | t2.m_type; + } + + void multInverseLeft(const btTransform& t1, const btTransform& t2) { + btVector3 v = t2.m_origin - t1.m_origin; + if (t1.m_type & SCALING) { + btMatrix3x3 inv = t1.m_basis.inverse(); + m_basis = inv * t2.m_basis; + m_origin = inv * v; + } + else { + m_basis = btMultTransposeLeft(t1.m_basis, t2.m_basis); + m_origin = v * t1.m_basis; + } + m_type = t1.m_type | t2.m_type; + } + + SIMD_FORCE_INLINE btVector3 operator()(const btVector3& x) const + { + return btVector3(m_basis[0].dot(x) + m_origin[0], + m_basis[1].dot(x) + m_origin[1], + m_basis[2].dot(x) + m_origin[2]); + } + + SIMD_FORCE_INLINE btVector3 operator*(const btVector3& x) const + { + return (*this)(x); + } + + SIMD_FORCE_INLINE btMatrix3x3& getBasis() { return m_basis; } + SIMD_FORCE_INLINE const btMatrix3x3& getBasis() const { return m_basis; } + + SIMD_FORCE_INLINE btVector3& getOrigin() { return m_origin; } + SIMD_FORCE_INLINE const btVector3& getOrigin() const { return m_origin; } + + btQuaternion getRotation() const { + btQuaternion q; + m_basis.getRotation(q); + return q; + } + template + void setValue(const Scalar2 *m) + { + m_basis.setValue(m); + m_origin.setValue(&m[12]); + m_type = AFFINE; + } + + + void setFromOpenGLMatrix(const btScalar *m) + { + m_basis.setFromOpenGLSubMatrix(m); + m_origin[0] = m[12]; + m_origin[1] = m[13]; + m_origin[2] = m[14]; + } + + void getOpenGLMatrix(btScalar *m) const + { + m_basis.getOpenGLSubMatrix(m); + m[12] = m_origin[0]; + m[13] = m_origin[1]; + m[14] = m_origin[2]; + m[15] = btScalar(1.0f); + } + + SIMD_FORCE_INLINE void setOrigin(const btVector3& origin) + { + m_origin = origin; + m_type |= TRANSLATION; + } + + SIMD_FORCE_INLINE btVector3 invXform(const btVector3& inVec) const; + + + + SIMD_FORCE_INLINE void setBasis(const btMatrix3x3& basis) + { + m_basis = basis; + m_type |= LINEAR; + } + + SIMD_FORCE_INLINE void setRotation(const btQuaternion& q) + { + m_basis.setRotation(q); + m_type = (m_type & ~LINEAR) | ROTATION; + } + + SIMD_FORCE_INLINE void scale(const btVector3& scaling) + { + m_basis = m_basis.scaled(scaling); + m_type |= SCALING; + } + + void setIdentity() + { + m_basis.setIdentity(); + m_origin.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); + m_type = 0x0; + } + + SIMD_FORCE_INLINE bool isIdentity() const { return m_type == 0x0; } + + btTransform& operator*=(const btTransform& t) + { + m_origin += m_basis * t.m_origin; + m_basis *= t.m_basis; + m_type |= t.m_type; + return *this; + } + + btTransform inverse() const + { + if (m_type) + { + btMatrix3x3 inv = (m_type & SCALING) ? + m_basis.inverse() : + m_basis.transpose(); + + return btTransform(inv, inv * -m_origin, m_type); + } + + return *this; + } + + btTransform inverseTimes(const btTransform& t) const; + + btTransform operator*(const btTransform& t) const; + +private: + + btMatrix3x3 m_basis; + btVector3 m_origin; + unsigned int m_type; +}; + + +SIMD_FORCE_INLINE btVector3 +btTransform::invXform(const btVector3& inVec) const +{ + btVector3 v = inVec - m_origin; + return (m_basis.transpose() * v); +} + +SIMD_FORCE_INLINE btTransform +btTransform::inverseTimes(const btTransform& t) const +{ + btVector3 v = t.getOrigin() - m_origin; + if (m_type & SCALING) + { + btMatrix3x3 inv = m_basis.inverse(); + return btTransform(inv * t.getBasis(), inv * v, + m_type | t.m_type); + } + else + { + return btTransform(m_basis.transposeTimes(t.m_basis), + v * m_basis, m_type | t.m_type); + } +} + +SIMD_FORCE_INLINE btTransform +btTransform::operator*(const btTransform& t) const +{ + return btTransform(m_basis * t.m_basis, + (*this)(t.m_origin), + m_type | t.m_type); +} + + + +#endif + + + + + diff --git a/src/LinearMath/SimdTransformUtil.h b/src/LinearMath/btTransformUtil.h similarity index 55% rename from src/LinearMath/SimdTransformUtil.h rename to src/LinearMath/btTransformUtil.h index 6cd822fdf..2e92ef90d 100644 --- a/src/LinearMath/SimdTransformUtil.h +++ b/src/LinearMath/btTransformUtil.h @@ -16,29 +16,29 @@ subject to the following restrictions: #ifndef SIMD_TRANSFORM_UTIL_H #define SIMD_TRANSFORM_UTIL_H -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btTransform.h" #define ANGULAR_MOTION_TRESHOLD 0.5f*SIMD_HALF_PI -#define SIMDSQRT12 SimdScalar(0.7071067811865475244008443621048490) +#define SIMDSQRT12 btScalar(0.7071067811865475244008443621048490) -#define SimdRecipSqrt(x) ((float)(1.0f/SimdSqrt(float(x)))) /* reciprocal square root */ +#define btRecipSqrt(x) ((float)(1.0f/btSqrt(float(x)))) /* reciprocal square root */ -inline SimdVector3 SimdAabbSupport(const SimdVector3& halfExtents,const SimdVector3& supportDir) +inline btVector3 btAabbSupport(const btVector3& halfExtents,const btVector3& supportDir) { - return SimdVector3(supportDir.x() < SimdScalar(0.0f) ? -halfExtents.x() : halfExtents.x(), - supportDir.y() < SimdScalar(0.0f) ? -halfExtents.y() : halfExtents.y(), - supportDir.z() < SimdScalar(0.0f) ? -halfExtents.z() : halfExtents.z()); + return btVector3(supportDir.x() < btScalar(0.0f) ? -halfExtents.x() : halfExtents.x(), + supportDir.y() < btScalar(0.0f) ? -halfExtents.y() : halfExtents.y(), + supportDir.z() < btScalar(0.0f) ? -halfExtents.z() : halfExtents.z()); } -inline void SimdPlaneSpace1 (const SimdVector3& n, SimdVector3& p, SimdVector3& q) +inline void btPlaneSpace1 (const btVector3& n, btVector3& p, btVector3& q) { - if (SimdFabs(n[2]) > SIMDSQRT12) { + if (btFabs(n[2]) > SIMDSQRT12) { // choose p in y-z plane - SimdScalar a = n[1]*n[1] + n[2]*n[2]; - SimdScalar k = SimdRecipSqrt (a); + btScalar a = n[1]*n[1] + n[2]*n[2]; + btScalar k = btRecipSqrt (a); p[0] = 0; p[1] = -n[2]*k; p[2] = n[1]*k; @@ -49,8 +49,8 @@ inline void SimdPlaneSpace1 (const SimdVector3& n, SimdVector3& p, SimdVector3& } else { // choose p in x-y plane - SimdScalar a = n[0]*n[0] + n[1]*n[1]; - SimdScalar k = SimdRecipSqrt (a); + btScalar a = n[0]*n[0] + n[1]*n[1]; + btScalar k = btRecipSqrt (a); p[0] = -n[1]*k; p[1] = n[0]*k; p[2] = 0; @@ -64,23 +64,23 @@ inline void SimdPlaneSpace1 (const SimdVector3& n, SimdVector3& p, SimdVector3& /// Utils related to temporal transforms -class SimdTransformUtil +class btTransformUtil { public: - static void IntegrateTransform(const SimdTransform& curTrans,const SimdVector3& linvel,const SimdVector3& angvel,SimdScalar timeStep,SimdTransform& predictedTransform) + static void IntegrateTransform(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep,btTransform& predictedTransform) { predictedTransform.setOrigin(curTrans.getOrigin() + linvel * timeStep); // #define QUATERNION_DERIVATIVE #ifdef QUATERNION_DERIVATIVE - SimdQuaternion orn = curTrans.getRotation(); + btQuaternion orn = curTrans.getRotation(); orn += (angvel * orn) * (timeStep * 0.5f); orn.normalize(); #else //exponential map - SimdVector3 axis; - SimdScalar fAngle = angvel.length(); + btVector3 axis; + btScalar fAngle = angvel.length(); //limit the angular motion if (fAngle*timeStep > ANGULAR_MOTION_TRESHOLD) { @@ -95,41 +95,41 @@ public: else { // sync(fAngle) = sin(c*fAngle)/t - axis = angvel*( SimdSin(0.5f*fAngle*timeStep)/fAngle ); + axis = angvel*( btSin(0.5f*fAngle*timeStep)/fAngle ); } - SimdQuaternion dorn (axis.x(),axis.y(),axis.z(),SimdCos( fAngle*timeStep*0.5f )); - SimdQuaternion orn0 = curTrans.getRotation(); + btQuaternion dorn (axis.x(),axis.y(),axis.z(),btCos( fAngle*timeStep*0.5f )); + btQuaternion orn0 = curTrans.getRotation(); - SimdQuaternion predictedOrn = dorn * orn0; + btQuaternion predictedOrn = dorn * orn0; #endif predictedTransform.setRotation(predictedOrn); } - static void CalculateVelocity(const SimdTransform& transform0,const SimdTransform& transform1,SimdScalar timeStep,SimdVector3& linVel,SimdVector3& angVel) + static void CalculateVelocity(const btTransform& transform0,const btTransform& transform1,btScalar timeStep,btVector3& linVel,btVector3& angVel) { linVel = (transform1.getOrigin() - transform0.getOrigin()) / timeStep; #ifdef USE_QUATERNION_DIFF - SimdQuaternion orn0 = transform0.getRotation(); - SimdQuaternion orn1a = transform1.getRotation(); - SimdQuaternion orn1 = orn0.farthest(orn1a); - SimdQuaternion dorn = orn1 * orn0.inverse(); + btQuaternion orn0 = transform0.getRotation(); + btQuaternion orn1a = transform1.getRotation(); + btQuaternion orn1 = orn0.farthest(orn1a); + btQuaternion dorn = orn1 * orn0.inverse(); #else - SimdMatrix3x3 dmat = transform1.getBasis() * transform0.getBasis().inverse(); - SimdQuaternion dorn; + btMatrix3x3 dmat = transform1.getBasis() * transform0.getBasis().inverse(); + btQuaternion dorn; dmat.getRotation(dorn); #endif//USE_QUATERNION_DIFF - SimdVector3 axis; - SimdScalar angle; + btVector3 axis; + btScalar angle; angle = dorn.getAngle(); - axis = SimdVector3(dorn.x(),dorn.y(),dorn.z()); + axis = btVector3(dorn.x(),dorn.y(),dorn.z()); axis[3] = 0.f; //check for axis length - SimdScalar len = axis.length2(); + btScalar len = axis.length2(); if (len < SIMD_EPSILON*SIMD_EPSILON) - axis = SimdVector3(1.f,0.f,0.f); + axis = btVector3(1.f,0.f,0.f); else - axis /= SimdSqrt(len); + axis /= btSqrt(len); angVel = axis * angle / timeStep; diff --git a/src/LinearMath/btVector3.h b/src/LinearMath/btVector3.h new file mode 100644 index 000000000..5a35652ec --- /dev/null +++ b/src/LinearMath/btVector3.h @@ -0,0 +1,403 @@ +/* +Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. 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. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + + + +#ifndef SIMD__VECTOR3_H +#define SIMD__VECTOR3_H + +#include "btQuadWord.h" + + +///btVector3 is 16byte aligned, and has an extra unused component m_w +///this extra component can be used by derived classes (Quaternion?) or by user +class btVector3 : public btQuadWord { + + +public: + SIMD_FORCE_INLINE btVector3() {} + + + + SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, const btScalar& z) + :btQuadWord(x,y,z,0.f) + { + } + +// SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) +// : btQuadWord(x,y,z,w) +// { +// } + + + + SIMD_FORCE_INLINE btVector3& operator+=(const btVector3& v) + { + m_x += v.x(); m_y += v.y(); m_z += v.z(); + return *this; + } + + + + SIMD_FORCE_INLINE btVector3& operator-=(const btVector3& v) + { + m_x -= v.x(); m_y -= v.y(); m_z -= v.z(); + return *this; + } + + SIMD_FORCE_INLINE btVector3& operator*=(const btScalar& s) + { + m_x *= s; m_y *= s; m_z *= s; + return *this; + } + + SIMD_FORCE_INLINE btVector3& operator/=(const btScalar& s) + { + assert(s != btScalar(0.0)); + return *this *= btScalar(1.0) / s; + } + + SIMD_FORCE_INLINE btScalar dot(const btVector3& v) const + { + return m_x * v.x() + m_y * v.y() + m_z * v.z(); + } + + SIMD_FORCE_INLINE btScalar length2() const + { + return dot(*this); + } + + SIMD_FORCE_INLINE btScalar length() const + { + return btSqrt(length2()); + } + + SIMD_FORCE_INLINE btScalar distance2(const btVector3& v) const; + + SIMD_FORCE_INLINE btScalar distance(const btVector3& v) const; + + SIMD_FORCE_INLINE btVector3& normalize() + { + return *this /= length(); + } + + SIMD_FORCE_INLINE btVector3 normalized() const; + + SIMD_FORCE_INLINE btVector3 rotate( const btVector3& wAxis, const btScalar angle ); + + SIMD_FORCE_INLINE btScalar angle(const btVector3& v) const + { + btScalar s = btSqrt(length2() * v.length2()); + assert(s != btScalar(0.0)); + return btAcos(dot(v) / s); + } + + SIMD_FORCE_INLINE btVector3 absolute() const + { + return btVector3( + btFabs(m_x), + btFabs(m_y), + btFabs(m_z)); + } + + SIMD_FORCE_INLINE btVector3 cross(const btVector3& v) const + { + return btVector3( + m_y * v.z() - m_z * v.y(), + m_z * v.x() - m_x * v.z(), + m_x * v.y() - m_y * v.x()); + } + + SIMD_FORCE_INLINE btScalar triple(const btVector3& v1, const btVector3& v2) const + { + return m_x * (v1.y() * v2.z() - v1.z() * v2.y()) + + m_y * (v1.z() * v2.x() - v1.x() * v2.z()) + + m_z * (v1.x() * v2.y() - v1.y() * v2.x()); + } + + SIMD_FORCE_INLINE int minAxis() const + { + return m_x < m_y ? (m_x < m_z ? 0 : 2) : (m_y < m_z ? 1 : 2); + } + + SIMD_FORCE_INLINE int maxAxis() const + { + return m_x < m_y ? (m_y < m_z ? 2 : 1) : (m_x < m_z ? 2 : 0); + } + + SIMD_FORCE_INLINE int furthestAxis() const + { + return absolute().minAxis(); + } + + SIMD_FORCE_INLINE int closestAxis() const + { + return absolute().maxAxis(); + } + + SIMD_FORCE_INLINE void setInterpolate3(const btVector3& v0, const btVector3& v1, btScalar rt) + { + btScalar s = 1.0f - rt; + m_x = s * v0[0] + rt * v1.x(); + m_y = s * v0[1] + rt * v1.y(); + m_z = s * v0[2] + rt * v1.z(); + //don't do the unused w component + // m_co[3] = s * v0[3] + rt * v1[3]; + } + + SIMD_FORCE_INLINE btVector3 lerp(const btVector3& v, const btScalar& t) const + { + return btVector3(m_x + (v.x() - m_x) * t, + m_y + (v.y() - m_y) * t, + m_z + (v.z() - m_z) * t); + } + + + SIMD_FORCE_INLINE btVector3& operator*=(const btVector3& v) + { + m_x *= v.x(); m_y *= v.y(); m_z *= v.z(); + return *this; + } + + + +}; + +SIMD_FORCE_INLINE btVector3 +operator+(const btVector3& v1, const btVector3& v2) +{ + return btVector3(v1.x() + v2.x(), v1.y() + v2.y(), v1.z() + v2.z()); +} + +SIMD_FORCE_INLINE btVector3 +operator*(const btVector3& v1, const btVector3& v2) +{ + return btVector3(v1.x() * v2.x(), v1.y() * v2.y(), v1.z() * v2.z()); +} + +SIMD_FORCE_INLINE btVector3 +operator-(const btVector3& v1, const btVector3& v2) +{ + return btVector3(v1.x() - v2.x(), v1.y() - v2.y(), v1.z() - v2.z()); +} + +SIMD_FORCE_INLINE btVector3 +operator-(const btVector3& v) +{ + return btVector3(-v.x(), -v.y(), -v.z()); +} + +SIMD_FORCE_INLINE btVector3 +operator*(const btVector3& v, const btScalar& s) +{ + return btVector3(v.x() * s, v.y() * s, v.z() * s); +} + +SIMD_FORCE_INLINE btVector3 +operator*(const btScalar& s, const btVector3& v) +{ + return v * s; +} + +SIMD_FORCE_INLINE btVector3 +operator/(const btVector3& v, const btScalar& s) +{ + assert(s != btScalar(0.0)); + return v * (btScalar(1.0) / s); +} + +SIMD_FORCE_INLINE btVector3 +operator/(const btVector3& v1, const btVector3& v2) +{ + return btVector3(v1.x() / v2.x(),v1.y() / v2.y(),v1.z() / v2.z()); +} + +SIMD_FORCE_INLINE btScalar +dot(const btVector3& v1, const btVector3& v2) +{ + return v1.dot(v2); +} + + + +SIMD_FORCE_INLINE btScalar +distance2(const btVector3& v1, const btVector3& v2) +{ + return v1.distance2(v2); +} + + +SIMD_FORCE_INLINE btScalar +distance(const btVector3& v1, const btVector3& v2) +{ + return v1.distance(v2); +} + +SIMD_FORCE_INLINE btScalar +angle(const btVector3& v1, const btVector3& v2) +{ + return v1.angle(v2); +} + +SIMD_FORCE_INLINE btVector3 +cross(const btVector3& v1, const btVector3& v2) +{ + return v1.cross(v2); +} + +SIMD_FORCE_INLINE btScalar +triple(const btVector3& v1, const btVector3& v2, const btVector3& v3) +{ + return v1.triple(v2, v3); +} + +SIMD_FORCE_INLINE btVector3 +lerp(const btVector3& v1, const btVector3& v2, const btScalar& t) +{ + return v1.lerp(v2, t); +} + + +SIMD_FORCE_INLINE bool operator==(const btVector3& p1, const btVector3& p2) +{ + return p1[0] == p2[0] && p1[1] == p2[1] && p1[2] == p2[2]; +} + +SIMD_FORCE_INLINE btScalar btVector3::distance2(const btVector3& v) const +{ + return (v - *this).length2(); +} + +SIMD_FORCE_INLINE btScalar btVector3::distance(const btVector3& v) const +{ + return (v - *this).length(); +} + +SIMD_FORCE_INLINE btVector3 btVector3::normalized() const +{ + return *this / length(); +} + +SIMD_FORCE_INLINE btVector3 btVector3::rotate( const btVector3& wAxis, const btScalar angle ) +{ + // wAxis must be a unit lenght vector + + btVector3 o = wAxis * wAxis.dot( *this ); + btVector3 x = *this - o; + btVector3 y; + + y = wAxis.cross( *this ); + + return ( o + x * btCos( angle ) + y * btSin( angle ) ); +} + +class btVector4 : public btVector3 +{ +public: + + SIMD_FORCE_INLINE btVector4() {} + + + SIMD_FORCE_INLINE btVector4(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) + : btVector3(x,y,z) + { + m_unusedW = w; + } + + + SIMD_FORCE_INLINE btVector4 absolute4() const + { + return btVector4( + btFabs(m_x), + btFabs(m_y), + btFabs(m_z), + btFabs(m_unusedW)); + } + + + + float getW() const { return m_unusedW;} + + + SIMD_FORCE_INLINE int maxAxis4() const + { + int maxIndex = -1; + float maxVal = -1e30f; + if (m_x > maxVal) + { + maxIndex = 0; + maxVal = m_x; + } + if (m_y > maxVal) + { + maxIndex = 1; + maxVal = m_y; + } + if (m_z > maxVal) + { + maxIndex = 2; + maxVal = m_z; + } + if (m_unusedW > maxVal) + { + maxIndex = 3; + maxVal = m_unusedW; + } + + + + + return maxIndex; + + } + + + SIMD_FORCE_INLINE int minAxis4() const + { + int minIndex = -1; + float minVal = 1e30f; + if (m_x < minVal) + { + minIndex = 0; + minVal = m_x; + } + if (m_y < minVal) + { + minIndex = 1; + minVal = m_y; + } + if (m_z < minVal) + { + minIndex = 2; + minVal = m_z; + } + if (m_unusedW < minVal) + { + minIndex = 3; + minVal = m_unusedW; + } + + return minIndex; + + } + + + SIMD_FORCE_INLINE int closestAxis4() const + { + return absolute4().maxAxis4(); + } + +}; + +#endif //SIMD__VECTOR3_H diff --git a/src/btBulletCollisionCommon.h b/src/btBulletCollisionCommon.h index 3cc1ff064..28095757f 100644 --- a/src/btBulletCollisionCommon.h +++ b/src/btBulletCollisionCommon.h @@ -18,7 +18,7 @@ subject to the following restrictions: ///Common headerfile includes for Bullet Collision Detection -///Bullet's CollisionWorld and CollisionObject definitions +///Bullet's btCollisionWorld and btCollisionObject definitions #include "BulletCollision/CollisionDispatch/btCollisionWorld.h" #include "BulletCollision/CollisionDispatch/btCollisionObject.h" @@ -50,9 +50,10 @@ subject to the following restrictions: ///Math library -#include "LinearMath/SimdQuaternion.h" -#include "LinearMath/SimdTransform.h" +#include "LinearMath/btQuaternion.h" +#include "LinearMath/btTransform.h" -#endif //BULLET_COLLISION_COMMON_H \ No newline at end of file +#endif //BULLET_COLLISION_COMMON_H + diff --git a/src/btBulletDynamicsCommon.h b/src/btBulletDynamicsCommon.h index b9789bb76..63765b998 100644 --- a/src/btBulletDynamicsCommon.h +++ b/src/btBulletDynamicsCommon.h @@ -19,6 +19,8 @@ subject to the following restrictions: ///Common headerfile includes for Bullet Dynamics, including Collision Detection #include "btBulletCollisionCommon.h" +#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" +#include "BulletDynamics/Dynamics/btSimpleDynamicsWorld.h" #include "BulletDynamics/Dynamics/btRigidBody.h" #include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h" #include "BulletDynamics/ConstraintSolver/btHingeConstraint.h" @@ -28,4 +30,5 @@ subject to the following restrictions: -#endif //BULLET_DYNAMICS_COMMON_H \ No newline at end of file +#endif //BULLET_DYNAMICS_COMMON_H +