diff --git a/btgui/OpenGLTrueTypeFont/main.cpp b/btgui/OpenGLTrueTypeFont/main.cpp index 984fed884..84a8a369f 100644 --- a/btgui/OpenGLTrueTypeFont/main.cpp +++ b/btgui/OpenGLTrueTypeFont/main.cpp @@ -471,7 +471,7 @@ int main(int argc, char* argv[]) while (!window->requestedExit()) { - CProfileManager::Reset(); + b3ProfileManager::Reset(); GLint err = glGetError(); b3Assert(err==GL_NO_ERROR); @@ -637,7 +637,7 @@ int main(int argc, char* argv[]) glFinish(); } - CProfileManager::Increment_Frame_Counter(); + b3ProfileManager::Increment_Frame_Counter(); static bool printStats = true; @@ -650,7 +650,7 @@ int main(int argc, char* argv[]) if (count<0) { count = 100; -// CProfileManager::dumpAll(); +// b3ProfileManager::dumpAll(); //printStats = false; } else { diff --git a/btgui/OpenGLWindow/GLInstancingRenderer.cpp b/btgui/OpenGLWindow/GLInstancingRenderer.cpp index 500bdb06d..693564e64 100644 --- a/btgui/OpenGLWindow/GLInstancingRenderer.cpp +++ b/btgui/OpenGLWindow/GLInstancingRenderer.cpp @@ -1007,7 +1007,7 @@ void GLInstancingRenderer::updateCamera() eyePos[m_forwardAxis] = -m_data->m_cameraDistance; b3Vector3 forward(eyePos[0],eyePos[1],eyePos[2]); - if (forward.length2() < SIMD_EPSILON) + if (forward.length2() < B3_EPSILON) { forward.setValue(1.f,0.f,0.f); } diff --git a/btgui/OpenGLWindow/gwenWindow.cpp b/btgui/OpenGLWindow/gwenWindow.cpp index 0b36ff4a7..06df2d15d 100644 --- a/btgui/OpenGLWindow/gwenWindow.cpp +++ b/btgui/OpenGLWindow/gwenWindow.cpp @@ -152,15 +152,15 @@ public: } - float dumpRecursive(CProfileIterator* profileIterator, Gwen::Controls::TreeNode* parentNode) + float dumpRecursive(b3ProfileIterator* profileIterator, Gwen::Controls::TreeNode* parentNode) { profileIterator->First(); if (profileIterator->Is_Done()) return 0.f; - float accumulated_time=0,parent_time = profileIterator->Is_Root() ? CProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time(); + float accumulated_time=0,parent_time = profileIterator->Is_Root() ? b3ProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time(); int i; - int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset(); + int frames_since_reset = b3ProfileManager::Get_Frame_Count_Since_Reset(); //printf("Profiling: %s (total running time: %.3f ms) ---\n", profileIterator->Get_Current_Parent_Name(), parent_time ); float totalTime = 0.f; @@ -175,7 +175,7 @@ public: numChildren++; float current_total_time = profileIterator->Get_Current_Total_Time(); accumulated_time += current_total_time; - double fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; + double fraction = parent_time > B3_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; Gwen::String name(profileIterator->Get_Current_Name()); #ifdef _WIN32 @@ -214,7 +214,7 @@ public: } - void UpdateText(CProfileIterator* profileIterator, bool idle) + void UpdateText(b3ProfileIterator* profileIterator, bool idle) { static bool update=true; @@ -232,7 +232,7 @@ public: static double time_since_reset = 0.f; if (!idle) { - time_since_reset = CProfileManager::Get_Time_Since_Reset(); + time_since_reset = b3ProfileManager::Get_Time_Since_Reset(); } //Gwen::UnicodeString txt = Gwen::Utility::Format( L"FEM Settings %i fps", test ); @@ -243,7 +243,7 @@ public: double totalTime = 0; - int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset(); + int frames_since_reset = b3ProfileManager::Get_Frame_Count_Since_Reset(); profileIterator->First(); @@ -258,10 +258,10 @@ public: #ifdef _WIN32 Gwen::UnicodeString uname = Gwen::Utility::StringToUnicode(name); Gwen::UnicodeString txt = Gwen::Utility::Format( L"Profiling: %s total time: %.3f ms, unaccounted %.3f %% :: %.3f ms", uname.c_str(), parent_time , - parent_time > SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time); + parent_time > B3_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time); #else Gwen::UnicodeString txt = Gwen::Utility::Format( L"Profiling: %s total time: %.3f ms, unaccounted %.3f %% :: %.3f ms", name, parent_time , - parent_time > SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time); + parent_time > B3_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time); #endif //sprintf(blockTime,"--- Profiling: %s (total running time: %.3f ms) ---", profileIterator->Get_Current_Parent_Name(), parent_time ); //displayProfileString(xOffset,yStart,blockTime); @@ -364,7 +364,7 @@ void resizeGUI(int width, int height) primRenderer->setScreenSize(width,height); } -void processProfileData(CProfileIterator* iterator, bool idle) +void processProfileData(b3ProfileIterator* iterator, bool idle) { if (profWindow) { diff --git a/btgui/OpenGLWindow/gwenWindow.h b/btgui/OpenGLWindow/gwenWindow.h index 19916f5c9..6f0940770 100644 --- a/btgui/OpenGLWindow/gwenWindow.h +++ b/btgui/OpenGLWindow/gwenWindow.h @@ -18,7 +18,7 @@ extern Gwen::Controls::Canvas* pCanvas; class GLPrimitiveRenderer; void setupGUI(int width, int height, sth_stash* font, float retinaScale,GLPrimitiveRenderer* primRender); -void processProfileData(class CProfileIterator* iterator, bool idle); +void processProfileData(class b3ProfileIterator* iterator, bool idle); void resizeGUI(int width, int height); #endif //MY_GWEN_WINDOW_H diff --git a/btgui/OpenGLWindow/main.cpp b/btgui/OpenGLWindow/main.cpp index cff1bcd32..18581a367 100644 --- a/btgui/OpenGLWindow/main.cpp +++ b/btgui/OpenGLWindow/main.cpp @@ -341,13 +341,13 @@ int main(int argc, char* argv[]) pCanvas->SetSize(g_OpenGLWidth,g_OpenGLHeight); } setupGUI(g_OpenGLWidth,g_OpenGLHeight,stash,retinaScale,primRenderer); - class CProfileIterator* m_profileIterator; - m_profileIterator = CProfileManager::Get_Iterator(); + class b3ProfileIterator* m_profileIterator; + m_profileIterator = b3ProfileManager::Get_Iterator(); glClearColor(1,1,1,1); while (!window->requestedExit()) { - CProfileManager::Reset(); + b3ProfileManager::Reset(); { B3_PROFILE("loop"); @@ -473,7 +473,7 @@ int main(int argc, char* argv[]) - CProfileManager::Increment_Frame_Counter(); + b3ProfileManager::Increment_Frame_Counter(); @@ -491,7 +491,7 @@ int main(int argc, char* argv[]) //B3_PROFILE("processProfileData"); processProfileData(m_profileIterator,false); } - //CProfileManager::dumpAll(); + //b3ProfileManager::dumpAll(); //printStats = false; } else { diff --git a/btgui/OpenGLWindow/renderscene.cpp b/btgui/OpenGLWindow/renderscene.cpp index 820399556..402e6fa19 100644 --- a/btgui/OpenGLWindow/renderscene.cpp +++ b/btgui/OpenGLWindow/renderscene.cpp @@ -114,7 +114,7 @@ void createSceneProgrammatically(GLInstancingRenderer& renderer) int tetraShapeIndex = -1; float position[4]={0,0,0,0}; - b3Quaternion born(b3Vector3(1,0,0),SIMD_PI*0.25*0.5); + b3Quaternion born(b3Vector3(1,0,0),B3_PI*0.25*0.5); float orn[4] = {0,0,0,1}; // float rotOrn[4] = {born.getX(),born.getY(),born.getZ(),born.getW()};// diff --git a/demo/donttouch/GpuDemo.cpp b/demo/donttouch/GpuDemo.cpp index 08a2805db..7f92ec67f 100644 --- a/demo/donttouch/GpuDemo.cpp +++ b/demo/donttouch/GpuDemo.cpp @@ -74,7 +74,7 @@ void GpuDemo::clientMoveAndDisplay() count++; if (count==25) { - //CProfileManager::dumpAll(); + //b3ProfileManager::dumpAll(); } } diff --git a/demo/donttouch/OpenGL3CoreRenderer.cpp b/demo/donttouch/OpenGL3CoreRenderer.cpp index cd2274fcc..fd8d2a874 100644 --- a/demo/donttouch/OpenGL3CoreRenderer.cpp +++ b/demo/donttouch/OpenGL3CoreRenderer.cpp @@ -311,7 +311,7 @@ GraphicsShape* createGraphicsShapeFromWavefrontObj(objLoader* obj) vtx.xyzw[1] = obj->vertexList[v]->e[1]; vtx.xyzw[2] = obj->vertexList[v]->e[2]; b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]); - if (n.length2()>SIMD_EPSILON) + if (n.length2()>B3_EPSILON) { n.normalize(); vtx.normal[0] = n[0]; diff --git a/demo/donttouch/b3GpuDynamicsWorld.cpp b/demo/donttouch/b3GpuDynamicsWorld.cpp index 01428d7ab..70f90a33f 100644 --- a/demo/donttouch/b3GpuDynamicsWorld.cpp +++ b/demo/donttouch/b3GpuDynamicsWorld.cpp @@ -46,7 +46,7 @@ void b3GpuDynamicsWorld::exitOpenCL() int b3GpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Scalar fixedTimeStep) { #ifndef B3_NO_PROFILE -// CProfileManager::Reset(); +// b3ProfileManager::Reset(); #endif //B3_NO_PROFILE B3_PROFILE("stepSimulation"); @@ -86,7 +86,7 @@ int b3GpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Sc #ifndef B3_NO_PROFILE - //CProfileManager::Increment_Frame_Counter(); + //b3ProfileManager::Increment_Frame_Counter(); #endif //B3_NO_PROFILE diff --git a/demo/gpu_initialize/main.cpp b/demo/gpu_initialize/main.cpp index d1de96c2f..aac207a6d 100644 --- a/demo/gpu_initialize/main.cpp +++ b/demo/gpu_initialize/main.cpp @@ -494,8 +494,8 @@ int main(int argc, char* argv[]) do { - CProfileManager::Reset(); - CProfileManager::Increment_Frame_Counter(); + b3ProfileManager::Reset(); + b3ProfileManager::Increment_Frame_Counter(); window->startRendering(); @@ -534,7 +534,7 @@ int main(int argc, char* argv[]) - CProfileManager::dumpAll(); + b3ProfileManager::dumpAll(); diff --git a/demo/gpudemo/ParticleDemo.cpp b/demo/gpudemo/ParticleDemo.cpp index 3d712a87f..780d67487 100644 --- a/demo/gpudemo/ParticleDemo.cpp +++ b/demo/gpudemo/ParticleDemo.cpp @@ -43,7 +43,7 @@ static char* particleKernelsString = -ATTRIBUTE_ALIGNED16(struct) b3SimParams +B3_ATTRIBUTE_ALIGNED16(struct) b3SimParams { B3_DECLARE_ALIGNED_ALLOCATOR(); b3Vector3 m_gravity; diff --git a/demo/gpudemo/broadphase/PairBench.cpp b/demo/gpudemo/broadphase/PairBench.cpp index adde27d19..61b4ed4ce 100644 --- a/demo/gpudemo/broadphase/PairBench.cpp +++ b/demo/gpudemo/broadphase/PairBench.cpp @@ -172,7 +172,7 @@ void PairBench::initPhysics(const ConstructionInfo& ci) m_instancingRenderer = ci.m_instancingRenderer; - CProfileManager::CleanupMemory(); + b3ProfileManager::CleanupMemory(); int strideInBytes = 9*sizeof(float); int numVertices = sizeof(cube_vertices)/strideInBytes; int numIndices = sizeof(cube_vertices)/sizeof(int); diff --git a/demo/gpudemo/main_opengl3core.cpp b/demo/gpudemo/main_opengl3core.cpp index b4ffe7b68..54485c0a5 100644 --- a/demo/gpudemo/main_opengl3core.cpp +++ b/demo/gpudemo/main_opengl3core.cpp @@ -325,15 +325,15 @@ void Usage() void DumpSimulationTime(FILE* f) { - CProfileIterator* profileIterator = CProfileManager::Get_Iterator(); + b3ProfileIterator* profileIterator = b3ProfileManager::Get_Iterator(); profileIterator->First(); if (profileIterator->Is_Done()) return; - float accumulated_time=0,parent_time = profileIterator->Is_Root() ? CProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time(); + float accumulated_time=0,parent_time = profileIterator->Is_Root() ? b3ProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time(); int i; - int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset(); + int frames_since_reset = b3ProfileManager::Get_Frame_Count_Since_Reset(); //fprintf(f,"%.3f,", parent_time ); float totalTime = 0.f; @@ -351,7 +351,7 @@ void DumpSimulationTime(FILE* f) { float current_total_time = profileIterator->Get_Current_Total_Time(); accumulated_time += current_total_time; - float fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; + float fraction = parent_time > B3_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; const char* name = profileIterator->Get_Current_Name(); fprintf(f,"%s,",name); } @@ -365,7 +365,7 @@ void DumpSimulationTime(FILE* f) { float current_total_time = profileIterator->Get_Current_Total_Time(); accumulated_time += current_total_time; - float fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; + float fraction = parent_time > B3_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; const char* name = profileIterator->Get_Current_Name(); //if (!strcmp(name,"stepSimulation")) { @@ -378,7 +378,7 @@ void DumpSimulationTime(FILE* f) fprintf(f,"\n"); - CProfileManager::Release_Iterator(profileIterator); + b3ProfileManager::Release_Iterator(profileIterator); } @@ -441,7 +441,7 @@ int main(int argc, char* argv[]) printf("-----------------------------------------------------\n"); #ifndef B3_NO_PROFILE - CProfileManager::Reset(); + b3ProfileManager::Reset(); #endif //B3_NO_PROFILE @@ -640,8 +640,8 @@ int main(int argc, char* argv[]) printf("-----------------------------------------------------\n"); do { - CProfileManager::Reset(); - CProfileManager::Increment_Frame_Counter(); + b3ProfileManager::Reset(); + b3ProfileManager::Increment_Frame_Counter(); // render.reshape(g_OpenGLWidth,g_OpenGLHeight); @@ -694,7 +694,7 @@ int main(int argc, char* argv[]) if (dump_timings) - CProfileManager::dumpAll(); + b3ProfileManager::dumpAll(); if (f) { @@ -715,7 +715,7 @@ int main(int argc, char* argv[]) demo->exitPhysics(); - CProfileManager::CleanupMemory(); + b3ProfileManager::CleanupMemory(); delete demo; if (f) fclose(f); diff --git a/demo/gpudemo/rigidbody/BulletDataExtractor.cpp b/demo/gpudemo/rigidbody/BulletDataExtractor.cpp index 3f45e9c42..0106a2a03 100644 --- a/demo/gpudemo/rigidbody/BulletDataExtractor.cpp +++ b/demo/gpudemo/rigidbody/BulletDataExtractor.cpp @@ -54,7 +54,7 @@ struct GraphicsShape struct InstanceGroup { - Bullet::b3CollisionShapeData* m_shape; + Bullet3SerializeBullet2::b3CollisionShapeData* m_shape; int m_collisionShapeIndex; b3AlignedObjectArray m_rigidBodies; @@ -198,7 +198,7 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2) for (i=0;im_collisionShapes.size();i++) { - Bullet::b3CollisionShapeData* shapeData = (Bullet::b3CollisionShapeData*)bulletFile2->m_collisionShapes[i]; + Bullet3SerializeBullet2::b3CollisionShapeData* shapeData = (Bullet3SerializeBullet2::b3CollisionShapeData*)bulletFile2->m_collisionShapes[i]; if (shapeData->m_name) printf("converting shape %s\n", shapeData->m_name); int shapeIndex = convertCollisionShape(shapeData); @@ -216,8 +216,8 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2) for (i=0;im_rigidBodies.size();i++) { - Bullet::b3RigidBodyFloatData* colObjData = (Bullet::b3RigidBodyFloatData*)bulletFile2->m_rigidBodies[i]; - Bullet::b3CollisionShapeData* shapeData = (Bullet::b3CollisionShapeData*)colObjData->m_collisionObjectData.m_collisionShape; + Bullet3SerializeBullet2::b3RigidBodyFloatData* colObjData = (Bullet3SerializeBullet2::b3RigidBodyFloatData*)bulletFile2->m_rigidBodies[i]; + Bullet3SerializeBullet2::b3CollisionShapeData* shapeData = (Bullet3SerializeBullet2::b3CollisionShapeData*)colObjData->m_collisionObjectData.m_collisionShape; for (int j=0;jm_shape == shapeData) @@ -237,7 +237,7 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2) for (int j=0;jm_rigidBodies.size();j++) { - Bullet::b3RigidBodyFloatData* colObjData = (Bullet::b3RigidBodyFloatData*)m_instanceGroups[i]->m_rigidBodies[j]; + Bullet3SerializeBullet2::b3RigidBodyFloatData* colObjData = (Bullet3SerializeBullet2::b3RigidBodyFloatData*)m_instanceGroups[i]->m_rigidBodies[j]; b3Matrix3x3 mat; mat.deSerializeFloat((const b3Matrix3x3FloatData&)colObjData->m_collisionObjectData.m_worldTransform.m_basis); @@ -283,7 +283,7 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2) -int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData* shapeData ) +int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3CollisionShapeData* shapeData ) { int shapeIndex = -1; @@ -291,7 +291,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData* { case STATIC_PLANE_PROXYTYPE: { - Bullet::b3StaticPlaneShapeData* planeData = (Bullet::b3StaticPlaneShapeData*)shapeData; + Bullet3SerializeBullet2::b3StaticPlaneShapeData* planeData = (Bullet3SerializeBullet2::b3StaticPlaneShapeData*)shapeData; shapeIndex = createPlaneShape(planeData->m_planeNormal,planeData->m_planeConstant, planeData->m_localScaling); break; } @@ -303,7 +303,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData* case MULTI_SPHERE_SHAPE_PROXYTYPE: case CONVEX_HULL_SHAPE_PROXYTYPE: { - Bullet::b3ConvexInternalShapeData* bsd = (Bullet::b3ConvexInternalShapeData*)shapeData; + Bullet3SerializeBullet2::b3ConvexInternalShapeData* bsd = (Bullet3SerializeBullet2::b3ConvexInternalShapeData*)shapeData; switch (shapeData->m_shapeType) { @@ -319,7 +319,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData* } case CONVEX_HULL_SHAPE_PROXYTYPE: { - Bullet::b3ConvexHullShapeData* convexData = (Bullet::b3ConvexHullShapeData*)bsd; + Bullet3SerializeBullet2::b3ConvexHullShapeData* convexData = (Bullet3SerializeBullet2::b3ConvexHullShapeData*)bsd; int numPoints = convexData->m_numUnscaledPoints; b3Vector3 localScaling; localScaling.deSerializeFloat((b3Vector3FloatData&)bsd->m_localScaling); @@ -441,13 +441,13 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData* case TRIANGLE_MESH_SHAPE_PROXYTYPE: { - Bullet::b3TriangleMeshShapeData* trimesh = (Bullet::b3TriangleMeshShapeData*)shapeData; + Bullet3SerializeBullet2::b3TriangleMeshShapeData* trimesh = (Bullet3SerializeBullet2::b3TriangleMeshShapeData*)shapeData; printf("numparts = %d\n",trimesh->m_meshInterface.m_numMeshParts); if (trimesh->m_meshInterface.m_numMeshParts) { for (int i=0;im_meshInterface.m_numMeshParts;i++) { - Bullet::b3MeshPartData& dat = trimesh->m_meshInterface.m_meshPartsPtr[i]; + Bullet3SerializeBullet2::b3MeshPartData& dat = trimesh->m_meshInterface.m_meshPartsPtr[i]; printf("numtris = %d, numverts = %d\n", dat.m_numTriangles,dat.m_numVertices);//,dat.m_vertices3f,dat.m_3indices16 printf("scaling = %f,%f,%f\n", trimesh->m_meshInterface.m_scaling.m_floats[0],trimesh->m_meshInterface.m_scaling.m_floats[1],trimesh->m_meshInterface.m_scaling.m_floats[2]); // dat. @@ -531,7 +531,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData* } -int b3BulletDataExtractor::createBoxShape( const Bullet::b3Vector3FloatData& halfDimensions, const Bullet::b3Vector3FloatData& localScaling, float collisionMargin) +int b3BulletDataExtractor::createBoxShape( const Bullet3SerializeBullet2::b3Vector3FloatData& halfDimensions, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling, float collisionMargin) { float cubeScaling[4] = { halfDimensions.m_floats[0]*localScaling.m_floats[0]+collisionMargin, @@ -561,14 +561,14 @@ int b3BulletDataExtractor::createBoxShape( const Bullet::b3Vector3FloatData& hal return cubeCollisionShapeIndex; } -int b3BulletDataExtractor::createSphereShape( float radius, const Bullet::b3Vector3FloatData& localScaling, float collisionMargin) +int b3BulletDataExtractor::createSphereShape( float radius, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling, float collisionMargin) { printf("createSphereShape with radius %f\n",radius); return -1; } -int b3BulletDataExtractor::createPlaneShape( const Bullet::b3Vector3FloatData& planeNormal, float planeConstant, const Bullet::b3Vector3FloatData& localScaling) +int b3BulletDataExtractor::createPlaneShape( const Bullet3SerializeBullet2::b3Vector3FloatData& planeNormal, float planeConstant, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling) { printf("createPlaneShape with normal %f,%f,%f and planeConstant\n",planeNormal.m_floats[0], planeNormal.m_floats[1],planeNormal.m_floats[2],planeConstant); return -1; @@ -590,7 +590,7 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromWavefrontObj(objLoa vtx.xyzw[1] = obj->vertexList[v]->e[1]; vtx.xyzw[2] = obj->vertexList[v]->e[2]; b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]); - if (n.length2()>SIMD_EPSILON) + if (n.length2()>B3_EPSILON) { n.normalize(); vtx.normal[0] = n[0]; diff --git a/demo/gpudemo/rigidbody/BulletDataExtractor.h b/demo/gpudemo/rigidbody/BulletDataExtractor.h index 8452f333c..3ffde6b91 100644 --- a/demo/gpudemo/rigidbody/BulletDataExtractor.h +++ b/demo/gpudemo/rigidbody/BulletDataExtractor.h @@ -35,13 +35,13 @@ class b3BulletDataExtractor virtual void convertAllObjects(bParse::b3BulletFile* bulletFile); //return -1 for invalid - virtual int convertCollisionShape( Bullet::b3CollisionShapeData* shapeData ); + virtual int convertCollisionShape( Bullet3SerializeBullet2::b3CollisionShapeData* shapeData ); - virtual int createPlaneShape( const Bullet::b3Vector3FloatData& planeNormal, float planeConstant, const Bullet::b3Vector3FloatData& localScaling); + virtual int createPlaneShape( const Bullet3SerializeBullet2::b3Vector3FloatData& planeNormal, float planeConstant, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling); - virtual int createBoxShape( const Bullet::b3Vector3FloatData& halfDimensions, const Bullet::b3Vector3FloatData& localScaling, float collisionMargin); + virtual int createBoxShape( const Bullet3SerializeBullet2::b3Vector3FloatData& halfDimensions, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling, float collisionMargin); - virtual int createSphereShape( float radius, const Bullet::b3Vector3FloatData& localScaling, float collisionMargin); + virtual int createSphereShape( float radius, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling, float collisionMargin); static GraphicsShape* createGraphicsShapeFromConvexHull(const b3Vector3* tmpPoints, int numPoints); static GraphicsShape* createGraphicsShapeFromWavefrontObj(class objLoader* obj); diff --git a/demo/gpudemo/rigidbody/ConcaveScene.cpp b/demo/gpudemo/rigidbody/ConcaveScene.cpp index 3c13aae8a..97f6440f2 100644 --- a/demo/gpudemo/rigidbody/ConcaveScene.cpp +++ b/demo/gpudemo/rigidbody/ConcaveScene.cpp @@ -39,7 +39,7 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(objLoader* obj) vtx.xyzw[1] = obj->vertexList[v]->e[1]; vtx.xyzw[2] = obj->vertexList[v]->e[2]; b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]); - if (n.length2()>SIMD_EPSILON) + if (n.length2()>B3_EPSILON) { n.normalize(); vtx.normal[0] = n[0]; diff --git a/opencl/gpu_narrowphase/host/b3ConvexHullContact.cpp b/opencl/gpu_narrowphase/host/b3ConvexHullContact.cpp index 82e93dcb2..fb1426765 100644 --- a/opencl/gpu_narrowphase/host/b3ConvexHullContact.cpp +++ b/opencl/gpu_narrowphase/host/b3ConvexHullContact.cpp @@ -433,7 +433,7 @@ void computeContactPlaneConvex(int pairIndex, b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane; b3Vector3 planeNormal(planeEq.x,planeEq.y,planeEq.z); - b3Vector3 planeNormalWorld = quatRotate(ornA,planeNormal); + b3Vector3 planeNormalWorld = b3QuatRotate(ornA,planeNormal); float planeConstant = planeEq.w; b3Transform convexWorldTransform; convexWorldTransform.setIdentity(); @@ -571,7 +571,7 @@ void computeContactPlaneCompound(int pairIndex, b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane; b3Vector3 planeNormal(planeEq.x,planeEq.y,planeEq.z); - b3Vector3 planeNormalWorld = quatRotate(ornA,planeNormal); + b3Vector3 planeNormalWorld = b3QuatRotate(ornA,planeNormal); float planeConstant = planeEq.w; b3Transform convexWorldTransform; convexWorldTransform.setIdentity(); diff --git a/opencl/gpu_narrowphase/host/b3ConvexPolyhedronCL.h b/opencl/gpu_narrowphase/host/b3ConvexPolyhedronCL.h index 1327d719f..7818194a6 100644 --- a/opencl/gpu_narrowphase/host/b3ConvexPolyhedronCL.h +++ b/opencl/gpu_narrowphase/host/b3ConvexPolyhedronCL.h @@ -10,7 +10,7 @@ struct b3GpuFace int m_numIndices; }; -ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL +B3_ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL { b3Vector3 m_localCenter; b3Vector3 m_extents; @@ -36,7 +36,7 @@ ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL int numVerts = m_numVertices; const b3Vector3 localDir = trans.getBasis().transpose()*dir; - const b3Vector3 localDi2 = quatRotate(trans.getRotation().inverse(),dir); + const b3Vector3 localDi2 = b3QuatRotate(trans.getRotation().inverse(),dir); b3Scalar offset = trans.getOrigin().dot(dir); diff --git a/opencl/gpu_narrowphase/host/b3ConvexUtility.cpp b/opencl/gpu_narrowphase/host/b3ConvexUtility.cpp index 609776ec1..500775725 100644 --- a/opencl/gpu_narrowphase/host/b3ConvexUtility.cpp +++ b/opencl/gpu_narrowphase/host/b3ConvexUtility.cpp @@ -146,7 +146,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices, { //do the merge: use Graham Scan 2d convex hull - b3AlignedObjectArray orgpoints; + b3AlignedObjectArray orgpoints; b3Vector3 averageFaceNormal(0,0,0); for (int i=0;i hull; + b3AlignedObjectArray hull; averageFaceNormal.normalize(); - GrahamScanConvexHull2D(orgpoints,hull,averageFaceNormal); + b3GrahamScanConvexHull2D(orgpoints,hull,averageFaceNormal); for (int i=0;im_aabbMinOrg,rootNode->m_aabbMaxOrg); + aabbOverlap = b3TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg); isLeafNode = rootNode->m_escapeIndex == -1; //PCK: unsigned instead of bool @@ -422,7 +422,7 @@ void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const b3Quantize unsigned aabbOverlap; //PCK: unsigned instead of bool - aabbOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,currentNode->m_quantizedAabbMin,currentNode->m_quantizedAabbMax); + aabbOverlap = b3TestQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,currentNode->m_quantizedAabbMin,currentNode->m_quantizedAabbMax); isLeafNode = currentNode->isLeafNode(); //PCK: unsigned instead of bool @@ -496,7 +496,7 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(b3NodeOverlapCallback* nodeCall bounds[0] -= aabbMax; bounds[1] -= aabbMin; - aabbOverlap = TestAabbAgainstAabb2(rayAabbMin,rayAabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg); + aabbOverlap = b3TestAabbAgainstAabb2(rayAabbMin,rayAabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg); //perhaps profile if it is worth doing the aabbOverlap test first #ifdef RAYAABB2 @@ -609,7 +609,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(b3NodeOverlapCallback* // only interested if this is closer than any previous hit b3Scalar param = 1.0; rayBoxOverlap = 0; - boxBoxOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax); + boxBoxOverlap = b3TestQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax); isLeafNode = rootNode->isLeafNode(); if (boxBoxOverlap) { @@ -703,7 +703,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTree(b3NodeOverlapCallback* nodeCallb walkIterations++; //PCK: unsigned instead of bool - aabbOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax); + aabbOverlap = b3TestQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax); isLeafNode = rootNode->isLeafNode(); if (isLeafNode && aabbOverlap) @@ -741,7 +741,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(b3NodeOverlapCallba const b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i]; //PCK: unsigned instead of bool - unsigned overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax); + unsigned overlap = b3TestQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax); if (overlap != 0) { walkStacklessQuantizedTree(nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax, diff --git a/opencl/gpu_narrowphase/host/b3QuantizedBvh.h b/opencl/gpu_narrowphase/host/b3QuantizedBvh.h index 49d778ef1..2292ee834 100644 --- a/opencl/gpu_narrowphase/host/b3QuantizedBvh.h +++ b/opencl/gpu_narrowphase/host/b3QuantizedBvh.h @@ -55,7 +55,7 @@ class b3Serializer; ///b3QuantizedBvhNode is a compressed aabb node, 16 bytes. ///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range). -ATTRIBUTE_ALIGNED16 (struct) b3QuantizedBvhNode +B3_ATTRIBUTE_ALIGNED16 (struct) b3QuantizedBvhNode { B3_DECLARE_ALIGNED_ALLOCATOR(); @@ -94,7 +94,7 @@ ATTRIBUTE_ALIGNED16 (struct) b3QuantizedBvhNode /// b3OptimizedBvhNode contains both internal and leaf node information. /// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes. -ATTRIBUTE_ALIGNED16 (struct) b3OptimizedBvhNode +B3_ATTRIBUTE_ALIGNED16 (struct) b3OptimizedBvhNode { B3_DECLARE_ALIGNED_ALLOCATOR(); @@ -116,7 +116,7 @@ ATTRIBUTE_ALIGNED16 (struct) b3OptimizedBvhNode ///b3BvhSubtreeInfo provides info to gather a subtree of limited size -ATTRIBUTE_ALIGNED16(class) b3BvhSubtreeInfo +B3_ATTRIBUTE_ALIGNED16(class) b3BvhSubtreeInfo { public: B3_DECLARE_ALIGNED_ALLOCATOR(); @@ -171,7 +171,7 @@ typedef b3AlignedObjectArray BvhSubtreeInfoArray; ///The b3QuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU. ///It is used by the b3BvhTriangleMeshShape as midphase, and by the b3MultiSapBroadphase. ///It is recommended to use quantization for better performance and lower memory requirements. -ATTRIBUTE_ALIGNED16(class) b3QuantizedBvh +B3_ATTRIBUTE_ALIGNED16(class) b3QuantizedBvh { public: enum b3TraversalMode @@ -350,7 +350,7 @@ public: void reportRayOverlappingNodex (b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const; void reportBoxCastOverlappingNodex(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const; - SIMD_FORCE_INLINE void quantize(unsigned short* out, const b3Vector3& point,int isMax) const + B3_FORCE_INLINE void quantize(unsigned short* out, const b3Vector3& point,int isMax) const { b3Assert(m_useQuantization); @@ -417,7 +417,7 @@ public: } - SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const b3Vector3& point2,int isMax) const + B3_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const b3Vector3& point2,int isMax) const { b3Assert(m_useQuantization); @@ -430,7 +430,7 @@ public: } - SIMD_FORCE_INLINE b3Vector3 unQuantize(const unsigned short* vecIn) const + B3_FORCE_INLINE b3Vector3 unQuantize(const unsigned short* vecIn) const { b3Vector3 vecOut; vecOut.setValue( @@ -448,13 +448,13 @@ public: } - SIMD_FORCE_INLINE QuantizedNodeArray& getQuantizedNodeArray() + B3_FORCE_INLINE QuantizedNodeArray& getQuantizedNodeArray() { return m_quantizedContiguousNodes; } - SIMD_FORCE_INLINE BvhSubtreeInfoArray& getSubtreeInfoArray() + B3_FORCE_INLINE BvhSubtreeInfoArray& getSubtreeInfoArray() { return m_SubtreeHeaders; } @@ -486,7 +486,7 @@ public: //////////////////////////////////////////////////////////////////// - SIMD_FORCE_INLINE bool isQuantized() + B3_FORCE_INLINE bool isQuantized() { return m_useQuantization; } @@ -572,7 +572,7 @@ struct b3QuantizedBvhDoubleData }; -SIMD_FORCE_INLINE int b3QuantizedBvh::calculateSerializeBufferSizeNew() const +B3_FORCE_INLINE int b3QuantizedBvh::calculateSerializeBufferSizeNew() const { return sizeof(b3QuantizedBvhData); } diff --git a/opencl/gpu_narrowphase/host/b3StridingMeshInterface.h b/opencl/gpu_narrowphase/host/b3StridingMeshInterface.h index 4ec11d12c..d5897de97 100644 --- a/opencl/gpu_narrowphase/host/b3StridingMeshInterface.h +++ b/opencl/gpu_narrowphase/host/b3StridingMeshInterface.h @@ -30,7 +30,7 @@ enum PHY_ScalarType { /// The b3StridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with b3BvhTriangleMeshShape and some other collision shapes. /// Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips. /// It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory. -ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface +B3_ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface { protected: @@ -157,7 +157,7 @@ struct b3StridingMeshInterfaceData -SIMD_FORCE_INLINE int b3StridingMeshInterface::calculateSerializeBufferSize() const +B3_FORCE_INLINE int b3StridingMeshInterface::calculateSerializeBufferSize() const { return sizeof(b3StridingMeshInterfaceData); } diff --git a/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.h b/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.h index c8f1ec97b..d26b2893b 100644 --- a/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.h +++ b/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.h @@ -23,7 +23,7 @@ subject to the following restrictions: ///The b3IndexedMesh indexes a single vertex and index array. Multiple b3IndexedMesh objects can be passed into a b3TriangleIndexVertexArray using addIndexedMesh. ///Instead of the number of indices, we pass the number of triangles. -ATTRIBUTE_ALIGNED16( struct) b3IndexedMesh +B3_ATTRIBUTE_ALIGNED16( struct) b3IndexedMesh { B3_DECLARE_ALIGNED_ALLOCATOR(); @@ -65,7 +65,7 @@ typedef b3AlignedObjectArray IndexedMeshArray; ///Additional meshes can be added using addIndexedMesh ///No duplcate is made of the vertex/index data, it only indexes into external vertex/index arrays. ///So keep those arrays around during the lifetime of this b3TriangleIndexVertexArray. -ATTRIBUTE_ALIGNED16( class) b3TriangleIndexVertexArray : public b3StridingMeshInterface +B3_ATTRIBUTE_ALIGNED16( class) b3TriangleIndexVertexArray : public b3StridingMeshInterface { protected: IndexedMeshArray m_indexedMeshes; diff --git a/opencl/gpu_rigidbody/host/b3GpuBatchingPgsSolver.cpp b/opencl/gpu_rigidbody/host/b3GpuBatchingPgsSolver.cpp index c1ddefce4..76aef9a9f 100644 --- a/opencl/gpu_rigidbody/host/b3GpuBatchingPgsSolver.cpp +++ b/opencl/gpu_rigidbody/host/b3GpuBatchingPgsSolver.cpp @@ -12,10 +12,10 @@ #include "b3Solver.h" -#define SOLVER_SETUP_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup.cl" -#define SOLVER_SETUP2_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup2.cl" -#define SOLVER_CONTACT_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveContact.cl" -#define SOLVER_FRICTION_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveFriction.cl" +#define B3_SOLVER_SETUP_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup.cl" +#define B3_SOLVER_SETUP2_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup2.cl" +#define B3_SOLVER_CONTACT_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveContact.cl" +#define B3_SOLVER_FRICTION_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveFriction.cl" #define BATCHING_PATH "opencl/gpu_rigidbody/kernels/batchingKernels.cl" #define BATCHING_NEW_PATH "opencl/gpu_rigidbody/kernels/batchingKernelsNew.cl" @@ -131,17 +131,17 @@ b3GpuBatchingPgsSolver::b3GpuBatchingPgsSolver(cl_context ctx,cl_device_id devic { - cl_program solveContactProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveContactSource, &pErrNum,additionalMacros, SOLVER_CONTACT_KERNEL_PATH); + cl_program solveContactProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveContactSource, &pErrNum,additionalMacros, B3_SOLVER_CONTACT_KERNEL_PATH); b3Assert(solveContactProg); - cl_program solveFrictionProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveFrictionSource, &pErrNum,additionalMacros, SOLVER_FRICTION_KERNEL_PATH); + cl_program solveFrictionProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveFrictionSource, &pErrNum,additionalMacros, B3_SOLVER_FRICTION_KERNEL_PATH); b3Assert(solveFrictionProg); - cl_program solverSetup2Prog= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetup2Source, &pErrNum,additionalMacros, SOLVER_SETUP2_KERNEL_PATH); + cl_program solverSetup2Prog= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetup2Source, &pErrNum,additionalMacros, B3_SOLVER_SETUP2_KERNEL_PATH); b3Assert(solverSetup2Prog); - cl_program solverSetupProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetupSource, &pErrNum,additionalMacros, SOLVER_SETUP_KERNEL_PATH); + cl_program solverSetupProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetupSource, &pErrNum,additionalMacros, B3_SOLVER_SETUP_KERNEL_PATH); b3Assert(solverSetupProg); diff --git a/opencl/gpu_rigidbody/host/b3GpuConstraint4.h b/opencl/gpu_rigidbody/host/b3GpuConstraint4.h index 1783cf38f..009447dac 100644 --- a/opencl/gpu_rigidbody/host/b3GpuConstraint4.h +++ b/opencl/gpu_rigidbody/host/b3GpuConstraint4.h @@ -3,7 +3,7 @@ #define B3_CONSTRAINT4_h #include "Bullet3Common/b3Vector3.h" -ATTRIBUTE_ALIGNED16(struct) b3GpuConstraint4 +B3_ATTRIBUTE_ALIGNED16(struct) b3GpuConstraint4 { B3_DECLARE_ALIGNED_ALLOCATOR(); diff --git a/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.cpp b/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.cpp index 74d9a5db3..c0f77abd8 100644 --- a/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.cpp +++ b/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.cpp @@ -16,7 +16,7 @@ //#define TEST_OTHER_GPU_SOLVER bool useDbvt = false; -bool useBullet2CpuSolver = true;//false; +bool useBullet2CpuSolver = false;//false; bool dumpContactStats = false; #ifdef TEST_OTHER_GPU_SOLVER @@ -41,7 +41,7 @@ b3GpuRigidBodyPipeline::b3GpuRigidBodyPipeline(cl_context ctx,cl_device_id devic m_data->m_device = device; m_data->m_queue = q; - m_data->m_solver = new b3PgsJacobiSolver(); + m_data->m_solver = new b3PgsJacobiSolver(true); b3Config config; m_data->m_allAabbsGPU = new b3OpenCLArray(ctx,q,config.m_maxConvexBodies); m_data->m_overlappingPairsGPU = new b3OpenCLArray(ctx,q,config.m_maxBroadphasePairs); diff --git a/opencl/gpu_rigidbody/host/b3Solver.cpp b/opencl/gpu_rigidbody/host/b3Solver.cpp index 8180a9b75..7d91b4e7d 100644 --- a/opencl/gpu_rigidbody/host/b3Solver.cpp +++ b/opencl/gpu_rigidbody/host/b3Solver.cpp @@ -19,11 +19,11 @@ subject to the following restrictions: ///useNewBatchingKernel is a rewritten kernel using just a single thread of the warp, for experiments bool useNewBatchingKernel = true; -#define SOLVER_SETUP_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup.cl" -#define SOLVER_SETUP2_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup2.cl" +#define B3_SOLVER_SETUP_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup.cl" +#define B3_SOLVER_SETUP2_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup2.cl" -#define SOLVER_CONTACT_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveContact.cl" -#define SOLVER_FRICTION_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveFriction.cl" +#define B3_SOLVER_CONTACT_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveContact.cl" +#define B3_SOLVER_FRICTION_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveFriction.cl" #define BATCHING_PATH "opencl/gpu_rigidbody/kernels/batchingKernels.cl" #define BATCHING_NEW_PATH "opencl/gpu_rigidbody/kernels/batchingKernelsNew.cl" @@ -125,17 +125,17 @@ b3Solver::b3Solver(cl_context ctx, cl_device_id device, cl_command_queue queue, { - cl_program solveContactProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveContactSource, &pErrNum,additionalMacros, SOLVER_CONTACT_KERNEL_PATH); + cl_program solveContactProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveContactSource, &pErrNum,additionalMacros, B3_SOLVER_CONTACT_KERNEL_PATH); b3Assert(solveContactProg); - cl_program solveFrictionProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveFrictionSource, &pErrNum,additionalMacros, SOLVER_FRICTION_KERNEL_PATH); + cl_program solveFrictionProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveFrictionSource, &pErrNum,additionalMacros, B3_SOLVER_FRICTION_KERNEL_PATH); b3Assert(solveFrictionProg); - cl_program solverSetup2Prog= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetup2Source, &pErrNum,additionalMacros, SOLVER_SETUP2_KERNEL_PATH); + cl_program solverSetup2Prog= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetup2Source, &pErrNum,additionalMacros, B3_SOLVER_SETUP2_KERNEL_PATH); b3Assert(solverSetup2Prog); - cl_program solverSetupProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetupSource, &pErrNum,additionalMacros, SOLVER_SETUP_KERNEL_PATH); + cl_program solverSetupProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetupSource, &pErrNum,additionalMacros, B3_SOLVER_SETUP_KERNEL_PATH); b3Assert(solverSetupProg); diff --git a/opencl/parallel_primitives/host/b3Int4.h b/opencl/parallel_primitives/host/b3Int4.h index ed043f1ea..41e049cb9 100644 --- a/opencl/parallel_primitives/host/b3Int4.h +++ b/opencl/parallel_primitives/host/b3Int4.h @@ -3,7 +3,7 @@ #include "Bullet3Common/b3Scalar.h" -ATTRIBUTE_ALIGNED16(struct) b3UnsignedInt4 +B3_ATTRIBUTE_ALIGNED16(struct) b3UnsignedInt4 { B3_DECLARE_ALIGNED_ALLOCATOR(); @@ -20,7 +20,7 @@ ATTRIBUTE_ALIGNED16(struct) b3UnsignedInt4 }; }; -ATTRIBUTE_ALIGNED16(struct) b3Int4 +B3_ATTRIBUTE_ALIGNED16(struct) b3Int4 { B3_DECLARE_ALIGNED_ALLOCATOR(); @@ -37,14 +37,14 @@ ATTRIBUTE_ALIGNED16(struct) b3Int4 }; }; -SIMD_FORCE_INLINE b3Int4 b3MakeInt4(int x, int y, int z, int w = 0) +B3_FORCE_INLINE b3Int4 b3MakeInt4(int x, int y, int z, int w = 0) { b3Int4 v; v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w; return v; } -SIMD_FORCE_INLINE b3UnsignedInt4 b3MakeUnsignedInt4(unsigned int x, unsigned int y, unsigned int z, unsigned int w = 0) +B3_FORCE_INLINE b3UnsignedInt4 b3MakeUnsignedInt4(unsigned int x, unsigned int y, unsigned int z, unsigned int w = 0) { b3UnsignedInt4 v; v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w; diff --git a/opencl/parallel_primitives/host/b3OpenCLArray.h b/opencl/parallel_primitives/host/b3OpenCLArray.h index 05277cab8..2c100bd7f 100644 --- a/opencl/parallel_primitives/host/b3OpenCLArray.h +++ b/opencl/parallel_primitives/host/b3OpenCLArray.h @@ -30,7 +30,7 @@ class b3OpenCLArray b3OpenCLArray& operator=(const b3OpenCLArray& src); - SIMD_FORCE_INLINE int allocSize(int size) + B3_FORCE_INLINE int allocSize(int size) { return (size ? size*2 : 1); } @@ -81,7 +81,7 @@ public: m_capacity=0; } - SIMD_FORCE_INLINE void push_back(const T& _Val,bool waitForCompletion=true) + B3_FORCE_INLINE void push_back(const T& _Val,bool waitForCompletion=true) { int sz = size(); if( sz == capacity() ) @@ -92,7 +92,7 @@ public: m_size++; } - SIMD_FORCE_INLINE T forcedAt(int n) const + B3_FORCE_INLINE T forcedAt(int n) const { b3Assert(n>=0); b3Assert(n=0); b3Assert(n tNodeArray; -typedef b3AlignedObjectArray tConstNodeArray; +typedef b3AlignedObjectArray b3NodeArray; +typedef b3AlignedObjectArray b3ConstNodeArray; // struct b3DbvtNodeEnumerator : b3DynamicBvh::ICollide { - tConstNodeArray nodes; + b3ConstNodeArray nodes; void Process(const b3DbvtNode* n) { nodes.push_back(n); } }; // -static DBVT_INLINE int indexof(const b3DbvtNode* node) +static B3_DBVT_INLINE int b3IndexOf(const b3DbvtNode* node) { return(node->parent->childs[1]==node); } // -static DBVT_INLINE b3DbvtVolume merge( const b3DbvtVolume& a, +static B3_DBVT_INLINE b3DbvtVolume b3Merge( const b3DbvtVolume& a, const b3DbvtVolume& b) { -#if (DBVT_MERGE_IMPL==DBVT_IMPL_SSE) - ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtAabbMm)]); +#if (B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE) + B3_ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtAabbMm)]); b3DbvtVolume& res=*(b3DbvtVolume*)locals; #else b3DbvtVolume res; #endif - Merge(a,b,res); + b3Merge(a,b,res); return(res); } // volume+edge lengths -static DBVT_INLINE b3Scalar size(const b3DbvtVolume& a) +static B3_DBVT_INLINE b3Scalar b3Size(const b3DbvtVolume& a) { const b3Vector3 edges=a.Lengths(); return( edges.x*edges.y*edges.z+ @@ -56,17 +56,17 @@ static DBVT_INLINE b3Scalar size(const b3DbvtVolume& a) } // -static void getmaxdepth(const b3DbvtNode* node,int depth,int& maxdepth) +static void b3GetMaxDepth(const b3DbvtNode* node,int depth,int& maxdepth) { if(node->isinternal()) { - getmaxdepth(node->childs[0],depth+1,maxdepth); - getmaxdepth(node->childs[1],depth+1,maxdepth); + b3GetMaxDepth(node->childs[0],depth+1,maxdepth); + b3GetMaxDepth(node->childs[1],depth+1,maxdepth); } else maxdepth=b3Max(maxdepth,depth); } // -static DBVT_INLINE void deletenode( b3DynamicBvh* pdbvt, +static B3_DBVT_INLINE void b3DeleteNode( b3DynamicBvh* pdbvt, b3DbvtNode* node) { b3AlignedFree(pdbvt->m_free); @@ -74,20 +74,20 @@ static DBVT_INLINE void deletenode( b3DynamicBvh* pdbvt, } // -static void recursedeletenode( b3DynamicBvh* pdbvt, +static void b3RecurseDeleteNode( b3DynamicBvh* pdbvt, b3DbvtNode* node) { if(!node->isleaf()) { - recursedeletenode(pdbvt,node->childs[0]); - recursedeletenode(pdbvt,node->childs[1]); + b3RecurseDeleteNode(pdbvt,node->childs[0]); + b3RecurseDeleteNode(pdbvt,node->childs[1]); } if(node==pdbvt->m_root) pdbvt->m_root=0; - deletenode(pdbvt,node); + b3DeleteNode(pdbvt,node); } // -static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt, +static B3_DBVT_INLINE b3DbvtNode* b3CreateNode( b3DynamicBvh* pdbvt, b3DbvtNode* parent, void* data) { @@ -103,30 +103,30 @@ static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt, } // -static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt, +static B3_DBVT_INLINE b3DbvtNode* b3CreateNode( b3DynamicBvh* pdbvt, b3DbvtNode* parent, const b3DbvtVolume& volume, void* data) { - b3DbvtNode* node=createnode(pdbvt,parent,data); + b3DbvtNode* node=b3CreateNode(pdbvt,parent,data); node->volume=volume; return(node); } // -static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt, +static B3_DBVT_INLINE b3DbvtNode* b3CreateNode( b3DynamicBvh* pdbvt, b3DbvtNode* parent, const b3DbvtVolume& volume0, const b3DbvtVolume& volume1, void* data) { - b3DbvtNode* node=createnode(pdbvt,parent,data); - Merge(volume0,volume1,node->volume); + b3DbvtNode* node=b3CreateNode(pdbvt,parent,data); + b3Merge(volume0,volume1,node->volume); return(node); } // -static void insertleaf( b3DynamicBvh* pdbvt, +static void b3InsertLeaf( b3DynamicBvh* pdbvt, b3DbvtNode* root, b3DbvtNode* leaf) { @@ -140,21 +140,21 @@ static void insertleaf( b3DynamicBvh* pdbvt, if(!root->isleaf()) { do { - root=root->childs[Select( leaf->volume, + root=root->childs[b3Select( leaf->volume, root->childs[0]->volume, root->childs[1]->volume)]; } while(!root->isleaf()); } b3DbvtNode* prev=root->parent; - b3DbvtNode* node=createnode(pdbvt,prev,leaf->volume,root->volume,0); + b3DbvtNode* node=b3CreateNode(pdbvt,prev,leaf->volume,root->volume,0); if(prev) { - prev->childs[indexof(root)] = node; + prev->childs[b3IndexOf(root)] = node; node->childs[0] = root;root->parent=node; node->childs[1] = leaf;leaf->parent=node; do { if(!prev->volume.Contain(node->volume)) - Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume); + b3Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume); else break; node=prev; @@ -170,7 +170,7 @@ static void insertleaf( b3DynamicBvh* pdbvt, } // -static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt, +static b3DbvtNode* b3RemoveLeaf( b3DynamicBvh* pdbvt, b3DbvtNode* leaf) { if(leaf==pdbvt->m_root) @@ -182,17 +182,17 @@ static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt, { b3DbvtNode* parent=leaf->parent; b3DbvtNode* prev=parent->parent; - b3DbvtNode* sibling=parent->childs[1-indexof(leaf)]; + b3DbvtNode* sibling=parent->childs[1-b3IndexOf(leaf)]; if(prev) { - prev->childs[indexof(parent)]=sibling; + prev->childs[b3IndexOf(parent)]=sibling; sibling->parent=prev; - deletenode(pdbvt,parent); + b3DeleteNode(pdbvt,parent); while(prev) { const b3DbvtVolume pb=prev->volume; - Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume); - if(NotEqual(pb,prev->volume)) + b3Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume); + if(b3NotEqual(pb,prev->volume)) { prev=prev->parent; } else break; @@ -203,23 +203,23 @@ static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt, { pdbvt->m_root=sibling; sibling->parent=0; - deletenode(pdbvt,parent); + b3DeleteNode(pdbvt,parent); return(pdbvt->m_root); } } } // -static void fetchleaves(b3DynamicBvh* pdbvt, +static void b3FetchLeaves(b3DynamicBvh* pdbvt, b3DbvtNode* root, - tNodeArray& leaves, + b3NodeArray& leaves, int depth=-1) { if(root->isinternal()&&depth) { - fetchleaves(pdbvt,root->childs[0],leaves,depth-1); - fetchleaves(pdbvt,root->childs[1],leaves,depth-1); - deletenode(pdbvt,root); + b3FetchLeaves(pdbvt,root->childs[0],leaves,depth-1); + b3FetchLeaves(pdbvt,root->childs[1],leaves,depth-1); + b3DeleteNode(pdbvt,root); } else { @@ -228,9 +228,9 @@ static void fetchleaves(b3DynamicBvh* pdbvt, } // -static void split( const tNodeArray& leaves, - tNodeArray& left, - tNodeArray& right, +static void b3Split( const b3NodeArray& leaves, + b3NodeArray& left, + b3NodeArray& right, const b3Vector3& org, const b3Vector3& axis) { @@ -246,10 +246,10 @@ static void split( const tNodeArray& leaves, } // -static b3DbvtVolume bounds( const tNodeArray& leaves) +static b3DbvtVolume b3Bounds( const b3NodeArray& leaves) { -#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE - ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtVolume)]); +#if B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE + B3_ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtVolume)]); b3DbvtVolume& volume=*(b3DbvtVolume*)locals; volume=leaves[0]->volume; #else @@ -257,24 +257,24 @@ static b3DbvtVolume bounds( const tNodeArray& leaves) #endif for(int i=1,ni=leaves.size();ivolume,volume); + b3Merge(volume,leaves[i]->volume,volume); } return(volume); } // -static void bottomup( b3DynamicBvh* pdbvt, - tNodeArray& leaves) +static void b3BottomUp( b3DynamicBvh* pdbvt, + b3NodeArray& leaves) { while(leaves.size()>1) { - b3Scalar minsize=SIMD_INFINITY; + b3Scalar minsize=B3_INFINITY; int minidx[2]={-1,-1}; for(int i=0;ivolume,leaves[j]->volume)); + const b3Scalar sz=b3Size(b3Merge(leaves[i]->volume,leaves[j]->volume)); if(szvolume,n[1]->volume,0); + b3DbvtNode* p = b3CreateNode(pdbvt,0,n[0]->volume,n[1]->volume,0); p->childs[0] = n[0]; p->childs[1] = n[1]; n[0]->parent = p; @@ -296,8 +296,8 @@ static void bottomup( b3DynamicBvh* pdbvt, } // -static b3DbvtNode* topdown(b3DynamicBvh* pdbvt, - tNodeArray& leaves, +static b3DbvtNode* b3TopDown(b3DynamicBvh* pdbvt, + b3NodeArray& leaves, int bu_treshold) { static const b3Vector3 axis[]={b3Vector3(1,0,0), @@ -307,9 +307,9 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt, { if(leaves.size()>bu_treshold) { - const b3DbvtVolume vol=bounds(leaves); + const b3DbvtVolume vol=b3Bounds(leaves); const b3Vector3 org=vol.Center(); - tNodeArray sets[2]; + b3NodeArray sets[2]; int bestaxis=-1; int bestmidp=leaves.size(); int splitcount[3][2]={{0,0},{0,0},{0,0}}; @@ -338,7 +338,7 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt, { sets[0].reserve(splitcount[bestaxis][0]); sets[1].reserve(splitcount[bestaxis][1]); - split(leaves,sets[0],sets[1],org,axis[bestaxis]); + b3Split(leaves,sets[0],sets[1],org,axis[bestaxis]); } else { @@ -349,16 +349,16 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt, sets[i&1].push_back(leaves[i]); } } - b3DbvtNode* node=createnode(pdbvt,0,vol,0); - node->childs[0]=topdown(pdbvt,sets[0],bu_treshold); - node->childs[1]=topdown(pdbvt,sets[1],bu_treshold); + b3DbvtNode* node=b3CreateNode(pdbvt,0,vol,0); + node->childs[0]=b3TopDown(pdbvt,sets[0],bu_treshold); + node->childs[1]=b3TopDown(pdbvt,sets[1],bu_treshold); node->childs[0]->parent=node; node->childs[1]->parent=node; return(node); } else { - bottomup(pdbvt,leaves); + b3BottomUp(pdbvt,leaves); return(leaves[0]); } } @@ -366,18 +366,18 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt, } // -static DBVT_INLINE b3DbvtNode* sort(b3DbvtNode* n,b3DbvtNode*& r) +static B3_DBVT_INLINE b3DbvtNode* b3Sort(b3DbvtNode* n,b3DbvtNode*& r) { b3DbvtNode* p=n->parent; b3Assert(n->isinternal()); if(p>n) { - const int i=indexof(n); + const int i=b3IndexOf(n); const int j=1-i; b3DbvtNode* s=p->childs[j]; b3DbvtNode* q=p->parent; b3Assert(n==p->childs[i]); - if(q) q->childs[indexof(p)]=n; else r=n; + if(q) q->childs[b3IndexOf(p)]=n; else r=n; s->parent=n; p->parent=n; n->parent=q; @@ -394,7 +394,7 @@ static DBVT_INLINE b3DbvtNode* sort(b3DbvtNode* n,b3DbvtNode*& r) } #if 0 -static DBVT_INLINE b3DbvtNode* walkup(b3DbvtNode* n,int count) +static B3_DBVT_INLINE b3DbvtNode* walkup(b3DbvtNode* n,int count) { while(n&&(count--)) n=n->parent; return(n); @@ -425,7 +425,7 @@ b3DynamicBvh::~b3DynamicBvh() void b3DynamicBvh::clear() { if(m_root) - recursedeletenode(this,m_root); + b3RecurseDeleteNode(this,m_root); b3AlignedFree(m_free); m_free=0; m_lkhd = -1; @@ -439,10 +439,10 @@ void b3DynamicBvh::optimizeBottomUp() { if(m_root) { - tNodeArray leaves; + b3NodeArray leaves; leaves.reserve(m_leaves); - fetchleaves(this,m_root,leaves); - bottomup(this,leaves); + b3FetchLeaves(this,m_root,leaves); + b3BottomUp(this,leaves); m_root=leaves[0]; } } @@ -452,10 +452,10 @@ void b3DynamicBvh::optimizeTopDown(int bu_treshold) { if(m_root) { - tNodeArray leaves; + b3NodeArray leaves; leaves.reserve(m_leaves); - fetchleaves(this,m_root,leaves); - m_root=topdown(this,leaves,bu_treshold); + b3FetchLeaves(this,m_root,leaves); + m_root=b3TopDown(this,leaves,bu_treshold); } } @@ -470,7 +470,7 @@ void b3DynamicBvh::optimizeIncremental(int passes) unsigned bit=0; while(node->isinternal()) { - node=sort(node,m_root)->childs[(m_opath>>bit)&1]; + node=b3Sort(node,m_root)->childs[(m_opath>>bit)&1]; bit=(bit+1)&(sizeof(unsigned)*8-1); } update(node); @@ -482,8 +482,8 @@ void b3DynamicBvh::optimizeIncremental(int passes) // b3DbvtNode* b3DynamicBvh::insert(const b3DbvtVolume& volume,void* data) { - b3DbvtNode* leaf=createnode(this,0,volume,data); - insertleaf(this,m_root,leaf); + b3DbvtNode* leaf=b3CreateNode(this,0,volume,data); + b3InsertLeaf(this,m_root,leaf); ++m_leaves; return(leaf); } @@ -491,7 +491,7 @@ b3DbvtNode* b3DynamicBvh::insert(const b3DbvtVolume& volume,void* data) // void b3DynamicBvh::update(b3DbvtNode* leaf,int lookahead) { - b3DbvtNode* root=removeleaf(this,leaf); + b3DbvtNode* root=b3RemoveLeaf(this,leaf); if(root) { if(lookahead>=0) @@ -502,13 +502,13 @@ void b3DynamicBvh::update(b3DbvtNode* leaf,int lookahead) } } else root=m_root; } - insertleaf(this,root,leaf); + b3InsertLeaf(this,root,leaf); } // void b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume) { - b3DbvtNode* root=removeleaf(this,leaf); + b3DbvtNode* root=b3RemoveLeaf(this,leaf); if(root) { if(m_lkhd>=0) @@ -520,7 +520,7 @@ void b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume) } else root=m_root; } leaf->volume=volume; - insertleaf(this,root,leaf); + b3InsertLeaf(this,root,leaf); } // @@ -554,8 +554,8 @@ bool b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume,b3Scalar margi // void b3DynamicBvh::remove(b3DbvtNode* leaf) { - removeleaf(this,leaf); - deletenode(this,leaf); + b3RemoveLeaf(this,leaf); + b3DeleteNode(this,leaf); --m_leaves; } @@ -596,7 +596,7 @@ void b3DynamicBvh::clone(b3DynamicBvh& dest,IClone* iclone) const do { const int i=stack.size()-1; const sStkCLN e=stack[i]; - b3DbvtNode* n=createnode(&dest,e.parent,e.node->volume,e.node->data); + b3DbvtNode* n=b3CreateNode(&dest,e.parent,e.node->volume,e.node->data); stack.pop_back(); if(e.parent!=0) e.parent->childs[i&1]=n; @@ -619,7 +619,7 @@ void b3DynamicBvh::clone(b3DynamicBvh& dest,IClone* iclone) const int b3DynamicBvh::maxdepth(const b3DbvtNode* node) { int depth=0; - if(node) getmaxdepth(node,1,depth); + if(node) b3GetMaxDepth(node,1,depth); return(depth); } @@ -647,7 +647,7 @@ void b3DynamicBvh::extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray #include @@ -692,7 +692,7 @@ struct b3DbvtBenchmark { struct NilPolicy : b3DynamicBvh::ICollide { - NilPolicy() : m_pcount(0),m_depth(-SIMD_INFINITY),m_checksort(true) {} + NilPolicy() : m_pcount(0),m_depth(-B3_INFINITY),m_checksort(true) {} void Process(const b3DbvtNode*,const b3DbvtNode*) { ++m_pcount; } void Process(const b3DbvtNode*) { ++m_pcount; } void Process(const b3DbvtNode*,b3Scalar depth) @@ -768,7 +768,7 @@ struct b3DbvtBenchmark { b3Transform t; t.setOrigin(RandVector3(cs)); - t.setRotation(b3Quaternion(RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2).normalized()); + t.setRotation(b3Quaternion(RandUnit()*B3_PI*2,RandUnit()*B3_PI*2,RandUnit()*B3_PI*2).normalized()); return(t); } static void RandTree(b3Scalar cs,b3Scalar eb,b3Scalar es,int leaves,b3DynamicBvh& dbvt) @@ -1168,7 +1168,7 @@ void b3DynamicBvh::benchmark() for(int i=0;i= 1400) -#define DBVT_USE_TEMPLATE 1 +#define B3_DBVT_USE_TEMPLATE 1 #else -#define DBVT_USE_TEMPLATE 0 +#define B3_DBVT_USE_TEMPLATE 0 #endif #else -#define DBVT_USE_TEMPLATE 0 +#define B3_DBVT_USE_TEMPLATE 0 #endif // Use only intrinsics instead of inline asm -#define DBVT_USE_INTRINSIC_SSE 1 +#define B3_DBVT_USE_INTRINSIC_SSE 1 // Using memmov for collideOCL -#define DBVT_USE_MEMMOVE 1 +#define B3_DBVT_USE_MEMMOVE 1 // Enable benchmarking code -#define DBVT_ENABLE_BENCHMARK 0 +#define B3_DBVT_ENABLE_BENCHMARK 0 // Inlining -#define DBVT_INLINE SIMD_FORCE_INLINE +#define B3_DBVT_INLINE B3_FORCE_INLINE // Specific methods implementation //SSE gives errors on a MSVC 7.1 #if defined (B3_USE_SSE) //&& defined (_WIN32) -#define DBVT_SELECT_IMPL DBVT_IMPL_SSE -#define DBVT_MERGE_IMPL DBVT_IMPL_SSE -#define DBVT_INT0_IMPL DBVT_IMPL_SSE +#define B3_DBVT_SELECT_IMPL B3_DBVT_IMPL_SSE +#define B3_DBVT_MERGE_IMPL B3_DBVT_IMPL_SSE +#define B3_DBVT_INT0_IMPL B3_DBVT_IMPL_SSE #else -#define DBVT_SELECT_IMPL DBVT_IMPL_GENERIC -#define DBVT_MERGE_IMPL DBVT_IMPL_GENERIC -#define DBVT_INT0_IMPL DBVT_IMPL_GENERIC +#define B3_DBVT_SELECT_IMPL B3_DBVT_IMPL_GENERIC +#define B3_DBVT_MERGE_IMPL B3_DBVT_IMPL_GENERIC +#define B3_DBVT_INT0_IMPL B3_DBVT_IMPL_GENERIC #endif -#if (DBVT_SELECT_IMPL==DBVT_IMPL_SSE)|| \ - (DBVT_MERGE_IMPL==DBVT_IMPL_SSE)|| \ - (DBVT_INT0_IMPL==DBVT_IMPL_SSE) +#if (B3_DBVT_SELECT_IMPL==B3_DBVT_IMPL_SSE)|| \ + (B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE)|| \ + (B3_DBVT_INT0_IMPL==B3_DBVT_IMPL_SSE) #include #endif @@ -77,49 +77,49 @@ subject to the following restrictions: // Auto config and checks // -#if DBVT_USE_TEMPLATE -#define DBVT_VIRTUAL -#define DBVT_VIRTUAL_DTOR(a) -#define DBVT_PREFIX template -#define DBVT_IPOLICY T& policy -#define DBVT_CHECKTYPE static const ICollide& typechecker=*(T*)1;(void)typechecker; +#if B3_DBVT_USE_TEMPLATE +#define B3_DBVT_VIRTUAL +#define B3_DBVT_VIRTUAL_DTOR(a) +#define B3_DBVT_PREFIX template +#define B3_DBVT_IPOLICY T& policy +#define B3_DBVT_CHECKTYPE static const ICollide& typechecker=*(T*)1;(void)typechecker; #else -#define DBVT_VIRTUAL_DTOR(a) virtual ~a() {} -#define DBVT_VIRTUAL virtual -#define DBVT_PREFIX -#define DBVT_IPOLICY ICollide& policy -#define DBVT_CHECKTYPE +#define B3_DBVT_VIRTUAL_DTOR(a) virtual ~a() {} +#define B3_DBVT_VIRTUAL virtual +#define B3_DBVT_PREFIX +#define B3_DBVT_IPOLICY ICollide& policy +#define B3_DBVT_CHECKTYPE #endif -#if DBVT_USE_MEMMOVE +#if B3_DBVT_USE_MEMMOVE #if !defined( __CELLOS_LV2__) && !defined(__MWERKS__) #include #endif #include #endif -#ifndef DBVT_USE_TEMPLATE -#error "DBVT_USE_TEMPLATE undefined" +#ifndef B3_DBVT_USE_TEMPLATE +#error "B3_DBVT_USE_TEMPLATE undefined" #endif -#ifndef DBVT_USE_MEMMOVE -#error "DBVT_USE_MEMMOVE undefined" +#ifndef B3_DBVT_USE_MEMMOVE +#error "B3_DBVT_USE_MEMMOVE undefined" #endif -#ifndef DBVT_ENABLE_BENCHMARK -#error "DBVT_ENABLE_BENCHMARK undefined" +#ifndef B3_DBVT_ENABLE_BENCHMARK +#error "B3_DBVT_ENABLE_BENCHMARK undefined" #endif -#ifndef DBVT_SELECT_IMPL -#error "DBVT_SELECT_IMPL undefined" +#ifndef B3_DBVT_SELECT_IMPL +#error "B3_DBVT_SELECT_IMPL undefined" #endif -#ifndef DBVT_MERGE_IMPL -#error "DBVT_MERGE_IMPL undefined" +#ifndef B3_DBVT_MERGE_IMPL +#error "B3_DBVT_MERGE_IMPL undefined" #endif -#ifndef DBVT_INT0_IMPL -#error "DBVT_INT0_IMPL undefined" +#ifndef B3_DBVT_INT0_IMPL +#error "B3_DBVT_INT0_IMPL undefined" #endif // @@ -129,43 +129,43 @@ subject to the following restrictions: /* b3DbvtAabbMm */ struct b3DbvtAabbMm { - DBVT_INLINE b3Vector3 Center() const { return((mi+mx)/2); } - DBVT_INLINE b3Vector3 Lengths() const { return(mx-mi); } - DBVT_INLINE b3Vector3 Extents() const { return((mx-mi)/2); } - DBVT_INLINE const b3Vector3& Mins() const { return(mi); } - DBVT_INLINE const b3Vector3& Maxs() const { return(mx); } + B3_DBVT_INLINE b3Vector3 Center() const { return((mi+mx)/2); } + B3_DBVT_INLINE b3Vector3 Lengths() const { return(mx-mi); } + B3_DBVT_INLINE b3Vector3 Extents() const { return((mx-mi)/2); } + B3_DBVT_INLINE const b3Vector3& Mins() const { return(mi); } + B3_DBVT_INLINE const b3Vector3& Maxs() const { return(mx); } static inline b3DbvtAabbMm FromCE(const b3Vector3& c,const b3Vector3& e); static inline b3DbvtAabbMm FromCR(const b3Vector3& c,b3Scalar r); static inline b3DbvtAabbMm FromMM(const b3Vector3& mi,const b3Vector3& mx); static inline b3DbvtAabbMm FromPoints(const b3Vector3* pts,int n); static inline b3DbvtAabbMm FromPoints(const b3Vector3** ppts,int n); - DBVT_INLINE void Expand(const b3Vector3& e); - DBVT_INLINE void SignedExpand(const b3Vector3& e); - DBVT_INLINE bool Contain(const b3DbvtAabbMm& a) const; - DBVT_INLINE int Classify(const b3Vector3& n,b3Scalar o,int s) const; - DBVT_INLINE b3Scalar ProjectMinimum(const b3Vector3& v,unsigned signs) const; - DBVT_INLINE friend bool Intersect( const b3DbvtAabbMm& a, + B3_DBVT_INLINE void Expand(const b3Vector3& e); + B3_DBVT_INLINE void SignedExpand(const b3Vector3& e); + B3_DBVT_INLINE bool Contain(const b3DbvtAabbMm& a) const; + B3_DBVT_INLINE int Classify(const b3Vector3& n,b3Scalar o,int s) const; + B3_DBVT_INLINE b3Scalar ProjectMinimum(const b3Vector3& v,unsigned signs) const; + B3_DBVT_INLINE friend bool b3Intersect( const b3DbvtAabbMm& a, const b3DbvtAabbMm& b); - DBVT_INLINE friend bool Intersect( const b3DbvtAabbMm& a, + B3_DBVT_INLINE friend bool b3Intersect( const b3DbvtAabbMm& a, const b3Vector3& b); - DBVT_INLINE friend b3Scalar Proximity( const b3DbvtAabbMm& a, + B3_DBVT_INLINE friend b3Scalar b3Proximity( const b3DbvtAabbMm& a, const b3DbvtAabbMm& b); - DBVT_INLINE friend int Select( const b3DbvtAabbMm& o, + B3_DBVT_INLINE friend int b3Select( const b3DbvtAabbMm& o, const b3DbvtAabbMm& a, const b3DbvtAabbMm& b); - DBVT_INLINE friend void Merge( const b3DbvtAabbMm& a, + B3_DBVT_INLINE friend void b3Merge( const b3DbvtAabbMm& a, const b3DbvtAabbMm& b, b3DbvtAabbMm& r); - DBVT_INLINE friend bool NotEqual( const b3DbvtAabbMm& a, + B3_DBVT_INLINE friend bool b3NotEqual( const b3DbvtAabbMm& a, const b3DbvtAabbMm& b); - DBVT_INLINE b3Vector3& tMins() { return(mi); } - DBVT_INLINE b3Vector3& tMaxs() { return(mx); } + B3_DBVT_INLINE b3Vector3& tMins() { return(mi); } + B3_DBVT_INLINE b3Vector3& tMaxs() { return(mx); } private: - DBVT_INLINE void AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const; + B3_DBVT_INLINE void AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const; private: b3Vector3 mi,mx; }; @@ -178,8 +178,8 @@ struct b3DbvtNode { b3DbvtVolume volume; b3DbvtNode* parent; - DBVT_INLINE bool isleaf() const { return(childs[1]==0); } - DBVT_INLINE bool isinternal() const { return(!isleaf()); } + B3_DBVT_INLINE bool isleaf() const { return(childs[1]==0); } + B3_DBVT_INLINE bool isinternal() const { return(!isleaf()); } union { b3DbvtNode* childs[2]; @@ -226,12 +226,12 @@ struct b3DynamicBvh /* ICollide */ struct ICollide { - DBVT_VIRTUAL_DTOR(ICollide) - DBVT_VIRTUAL void Process(const b3DbvtNode*,const b3DbvtNode*) {} - DBVT_VIRTUAL void Process(const b3DbvtNode*) {} - DBVT_VIRTUAL void Process(const b3DbvtNode* n,b3Scalar) { Process(n); } - DBVT_VIRTUAL bool Descent(const b3DbvtNode*) { return(true); } - DBVT_VIRTUAL bool AllLeaves(const b3DbvtNode*) { return(true); } + B3_DBVT_VIRTUAL_DTOR(ICollide) + B3_DBVT_VIRTUAL void Process(const b3DbvtNode*,const b3DbvtNode*) {} + B3_DBVT_VIRTUAL void Process(const b3DbvtNode*) {} + B3_DBVT_VIRTUAL void Process(const b3DbvtNode* n,b3Scalar) { Process(n); } + B3_DBVT_VIRTUAL bool Descent(const b3DbvtNode*) { return(true); } + B3_DBVT_VIRTUAL bool AllLeaves(const b3DbvtNode*) { return(true); } }; /* IWriter */ struct IWriter @@ -250,8 +250,8 @@ struct b3DynamicBvh // Constants enum { - SIMPLE_STACKSIZE = 64, - DOUBLE_STACKSIZE = SIMPLE_STACKSIZE*2 + B3_SIMPLE_STACKSIZE = 64, + B3_DOUBLE_STACKSIZE = B3_SIMPLE_STACKSIZE*2 }; // Fields @@ -286,55 +286,55 @@ struct b3DynamicBvh static int maxdepth(const b3DbvtNode* node); static int countLeaves(const b3DbvtNode* node); static void extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray& leaves); -#if DBVT_ENABLE_BENCHMARK +#if B3_DBVT_ENABLE_BENCHMARK static void benchmark(); #else static void benchmark(){} #endif - // DBVT_IPOLICY must support ICollide policy/interface - DBVT_PREFIX + // B3_DBVT_IPOLICY must support ICollide policy/interface + B3_DBVT_PREFIX static void enumNodes( const b3DbvtNode* root, - DBVT_IPOLICY); - DBVT_PREFIX + B3_DBVT_IPOLICY); + B3_DBVT_PREFIX static void enumLeaves( const b3DbvtNode* root, - DBVT_IPOLICY); - DBVT_PREFIX + B3_DBVT_IPOLICY); + B3_DBVT_PREFIX void collideTT( const b3DbvtNode* root0, const b3DbvtNode* root1, - DBVT_IPOLICY); + B3_DBVT_IPOLICY); - DBVT_PREFIX + B3_DBVT_PREFIX void collideTTpersistentStack( const b3DbvtNode* root0, const b3DbvtNode* root1, - DBVT_IPOLICY); + B3_DBVT_IPOLICY); #if 0 - DBVT_PREFIX + B3_DBVT_PREFIX void collideTT( const b3DbvtNode* root0, const b3DbvtNode* root1, const b3Transform& xform, - DBVT_IPOLICY); - DBVT_PREFIX + B3_DBVT_IPOLICY); + B3_DBVT_PREFIX void collideTT( const b3DbvtNode* root0, const b3Transform& xform0, const b3DbvtNode* root1, const b3Transform& xform1, - DBVT_IPOLICY); + B3_DBVT_IPOLICY); #endif - DBVT_PREFIX + B3_DBVT_PREFIX void collideTV( const b3DbvtNode* root, const b3DbvtVolume& volume, - DBVT_IPOLICY) const; + B3_DBVT_IPOLICY) const; ///rayTest is a re-entrant ray test, and can be called in parallel as long as the b3AlignedAlloc is thread-safe (uses locking etc) ///rayTest is slower than rayTestInternal, because it builds a local stack, using memory allocations, and it recomputes signs/rayDirectionInverses each time - DBVT_PREFIX + B3_DBVT_PREFIX static void rayTest( const b3DbvtNode* root, const b3Vector3& rayFrom, const b3Vector3& rayTo, - DBVT_IPOLICY); + B3_DBVT_IPOLICY); ///rayTestInternal is faster than rayTest, because it uses a persistent stack (to reduce dynamic memory allocations to a minimum) and it uses precomputed signs/rayInverseDirections ///rayTestInternal is used by b3DynamicBvhBroadphase to accelerate world ray casts - DBVT_PREFIX + B3_DBVT_PREFIX void rayTestInternal( const b3DbvtNode* root, const b3Vector3& rayFrom, const b3Vector3& rayTo, @@ -343,27 +343,27 @@ struct b3DynamicBvh b3Scalar lambda_max, const b3Vector3& aabbMin, const b3Vector3& aabbMax, - DBVT_IPOLICY) const; + B3_DBVT_IPOLICY) const; - DBVT_PREFIX + B3_DBVT_PREFIX static void collideKDOP(const b3DbvtNode* root, const b3Vector3* normals, const b3Scalar* offsets, int count, - DBVT_IPOLICY); - DBVT_PREFIX + B3_DBVT_IPOLICY); + B3_DBVT_PREFIX static void collideOCL( const b3DbvtNode* root, const b3Vector3* normals, const b3Scalar* offsets, const b3Vector3& sortaxis, int count, - DBVT_IPOLICY, + B3_DBVT_IPOLICY, bool fullsort=true); - DBVT_PREFIX + B3_DBVT_PREFIX static void collideTU( const b3DbvtNode* root, - DBVT_IPOLICY); + B3_DBVT_IPOLICY); // Helpers - static DBVT_INLINE int nearest(const int* i,const b3DynamicBvh::sStkNPS* a,b3Scalar v,int l,int h) + static B3_DBVT_INLINE int nearest(const int* i,const b3DynamicBvh::sStkNPS* a,b3Scalar v,int l,int h) { int m=0; while(l& ifree, + static B3_DBVT_INLINE int allocate( b3AlignedObjectArray& ifree, b3AlignedObjectArray& stock, const sStkNPS& value) { @@ -442,13 +442,13 @@ inline b3DbvtAabbMm b3DbvtAabbMm::FromPoints(const b3Vector3** ppts,int n) } // -DBVT_INLINE void b3DbvtAabbMm::Expand(const b3Vector3& e) +B3_DBVT_INLINE void b3DbvtAabbMm::Expand(const b3Vector3& e) { mi-=e;mx+=e; } // -DBVT_INLINE void b3DbvtAabbMm::SignedExpand(const b3Vector3& e) +B3_DBVT_INLINE void b3DbvtAabbMm::SignedExpand(const b3Vector3& e) { if(e.x>0) mx.setX(mx.x+e[0]); else mi.setX(mi.x+e[0]); if(e.y>0) mx.setY(mx.y+e[1]); else mi.setY(mi.y+e[1]); @@ -456,7 +456,7 @@ DBVT_INLINE void b3DbvtAabbMm::SignedExpand(const b3Vector3& e) } // -DBVT_INLINE bool b3DbvtAabbMm::Contain(const b3DbvtAabbMm& a) const +B3_DBVT_INLINE bool b3DbvtAabbMm::Contain(const b3DbvtAabbMm& a) const { return( (mi.x<=a.mi.x)&& (mi.y<=a.mi.y)&& @@ -467,7 +467,7 @@ DBVT_INLINE bool b3DbvtAabbMm::Contain(const b3DbvtAabbMm& a) const } // -DBVT_INLINE int b3DbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) const +B3_DBVT_INLINE int b3DbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) const { b3Vector3 pi,px; switch(s) @@ -495,7 +495,7 @@ DBVT_INLINE int b3DbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) con } // -DBVT_INLINE b3Scalar b3DbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned signs) const +B3_DBVT_INLINE b3Scalar b3DbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned signs) const { const b3Vector3* b[]={&mx,&mi}; const b3Vector3 p( b[(signs>>0)&1]->x, @@ -505,7 +505,7 @@ DBVT_INLINE b3Scalar b3DbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned si } // -DBVT_INLINE void b3DbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const +B3_DBVT_INLINE void b3DbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const { for(int i=0;i<3;++i) { @@ -517,10 +517,10 @@ DBVT_INLINE void b3DbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scala } // -DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a, +B3_DBVT_INLINE bool b3Intersect( const b3DbvtAabbMm& a, const b3DbvtAabbMm& b) { -#if DBVT_INT0_IMPL == DBVT_IMPL_SSE +#if B3_DBVT_INT0_IMPL == B3_DBVT_IMPL_SSE const __m128 rt(_mm_or_ps( _mm_cmplt_ps(_mm_load_ps(b.mx),_mm_load_ps(a.mi)), _mm_cmplt_ps(_mm_load_ps(a.mx),_mm_load_ps(b.mi)))); #if defined (_WIN32) @@ -542,7 +542,7 @@ DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a, // -DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a, +B3_DBVT_INLINE bool b3Intersect( const b3DbvtAabbMm& a, const b3Vector3& b) { return( (b.x>=a.mi.x)&& @@ -561,7 +561,7 @@ DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a, // -DBVT_INLINE b3Scalar Proximity( const b3DbvtAabbMm& a, +B3_DBVT_INLINE b3Scalar b3Proximity( const b3DbvtAabbMm& a, const b3DbvtAabbMm& b) { const b3Vector3 d=(a.mi+a.mx)-(b.mi+b.mx); @@ -571,19 +571,19 @@ DBVT_INLINE b3Scalar Proximity( const b3DbvtAabbMm& a, // -DBVT_INLINE int Select( const b3DbvtAabbMm& o, +B3_DBVT_INLINE int b3Select( const b3DbvtAabbMm& o, const b3DbvtAabbMm& a, const b3DbvtAabbMm& b) { -#if DBVT_SELECT_IMPL == DBVT_IMPL_SSE +#if B3_DBVT_SELECT_IMPL == B3_DBVT_IMPL_SSE #if defined (_WIN32) - static ATTRIBUTE_ALIGNED16(const unsigned __int32) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff}; + static B3_ATTRIBUTE_ALIGNED16(const unsigned __int32) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff}; #else - static ATTRIBUTE_ALIGNED16(const unsigned int) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x00000000 /*0x7fffffff*/}; + static B3_ATTRIBUTE_ALIGNED16(const unsigned int) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x00000000 /*0x7fffffff*/}; #endif ///@todo: the intrinsic version is 11% slower -#if DBVT_USE_INTRINSIC_SSE +#if B3_DBVT_USE_INTRINSIC_SSE union b3SSEUnion ///NOTE: if we use more intrinsics, move b3SSEUnion into the LinearMath directory { @@ -614,7 +614,7 @@ DBVT_INLINE int Select( const b3DbvtAabbMm& o, return tmp.ints[0]&1; #else - ATTRIBUTE_ALIGNED16(__int32 r[1]); + B3_ATTRIBUTE_ALIGNED16(__int32 r[1]); __asm { mov eax,o @@ -645,16 +645,16 @@ DBVT_INLINE int Select( const b3DbvtAabbMm& o, return(r[0]&1); #endif #else - return(Proximity(o,a)isinternal()) { @@ -703,11 +703,11 @@ inline void b3DynamicBvh::enumNodes( const b3DbvtNode* root, } // -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::enumLeaves( const b3DbvtNode* root, - DBVT_IPOLICY) + B3_DBVT_IPOLICY) { - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root->isinternal()) { enumLeaves(root->childs[0],policy); @@ -720,18 +720,18 @@ inline void b3DynamicBvh::enumLeaves( const b3DbvtNode* root, } // -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, const b3DbvtNode* root1, - DBVT_IPOLICY) + B3_DBVT_IPOLICY) { - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root0&&root1) { int depth=1; - int treshold=DOUBLE_STACKSIZE-4; + int treshold=B3_DOUBLE_STACKSIZE-4; b3AlignedObjectArray stkStack; - stkStack.resize(DOUBLE_STACKSIZE); + stkStack.resize(B3_DOUBLE_STACKSIZE); stkStack[0]=sStkNN(root0,root1); do { sStkNN p=stkStack[--depth]; @@ -749,7 +749,7 @@ inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[1]); } } - else if(Intersect(p.a->volume,p.b->volume)) + else if(b3Intersect(p.a->volume,p.b->volume)) { if(p.a->isinternal()) { @@ -785,18 +785,18 @@ inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0, const b3DbvtNode* root1, - DBVT_IPOLICY) + B3_DBVT_IPOLICY) { - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root0&&root1) { int depth=1; - int treshold=DOUBLE_STACKSIZE-4; + int treshold=B3_DOUBLE_STACKSIZE-4; - m_stkStack.resize(DOUBLE_STACKSIZE); + m_stkStack.resize(B3_DOUBLE_STACKSIZE); m_stkStack[0]=sStkNN(root0,root1); do { sStkNN p=m_stkStack[--depth]; @@ -814,7 +814,7 @@ inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0, m_stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[1]); } } - else if(Intersect(p.a->volume,p.b->volume)) + else if(b3Intersect(p.a->volume,p.b->volume)) { if(p.a->isinternal()) { @@ -850,23 +850,23 @@ inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0, #if 0 // -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, const b3DbvtNode* root1, const b3Transform& xform, - DBVT_IPOLICY) + B3_DBVT_IPOLICY) { - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root0&&root1) { int depth=1; - int treshold=DOUBLE_STACKSIZE-4; + int treshold=B3_DOUBLE_STACKSIZE-4; b3AlignedObjectArray stkStack; - stkStack.resize(DOUBLE_STACKSIZE); + stkStack.resize(B3_DOUBLE_STACKSIZE); stkStack[0]=sStkNN(root0,root1); do { sStkNN p=stkStack[--depth]; - if(Intersect(p.a->volume,p.b->volume,xform)) + if(b3Intersect(p.a->volume,p.b->volume,xform)) { if(depth>treshold) { @@ -905,12 +905,12 @@ inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, } } // -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, const b3Transform& xform0, const b3DbvtNode* root1, const b3Transform& xform1, - DBVT_IPOLICY) + B3_DBVT_IPOLICY) { const b3Transform xform=xform0.inverse()*xform1; collideTT(root0,root1,xform,policy); @@ -918,23 +918,23 @@ inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, #endif // -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::collideTV( const b3DbvtNode* root, const b3DbvtVolume& vol, - DBVT_IPOLICY) const + B3_DBVT_IPOLICY) const { - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root) { - ATTRIBUTE_ALIGNED16(b3DbvtVolume) volume(vol); + B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) volume(vol); b3AlignedObjectArray stack; stack.resize(0); - stack.reserve(SIMPLE_STACKSIZE); + stack.reserve(B3_SIMPLE_STACKSIZE); stack.push_back(root); do { const b3DbvtNode* n=stack[stack.size()-1]; stack.pop_back(); - if(Intersect(n->volume,volume)) + if(b3Intersect(n->volume,volume)) { if(n->isinternal()) { @@ -950,7 +950,7 @@ inline void b3DynamicBvh::collideTV( const b3DbvtNode* root, } } -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root, const b3Vector3& rayFrom, const b3Vector3& rayTo, @@ -959,18 +959,18 @@ inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root, b3Scalar lambda_max, const b3Vector3& aabbMin, const b3Vector3& aabbMax, - DBVT_IPOLICY) const + B3_DBVT_IPOLICY) const { (void) rayTo; - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root) { b3Vector3 resultNormal; int depth=1; - int treshold=DOUBLE_STACKSIZE-2; + int treshold=B3_DOUBLE_STACKSIZE-2; b3AlignedObjectArray& stack = m_rayTestStack; - stack.resize(DOUBLE_STACKSIZE); + stack.resize(B3_DOUBLE_STACKSIZE); stack[0]=root; b3Vector3 bounds[2]; do @@ -1003,13 +1003,13 @@ inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root, } // -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::rayTest( const b3DbvtNode* root, const b3Vector3& rayFrom, const b3Vector3& rayTo, - DBVT_IPOLICY) + B3_DBVT_IPOLICY) { - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root) { b3Vector3 rayDir = (rayTo-rayFrom); @@ -1029,9 +1029,9 @@ inline void b3DynamicBvh::rayTest( const b3DbvtNode* root, b3AlignedObjectArray stack; int depth=1; - int treshold=DOUBLE_STACKSIZE-2; + int treshold=B3_DOUBLE_STACKSIZE-2; - stack.resize(DOUBLE_STACKSIZE); + stack.resize(B3_DOUBLE_STACKSIZE); stack[0]=root; b3Vector3 bounds[2]; do { @@ -1072,14 +1072,14 @@ inline void b3DynamicBvh::rayTest( const b3DbvtNode* root, } // -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root, const b3Vector3* normals, const b3Scalar* offsets, int count, - DBVT_IPOLICY) + B3_DBVT_IPOLICY) { - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root) { const int inside=(1<=0)?2:0)+ ((normals[i].z>=0)?4:0); } - stack.reserve(SIMPLE_STACKSIZE); + stack.reserve(B3_SIMPLE_STACKSIZE); stack.push_back(sStkNP(root,0)); do { sStkNP se=stack[stack.size()-1]; @@ -1127,16 +1127,16 @@ inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root, } // -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root, const b3Vector3* normals, const b3Scalar* offsets, const b3Vector3& sortaxis, int count, - DBVT_IPOLICY, + B3_DBVT_IPOLICY, bool fsort) { - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root) { const unsigned srtsgns=(sortaxis[0]>=0?1:0)+ @@ -1154,9 +1154,9 @@ inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root, ((normals[i].y>=0)?2:0)+ ((normals[i].z>=0)?4:0); } - stock.reserve(SIMPLE_STACKSIZE); - stack.reserve(SIMPLE_STACKSIZE); - ifree.reserve(SIMPLE_STACKSIZE); + stock.reserve(B3_SIMPLE_STACKSIZE); + stack.reserve(B3_SIMPLE_STACKSIZE); + ifree.reserve(B3_SIMPLE_STACKSIZE); stack.push_back(allocate(ifree,stock,sStkNPS(root,0,root->volume.ProjectMinimum(sortaxis,srtsgns)))); do { const int id=stack[stack.size()-1]; @@ -1193,7 +1193,7 @@ inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root, /* Insert 0 */ j=nearest(&stack[0],&stock[0],nes[q].value,0,stack.size()); stack.push_back(0); -#if DBVT_USE_MEMMOVE +#if B3_DBVT_USE_MEMMOVE memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1)); #else for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1]; @@ -1202,7 +1202,7 @@ inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root, /* Insert 1 */ j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size()); stack.push_back(0); -#if DBVT_USE_MEMMOVE +#if B3_DBVT_USE_MEMMOVE memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1)); #else for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1]; @@ -1225,15 +1225,15 @@ inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root, } // -DBVT_PREFIX +B3_DBVT_PREFIX inline void b3DynamicBvh::collideTU( const b3DbvtNode* root, - DBVT_IPOLICY) + B3_DBVT_IPOLICY) { - DBVT_CHECKTYPE + B3_DBVT_CHECKTYPE if(root) { b3AlignedObjectArray stack; - stack.reserve(SIMPLE_STACKSIZE); + stack.reserve(B3_SIMPLE_STACKSIZE); stack.push_back(root); do { const b3DbvtNode* n=stack[stack.size()-1]; @@ -1253,18 +1253,18 @@ inline void b3DynamicBvh::collideTU( const b3DbvtNode* root, // PP Cleanup // -#undef DBVT_USE_MEMMOVE -#undef DBVT_USE_TEMPLATE -#undef DBVT_VIRTUAL_DTOR -#undef DBVT_VIRTUAL -#undef DBVT_PREFIX -#undef DBVT_IPOLICY -#undef DBVT_CHECKTYPE -#undef DBVT_IMPL_GENERIC -#undef DBVT_IMPL_SSE -#undef DBVT_USE_INTRINSIC_SSE -#undef DBVT_SELECT_IMPL -#undef DBVT_MERGE_IMPL -#undef DBVT_INT0_IMPL +#undef B3_DBVT_USE_MEMMOVE +#undef B3_DBVT_USE_TEMPLATE +#undef B3_DBVT_VIRTUAL_DTOR +#undef B3_DBVT_VIRTUAL +#undef B3_DBVT_PREFIX +#undef B3_DBVT_IPOLICY +#undef B3_DBVT_CHECKTYPE +#undef B3_DBVT_IMPL_GENERIC +#undef B3_DBVT_IMPL_SSE +#undef B3_DBVT_USE_INTRINSIC_SSE +#undef B3_DBVT_SELECT_IMPL +#undef B3_DBVT_MERGE_IMPL +#undef B3_DBVT_INT0_IMPL #endif diff --git a/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.cpp b/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.cpp index c4f8421ea..0b0833bef 100644 --- a/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.cpp +++ b/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.cpp @@ -1,11 +1,11 @@ /* Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org 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, +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. @@ -22,18 +22,18 @@ subject to the following restrictions: // Profiling // -#if DBVT_BP_PROFILE||DBVT_BP_ENABLE_BENCHMARK +#if B3_DBVT_BP_PROFILE||B3_DBVT_BP_ENABLE_BENCHMARK #include #endif -#if DBVT_BP_PROFILE -struct ProfileScope +#if B3_DBVT_BP_PROFILE +struct b3ProfileScope { - __forceinline ProfileScope(b3Clock& clock,unsigned long& value) : + __forceinline b3ProfileScope(b3Clock& clock,unsigned long& value) : m_clock(&clock),m_value(&value),m_base(clock.getTimeMicroseconds()) { } - __forceinline ~ProfileScope() + __forceinline ~b3ProfileScope() { (*m_value)+=m_clock->getTimeMicroseconds()-m_base; } @@ -41,9 +41,9 @@ struct ProfileScope unsigned long* m_value; unsigned long m_base; }; -#define SPC(_value_) ProfileScope spc_scope(m_clock,_value_) +#define b3SPC(_value_) b3ProfileScope spc_scope(m_clock,_value_) #else -#define SPC(_value_) +#define b3SPC(_value_) #endif // @@ -52,7 +52,7 @@ struct ProfileScope // template -static inline void listappend(T* item,T*& list) +static inline void b3ListAppend(T* item,T*& list) { item->links[0]=0; item->links[1]=list; @@ -62,7 +62,7 @@ static inline void listappend(T* item,T*& list) // template -static inline void listremove(T* item,T*& list) +static inline void b3ListRemove(T* item,T*& list) { if(item->links[0]) item->links[0]->links[1]=item->links[1]; else list=item->links[1]; if(item->links[1]) item->links[1]->links[0]=item->links[0]; @@ -70,7 +70,7 @@ static inline void listremove(T* item,T*& list) // template -static inline int listcount(T* root) +static inline int b3ListCount(T* root) { int n=0; while(root) { ++n;root=root->links[1]; } @@ -79,7 +79,7 @@ static inline int listcount(T* root) // template -static inline void clear(T& value) +static inline void b3Clear(T& value) { static const struct ZeroDummy : T {} zerodummy; value=zerodummy; @@ -101,7 +101,7 @@ struct b3DbvtTreeCollider : b3DynamicBvh::ICollide { b3DbvtProxy* pa=(b3DbvtProxy*)na->data; b3DbvtProxy* pb=(b3DbvtProxy*)nb->data; -#if DBVT_BP_SORTPAIRS +#if B3_DBVT_BP_SORTPAIRS if(pa->m_uniqueId>pb->m_uniqueId) b3Swap(pa,pb); #endif @@ -143,8 +143,8 @@ b3DynamicBvhBroadphase::b3DynamicBvhBroadphase(int proxyCapacity, b3OverlappingP { m_stageRoots[i]=0; } -#if DBVT_BP_PROFILE - clear(m_profiling); +#if B3_DBVT_BP_PROFILE + b3Clear(m_profiling); #endif m_proxies.resize(proxyCapacity); } @@ -178,7 +178,7 @@ b3BroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabb proxy->stage = m_stageCurrent; proxy->m_uniqueId = objectId; proxy->leaf = m_sets[0].insert(aabb,proxy); - listappend(proxy,m_stageRoots[m_stageCurrent]); + b3ListAppend(proxy,m_stageRoots[m_stageCurrent]); if(!m_deferedcollide) { b3DbvtTreeCollider collider(this); @@ -198,7 +198,7 @@ void b3DynamicBvhBroadphase::destroyProxy( b3BroadphaseProxy* absproxy, m_sets[1].remove(proxy->leaf); else m_sets[0].remove(proxy->leaf); - listremove(proxy,m_stageRoots[proxy->stage]); + b3ListRemove(proxy,m_stageRoots[proxy->stage]); m_paircache->removeOverlappingPairsContainingProxy(proxy->getUid(),dispatcher); m_needcleanup=true; @@ -270,7 +270,7 @@ void b3DynamicBvhBroadphase::aabbTest(const b3Vector3& aabbMin,const b3Vector3& { BroadphaseAabbTester callback(aabbCallback); - const ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds=b3DbvtVolume::FromMM(aabbMin,aabbMax); + const B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds=b3DbvtVolume::FromMM(aabbMin,aabbMax); //process all children, that overlap with the given AABB bounds m_sets[0].collideTV(m_sets[0].m_root,bounds,callback); m_sets[1].collideTV(m_sets[1].m_root,bounds,callback); @@ -286,9 +286,9 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy, b3Dispatcher* /*dispatcher*/) { b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy; - ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax); -#if DBVT_BP_PREVENTFALSEUPDATE - if(NotEqual(aabb,proxy->leaf->volume)) + B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax); +#if B3_DBVT_BP_PREVENTFALSEUPDATE + if(b3NotEqual(aabb,proxy->leaf->volume)) #endif { bool docollide=false; @@ -301,7 +301,7 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy, else {/* dynamic set */ ++m_updates_call; - if(Intersect(proxy->leaf->volume,aabb)) + if(b3Intersect(proxy->leaf->volume,aabb)) {/* Moving */ const b3Vector3 delta=aabbMin-proxy->m_aabbMin; @@ -310,8 +310,8 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy, if(delta[1]<0) velocity[1]=-velocity[1]; if(delta[2]<0) velocity[2]=-velocity[2]; if ( -#ifdef DBVT_BP_MARGIN - m_sets[0].update(proxy->leaf,aabb,velocity,DBVT_BP_MARGIN) +#ifdef B3_DBVT_BP_MARGIN + m_sets[0].update(proxy->leaf,aabb,velocity,B3_DBVT_BP_MARGIN) #else m_sets[0].update(proxy->leaf,aabb,velocity) #endif @@ -328,11 +328,11 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy, docollide=true; } } - listremove(proxy,m_stageRoots[proxy->stage]); + b3ListRemove(proxy,m_stageRoots[proxy->stage]); proxy->m_aabbMin = aabbMin; proxy->m_aabbMax = aabbMax; proxy->stage = m_stageCurrent; - listappend(proxy,m_stageRoots[m_stageCurrent]); + b3ListAppend(proxy,m_stageRoots[m_stageCurrent]); if(docollide) { m_needcleanup=true; @@ -354,7 +354,7 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* abspr b3Dispatcher* /*dispatcher*/) { b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy; - ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax); + B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax); bool docollide=false; if(proxy->stage==STAGECOUNT) {/* fixed -> dynamic set */ @@ -370,11 +370,11 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* abspr ++m_updates_done; docollide=true; } - listremove(proxy,m_stageRoots[proxy->stage]); + b3ListRemove(proxy,m_stageRoots[proxy->stage]); proxy->m_aabbMin = aabbMin; proxy->m_aabbMax = aabbMax; proxy->stage = m_stageCurrent; - listappend(proxy,m_stageRoots[m_stageCurrent]); + b3ListAppend(proxy,m_stageRoots[m_stageCurrent]); if(docollide) { m_needcleanup=true; @@ -391,22 +391,22 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* abspr void b3DynamicBvhBroadphase::calculateOverlappingPairs(b3Dispatcher* dispatcher) { collide(dispatcher); -#if DBVT_BP_PROFILE - if(0==(m_pid%DBVT_BP_PROFILING_RATE)) +#if B3_DBVT_BP_PROFILE + if(0==(m_pid%B3_DBVT_BP_PROFILING_RATE)) { printf("fixed(%u) dynamics(%u) pairs(%u)\r\n",m_sets[1].m_leaves,m_sets[0].m_leaves,m_paircache->getNumOverlappingPairs()); unsigned int total=m_profiling.m_total; if(total<=0) total=1; - printf("ddcollide: %u%% (%uus)\r\n",(50+m_profiling.m_ddcollide*100)/total,m_profiling.m_ddcollide/DBVT_BP_PROFILING_RATE); - printf("fdcollide: %u%% (%uus)\r\n",(50+m_profiling.m_fdcollide*100)/total,m_profiling.m_fdcollide/DBVT_BP_PROFILING_RATE); - printf("cleanup: %u%% (%uus)\r\n",(50+m_profiling.m_cleanup*100)/total,m_profiling.m_cleanup/DBVT_BP_PROFILING_RATE); - printf("total: %uus\r\n",total/DBVT_BP_PROFILING_RATE); + printf("ddcollide: %u%% (%uus)\r\n",(50+m_profiling.m_ddcollide*100)/total,m_profiling.m_ddcollide/B3_DBVT_BP_PROFILING_RATE); + printf("fdcollide: %u%% (%uus)\r\n",(50+m_profiling.m_fdcollide*100)/total,m_profiling.m_fdcollide/B3_DBVT_BP_PROFILING_RATE); + printf("cleanup: %u%% (%uus)\r\n",(50+m_profiling.m_cleanup*100)/total,m_profiling.m_cleanup/B3_DBVT_BP_PROFILING_RATE); + printf("total: %uus\r\n",total/B3_DBVT_BP_PROFILING_RATE); const unsigned long sum=m_profiling.m_ddcollide+ m_profiling.m_fdcollide+ m_profiling.m_cleanup; - printf("leaked: %u%% (%uus)\r\n",100-((50+sum*100)/total),(total-sum)/DBVT_BP_PROFILING_RATE); - printf("job counts: %u%%\r\n",(m_profiling.m_jobcount*100)/((m_sets[0].m_leaves+m_sets[1].m_leaves)*DBVT_BP_PROFILING_RATE)); - clear(m_profiling); + printf("leaked: %u%% (%uus)\r\n",100-((50+sum*100)/total),(total-sum)/B3_DBVT_BP_PROFILING_RATE); + printf("job counts: %u%%\r\n",(m_profiling.m_jobcount*100)/((m_sets[0].m_leaves+m_sets[1].m_leaves)*B3_DBVT_BP_PROFILING_RATE)); + b3Clear(m_profiling); m_clock.reset(); } #endif @@ -451,7 +451,7 @@ void b3DynamicBvhBroadphase::performDeferredRemoval(b3Dispatcher* dispatcher) //important to perform AABB check that is consistent with the broadphase b3DbvtProxy* pa=&m_proxies[pair.x]; b3DbvtProxy* pb=&m_proxies[pair.y]; - bool hasOverlap = Intersect(pa->leaf->volume,pb->leaf->volume); + bool hasOverlap = b3Intersect(pa->leaf->volume,pb->leaf->volume); if (hasOverlap) { @@ -504,7 +504,7 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher) - SPC(m_profiling.m_total); + b3SPC(m_profiling.m_total); /* optimize */ m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100); if(m_fixedleft) @@ -521,16 +521,16 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher) b3DbvtTreeCollider collider(this); do { b3DbvtProxy* next=current->links[1]; - listremove(current,m_stageRoots[current->stage]); - listappend(current,m_stageRoots[STAGECOUNT]); -#if DBVT_BP_ACCURATESLEEPING + b3ListRemove(current,m_stageRoots[current->stage]); + b3ListAppend(current,m_stageRoots[STAGECOUNT]); +#if B3_DBVT_BP_ACCURATESLEEPING m_paircache->removeOverlappingPairsContainingProxy(current,dispatcher); collider.proxy=current; b3DynamicBvh::collideTV(m_sets[0].m_root,current->aabb,collider); b3DynamicBvh::collideTV(m_sets[1].m_root,current->aabb,collider); #endif m_sets[0].remove(current->leaf); - ATTRIBUTE_ALIGNED16(b3DbvtVolume) curAabb=b3DbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax); + B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) curAabb=b3DbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax); current->leaf = m_sets[1].insert(curAabb,current); current->stage = STAGECOUNT; current = next; @@ -543,19 +543,19 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher) b3DbvtTreeCollider collider(this); if(m_deferedcollide) { - SPC(m_profiling.m_fdcollide); + b3SPC(m_profiling.m_fdcollide); m_sets[0].collideTTpersistentStack(m_sets[0].m_root,m_sets[1].m_root,collider); } if(m_deferedcollide) { - SPC(m_profiling.m_ddcollide); + b3SPC(m_profiling.m_ddcollide); m_sets[0].collideTTpersistentStack(m_sets[0].m_root,m_sets[0].m_root,collider); } } /* clean up */ if(m_needcleanup) { - SPC(m_profiling.m_cleanup); + b3SPC(m_profiling.m_cleanup); b3BroadphasePairArray& pairs=m_paircache->getOverlappingPairArray(); if(pairs.size()>0) { @@ -566,9 +566,9 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher) b3BroadphasePair& p=pairs[(m_cid+i)%pairs.size()]; b3DbvtProxy* pa=&m_proxies[p.x]; b3DbvtProxy* pb=&m_proxies[p.y]; - if(!Intersect(pa->leaf->volume,pb->leaf->volume)) + if(!b3Intersect(pa->leaf->volume,pb->leaf->volume)) { -#if DBVT_BP_SORTPAIRS +#if B3_DBVT_BP_SORTPAIRS if(pa->m_uniqueId>pb->m_uniqueId) b3Swap(pa,pb); #endif @@ -613,10 +613,10 @@ const b3OverlappingPairCache* b3DynamicBvhBroadphase::getOverlappingPairCache() void b3DynamicBvhBroadphase::getBroadphaseAabb(b3Vector3& aabbMin,b3Vector3& aabbMax) const { - ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds; + B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds; if(!m_sets[0].empty()) - if(!m_sets[1].empty()) Merge( m_sets[0].m_root->volume, + if(!m_sets[1].empty()) b3Merge( m_sets[0].m_root->volume, m_sets[1].m_root->volume,bounds); else bounds=m_sets[0].m_root->volume; @@ -663,7 +663,7 @@ void b3DynamicBvhBroadphase::printStats() {} // -#if DBVT_BP_ENABLE_BENCHMARK +#if B3_DBVT_BP_ENABLE_BENCHMARK struct b3BroadphaseBenchmark { @@ -788,7 +788,7 @@ void b3DynamicBvhBroadphase::benchmark(b3BroadphaseInterface* pbi) */ #endif -#if DBVT_BP_PROFILE -#undef SPC +#if B3_DBVT_BP_PROFILE +#undef b3SPC #endif diff --git a/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h b/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h index 63e23e610..7685290ed 100644 --- a/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h +++ b/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h @@ -1,11 +1,11 @@ /* Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org 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, +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. @@ -27,22 +27,22 @@ subject to the following restrictions: // Compile time config // -#define DBVT_BP_PROFILE 0 -//#define DBVT_BP_SORTPAIRS 1 -#define DBVT_BP_PREVENTFALSEUPDATE 0 -#define DBVT_BP_ACCURATESLEEPING 0 -#define DBVT_BP_ENABLE_BENCHMARK 0 -#define DBVT_BP_MARGIN (b3Scalar)0.05 +#define B3_DBVT_BP_PROFILE 0 +//#define B3_DBVT_BP_SORTPAIRS 1 +#define B3_DBVT_BP_PREVENTFALSEUPDATE 0 +#define B3_DBVT_BP_ACCURATESLEEPING 0 +#define B3_DBVT_BP_ENABLE_BENCHMARK 0 +#define B3_DBVT_BP_MARGIN (b3Scalar)0.05 -#if DBVT_BP_PROFILE -#define DBVT_BP_PROFILING_RATE 256 +#if B3_DBVT_BP_PROFILE +#define B3_DBVT_BP_PROFILING_RATE 256 #include "LinearMath/b3Quickprof.h" #endif -ATTRIBUTE_ALIGNED16(struct) b3BroadphaseProxy +B3_ATTRIBUTE_ALIGNED16(struct) b3BroadphaseProxy { B3_DECLARE_ALIGNED_ALLOCATOR(); @@ -69,7 +69,7 @@ B3_DECLARE_ALIGNED_ALLOCATOR(); b3Vector3 m_aabbMin; b3Vector3 m_aabbMax; - SIMD_FORCE_INLINE int getUid() const + B3_FORCE_INLINE int getUid() const { return m_uniqueId; } @@ -148,7 +148,7 @@ struct b3DynamicBvhBroadphase bool m_releasepaircache; // Release pair cache on delete bool m_deferedcollide; // Defere dynamic/static collision to collide call bool m_needcleanup; // Need to run cleanup? -#if DBVT_BP_PROFILE +#if B3_DBVT_BP_PROFILE b3Clock m_clock; struct { unsigned long m_total; diff --git a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPair.h b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPair.h index 5a8fd491b..596705c1a 100644 --- a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPair.h +++ b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPair.h @@ -1,3 +1,18 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +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 B3_OVERLAPPING_PAIR_H #define B3_OVERLAPPING_PAIR_H @@ -36,7 +51,7 @@ class b3BroadphasePairSortPredicate } }; -SIMD_FORCE_INLINE bool operator==(const b3BroadphasePair& a, const b3BroadphasePair& b) +B3_FORCE_INLINE bool operator==(const b3BroadphasePair& a, const b3BroadphasePair& b) { return (a.x == b.x ) && (a.y == b.y ); } diff --git a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.cpp b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.cpp index ebf20ff03..a57d6f5b7 100644 --- a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.cpp +++ b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.cpp @@ -1,11 +1,11 @@ /* Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org 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, +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. @@ -23,11 +23,10 @@ subject to the following restrictions: #include -int gOverlappingPairs = 0; - -int gRemovePairs =0; -int gAddedPairs =0; -int gFindPairs =0; +int b3g_overlappingPairs = 0; +int b3g_removePairs =0; +int b3g_addedPairs =0; +int b3g_findPairs =0; @@ -136,7 +135,7 @@ void b3HashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro b3BroadphasePair* b3HashedOverlappingPairCache::findPair(int proxy0, int proxy1) { - gFindPairs++; + b3g_findPairs++; if(proxy0 >proxy1) b3Swap(proxy0,proxy1); int proxyId1 = proxy0; @@ -274,7 +273,7 @@ b3BroadphasePair* b3HashedOverlappingPairCache::internalAddPair(int proxy0, int void* b3HashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1,b3Dispatcher* dispatcher) { - gRemovePairs++; + b3g_removePairs++; if(proxy0>proxy1) b3Swap(proxy0,proxy1); int proxyId1 = proxy0; @@ -387,7 +386,7 @@ void b3HashedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback* { removeOverlappingPair(pair->x,pair->y,dispatcher); - gOverlappingPairs--; + b3g_overlappingPairs--; } else { i++; @@ -440,7 +439,7 @@ void* b3SortedOverlappingPairCache::removeOverlappingPair(int proxy0,int proxy1, int findIndex = m_overlappingPairArray.findLinearSearch(findPair); if (findIndex < m_overlappingPairArray.size()) { - gOverlappingPairs--; + b3g_overlappingPairs--; b3BroadphasePair& pair = m_overlappingPairArray[findIndex]; cleanOverlappingPair(pair,dispatcher); @@ -475,8 +474,8 @@ b3BroadphasePair* b3SortedOverlappingPairCache::addOverlappingPair(int proxy0,in b3BroadphasePair* pair = new (mem) b3BroadphasePair(proxy0,proxy1); - gOverlappingPairs++; - gAddedPairs++; + b3g_overlappingPairs++; + b3g_addedPairs++; // if (m_ghostPairCallback) // m_ghostPairCallback->addOverlappingPair(proxy0, proxy1); @@ -532,7 +531,7 @@ void b3SortedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback* pair->y = -1; m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1); m_overlappingPairArray.pop_back(); - gOverlappingPairs--; + b3g_overlappingPairs--; } else { i++; @@ -565,7 +564,7 @@ void b3SortedOverlappingPairCache::cleanOverlappingPair(b3BroadphasePair& pair,b pair.m_algorithm->~b3CollisionAlgorithm(); dispatcher->freeCollisionAlgorithm(pair.m_algorithm); pair.m_algorithm=0; - gRemovePairs--; + b3g_removePairs--; } } */ diff --git a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h index 45ee48007..35099be37 100644 --- a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h +++ b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h @@ -1,11 +1,11 @@ /* Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org 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, +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. @@ -49,9 +49,9 @@ struct b3OverlapFilterCallback -extern int gRemovePairs; -extern int gAddedPairs; -extern int gFindPairs; +extern int b3g_removePairs; +extern int b3g_addedPairs; +extern int b3g_findPairs; const int B3_NULL_PAIR=0xffffffff; @@ -110,7 +110,7 @@ public: virtual void* removeOverlappingPair(int proxy0,int proxy1,b3Dispatcher* dispatcher); - SIMD_FORCE_INLINE bool needsBroadphaseCollision(int proxy0,int proxy1) const + B3_FORCE_INLINE bool needsBroadphaseCollision(int proxy0,int proxy1) const { if (m_overlapFilterCallback) return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1); @@ -125,7 +125,7 @@ public: // no new pair is created and the old one is returned. virtual b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1) { - gAddedPairs++; + b3g_addedPairs++; if (!needsBroadphaseCollision(proxy0,proxy1)) return 0; @@ -189,7 +189,7 @@ private: void growTables(); - SIMD_FORCE_INLINE bool equalsPair(const b3BroadphasePair& pair, int proxyId1, int proxyId2) + B3_FORCE_INLINE bool equalsPair(const b3BroadphasePair& pair, int proxyId1, int proxyId2) { return pair.x == proxyId1 && pair.y == proxyId2; } @@ -197,7 +197,7 @@ private: /* // Thomas Wang's hash, see: http://www.concentric.net/~Ttwang/tech/inthash.htm // This assumes proxyId1 and proxyId2 are 16-bit. - SIMD_FORCE_INLINE int getHash(int proxyId1, int proxyId2) + B3_FORCE_INLINE int getHash(int proxyId1, int proxyId2) { int key = (proxyId2 << 16) | proxyId1; key = ~key + (key << 15); @@ -212,7 +212,7 @@ private: - SIMD_FORCE_INLINE unsigned int getHash(unsigned int proxyId1, unsigned int proxyId2) + B3_FORCE_INLINE unsigned int getHash(unsigned int proxyId1, unsigned int proxyId2) { int key = static_cast(((unsigned int)proxyId1) | (((unsigned int)proxyId2) <<16)); // Thomas Wang's hash @@ -230,7 +230,7 @@ private: - SIMD_FORCE_INLINE b3BroadphasePair* internalFindPair(int proxy0, int proxy1, int hash) + B3_FORCE_INLINE b3BroadphasePair* internalFindPair(int proxy0, int proxy1, int hash) { int proxyId1 = proxy0; int proxyId2 = proxy1; diff --git a/src/Bullet3Collision/NarrowPhaseCollision/b3Contact4.h b/src/Bullet3Collision/NarrowPhaseCollision/b3Contact4.h index cdd1c5b7e..25fdba70f 100644 --- a/src/Bullet3Collision/NarrowPhaseCollision/b3Contact4.h +++ b/src/Bullet3Collision/NarrowPhaseCollision/b3Contact4.h @@ -1,10 +1,25 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +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 B3_CONTACT4_H #define B3_CONTACT4_H #include "Bullet3Common/b3Vector3.h" -ATTRIBUTE_ALIGNED16(struct) b3Contact4 +B3_ATTRIBUTE_ALIGNED16(struct) b3Contact4 { B3_DECLARE_ALIGNED_ALLOCATOR(); diff --git a/src/Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h b/src/Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h index ecf9e726f..9401eb28a 100644 --- a/src/Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h +++ b/src/Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h @@ -1,10 +1,25 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +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 B3_RIGID_BODY_CL #define B3_RIGID_BODY_CL #include "Bullet3Common/b3Scalar.h" #include "Bullet3Common/b3Matrix3x3.h" -ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL +B3_ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL { B3_DECLARE_ALIGNED_ALLOCATOR(); diff --git a/src/Bullet3Common/b3AlignedAllocator.cpp b/src/Bullet3Common/b3AlignedAllocator.cpp index 7aaf74242..8ead5e134 100644 --- a/src/Bullet3Common/b3AlignedAllocator.cpp +++ b/src/Bullet3Common/b3AlignedAllocator.cpp @@ -1,6 +1,6 @@ /* Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org 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. @@ -15,9 +15,9 @@ subject to the following restrictions: #include "b3AlignedAllocator.h" -int gNumAlignedAllocs = 0; -int gNumAlignedFree = 0; -int gTotalBytesAlignedAllocs = 0;//detect memory leaks +int b3g_numAlignedAllocs = 0; +int b3g_numAlignedFree = 0; +int b3g_totalBytesAlignedAllocs = 0;//detect memory leaks static void *b3AllocDefault(size_t size) { @@ -29,8 +29,8 @@ static void b3FreeDefault(void *ptr) free(ptr); } -static b3AllocFunc *sAllocFunc = b3AllocDefault; -static b3FreeFunc *sFreeFunc = b3FreeDefault; +static b3AllocFunc* b3s_allocFunc = b3AllocDefault; +static b3FreeFunc* b3s_freeFunc = b3FreeDefault; @@ -67,7 +67,7 @@ static inline void *b3AlignedAllocDefault(size_t size, int alignment) { void *ret; char *real; - real = (char *)sAllocFunc(size + sizeof(void *) + (alignment-1)); + real = (char *)b3s_allocFunc(size + sizeof(void *) + (alignment-1)); if (real) { ret = b3AlignPointer(real + sizeof(void *),alignment); *((void **)(ret)-1) = (void *)(real); @@ -83,25 +83,25 @@ static inline void b3AlignedFreeDefault(void *ptr) if (ptr) { real = *((void **)(ptr)-1); - sFreeFunc(real); + b3s_freeFunc(real); } } #endif -static b3AlignedAllocFunc *sAlignedAllocFunc = b3AlignedAllocDefault; -static b3AlignedFreeFunc *sAlignedFreeFunc = b3AlignedFreeDefault; +static b3AlignedAllocFunc* b3s_alignedAllocFunc = b3AlignedAllocDefault; +static b3AlignedFreeFunc* b3s_alignedFreeFunc = b3AlignedFreeDefault; void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *allocFunc, b3AlignedFreeFunc *freeFunc) { - sAlignedAllocFunc = allocFunc ? allocFunc : b3AlignedAllocDefault; - sAlignedFreeFunc = freeFunc ? freeFunc : b3AlignedFreeDefault; + b3s_alignedAllocFunc = allocFunc ? allocFunc : b3AlignedAllocDefault; + b3s_alignedFreeFunc = freeFunc ? freeFunc : b3AlignedFreeDefault; } void b3AlignedAllocSetCustom(b3AllocFunc *allocFunc, b3FreeFunc *freeFunc) { - sAllocFunc = allocFunc ? allocFunc : b3AllocDefault; - sFreeFunc = freeFunc ? freeFunc : b3FreeDefault; + b3s_allocFunc = allocFunc ? allocFunc : b3AllocDefault; + b3s_freeFunc = freeFunc ? freeFunc : b3FreeDefault; } #ifdef B3_DEBUG_MEMORY_ALLOCATIONS @@ -113,11 +113,11 @@ void* b3AlignedAllocInternal (size_t size, int alignment,int line,char* filen void *ret; char *real; - gTotalBytesAlignedAllocs += size; - gNumAlignedAllocs++; + b3g_totalBytesAlignedAllocs += size; + b3g_numAlignedAllocs++; - real = (char *)sAllocFunc(size + 2*sizeof(void *) + (alignment-1)); + real = (char *)b3s_allocFunc(size + 2*sizeof(void *) + (alignment-1)); if (real) { ret = (void*) b3AlignPointer(real + 2*sizeof(void *), alignment); *((void **)(ret)-1) = (void *)(real); @@ -127,7 +127,7 @@ void* b3AlignedAllocInternal (size_t size, int alignment,int line,char* filen ret = (void *)(real);//?? } - printf("allocation#%d at address %x, from %s,line %d, size %d\n",gNumAlignedAllocs,real, filename,line,size); + printf("allocation#%d at address %x, from %s,line %d, size %d\n",b3g_numAlignedAllocs,real, filename,line,size); int* ptr = (int*)ret; *ptr = 12; @@ -138,16 +138,16 @@ void b3AlignedFreeInternal (void* ptr,int line,char* filename) { void* real; - gNumAlignedFree++; + b3g_numAlignedFree++; if (ptr) { real = *((void **)(ptr)-1); int size = *((int*)(ptr)-2); - gTotalBytesAlignedAllocs -= size; + b3g_totalBytesAlignedAllocs -= size; - printf("free #%d at address %x, from %s,line %d, size %d\n",gNumAlignedFree,real, filename,line,size); + printf("free #%d at address %x, from %s,line %d, size %d\n",b3g_numAlignedFree,real, filename,line,size); - sFreeFunc(real); + b3s_freeFunc(real); } else { printf("NULL ptr\n"); @@ -158,9 +158,9 @@ void b3AlignedFreeInternal (void* ptr,int line,char* filename) void* b3AlignedAllocInternal (size_t size, int alignment) { - gNumAlignedAllocs++; + b3g_numAlignedAllocs++; void* ptr; - ptr = sAlignedAllocFunc(size, alignment); + ptr = b3s_alignedAllocFunc(size, alignment); // printf("b3AlignedAllocInternal %d, %x\n",size,ptr); return ptr; } @@ -172,9 +172,9 @@ void b3AlignedFreeInternal (void* ptr) return; } - gNumAlignedFree++; + b3g_numAlignedFree++; // printf("b3AlignedFreeInternal %x\n",ptr); - sAlignedFreeFunc(ptr); + b3s_alignedFreeFunc(ptr); } #endif //B3_DEBUG_MEMORY_ALLOCATIONS diff --git a/src/Bullet3Common/b3AlignedAllocator.h b/src/Bullet3Common/b3AlignedAllocator.h index e38eb7d57..be418bd55 100644 --- a/src/Bullet3Common/b3AlignedAllocator.h +++ b/src/Bullet3Common/b3AlignedAllocator.h @@ -1,6 +1,6 @@ /* Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org 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. @@ -42,7 +42,7 @@ void b3AlignedFreeInternal (void* ptr,int line,char* filename); #define b3AlignedFree(ptr) b3AlignedFreeInternal(ptr) #endif -typedef int size_type; +typedef int btSizeType; typedef void *(b3AlignedAllocFunc)(size_t size, int alignment); typedef void (b3AlignedFreeFunc)(void *memblock); @@ -81,7 +81,7 @@ public: pointer address ( reference ref ) const { return &ref; } const_pointer address ( const_reference ref ) const { return &ref; } - pointer allocate ( size_type n , const_pointer * hint = 0 ) { + pointer allocate ( btSizeType n , const_pointer * hint = 0 ) { (void)hint; return reinterpret_cast< pointer >(b3AlignedAlloc( sizeof(value_type) * n , Alignment )); } diff --git a/src/Bullet3Common/b3AlignedObjectArray.h b/src/Bullet3Common/b3AlignedObjectArray.h index 9abdcbf33..5ff9876e7 100644 --- a/src/Bullet3Common/b3AlignedObjectArray.h +++ b/src/Bullet3Common/b3AlignedObjectArray.h @@ -1,11 +1,11 @@ /* Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org 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, +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. @@ -17,7 +17,7 @@ subject to the following restrictions: #ifndef B3_OBJECT_ARRAY__ #define B3_OBJECT_ARRAY__ -#include "b3Scalar.h" // has definitions like SIMD_FORCE_INLINE +#include "b3Scalar.h" // has definitions like B3_FORCE_INLINE #include "b3AlignedAllocator.h" ///If the platform doesn't support placement new, you can disable B3_USE_PLACEMENT_NEW @@ -56,22 +56,22 @@ class b3AlignedObjectArray #ifdef B3_ALLOW_ARRAY_COPY_OPERATOR public: - SIMD_FORCE_INLINE b3AlignedObjectArray& operator=(const b3AlignedObjectArray &other) + B3_FORCE_INLINE b3AlignedObjectArray& operator=(const b3AlignedObjectArray &other) { copyFromArray(other); return *this; } #else//B3_ALLOW_ARRAY_COPY_OPERATOR private: - SIMD_FORCE_INLINE b3AlignedObjectArray& operator=(const b3AlignedObjectArray &other); + B3_FORCE_INLINE b3AlignedObjectArray& operator=(const b3AlignedObjectArray &other); #endif//B3_ALLOW_ARRAY_COPY_OPERATOR protected: - SIMD_FORCE_INLINE int allocSize(int size) + B3_FORCE_INLINE int allocSize(int size) { return (size ? size*2 : 1); } - SIMD_FORCE_INLINE void copy(int start,int end, T* dest) const + B3_FORCE_INLINE void copy(int start,int end, T* dest) const { int i; for (i=start;i=0); b3Assert(n=0); b3Assert(n=0); b3Assert(n=0); b3Assert(n0); m_size--; @@ -200,7 +200,7 @@ protected: ///resize changes the number of elements in the array. If the new size is larger, the new elements will be constructed using the optional second argument. ///when the new number of elements is smaller, the destructor will be called, but memory will not be freed, to reduce performance overhead of run-time memory (de)allocations. - SIMD_FORCE_INLINE void resizeNoInitialize(int newsize) + B3_FORCE_INLINE void resizeNoInitialize(int newsize) { int curSize = size(); @@ -217,7 +217,7 @@ protected: m_size = newsize; } - SIMD_FORCE_INLINE void resize(int newsize, const T& fillData=T()) + B3_FORCE_INLINE void resize(int newsize, const T& fillData=T()) { int curSize = size(); @@ -244,7 +244,7 @@ protected: m_size = newsize; } - SIMD_FORCE_INLINE T& expandNonInitializing( ) + B3_FORCE_INLINE T& expandNonInitializing( ) { int sz = size(); if( sz == capacity() ) @@ -257,7 +257,7 @@ protected: } - SIMD_FORCE_INLINE T& expand( const T& fillValue=T()) + B3_FORCE_INLINE T& expand( const T& fillValue=T()) { int sz = size(); if( sz == capacity() ) @@ -273,7 +273,7 @@ protected: } - SIMD_FORCE_INLINE void push_back(const T& _Val) + B3_FORCE_INLINE void push_back(const T& _Val) { int sz = size(); if( sz == capacity() ) @@ -292,12 +292,12 @@ protected: /// return the pre-allocated (reserved) elements, this is at least as large as the total number of elements,see size() and reserve() - SIMD_FORCE_INLINE int capacity() const + B3_FORCE_INLINE int capacity() const { return m_capacity; } - SIMD_FORCE_INLINE void reserve(int _Count) + B3_FORCE_INLINE void reserve(int _Count) { // determine new minimum length of allocated storage if (capacity() < _Count) { // not enough room, reallocate diff --git a/src/Bullet3Common/b3HashMap.h b/src/Bullet3Common/b3HashMap.h index 3802b15bb..3569503fb 100644 --- a/src/Bullet3Common/b3HashMap.h +++ b/src/Bullet3Common/b3HashMap.h @@ -1,11 +1,11 @@ /* Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org 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, +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. @@ -25,7 +25,7 @@ struct b3HashString const char* m_string; unsigned int m_hash; - SIMD_FORCE_INLINE unsigned int getHash()const + B3_FORCE_INLINE unsigned int getHash()const { return m_hash; } @@ -98,7 +98,7 @@ public: return getUid1() == other.getUid1(); } //to our success - SIMD_FORCE_INLINE unsigned int getHash()const + B3_FORCE_INLINE unsigned int getHash()const { int key = m_uid; // Thomas Wang's hash @@ -136,7 +136,7 @@ public: } //to our success - SIMD_FORCE_INLINE unsigned int getHash()const + B3_FORCE_INLINE unsigned int getHash()const { const bool VOID_IS_8 = ((sizeof(void*)==8)); @@ -172,7 +172,7 @@ public: } //to our success - SIMD_FORCE_INLINE unsigned int getHash()const + B3_FORCE_INLINE unsigned int getHash()const { int key = m_uid; // Thomas Wang's hash @@ -204,7 +204,7 @@ public: return getUid1() == other.getUid1(); } //to our success - SIMD_FORCE_INLINE unsigned int getHash()const + B3_FORCE_INLINE unsigned int getHash()const { int key = m_uid; // Thomas Wang's hash diff --git a/src/Bullet3Common/b3Int2.h b/src/Bullet3Common/b3Int2.h index be0dbd9bd..6b73e2eaa 100644 --- a/src/Bullet3Common/b3Int2.h +++ b/src/Bullet3Common/b3Int2.h @@ -1,3 +1,18 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +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 B3_INT2_H #define B3_INT2_H diff --git a/src/Bullet3Common/b3Matrix3x3.h b/src/Bullet3Common/b3Matrix3x3.h index f5b36859b..d15e1d279 100644 --- a/src/Bullet3Common/b3Matrix3x3.h +++ b/src/Bullet3Common/b3Matrix3x3.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. @@ -21,14 +21,14 @@ subject to the following restrictions: #include #ifdef B3_USE_SSE -//const __m128 ATTRIBUTE_ALIGNED16(v2220) = {2.0f, 2.0f, 2.0f, 0.0f}; -const __m128 ATTRIBUTE_ALIGNED16(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f}; +//const __m128 B3_ATTRIBUTE_ALIGNED16(v2220) = {2.0f, 2.0f, 2.0f, 0.0f}; +const __m128 B3_ATTRIBUTE_ALIGNED16(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f}; #endif #if defined(B3_USE_SSE) || defined(B3_USE_NEON) -const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v1000) = {1.0f, 0.0f, 0.0f, 0.0f}; -const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v0100) = {0.0f, 1.0f, 0.0f, 0.0f}; -const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f}; +const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(v1000) = {1.0f, 0.0f, 0.0f, 0.0f}; +const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(v0100) = {0.0f, 1.0f, 0.0f, 0.0f}; +const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f}; #endif #ifdef B3_USE_DOUBLE_PRECISION @@ -40,7 +40,7 @@ const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f}; /**@brief The b3Matrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with b3Quaternion, b3Transform and b3Vector3. * Make sure to only include a pure orthogonal matrix without scaling. */ -ATTRIBUTE_ALIGNED16(class) b3Matrix3x3 { +B3_ATTRIBUTE_ALIGNED16(class) b3Matrix3x3 { ///Data storage for the matrix, each vector is a row of the matrix b3Vector3 m_el[3]; @@ -71,14 +71,14 @@ public: } #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) - SIMD_FORCE_INLINE b3Matrix3x3 (const b3SimdFloat4 v0, const b3SimdFloat4 v1, const b3SimdFloat4 v2 ) + B3_FORCE_INLINE b3Matrix3x3 (const b3SimdFloat4 v0, const b3SimdFloat4 v1, const b3SimdFloat4 v2 ) { m_el[0].mVec128 = v0; m_el[1].mVec128 = v1; m_el[2].mVec128 = v2; } - SIMD_FORCE_INLINE b3Matrix3x3 (const b3Vector3& v0, const b3Vector3& v1, const b3Vector3& v2 ) + B3_FORCE_INLINE b3Matrix3x3 (const b3Vector3& v0, const b3Vector3& v1, const b3Vector3& v2 ) { m_el[0] = v0; m_el[1] = v1; @@ -86,7 +86,7 @@ public: } // Copy constructor - SIMD_FORCE_INLINE b3Matrix3x3(const b3Matrix3x3& rhs) + B3_FORCE_INLINE b3Matrix3x3(const b3Matrix3x3& rhs) { m_el[0].mVec128 = rhs.m_el[0].mVec128; m_el[1].mVec128 = rhs.m_el[1].mVec128; @@ -94,7 +94,7 @@ public: } // Assignment Operator - SIMD_FORCE_INLINE b3Matrix3x3& operator=(const b3Matrix3x3& m) + B3_FORCE_INLINE b3Matrix3x3& operator=(const b3Matrix3x3& m) { m_el[0].mVec128 = m.m_el[0].mVec128; m_el[1].mVec128 = m.m_el[1].mVec128; @@ -106,7 +106,7 @@ public: #else /** @brief Copy constructor */ - SIMD_FORCE_INLINE b3Matrix3x3 (const b3Matrix3x3& other) + B3_FORCE_INLINE b3Matrix3x3 (const b3Matrix3x3& other) { m_el[0] = other.m_el[0]; m_el[1] = other.m_el[1]; @@ -114,7 +114,7 @@ public: } /** @brief Assignment Operator */ - SIMD_FORCE_INLINE b3Matrix3x3& operator=(const b3Matrix3x3& other) + B3_FORCE_INLINE b3Matrix3x3& operator=(const b3Matrix3x3& other) { m_el[0] = other.m_el[0]; m_el[1] = other.m_el[1]; @@ -126,7 +126,7 @@ public: /** @brief Get a column of the matrix as a vector * @param i Column number 0 indexed */ - SIMD_FORCE_INLINE b3Vector3 getColumn(int i) const + B3_FORCE_INLINE b3Vector3 getColumn(int i) const { return b3Vector3(m_el[0][i],m_el[1][i],m_el[2][i]); } @@ -134,7 +134,7 @@ public: /** @brief Get a row of the matrix as a vector * @param i Row number 0 indexed */ - SIMD_FORCE_INLINE const b3Vector3& getRow(int i) const + B3_FORCE_INLINE const b3Vector3& getRow(int i) const { b3FullAssert(0 <= i && i < 3); return m_el[i]; @@ -142,7 +142,7 @@ public: /** @brief Get a mutable reference to a row of the matrix as a vector * @param i Row number 0 indexed */ - SIMD_FORCE_INLINE b3Vector3& operator[](int i) + B3_FORCE_INLINE b3Vector3& operator[](int i) { b3FullAssert(0 <= i && i < 3); return m_el[i]; @@ -150,7 +150,7 @@ public: /** @brief Get a const reference to a row of the matrix as a vector * @param i Row number 0 indexed */ - SIMD_FORCE_INLINE const b3Vector3& operator[](int i) const + B3_FORCE_INLINE const b3Vector3& operator[](int i) const { b3FullAssert(0 <= i && i < 3); return m_el[i]; @@ -493,17 +493,17 @@ public: roll = b3Scalar(b3Atan2(m_el[2].getY(), m_el[2].getZ())); // on pitch = +/-HalfPI - if (b3Fabs(pitch)==SIMD_HALF_PI) + if (b3Fabs(pitch)==B3_HALF_PI) { if (yaw>0) - yaw-=SIMD_PI; + yaw-=B3_PI; else - yaw+=SIMD_PI; + yaw+=B3_PI; if (roll>0) - roll-=SIMD_PI; + roll-=B3_PI; else - roll+=SIMD_PI; + roll+=B3_PI; } }; @@ -536,15 +536,15 @@ public: b3Scalar delta = b3Atan2(m_el[0].getX(),m_el[0].getZ()); if (m_el[2].getX() > 0) //gimbal locked up { - euler_out.pitch = SIMD_PI / b3Scalar(2.0); - euler_out2.pitch = SIMD_PI / b3Scalar(2.0); + euler_out.pitch = B3_PI / b3Scalar(2.0); + euler_out2.pitch = B3_PI / b3Scalar(2.0); euler_out.roll = euler_out.pitch + delta; euler_out2.roll = euler_out.pitch + delta; } else // gimbal locked down { - euler_out.pitch = -SIMD_PI / b3Scalar(2.0); - euler_out2.pitch = -SIMD_PI / b3Scalar(2.0); + euler_out.pitch = -B3_PI / b3Scalar(2.0); + euler_out2.pitch = -B3_PI / b3Scalar(2.0); euler_out.roll = -euler_out.pitch + delta; euler_out2.roll = -euler_out.pitch + delta; } @@ -552,7 +552,7 @@ public: else { euler_out.pitch = - b3Asin(m_el[2].getX()); - euler_out2.pitch = SIMD_PI - euler_out.pitch; + euler_out2.pitch = B3_PI - euler_out.pitch; euler_out.roll = b3Atan2(m_el[2].getY()/b3Cos(euler_out.pitch), m_el[2].getZ()/b3Cos(euler_out.pitch)); @@ -608,15 +608,15 @@ public: b3Matrix3x3 transposeTimes(const b3Matrix3x3& m) const; b3Matrix3x3 timesTranspose(const b3Matrix3x3& m) const; - SIMD_FORCE_INLINE b3Scalar tdotx(const b3Vector3& v) const + B3_FORCE_INLINE b3Scalar tdotx(const b3Vector3& v) const { return m_el[0].getX() * v.getX() + m_el[1].getX() * v.getY() + m_el[2].getX() * v.getZ(); } - SIMD_FORCE_INLINE b3Scalar tdoty(const b3Vector3& v) const + B3_FORCE_INLINE b3Scalar tdoty(const b3Vector3& v) const { return m_el[0].getY() * v.getX() + m_el[1].getY() * v.getY() + m_el[2].getY() * v.getZ(); } - SIMD_FORCE_INLINE b3Scalar tdotz(const b3Vector3& v) const + B3_FORCE_INLINE b3Scalar tdotz(const b3Vector3& v) const { return m_el[0].getZ() * v.getX() + m_el[1].getZ() * v.getY() + m_el[2].getZ() * v.getZ(); } @@ -660,7 +660,7 @@ public: b3Scalar t = threshold * (b3Fabs(m_el[0][0]) + b3Fabs(m_el[1][1]) + b3Fabs(m_el[2][2])); if (max <= t) { - if (max <= SIMD_EPSILON * t) + if (max <= B3_EPSILON * t) { return; } @@ -673,7 +673,7 @@ public: b3Scalar theta2 = theta * theta; b3Scalar cos; b3Scalar sin; - if (theta2 * theta2 < b3Scalar(10 / SIMD_EPSILON)) + if (theta2 * theta2 < b3Scalar(10 / B3_EPSILON)) { t = (theta >= 0) ? 1 / (theta + b3Sqrt(1 + theta2)) : 1 / (theta - b3Sqrt(1 + theta2)); @@ -737,7 +737,7 @@ public: }; -SIMD_FORCE_INLINE b3Matrix3x3& +B3_FORCE_INLINE b3Matrix3x3& b3Matrix3x3::operator*=(const b3Matrix3x3& m) { #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -827,7 +827,7 @@ b3Matrix3x3::operator*=(const b3Matrix3x3& m) return *this; } -SIMD_FORCE_INLINE b3Matrix3x3& +B3_FORCE_INLINE b3Matrix3x3& b3Matrix3x3::operator+=(const b3Matrix3x3& m) { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) @@ -849,7 +849,7 @@ b3Matrix3x3::operator+=(const b3Matrix3x3& m) return *this; } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 operator*(const b3Matrix3x3& m, const b3Scalar & k) { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) @@ -871,7 +871,7 @@ operator*(const b3Matrix3x3& m, const b3Scalar & k) #endif } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 operator+(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) @@ -895,7 +895,7 @@ operator+(const b3Matrix3x3& m1, const b3Matrix3x3& m2) #endif } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 operator-(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) @@ -920,7 +920,7 @@ operator-(const b3Matrix3x3& m1, const b3Matrix3x3& m2) } -SIMD_FORCE_INLINE b3Matrix3x3& +B3_FORCE_INLINE b3Matrix3x3& b3Matrix3x3::operator-=(const b3Matrix3x3& m) { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) @@ -943,14 +943,14 @@ b3Matrix3x3::operator-=(const b3Matrix3x3& m) } -SIMD_FORCE_INLINE b3Scalar +B3_FORCE_INLINE b3Scalar b3Matrix3x3::determinant() const { return b3Triple((*this)[0], (*this)[1], (*this)[2]); } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::absolute() const { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) @@ -971,7 +971,7 @@ b3Matrix3x3::absolute() const #endif } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::transpose() const { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) @@ -1008,7 +1008,7 @@ b3Matrix3x3::transpose() const #endif } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::adjoint() const { return b3Matrix3x3(cofac(1, 1, 2, 2), cofac(0, 2, 2, 1), cofac(0, 1, 1, 2), @@ -1016,7 +1016,7 @@ b3Matrix3x3::adjoint() const cofac(1, 0, 2, 1), cofac(0, 1, 2, 0), cofac(0, 0, 1, 1)); } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::inverse() const { b3Vector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1)); @@ -1028,7 +1028,7 @@ b3Matrix3x3::inverse() const co.getZ() * s, cofac(0, 1, 2, 0) * s, cofac(0, 0, 1, 1) * s); } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::transposeTimes(const b3Matrix3x3& m) const { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) @@ -1084,7 +1084,7 @@ b3Matrix3x3::transposeTimes(const b3Matrix3x3& m) const #endif } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) @@ -1137,7 +1137,7 @@ b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const #endif } -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator*(const b3Matrix3x3& m, const b3Vector3& v) { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) @@ -1148,7 +1148,7 @@ operator*(const b3Matrix3x3& m, const b3Vector3& v) } -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator*(const b3Vector3& v, const b3Matrix3x3& m) { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) @@ -1188,7 +1188,7 @@ operator*(const b3Vector3& v, const b3Matrix3x3& m) #endif } -SIMD_FORCE_INLINE b3Matrix3x3 +B3_FORCE_INLINE b3Matrix3x3 operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) @@ -1274,7 +1274,7 @@ operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2) } /* -SIMD_FORCE_INLINE b3Matrix3x3 b3MultTransposeLeft(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { +B3_FORCE_INLINE b3Matrix3x3 b3MultTransposeLeft(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { return b3Matrix3x3( 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], @@ -1290,7 +1290,7 @@ m1[0][2] * m2[0][2] + m1[1][2] * m2[1][2] + m1[2][2] * m2[2][2]); /**@brief Equality operator between two matrices * It will test all elements are equal. */ -SIMD_FORCE_INLINE bool operator==(const b3Matrix3x3& m1, const b3Matrix3x3& m2) +B3_FORCE_INLINE bool operator==(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) @@ -1327,32 +1327,32 @@ struct b3Matrix3x3DoubleData -SIMD_FORCE_INLINE void b3Matrix3x3::serialize(struct b3Matrix3x3Data& dataOut) const +B3_FORCE_INLINE void b3Matrix3x3::serialize(struct b3Matrix3x3Data& dataOut) const { for (int i=0;i<3;i++) m_el[i].serialize(dataOut.m_el[i]); } -SIMD_FORCE_INLINE void b3Matrix3x3::serializeFloat(struct b3Matrix3x3FloatData& dataOut) const +B3_FORCE_INLINE void b3Matrix3x3::serializeFloat(struct b3Matrix3x3FloatData& dataOut) const { for (int i=0;i<3;i++) m_el[i].serializeFloat(dataOut.m_el[i]); } -SIMD_FORCE_INLINE void b3Matrix3x3::deSerialize(const struct b3Matrix3x3Data& dataIn) +B3_FORCE_INLINE void b3Matrix3x3::deSerialize(const struct b3Matrix3x3Data& dataIn) { for (int i=0;i<3;i++) m_el[i].deSerialize(dataIn.m_el[i]); } -SIMD_FORCE_INLINE void b3Matrix3x3::deSerializeFloat(const struct b3Matrix3x3FloatData& dataIn) +B3_FORCE_INLINE void b3Matrix3x3::deSerializeFloat(const struct b3Matrix3x3FloatData& dataIn) { for (int i=0;i<3;i++) m_el[i].deSerializeFloat(dataIn.m_el[i]); } -SIMD_FORCE_INLINE void b3Matrix3x3::deSerializeDouble(const struct b3Matrix3x3DoubleData& dataIn) +B3_FORCE_INLINE void b3Matrix3x3::deSerializeDouble(const struct b3Matrix3x3DoubleData& dataIn) { for (int i=0;i<3;i++) m_el[i].deSerializeDouble(dataIn.m_el[i]); diff --git a/src/Bullet3Common/b3MinMax.h b/src/Bullet3Common/b3MinMax.h index 0bb4b5026..73af23a4f 100644 --- a/src/Bullet3Common/b3MinMax.h +++ b/src/Bullet3Common/b3MinMax.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. @@ -20,25 +20,25 @@ subject to the following restrictions: #include "b3Scalar.h" template -SIMD_FORCE_INLINE const T& b3Min(const T& a, const T& b) +B3_FORCE_INLINE const T& b3Min(const T& a, const T& b) { return a < b ? a : b ; } template -SIMD_FORCE_INLINE const T& b3Max(const T& a, const T& b) +B3_FORCE_INLINE const T& b3Max(const T& a, const T& b) { return a > b ? a : b; } template -SIMD_FORCE_INLINE const T& b3Clamped(const T& a, const T& lb, const T& ub) +B3_FORCE_INLINE const T& b3Clamped(const T& a, const T& lb, const T& ub) { return a < lb ? lb : (ub < a ? ub : a); } template -SIMD_FORCE_INLINE void b3SetMin(T& a, const T& b) +B3_FORCE_INLINE void b3SetMin(T& a, const T& b) { if (b < a) { @@ -47,7 +47,7 @@ SIMD_FORCE_INLINE void b3SetMin(T& a, const T& b) } template -SIMD_FORCE_INLINE void b3SetMax(T& a, const T& b) +B3_FORCE_INLINE void b3SetMax(T& a, const T& b) { if (a < b) { @@ -56,7 +56,7 @@ SIMD_FORCE_INLINE void b3SetMax(T& a, const T& b) } template -SIMD_FORCE_INLINE void b3Clamp(T& a, const T& lb, const T& ub) +B3_FORCE_INLINE void b3Clamp(T& a, const T& lb, const T& ub) { if (a < lb) { diff --git a/src/Bullet3Common/b3PoolAllocator.h b/src/Bullet3Common/b3PoolAllocator.h index 671660c2d..2fcdcf5b2 100644 --- a/src/Bullet3Common/b3PoolAllocator.h +++ b/src/Bullet3Common/b3PoolAllocator.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. diff --git a/src/Bullet3Common/b3QuadWord.h b/src/Bullet3Common/b3QuadWord.h index 4500688fa..7dda971cc 100644 --- a/src/Bullet3Common/b3QuadWord.h +++ b/src/Bullet3Common/b3QuadWord.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. @@ -31,7 +31,7 @@ subject to the following restrictions: * Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword. */ #ifndef USE_LIBSPE2 -ATTRIBUTE_ALIGNED16(class) b3QuadWord +B3_ATTRIBUTE_ALIGNED16(class) b3QuadWord #else class b3QuadWord #endif @@ -58,11 +58,11 @@ public: struct {b3Scalar x,y,z,w;}; }; public: - SIMD_FORCE_INLINE b3SimdFloat4 get128() const + B3_FORCE_INLINE b3SimdFloat4 get128() const { return mVec128; } - SIMD_FORCE_INLINE void set128(b3SimdFloat4 v128) + B3_FORCE_INLINE void set128(b3SimdFloat4 v128) { mVec128 = v128; } @@ -77,19 +77,19 @@ public: #if defined(B3_USE_SSE) || defined(B3_USE_NEON) // Set Vector - SIMD_FORCE_INLINE b3QuadWord(const b3SimdFloat4 vec) + B3_FORCE_INLINE b3QuadWord(const b3SimdFloat4 vec) { mVec128 = vec; } // Copy constructor - SIMD_FORCE_INLINE b3QuadWord(const b3QuadWord& rhs) + B3_FORCE_INLINE b3QuadWord(const b3QuadWord& rhs) { mVec128 = rhs.mVec128; } // Assignment Operator - SIMD_FORCE_INLINE b3QuadWord& + B3_FORCE_INLINE b3QuadWord& operator=(const b3QuadWord& v) { mVec128 = v.mVec128; @@ -100,29 +100,29 @@ public: #endif /**@brief Return the x value */ - SIMD_FORCE_INLINE const b3Scalar& getX() const { return m_floats[0]; } + B3_FORCE_INLINE const b3Scalar& getX() const { return m_floats[0]; } /**@brief Return the y value */ - SIMD_FORCE_INLINE const b3Scalar& getY() const { return m_floats[1]; } + B3_FORCE_INLINE const b3Scalar& getY() const { return m_floats[1]; } /**@brief Return the z value */ - SIMD_FORCE_INLINE const b3Scalar& getZ() const { return m_floats[2]; } + B3_FORCE_INLINE const b3Scalar& getZ() const { return m_floats[2]; } /**@brief Set the x value */ - SIMD_FORCE_INLINE void setX(b3Scalar _x) { m_floats[0] = _x;}; + B3_FORCE_INLINE void setX(b3Scalar _x) { m_floats[0] = _x;}; /**@brief Set the y value */ - SIMD_FORCE_INLINE void setY(b3Scalar _y) { m_floats[1] = _y;}; + B3_FORCE_INLINE void setY(b3Scalar _y) { m_floats[1] = _y;}; /**@brief Set the z value */ - SIMD_FORCE_INLINE void setZ(b3Scalar _z) { m_floats[2] = _z;}; + B3_FORCE_INLINE void setZ(b3Scalar _z) { m_floats[2] = _z;}; /**@brief Set the w value */ - SIMD_FORCE_INLINE void setW(b3Scalar _w) { m_floats[3] = _w;}; + B3_FORCE_INLINE void setW(b3Scalar _w) { m_floats[3] = _w;}; /**@brief Return the x value */ - //SIMD_FORCE_INLINE b3Scalar& operator[](int i) { return (&m_floats[0])[i]; } - //SIMD_FORCE_INLINE const b3Scalar& operator[](int i) const { return (&m_floats[0])[i]; } + //B3_FORCE_INLINE b3Scalar& operator[](int i) { return (&m_floats[0])[i]; } + //B3_FORCE_INLINE const b3Scalar& operator[](int i) const { return (&m_floats[0])[i]; } ///operator b3Scalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons. - SIMD_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; } - SIMD_FORCE_INLINE operator const b3Scalar *() const { return &m_floats[0]; } + B3_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; } + B3_FORCE_INLINE operator const b3Scalar *() const { return &m_floats[0]; } - SIMD_FORCE_INLINE bool operator==(const b3QuadWord& other) const + B3_FORCE_INLINE bool operator==(const b3QuadWord& other) const { #ifdef B3_USE_SSE return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128))); @@ -134,7 +134,7 @@ public: #endif } - SIMD_FORCE_INLINE bool operator!=(const b3QuadWord& other) const + B3_FORCE_INLINE bool operator!=(const b3QuadWord& other) const { return !(*this == other); } @@ -144,7 +144,7 @@ public: * @param y Value of y * @param z Value of z */ - SIMD_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z) + B3_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z) { m_floats[0]=_x; m_floats[1]=_y; @@ -165,7 +165,7 @@ public: * @param z Value of z * @param w Value of w */ - SIMD_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) + B3_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) { m_floats[0]=_x; m_floats[1]=_y; @@ -173,7 +173,7 @@ public: m_floats[3]=_w; } /**@brief No initialization constructor */ - SIMD_FORCE_INLINE b3QuadWord() + B3_FORCE_INLINE b3QuadWord() // :m_floats[0](b3Scalar(0.)),m_floats[1](b3Scalar(0.)),m_floats[2](b3Scalar(0.)),m_floats[3](b3Scalar(0.)) { } @@ -183,7 +183,7 @@ public: * @param y Value of y * @param z Value of z */ - SIMD_FORCE_INLINE b3QuadWord(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z) + B3_FORCE_INLINE b3QuadWord(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z) { m_floats[0] = _x, m_floats[1] = _y, m_floats[2] = _z, m_floats[3] = 0.0f; } @@ -194,7 +194,7 @@ public: * @param z Value of z * @param w Value of w */ - SIMD_FORCE_INLINE b3QuadWord(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) + B3_FORCE_INLINE b3QuadWord(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) { m_floats[0] = _x, m_floats[1] = _y, m_floats[2] = _z, m_floats[3] = _w; } @@ -202,7 +202,7 @@ public: /**@brief Set each element to the max of the current values and the values of another b3QuadWord * @param other The other b3QuadWord to compare with */ - SIMD_FORCE_INLINE void setMax(const b3QuadWord& other) + B3_FORCE_INLINE void setMax(const b3QuadWord& other) { #ifdef B3_USE_SSE mVec128 = _mm_max_ps(mVec128, other.mVec128); @@ -218,7 +218,7 @@ public: /**@brief Set each element to the min of the current values and the values of another b3QuadWord * @param other The other b3QuadWord to compare with */ - SIMD_FORCE_INLINE void setMin(const b3QuadWord& other) + B3_FORCE_INLINE void setMin(const b3QuadWord& other) { #ifdef B3_USE_SSE mVec128 = _mm_min_ps(mVec128, other.mVec128); diff --git a/src/Bullet3Common/b3Quaternion.h b/src/Bullet3Common/b3Quaternion.h index a844c0dbf..f5f38993f 100644 --- a/src/Bullet3Common/b3Quaternion.h +++ b/src/Bullet3Common/b3Quaternion.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. @@ -27,14 +27,14 @@ subject to the following restrictions: #ifdef B3_USE_SSE -const __m128 ATTRIBUTE_ALIGNED16(vOnes) = {1.0f, 1.0f, 1.0f, 1.0f}; +const __m128 B3_ATTRIBUTE_ALIGNED16(vOnes) = {1.0f, 1.0f, 1.0f, 1.0f}; #endif #if defined(B3_USE_SSE) || defined(B3_USE_NEON) -const b3SimdFloat4 ATTRIBUTE_ALIGNED16(vQInv) = {-0.0f, -0.0f, -0.0f, +0.0f}; -const b3SimdFloat4 ATTRIBUTE_ALIGNED16(vPPPM) = {+0.0f, +0.0f, +0.0f, -0.0f}; +const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(vQInv) = {-0.0f, -0.0f, -0.0f, +0.0f}; +const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(vPPPM) = {+0.0f, +0.0f, +0.0f, -0.0f}; #endif @@ -46,19 +46,19 @@ public: #if (defined(B3_USE_SSE_IN_API) && defined(B3_USE_SSE))|| defined(B3_USE_NEON) // Set Vector - SIMD_FORCE_INLINE b3Quaternion(const b3SimdFloat4 vec) + B3_FORCE_INLINE b3Quaternion(const b3SimdFloat4 vec) { mVec128 = vec; } // Copy constructor - SIMD_FORCE_INLINE b3Quaternion(const b3Quaternion& rhs) + B3_FORCE_INLINE b3Quaternion(const b3Quaternion& rhs) { mVec128 = rhs.mVec128; } // Assignment Operator - SIMD_FORCE_INLINE b3Quaternion& + B3_FORCE_INLINE b3Quaternion& operator=(const b3Quaternion& v) { mVec128 = v.mVec128; @@ -148,7 +148,7 @@ public: } /**@brief Add two quaternions * @param q The quaternion to add to this one */ - SIMD_FORCE_INLINE b3Quaternion& operator+=(const b3Quaternion& q) + B3_FORCE_INLINE b3Quaternion& operator+=(const b3Quaternion& q) { #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_add_ps(mVec128, q.mVec128); @@ -350,7 +350,7 @@ public: /**@brief Return a scaled version of this quaternion * @param s The scale factor */ - SIMD_FORCE_INLINE b3Quaternion + B3_FORCE_INLINE b3Quaternion operator*(const b3Scalar& s) const { #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -406,7 +406,7 @@ public: { b3Scalar s_squared = 1.f-m_floats[3]*m_floats[3]; - if (s_squared < b3Scalar(10.) * SIMD_EPSILON) //Check for divide by zero + if (s_squared < b3Scalar(10.) * B3_EPSILON) //Check for divide by zero return b3Vector3(1.0, 0.0, 0.0); // Arbitrary b3Scalar s = 1.f/b3Sqrt(s_squared); return b3Vector3(m_floats[0] * s, m_floats[1] * s, m_floats[2] * s); @@ -426,7 +426,7 @@ public: /**@brief Return the sum of this quaternion and the other * @param q2 The other quaternion */ - SIMD_FORCE_INLINE b3Quaternion + B3_FORCE_INLINE b3Quaternion operator+(const b3Quaternion& q2) const { #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -441,7 +441,7 @@ public: /**@brief Return the difference between this quaternion and the other * @param q2 The other quaternion */ - SIMD_FORCE_INLINE b3Quaternion + B3_FORCE_INLINE b3Quaternion operator-(const b3Quaternion& q2) const { #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -456,7 +456,7 @@ public: /**@brief Return the negative of this quaternion * This simply negates each element */ - SIMD_FORCE_INLINE b3Quaternion operator-() const + B3_FORCE_INLINE b3Quaternion operator-() const { #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return b3Quaternion(_mm_xor_ps(mVec128, b3vMzeroMask)); @@ -468,7 +468,7 @@ public: #endif } /**@todo document this and it's use */ - SIMD_FORCE_INLINE b3Quaternion farthest( const b3Quaternion& qd) const + B3_FORCE_INLINE b3Quaternion farthest( const b3Quaternion& qd) const { b3Quaternion diff,sum; diff = *this - qd; @@ -479,7 +479,7 @@ public: } /**@todo document this and it's use */ - SIMD_FORCE_INLINE b3Quaternion nearest( const b3Quaternion& qd) const + B3_FORCE_INLINE b3Quaternion nearest( const b3Quaternion& qd) const { b3Quaternion diff,sum; diff = *this - qd; @@ -528,7 +528,7 @@ public: return identityQuat; } - SIMD_FORCE_INLINE const b3Scalar& getW() const { return m_floats[3]; } + B3_FORCE_INLINE const b3Scalar& getW() const { return m_floats[3]; } }; @@ -538,7 +538,7 @@ public: /**@brief Return the product of two quaternions */ -SIMD_FORCE_INLINE b3Quaternion +B3_FORCE_INLINE b3Quaternion operator*(const b3Quaternion& q1, const b3Quaternion& q2) { #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -626,7 +626,7 @@ operator*(const b3Quaternion& q1, const b3Quaternion& q2) #endif } -SIMD_FORCE_INLINE b3Quaternion +B3_FORCE_INLINE b3Quaternion operator*(const b3Quaternion& q, const b3Vector3& w) { #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -709,7 +709,7 @@ operator*(const b3Quaternion& q, const b3Vector3& w) #endif } -SIMD_FORCE_INLINE b3Quaternion +B3_FORCE_INLINE b3Quaternion operator*(const b3Vector3& w, const b3Quaternion& q) { #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -793,30 +793,30 @@ operator*(const b3Vector3& w, const b3Quaternion& q) } /**@brief Calculate the dot product between two quaternions */ -SIMD_FORCE_INLINE b3Scalar -dot(const b3Quaternion& q1, const b3Quaternion& q2) +B3_FORCE_INLINE b3Scalar +b3Dot(const b3Quaternion& q1, const b3Quaternion& q2) { return q1.dot(q2); } /**@brief Return the length of a quaternion */ -SIMD_FORCE_INLINE b3Scalar -length(const b3Quaternion& q) +B3_FORCE_INLINE b3Scalar +b3Length(const b3Quaternion& q) { return q.length(); } /**@brief Return the angle between two quaternions*/ -SIMD_FORCE_INLINE b3Scalar +B3_FORCE_INLINE b3Scalar b3Angle(const b3Quaternion& q1, const b3Quaternion& q2) { return q1.angle(q2); } /**@brief Return the inverse of a quaternion*/ -SIMD_FORCE_INLINE b3Quaternion -inverse(const b3Quaternion& q) +B3_FORCE_INLINE b3Quaternion +b3Inverse(const b3Quaternion& q) { return q.inverse(); } @@ -826,14 +826,14 @@ inverse(const b3Quaternion& q) * @param q2 The second quaternion * @param t The ration between q1 and q2. t = 0 return q1, t=1 returns q2 * Slerp assumes constant velocity between positions. */ -SIMD_FORCE_INLINE b3Quaternion -slerp(const b3Quaternion& q1, const b3Quaternion& q2, const b3Scalar& t) +B3_FORCE_INLINE b3Quaternion +b3Slerp(const b3Quaternion& q1, const b3Quaternion& q2, const b3Scalar& t) { return q1.slerp(q2, t); } -SIMD_FORCE_INLINE b3Vector3 -quatRotate(const b3Quaternion& rotation, const b3Vector3& v) +B3_FORCE_INLINE b3Vector3 +b3QuatRotate(const b3Quaternion& rotation, const b3Vector3& v) { b3Quaternion q = rotation * v; q *= rotation.inverse(); @@ -846,13 +846,13 @@ quatRotate(const b3Quaternion& rotation, const b3Vector3& v) #endif } -SIMD_FORCE_INLINE b3Quaternion -shortestArcQuat(const b3Vector3& v0, const b3Vector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized +B3_FORCE_INLINE b3Quaternion +b3ShortestArcQuat(const b3Vector3& v0, const b3Vector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized { b3Vector3 c = v0.cross(v1); b3Scalar d = v0.dot(v1); - if (d < -1.0 + SIMD_EPSILON) + if (d < -1.0 + B3_EPSILON) { b3Vector3 n,unused; b3PlaneSpace1(v0,n,unused); @@ -865,12 +865,12 @@ shortestArcQuat(const b3Vector3& v0, const b3Vector3& v1) // Game Programming Ge return b3Quaternion(c.getX()*rs,c.getY()*rs,c.getZ()*rs,s * 0.5f); } -SIMD_FORCE_INLINE b3Quaternion -shortestArcQuatNormalize2(b3Vector3& v0,b3Vector3& v1) +B3_FORCE_INLINE b3Quaternion +b3ShortestArcQuatNormalize2(b3Vector3& v0,b3Vector3& v1) { v0.normalize(); v1.normalize(); - return shortestArcQuat(v0,v1); + return b3ShortestArcQuat(v0,v1); } #endif //B3_SIMD__QUATERNION_H_ diff --git a/src/Bullet3Common/b3Quickprof.cpp b/src/Bullet3Common/b3Quickprof.cpp index 54d0fcc04..12bda2fd3 100644 --- a/src/Bullet3Common/b3Quickprof.cpp +++ b/src/Bullet3Common/b3Quickprof.cpp @@ -1,3 +1,17 @@ +/* +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +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. +*/ + /* *************************************************************************************************** @@ -14,11 +28,12 @@ // Ogre (www.ogre3d.org). #include "b3Quickprof.h" +#include "b3MinMax.h" #ifndef B3_NO_PROFILE -static b3Clock gProfileClock; +static b3Clock b3s_profileClock; #ifdef __CELLOS_LV2__ @@ -52,7 +67,7 @@ static b3Clock gProfileClock; #include #endif //_WIN32 -#define mymin(a,b) (a > b ? a : b) + struct b3ClockData { @@ -141,7 +156,7 @@ unsigned long int b3Clock::getTimeMilliseconds() if (msecOff < -100 || msecOff > 100) { // Adjust the starting time forwards. - LONGLONG msecAdjustment = mymin(msecOff * + LONGLONG msecAdjustment = b3Min(msecOff * m_data->mClockFrequency.QuadPart / 1000, elapsedTime - m_data->mPrevElapsedTime); m_data->mStartTime.QuadPart += msecAdjustment; @@ -199,7 +214,7 @@ unsigned long int b3Clock::getTimeMicroseconds() if (msecOff < -100 || msecOff > 100) { // Adjust the starting time forwards. - LONGLONG msecAdjustment = mymin(msecOff * + LONGLONG msecAdjustment = b3Min(msecOff * m_data->mClockFrequency.QuadPart / 1000, elapsedTime - m_data->mPrevElapsedTime); m_data->mStartTime.QuadPart += msecAdjustment; @@ -239,12 +254,12 @@ unsigned long int b3Clock::getTimeMicroseconds() -inline void Profile_Get_Ticks(unsigned long int * ticks) +inline void b3Profile_Get_Ticks(unsigned long int * ticks) { - *ticks = gProfileClock.getTimeMicroseconds(); + *ticks = b3s_profileClock.getTimeMicroseconds(); } -inline float Profile_Get_Tick_Rate(void) +inline float b3Profile_Get_Tick_Rate(void) { // return 1000000.f; return 1000.f; @@ -255,7 +270,7 @@ inline float Profile_Get_Tick_Rate(void) /*************************************************************************************************** ** -** CProfileNode +** b3ProfileNode ** ***************************************************************************************************/ @@ -268,7 +283,7 @@ inline float Profile_Get_Tick_Rate(void) * The name is assumed to be a static pointer, only the pointer is stored and compared for * * efficiency reasons. * *=============================================================================================*/ -CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) : +b3ProfileNode::b3ProfileNode( const char * name, b3ProfileNode * parent ) : Name( name ), TotalCalls( 0 ), TotalTime( 0 ), @@ -283,7 +298,7 @@ CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) : } -void CProfileNode::CleanupMemory() +void b3ProfileNode::CleanupMemory() { delete ( Child); Child = NULL; @@ -291,7 +306,7 @@ void CProfileNode::CleanupMemory() Sibling = NULL; } -CProfileNode::~CProfileNode( void ) +b3ProfileNode::~b3ProfileNode( void ) { delete ( Child); delete ( Sibling); @@ -306,10 +321,10 @@ CProfileNode::~CProfileNode( void ) * All profile names are assumed to be static strings so this function uses pointer compares * * to find the named node. * *=============================================================================================*/ -CProfileNode * CProfileNode::Get_Sub_Node( const char * name ) +b3ProfileNode * b3ProfileNode::Get_Sub_Node( const char * name ) { // Try to find this sub node - CProfileNode * child = Child; + b3ProfileNode * child = Child; while ( child ) { if ( child->Name == name ) { return child; @@ -319,14 +334,14 @@ CProfileNode * CProfileNode::Get_Sub_Node( const char * name ) // We didn't find it, so add it - CProfileNode * node = new CProfileNode( name, this ); + b3ProfileNode * node = new b3ProfileNode( name, this ); node->Sibling = Child; Child = node; return node; } -void CProfileNode::Reset( void ) +void b3ProfileNode::Reset( void ) { TotalCalls = 0; TotalTime = 0.0f; @@ -341,22 +356,22 @@ void CProfileNode::Reset( void ) } -void CProfileNode::Call( void ) +void b3ProfileNode::Call( void ) { TotalCalls++; if (RecursionCounter++ == 0) { - Profile_Get_Ticks(&StartTime); + b3Profile_Get_Ticks(&StartTime); } } -bool CProfileNode::Return( void ) +bool b3ProfileNode::Return( void ) { if ( --RecursionCounter == 0 && TotalCalls != 0 ) { unsigned long int time; - Profile_Get_Ticks(&time); + b3Profile_Get_Ticks(&time); time-=StartTime; - TotalTime += (float)time / Profile_Get_Tick_Rate(); + TotalTime += (float)time / b3Profile_Get_Tick_Rate(); } return ( RecursionCounter == 0 ); } @@ -364,35 +379,35 @@ bool CProfileNode::Return( void ) /*************************************************************************************************** ** -** CProfileIterator +** b3ProfileIterator ** ***************************************************************************************************/ -CProfileIterator::CProfileIterator( CProfileNode * start ) +b3ProfileIterator::b3ProfileIterator( b3ProfileNode * start ) { CurrentParent = start; CurrentChild = CurrentParent->Get_Child(); } -void CProfileIterator::First(void) +void b3ProfileIterator::First(void) { CurrentChild = CurrentParent->Get_Child(); } -void CProfileIterator::Next(void) +void b3ProfileIterator::Next(void) { CurrentChild = CurrentChild->Get_Sibling(); } -bool CProfileIterator::Is_Done(void) +bool b3ProfileIterator::Is_Done(void) { return CurrentChild == NULL; } -void CProfileIterator::Enter_Child( int index ) +void b3ProfileIterator::Enter_Child( int index ) { CurrentChild = CurrentParent->Get_Child(); while ( (CurrentChild != NULL) && (index != 0) ) { @@ -407,7 +422,7 @@ void CProfileIterator::Enter_Child( int index ) } -void CProfileIterator::Enter_Parent( void ) +void b3ProfileIterator::Enter_Parent( void ) { if ( CurrentParent->Get_Parent() != NULL ) { CurrentParent = CurrentParent->Get_Parent(); @@ -418,18 +433,18 @@ void CProfileIterator::Enter_Parent( void ) /*************************************************************************************************** ** -** CProfileManager +** b3ProfileManager ** ***************************************************************************************************/ -CProfileNode CProfileManager::Root( "Root", NULL ); -CProfileNode * CProfileManager::CurrentNode = &CProfileManager::Root; -int CProfileManager::FrameCounter = 0; -unsigned long int CProfileManager::ResetTime = 0; +b3ProfileNode b3ProfileManager::Root( "Root", NULL ); +b3ProfileNode * b3ProfileManager::CurrentNode = &b3ProfileManager::Root; +int b3ProfileManager::FrameCounter = 0; +unsigned long int b3ProfileManager::ResetTime = 0; /*********************************************************************************************** - * CProfileManager::Start_Profile -- Begin a named profile * + * b3ProfileManager::Start_Profile -- Begin a named profile * * * * Steps one level deeper into the tree, if a child already exists with the specified name * * then it accumulates the profiling; otherwise a new child node is added to the profile tree. * @@ -441,7 +456,7 @@ unsigned long int CProfileManager::ResetTime = 0; * The string used is assumed to be a static string; pointer compares are used throughout * * the profiling code for efficiency. * *=============================================================================================*/ -void CProfileManager::Start_Profile( const char * name ) +void b3ProfileManager::Start_Profile( const char * name ) { if (name != CurrentNode->Get_Name()) { CurrentNode = CurrentNode->Get_Sub_Node( name ); @@ -452,9 +467,9 @@ void CProfileManager::Start_Profile( const char * name ) /*********************************************************************************************** - * CProfileManager::Stop_Profile -- Stop timing and record the results. * + * b3ProfileManager::Stop_Profile -- Stop timing and record the results. * *=============================================================================================*/ -void CProfileManager::Stop_Profile( void ) +void b3ProfileManager::Stop_Profile( void ) { // Return will indicate whether we should back up to our parent (we may // be profiling a recursive function) @@ -465,51 +480,51 @@ void CProfileManager::Stop_Profile( void ) /*********************************************************************************************** - * CProfileManager::Reset -- Reset the contents of the profiling system * + * b3ProfileManager::Reset -- Reset the contents of the profiling system * * * * This resets everything except for the tree structure. All of the timing data is reset. * *=============================================================================================*/ -void CProfileManager::Reset( void ) +void b3ProfileManager::Reset( void ) { - gProfileClock.reset(); + b3s_profileClock.reset(); Root.Reset(); Root.Call(); FrameCounter = 0; - Profile_Get_Ticks(&ResetTime); + b3Profile_Get_Ticks(&ResetTime); } /*********************************************************************************************** - * CProfileManager::Increment_Frame_Counter -- Increment the frame counter * + * b3ProfileManager::Increment_Frame_Counter -- Increment the frame counter * *=============================================================================================*/ -void CProfileManager::Increment_Frame_Counter( void ) +void b3ProfileManager::Increment_Frame_Counter( void ) { FrameCounter++; } /*********************************************************************************************** - * CProfileManager::Get_Time_Since_Reset -- returns the elapsed time since last reset * + * b3ProfileManager::Get_Time_Since_Reset -- returns the elapsed time since last reset * *=============================================================================================*/ -float CProfileManager::Get_Time_Since_Reset( void ) +float b3ProfileManager::Get_Time_Since_Reset( void ) { unsigned long int time; - Profile_Get_Ticks(&time); + b3Profile_Get_Ticks(&time); time -= ResetTime; - return (float)time / Profile_Get_Tick_Rate(); + return (float)time / b3Profile_Get_Tick_Rate(); } #include -void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spacing) +void b3ProfileManager::dumpRecursive(b3ProfileIterator* profileIterator, int spacing) { profileIterator->First(); if (profileIterator->Is_Done()) return; - float accumulated_time=0,parent_time = profileIterator->Is_Root() ? CProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time(); + float accumulated_time=0,parent_time = profileIterator->Is_Root() ? b3ProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time(); int i; - int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset(); + int frames_since_reset = b3ProfileManager::Get_Frame_Count_Since_Reset(); for (i=0;iGet_Current_Total_Time(); accumulated_time += current_total_time; - float fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; + float fraction = parent_time > B3_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; { int i; for (i=0;i SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time); + printf("%s (%.3f %%) :: %.3f ms\n", "Unaccounted:",parent_time > B3_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time); for (i=0;i #include -#define GEN_RAND_MAX UINT_MAX +#define B3_RAND_MAX UINT_MAX -SIMD_FORCE_INLINE void GEN_srand(unsigned int seed) { init_genrand(seed); } -SIMD_FORCE_INLINE unsigned int GEN_rand() { return genrand_int32(); } +B3_FORCE_INLINE void b3Srand(unsigned int seed) { init_genrand(seed); } +B3_FORCE_INLINE unsigned int b3rand() { return genrand_int32(); } #else #include -#define GEN_RAND_MAX RAND_MAX +#define B3_RAND_MAX RAND_MAX -SIMD_FORCE_INLINE void GEN_srand(unsigned int seed) { srand(seed); } -SIMD_FORCE_INLINE unsigned int GEN_rand() { return rand(); } +B3_FORCE_INLINE void b3Srand(unsigned int seed) { srand(seed); } +B3_FORCE_INLINE unsigned int b3rand() { return rand(); } #endif diff --git a/src/Bullet3Common/b3Scalar.h b/src/Bullet3Common/b3Scalar.h index 6b6418af6..eae7adcbd 100644 --- a/src/Bullet3Common/b3Scalar.h +++ b/src/Bullet3Common/b3Scalar.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009 Erwin Coumans http://bullet.googlecode.com +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. @@ -44,10 +44,10 @@ inline int b3GetVersion() #if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300) - #define SIMD_FORCE_INLINE inline - #define ATTRIBUTE_ALIGNED16(a) a - #define ATTRIBUTE_ALIGNED64(a) a - #define ATTRIBUTE_ALIGNED128(a) a + #define B3_FORCE_INLINE inline + #define B3_ATTRIBUTE_ALIGNED16(a) a + #define B3_ATTRIBUTE_ALIGNED64(a) a + #define B3_ATTRIBUTE_ALIGNED128(a) a #else //#define B3_HAS_ALIGNED_ALLOCATOR #pragma warning(disable : 4324) // disable padding warning @@ -55,10 +55,10 @@ inline int b3GetVersion() // #pragma warning(disable:4996) //Turn off warnings about deprecated C routines // #pragma warning(disable:4786) // Disable the "debug name too long" warning - #define SIMD_FORCE_INLINE __forceinline - #define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a - #define ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a - #define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a + #define B3_FORCE_INLINE __forceinline + #define B3_ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a + #define B3_ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a + #define B3_ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a #ifdef _XBOX #define B3_USE_VMX128 @@ -105,10 +105,10 @@ inline int b3GetVersion() #else #if defined (__CELLOS_LV2__) - #define SIMD_FORCE_INLINE inline __attribute__((always_inline)) - #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) - #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) - #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) + #define B3_FORCE_INLINE inline __attribute__((always_inline)) + #define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) + #define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) + #define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) #ifndef assert #include #endif @@ -134,10 +134,10 @@ inline int b3GetVersion() #ifdef USE_LIBSPE2 - #define SIMD_FORCE_INLINE __inline - #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) - #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) - #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) + #define B3_FORCE_INLINE __inline + #define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) + #define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) + #define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) #ifndef assert #include #endif @@ -185,11 +185,11 @@ inline int b3GetVersion() #endif //__clang__ #endif//__arm__ - #define SIMD_FORCE_INLINE inline __attribute__ ((always_inline)) + #define B3_FORCE_INLINE inline __attribute__ ((always_inline)) ///@todo: check out alignment methods for other platforms/compilers - #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) - #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) - #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) + #define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) + #define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) + #define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) #ifndef assert #include #endif @@ -219,14 +219,14 @@ inline int b3GetVersion() #else - #define SIMD_FORCE_INLINE inline + #define B3_FORCE_INLINE inline ///@todo: check out alignment methods for other platforms/compilers - ///#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) - ///#define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) - ///#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) - #define ATTRIBUTE_ALIGNED16(a) a - #define ATTRIBUTE_ALIGNED64(a) a - #define ATTRIBUTE_ALIGNED128(a) a + ///#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) + ///#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) + ///#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) + #define B3_ATTRIBUTE_ALIGNED16(a) a + #define B3_ATTRIBUTE_ALIGNED64(a) a + #define B3_ATTRIBUTE_ALIGNED128(a) a #ifndef assert #include #endif @@ -326,36 +326,36 @@ typedef float32x4_t b3SimdFloat4; #define B3_DECLARE_ALIGNED_ALLOCATOR() \ - SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \ - SIMD_FORCE_INLINE void operator delete(void* ptr) { b3AlignedFree(ptr); } \ - SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \ - SIMD_FORCE_INLINE void operator delete(void*, void*) { } \ - SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \ - SIMD_FORCE_INLINE void operator delete[](void* ptr) { b3AlignedFree(ptr); } \ - SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \ - SIMD_FORCE_INLINE void operator delete[](void*, void*) { } \ + B3_FORCE_INLINE void* operator new(size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \ + B3_FORCE_INLINE void operator delete(void* ptr) { b3AlignedFree(ptr); } \ + B3_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \ + B3_FORCE_INLINE void operator delete(void*, void*) { } \ + B3_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \ + B3_FORCE_INLINE void operator delete[](void* ptr) { b3AlignedFree(ptr); } \ + B3_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \ + B3_FORCE_INLINE void operator delete[](void*, void*) { } \ #if defined(B3_USE_DOUBLE_PRECISION) || defined(B3_FORCE_DOUBLE_FUNCTIONS) -SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar x) { return sqrt(x); } -SIMD_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabs(x); } -SIMD_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cos(x); } -SIMD_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sin(x); } -SIMD_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tan(x); } -SIMD_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return acos(x); } -SIMD_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return asin(x); } -SIMD_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atan(x); } -SIMD_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2(x, y); } -SIMD_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return exp(x); } -SIMD_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return log(x); } -SIMD_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return pow(x,y); } -SIMD_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmod(x,y); } +B3_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar x) { return sqrt(x); } +B3_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabs(x); } +B3_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cos(x); } +B3_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sin(x); } +B3_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tan(x); } +B3_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return acos(x); } +B3_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return asin(x); } +B3_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atan(x); } +B3_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2(x, y); } +B3_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return exp(x); } +B3_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return log(x); } +B3_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return pow(x,y); } +B3_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmod(x,y); } #else -SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y) +B3_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y) { #ifdef USE_APPROXIMATION double x, z, tempf; @@ -375,54 +375,54 @@ SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y) return sqrtf(y); #endif } -SIMD_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabsf(x); } -SIMD_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cosf(x); } -SIMD_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sinf(x); } -SIMD_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tanf(x); } -SIMD_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { +B3_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabsf(x); } +B3_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cosf(x); } +B3_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sinf(x); } +B3_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tanf(x); } +B3_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return acosf(x); } -SIMD_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { +B3_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return asinf(x); } -SIMD_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atanf(x); } -SIMD_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2f(x, y); } -SIMD_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return expf(x); } -SIMD_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return logf(x); } -SIMD_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return powf(x,y); } -SIMD_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmodf(x,y); } +B3_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atanf(x); } +B3_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2f(x, y); } +B3_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return expf(x); } +B3_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return logf(x); } +B3_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return powf(x,y); } +B3_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmodf(x,y); } #endif -#define SIMD_2_PI b3Scalar(6.283185307179586232) -#define SIMD_PI (SIMD_2_PI * b3Scalar(0.5)) -#define SIMD_HALF_PI (SIMD_2_PI * b3Scalar(0.25)) -#define SIMD_RADS_PER_DEG (SIMD_2_PI / b3Scalar(360.0)) -#define SIMD_DEGS_PER_RAD (b3Scalar(360.0) / SIMD_2_PI) -#define SIMDSQRT12 b3Scalar(0.7071067811865475244008443621048490) +#define B3_2_PI b3Scalar(6.283185307179586232) +#define B3_PI (B3_2_PI * b3Scalar(0.5)) +#define B3_HALF_PI (B3_2_PI * b3Scalar(0.25)) +#define B3_RADS_PER_DEG (B3_2_PI / b3Scalar(360.0)) +#define B3_DEGS_PER_RAD (b3Scalar(360.0) / B3_2_PI) +#define B3_SQRT12 b3Scalar(0.7071067811865475244008443621048490) #define b3RecipSqrt(x) ((b3Scalar)(b3Scalar(1.0)/b3Sqrt(b3Scalar(x)))) /* reciprocal square root */ #ifdef B3_USE_DOUBLE_PRECISION -#define SIMD_EPSILON DBL_EPSILON -#define SIMD_INFINITY DBL_MAX +#define B3_EPSILON DBL_EPSILON +#define B3_INFINITY DBL_MAX #else -#define SIMD_EPSILON FLT_EPSILON -#define SIMD_INFINITY FLT_MAX +#define B3_EPSILON FLT_EPSILON +#define B3_INFINITY FLT_MAX #endif -SIMD_FORCE_INLINE b3Scalar b3Atan2Fast(b3Scalar y, b3Scalar x) +B3_FORCE_INLINE b3Scalar b3Atan2Fast(b3Scalar y, b3Scalar x) { - b3Scalar coeff_1 = SIMD_PI / 4.0f; + b3Scalar coeff_1 = B3_PI / 4.0f; b3Scalar coeff_2 = 3.0f * coeff_1; b3Scalar abs_y = b3Fabs(y); b3Scalar angle; @@ -436,27 +436,27 @@ SIMD_FORCE_INLINE b3Scalar b3Atan2Fast(b3Scalar y, b3Scalar x) return (y < 0.0f) ? -angle : angle; } -SIMD_FORCE_INLINE bool b3FuzzyZero(b3Scalar x) { return b3Fabs(x) < SIMD_EPSILON; } +B3_FORCE_INLINE bool b3FuzzyZero(b3Scalar x) { return b3Fabs(x) < B3_EPSILON; } -SIMD_FORCE_INLINE bool b3Equal(b3Scalar a, b3Scalar eps) { +B3_FORCE_INLINE bool b3Equal(b3Scalar a, b3Scalar eps) { return (((a) <= eps) && !((a) < -eps)); } -SIMD_FORCE_INLINE bool b3GreaterEqual (b3Scalar a, b3Scalar eps) { +B3_FORCE_INLINE bool b3GreaterEqual (b3Scalar a, b3Scalar eps) { return (!((a) <= eps)); } -SIMD_FORCE_INLINE int b3IsNegative(b3Scalar x) { +B3_FORCE_INLINE int b3IsNegative(b3Scalar x) { return x < b3Scalar(0.0) ? 1 : 0; } -SIMD_FORCE_INLINE b3Scalar b3Radians(b3Scalar x) { return x * SIMD_RADS_PER_DEG; } -SIMD_FORCE_INLINE b3Scalar b3Degrees(b3Scalar x) { return x * SIMD_DEGS_PER_RAD; } +B3_FORCE_INLINE b3Scalar b3Radians(b3Scalar x) { return x * B3_RADS_PER_DEG; } +B3_FORCE_INLINE b3Scalar b3Degrees(b3Scalar x) { return x * B3_DEGS_PER_RAD; } #define B3_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name #ifndef b3Fsel -SIMD_FORCE_INLINE b3Scalar b3Fsel(b3Scalar a, b3Scalar b, b3Scalar c) +B3_FORCE_INLINE b3Scalar b3Fsel(b3Scalar a, b3Scalar b, b3Scalar c) { return a >= 0 ? b : c; } @@ -464,7 +464,7 @@ SIMD_FORCE_INLINE b3Scalar b3Fsel(b3Scalar a, b3Scalar b, b3Scalar c) #define b3Fsels(a,b,c) (b3Scalar)b3Fsel(a,b,c) -SIMD_FORCE_INLINE bool b3MachineIsLittleEndian() +B3_FORCE_INLINE bool b3MachineIsLittleEndian() { long int i = 1; const char *p = (const char *) &i; @@ -478,7 +478,7 @@ SIMD_FORCE_INLINE bool b3MachineIsLittleEndian() ///b3Select avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360 ///Thanks Phil Knight. See also http://www.cellperformance.com/articles/2006/04/more_techniques_for_eliminatin_1.html -SIMD_FORCE_INLINE unsigned b3Select(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero) +B3_FORCE_INLINE unsigned b3Select(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero) { // Set testNz to 0xFFFFFFFF if condition is nonzero, 0x00000000 if condition is zero // Rely on positive value or'ed with its negative having sign bit on @@ -488,13 +488,13 @@ SIMD_FORCE_INLINE unsigned b3Select(unsigned condition, unsigned valueIfConditio unsigned testEqz = ~testNz; return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); } -SIMD_FORCE_INLINE int b3Select(unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero) +B3_FORCE_INLINE int b3Select(unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero) { unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31); unsigned testEqz = ~testNz; return static_cast((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); } -SIMD_FORCE_INLINE float b3Select(unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero) +B3_FORCE_INLINE float b3Select(unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero) { #ifdef B3_HAVE_NATIVE_FSEL return (float)b3Fsel((b3Scalar)condition - b3Scalar(1.0f), valueIfConditionNonZero, valueIfConditionZero); @@ -503,7 +503,7 @@ SIMD_FORCE_INLINE float b3Select(unsigned condition, float valueIfConditionNonZe #endif } -template SIMD_FORCE_INLINE void b3Swap(T& a, T& b) +template B3_FORCE_INLINE void b3Swap(T& a, T& b) { T tmp = a; a = b; @@ -512,22 +512,22 @@ template SIMD_FORCE_INLINE void b3Swap(T& a, T& b) //PCK: endian swapping functions -SIMD_FORCE_INLINE unsigned b3SwapEndian(unsigned val) +B3_FORCE_INLINE unsigned b3SwapEndian(unsigned val) { return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24)); } -SIMD_FORCE_INLINE unsigned short b3SwapEndian(unsigned short val) +B3_FORCE_INLINE unsigned short b3SwapEndian(unsigned short val) { return static_cast(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8)); } -SIMD_FORCE_INLINE unsigned b3SwapEndian(int val) +B3_FORCE_INLINE unsigned b3SwapEndian(int val) { return b3SwapEndian((unsigned)val); } -SIMD_FORCE_INLINE unsigned short b3SwapEndian(short val) +B3_FORCE_INLINE unsigned short b3SwapEndian(short val) { return b3SwapEndian((unsigned short) val); } @@ -538,7 +538,7 @@ SIMD_FORCE_INLINE unsigned short b3SwapEndian(short val) ///When a floating point unit is faced with an invalid value, it may actually change the value, or worse, throw an exception. ///In most systems, running user mode code, you wouldn't get an exception, but instead the hardware/os/runtime will 'fix' the number for you. ///so instead of returning a float/double, we return integer/long long integer -SIMD_FORCE_INLINE unsigned int b3SwapEndianFloat(float d) +B3_FORCE_INLINE unsigned int b3SwapEndianFloat(float d) { unsigned int a = 0; unsigned char *dst = (unsigned char *)&a; @@ -552,7 +552,7 @@ SIMD_FORCE_INLINE unsigned int b3SwapEndianFloat(float d) } // unswap using char pointers -SIMD_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a) +B3_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a) { float d = 0.0f; unsigned char *src = (unsigned char *)&a; @@ -568,7 +568,7 @@ SIMD_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a) // swap using char pointers -SIMD_FORCE_INLINE void b3SwapEndianDouble(double d, unsigned char* dst) +B3_FORCE_INLINE void b3SwapEndianDouble(double d, unsigned char* dst) { unsigned char *src = (unsigned char *)&d; @@ -584,7 +584,7 @@ SIMD_FORCE_INLINE void b3SwapEndianDouble(double d, unsigned char* dst) } // unswap using char pointers -SIMD_FORCE_INLINE double b3UnswapEndianDouble(const unsigned char *src) +B3_FORCE_INLINE double b3UnswapEndianDouble(const unsigned char *src) { double d = 0.0; unsigned char *dst = (unsigned char *)&d; @@ -601,17 +601,17 @@ SIMD_FORCE_INLINE double b3UnswapEndianDouble(const unsigned char *src) return d; } -// returns normalized value in range [-SIMD_PI, SIMD_PI] -SIMD_FORCE_INLINE b3Scalar b3NormalizeAngle(b3Scalar angleInRadians) +// returns normalized value in range [-B3_PI, B3_PI] +B3_FORCE_INLINE b3Scalar b3NormalizeAngle(b3Scalar angleInRadians) { - angleInRadians = b3Fmod(angleInRadians, SIMD_2_PI); - if(angleInRadians < -SIMD_PI) + angleInRadians = b3Fmod(angleInRadians, B3_2_PI); + if(angleInRadians < -B3_PI) { - return angleInRadians + SIMD_2_PI; + return angleInRadians + B3_2_PI; } - else if(angleInRadians > SIMD_PI) + else if(angleInRadians > B3_PI) { - return angleInRadians - SIMD_2_PI; + return angleInRadians - B3_2_PI; } else { diff --git a/src/Bullet3Common/b3StackAlloc.h b/src/Bullet3Common/b3StackAlloc.h index 6443cf48f..de7de056b 100644 --- a/src/Bullet3Common/b3StackAlloc.h +++ b/src/Bullet3Common/b3StackAlloc.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. @@ -78,7 +78,7 @@ public: return(0); } - SIMD_FORCE_INLINE b3Block* beginBlock() + B3_FORCE_INLINE b3Block* beginBlock() { b3Block* pb = (b3Block*)allocate(sizeof(b3Block)); pb->previous = current; @@ -86,7 +86,7 @@ public: current = pb; return(pb); } - SIMD_FORCE_INLINE void endBlock(b3Block* block) + B3_FORCE_INLINE void endBlock(b3Block* block) { b3Assert(block==current); //Raise(L"Unmatched blocks"); diff --git a/src/Bullet3Common/b3Transform.h b/src/Bullet3Common/b3Transform.h index 7a1921313..802dda646 100644 --- a/src/Bullet3Common/b3Transform.h +++ b/src/Bullet3Common/b3Transform.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. @@ -13,7 +13,6 @@ subject to the following restrictions: */ - #ifndef B3_TRANSFORM_H #define B3_TRANSFORM_H @@ -31,7 +30,7 @@ subject to the following restrictions: /**@brief The b3Transform class supports rigid transforms with only translation and rotation and no scaling/shear. *It can be used in combination with b3Vector3, b3Quaternion and b3Matrix3x3 linear algebra classes. */ -ATTRIBUTE_ALIGNED16(class) b3Transform { +B3_ATTRIBUTE_ALIGNED16(class) b3Transform { ///Storage for the rotation b3Matrix3x3 m_basis; @@ -45,7 +44,7 @@ public: /**@brief Constructor from b3Quaternion (optional b3Vector3 ) * @param q Rotation from quaternion * @param c Translation from Vector (default 0,0,0) */ - explicit SIMD_FORCE_INLINE b3Transform(const b3Quaternion& q, + explicit B3_FORCE_INLINE b3Transform(const b3Quaternion& q, const b3Vector3& c = b3Vector3(b3Scalar(0), b3Scalar(0), b3Scalar(0))) : m_basis(q), m_origin(c) @@ -54,19 +53,19 @@ public: /**@brief Constructor from b3Matrix3x3 (optional b3Vector3) * @param b Rotation from Matrix * @param c Translation from Vector default (0,0,0)*/ - explicit SIMD_FORCE_INLINE b3Transform(const b3Matrix3x3& b, + explicit B3_FORCE_INLINE b3Transform(const b3Matrix3x3& b, const b3Vector3& c = b3Vector3(b3Scalar(0), b3Scalar(0), b3Scalar(0))) : m_basis(b), m_origin(c) {} /**@brief Copy constructor */ - SIMD_FORCE_INLINE b3Transform (const b3Transform& other) + B3_FORCE_INLINE b3Transform (const b3Transform& other) : m_basis(other.m_basis), m_origin(other.m_origin) { } /**@brief Assignment Operator */ - SIMD_FORCE_INLINE b3Transform& operator=(const b3Transform& other) + B3_FORCE_INLINE b3Transform& operator=(const b3Transform& other) { m_basis = other.m_basis; m_origin = other.m_origin; @@ -78,7 +77,7 @@ public: * @param t1 Transform 1 * @param t2 Transform 2 * This = Transform1 * Transform2 */ - SIMD_FORCE_INLINE void mult(const b3Transform& t1, const b3Transform& t2) { + B3_FORCE_INLINE void mult(const b3Transform& t1, const b3Transform& t2) { m_basis = t1.m_basis * t2.m_basis; m_origin = t1(t2.m_origin); } @@ -91,32 +90,32 @@ public: */ /**@brief Return the transform of the vector */ - SIMD_FORCE_INLINE b3Vector3 operator()(const b3Vector3& x) const + B3_FORCE_INLINE b3Vector3 operator()(const b3Vector3& x) const { return x.dot3(m_basis[0], m_basis[1], m_basis[2]) + m_origin; } /**@brief Return the transform of the vector */ - SIMD_FORCE_INLINE b3Vector3 operator*(const b3Vector3& x) const + B3_FORCE_INLINE b3Vector3 operator*(const b3Vector3& x) const { return (*this)(x); } /**@brief Return the transform of the b3Quaternion */ - SIMD_FORCE_INLINE b3Quaternion operator*(const b3Quaternion& q) const + B3_FORCE_INLINE b3Quaternion operator*(const b3Quaternion& q) const { return getRotation() * q; } /**@brief Return the basis matrix for the rotation */ - SIMD_FORCE_INLINE b3Matrix3x3& getBasis() { return m_basis; } + B3_FORCE_INLINE b3Matrix3x3& getBasis() { return m_basis; } /**@brief Return the basis matrix for the rotation */ - SIMD_FORCE_INLINE const b3Matrix3x3& getBasis() const { return m_basis; } + B3_FORCE_INLINE const b3Matrix3x3& getBasis() const { return m_basis; } /**@brief Return the origin vector translation */ - SIMD_FORCE_INLINE b3Vector3& getOrigin() { return m_origin; } + B3_FORCE_INLINE b3Vector3& getOrigin() { return m_origin; } /**@brief Return the origin vector translation */ - SIMD_FORCE_INLINE const b3Vector3& getOrigin() const { return m_origin; } + B3_FORCE_INLINE const b3Vector3& getOrigin() const { return m_origin; } /**@brief Return a quaternion representing the rotation */ b3Quaternion getRotation() const { @@ -147,22 +146,22 @@ public: /**@brief Set the translational element * @param origin The vector to set the translation to */ - SIMD_FORCE_INLINE void setOrigin(const b3Vector3& origin) + B3_FORCE_INLINE void setOrigin(const b3Vector3& origin) { m_origin = origin; } - SIMD_FORCE_INLINE b3Vector3 invXform(const b3Vector3& inVec) const; + B3_FORCE_INLINE b3Vector3 invXform(const b3Vector3& inVec) const; /**@brief Set the rotational element by b3Matrix3x3 */ - SIMD_FORCE_INLINE void setBasis(const b3Matrix3x3& basis) + B3_FORCE_INLINE void setBasis(const b3Matrix3x3& basis) { m_basis = basis; } /**@brief Set the rotational element by b3Quaternion */ - SIMD_FORCE_INLINE void setRotation(const b3Quaternion& q) + B3_FORCE_INLINE void setRotation(const b3Quaternion& q) { m_basis.setRotation(q); } @@ -219,14 +218,14 @@ public: }; -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 b3Transform::invXform(const b3Vector3& inVec) const { b3Vector3 v = inVec - m_origin; return (m_basis.transpose() * v); } -SIMD_FORCE_INLINE b3Transform +B3_FORCE_INLINE b3Transform b3Transform::inverseTimes(const b3Transform& t) const { b3Vector3 v = t.getOrigin() - m_origin; @@ -234,7 +233,7 @@ b3Transform::inverseTimes(const b3Transform& t) const v * m_basis); } -SIMD_FORCE_INLINE b3Transform +B3_FORCE_INLINE b3Transform b3Transform::operator*(const b3Transform& t) const { return b3Transform(m_basis * t.m_basis, @@ -242,7 +241,7 @@ b3Transform::operator*(const b3Transform& t) const } /**@brief Test if two transforms have all elements equal */ -SIMD_FORCE_INLINE bool operator==(const b3Transform& t1, const b3Transform& t2) +B3_FORCE_INLINE bool operator==(const b3Transform& t1, const b3Transform& t2) { return ( t1.getBasis() == t2.getBasis() && t1.getOrigin() == t2.getOrigin() ); @@ -264,32 +263,32 @@ struct b3TransformDoubleData -SIMD_FORCE_INLINE void b3Transform::serialize(b3TransformData& dataOut) const +B3_FORCE_INLINE void b3Transform::serialize(b3TransformData& dataOut) const { m_basis.serialize(dataOut.m_basis); m_origin.serialize(dataOut.m_origin); } -SIMD_FORCE_INLINE void b3Transform::serializeFloat(b3TransformFloatData& dataOut) const +B3_FORCE_INLINE void b3Transform::serializeFloat(b3TransformFloatData& dataOut) const { m_basis.serializeFloat(dataOut.m_basis); m_origin.serializeFloat(dataOut.m_origin); } -SIMD_FORCE_INLINE void b3Transform::deSerialize(const b3TransformData& dataIn) +B3_FORCE_INLINE void b3Transform::deSerialize(const b3TransformData& dataIn) { m_basis.deSerialize(dataIn.m_basis); m_origin.deSerialize(dataIn.m_origin); } -SIMD_FORCE_INLINE void b3Transform::deSerializeFloat(const b3TransformFloatData& dataIn) +B3_FORCE_INLINE void b3Transform::deSerializeFloat(const b3TransformFloatData& dataIn) { m_basis.deSerializeFloat(dataIn.m_basis); m_origin.deSerializeFloat(dataIn.m_origin); } -SIMD_FORCE_INLINE void b3Transform::deSerializeDouble(const b3TransformDoubleData& dataIn) +B3_FORCE_INLINE void b3Transform::deSerializeDouble(const b3TransformDoubleData& dataIn) { m_basis.deSerializeDouble(dataIn.m_basis); m_origin.deSerializeDouble(dataIn.m_origin); diff --git a/src/Bullet3Common/b3TransformUtil.h b/src/Bullet3Common/b3TransformUtil.h index 157138b63..c6aeef415 100644 --- a/src/Bullet3Common/b3TransformUtil.h +++ b/src/Bullet3Common/b3TransformUtil.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. @@ -17,12 +17,12 @@ subject to the following restrictions: #define B3_TRANSFORM_UTIL_H #include "b3Transform.h" -#define ANGULAR_MOTION_THRESHOLD b3Scalar(0.5)*SIMD_HALF_PI +#define B3_ANGULAR_MOTION_THRESHOLD b3Scalar(0.5)*B3_HALF_PI -SIMD_FORCE_INLINE b3Vector3 b3AabbSupport(const b3Vector3& halfExtents,const b3Vector3& supportDir) +B3_FORCE_INLINE b3Vector3 b3AabbSupport(const b3Vector3& halfExtents,const b3Vector3& supportDir) { return b3Vector3(supportDir.getX() < b3Scalar(0.0) ? -halfExtents.getX() : halfExtents.getX(), supportDir.getY() < b3Scalar(0.0) ? -halfExtents.getY() : halfExtents.getY(), @@ -55,9 +55,9 @@ public: b3Vector3 axis; b3Scalar fAngle = angvel.length(); //limit the angular motion - if (fAngle*timeStep > ANGULAR_MOTION_THRESHOLD) + if (fAngle*timeStep > B3_ANGULAR_MOTION_THRESHOLD) { - fAngle = ANGULAR_MOTION_THRESHOLD / timeStep; + fAngle = B3_ANGULAR_MOTION_THRESHOLD / timeStep; } if ( fAngle < b3Scalar(0.001) ) @@ -103,7 +103,7 @@ public: axis[3] = b3Scalar(0.); //check for axis length b3Scalar len = axis.length2(); - if (len < SIMD_EPSILON*SIMD_EPSILON) + if (len < B3_EPSILON*B3_EPSILON) axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.)); else axis /= b3Sqrt(len); @@ -132,7 +132,7 @@ public: axis[3] = b3Scalar(0.); //check for axis length b3Scalar len = axis.length2(); - if (len < SIMD_EPSILON*SIMD_EPSILON) + if (len < B3_EPSILON*B3_EPSILON) axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.)); else axis /= b3Sqrt(len); diff --git a/src/Bullet3Common/b3Vector3.cpp b/src/Bullet3Common/b3Vector3.cpp index e8d4f4ddd..faebefcab 100644 --- a/src/Bullet3Common/b3Vector3.cpp +++ b/src/Bullet3Common/b3Vector3.cpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2011 Apple Inc. - http://continuousphysics.com/Bullet/ + Copyright (c) 2011-213 Apple Inc. http://bulletphysics.org 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. diff --git a/src/Bullet3Common/b3Vector3.h b/src/Bullet3Common/b3Vector3.h index 3188efbf4..e8f6350b9 100644 --- a/src/Bullet3Common/b3Vector3.h +++ b/src/Bullet3Common/b3Vector3.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ +Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org 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. @@ -55,19 +55,19 @@ subject to the following restrictions: -const __m128 ATTRIBUTE_ALIGNED16(b3vMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f}; -const __m128 ATTRIBUTE_ALIGNED16(v1110) = {1.0f, 1.0f, 1.0f, 0.0f}; -const __m128 ATTRIBUTE_ALIGNED16(vHalf) = {0.5f, 0.5f, 0.5f, 0.5f}; -const __m128 ATTRIBUTE_ALIGNED16(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f}; +const __m128 B3_ATTRIBUTE_ALIGNED16(b3vMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f}; +const __m128 B3_ATTRIBUTE_ALIGNED16(v1110) = {1.0f, 1.0f, 1.0f, 0.0f}; +const __m128 B3_ATTRIBUTE_ALIGNED16(vHalf) = {0.5f, 0.5f, 0.5f, 0.5f}; +const __m128 B3_ATTRIBUTE_ALIGNED16(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f}; #endif #ifdef B3_USE_NEON -const float32x4_t ATTRIBUTE_ALIGNED16(b3vMzeroMask) = (float32x4_t){-0.0f, -0.0f, -0.0f, -0.0f}; -const int32x4_t ATTRIBUTE_ALIGNED16(b3vFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0}; -const int32x4_t ATTRIBUTE_ALIGNED16(b3vAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; -const int32x4_t ATTRIBUTE_ALIGNED16(b3v3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0}; +const float32x4_t B3_ATTRIBUTE_ALIGNED16(b3vMzeroMask) = (float32x4_t){-0.0f, -0.0f, -0.0f, -0.0f}; +const int32x4_t B3_ATTRIBUTE_ALIGNED16(b3vFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0}; +const int32x4_t B3_ATTRIBUTE_ALIGNED16(b3vAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; +const int32x4_t B3_ATTRIBUTE_ALIGNED16(b3v3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0}; #endif @@ -75,7 +75,7 @@ const int32x4_t ATTRIBUTE_ALIGNED16(b3v3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FF * It has an un-used w component to suit 16-byte alignment when b3Vector3 is stored in containers. This extra component can be used by derived classes (Quaternion?) or by user * Ideally, this class should be replaced by a platform optimized SIMD version that keeps the data in registers */ -ATTRIBUTE_ALIGNED16(class) b3Vector3 +B3_ATTRIBUTE_ALIGNED16(class) b3Vector3 { public: @@ -84,7 +84,7 @@ public: #if defined (__SPU__) && defined (__CELLOS_LV2__) b3Scalar m_floats[4]; public: - SIMD_FORCE_INLINE const vec_float4& get128() const + B3_FORCE_INLINE const vec_float4& get128() const { return *((const vec_float4*)&m_floats[0]); } @@ -97,11 +97,11 @@ public: struct {b3Scalar x,y,z,w;}; }; - SIMD_FORCE_INLINE b3SimdFloat4 get128() const + B3_FORCE_INLINE b3SimdFloat4 get128() const { return mVec128; } - SIMD_FORCE_INLINE void set128(b3SimdFloat4 v128) + B3_FORCE_INLINE void set128(b3SimdFloat4 v128) { mVec128 = v128; } @@ -113,7 +113,7 @@ public: public: /**@brief No initialization constructor */ - SIMD_FORCE_INLINE b3Vector3() + B3_FORCE_INLINE b3Vector3() { } @@ -125,7 +125,7 @@ public: * @param y Y value * @param z Z value */ - SIMD_FORCE_INLINE b3Vector3(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z) + B3_FORCE_INLINE b3Vector3(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z) { m_floats[0] = _x; m_floats[1] = _y; @@ -135,19 +135,19 @@ public: #if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) )|| defined (B3_USE_NEON) // Set Vector - SIMD_FORCE_INLINE b3Vector3( b3SimdFloat4 v) + B3_FORCE_INLINE b3Vector3( b3SimdFloat4 v) { mVec128 = v; } // Copy constructor - SIMD_FORCE_INLINE b3Vector3(const b3Vector3& rhs) + B3_FORCE_INLINE b3Vector3(const b3Vector3& rhs) { mVec128 = rhs.mVec128; } // Assignment Operator - SIMD_FORCE_INLINE b3Vector3& + B3_FORCE_INLINE b3Vector3& operator=(const b3Vector3& v) { mVec128 = v.mVec128; @@ -158,7 +158,7 @@ public: /**@brief Add a vector to this one * @param The vector to add to this one */ - SIMD_FORCE_INLINE b3Vector3& operator+=(const b3Vector3& v) + B3_FORCE_INLINE b3Vector3& operator+=(const b3Vector3& v) { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_add_ps(mVec128, v.mVec128); @@ -175,7 +175,7 @@ public: /**@brief Subtract a vector from this one * @param The vector to subtract */ - SIMD_FORCE_INLINE b3Vector3& operator-=(const b3Vector3& v) + B3_FORCE_INLINE b3Vector3& operator-=(const b3Vector3& v) { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_sub_ps(mVec128, v.mVec128); @@ -191,7 +191,7 @@ public: /**@brief Scale the vector * @param s Scale factor */ - SIMD_FORCE_INLINE b3Vector3& operator*=(const b3Scalar& s) + B3_FORCE_INLINE b3Vector3& operator*=(const b3Scalar& s) { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vs = _mm_load_ss(&s); // (S 0 0 0) @@ -209,7 +209,7 @@ public: /**@brief Inversely scale the vector * @param s Scale factor to divide by */ - SIMD_FORCE_INLINE b3Vector3& operator/=(const b3Scalar& s) + B3_FORCE_INLINE b3Vector3& operator/=(const b3Scalar& s) { b3FullAssert(s != b3Scalar(0.0)); @@ -229,7 +229,7 @@ public: /**@brief Return the dot product * @param v The other vector in the dot product */ - SIMD_FORCE_INLINE b3Scalar dot(const b3Vector3& v) const + B3_FORCE_INLINE b3Scalar dot(const b3Vector3& v) const { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vd = _mm_mul_ps(mVec128, v.mVec128); @@ -251,26 +251,26 @@ public: } /**@brief Return the length of the vector squared */ - SIMD_FORCE_INLINE b3Scalar length2() const + B3_FORCE_INLINE b3Scalar length2() const { return dot(*this); } /**@brief Return the length of the vector */ - SIMD_FORCE_INLINE b3Scalar length() const + B3_FORCE_INLINE b3Scalar length() const { return b3Sqrt(length2()); } /**@brief Return the distance squared between the ends of this and another vector * This is symantically treating the vector like a point */ - SIMD_FORCE_INLINE b3Scalar distance2(const b3Vector3& v) const; + B3_FORCE_INLINE b3Scalar distance2(const b3Vector3& v) const; /**@brief Return the distance between the ends of this and another vector * This is symantically treating the vector like a point */ - SIMD_FORCE_INLINE b3Scalar distance(const b3Vector3& v) const; + B3_FORCE_INLINE b3Scalar distance(const b3Vector3& v) const; - SIMD_FORCE_INLINE b3Vector3& safeNormalize() + B3_FORCE_INLINE b3Vector3& safeNormalize() { b3Vector3 absVec = this->absolute(); int maxIndex = absVec.maxAxis(); @@ -285,7 +285,7 @@ public: /**@brief Normalize this vector * x^2 + y^2 + z^2 = 1 */ - SIMD_FORCE_INLINE b3Vector3& normalize() + B3_FORCE_INLINE b3Vector3& normalize() { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) // dot product first @@ -328,16 +328,16 @@ public: } /**@brief Return a normalized version of this vector */ - SIMD_FORCE_INLINE b3Vector3 normalized() const; + B3_FORCE_INLINE b3Vector3 normalized() const; /**@brief Return a rotated version of this vector * @param wAxis The axis to rotate about * @param angle The angle to rotate by */ - SIMD_FORCE_INLINE b3Vector3 rotate( const b3Vector3& wAxis, const b3Scalar angle ) const; + B3_FORCE_INLINE b3Vector3 rotate( const b3Vector3& wAxis, const b3Scalar angle ) const; /**@brief Return the angle between this and another vector * @param v The other vector */ - SIMD_FORCE_INLINE b3Scalar angle(const b3Vector3& v) const + B3_FORCE_INLINE b3Scalar angle(const b3Vector3& v) const { b3Scalar s = b3Sqrt(length2() * v.length2()); b3FullAssert(s != b3Scalar(0.0)); @@ -345,7 +345,7 @@ public: } /**@brief Return a vector will the absolute values of each element */ - SIMD_FORCE_INLINE b3Vector3 absolute() const + B3_FORCE_INLINE b3Vector3 absolute() const { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return b3Vector3(_mm_and_ps(mVec128, b3v3AbsfMask)); @@ -361,7 +361,7 @@ public: /**@brief Return the cross product between this and another vector * @param v The other vector */ - SIMD_FORCE_INLINE b3Vector3 cross(const b3Vector3& v) const + B3_FORCE_INLINE b3Vector3 cross(const b3Vector3& v) const { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 T, V; @@ -400,7 +400,7 @@ public: #endif } - SIMD_FORCE_INLINE b3Scalar triple(const b3Vector3& v1, const b3Vector3& v2) const + B3_FORCE_INLINE b3Scalar triple(const b3Vector3& v1, const b3Vector3& v2) const { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) // cross: @@ -452,30 +452,30 @@ public: /**@brief Return the axis with the smallest value * Note return values are 0,1,2 for x, y, or z */ - SIMD_FORCE_INLINE int minAxis() const + B3_FORCE_INLINE int minAxis() const { return m_floats[0] < m_floats[1] ? (m_floats[0] return this, t=1 => return other) */ - SIMD_FORCE_INLINE b3Vector3 lerp(const b3Vector3& v, const b3Scalar& t) const + B3_FORCE_INLINE b3Vector3 lerp(const b3Vector3& v, const b3Scalar& t) const { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vt = _mm_load_ss(&t); // (t 0 0 0) @@ -530,7 +530,7 @@ public: /**@brief Elementwise multiply this vector by the other * @param v The other vector */ - SIMD_FORCE_INLINE b3Vector3& operator*=(const b3Vector3& v) + B3_FORCE_INLINE b3Vector3& operator*=(const b3Vector3& v) { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_mul_ps(mVec128, v.mVec128); @@ -545,30 +545,30 @@ public: } /**@brief Return the x value */ - SIMD_FORCE_INLINE const b3Scalar& getX() const { return m_floats[0]; } + B3_FORCE_INLINE const b3Scalar& getX() const { return m_floats[0]; } /**@brief Return the y value */ - SIMD_FORCE_INLINE const b3Scalar& getY() const { return m_floats[1]; } + B3_FORCE_INLINE const b3Scalar& getY() const { return m_floats[1]; } /**@brief Return the z value */ - SIMD_FORCE_INLINE const b3Scalar& getZ() const { return m_floats[2]; } + B3_FORCE_INLINE const b3Scalar& getZ() const { return m_floats[2]; } /**@brief Return the w value */ - SIMD_FORCE_INLINE const b3Scalar& getW() const { return m_floats[3]; } + B3_FORCE_INLINE const b3Scalar& getW() const { return m_floats[3]; } /**@brief Set the x value */ - SIMD_FORCE_INLINE void setX(b3Scalar _x) { m_floats[0] = _x;}; + B3_FORCE_INLINE void setX(b3Scalar _x) { m_floats[0] = _x;}; /**@brief Set the y value */ - SIMD_FORCE_INLINE void setY(b3Scalar _y) { m_floats[1] = _y;}; + B3_FORCE_INLINE void setY(b3Scalar _y) { m_floats[1] = _y;}; /**@brief Set the z value */ - SIMD_FORCE_INLINE void setZ(b3Scalar _z) { m_floats[2] = _z;}; + B3_FORCE_INLINE void setZ(b3Scalar _z) { m_floats[2] = _z;}; /**@brief Set the w value */ - SIMD_FORCE_INLINE void setW(b3Scalar _w) { m_floats[3] = _w;}; + B3_FORCE_INLINE void setW(b3Scalar _w) { m_floats[3] = _w;}; - //SIMD_FORCE_INLINE b3Scalar& operator[](int i) { return (&m_floats[0])[i]; } - //SIMD_FORCE_INLINE const b3Scalar& operator[](int i) const { return (&m_floats[0])[i]; } + //B3_FORCE_INLINE b3Scalar& operator[](int i) { return (&m_floats[0])[i]; } + //B3_FORCE_INLINE const b3Scalar& operator[](int i) const { return (&m_floats[0])[i]; } ///operator b3Scalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons. - SIMD_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; } - SIMD_FORCE_INLINE operator const b3Scalar *() const { return &m_floats[0]; } + B3_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; } + B3_FORCE_INLINE operator const b3Scalar *() const { return &m_floats[0]; } - SIMD_FORCE_INLINE bool operator==(const b3Vector3& other) const + B3_FORCE_INLINE bool operator==(const b3Vector3& other) const { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128))); @@ -580,7 +580,7 @@ public: #endif } - SIMD_FORCE_INLINE bool operator!=(const b3Vector3& other) const + B3_FORCE_INLINE bool operator!=(const b3Vector3& other) const { return !(*this == other); } @@ -588,7 +588,7 @@ public: /**@brief Set each element to the max of the current values and the values of another b3Vector3 * @param other The other b3Vector3 to compare with */ - SIMD_FORCE_INLINE void setMax(const b3Vector3& other) + B3_FORCE_INLINE void setMax(const b3Vector3& other) { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_max_ps(mVec128, other.mVec128); @@ -605,7 +605,7 @@ public: /**@brief Set each element to the min of the current values and the values of another b3Vector3 * @param other The other b3Vector3 to compare with */ - SIMD_FORCE_INLINE void setMin(const b3Vector3& other) + B3_FORCE_INLINE void setMin(const b3Vector3& other) { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_min_ps(mVec128, other.mVec128); @@ -619,7 +619,7 @@ public: #endif } - SIMD_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z) + B3_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z) { m_floats[0]=_x; m_floats[1]=_y; @@ -662,42 +662,42 @@ public: #endif } - SIMD_FORCE_INLINE bool isZero() const + B3_FORCE_INLINE bool isZero() const { return m_floats[0] == b3Scalar(0) && m_floats[1] == b3Scalar(0) && m_floats[2] == b3Scalar(0); } - SIMD_FORCE_INLINE bool fuzzyZero() const + B3_FORCE_INLINE bool fuzzyZero() const { - return length2() < SIMD_EPSILON; + return length2() < B3_EPSILON; } - SIMD_FORCE_INLINE void serialize(struct b3Vector3Data& dataOut) const; + B3_FORCE_INLINE void serialize(struct b3Vector3Data& dataOut) const; - SIMD_FORCE_INLINE void deSerialize(const struct b3Vector3Data& dataIn); + B3_FORCE_INLINE void deSerialize(const struct b3Vector3Data& dataIn); - SIMD_FORCE_INLINE void serializeFloat(struct b3Vector3FloatData& dataOut) const; + B3_FORCE_INLINE void serializeFloat(struct b3Vector3FloatData& dataOut) const; - SIMD_FORCE_INLINE void deSerializeFloat(const struct b3Vector3FloatData& dataIn); + B3_FORCE_INLINE void deSerializeFloat(const struct b3Vector3FloatData& dataIn); - SIMD_FORCE_INLINE void serializeDouble(struct b3Vector3DoubleData& dataOut) const; + B3_FORCE_INLINE void serializeDouble(struct b3Vector3DoubleData& dataOut) const; - SIMD_FORCE_INLINE void deSerializeDouble(const struct b3Vector3DoubleData& dataIn); + B3_FORCE_INLINE void deSerializeDouble(const struct b3Vector3DoubleData& dataIn); /**@brief returns index of maximum dot product between this and vectors in array[] * @param array The other vectors * @param array_count The number of other vectors * @param dotOut The maximum dot product */ - SIMD_FORCE_INLINE long maxDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const; + B3_FORCE_INLINE long maxDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const; /**@brief returns index of minimum dot product between this and vectors in array[] * @param array The other vectors * @param array_count The number of other vectors * @param dotOut The minimum dot product */ - SIMD_FORCE_INLINE long minDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const; + B3_FORCE_INLINE long minDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const; /* create a vector as b3Vector3( this->dot( b3Vector3 v0 ), this->dot( b3Vector3 v1), this->dot( b3Vector3 v2 )) */ - SIMD_FORCE_INLINE b3Vector3 dot3( const b3Vector3 &v0, const b3Vector3 &v1, const b3Vector3 &v2 ) const + B3_FORCE_INLINE b3Vector3 dot3( const b3Vector3 &v0, const b3Vector3 &v1, const b3Vector3 &v2 ) const { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -730,7 +730,7 @@ public: }; /**@brief Return the sum of two vectors (Point symantics)*/ -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator+(const b3Vector3& v1, const b3Vector3& v2) { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -746,7 +746,7 @@ operator+(const b3Vector3& v1, const b3Vector3& v2) } /**@brief Return the elementwise product of two vectors */ -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator*(const b3Vector3& v1, const b3Vector3& v2) { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -762,7 +762,7 @@ operator*(const b3Vector3& v1, const b3Vector3& v2) } /**@brief Return the difference between two vectors */ -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator-(const b3Vector3& v1, const b3Vector3& v2) { #if (defined(B3_USE_SSE_IN_API) && defined(B3_USE_SSE)) @@ -782,7 +782,7 @@ operator-(const b3Vector3& v1, const b3Vector3& v2) } /**@brief Return the negative of the vector */ -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator-(const b3Vector3& v) { #if (defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) @@ -796,7 +796,7 @@ operator-(const b3Vector3& v) } /**@brief Return the vector scaled by s */ -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator*(const b3Vector3& v, const b3Scalar& s) { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) @@ -812,14 +812,14 @@ operator*(const b3Vector3& v, const b3Scalar& s) } /**@brief Return the vector scaled by s */ -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator*(const b3Scalar& s, const b3Vector3& v) { return v * s; } /**@brief Return the vector inversely scaled by s */ -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator/(const b3Vector3& v, const b3Scalar& s) { b3FullAssert(s != b3Scalar(0.0)); @@ -836,7 +836,7 @@ operator/(const b3Vector3& v, const b3Scalar& s) } /**@brief Return the vector inversely scaled by s */ -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 operator/(const b3Vector3& v1, const b3Vector3& v2) { #if (defined(B3_USE_SSE_IN_API)&& defined (B3_USE_SSE)) @@ -866,7 +866,7 @@ operator/(const b3Vector3& v1, const b3Vector3& v2) } /**@brief Return the dot product between two vectors */ -SIMD_FORCE_INLINE b3Scalar +B3_FORCE_INLINE b3Scalar b3Dot(const b3Vector3& v1, const b3Vector3& v2) { return v1.dot(v2); @@ -874,7 +874,7 @@ b3Dot(const b3Vector3& v1, const b3Vector3& v2) /**@brief Return the distance squared between two vectors */ -SIMD_FORCE_INLINE b3Scalar +B3_FORCE_INLINE b3Scalar b3Distance2(const b3Vector3& v1, const b3Vector3& v2) { return v1.distance2(v2); @@ -882,27 +882,27 @@ b3Distance2(const b3Vector3& v1, const b3Vector3& v2) /**@brief Return the distance between two vectors */ -SIMD_FORCE_INLINE b3Scalar +B3_FORCE_INLINE b3Scalar b3Distance(const b3Vector3& v1, const b3Vector3& v2) { return v1.distance(v2); } /**@brief Return the angle between two vectors */ -SIMD_FORCE_INLINE b3Scalar +B3_FORCE_INLINE b3Scalar b3Angle(const b3Vector3& v1, const b3Vector3& v2) { return v1.angle(v2); } /**@brief Return the cross product of two vectors */ -SIMD_FORCE_INLINE b3Vector3 +B3_FORCE_INLINE b3Vector3 b3Cross(const b3Vector3& v1, const b3Vector3& v2) { return v1.cross(v2); } -SIMD_FORCE_INLINE b3Scalar +B3_FORCE_INLINE b3Scalar b3Triple(const b3Vector3& v1, const b3Vector3& v2, const b3Vector3& v3) { return v1.triple(v2, v3); @@ -912,25 +912,25 @@ b3Triple(const b3Vector3& v1, const b3Vector3& v2, const b3Vector3& v3) * @param v1 One vector * @param v2 The other vector * @param t The ration of this to v (t = 0 => return v1, t=1 => return v2) */ -SIMD_FORCE_INLINE b3Vector3 -lerp(const b3Vector3& v1, const b3Vector3& v2, const b3Scalar& t) +B3_FORCE_INLINE b3Vector3 +b3Lerp(const b3Vector3& v1, const b3Vector3& v2, const b3Scalar& t) { return v1.lerp(v2, t); } -SIMD_FORCE_INLINE b3Scalar b3Vector3::distance2(const b3Vector3& v) const +B3_FORCE_INLINE b3Scalar b3Vector3::distance2(const b3Vector3& v) const { return (v - *this).length2(); } -SIMD_FORCE_INLINE b3Scalar b3Vector3::distance(const b3Vector3& v) const +B3_FORCE_INLINE b3Scalar b3Vector3::distance(const b3Vector3& v) const { return (v - *this).length(); } -SIMD_FORCE_INLINE b3Vector3 b3Vector3::normalized() const +B3_FORCE_INLINE b3Vector3 b3Vector3::normalized() const { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) b3Vector3 norm = *this; @@ -941,7 +941,7 @@ SIMD_FORCE_INLINE b3Vector3 b3Vector3::normalized() const #endif } -SIMD_FORCE_INLINE b3Vector3 b3Vector3::rotate( const b3Vector3& wAxis, const b3Scalar _angle ) const +B3_FORCE_INLINE b3Vector3 b3Vector3::rotate( const b3Vector3& wAxis, const b3Scalar _angle ) const { // wAxis must be a unit lenght vector @@ -983,7 +983,7 @@ SIMD_FORCE_INLINE b3Vector3 b3Vector3::rotate( const b3Vector3& wAxis, const b3S #endif } -SIMD_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const +B3_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const { #if defined (B3_USE_SSE) || defined (B3_USE_NEON) #if defined _WIN32 || defined (B3_USE_SSE) @@ -998,7 +998,7 @@ SIMD_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long arra #endif//B3_USE_SSE || B3_USE_NEON { - b3Scalar maxDot = -SIMD_INFINITY; + b3Scalar maxDot = -B3_INFINITY; int i = 0; int ptIndex = -1; for( i = 0; i < array_count; i++ ) @@ -1020,7 +1020,7 @@ SIMD_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long arra #endif } -SIMD_FORCE_INLINE long b3Vector3::minDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const +B3_FORCE_INLINE long b3Vector3::minDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const { #if defined (B3_USE_SSE) || defined (B3_USE_NEON) #if defined B3_USE_SSE @@ -1036,7 +1036,7 @@ SIMD_FORCE_INLINE long b3Vector3::minDot( const b3Vector3 *array, long arra if( array_count < scalar_cutoff ) #endif//B3_USE_SSE || B3_USE_NEON { - b3Scalar minDot = SIMD_INFINITY; + b3Scalar minDot = B3_INFINITY; int i = 0; int ptIndex = -1; @@ -1065,27 +1065,27 @@ class b3Vector4 : public b3Vector3 { public: - SIMD_FORCE_INLINE b3Vector4() {} + B3_FORCE_INLINE b3Vector4() {} - SIMD_FORCE_INLINE b3Vector4(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) + B3_FORCE_INLINE b3Vector4(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) : b3Vector3(_x,_y,_z) { m_floats[3] = _w; } #if (defined (B3_USE_SSE_IN_API)&& defined (B3_USE_SSE)) || defined (B3_USE_NEON) - SIMD_FORCE_INLINE b3Vector4(const b3SimdFloat4 vec) + B3_FORCE_INLINE b3Vector4(const b3SimdFloat4 vec) { mVec128 = vec; } - SIMD_FORCE_INLINE b3Vector4(const b3Vector3& rhs) + B3_FORCE_INLINE b3Vector4(const b3Vector3& rhs) { mVec128 = rhs.mVec128; } - SIMD_FORCE_INLINE b3Vector4& + B3_FORCE_INLINE b3Vector4& operator=(const b3Vector4& v) { mVec128 = v.mVec128; @@ -1093,7 +1093,7 @@ public: } #endif // #if defined (B3_USE_SSE_IN_API) || defined (B3_USE_NEON) - SIMD_FORCE_INLINE b3Vector4 absolute4() const + B3_FORCE_INLINE b3Vector4 absolute4() const { #if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return b3Vector4(_mm_and_ps(mVec128, b3vAbsfMask)); @@ -1112,7 +1112,7 @@ public: b3Scalar getW() const { return m_floats[3];} - SIMD_FORCE_INLINE int maxAxis4() const + B3_FORCE_INLINE int maxAxis4() const { int maxIndex = -1; b3Scalar maxVal = b3Scalar(-B3_LARGE_FLOAT); @@ -1141,7 +1141,7 @@ public: } - SIMD_FORCE_INLINE int minAxis4() const + B3_FORCE_INLINE int minAxis4() const { int minIndex = -1; b3Scalar minVal = b3Scalar(B3_LARGE_FLOAT); @@ -1170,7 +1170,7 @@ public: } - SIMD_FORCE_INLINE int closestAxis4() const + B3_FORCE_INLINE int closestAxis4() const { return absolute4().maxAxis4(); } @@ -1198,7 +1198,7 @@ public: * @param z Value of z * @param w Value of w */ - SIMD_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) + B3_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) { m_floats[0]=_x; m_floats[1]=_y; @@ -1211,7 +1211,7 @@ public: ///b3SwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization -SIMD_FORCE_INLINE void b3SwapScalarEndian(const b3Scalar& sourceVal, b3Scalar& destVal) +B3_FORCE_INLINE void b3SwapScalarEndian(const b3Scalar& sourceVal, b3Scalar& destVal) { #ifdef B3_USE_DOUBLE_PRECISION unsigned char* dest = (unsigned char*) &destVal; @@ -1234,7 +1234,7 @@ SIMD_FORCE_INLINE void b3SwapScalarEndian(const b3Scalar& sourceVal, b3Scalar& d #endif //B3_USE_DOUBLE_PRECISION } ///b3SwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization -SIMD_FORCE_INLINE void b3SwapVector3Endian(const b3Vector3& sourceVec, b3Vector3& destVec) +B3_FORCE_INLINE void b3SwapVector3Endian(const b3Vector3& sourceVec, b3Vector3& destVec) { for (int i=0;i<4;i++) { @@ -1244,7 +1244,7 @@ SIMD_FORCE_INLINE void b3SwapVector3Endian(const b3Vector3& sourceVec, b3Vector3 } ///b3UnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization -SIMD_FORCE_INLINE void b3UnSwapVector3Endian(b3Vector3& vector) +B3_FORCE_INLINE void b3UnSwapVector3Endian(b3Vector3& vector) { b3Vector3 swappedVec; @@ -1256,9 +1256,9 @@ SIMD_FORCE_INLINE void b3UnSwapVector3Endian(b3Vector3& vector) } template -SIMD_FORCE_INLINE void b3PlaneSpace1 (const T& n, T& p, T& q) +B3_FORCE_INLINE void b3PlaneSpace1 (const T& n, T& p, T& q) { - if (b3Fabs(n[2]) > SIMDSQRT12) { + if (b3Fabs(n[2]) > B3_SQRT12) { // choose p in y-z plane b3Scalar a = n[1]*n[1] + n[2]*n[2]; b3Scalar k = b3RecipSqrt (a); @@ -1296,42 +1296,42 @@ struct b3Vector3DoubleData }; -SIMD_FORCE_INLINE void b3Vector3::serializeFloat(struct b3Vector3FloatData& dataOut) const +B3_FORCE_INLINE void b3Vector3::serializeFloat(struct b3Vector3FloatData& dataOut) const { ///could also do a memcpy, check if it is worth it for (int i=0;i<4;i++) dataOut.m_floats[i] = float(m_floats[i]); } -SIMD_FORCE_INLINE void b3Vector3::deSerializeFloat(const struct b3Vector3FloatData& dataIn) +B3_FORCE_INLINE void b3Vector3::deSerializeFloat(const struct b3Vector3FloatData& dataIn) { for (int i=0;i<4;i++) m_floats[i] = b3Scalar(dataIn.m_floats[i]); } -SIMD_FORCE_INLINE void b3Vector3::serializeDouble(struct b3Vector3DoubleData& dataOut) const +B3_FORCE_INLINE void b3Vector3::serializeDouble(struct b3Vector3DoubleData& dataOut) const { ///could also do a memcpy, check if it is worth it for (int i=0;i<4;i++) dataOut.m_floats[i] = double(m_floats[i]); } -SIMD_FORCE_INLINE void b3Vector3::deSerializeDouble(const struct b3Vector3DoubleData& dataIn) +B3_FORCE_INLINE void b3Vector3::deSerializeDouble(const struct b3Vector3DoubleData& dataIn) { for (int i=0;i<4;i++) m_floats[i] = b3Scalar(dataIn.m_floats[i]); } -SIMD_FORCE_INLINE void b3Vector3::serialize(struct b3Vector3Data& dataOut) const +B3_FORCE_INLINE void b3Vector3::serialize(struct b3Vector3Data& dataOut) const { ///could also do a memcpy, check if it is worth it for (int i=0;i<4;i++) dataOut.m_floats[i] = m_floats[i]; } -SIMD_FORCE_INLINE void b3Vector3::deSerialize(const struct b3Vector3Data& dataIn) +B3_FORCE_INLINE void b3Vector3::deSerialize(const struct b3Vector3Data& dataIn) { for (int i=0;i<4;i++) m_floats[i] = dataIn.m_floats[i]; diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3ContactSolverInfo.h b/src/Bullet3Dynamics/ConstraintSolver/b3ContactSolverInfo.h index 4369f86ff..7a12257b3 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3ContactSolverInfo.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3ContactSolverInfo.h @@ -20,16 +20,16 @@ subject to the following restrictions: enum b3SolverMode { - SOLVER_RANDMIZE_ORDER = 1, - SOLVER_FRICTION_SEPARATE = 2, - SOLVER_USE_WARMSTARTING = 4, - SOLVER_USE_2_FRICTION_DIRECTIONS = 16, - SOLVER_ENABLE_FRICTION_DIRECTION_CACHING = 32, - SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64, - SOLVER_CACHE_FRIENDLY = 128, - SOLVER_SIMD = 256, - SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS = 512, - SOLVER_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024 + B3_SOLVER_RANDMIZE_ORDER = 1, + B3_SOLVER_FRICTION_SEPARATE = 2, + B3_SOLVER_USE_WARMSTARTING = 4, + B3_SOLVER_USE_2_FRICTION_DIRECTIONS = 16, + B3_SOLVER_ENABLE_FRICTION_DIRECTION_CACHING = 32, + B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64, + B3_SOLVER_CACHE_FRIENDLY = 128, + B3_SOLVER_SIMD = 256, + B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS = 512, + B3_SOLVER_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024 }; struct b3ContactSolverInfoData @@ -85,8 +85,8 @@ struct b3ContactSolverInfo : public b3ContactSolverInfoData m_splitImpulseTurnErp = 0.1f; m_linearSlop = b3Scalar(0.0); m_warmstartingFactor=b3Scalar(0.85); - //m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD | SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION|SOLVER_USE_2_FRICTION_DIRECTIONS|SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;// | SOLVER_RANDMIZE_ORDER; - m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD;// | SOLVER_RANDMIZE_ORDER; + //m_solverMode = B3_SOLVER_USE_WARMSTARTING | B3_SOLVER_SIMD | B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION|B3_SOLVER_USE_2_FRICTION_DIRECTIONS|B3_SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;// | B3_SOLVER_RANDMIZE_ORDER; + m_solverMode = B3_SOLVER_USE_WARMSTARTING | B3_SOLVER_SIMD;// | B3_SOLVER_RANDMIZE_ORDER; m_restingContactRestitutionThreshold = 2;//unused as of 2.81 m_minimumSolverBatchSize = 128; //try to combine islands until the amount of constraints reaches this limit m_maxGyroscopicForce = 100.f; ///only used to clamp forces for bodies that have their B3_ENABLE_GYROPSCOPIC_FORCE flag set (using b3RigidBody::setFlag) diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.cpp b/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.cpp index 3346522e4..e723b6f66 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.cpp +++ b/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.cpp @@ -33,8 +33,6 @@ subject to the following restrictions: //#include "../../dynamics/basic_demo/Stubs/AdlContact4.h" #include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h" -bool usePgs = true; -int gNumSplitImpulseRecoveries2 = 0; #include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h" @@ -144,8 +142,9 @@ int getNumContacts(b3Contact4* contact) return contact->getNPoints(); } -b3PgsJacobiSolver::b3PgsJacobiSolver() -:m_btSeed2(0),m_usePgs(usePgs) +b3PgsJacobiSolver::b3PgsJacobiSolver(bool usePgs) +:m_btSeed2(0),m_usePgs(usePgs), +m_numSplitImpulseRecoveries(0) { } @@ -160,12 +159,12 @@ void b3PgsJacobiSolver::solveContacts(int numBodies, b3RigidBodyCL* bodies, b3In infoGlobal.m_splitImpulse = false; infoGlobal.m_timeStep = 1.f/60.f; infoGlobal.m_numIterations = 4;//4; -// infoGlobal.m_solverMode|=SOLVER_USE_2_FRICTION_DIRECTIONS|SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS|SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION; - //infoGlobal.m_solverMode|=SOLVER_USE_2_FRICTION_DIRECTIONS|SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS; - infoGlobal.m_solverMode|=SOLVER_USE_2_FRICTION_DIRECTIONS; +// infoGlobal.m_solverMode|=B3_SOLVER_USE_2_FRICTION_DIRECTIONS|B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS|B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION; + //infoGlobal.m_solverMode|=B3_SOLVER_USE_2_FRICTION_DIRECTIONS|B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS; + infoGlobal.m_solverMode|=B3_SOLVER_USE_2_FRICTION_DIRECTIONS; - //if (infoGlobal.m_solverMode & SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS) - //if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION)) + //if (infoGlobal.m_solverMode & B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS) + //if ((infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION)) solveGroup(bodies,inertias,numBodies,contacts,numContacts,constraints,numConstraints,infoGlobal); @@ -344,7 +343,7 @@ void b3PgsJacobiSolver::resolveSplitPenetrationImpulseCacheFriendly( { if (c.m_rhsPenetration) { - gNumSplitImpulseRecoveries2++; + m_numSplitImpulseRecoveries++; b3Scalar deltaImpulse = c.m_rhsPenetration-b3Scalar(c.m_appliedPushImpulse)*c.m_cfm; const b3Scalar deltaVel1Dotn = c.m_contactNormal.dot(body1.internalGetPushVelocity()) + c.m_relpos1CrossNormal.dot(body1.internalGetTurnVelocity()); const b3Scalar deltaVel2Dotn = -c.m_contactNormal.dot(body2.internalGetPushVelocity()) + c.m_relpos2CrossNormal.dot(body2.internalGetTurnVelocity()); @@ -372,7 +371,7 @@ void b3PgsJacobiSolver::resolveSplitPenetrationImpulseCacheFriendly( if (!c.m_rhsPenetration) return; - gNumSplitImpulseRecoveries2++; + m_numSplitImpulseRecoveries++; __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedPushImpulse); __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); @@ -804,7 +803,7 @@ void b3PgsJacobiSolver::setupContactConstraint(b3RigidBodyCL* bodies, b3InertiaC ///warm starting (or zero if disabled) - if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) + if (infoGlobal.m_solverMode & B3_SOLVER_USE_WARMSTARTING) { solverConstraint.m_appliedImpulse = cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor; if (rb0) @@ -883,7 +882,7 @@ void b3PgsJacobiSolver::setFrictionConstraintImpulse( b3RigidBodyCL* bodies, b3I { b3SolverConstraint& frictionConstraint1 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex]; - if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) + if (infoGlobal.m_solverMode & B3_SOLVER_USE_WARMSTARTING) { frictionConstraint1.m_appliedImpulse = cp.m_appliedImpulseLateral1 * infoGlobal.m_warmstartingFactor; if (bodies[bodyA->m_originalBodyIndex].m_invMass) @@ -896,10 +895,10 @@ void b3PgsJacobiSolver::setFrictionConstraintImpulse( b3RigidBodyCL* bodies, b3I } } - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + if ((infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS)) { b3SolverConstraint& frictionConstraint2 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex+1]; - if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) + if (infoGlobal.m_solverMode & B3_SOLVER_USE_WARMSTARTING) { frictionConstraint2.m_appliedImpulse = cp.m_appliedImpulseLateral2 * infoGlobal.m_warmstartingFactor; if (bodies[bodyA->m_originalBodyIndex].m_invMass) @@ -1003,24 +1002,24 @@ void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, b3InertiaCL* inert ///based on the relative linear velocity. ///If the relative velocity it zero, it will automatically compute a friction direction. - ///You can also enable two friction directions, using the SOLVER_USE_2_FRICTION_DIRECTIONS. + ///You can also enable two friction directions, using the B3_SOLVER_USE_2_FRICTION_DIRECTIONS. ///In that case, the second friction direction will be orthogonal to both contact normal and first friction direction. /// - ///If you choose SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION, then the friction will be independent from the relative projected velocity. + ///If you choose B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION, then the friction will be independent from the relative projected velocity. /// ///The user can manually override the friction directions for certain contacts using a contact callback, ///and set the cp.m_lateralFrictionInitialized to true ///In that case, you can set the target relative motion in each friction direction (cp.m_contactMotion1 and cp.m_contactMotion2) ///this will give a conveyor belt effect /// - if (!(infoGlobal.m_solverMode & SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !cp.m_lateralFrictionInitialized) + if (!(infoGlobal.m_solverMode & B3_SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !cp.m_lateralFrictionInitialized) { cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel; b3Scalar lat_rel_vel = cp.m_lateralFrictionDir1.length2(); - if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON) + if (!(infoGlobal.m_solverMode & B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > B3_EPSILON) { cp.m_lateralFrictionDir1 *= 1.f/b3Sqrt(lat_rel_vel); - if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + if((infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS)) { cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); cp.m_lateralFrictionDir2.normalize();//?? @@ -1034,14 +1033,14 @@ void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, b3InertiaCL* inert { b3PlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + if ((infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS)) { addFrictionConstraint(bodies,inertias,cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); } addFrictionConstraint(bodies,inertias,cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION)) + if ((infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION)) { cp.m_lateralFrictionInitialized = true; } @@ -1051,7 +1050,7 @@ void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, b3InertiaCL* inert { addFrictionConstraint(bodies,inertias,cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation,cp.m_contactMotion1, cp.m_contactCFM1); - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + if ((infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS)) addFrictionConstraint(bodies,inertias,cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation, cp.m_contactMotion2, cp.m_contactCFM2); setFrictionConstraintImpulse( bodies,inertias,solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal); @@ -1219,8 +1218,8 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, for ( j=0;j SIMD_EPSILON); - solverConstraint.m_jacDiagABInv = fsum>SIMD_EPSILON?b3Scalar(1.)/sum : 0.f; + b3Assert(fsum > B3_EPSILON); + solverConstraint.m_jacDiagABInv = fsum>B3_EPSILON?b3Scalar(1.)/sum : 0.f; } @@ -1351,7 +1350,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, ///@todo: use stack allocator for such temporarily memory, same for solver bodies/constraints m_orderNonContactConstraintPool.resizeNoInitialize(numNonContactPool); - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + if ((infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS)) m_orderTmpConstraintPool.resizeNoInitialize(numConstraintPool*2); else m_orderTmpConstraintPool.resizeNoInitialize(numConstraintPool); @@ -1385,7 +1384,7 @@ b3Scalar b3PgsJacobiSolver::solveSingleIteration(int iteration,b3TypedConstraint int numConstraintPool = m_tmpSolverContactConstraintPool.size(); int numFrictionPool = m_tmpSolverContactFrictionConstraintPool.size(); - if (infoGlobal.m_solverMode & SOLVER_RANDMIZE_ORDER) + if (infoGlobal.m_solverMode & B3_SOLVER_RANDMIZE_ORDER) { if (1) // uncomment this for a bit less random ((iteration & 7) == 0) { @@ -1417,7 +1416,7 @@ b3Scalar b3PgsJacobiSolver::solveSingleIteration(int iteration,b3TypedConstraint } } - if (infoGlobal.m_solverMode & SOLVER_SIMD) + if (infoGlobal.m_solverMode & B3_SOLVER_SIMD) { ///solve all joint constraints, using SIMD, if available for (int j=0;jm_appliedImpulseLateral1 = %f\n", f); pt->m_appliedImpulseLateral1 = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; //printf("pt->m_appliedImpulseLateral1 = %f\n", pt->m_appliedImpulseLateral1); - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + if ((infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS)) { pt->m_appliedImpulseLateral2 = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex+1].m_appliedImpulse; } diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h b/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h index f8b6f5f97..337413856 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h @@ -41,6 +41,9 @@ protected: void averageVelocities(); int m_maxOverrideNumSolverIterations; + + int m_numSplitImpulseRecoveries; + b3Scalar getContactProcessingThreshold(b3Contact4* contact) { return 0.02f; @@ -113,7 +116,7 @@ public: B3_DECLARE_ALIGNED_ALLOCATOR(); - b3PgsJacobiSolver(); + b3PgsJacobiSolver(bool usePgs); virtual ~b3PgsJacobiSolver(); // void solveContacts(int numBodies, b3RigidBodyCL* bodies, b3InertiaCL* inertias, int numContacts, b3Contact4* contacts); diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.cpp b/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.cpp index d3758ea9e..c2dd32a75 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.cpp +++ b/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.cpp @@ -24,7 +24,7 @@ subject to the following restrictions: b3Point2PointConstraint::b3Point2PointConstraint(int rbA,int rbB, const b3Vector3& pivotInA,const b3Vector3& pivotInB) -:b3TypedConstraint(POINT2POINT_CONSTRAINT_TYPE,rbA,rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB), +:b3TypedConstraint(B3_POINT2POINT_CONSTRAINT_TYPE,rbA,rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB), m_flags(0), m_useSolveConstraintObsolete(false) { @@ -33,7 +33,7 @@ m_useSolveConstraintObsolete(false) /* b3Point2PointConstraint::b3Point2PointConstraint(int rbA,const b3Vector3& pivotInA) -:b3TypedConstraint(POINT2POINT_CONSTRAINT_TYPE,rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA)), +:b3TypedConstraint(B3_POINT2POINT_CONSTRAINT_TYPE,rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA)), m_flags(0), m_useSolveConstraintObsolete(false) { @@ -197,7 +197,7 @@ void b3Point2PointConstraint::setParam(int num, b3Scalar value, int axis) ///return the local value of parameter b3Scalar b3Point2PointConstraint::getParam(int num, int axis) const { - b3Scalar retVal(SIMD_INFINITY); + b3Scalar retVal(B3_INFINITY); if(axis != -1) { b3AssertConstrParams(0); diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h b/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h index 2c6e37ba5..6823e3628 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h @@ -51,7 +51,7 @@ enum b3Point2PointFlags }; /// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space -ATTRIBUTE_ALIGNED16(class) b3Point2PointConstraint : public b3TypedConstraint +B3_ATTRIBUTE_ALIGNED16(class) b3Point2PointConstraint : public b3TypedConstraint { #ifdef IN_PARALLELL_SOLVER public: @@ -141,14 +141,14 @@ struct b3Point2PointConstraintDoubleData }; /* -SIMD_FORCE_INLINE int b3Point2PointConstraint::calculateSerializeBufferSize() const +B3_FORCE_INLINE int b3Point2PointConstraint::calculateSerializeBufferSize() const { return sizeof(b3Point2PointConstraintData); } ///fills the dataBuffer and returns the struct name (and 0 on failure) -SIMD_FORCE_INLINE const char* b3Point2PointConstraint::serialize(void* dataBuffer, b3Serializer* serializer) const +B3_FORCE_INLINE const char* b3Point2PointConstraint::serialize(void* dataBuffer, b3Serializer* serializer) const { b3Point2PointConstraintData* p2pData = (b3Point2PointConstraintData*)dataBuffer; diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3SolverBody.h b/src/Bullet3Dynamics/ConstraintSolver/b3SolverBody.h index afd5a2b30..5ca5ed7e4 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3SolverBody.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3SolverBody.h @@ -33,17 +33,17 @@ class b3RigidBody; struct b3SimdScalar { - SIMD_FORCE_INLINE b3SimdScalar() + B3_FORCE_INLINE b3SimdScalar() { } - SIMD_FORCE_INLINE b3SimdScalar(float fl) + B3_FORCE_INLINE b3SimdScalar(float fl) :m_vec128 (_mm_set1_ps(fl)) { } - SIMD_FORCE_INLINE b3SimdScalar(__m128 v128) + B3_FORCE_INLINE b3SimdScalar(__m128 v128) :m_vec128(v128) { } @@ -54,31 +54,31 @@ struct b3SimdScalar int m_ints[4]; b3Scalar m_unusedPadding; }; - SIMD_FORCE_INLINE __m128 get128() + B3_FORCE_INLINE __m128 get128() { return m_vec128; } - SIMD_FORCE_INLINE const __m128 get128() const + B3_FORCE_INLINE const __m128 get128() const { return m_vec128; } - SIMD_FORCE_INLINE void set128(__m128 v128) + B3_FORCE_INLINE void set128(__m128 v128) { m_vec128 = v128; } - SIMD_FORCE_INLINE operator __m128() + B3_FORCE_INLINE operator __m128() { return m_vec128; } - SIMD_FORCE_INLINE operator const __m128() const + B3_FORCE_INLINE operator const __m128() const { return m_vec128; } - SIMD_FORCE_INLINE operator float() const + B3_FORCE_INLINE operator float() const { return m_floats[0]; } @@ -86,14 +86,14 @@ struct b3SimdScalar }; ///@brief Return the elementwise product of two b3SimdScalar -SIMD_FORCE_INLINE b3SimdScalar +B3_FORCE_INLINE b3SimdScalar operator*(const b3SimdScalar& v1, const b3SimdScalar& v2) { return b3SimdScalar(_mm_mul_ps(v1.get128(),v2.get128())); } ///@brief Return the elementwise product of two b3SimdScalar -SIMD_FORCE_INLINE b3SimdScalar +B3_FORCE_INLINE b3SimdScalar operator+(const b3SimdScalar& v1, const b3SimdScalar& v2) { return b3SimdScalar(_mm_add_ps(v1.get128(),v2.get128())); @@ -105,7 +105,7 @@ operator+(const b3SimdScalar& v1, const b3SimdScalar& v2) #endif ///The b3SolverBody is an internal datastructure for the constraint solver. Only necessary data is packed to increase cache coherence/performance. -ATTRIBUTE_ALIGNED64 (struct) b3SolverBody +B3_ATTRIBUTE_ALIGNED64 (struct) b3SolverBody { B3_DECLARE_ALIGNED_ALLOCATOR(); b3Transform m_worldTransform; @@ -136,7 +136,7 @@ ATTRIBUTE_ALIGNED64 (struct) b3SolverBody return m_worldTransform; } - SIMD_FORCE_INLINE void getVelocityInLocalPointObsolete(const b3Vector3& rel_pos, b3Vector3& velocity ) const + B3_FORCE_INLINE void getVelocityInLocalPointObsolete(const b3Vector3& rel_pos, b3Vector3& velocity ) const { if (m_originalBody) velocity = m_linearVelocity+m_deltaLinearVelocity + (m_angularVelocity+m_deltaAngularVelocity).cross(rel_pos); @@ -144,7 +144,7 @@ ATTRIBUTE_ALIGNED64 (struct) b3SolverBody velocity.setValue(0,0,0); } - SIMD_FORCE_INLINE void getAngularVelocity(b3Vector3& angVel) const + B3_FORCE_INLINE void getAngularVelocity(b3Vector3& angVel) const { if (m_originalBody) angVel =m_angularVelocity+m_deltaAngularVelocity; @@ -154,7 +154,7 @@ ATTRIBUTE_ALIGNED64 (struct) b3SolverBody //Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position - SIMD_FORCE_INLINE void applyImpulse(const b3Vector3& linearComponent, const b3Vector3& angularComponent,const b3Scalar impulseMagnitude) + B3_FORCE_INLINE void applyImpulse(const b3Vector3& linearComponent, const b3Vector3& angularComponent,const b3Scalar impulseMagnitude) { if (m_originalBody) { @@ -163,7 +163,7 @@ ATTRIBUTE_ALIGNED64 (struct) b3SolverBody } } - SIMD_FORCE_INLINE void internalApplyPushImpulse(const b3Vector3& linearComponent, const b3Vector3& angularComponent,b3Scalar impulseMagnitude) + B3_FORCE_INLINE void internalApplyPushImpulse(const b3Vector3& linearComponent, const b3Vector3& angularComponent,b3Scalar impulseMagnitude) { if (m_originalBody) { @@ -233,19 +233,19 @@ ATTRIBUTE_ALIGNED64 (struct) b3SolverBody return m_turnVelocity; } - SIMD_FORCE_INLINE void internalGetVelocityInLocalPointObsolete(const b3Vector3& rel_pos, b3Vector3& velocity ) const + B3_FORCE_INLINE void internalGetVelocityInLocalPointObsolete(const b3Vector3& rel_pos, b3Vector3& velocity ) const { velocity = m_linearVelocity+m_deltaLinearVelocity + (m_angularVelocity+m_deltaAngularVelocity).cross(rel_pos); } - SIMD_FORCE_INLINE void internalGetAngularVelocity(b3Vector3& angVel) const + B3_FORCE_INLINE void internalGetAngularVelocity(b3Vector3& angVel) const { angVel = m_angularVelocity+m_deltaAngularVelocity; } //Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position - SIMD_FORCE_INLINE void internalApplyImpulse(const b3Vector3& linearComponent, const b3Vector3& angularComponent,const b3Scalar impulseMagnitude) + B3_FORCE_INLINE void internalApplyImpulse(const b3Vector3& linearComponent, const b3Vector3& angularComponent,const b3Scalar impulseMagnitude) { if (m_originalBody) { diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3SolverConstraint.h b/src/Bullet3Dynamics/ConstraintSolver/b3SolverConstraint.h index cf733926c..79dbaceb9 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3SolverConstraint.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3SolverConstraint.h @@ -27,7 +27,7 @@ class b3RigidBody; ///1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and friction constraints. -ATTRIBUTE_ALIGNED16 (struct) b3SolverConstraint +B3_ATTRIBUTE_ALIGNED16 (struct) b3SolverConstraint { B3_DECLARE_ALIGNED_ALLOCATOR(); diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.cpp b/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.cpp index 570e0ead1..dad4d5f82 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.cpp +++ b/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.cpp @@ -18,7 +18,7 @@ subject to the following restrictions: //#include "Bullet3Common/b3Serializer.h" -#define DEFAULT_DEBUGDRAW_SIZE b3Scalar(0.3f) +#define B3_DEFAULT_DEBUGDRAW_SIZE b3Scalar(0.3f) @@ -26,14 +26,14 @@ b3TypedConstraint::b3TypedConstraint(b3TypedConstraintType type, int rbA,int rbB :b3TypedObject(type), m_userConstraintType(-1), m_userConstraintId(-1), -m_breakingImpulseThreshold(SIMD_INFINITY), +m_breakingImpulseThreshold(B3_INFINITY), m_isEnabled(true), m_needsFeedback(false), m_overrideNumSolverIterations(-1), m_rbA(rbA), m_rbB(rbB), m_appliedImpulse(b3Scalar(0.)), -m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE), +m_dbgDrawSize(B3_DEFAULT_DEBUGDRAW_SIZE), m_jointFeedback(0) { } diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h b/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h index 3913b4726..c4d2aa0c4 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h @@ -25,15 +25,15 @@ class b3Serializer; //Don't change any of the existing enum values, so add enum types at the end for serialization compatibility enum b3TypedConstraintType { - POINT2POINT_CONSTRAINT_TYPE=3, - HINGE_CONSTRAINT_TYPE, - CONETWIST_CONSTRAINT_TYPE, - D6_CONSTRAINT_TYPE, - SLIDER_CONSTRAINT_TYPE, - CONTACT_CONSTRAINT_TYPE, - D6_SPRING_CONSTRAINT_TYPE, - GEAR_CONSTRAINT_TYPE, - MAX_CONSTRAINT_TYPE + B3_POINT2POINT_CONSTRAINT_TYPE=3, + B3_HINGE_CONSTRAINT_TYPE, + B3_CONETWIST_CONSTRAINT_TYPE, + B3_D6_CONSTRAINT_TYPE, + B3_SLIDER_CONSTRAINT_TYPE, + B3_CONTACT_CONSTRAINT_TYPE, + B3_D6_SPRING_CONSTRAINT_TYPE, + B3_GEAR_CONSTRAINT_TYPE, + B3_MAX_CONSTRAINT_TYPE }; @@ -52,7 +52,7 @@ enum b3ConstraintParams #endif -ATTRIBUTE_ALIGNED16(struct) b3JointFeedback +B3_ATTRIBUTE_ALIGNED16(struct) b3JointFeedback { b3Vector3 m_appliedForceBodyA; b3Vector3 m_appliedTorqueBodyA; @@ -64,7 +64,7 @@ struct b3RigidBodyCL; ///TypedConstraint is the baseclass for Bullet constraints and vehicles -ATTRIBUTE_ALIGNED16(class) b3TypedConstraint : public b3TypedObject +B3_ATTRIBUTE_ALIGNED16(class) b3TypedConstraint : public b3TypedObject { int m_userConstraintType; @@ -330,9 +330,9 @@ public: }; -// returns angle in range [-SIMD_2_PI, SIMD_2_PI], closest to one of the limits -// all arguments should be normalized angles (i.e. in range [-SIMD_PI, SIMD_PI]) -SIMD_FORCE_INLINE b3Scalar b3AdjustAngleToLimits(b3Scalar angleInRadians, b3Scalar angleLowerLimitInRadians, b3Scalar angleUpperLimitInRadians) +// returns angle in range [-B3_2_PI, B3_2_PI], closest to one of the limits +// all arguments should be normalized angles (i.e. in range [-B3_PI, B3_PI]) +B3_FORCE_INLINE b3Scalar b3AdjustAngleToLimits(b3Scalar angleInRadians, b3Scalar angleLowerLimitInRadians, b3Scalar angleUpperLimitInRadians) { if(angleLowerLimitInRadians >= angleUpperLimitInRadians) { @@ -342,13 +342,13 @@ SIMD_FORCE_INLINE b3Scalar b3AdjustAngleToLimits(b3Scalar angleInRadians, b3Scal { b3Scalar diffLo = b3Fabs(b3NormalizeAngle(angleLowerLimitInRadians - angleInRadians)); b3Scalar diffHi = b3Fabs(b3NormalizeAngle(angleUpperLimitInRadians - angleInRadians)); - return (diffLo < diffHi) ? angleInRadians : (angleInRadians + SIMD_2_PI); + return (diffLo < diffHi) ? angleInRadians : (angleInRadians + B3_2_PI); } else if(angleInRadians > angleUpperLimitInRadians) { b3Scalar diffHi = b3Fabs(b3NormalizeAngle(angleInRadians - angleUpperLimitInRadians)); b3Scalar diffLo = b3Fabs(b3NormalizeAngle(angleInRadians - angleLowerLimitInRadians)); - return (diffLo < diffHi) ? (angleInRadians - SIMD_2_PI) : angleInRadians; + return (diffLo < diffHi) ? (angleInRadians - B3_2_PI) : angleInRadians; } else { @@ -379,7 +379,7 @@ struct b3TypedConstraintData }; -/*SIMD_FORCE_INLINE int b3TypedConstraint::calculateSerializeBufferSize() const +/*B3_FORCE_INLINE int b3TypedConstraint::calculateSerializeBufferSize() const { return sizeof(b3TypedConstraintData); } diff --git a/src/Bullet3Geometry/b3AabbUtil.h b/src/Bullet3Geometry/b3AabbUtil.h index 0772a54d3..3c551714b 100644 --- a/src/Bullet3Geometry/b3AabbUtil.h +++ b/src/Bullet3Geometry/b3AabbUtil.h @@ -23,7 +23,7 @@ subject to the following restrictions: -SIMD_FORCE_INLINE void AabbExpand (b3Vector3& aabbMin, +B3_FORCE_INLINE void b3AabbExpand (b3Vector3& aabbMin, b3Vector3& aabbMax, const b3Vector3& expansionMin, const b3Vector3& expansionMax) @@ -33,7 +33,7 @@ SIMD_FORCE_INLINE void AabbExpand (b3Vector3& aabbMin, } /// conservative test for overlap between two aabbs -SIMD_FORCE_INLINE bool TestPointAgainstAabb2(const b3Vector3 &aabbMin1, const b3Vector3 &aabbMax1, +B3_FORCE_INLINE bool b3TestPointAgainstAabb2(const b3Vector3 &aabbMin1, const b3Vector3 &aabbMax1, const b3Vector3 &point) { bool overlap = true; @@ -45,7 +45,7 @@ SIMD_FORCE_INLINE bool TestPointAgainstAabb2(const b3Vector3 &aabbMin1, const b3 /// conservative test for overlap between two aabbs -SIMD_FORCE_INLINE bool TestAabbAgainstAabb2(const b3Vector3 &aabbMin1, const b3Vector3 &aabbMax1, +B3_FORCE_INLINE bool b3TestAabbAgainstAabb2(const b3Vector3 &aabbMin1, const b3Vector3 &aabbMax1, const b3Vector3 &aabbMin2, const b3Vector3 &aabbMax2) { bool overlap = true; @@ -56,7 +56,7 @@ SIMD_FORCE_INLINE bool TestAabbAgainstAabb2(const b3Vector3 &aabbMin1, const b3V } /// conservative test for overlap between triangle and aabb -SIMD_FORCE_INLINE bool TestTriangleAgainstAabb2(const b3Vector3 *vertices, +B3_FORCE_INLINE bool b3TestTriangleAgainstAabb2(const b3Vector3 *vertices, const b3Vector3 &aabbMin, const b3Vector3 &aabbMax) { const b3Vector3 &p1 = vertices[0]; @@ -75,7 +75,7 @@ SIMD_FORCE_INLINE bool TestTriangleAgainstAabb2(const b3Vector3 *vertices, } -SIMD_FORCE_INLINE int b3Outcode(const b3Vector3& p,const b3Vector3& halfExtent) +B3_FORCE_INLINE int b3Outcode(const b3Vector3& p,const b3Vector3& halfExtent) { return (p.getX() < -halfExtent.getX() ? 0x01 : 0x0) | (p.getX() > halfExtent.getX() ? 0x08 : 0x0) | @@ -87,7 +87,7 @@ SIMD_FORCE_INLINE int b3Outcode(const b3Vector3& p,const b3Vector3& halfExtent) -SIMD_FORCE_INLINE bool b3RayAabb2(const b3Vector3& rayFrom, +B3_FORCE_INLINE bool b3RayAabb2(const b3Vector3& rayFrom, const b3Vector3& rayInvDirection, const unsigned int raySign[3], const b3Vector3 bounds[2], @@ -122,7 +122,7 @@ SIMD_FORCE_INLINE bool b3RayAabb2(const b3Vector3& rayFrom, return ( (tmin < lambda_max) && (tmax > lambda_min) ); } -SIMD_FORCE_INLINE bool b3RayAabb(const b3Vector3& rayFrom, +B3_FORCE_INLINE bool b3RayAabb(const b3Vector3& rayFrom, const b3Vector3& rayTo, const b3Vector3& aabbMin, const b3Vector3& aabbMax, @@ -179,7 +179,7 @@ SIMD_FORCE_INLINE bool b3RayAabb(const b3Vector3& rayFrom, -SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& halfExtents, b3Scalar margin,const b3Transform& t,b3Vector3& aabbMinOut,b3Vector3& aabbMaxOut) +B3_FORCE_INLINE void b3TransformAabb(const b3Vector3& halfExtents, b3Scalar margin,const b3Transform& t,b3Vector3& aabbMinOut,b3Vector3& aabbMaxOut) { b3Vector3 halfExtentsWithMargin = halfExtents+b3Vector3(margin,margin,margin); b3Matrix3x3 abs_b = t.getBasis().absolute(); @@ -190,7 +190,7 @@ SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& halfExtents, b3Scalar ma } -SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& localAabbMin,const b3Vector3& localAabbMax, b3Scalar margin,const b3Transform& trans,b3Vector3& aabbMinOut,b3Vector3& aabbMaxOut) +B3_FORCE_INLINE void b3TransformAabb(const b3Vector3& localAabbMin,const b3Vector3& localAabbMax, b3Scalar margin,const b3Transform& trans,b3Vector3& aabbMinOut,b3Vector3& aabbMaxOut) { b3Assert(localAabbMin.getX() <= localAabbMax.getX()); b3Assert(localAabbMin.getY() <= localAabbMax.getY()); @@ -206,10 +206,10 @@ SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& localAabbMin,const b3Vec aabbMaxOut = center+extent; } -#define USE_BANCHLESS 1 -#ifdef USE_BANCHLESS +#define B3_USE_BANCHLESS 1 +#ifdef B3_USE_BANCHLESS //This block replaces the block below and uses no branches, and replaces the 8 bit return with a 32 bit return for improved performance (~3x on XBox 360) - SIMD_FORCE_INLINE unsigned testQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) + B3_FORCE_INLINE unsigned b3TestQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) { return static_cast(b3Select((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0]) & (aabbMin1[2] <= aabbMax2[2]) & (aabbMax1[2] >= aabbMin2[2]) @@ -217,7 +217,7 @@ SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& localAabbMin,const b3Vec 1, 0)); } #else - SIMD_FORCE_INLINE bool testQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) + B3_FORCE_INLINE bool b3TestQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) { bool overlap = true; overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap; @@ -225,7 +225,7 @@ SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& localAabbMin,const b3Vec overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap; return overlap; } -#endif //USE_BANCHLESS +#endif //B3_USE_BANCHLESS #endif //B3_AABB_UTIL2 diff --git a/src/Bullet3Geometry/b3ConvexHullComputer.cpp b/src/Bullet3Geometry/b3ConvexHullComputer.cpp index 10478b6f7..32988e435 100644 --- a/src/Bullet3Geometry/b3ConvexHullComputer.cpp +++ b/src/Bullet3Geometry/b3ConvexHullComputer.cpp @@ -21,16 +21,20 @@ subject to the following restrictions: #ifdef __GNUC__ #include + typedef int32_t btInt32_t; + typedef int64_t btInt64_t; + typedef uint32_t btUint32_t; + typedef uint64_t btUint64_t; #elif defined(_MSC_VER) - typedef __int32 int32_t; - typedef __int64 int64_t; - typedef unsigned __int32 uint32_t; - typedef unsigned __int64 uint64_t; + typedef __int32 btInt32_t; + typedef __int64 btInt64_t; + typedef unsigned __int32 btUint32_t; + typedef unsigned __int64 btUint64_t; #else - typedef int int32_t; - typedef long long int int64_t; - typedef unsigned int uint32_t; - typedef unsigned long long int uint64_t; + typedef int btInt32_t; + typedef long long int btInt64_t; + typedef unsigned int btUint32_t; + typedef unsigned long long int btUint64_t; #endif @@ -56,11 +60,11 @@ class b3ConvexHullInternal class Point64 { public: - int64_t x; - int64_t y; - int64_t z; + btInt64_t x; + btInt64_t y; + btInt64_t z; - Point64(int64_t x, int64_t y, int64_t z): x(x), y(y), z(z) + Point64(btInt64_t x, btInt64_t y, btInt64_t z): x(x), y(y), z(z) { } @@ -69,7 +73,7 @@ class b3ConvexHullInternal return (x == 0) && (y == 0) && (z == 0); } - int64_t dot(const Point64& b) const + btInt64_t dot(const Point64& b) const { return x * b.x + y * b.y + z * b.z; } @@ -78,16 +82,16 @@ class b3ConvexHullInternal class Point32 { public: - int32_t x; - int32_t y; - int32_t z; + btInt32_t x; + btInt32_t y; + btInt32_t z; int index; Point32() { } - Point32(int32_t x, int32_t y, int32_t z): x(x), y(y), z(z), index(-1) + Point32(btInt32_t x, btInt32_t y, btInt32_t z): x(x), y(y), z(z), index(-1) { } @@ -116,12 +120,12 @@ class b3ConvexHullInternal return Point64(y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x); } - int64_t dot(const Point32& b) const + btInt64_t dot(const Point32& b) const { return x * b.x + y * b.y + z * b.z; } - int64_t dot(const Point64& b) const + btInt64_t dot(const Point64& b) const { return x * b.x + y * b.y + z * b.z; } @@ -140,32 +144,32 @@ class b3ConvexHullInternal class Int128 { public: - uint64_t low; - uint64_t high; + btUint64_t low; + btUint64_t high; Int128() { } - Int128(uint64_t low, uint64_t high): low(low), high(high) + Int128(btUint64_t low, btUint64_t high): low(low), high(high) { } - Int128(uint64_t low): low(low), high(0) + Int128(btUint64_t low): low(low), high(0) { } - Int128(int64_t value): low(value), high((value >= 0) ? 0 : (uint64_t) -1LL) + Int128(btInt64_t value): low(value), high((value >= 0) ? 0 : (btUint64_t) -1LL) { } - static Int128 mul(int64_t a, int64_t b); + static Int128 mul(btInt64_t a, btInt64_t b); - static Int128 mul(uint64_t a, uint64_t b); + static Int128 mul(btUint64_t a, btUint64_t b); Int128 operator-() const { - return Int128((uint64_t) -(int64_t)low, ~high + (low == 0)); + return Int128((btUint64_t) -(btInt64_t)low, ~high + (low == 0)); } Int128 operator+(const Int128& b) const @@ -179,7 +183,7 @@ class b3ConvexHullInternal : "cc" ); return result; #else - uint64_t lo = low + b.low; + btUint64_t lo = low + b.low; return Int128(lo, high + b.high + (lo < low)); #endif } @@ -208,7 +212,7 @@ class b3ConvexHullInternal : "0"(low), "1"(high), [bl] "g"(b.low), [bh] "g"(b.high) : "cc" ); #else - uint64_t lo = low + b.low; + btUint64_t lo = low + b.low; if (lo < low) { ++high; @@ -228,17 +232,17 @@ class b3ConvexHullInternal return *this; } - Int128 operator*(int64_t b) const; + Int128 operator*(btInt64_t b) const; b3Scalar toScalar() const { - return ((int64_t) high >= 0) ? b3Scalar(high) * (b3Scalar(0x100000000LL) * b3Scalar(0x100000000LL)) + b3Scalar(low) + return ((btInt64_t) high >= 0) ? b3Scalar(high) * (b3Scalar(0x100000000LL) * b3Scalar(0x100000000LL)) + b3Scalar(low) : -(-*this).toScalar(); } int getSign() const { - return ((int64_t) high < 0) ? -1 : (high || low) ? 1 : 0; + return ((btInt64_t) high < 0) ? -1 : (high || low) ? 1 : 0; } bool operator<(const Int128& b) const @@ -272,22 +276,22 @@ class b3ConvexHullInternal class Rational64 { private: - uint64_t m_numerator; - uint64_t m_denominator; + btUint64_t m_numerator; + btUint64_t m_denominator; int sign; public: - Rational64(int64_t numerator, int64_t denominator) + Rational64(btInt64_t numerator, btInt64_t denominator) { if (numerator > 0) { sign = 1; - m_numerator = (uint64_t) numerator; + m_numerator = (btUint64_t) numerator; } else if (numerator < 0) { sign = -1; - m_numerator = (uint64_t) -numerator; + m_numerator = (btUint64_t) -numerator; } else { @@ -296,12 +300,12 @@ class b3ConvexHullInternal } if (denominator > 0) { - m_denominator = (uint64_t) denominator; + m_denominator = (btUint64_t) denominator; } else if (denominator < 0) { sign = -sign; - m_denominator = (uint64_t) -denominator; + m_denominator = (btUint64_t) -denominator; } else { @@ -323,7 +327,7 @@ class b3ConvexHullInternal b3Scalar toScalar() const { - return sign * ((m_denominator == 0) ? SIMD_INFINITY : (b3Scalar) m_numerator / m_denominator); + return sign * ((m_denominator == 0) ? B3_INFINITY : (b3Scalar) m_numerator / m_denominator); } }; @@ -337,7 +341,7 @@ class b3ConvexHullInternal bool isInt64; public: - Rational128(int64_t value) + Rational128(btInt64_t value) { if (value > 0) { @@ -352,9 +356,9 @@ class b3ConvexHullInternal else { sign = 0; - this->numerator = (uint64_t) 0; + this->numerator = (btUint64_t) 0; } - this->denominator = (uint64_t) 1; + this->denominator = (btUint64_t) 1; isInt64 = true; } @@ -384,11 +388,11 @@ class b3ConvexHullInternal int compare(const Rational128& b) const; - int compare(int64_t b) const; + int compare(btInt64_t b) const; b3Scalar toScalar() const { - return sign * ((denominator.getSign() == 0) ? SIMD_INFINITY : numerator.toScalar() / denominator.toScalar()); + return sign * ((denominator.getSign() == 0) ? B3_INFINITY : numerator.toScalar() / denominator.toScalar()); } }; @@ -579,37 +583,37 @@ class b3ConvexHullInternal template class DMul { private: - static uint32_t high(uint64_t value) + static btUint32_t high(btUint64_t value) { - return (uint32_t) (value >> 32); + return (btUint32_t) (value >> 32); } - static uint32_t low(uint64_t value) + static btUint32_t low(btUint64_t value) { - return (uint32_t) value; + return (btUint32_t) value; } - static uint64_t mul(uint32_t a, uint32_t b) + static btUint64_t mul(btUint32_t a, btUint32_t b) { - return (uint64_t) a * (uint64_t) b; + return (btUint64_t) a * (btUint64_t) b; } - static void shlHalf(uint64_t& value) + static void shlHalf(btUint64_t& value) { value <<= 32; } - static uint64_t high(Int128 value) + static btUint64_t high(Int128 value) { return value.high; } - static uint64_t low(Int128 value) + static btUint64_t low(Int128 value) { return value.low; } - static Int128 mul(uint64_t a, uint64_t b) + static Int128 mul(btUint64_t a, btUint64_t b) { return Int128::mul(a, b); } @@ -835,21 +839,21 @@ class b3ConvexHullInternal }; -b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::operator*(int64_t b) const +b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::operator*(btInt64_t b) const { - bool negative = (int64_t) high < 0; + bool negative = (btInt64_t) high < 0; Int128 a = negative ? -*this : *this; if (b < 0) { negative = !negative; b = -b; } - Int128 result = mul(a.low, (uint64_t) b); - result.high += a.high * (uint64_t) b; + Int128 result = mul(a.low, (btUint64_t) b); + result.high += a.high * (btUint64_t) b; return negative ? -result : result; } -b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(int64_t a, int64_t b) +b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(btInt64_t a, btInt64_t b) { Int128 result; @@ -871,12 +875,12 @@ b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(int64_t a, int64_ negative = !negative; b = -b; } - DMul::mul((uint64_t) a, (uint64_t) b, result.low, result.high); + DMul::mul((btUint64_t) a, (btUint64_t) b, result.low, result.high); return negative ? -result : result; #endif } -b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(uint64_t a, uint64_t b) +b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(btUint64_t a, btUint64_t b) { Int128 result; @@ -887,7 +891,7 @@ b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(uint64_t a, uint6 : "cc" ); #else - DMul::mul(a, b, result.low, result.high); + DMul::mul(a, b, result.low, result.high); #endif return result; @@ -909,8 +913,8 @@ int b3ConvexHullInternal::Rational64::compare(const Rational64& b) const #ifdef USE_X86_64_ASM int result; - int64_t tmp; - int64_t dummy; + btInt64_t tmp; + btInt64_t dummy; __asm__ ("mulq %[bn]\n\t" "movq %%rax, %[tmp]\n\t" "movq %%rdx, %%rbx\n\t" @@ -949,12 +953,12 @@ int b3ConvexHullInternal::Rational128::compare(const Rational128& b) const } if (isInt64) { - return -b.compare(sign * (int64_t) numerator.low); + return -b.compare(sign * (btInt64_t) numerator.low); } Int128 nbdLow, nbdHigh, dbnLow, dbnHigh; - DMul::mul(numerator, b.denominator, nbdLow, nbdHigh); - DMul::mul(denominator, b.numerator, dbnLow, dbnHigh); + DMul::mul(numerator, b.denominator, nbdLow, nbdHigh); + DMul::mul(denominator, b.numerator, dbnLow, dbnHigh); int cmp = nbdHigh.ucmp(dbnHigh); if (cmp) @@ -964,11 +968,11 @@ int b3ConvexHullInternal::Rational128::compare(const Rational128& b) const return nbdLow.ucmp(dbnLow) * sign; } -int b3ConvexHullInternal::Rational128::compare(int64_t b) const +int b3ConvexHullInternal::Rational128::compare(btInt64_t b) const { if (isInt64) { - int64_t a = sign * (int64_t) numerator.low; + btInt64_t a = sign * (btInt64_t) numerator.low; return (a > b) ? 1 : (a < b) ? -1 : 0; } if (b > 0) @@ -1067,22 +1071,22 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul v1 = h1.maxXy; Vertex* v00 = NULL; Vertex* v10 = NULL; - int32_t sign = 1; + btInt32_t sign = 1; for (int side = 0; side <= 1; side++) { - int32_t dx = (v1->point.x - v0->point.x) * sign; + btInt32_t dx = (v1->point.x - v0->point.x) * sign; if (dx > 0) { while (true) { - int32_t dy = v1->point.y - v0->point.y; + btInt32_t dy = v1->point.y - v0->point.y; Vertex* w0 = side ? v0->next : v0->prev; if (w0 != v0) { - int32_t dx0 = (w0->point.x - v0->point.x) * sign; - int32_t dy0 = w0->point.y - v0->point.y; + btInt32_t dx0 = (w0->point.x - v0->point.x) * sign; + btInt32_t dy0 = w0->point.y - v0->point.y; if ((dy0 <= 0) && ((dx0 == 0) || ((dx0 < 0) && (dy0 * dx <= dy * dx0)))) { v0 = w0; @@ -1094,9 +1098,9 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul Vertex* w1 = side ? v1->next : v1->prev; if (w1 != v1) { - int32_t dx1 = (w1->point.x - v1->point.x) * sign; - int32_t dy1 = w1->point.y - v1->point.y; - int32_t dxn = (w1->point.x - v0->point.x) * sign; + btInt32_t dx1 = (w1->point.x - v1->point.x) * sign; + btInt32_t dy1 = w1->point.y - v1->point.y; + btInt32_t dxn = (w1->point.x - v0->point.x) * sign; if ((dxn > 0) && (dy1 < 0) && ((dx1 == 0) || ((dx1 < 0) && (dy1 * dx < dy * dx1)))) { v1 = w1; @@ -1112,13 +1116,13 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul { while (true) { - int32_t dy = v1->point.y - v0->point.y; + btInt32_t dy = v1->point.y - v0->point.y; Vertex* w1 = side ? v1->prev : v1->next; if (w1 != v1) { - int32_t dx1 = (w1->point.x - v1->point.x) * sign; - int32_t dy1 = w1->point.y - v1->point.y; + btInt32_t dx1 = (w1->point.x - v1->point.x) * sign; + btInt32_t dy1 = w1->point.y - v1->point.y; if ((dy1 >= 0) && ((dx1 == 0) || ((dx1 < 0) && (dy1 * dx <= dy * dx1)))) { v1 = w1; @@ -1130,9 +1134,9 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul Vertex* w0 = side ? v0->prev : v0->next; if (w0 != v0) { - int32_t dx0 = (w0->point.x - v0->point.x) * sign; - int32_t dy0 = w0->point.y - v0->point.y; - int32_t dxn = (v1->point.x - w0->point.x) * sign; + btInt32_t dx0 = (w0->point.x - v0->point.x) * sign; + btInt32_t dy0 = w0->point.y - v0->point.y; + btInt32_t dxn = (v1->point.x - w0->point.x) * sign; if ((dxn < 0) && (dy0 > 0) && ((dx0 == 0) || ((dx0 < 0) && (dy0 * dx < dy * dx0)))) { v0 = w0; @@ -1146,8 +1150,8 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul } else { - int32_t x = v0->point.x; - int32_t y0 = v0->point.y; + btInt32_t x = v0->point.x; + btInt32_t y0 = v0->point.y; Vertex* w0 = v0; Vertex* t; while (((t = side ? w0->next : w0->prev) != v0) && (t->point.x == x) && (t->point.y <= y0)) @@ -1157,7 +1161,7 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul } v0 = w0; - int32_t y1 = v1->point.y; + btInt32_t y1 = v1->point.y; Vertex* w1 = v1; while (((t = side ? w1->prev : w1->next) != v1) && (t->point.x == x) && (t->point.y >= y1)) { @@ -1218,8 +1222,8 @@ void b3ConvexHullInternal::computeInternal(int start, int end, IntermediateHull& Vertex* w = v + 1; if (v->point != w->point) { - int32_t dx = v->point.x - w->point.x; - int32_t dy = v->point.y - w->point.y; + btInt32_t dx = v->point.x - w->point.x; + btInt32_t dy = v->point.y - w->point.y; if ((dx == 0) && (dy == 0)) { @@ -1392,7 +1396,7 @@ b3ConvexHullInternal::Orientation b3ConvexHullInternal::getOrientation(const Edg Point64 n = t.cross(s); Point64 m = (*prev->target - *next->reverse->target).cross(*next->target - *next->reverse->target); b3Assert(!m.isZero()); - int64_t dot = n.dot(m); + btInt64_t dot = n.dot(m); b3Assert(dot != 0); return (dot > 0) ? COUNTER_CLOCKWISE : CLOCKWISE; } @@ -1468,7 +1472,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge Point32 et1 = start1 ? start1->target->point : c1->point; Point32 s = c1->point - c0->point; Point64 normal = ((start0 ? start0 : start1)->target->point - c0->point).cross(s); - int64_t dist = c0->point.dot(normal); + btInt64_t dist = c0->point.dot(normal); b3Assert(!start1 || (start1->target->point.dot(normal) == dist)); Point64 perp = s.cross(normal); b3Assert(!perp.isZero()); @@ -1477,7 +1481,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge printf(" Advancing %d %d (%p %p, %d %d)\n", c0->point.index, c1->point.index, start0, start1, start0 ? start0->target->point.index : -1, start1 ? start1->target->point.index : -1); #endif - int64_t maxDot0 = et0.dot(perp); + btInt64_t maxDot0 = et0.dot(perp); if (e0) { while (e0->target != stop0) @@ -1492,7 +1496,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge { break; } - int64_t dot = e->target->point.dot(perp); + btInt64_t dot = e->target->point.dot(perp); if (dot <= maxDot0) { break; @@ -1503,7 +1507,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge } } - int64_t maxDot1 = et1.dot(perp); + btInt64_t maxDot1 = et1.dot(perp); if (e1) { while (e1->target != stop1) @@ -1518,7 +1522,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge { break; } - int64_t dot = e->target->point.dot(perp); + btInt64_t dot = e->target->point.dot(perp); if (dot <= maxDot1) { break; @@ -1533,20 +1537,20 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge printf(" Starting at %d %d\n", et0.index, et1.index); #endif - int64_t dx = maxDot1 - maxDot0; + btInt64_t dx = maxDot1 - maxDot0; if (dx > 0) { while (true) { - int64_t dy = (et1 - et0).dot(s); + btInt64_t dy = (et1 - et0).dot(s); if (e0 && (e0->target != stop0)) { Edge* f0 = e0->next->reverse; if (f0->copy > mergeStamp) { - int64_t dx0 = (f0->target->point - et0).dot(perp); - int64_t dy0 = (f0->target->point - et0).dot(s); + btInt64_t dx0 = (f0->target->point - et0).dot(perp); + btInt64_t dy0 = (f0->target->point - et0).dot(s); if ((dx0 == 0) ? (dy0 < 0) : ((dx0 < 0) && (Rational64(dy0, dx0).compare(Rational64(dy, dx)) >= 0))) { et0 = f0->target->point; @@ -1565,9 +1569,9 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge Point32 d1 = f1->target->point - et1; if (d1.dot(normal) == 0) { - int64_t dx1 = d1.dot(perp); - int64_t dy1 = d1.dot(s); - int64_t dxn = (f1->target->point - et0).dot(perp); + btInt64_t dx1 = d1.dot(perp); + btInt64_t dy1 = d1.dot(s); + btInt64_t dxn = (f1->target->point - et0).dot(perp); if ((dxn > 0) && ((dx1 == 0) ? (dy1 < 0) : ((dx1 < 0) && (Rational64(dy1, dx1).compare(Rational64(dy, dx)) > 0)))) { e1 = f1; @@ -1590,15 +1594,15 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge { while (true) { - int64_t dy = (et1 - et0).dot(s); + btInt64_t dy = (et1 - et0).dot(s); if (e1 && (e1->target != stop1)) { Edge* f1 = e1->prev->reverse; if (f1->copy > mergeStamp) { - int64_t dx1 = (f1->target->point - et1).dot(perp); - int64_t dy1 = (f1->target->point - et1).dot(s); + btInt64_t dx1 = (f1->target->point - et1).dot(perp); + btInt64_t dy1 = (f1->target->point - et1).dot(s); if ((dx1 == 0) ? (dy1 > 0) : ((dx1 < 0) && (Rational64(dy1, dx1).compare(Rational64(dy, dx)) <= 0))) { et1 = f1->target->point; @@ -1617,9 +1621,9 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge Point32 d0 = f0->target->point - et0; if (d0.dot(normal) == 0) { - int64_t dx0 = d0.dot(perp); - int64_t dy0 = d0.dot(s); - int64_t dxn = (et1 - f0->target->point).dot(perp); + btInt64_t dx0 = d0.dot(perp); + btInt64_t dy0 = d0.dot(s); + btInt64_t dxn = (et1 - f0->target->point).dot(perp); if ((dxn < 0) && ((dx0 == 0) ? (dy0 > 0) : ((dx0 < 0) && (Rational64(dy0, dx0).compare(Rational64(dy, dx)) < 0)))) { e0 = f0; @@ -1683,7 +1687,7 @@ void b3ConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1) { do { - int64_t dot = (*e->target - *c0).dot(normal); + btInt64_t dot = (*e->target - *c0).dot(normal); b3Assert(dot <= 0); if ((dot == 0) && ((*e->target - *c0).dot(t) > 0)) { @@ -1702,7 +1706,7 @@ void b3ConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1) { do { - int64_t dot = (*e->target - *c1).dot(normal); + btInt64_t dot = (*e->target - *c1).dot(normal); b3Assert(dot <= 0); if ((dot == 0) && ((*e->target - *c1).dot(t) > 0)) { @@ -1932,7 +1936,7 @@ void b3ConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1) } -static bool pointCmp(const b3ConvexHullInternal::Point32& p, const b3ConvexHullInternal::Point32& q) +static bool b3PointCmp(const b3ConvexHullInternal::Point32& p, const b3ConvexHullInternal::Point32& q) { return (p.y < q.y) || ((p.y == q.y) && ((p.x < q.x) || ((p.x == q.x) && (p.z < q.z)))); } @@ -2006,9 +2010,9 @@ void b3ConvexHullInternal::compute(const void* coords, bool doubleCoords, int st b3Vector3 p((b3Scalar) v[0], (b3Scalar) v[1], (b3Scalar) v[2]); ptr += stride; p = (p - center) * s; - points[i].x = (int32_t) p[medAxis]; - points[i].y = (int32_t) p[maxAxis]; - points[i].z = (int32_t) p[minAxis]; + points[i].x = (btInt32_t) p[medAxis]; + points[i].y = (btInt32_t) p[maxAxis]; + points[i].z = (btInt32_t) p[minAxis]; points[i].index = i; } } @@ -2020,13 +2024,13 @@ void b3ConvexHullInternal::compute(const void* coords, bool doubleCoords, int st b3Vector3 p(v[0], v[1], v[2]); ptr += stride; p = (p - center) * s; - points[i].x = (int32_t) p[medAxis]; - points[i].y = (int32_t) p[maxAxis]; - points[i].z = (int32_t) p[minAxis]; + points[i].x = (btInt32_t) p[medAxis]; + points[i].y = (btInt32_t) p[maxAxis]; + points[i].z = (btInt32_t) p[minAxis]; points[i].index = i; } } - points.quickSort(pointCmp); + points.quickSort(b3PointCmp); vertexPool.reset(); vertexPool.setArraySize(count); @@ -2126,7 +2130,7 @@ b3Scalar b3ConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount) { if (a && b) { - int64_t vol = (v->point - ref).dot((a->point - ref).cross(b->point - ref)); + btInt64_t vol = (v->point - ref).dot((a->point - ref).cross(b->point - ref)); b3Assert(vol >= 0); Point32 c = v->point + a->point + b->point + ref; hullCenterX += vol * c.x; @@ -2166,7 +2170,7 @@ b3Scalar b3ConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount) if (clampAmount > 0) { - b3Scalar minDist = SIMD_INFINITY; + b3Scalar minDist = B3_INFINITY; for (int i = 0; i < faceCount; i++) { b3Vector3 normal = getBtNormal(faces[i]); @@ -2217,7 +2221,7 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec { origShift[2] /= scaling[2]; } - Point32 shift((int32_t) origShift[medAxis], (int32_t) origShift[maxAxis], (int32_t) origShift[minAxis]); + Point32 shift((btInt32_t) origShift[medAxis], (btInt32_t) origShift[maxAxis], (btInt32_t) origShift[minAxis]); if (shift.isZero()) { return true; @@ -2227,9 +2231,9 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec printf("\nShrinking face (%d %d %d) (%d %d %d) (%d %d %d) by (%d %d %d)\n", face->origin.x, face->origin.y, face->origin.z, face->dir0.x, face->dir0.y, face->dir0.z, face->dir1.x, face->dir1.y, face->dir1.z, shift.x, shift.y, shift.z); #endif - int64_t origDot = face->origin.dot(normal); + btInt64_t origDot = face->origin.dot(normal); Point32 shiftedOrigin = face->origin + shift; - int64_t shiftedDot = shiftedOrigin.dot(normal); + btInt64_t shiftedDot = shiftedOrigin.dot(normal); b3Assert(shiftedDot <= origDot); if (shiftedDot >= origDot) { @@ -2463,12 +2467,12 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec Point64 n0 = intersection->face->getNormal(); Point64 n1 = intersection->reverse->face->getNormal(); - int64_t m00 = face->dir0.dot(n0); - int64_t m01 = face->dir1.dot(n0); - int64_t m10 = face->dir0.dot(n1); - int64_t m11 = face->dir1.dot(n1); - int64_t r0 = (intersection->face->origin - shiftedOrigin).dot(n0); - int64_t r1 = (intersection->reverse->face->origin - shiftedOrigin).dot(n1); + btInt64_t m00 = face->dir0.dot(n0); + btInt64_t m01 = face->dir1.dot(n0); + btInt64_t m10 = face->dir0.dot(n1); + btInt64_t m11 = face->dir1.dot(n1); + btInt64_t r0 = (intersection->face->origin - shiftedOrigin).dot(n0); + btInt64_t r1 = (intersection->reverse->face->origin - shiftedOrigin).dot(n1); Int128 det = Int128::mul(m00, m11) - Int128::mul(m01, m10); b3Assert(det.getSign() != 0); Vertex* v = vertexPool.newObject(); @@ -2481,9 +2485,9 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec Int128::mul(face->dir0.z * r0, m11) - Int128::mul(face->dir0.z * r1, m01) + Int128::mul(face->dir1.z * r1, m00) - Int128::mul(face->dir1.z * r0, m10) + det * shiftedOrigin.z, det); - v->point.x = (int32_t) v->point128.xvalue(); - v->point.y = (int32_t) v->point128.yvalue(); - v->point.z = (int32_t) v->point128.zvalue(); + v->point.x = (btInt32_t) v->point128.xvalue(); + v->point.y = (btInt32_t) v->point128.yvalue(); + v->point.z = (btInt32_t) v->point128.zvalue(); intersection->target = v; v->edges = e; diff --git a/src/Bullet3Geometry/b3GrahamScan2dConvexHull.h b/src/Bullet3Geometry/b3GrahamScan2dConvexHull.h index a4d24aefc..1b933c526 100644 --- a/src/Bullet3Geometry/b3GrahamScan2dConvexHull.h +++ b/src/Bullet3Geometry/b3GrahamScan2dConvexHull.h @@ -14,16 +14,16 @@ subject to the following restrictions: */ -#ifndef GRAHAM_SCAN_2D_CONVEX_HULL_H -#define GRAHAM_SCAN_2D_CONVEX_HULL_H +#ifndef B3_GRAHAM_SCAN_2D_CONVEX_HULL_H +#define B3_GRAHAM_SCAN_2D_CONVEX_HULL_H #include "Bullet3Common/b3Vector3.h" #include "Bullet3Common/b3AlignedObjectArray.h" -struct GrahamVector3 : public b3Vector3 +struct b3GrahamVector3 : public b3Vector3 { - GrahamVector3(const b3Vector3& org, int orgIndex) + b3GrahamVector3(const b3Vector3& org, int orgIndex) :b3Vector3(org), m_orgIndex(orgIndex) { @@ -39,7 +39,7 @@ struct b3AngleCompareFunc { : m_anchor(anchor) { } - bool operator()(const GrahamVector3& a, const GrahamVector3& b) const { + bool operator()(const b3GrahamVector3& a, const b3GrahamVector3& b) const { if (a.m_angle != b.m_angle) return a.m_angle < b.m_angle; else @@ -56,7 +56,7 @@ struct b3AngleCompareFunc { } }; -inline void GrahamScanConvexHull2D(b3AlignedObjectArray& originalPoints, b3AlignedObjectArray& hull, const b3Vector3& normalAxis) +inline void b3GrahamScanConvexHull2D(b3AlignedObjectArray& originalPoints, b3AlignedObjectArray& hull, const b3Vector3& normalAxis) { b3Vector3 axis0,axis1; b3PlaneSpace1(normalAxis,axis0,axis1); @@ -114,4 +114,4 @@ inline void GrahamScanConvexHull2D(b3AlignedObjectArray& original } } -#endif //GRAHAM_SCAN_2D_CONVEX_HULL_H +#endif //B3_GRAHAM_SCAN_2D_CONVEX_HULL_H diff --git a/src/Bullet3Serialize/Bullet2FileLoader/autogenerated/bullet2.h b/src/Bullet3Serialize/Bullet2FileLoader/autogenerated/bullet2.h index e0b6a5525..6db7b4a91 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/autogenerated/bullet2.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/autogenerated/bullet2.h @@ -19,7 +19,7 @@ // Auto generated from Bullet/Extras/HeaderGenerator/bulletGenerate.py #ifndef __BULLET_H__ #define __BULLET_H__ -namespace Bullet { +namespace Bullet3SerializeBullet2 { // put an empty struct in the case typedef struct bInvalidHandle { diff --git a/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.cpp b/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.cpp index 381bf905e..6f47f3b6e 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.cpp +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.cpp @@ -14,8 +14,8 @@ subject to the following restrictions: */ #include "b3BulletFile.h" -#include "bDefines.h" -#include "bDNA.h" +#include "b3Defines.h" +#include "b3DNA.h" #if !defined( __CELLOS_LV2__) && !defined(__MWERKS__) #include @@ -26,18 +26,18 @@ subject to the following restrictions: // 32 && 64 bit versions #ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES #ifdef _WIN64 -extern char sBulletDNAstr64[]; -extern int sBulletDNAlen64; +extern char b3s_bulletDNAstr64[]; +extern int b3s_bulletDNAlen64; #else -extern char sBulletDNAstr[]; -extern int sBulletDNAlen; +extern char b3s_bulletDNAstr[]; +extern int b3s_bulletDNAlen; #endif //_WIN64 #else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES -extern char sBulletDNAstr64[]; -extern int sBulletDNAlen64; -extern char sBulletDNAstr[]; -extern int sBulletDNAlen; +extern char b3s_bulletDNAstr64[]; +extern int b3s_bulletDNAlen64; +extern char b3s_bulletDNAstr[]; +extern int b3s_bulletDNAlen; #endif //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES @@ -53,26 +53,26 @@ b3BulletFile::b3BulletFile() #ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES #ifdef _WIN64 - m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16); - memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64); - mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64); + m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen64,16); + memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64); + mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen64); #else//_WIN64 - m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16); - memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen); - mMemoryDNA->init(m_DnaCopy,sBulletDNAlen); + m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen,16); + memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen); + mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen); #endif//_WIN64 #else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { - m_DnaCopy = (char*) b3AlignedAlloc(sBulletDNAlen64,16); - memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64); - mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64); + m_DnaCopy = (char*) b3AlignedAlloc(b3s_bulletDNAlen64,16); + memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64); + mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen64); } else { - m_DnaCopy =(char*) b3AlignedAlloc(sBulletDNAlen,16); - memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen); - mMemoryDNA->init(m_DnaCopy,sBulletDNAlen); + m_DnaCopy =(char*) b3AlignedAlloc(b3s_bulletDNAlen,16); + memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen); + mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen); } #endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES } @@ -141,13 +141,13 @@ void b3BulletFile::parseData() //dataPtr += ChunkUtils::getOffset(mFlags); char *dataPtrHead = 0; - while (dataChunk.code != DNA1) + while (dataChunk.code != B3_DNA1) { if (!brokenDNA || (dataChunk.code != B3_QUANTIZED_BVH_CODE) ) { // one behind - if (dataChunk.code == SDNA) break; + if (dataChunk.code == B3_SDNA) break; //if (dataChunk.code == DNA1) break; // same as (BHEAD+DATA dependency) @@ -250,17 +250,17 @@ void b3BulletFile::writeDNA(FILE* fp) { bChunkInd dataChunk; - dataChunk.code = DNA1; + dataChunk.code = B3_DNA1; dataChunk.dna_nr = 0; dataChunk.nr = 1; #ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { #ifdef _WIN64 - dataChunk.len = sBulletDNAlen64; - dataChunk.oldPtr = sBulletDNAstr64; + dataChunk.len = b3s_bulletDNAlen64; + dataChunk.oldPtr = b3s_bulletDNAstr64; fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp); + fwrite(b3s_bulletDNAstr64, b3s_bulletDNAlen64,1,fp); #else b3Assert(0); #endif @@ -268,10 +268,10 @@ void b3BulletFile::writeDNA(FILE* fp) else { #ifndef _WIN64 - dataChunk.len = sBulletDNAlen; - dataChunk.oldPtr = sBulletDNAstr; + dataChunk.len = b3s_bulletDNAlen; + dataChunk.oldPtr = b3s_bulletDNAstr; fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - fwrite(sBulletDNAstr, sBulletDNAlen,1,fp); + fwrite(b3s_bulletDNAstr, b3s_bulletDNAlen,1,fp); #else//_WIN64 b3Assert(0); #endif//_WIN64 @@ -279,17 +279,17 @@ void b3BulletFile::writeDNA(FILE* fp) #else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { - dataChunk.len = sBulletDNAlen64; - dataChunk.oldPtr = sBulletDNAstr64; + dataChunk.len = b3s_bulletDNAlen64; + dataChunk.oldPtr = b3s_bulletDNAstr64; fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp); + fwrite(b3s_bulletDNAstr64, b3s_bulletDNAlen64,1,fp); } else { - dataChunk.len = sBulletDNAlen; - dataChunk.oldPtr = sBulletDNAstr; + dataChunk.len = b3s_bulletDNAlen; + dataChunk.oldPtr = b3s_bulletDNAstr; fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - fwrite(sBulletDNAstr, sBulletDNAlen,1,fp); + fwrite(b3s_bulletDNAstr, b3s_bulletDNAlen,1,fp); } #endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES } @@ -304,9 +304,9 @@ void b3BulletFile::parse(int verboseMode) if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16); - memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64); - parseInternal(verboseMode,(char*)sBulletDNAstr64,sBulletDNAlen64); + m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen64,16); + memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64); + parseInternal(verboseMode,(char*)b3s_bulletDNAstr64,b3s_bulletDNAlen64); #else b3Assert(0); #endif @@ -317,9 +317,9 @@ void b3BulletFile::parse(int verboseMode) if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16); - memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen); - parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen); + m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen,16); + memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen); + parseInternal(verboseMode,m_DnaCopy,b3s_bulletDNAlen); #else b3Assert(0); #endif @@ -329,17 +329,17 @@ void b3BulletFile::parse(int verboseMode) { if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16); - memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64); - parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen64); + m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen64,16); + memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64); + parseInternal(verboseMode,m_DnaCopy,b3s_bulletDNAlen64); } else { if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16); - memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen); - parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen); + m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen,16); + memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen); + parseInternal(verboseMode,m_DnaCopy,b3s_bulletDNAlen); } #endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES @@ -359,7 +359,7 @@ int b3BulletFile::write(const char* fileName, bool fixupPointers) FILE *fp = fopen(fileName, "wb"); if (fp) { - char header[SIZEOFBLENDERHEADER] ; + char header[B3_SIZEOFBLENDERHEADER] ; memcpy(header, m_headerString, 7); int endian= 1; endian= ((char*)&endian)[0]; @@ -383,7 +383,7 @@ int b3BulletFile::write(const char* fileName, bool fixupPointers) header[10] = '7'; header[11] = '5'; - fwrite(header,SIZEOFBLENDERHEADER,1,fp); + fwrite(header,B3_SIZEOFBLENDERHEADER,1,fp); writeChunks(fp, fixupPointers); diff --git a/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.h b/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.h index e128453e6..fb1b9b0dd 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.h @@ -17,9 +17,9 @@ subject to the following restrictions: #define B3_BULLET_FILE_H -#include "bFile.h" +#include "b3File.h" #include "Bullet3Common/b3AlignedObjectArray.h" -#include "bDefines.h" +#include "b3Defines.h" #include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h" diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bChunk.cpp b/src/Bullet3Serialize/Bullet2FileLoader/b3Chunk.cpp similarity index 90% rename from src/Bullet3Serialize/Bullet2FileLoader/bChunk.cpp rename to src/Bullet3Serialize/Bullet2FileLoader/b3Chunk.cpp index 564e5507e..c0e1bb708 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/bChunk.cpp +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3Chunk.cpp @@ -13,9 +13,9 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#include "bChunk.h" -#include "bDefines.h" -#include "bFile.h" +#include "b3Chunk.h" +#include "b3Defines.h" +#include "b3File.h" #if !defined( __CELLOS_LV2__) && !defined(__MWERKS__) #include @@ -29,21 +29,21 @@ using namespace bParse; // ----------------------------------------------------- // short ChunkUtils::swapShort(short sht) { - SWITCH_SHORT(sht); + B3_SWITCH_SHORT(sht); return sht; } // ----------------------------------------------------- // int ChunkUtils::swapInt(int inte) { - SWITCH_INT(inte); + B3_SWITCH_INT(inte); return inte; } // ----------------------------------------------------- // -long64 ChunkUtils::swapLong64(long64 lng) +b3Long64 ChunkUtils::swapLong64(b3Long64 lng) { - SWITCH_LONGINT(lng); + B3_SWITCH_LONGINT(lng); return lng; } diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bChunk.h b/src/Bullet3Serialize/Bullet2FileLoader/b3Chunk.h similarity index 93% rename from src/Bullet3Serialize/Bullet2FileLoader/bChunk.h rename to src/Bullet3Serialize/Bullet2FileLoader/b3Chunk.h index 77039bcf9..03ecb6b4f 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/bChunk.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3Chunk.h @@ -17,12 +17,12 @@ subject to the following restrictions: #define __BCHUNK_H__ #if defined (_WIN32) && ! defined (__MINGW32__) - #define long64 __int64 + #define b3Long64 __int64 #elif defined (__MINGW32__) #include - #define long64 int64_t + #define b3Long64 int64_t #else - #define long64 long long + #define b3Long64 long long #endif @@ -52,7 +52,7 @@ namespace bParse { int code, len; union { - long64 oldPrev; + b3Long64 oldPrev; int m_uniqueInts[2]; }; int dna_nr, nr; @@ -80,7 +80,7 @@ namespace bParse { // endian utils static short swapShort(short sht); static int swapInt(int inte); - static long64 swapLong64(long64 lng); + static b3Long64 swapLong64(b3Long64 lng); }; diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bCommon.h b/src/Bullet3Serialize/Bullet2FileLoader/b3Common.h similarity index 100% rename from src/Bullet3Serialize/Bullet2FileLoader/bCommon.h rename to src/Bullet3Serialize/Bullet2FileLoader/b3Common.h diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bDNA.cpp b/src/Bullet3Serialize/Bullet2FileLoader/b3DNA.cpp similarity index 99% rename from src/Bullet3Serialize/Bullet2FileLoader/bDNA.cpp rename to src/Bullet3Serialize/Bullet2FileLoader/b3DNA.cpp index 140283191..6b332f50c 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/bDNA.cpp +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3DNA.cpp @@ -14,8 +14,8 @@ subject to the following restrictions: */ #include -#include "bDNA.h" -#include "bChunk.h" +#include "b3DNA.h" +#include "b3Chunk.h" #include #include #include diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bDNA.h b/src/Bullet3Serialize/Bullet2FileLoader/b3DNA.h similarity index 99% rename from src/Bullet3Serialize/Bullet2FileLoader/bDNA.h rename to src/Bullet3Serialize/Bullet2FileLoader/b3DNA.h index c0d701b02..6e60087cc 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/bDNA.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3DNA.h @@ -17,7 +17,7 @@ subject to the following restrictions: #define __BDNA_H__ -#include "bCommon.h" +#include "b3Common.h" namespace bParse { diff --git a/src/Bullet3Serialize/Bullet2FileLoader/b3Defines.h b/src/Bullet3Serialize/Bullet2FileLoader/b3Defines.h new file mode 100644 index 000000000..8f28d3c44 --- /dev/null +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3Defines.h @@ -0,0 +1,136 @@ +/* Copyright (C) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com +* +* 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 __B_DEFINES_H__ +#define __B_DEFINES_H__ + + +// MISC defines, see BKE_global.h, BKE_utildefines.h +#define B3_SIZEOFBLENDERHEADER 12 + + +// ------------------------------------------------------------ +#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__) +# define B3_MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) +#else +# define B3_MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) +#endif + + +// ------------------------------------------------------------ +#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__) +# define B3_MAKE_ID2(c, d) ( (c)<<8 | (d) ) +#else +# define B3_MAKE_ID2(c, d) ( (d)<<8 | (c) ) +#endif + +// ------------------------------------------------------------ +#define B3_ID_SCE B3_MAKE_ID2('S', 'C') +#define B3_ID_LI B3_MAKE_ID2('L', 'I') +#define B3_ID_OB B3_MAKE_ID2('O', 'B') +#define B3_ID_ME B3_MAKE_ID2('M', 'E') +#define B3_ID_CU B3_MAKE_ID2('C', 'U') +#define B3_ID_MB B3_MAKE_ID2('M', 'B') +#define B3_ID_MA B3_MAKE_ID2('M', 'A') +#define B3_ID_TE B3_MAKE_ID2('T', 'E') +#define B3_ID_IM B3_MAKE_ID2('I', 'M') +#define B3_ID_IK B3_MAKE_ID2('I', 'K') +#define B3_ID_WV B3_MAKE_ID2('W', 'V') +#define B3_ID_LT B3_MAKE_ID2('L', 'T') +#define B3_ID_SE B3_MAKE_ID2('S', 'E') +#define B3_ID_LF B3_MAKE_ID2('L', 'F') +#define B3_ID_LA B3_MAKE_ID2('L', 'A') +#define B3_ID_CA B3_MAKE_ID2('C', 'A') +#define B3_ID_IP B3_MAKE_ID2('I', 'P') +#define B3_ID_KE B3_MAKE_ID2('K', 'E') +#define B3_ID_WO B3_MAKE_ID2('W', 'O') +#define B3_ID_SCR B3_MAKE_ID2('S', 'R') +#define B3_ID_VF B3_MAKE_ID2('V', 'F') +#define B3_ID_TXT B3_MAKE_ID2('T', 'X') +#define B3_ID_SO B3_MAKE_ID2('S', 'O') +#define B3_ID_SAMPLE B3_MAKE_ID2('S', 'A') +#define B3_ID_GR B3_MAKE_ID2('G', 'R') +#define B3_ID_ID B3_MAKE_ID2('I', 'D') +#define B3_ID_AR B3_MAKE_ID2('A', 'R') +#define B3_ID_AC B3_MAKE_ID2('A', 'C') +#define B3_ID_SCRIPT B3_MAKE_ID2('P', 'Y') +#define B3_ID_FLUIDSIM B3_MAKE_ID2('F', 'S') +#define B3_ID_NT B3_MAKE_ID2('N', 'T') +#define B3_ID_BR B3_MAKE_ID2('B', 'R') + + +#define B3_ID_SEQ B3_MAKE_ID2('S', 'Q') +#define B3_ID_CO B3_MAKE_ID2('C', 'O') +#define B3_ID_PO B3_MAKE_ID2('A', 'C') +#define B3_ID_NLA B3_MAKE_ID2('N', 'L') + +#define B3_ID_VS B3_MAKE_ID2('V', 'S') +#define B3_ID_VN B3_MAKE_ID2('V', 'N') + + +// ------------------------------------------------------------ +#define B3_FORM B3_MAKE_ID('F','O','R','M') +#define B3_DDG1 B3_MAKE_ID('3','D','G','1') +#define B3_DDG2 B3_MAKE_ID('3','D','G','2') +#define B3_DDG3 B3_MAKE_ID('3','D','G','3') +#define B3_DDG4 B3_MAKE_ID('3','D','G','4') +#define B3_GOUR B3_MAKE_ID('G','O','U','R') +#define B3_BLEN B3_MAKE_ID('B','L','E','N') +#define B3_DER_ B3_MAKE_ID('D','E','R','_') +#define B3_V100 B3_MAKE_ID('V','1','0','0') +#define B3_DATA B3_MAKE_ID('D','A','T','A') +#define B3_GLOB B3_MAKE_ID('G','L','O','B') +#define B3_IMAG B3_MAKE_ID('I','M','A','G') +#define B3_TEST B3_MAKE_ID('T','E','S','T') +#define B3_USER B3_MAKE_ID('U','S','E','R') + + +// ------------------------------------------------------------ +#define B3_DNA1 B3_MAKE_ID('D','N','A','1') +#define B3_REND B3_MAKE_ID('R','E','N','D') +#define B3_ENDB B3_MAKE_ID('E','N','D','B') +#define B3_NAME B3_MAKE_ID('N','A','M','E') +#define B3_SDNA B3_MAKE_ID('S','D','N','A') +#define B3_TYPE B3_MAKE_ID('T','Y','P','E') +#define B3_TLEN B3_MAKE_ID('T','L','E','N') +#define B3_STRC B3_MAKE_ID('S','T','R','C') + + +// ------------------------------------------------------------ +#define B3_SWITCH_INT(a) { \ + char s_i, *p_i; \ + p_i= (char *)&(a); \ + s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \ + s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; } + +// ------------------------------------------------------------ +#define B3_SWITCH_SHORT(a) { \ + char s_i, *p_i; \ + p_i= (char *)&(a); \ + s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; } + +// ------------------------------------------------------------ +#define B3_SWITCH_LONGINT(a) { \ + char s_i, *p_i; \ + p_i= (char *)&(a); \ + s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ + s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ + s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ + s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } + +#endif//__B_DEFINES_H__ diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bFile.cpp b/src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp similarity index 93% rename from src/Bullet3Serialize/Bullet2FileLoader/bFile.cpp rename to src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp index 89a5de49c..e21ccb661 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/bFile.cpp +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp @@ -12,19 +12,19 @@ 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 "bFile.h" -#include "bCommon.h" -#include "bChunk.h" -#include "bDNA.h" +#include "b3File.h" +#include "b3Common.h" +#include "b3Chunk.h" +#include "b3DNA.h" #include #include #include -#include "bDefines.h" +#include "b3Defines.h" #include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h" #include "Bullet3Common/b3AlignedAllocator.h" #include "Bullet3Common/b3MinMax.h" -#define SIZEOFBLENDERHEADER 12 +#define B3_SIZEOFBLENDERHEADER 12 #define MAX_ARRAY_LENGTH 512 using namespace bParse; #define MAX_STRLEN 1024 @@ -49,7 +49,6 @@ const char* getCleanName(const char* memName, char* buffer) } -int numallocs = 0; // ----------------------------------------------------- // bFile::bFile(const char *filename, const char headerString[7]) @@ -133,13 +132,13 @@ void bFile::parseHeader() return; char *blenderBuf = mFileBuffer; - char header[SIZEOFBLENDERHEADER+1] ; - memcpy(header, blenderBuf, SIZEOFBLENDERHEADER); - header[SIZEOFBLENDERHEADER]='\0'; + char header[B3_SIZEOFBLENDERHEADER+1] ; + memcpy(header, blenderBuf, B3_SIZEOFBLENDERHEADER); + header[B3_SIZEOFBLENDERHEADER]='\0'; if (strncmp(header, m_headerString, 6)!=0) { - memcpy(header, m_headerString, SIZEOFBLENDERHEADER); + memcpy(header, m_headerString, B3_SIZEOFBLENDERHEADER); return; } @@ -344,17 +343,17 @@ void bFile::swapLen(char *dataPtr) bChunkPtr4*c = (bChunkPtr4*) dataPtr; if ((c->code & 0xFFFF)==0) c->code >>=16; - SWITCH_INT(c->len); - SWITCH_INT(c->dna_nr); - SWITCH_INT(c->nr); + B3_SWITCH_INT(c->len); + B3_SWITCH_INT(c->dna_nr); + B3_SWITCH_INT(c->nr); } else { bChunkPtr8* c = (bChunkPtr8*) dataPtr; if ((c->code & 0xFFFF)==0) c->code >>=16; - SWITCH_INT(c->len); - SWITCH_INT(c->dna_nr); - SWITCH_INT(c->nr); + B3_SWITCH_INT(c->len); + B3_SWITCH_INT(c->dna_nr); + B3_SWITCH_INT(c->nr); } } else @@ -364,19 +363,19 @@ void bFile::swapLen(char *dataPtr) bChunkPtr8*c = (bChunkPtr8*) dataPtr; if ((c->code & 0xFFFF)==0) c->code >>=16; - SWITCH_INT(c->len); - SWITCH_INT(c->dna_nr); - SWITCH_INT(c->nr); + B3_SWITCH_INT(c->len); + B3_SWITCH_INT(c->dna_nr); + B3_SWITCH_INT(c->nr); } else { bChunkPtr4* c = (bChunkPtr4*) dataPtr; if ((c->code & 0xFFFF)==0) c->code >>=16; - SWITCH_INT(c->len); + B3_SWITCH_INT(c->len); - SWITCH_INT(c->dna_nr); - SWITCH_INT(c->nr); + B3_SWITCH_INT(c->dna_nr); + B3_SWITCH_INT(c->nr); } } @@ -596,7 +595,7 @@ void bFile::preSwap() while (1) { // one behind - if (dataChunk.code == SDNA || dataChunk.code==DNA1 || dataChunk.code == TYPE || dataChunk.code == TLEN || dataChunk.code==STRC) + if (dataChunk.code == B3_SDNA || dataChunk.code==B3_DNA1 || dataChunk.code == B3_TYPE || dataChunk.code == B3_TLEN || dataChunk.code==B3_STRC) { swapDNA(dataPtr); @@ -678,7 +677,7 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk) dest[i] = src[i]; if (mFlags &FD_ENDIAN_SWAP) { - SWITCH_SHORT(dest[i]); + B3_SWITCH_SHORT(dest[i]); } } addDataBlock(dataAlloc); @@ -709,7 +708,6 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk) assert((strcmp(oldType, newType)==0) && "internal error, struct mismatch!"); - numallocs++; // numBlocks * length int allocLen = (curLen); @@ -851,14 +849,14 @@ void bFile::parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bo // ----------------------------------------------------- // static void getElement(int arrayLen, const char *cur, const char *old, char *oldPtr, char *curData) { -#define getEle(value, current, type, cast, size, ptr)\ +#define b3GetEle(value, current, type, cast, size, ptr)\ if (strcmp(current, type)==0)\ {\ value = (*(cast*)ptr);\ ptr += size;\ } -#define setEle(value, current, type, cast, size, ptr)\ +#define b3SetEle(value, current, type, cast, size, ptr)\ if (strcmp(current, type)==0)\ {\ (*(cast*)ptr) = (cast)value;\ @@ -868,20 +866,20 @@ static void getElement(int arrayLen, const char *cur, const char *old, char *old for (int i=0; i>3); } @@ -965,7 +963,7 @@ void bFile::safeSwapPtr(char *dst, const char *src) newPtr->m_uniqueIds[1] = 0; } else { - *((long64*)dst)= *((int*)src); + *((b3Long64*)dst)= *((int*)src); } } else @@ -1654,9 +1652,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl if ((chunk.code & 0xFFFF)==0) chunk.code >>=16; - SWITCH_INT(chunk.len); - SWITCH_INT(chunk.dna_nr); - SWITCH_INT(chunk.nr); + B3_SWITCH_INT(chunk.len); + B3_SWITCH_INT(chunk.dna_nr); + B3_SWITCH_INT(chunk.nr); } @@ -1672,9 +1670,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl if ((c.code & 0xFFFF)==0) c.code >>=16; - SWITCH_INT(c.len); - SWITCH_INT(c.dna_nr); - SWITCH_INT(c.nr); + B3_SWITCH_INT(c.len); + B3_SWITCH_INT(c.dna_nr); + B3_SWITCH_INT(c.nr); } memcpy(dataChunk, &c, sizeof(bChunkInd)); @@ -1697,10 +1695,10 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl chunk.m_uniqueInt = head.m_uniqueInts[0]; } else { - long64 oldPtr =0; + b3Long64 oldPtr =0; memcpy(&oldPtr, &head.m_uniqueInts[0], 8); if (swap) - SWITCH_LONGINT(oldPtr); + B3_SWITCH_LONGINT(oldPtr); chunk.m_uniqueInt = (int)(oldPtr >> 3); } @@ -1713,9 +1711,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl if ((chunk.code & 0xFFFF)==0) chunk.code >>=16; - SWITCH_INT(chunk.len); - SWITCH_INT(chunk.dna_nr); - SWITCH_INT(chunk.nr); + B3_SWITCH_INT(chunk.len); + B3_SWITCH_INT(chunk.dna_nr); + B3_SWITCH_INT(chunk.nr); } memcpy(dataChunk, &chunk, sizeof(bChunkInd)); @@ -1730,9 +1728,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl if ((c.code & 0xFFFF)==0) c.code >>=16; - SWITCH_INT(c.len); - SWITCH_INT(c.dna_nr); - SWITCH_INT(c.nr); + B3_SWITCH_INT(c.len); + B3_SWITCH_INT(c.dna_nr); + B3_SWITCH_INT(c.nr); } memcpy(dataChunk, &c, sizeof(bChunkInd)); } diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bFile.h b/src/Bullet3Serialize/Bullet2FileLoader/b3File.h similarity index 99% rename from src/Bullet3Serialize/Bullet2FileLoader/bFile.h rename to src/Bullet3Serialize/Bullet2FileLoader/b3File.h index 237a98b0b..861056806 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/bFile.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3File.h @@ -16,8 +16,8 @@ subject to the following restrictions: #ifndef __BFILE_H__ #define __BFILE_H__ -#include "bCommon.h" -#include "bChunk.h" +#include "b3Common.h" +#include "b3Chunk.h" #include namespace bParse { diff --git a/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.cpp b/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.cpp index d6b2b3a5a..c6a2a832a 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.cpp +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.cpp @@ -1,4 +1,4 @@ -char sBulletDNAstr[]= { +char b3s_bulletDNAstr[]= { char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(63),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109), char(95),char(99),char(97),char(112),char(97),char(99),char(105),char(116),char(121),char(0),char(42),char(109),char(95),char(100),char(97),char(116),char(97),char(0),char(109),char(95), char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(115),char(0),char(109),char(95),char(99),char(111), @@ -451,8 +451,8 @@ char(65),char(0),char(47),char(1),char(66),char(0),char(48),char(1),char(67),cha char(70),char(0),char(52),char(1),char(73),char(0),char(53),char(1),char(74),char(0),char(54),char(1),char(4),char(0),char(55),char(1),char(4),char(0),char(21),char(1), char(4),char(0),char(56),char(1),char(4),char(0),char(57),char(1),char(4),char(0),char(58),char(1),char(4),char(0),char(59),char(1),char(4),char(0),char(60),char(1), char(4),char(0),char(61),char(1),char(71),char(0),char(62),char(1),}; -int sBulletDNAlen= sizeof(sBulletDNAstr); -char sBulletDNAstr64[]= { +int b3s_bulletDNAlen= sizeof(b3s_bulletDNAstr); +char b3s_bulletDNAstr64[]= { char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(63),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109), char(95),char(99),char(97),char(112),char(97),char(99),char(105),char(116),char(121),char(0),char(42),char(109),char(95),char(100),char(97),char(116),char(97),char(0),char(109),char(95), char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(115),char(0),char(109),char(95),char(99),char(111), @@ -905,4 +905,4 @@ char(65),char(0),char(47),char(1),char(66),char(0),char(48),char(1),char(67),cha char(70),char(0),char(52),char(1),char(73),char(0),char(53),char(1),char(74),char(0),char(54),char(1),char(4),char(0),char(55),char(1),char(4),char(0),char(21),char(1), char(4),char(0),char(56),char(1),char(4),char(0),char(57),char(1),char(4),char(0),char(58),char(1),char(4),char(0),char(59),char(1),char(4),char(0),char(60),char(1), char(4),char(0),char(61),char(1),char(71),char(0),char(62),char(1),}; -int sBulletDNAlen64= sizeof(sBulletDNAstr64); +int b3s_bulletDNAlen64= sizeof(b3s_bulletDNAstr64); diff --git a/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.h b/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.h index adfeeb2be..1c1ce4376 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.h @@ -16,7 +16,7 @@ subject to the following restrictions: #ifndef B3_SERIALIZER_H #define B3_SERIALIZER_H -#include "Bullet3Common/b3Scalar.h" // has definitions like SIMD_FORCE_INLINE +#include "Bullet3Common/b3Scalar.h" // has definitions like B3_FORCE_INLINE #include "Bullet3Common/b3StackAlloc.h" #include "Bullet3Common/b3HashMap.h" @@ -27,13 +27,12 @@ subject to the following restrictions: -///only the 32bit versions for now -extern char sBulletDNAstr[]; -extern int sBulletDNAlen; -extern char sBulletDNAstr64[]; -extern int sBulletDNAlen64; +extern char b3s_bulletDNAstr[]; +extern int b3s_bulletDNAlen; +extern char b3s_bulletDNAstr64[]; +extern int b3s_bulletDNAlen64; -SIMD_FORCE_INLINE int b3StrLen(const char* str) +B3_FORCE_INLINE int b3StrLen(const char* str) { if (!str) return(0); @@ -374,14 +373,14 @@ public: if (VOID_IS_8) { #if _WIN64 - initDNA((const char*)sBulletDNAstr64,sBulletDNAlen64); + initDNA((const char*)b3s_bulletDNAstr64,b3s_bulletDNAlen64); #else b3Assert(0); #endif } else { #ifndef _WIN64 - initDNA((const char*)sBulletDNAstr,sBulletDNAlen); + initDNA((const char*)b3s_bulletDNAstr,b3s_bulletDNAlen); #else b3Assert(0); #endif @@ -390,10 +389,10 @@ public: #else //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { - initDNA((const char*)sBulletDNAstr64,sBulletDNAlen64); + initDNA((const char*)b3s_bulletDNAstr64,b3s_bulletDNAlen64); } else { - initDNA((const char*)sBulletDNAstr,sBulletDNAlen); + initDNA((const char*)b3s_bulletDNAstr,b3s_bulletDNAlen); } #endif //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bDefines.h b/src/Bullet3Serialize/Bullet2FileLoader/bDefines.h deleted file mode 100644 index 238df7d4b..000000000 --- a/src/Bullet3Serialize/Bullet2FileLoader/bDefines.h +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright (C) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com -* -* 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 __B_DEFINES_H__ -#define __B_DEFINES_H__ - - -// MISC defines, see BKE_global.h, BKE_utildefines.h -#define SIZEOFBLENDERHEADER 12 - - -// ------------------------------------------------------------ -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__) -# define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) -#else -# define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) -#endif - - -// ------------------------------------------------------------ -#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__) -# define MAKE_ID2(c, d) ( (c)<<8 | (d) ) -# define MOST_SIG_BYTE 0 -# define BBIG_ENDIAN -#else -# define MAKE_ID2(c, d) ( (d)<<8 | (c) ) -# define MOST_SIG_BYTE 1 -# define BLITTLE_ENDIAN -#endif - -// ------------------------------------------------------------ -#define ID_SCE MAKE_ID2('S', 'C') -#define ID_LI MAKE_ID2('L', 'I') -#define ID_OB MAKE_ID2('O', 'B') -#define ID_ME MAKE_ID2('M', 'E') -#define ID_CU MAKE_ID2('C', 'U') -#define ID_MB MAKE_ID2('M', 'B') -#define ID_MA MAKE_ID2('M', 'A') -#define ID_TE MAKE_ID2('T', 'E') -#define ID_IM MAKE_ID2('I', 'M') -#define ID_IK MAKE_ID2('I', 'K') -#define ID_WV MAKE_ID2('W', 'V') -#define ID_LT MAKE_ID2('L', 'T') -#define ID_SE MAKE_ID2('S', 'E') -#define ID_LF MAKE_ID2('L', 'F') -#define ID_LA MAKE_ID2('L', 'A') -#define ID_CA MAKE_ID2('C', 'A') -#define ID_IP MAKE_ID2('I', 'P') -#define ID_KE MAKE_ID2('K', 'E') -#define ID_WO MAKE_ID2('W', 'O') -#define ID_SCR MAKE_ID2('S', 'R') -#define ID_VF MAKE_ID2('V', 'F') -#define ID_TXT MAKE_ID2('T', 'X') -#define ID_SO MAKE_ID2('S', 'O') -#define ID_SAMPLE MAKE_ID2('S', 'A') -#define ID_GR MAKE_ID2('G', 'R') -#define ID_ID MAKE_ID2('I', 'D') -#define ID_AR MAKE_ID2('A', 'R') -#define ID_AC MAKE_ID2('A', 'C') -#define ID_SCRIPT MAKE_ID2('P', 'Y') -#define ID_FLUIDSIM MAKE_ID2('F', 'S') -#define ID_NT MAKE_ID2('N', 'T') -#define ID_BR MAKE_ID2('B', 'R') - - -#define ID_SEQ MAKE_ID2('S', 'Q') -#define ID_CO MAKE_ID2('C', 'O') -#define ID_PO MAKE_ID2('A', 'C') -#define ID_NLA MAKE_ID2('N', 'L') - -#define ID_VS MAKE_ID2('V', 'S') -#define ID_VN MAKE_ID2('V', 'N') - - -// ------------------------------------------------------------ -#define FORM MAKE_ID('F','O','R','M') -#define DDG1 MAKE_ID('3','D','G','1') -#define DDG2 MAKE_ID('3','D','G','2') -#define DDG3 MAKE_ID('3','D','G','3') -#define DDG4 MAKE_ID('3','D','G','4') -#define GOUR MAKE_ID('G','O','U','R') -#define BLEN MAKE_ID('B','L','E','N') -#define DER_ MAKE_ID('D','E','R','_') -#define V100 MAKE_ID('V','1','0','0') -#define DATA MAKE_ID('D','A','T','A') -#define GLOB MAKE_ID('G','L','O','B') -#define IMAG MAKE_ID('I','M','A','G') -#define TEST MAKE_ID('T','E','S','T') -#define USER MAKE_ID('U','S','E','R') - - -// ------------------------------------------------------------ -#define DNA1 MAKE_ID('D','N','A','1') -#define REND MAKE_ID('R','E','N','D') -#define ENDB MAKE_ID('E','N','D','B') -#define NAME MAKE_ID('N','A','M','E') -#define SDNA MAKE_ID('S','D','N','A') -#define TYPE MAKE_ID('T','Y','P','E') -#define TLEN MAKE_ID('T','L','E','N') -#define STRC MAKE_ID('S','T','R','C') - - -// ------------------------------------------------------------ -#define SWITCH_INT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; } - -// ------------------------------------------------------------ -#define SWITCH_SHORT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; } - -// ------------------------------------------------------------ -#define SWITCH_LONGINT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ - s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ - s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } - -#endif//__B_DEFINES_H__ diff --git a/test/b3DynamicBvhBroadphase/main.cpp b/test/b3DynamicBvhBroadphase/main.cpp index ac4342304..b071dda1f 100644 --- a/test/b3DynamicBvhBroadphase/main.cpp +++ b/test/b3DynamicBvhBroadphase/main.cpp @@ -35,7 +35,7 @@ inline void broadphaseTest() { TEST_INIT; - b3DynamicBvhBroadphase* bp = new b3DynamicBvhBroadphase(1); + b3DynamicBvhBroadphase* bp = new b3DynamicBvhBroadphase(2); int group=1; int mask=1;