rename to b3 convention, to avoid naming conflicts when using in combination with Bullet 2.x
This commit is contained in:
@@ -471,7 +471,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
while (!window->requestedExit())
|
while (!window->requestedExit())
|
||||||
{
|
{
|
||||||
CProfileManager::Reset();
|
b3ProfileManager::Reset();
|
||||||
GLint err = glGetError();
|
GLint err = glGetError();
|
||||||
b3Assert(err==GL_NO_ERROR);
|
b3Assert(err==GL_NO_ERROR);
|
||||||
|
|
||||||
@@ -637,7 +637,7 @@ int main(int argc, char* argv[])
|
|||||||
glFinish();
|
glFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
CProfileManager::Increment_Frame_Counter();
|
b3ProfileManager::Increment_Frame_Counter();
|
||||||
|
|
||||||
static bool printStats = true;
|
static bool printStats = true;
|
||||||
|
|
||||||
@@ -650,7 +650,7 @@ int main(int argc, char* argv[])
|
|||||||
if (count<0)
|
if (count<0)
|
||||||
{
|
{
|
||||||
count = 100;
|
count = 100;
|
||||||
// CProfileManager::dumpAll();
|
// b3ProfileManager::dumpAll();
|
||||||
//printStats = false;
|
//printStats = false;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1007,7 +1007,7 @@ void GLInstancingRenderer::updateCamera()
|
|||||||
eyePos[m_forwardAxis] = -m_data->m_cameraDistance;
|
eyePos[m_forwardAxis] = -m_data->m_cameraDistance;
|
||||||
|
|
||||||
b3Vector3 forward(eyePos[0],eyePos[1],eyePos[2]);
|
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);
|
forward.setValue(1.f,0.f,0.f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,15 +152,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float dumpRecursive(CProfileIterator* profileIterator, Gwen::Controls::TreeNode* parentNode)
|
float dumpRecursive(b3ProfileIterator* profileIterator, Gwen::Controls::TreeNode* parentNode)
|
||||||
{
|
{
|
||||||
profileIterator->First();
|
profileIterator->First();
|
||||||
if (profileIterator->Is_Done())
|
if (profileIterator->Is_Done())
|
||||||
return 0.f;
|
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 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 );
|
//printf("Profiling: %s (total running time: %.3f ms) ---\n", profileIterator->Get_Current_Parent_Name(), parent_time );
|
||||||
float totalTime = 0.f;
|
float totalTime = 0.f;
|
||||||
@@ -175,7 +175,7 @@ public:
|
|||||||
numChildren++;
|
numChildren++;
|
||||||
float current_total_time = profileIterator->Get_Current_Total_Time();
|
float current_total_time = profileIterator->Get_Current_Total_Time();
|
||||||
accumulated_time += 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());
|
Gwen::String name(profileIterator->Get_Current_Name());
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -214,7 +214,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateText(CProfileIterator* profileIterator, bool idle)
|
void UpdateText(b3ProfileIterator* profileIterator, bool idle)
|
||||||
{
|
{
|
||||||
|
|
||||||
static bool update=true;
|
static bool update=true;
|
||||||
@@ -232,7 +232,7 @@ public:
|
|||||||
static double time_since_reset = 0.f;
|
static double time_since_reset = 0.f;
|
||||||
if (!idle)
|
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 );
|
//Gwen::UnicodeString txt = Gwen::Utility::Format( L"FEM Settings %i fps", test );
|
||||||
@@ -243,7 +243,7 @@ public:
|
|||||||
|
|
||||||
double totalTime = 0;
|
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();
|
profileIterator->First();
|
||||||
|
|
||||||
@@ -258,10 +258,10 @@ public:
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Gwen::UnicodeString uname = Gwen::Utility::StringToUnicode(name);
|
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 ,
|
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
|
#else
|
||||||
Gwen::UnicodeString txt = Gwen::Utility::Format( L"Profiling: %s total time: %.3f ms, unaccounted %.3f %% :: %.3f ms", name, parent_time ,
|
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
|
#endif
|
||||||
//sprintf(blockTime,"--- Profiling: %s (total running time: %.3f ms) ---", profileIterator->Get_Current_Parent_Name(), parent_time );
|
//sprintf(blockTime,"--- Profiling: %s (total running time: %.3f ms) ---", profileIterator->Get_Current_Parent_Name(), parent_time );
|
||||||
//displayProfileString(xOffset,yStart,blockTime);
|
//displayProfileString(xOffset,yStart,blockTime);
|
||||||
@@ -364,7 +364,7 @@ void resizeGUI(int width, int height)
|
|||||||
primRenderer->setScreenSize(width,height);
|
primRenderer->setScreenSize(width,height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void processProfileData(CProfileIterator* iterator, bool idle)
|
void processProfileData(b3ProfileIterator* iterator, bool idle)
|
||||||
{
|
{
|
||||||
if (profWindow)
|
if (profWindow)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ extern Gwen::Controls::Canvas* pCanvas;
|
|||||||
class GLPrimitiveRenderer;
|
class GLPrimitiveRenderer;
|
||||||
|
|
||||||
void setupGUI(int width, int height, sth_stash* font, float retinaScale,GLPrimitiveRenderer* primRender);
|
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);
|
void resizeGUI(int width, int height);
|
||||||
|
|
||||||
#endif //MY_GWEN_WINDOW_H
|
#endif //MY_GWEN_WINDOW_H
|
||||||
|
|||||||
@@ -341,13 +341,13 @@ int main(int argc, char* argv[])
|
|||||||
pCanvas->SetSize(g_OpenGLWidth,g_OpenGLHeight);
|
pCanvas->SetSize(g_OpenGLWidth,g_OpenGLHeight);
|
||||||
}
|
}
|
||||||
setupGUI(g_OpenGLWidth,g_OpenGLHeight,stash,retinaScale,primRenderer);
|
setupGUI(g_OpenGLWidth,g_OpenGLHeight,stash,retinaScale,primRenderer);
|
||||||
class CProfileIterator* m_profileIterator;
|
class b3ProfileIterator* m_profileIterator;
|
||||||
m_profileIterator = CProfileManager::Get_Iterator();
|
m_profileIterator = b3ProfileManager::Get_Iterator();
|
||||||
|
|
||||||
glClearColor(1,1,1,1);
|
glClearColor(1,1,1,1);
|
||||||
while (!window->requestedExit())
|
while (!window->requestedExit())
|
||||||
{
|
{
|
||||||
CProfileManager::Reset();
|
b3ProfileManager::Reset();
|
||||||
|
|
||||||
{
|
{
|
||||||
B3_PROFILE("loop");
|
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");
|
//B3_PROFILE("processProfileData");
|
||||||
processProfileData(m_profileIterator,false);
|
processProfileData(m_profileIterator,false);
|
||||||
}
|
}
|
||||||
//CProfileManager::dumpAll();
|
//b3ProfileManager::dumpAll();
|
||||||
//printStats = false;
|
//printStats = false;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ void createSceneProgrammatically(GLInstancingRenderer& renderer)
|
|||||||
int tetraShapeIndex = -1;
|
int tetraShapeIndex = -1;
|
||||||
|
|
||||||
float position[4]={0,0,0,0};
|
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 orn[4] = {0,0,0,1};
|
||||||
// float rotOrn[4] = {born.getX(),born.getY(),born.getZ(),born.getW()};//
|
// float rotOrn[4] = {born.getX(),born.getY(),born.getZ(),born.getW()};//
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ void GpuDemo::clientMoveAndDisplay()
|
|||||||
count++;
|
count++;
|
||||||
if (count==25)
|
if (count==25)
|
||||||
{
|
{
|
||||||
//CProfileManager::dumpAll();
|
//b3ProfileManager::dumpAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ GraphicsShape* createGraphicsShapeFromWavefrontObj(objLoader* obj)
|
|||||||
vtx.xyzw[1] = obj->vertexList[v]->e[1];
|
vtx.xyzw[1] = obj->vertexList[v]->e[1];
|
||||||
vtx.xyzw[2] = obj->vertexList[v]->e[2];
|
vtx.xyzw[2] = obj->vertexList[v]->e[2];
|
||||||
b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]);
|
b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]);
|
||||||
if (n.length2()>SIMD_EPSILON)
|
if (n.length2()>B3_EPSILON)
|
||||||
{
|
{
|
||||||
n.normalize();
|
n.normalize();
|
||||||
vtx.normal[0] = n[0];
|
vtx.normal[0] = n[0];
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ void b3GpuDynamicsWorld::exitOpenCL()
|
|||||||
int b3GpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Scalar fixedTimeStep)
|
int b3GpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Scalar fixedTimeStep)
|
||||||
{
|
{
|
||||||
#ifndef B3_NO_PROFILE
|
#ifndef B3_NO_PROFILE
|
||||||
// CProfileManager::Reset();
|
// b3ProfileManager::Reset();
|
||||||
#endif //B3_NO_PROFILE
|
#endif //B3_NO_PROFILE
|
||||||
|
|
||||||
B3_PROFILE("stepSimulation");
|
B3_PROFILE("stepSimulation");
|
||||||
@@ -86,7 +86,7 @@ int b3GpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Sc
|
|||||||
|
|
||||||
|
|
||||||
#ifndef B3_NO_PROFILE
|
#ifndef B3_NO_PROFILE
|
||||||
//CProfileManager::Increment_Frame_Counter();
|
//b3ProfileManager::Increment_Frame_Counter();
|
||||||
#endif //B3_NO_PROFILE
|
#endif //B3_NO_PROFILE
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -494,8 +494,8 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CProfileManager::Reset();
|
b3ProfileManager::Reset();
|
||||||
CProfileManager::Increment_Frame_Counter();
|
b3ProfileManager::Increment_Frame_Counter();
|
||||||
|
|
||||||
|
|
||||||
window->startRendering();
|
window->startRendering();
|
||||||
@@ -534,7 +534,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CProfileManager::dumpAll();
|
b3ProfileManager::dumpAll();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ static char* particleKernelsString =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) b3SimParams
|
B3_ATTRIBUTE_ALIGNED16(struct) b3SimParams
|
||||||
{
|
{
|
||||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
b3Vector3 m_gravity;
|
b3Vector3 m_gravity;
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ void PairBench::initPhysics(const ConstructionInfo& ci)
|
|||||||
|
|
||||||
m_instancingRenderer = ci.m_instancingRenderer;
|
m_instancingRenderer = ci.m_instancingRenderer;
|
||||||
|
|
||||||
CProfileManager::CleanupMemory();
|
b3ProfileManager::CleanupMemory();
|
||||||
int strideInBytes = 9*sizeof(float);
|
int strideInBytes = 9*sizeof(float);
|
||||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||||
int numIndices = sizeof(cube_vertices)/sizeof(int);
|
int numIndices = sizeof(cube_vertices)/sizeof(int);
|
||||||
|
|||||||
@@ -325,15 +325,15 @@ void Usage()
|
|||||||
|
|
||||||
void DumpSimulationTime(FILE* f)
|
void DumpSimulationTime(FILE* f)
|
||||||
{
|
{
|
||||||
CProfileIterator* profileIterator = CProfileManager::Get_Iterator();
|
b3ProfileIterator* profileIterator = b3ProfileManager::Get_Iterator();
|
||||||
|
|
||||||
profileIterator->First();
|
profileIterator->First();
|
||||||
if (profileIterator->Is_Done())
|
if (profileIterator->Is_Done())
|
||||||
return;
|
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 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 );
|
//fprintf(f,"%.3f,", parent_time );
|
||||||
float totalTime = 0.f;
|
float totalTime = 0.f;
|
||||||
@@ -351,7 +351,7 @@ void DumpSimulationTime(FILE* f)
|
|||||||
{
|
{
|
||||||
float current_total_time = profileIterator->Get_Current_Total_Time();
|
float current_total_time = profileIterator->Get_Current_Total_Time();
|
||||||
accumulated_time += 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();
|
const char* name = profileIterator->Get_Current_Name();
|
||||||
fprintf(f,"%s,",name);
|
fprintf(f,"%s,",name);
|
||||||
}
|
}
|
||||||
@@ -365,7 +365,7 @@ void DumpSimulationTime(FILE* f)
|
|||||||
{
|
{
|
||||||
float current_total_time = profileIterator->Get_Current_Total_Time();
|
float current_total_time = profileIterator->Get_Current_Total_Time();
|
||||||
accumulated_time += 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();
|
const char* name = profileIterator->Get_Current_Name();
|
||||||
//if (!strcmp(name,"stepSimulation"))
|
//if (!strcmp(name,"stepSimulation"))
|
||||||
{
|
{
|
||||||
@@ -378,7 +378,7 @@ void DumpSimulationTime(FILE* f)
|
|||||||
fprintf(f,"\n");
|
fprintf(f,"\n");
|
||||||
|
|
||||||
|
|
||||||
CProfileManager::Release_Iterator(profileIterator);
|
b3ProfileManager::Release_Iterator(profileIterator);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -441,7 +441,7 @@ int main(int argc, char* argv[])
|
|||||||
printf("-----------------------------------------------------\n");
|
printf("-----------------------------------------------------\n");
|
||||||
|
|
||||||
#ifndef B3_NO_PROFILE
|
#ifndef B3_NO_PROFILE
|
||||||
CProfileManager::Reset();
|
b3ProfileManager::Reset();
|
||||||
#endif //B3_NO_PROFILE
|
#endif //B3_NO_PROFILE
|
||||||
|
|
||||||
|
|
||||||
@@ -640,8 +640,8 @@ int main(int argc, char* argv[])
|
|||||||
printf("-----------------------------------------------------\n");
|
printf("-----------------------------------------------------\n");
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CProfileManager::Reset();
|
b3ProfileManager::Reset();
|
||||||
CProfileManager::Increment_Frame_Counter();
|
b3ProfileManager::Increment_Frame_Counter();
|
||||||
|
|
||||||
// render.reshape(g_OpenGLWidth,g_OpenGLHeight);
|
// render.reshape(g_OpenGLWidth,g_OpenGLHeight);
|
||||||
|
|
||||||
@@ -694,7 +694,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
|
|
||||||
if (dump_timings)
|
if (dump_timings)
|
||||||
CProfileManager::dumpAll();
|
b3ProfileManager::dumpAll();
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
@@ -715,7 +715,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
|
|
||||||
demo->exitPhysics();
|
demo->exitPhysics();
|
||||||
CProfileManager::CleanupMemory();
|
b3ProfileManager::CleanupMemory();
|
||||||
delete demo;
|
delete demo;
|
||||||
if (f)
|
if (f)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ struct GraphicsShape
|
|||||||
|
|
||||||
struct InstanceGroup
|
struct InstanceGroup
|
||||||
{
|
{
|
||||||
Bullet::b3CollisionShapeData* m_shape;
|
Bullet3SerializeBullet2::b3CollisionShapeData* m_shape;
|
||||||
int m_collisionShapeIndex;
|
int m_collisionShapeIndex;
|
||||||
|
|
||||||
b3AlignedObjectArray<bParse::bStructHandle*> m_rigidBodies;
|
b3AlignedObjectArray<bParse::bStructHandle*> m_rigidBodies;
|
||||||
@@ -198,7 +198,7 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
|
|||||||
|
|
||||||
for (i=0;i<bulletFile2->m_collisionShapes.size();i++)
|
for (i=0;i<bulletFile2->m_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)
|
if (shapeData->m_name)
|
||||||
printf("converting shape %s\n", shapeData->m_name);
|
printf("converting shape %s\n", shapeData->m_name);
|
||||||
int shapeIndex = convertCollisionShape(shapeData);
|
int shapeIndex = convertCollisionShape(shapeData);
|
||||||
@@ -216,8 +216,8 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
|
|||||||
for (i=0;i<bulletFile2->m_rigidBodies.size();i++)
|
for (i=0;i<bulletFile2->m_rigidBodies.size();i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
Bullet::b3RigidBodyFloatData* colObjData = (Bullet::b3RigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
|
Bullet3SerializeBullet2::b3RigidBodyFloatData* colObjData = (Bullet3SerializeBullet2::b3RigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
|
||||||
Bullet::b3CollisionShapeData* shapeData = (Bullet::b3CollisionShapeData*)colObjData->m_collisionObjectData.m_collisionShape;
|
Bullet3SerializeBullet2::b3CollisionShapeData* shapeData = (Bullet3SerializeBullet2::b3CollisionShapeData*)colObjData->m_collisionObjectData.m_collisionShape;
|
||||||
for (int j=0;j<m_instanceGroups.size();j++)
|
for (int j=0;j<m_instanceGroups.size();j++)
|
||||||
{
|
{
|
||||||
if (m_instanceGroups[j]->m_shape == shapeData)
|
if (m_instanceGroups[j]->m_shape == shapeData)
|
||||||
@@ -237,7 +237,7 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
|
|||||||
|
|
||||||
for (int j=0;j<m_instanceGroups[i]->m_rigidBodies.size();j++)
|
for (int j=0;j<m_instanceGroups[i]->m_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;
|
b3Matrix3x3 mat;
|
||||||
mat.deSerializeFloat((const b3Matrix3x3FloatData&)colObjData->m_collisionObjectData.m_worldTransform.m_basis);
|
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;
|
int shapeIndex = -1;
|
||||||
|
|
||||||
@@ -291,7 +291,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData*
|
|||||||
{
|
{
|
||||||
case STATIC_PLANE_PROXYTYPE:
|
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);
|
shapeIndex = createPlaneShape(planeData->m_planeNormal,planeData->m_planeConstant, planeData->m_localScaling);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData*
|
|||||||
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
||||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||||
{
|
{
|
||||||
Bullet::b3ConvexInternalShapeData* bsd = (Bullet::b3ConvexInternalShapeData*)shapeData;
|
Bullet3SerializeBullet2::b3ConvexInternalShapeData* bsd = (Bullet3SerializeBullet2::b3ConvexInternalShapeData*)shapeData;
|
||||||
|
|
||||||
switch (shapeData->m_shapeType)
|
switch (shapeData->m_shapeType)
|
||||||
{
|
{
|
||||||
@@ -319,7 +319,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData*
|
|||||||
}
|
}
|
||||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||||
{
|
{
|
||||||
Bullet::b3ConvexHullShapeData* convexData = (Bullet::b3ConvexHullShapeData*)bsd;
|
Bullet3SerializeBullet2::b3ConvexHullShapeData* convexData = (Bullet3SerializeBullet2::b3ConvexHullShapeData*)bsd;
|
||||||
int numPoints = convexData->m_numUnscaledPoints;
|
int numPoints = convexData->m_numUnscaledPoints;
|
||||||
b3Vector3 localScaling;
|
b3Vector3 localScaling;
|
||||||
localScaling.deSerializeFloat((b3Vector3FloatData&)bsd->m_localScaling);
|
localScaling.deSerializeFloat((b3Vector3FloatData&)bsd->m_localScaling);
|
||||||
@@ -441,13 +441,13 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData*
|
|||||||
|
|
||||||
case TRIANGLE_MESH_SHAPE_PROXYTYPE:
|
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);
|
printf("numparts = %d\n",trimesh->m_meshInterface.m_numMeshParts);
|
||||||
if (trimesh->m_meshInterface.m_numMeshParts)
|
if (trimesh->m_meshInterface.m_numMeshParts)
|
||||||
{
|
{
|
||||||
for (int i=0;i<trimesh->m_meshInterface.m_numMeshParts;i++)
|
for (int i=0;i<trimesh->m_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("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]);
|
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.
|
// 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] = {
|
float cubeScaling[4] = {
|
||||||
halfDimensions.m_floats[0]*localScaling.m_floats[0]+collisionMargin,
|
halfDimensions.m_floats[0]*localScaling.m_floats[0]+collisionMargin,
|
||||||
@@ -561,14 +561,14 @@ int b3BulletDataExtractor::createBoxShape( const Bullet::b3Vector3FloatData& hal
|
|||||||
return cubeCollisionShapeIndex;
|
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);
|
printf("createSphereShape with radius %f\n",radius);
|
||||||
return -1;
|
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);
|
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;
|
return -1;
|
||||||
@@ -590,7 +590,7 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromWavefrontObj(objLoa
|
|||||||
vtx.xyzw[1] = obj->vertexList[v]->e[1];
|
vtx.xyzw[1] = obj->vertexList[v]->e[1];
|
||||||
vtx.xyzw[2] = obj->vertexList[v]->e[2];
|
vtx.xyzw[2] = obj->vertexList[v]->e[2];
|
||||||
b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]);
|
b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]);
|
||||||
if (n.length2()>SIMD_EPSILON)
|
if (n.length2()>B3_EPSILON)
|
||||||
{
|
{
|
||||||
n.normalize();
|
n.normalize();
|
||||||
vtx.normal[0] = n[0];
|
vtx.normal[0] = n[0];
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ class b3BulletDataExtractor
|
|||||||
virtual void convertAllObjects(bParse::b3BulletFile* bulletFile);
|
virtual void convertAllObjects(bParse::b3BulletFile* bulletFile);
|
||||||
|
|
||||||
//return -1 for invalid
|
//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* createGraphicsShapeFromConvexHull(const b3Vector3* tmpPoints, int numPoints);
|
||||||
static GraphicsShape* createGraphicsShapeFromWavefrontObj(class objLoader* obj);
|
static GraphicsShape* createGraphicsShapeFromWavefrontObj(class objLoader* obj);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(objLoader* obj)
|
|||||||
vtx.xyzw[1] = obj->vertexList[v]->e[1];
|
vtx.xyzw[1] = obj->vertexList[v]->e[1];
|
||||||
vtx.xyzw[2] = obj->vertexList[v]->e[2];
|
vtx.xyzw[2] = obj->vertexList[v]->e[2];
|
||||||
b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]);
|
b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]);
|
||||||
if (n.length2()>SIMD_EPSILON)
|
if (n.length2()>B3_EPSILON)
|
||||||
{
|
{
|
||||||
n.normalize();
|
n.normalize();
|
||||||
vtx.normal[0] = n[0];
|
vtx.normal[0] = n[0];
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ void computeContactPlaneConvex(int pairIndex,
|
|||||||
|
|
||||||
b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
|
b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
|
||||||
b3Vector3 planeNormal(planeEq.x,planeEq.y,planeEq.z);
|
b3Vector3 planeNormal(planeEq.x,planeEq.y,planeEq.z);
|
||||||
b3Vector3 planeNormalWorld = quatRotate(ornA,planeNormal);
|
b3Vector3 planeNormalWorld = b3QuatRotate(ornA,planeNormal);
|
||||||
float planeConstant = planeEq.w;
|
float planeConstant = planeEq.w;
|
||||||
b3Transform convexWorldTransform;
|
b3Transform convexWorldTransform;
|
||||||
convexWorldTransform.setIdentity();
|
convexWorldTransform.setIdentity();
|
||||||
@@ -571,7 +571,7 @@ void computeContactPlaneCompound(int pairIndex,
|
|||||||
|
|
||||||
b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
|
b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
|
||||||
b3Vector3 planeNormal(planeEq.x,planeEq.y,planeEq.z);
|
b3Vector3 planeNormal(planeEq.x,planeEq.y,planeEq.z);
|
||||||
b3Vector3 planeNormalWorld = quatRotate(ornA,planeNormal);
|
b3Vector3 planeNormalWorld = b3QuatRotate(ornA,planeNormal);
|
||||||
float planeConstant = planeEq.w;
|
float planeConstant = planeEq.w;
|
||||||
b3Transform convexWorldTransform;
|
b3Transform convexWorldTransform;
|
||||||
convexWorldTransform.setIdentity();
|
convexWorldTransform.setIdentity();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ struct b3GpuFace
|
|||||||
int m_numIndices;
|
int m_numIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL
|
B3_ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL
|
||||||
{
|
{
|
||||||
b3Vector3 m_localCenter;
|
b3Vector3 m_localCenter;
|
||||||
b3Vector3 m_extents;
|
b3Vector3 m_extents;
|
||||||
@@ -36,7 +36,7 @@ ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL
|
|||||||
int numVerts = m_numVertices;
|
int numVerts = m_numVertices;
|
||||||
|
|
||||||
const b3Vector3 localDir = trans.getBasis().transpose()*dir;
|
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);
|
b3Scalar offset = trans.getOrigin().dot(dir);
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
|||||||
{
|
{
|
||||||
//do the merge: use Graham Scan 2d convex hull
|
//do the merge: use Graham Scan 2d convex hull
|
||||||
|
|
||||||
b3AlignedObjectArray<GrahamVector3> orgpoints;
|
b3AlignedObjectArray<b3GrahamVector3> orgpoints;
|
||||||
b3Vector3 averageFaceNormal(0,0,0);
|
b3Vector3 averageFaceNormal(0,0,0);
|
||||||
|
|
||||||
for (int i=0;i<coplanarFaceGroup.size();i++)
|
for (int i=0;i<coplanarFaceGroup.size();i++)
|
||||||
@@ -173,7 +173,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
orgpoints.push_back(GrahamVector3(pt,orgIndex));
|
orgpoints.push_back(b3GrahamVector3(pt,orgIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,10 +183,10 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
|||||||
for (int i=0;i<4;i++)
|
for (int i=0;i<4;i++)
|
||||||
combinedFace.m_plane[i] = tmpFaces[coplanarFaceGroup[0]].m_plane[i];
|
combinedFace.m_plane[i] = tmpFaces[coplanarFaceGroup[0]].m_plane[i];
|
||||||
|
|
||||||
b3AlignedObjectArray<GrahamVector3> hull;
|
b3AlignedObjectArray<b3GrahamVector3> hull;
|
||||||
|
|
||||||
averageFaceNormal.normalize();
|
averageFaceNormal.normalize();
|
||||||
GrahamScanConvexHull2D(orgpoints,hull,averageFaceNormal);
|
b3GrahamScanConvexHull2D(orgpoints,hull,averageFaceNormal);
|
||||||
|
|
||||||
for (int i=0;i<hull.size();i++)
|
for (int i=0;i<hull.size();i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ struct b3MyFace
|
|||||||
b3Scalar m_plane[4];
|
b3Scalar m_plane[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(class) b3ConvexUtility
|
B3_ATTRIBUTE_ALIGNED16(class) b3ConvexUtility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ void b3OptimizedBvh::refitPartial(b3StridingMeshInterface* meshInterface,const b
|
|||||||
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
||||||
|
|
||||||
//PCK: unsigned instead of bool
|
//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)
|
if (overlap != 0)
|
||||||
{
|
{
|
||||||
updateBvhNodes(meshInterface,subtree.m_rootNodeIndex,subtree.m_rootNodeIndex+subtree.m_subtreeSize,i);
|
updateBvhNodes(meshInterface,subtree.m_rootNodeIndex,subtree.m_rootNodeIndex+subtree.m_subtreeSize,i);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class b3StridingMeshInterface;
|
|||||||
|
|
||||||
|
|
||||||
///The b3OptimizedBvh extends the b3QuantizedBvh to create AABB tree for triangle meshes, through the b3StridingMeshInterface.
|
///The b3OptimizedBvh extends the b3QuantizedBvh to create AABB tree for triangle meshes, through the b3StridingMeshInterface.
|
||||||
ATTRIBUTE_ALIGNED16(class) b3OptimizedBvh : public b3QuantizedBvh
|
B3_ATTRIBUTE_ALIGNED16(class) b3OptimizedBvh : public b3QuantizedBvh
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ b3QuantizedBvh::b3QuantizedBvh() :
|
|||||||
//m_traversalMode(TRAVERSAL_RECURSIVE)
|
//m_traversalMode(TRAVERSAL_RECURSIVE)
|
||||||
,m_subtreeHeaderCount(0) //PCK: add this line
|
,m_subtreeHeaderCount(0) //PCK: add this line
|
||||||
{
|
{
|
||||||
m_bvhAabbMin.setValue(-SIMD_INFINITY,-SIMD_INFINITY,-SIMD_INFINITY);
|
m_bvhAabbMin.setValue(-B3_INFINITY,-B3_INFINITY,-B3_INFINITY);
|
||||||
m_bvhAabbMax.setValue(SIMD_INFINITY,SIMD_INFINITY,SIMD_INFINITY);
|
m_bvhAabbMax.setValue(B3_INFINITY,B3_INFINITY,B3_INFINITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,8 +146,8 @@ void b3QuantizedBvh::buildTree (int startIndex,int endIndex)
|
|||||||
|
|
||||||
//set the min aabb to 'inf' or a max value, and set the max aabb to a -inf/minimum value.
|
//set the min aabb to 'inf' or a max value, and set the max aabb to a -inf/minimum value.
|
||||||
//the aabb will be expanded during buildTree/mergeInternalNodeAabb with actual node values
|
//the aabb will be expanded during buildTree/mergeInternalNodeAabb with actual node values
|
||||||
setInternalNodeAabbMin(m_curNodeIndex,m_bvhAabbMax);//can't use b3Vector3(SIMD_INFINITY,SIMD_INFINITY,SIMD_INFINITY)) because of quantization
|
setInternalNodeAabbMin(m_curNodeIndex,m_bvhAabbMax);//can't use b3Vector3(B3_INFINITY,B3_INFINITY,B3_INFINITY)) because of quantization
|
||||||
setInternalNodeAabbMax(m_curNodeIndex,m_bvhAabbMin);//can't use b3Vector3(-SIMD_INFINITY,-SIMD_INFINITY,-SIMD_INFINITY)) because of quantization
|
setInternalNodeAabbMax(m_curNodeIndex,m_bvhAabbMin);//can't use b3Vector3(-B3_INFINITY,-B3_INFINITY,-B3_INFINITY)) because of quantization
|
||||||
|
|
||||||
|
|
||||||
for (i=startIndex;i<endIndex;i++)
|
for (i=startIndex;i<endIndex;i++)
|
||||||
@@ -366,7 +366,7 @@ void b3QuantizedBvh::walkStacklessTree(b3NodeOverlapCallback* nodeCallback,const
|
|||||||
b3Assert (walkIterations < m_curNodeIndex);
|
b3Assert (walkIterations < m_curNodeIndex);
|
||||||
|
|
||||||
walkIterations++;
|
walkIterations++;
|
||||||
aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg);
|
aabbOverlap = b3TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg);
|
||||||
isLeafNode = rootNode->m_escapeIndex == -1;
|
isLeafNode = rootNode->m_escapeIndex == -1;
|
||||||
|
|
||||||
//PCK: unsigned instead of bool
|
//PCK: unsigned instead of bool
|
||||||
@@ -422,7 +422,7 @@ void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const b3Quantize
|
|||||||
unsigned aabbOverlap;
|
unsigned aabbOverlap;
|
||||||
|
|
||||||
//PCK: unsigned instead of bool
|
//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();
|
isLeafNode = currentNode->isLeafNode();
|
||||||
|
|
||||||
//PCK: unsigned instead of bool
|
//PCK: unsigned instead of bool
|
||||||
@@ -496,7 +496,7 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(b3NodeOverlapCallback* nodeCall
|
|||||||
bounds[0] -= aabbMax;
|
bounds[0] -= aabbMax;
|
||||||
bounds[1] -= aabbMin;
|
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
|
//perhaps profile if it is worth doing the aabbOverlap test first
|
||||||
|
|
||||||
#ifdef RAYAABB2
|
#ifdef RAYAABB2
|
||||||
@@ -609,7 +609,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(b3NodeOverlapCallback*
|
|||||||
// only interested if this is closer than any previous hit
|
// only interested if this is closer than any previous hit
|
||||||
b3Scalar param = 1.0;
|
b3Scalar param = 1.0;
|
||||||
rayBoxOverlap = 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();
|
isLeafNode = rootNode->isLeafNode();
|
||||||
if (boxBoxOverlap)
|
if (boxBoxOverlap)
|
||||||
{
|
{
|
||||||
@@ -703,7 +703,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTree(b3NodeOverlapCallback* nodeCallb
|
|||||||
|
|
||||||
walkIterations++;
|
walkIterations++;
|
||||||
//PCK: unsigned instead of bool
|
//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();
|
isLeafNode = rootNode->isLeafNode();
|
||||||
|
|
||||||
if (isLeafNode && aabbOverlap)
|
if (isLeafNode && aabbOverlap)
|
||||||
@@ -741,7 +741,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(b3NodeOverlapCallba
|
|||||||
const b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
const b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
||||||
|
|
||||||
//PCK: unsigned instead of bool
|
//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)
|
if (overlap != 0)
|
||||||
{
|
{
|
||||||
walkStacklessQuantizedTree(nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax,
|
walkStacklessQuantizedTree(nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax,
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class b3Serializer;
|
|||||||
|
|
||||||
///b3QuantizedBvhNode is a compressed aabb node, 16 bytes.
|
///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).
|
///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();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ ATTRIBUTE_ALIGNED16 (struct) b3QuantizedBvhNode
|
|||||||
|
|
||||||
/// b3OptimizedBvhNode contains both internal and leaf node information.
|
/// b3OptimizedBvhNode contains both internal and leaf node information.
|
||||||
/// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes.
|
/// 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();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ ATTRIBUTE_ALIGNED16 (struct) b3OptimizedBvhNode
|
|||||||
|
|
||||||
|
|
||||||
///b3BvhSubtreeInfo provides info to gather a subtree of limited size
|
///b3BvhSubtreeInfo provides info to gather a subtree of limited size
|
||||||
ATTRIBUTE_ALIGNED16(class) b3BvhSubtreeInfo
|
B3_ATTRIBUTE_ALIGNED16(class) b3BvhSubtreeInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
@@ -171,7 +171,7 @@ typedef b3AlignedObjectArray<b3BvhSubtreeInfo> BvhSubtreeInfoArray;
|
|||||||
///The b3QuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
|
///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 used by the b3BvhTriangleMeshShape as midphase, and by the b3MultiSapBroadphase.
|
||||||
///It is recommended to use quantization for better performance and lower memory requirements.
|
///It is recommended to use quantization for better performance and lower memory requirements.
|
||||||
ATTRIBUTE_ALIGNED16(class) b3QuantizedBvh
|
B3_ATTRIBUTE_ALIGNED16(class) b3QuantizedBvh
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum b3TraversalMode
|
enum b3TraversalMode
|
||||||
@@ -350,7 +350,7 @@ public:
|
|||||||
void reportRayOverlappingNodex (b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const;
|
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;
|
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);
|
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);
|
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;
|
b3Vector3 vecOut;
|
||||||
vecOut.setValue(
|
vecOut.setValue(
|
||||||
@@ -448,13 +448,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE QuantizedNodeArray& getQuantizedNodeArray()
|
B3_FORCE_INLINE QuantizedNodeArray& getQuantizedNodeArray()
|
||||||
{
|
{
|
||||||
return m_quantizedContiguousNodes;
|
return m_quantizedContiguousNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE BvhSubtreeInfoArray& getSubtreeInfoArray()
|
B3_FORCE_INLINE BvhSubtreeInfoArray& getSubtreeInfoArray()
|
||||||
{
|
{
|
||||||
return m_SubtreeHeaders;
|
return m_SubtreeHeaders;
|
||||||
}
|
}
|
||||||
@@ -486,7 +486,7 @@ public:
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SIMD_FORCE_INLINE bool isQuantized()
|
B3_FORCE_INLINE bool isQuantized()
|
||||||
{
|
{
|
||||||
return m_useQuantization;
|
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);
|
return sizeof(b3QuantizedBvhData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
/// 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.
|
/// 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.
|
/// 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:
|
protected:
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ struct b3StridingMeshInterfaceData
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int b3StridingMeshInterface::calculateSerializeBufferSize() const
|
B3_FORCE_INLINE int b3StridingMeshInterface::calculateSerializeBufferSize() const
|
||||||
{
|
{
|
||||||
return sizeof(b3StridingMeshInterfaceData);
|
return sizeof(b3StridingMeshInterfaceData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
///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.
|
///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();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ typedef b3AlignedObjectArray<b3IndexedMesh> IndexedMeshArray;
|
|||||||
///Additional meshes can be added using addIndexedMesh
|
///Additional meshes can be added using addIndexedMesh
|
||||||
///No duplcate is made of the vertex/index data, it only indexes into external vertex/index arrays.
|
///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.
|
///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:
|
protected:
|
||||||
IndexedMeshArray m_indexedMeshes;
|
IndexedMeshArray m_indexedMeshes;
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
#include "b3Solver.h"
|
#include "b3Solver.h"
|
||||||
|
|
||||||
|
|
||||||
#define SOLVER_SETUP_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup.cl"
|
#define B3_SOLVER_SETUP_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup.cl"
|
||||||
#define SOLVER_SETUP2_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup2.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 B3_SOLVER_CONTACT_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveContact.cl"
|
||||||
#define SOLVER_FRICTION_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveFriction.cl"
|
#define B3_SOLVER_FRICTION_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveFriction.cl"
|
||||||
#define BATCHING_PATH "opencl/gpu_rigidbody/kernels/batchingKernels.cl"
|
#define BATCHING_PATH "opencl/gpu_rigidbody/kernels/batchingKernels.cl"
|
||||||
#define BATCHING_NEW_PATH "opencl/gpu_rigidbody/kernels/batchingKernelsNew.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);
|
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);
|
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);
|
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);
|
b3Assert(solverSetupProg);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#define B3_CONSTRAINT4_h
|
#define B3_CONSTRAINT4_h
|
||||||
#include "Bullet3Common/b3Vector3.h"
|
#include "Bullet3Common/b3Vector3.h"
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) b3GpuConstraint4
|
B3_ATTRIBUTE_ALIGNED16(struct) b3GpuConstraint4
|
||||||
{
|
{
|
||||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
//#define TEST_OTHER_GPU_SOLVER
|
//#define TEST_OTHER_GPU_SOLVER
|
||||||
|
|
||||||
bool useDbvt = false;
|
bool useDbvt = false;
|
||||||
bool useBullet2CpuSolver = true;//false;
|
bool useBullet2CpuSolver = false;//false;
|
||||||
bool dumpContactStats = false;
|
bool dumpContactStats = false;
|
||||||
|
|
||||||
#ifdef TEST_OTHER_GPU_SOLVER
|
#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_device = device;
|
||||||
m_data->m_queue = q;
|
m_data->m_queue = q;
|
||||||
|
|
||||||
m_data->m_solver = new b3PgsJacobiSolver();
|
m_data->m_solver = new b3PgsJacobiSolver(true);
|
||||||
b3Config config;
|
b3Config config;
|
||||||
m_data->m_allAabbsGPU = new b3OpenCLArray<b3SapAabb>(ctx,q,config.m_maxConvexBodies);
|
m_data->m_allAabbsGPU = new b3OpenCLArray<b3SapAabb>(ctx,q,config.m_maxConvexBodies);
|
||||||
m_data->m_overlappingPairsGPU = new b3OpenCLArray<b3BroadphasePair>(ctx,q,config.m_maxBroadphasePairs);
|
m_data->m_overlappingPairsGPU = new b3OpenCLArray<b3BroadphasePair>(ctx,q,config.m_maxBroadphasePairs);
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ subject to the following restrictions:
|
|||||||
///useNewBatchingKernel is a rewritten kernel using just a single thread of the warp, for experiments
|
///useNewBatchingKernel is a rewritten kernel using just a single thread of the warp, for experiments
|
||||||
bool useNewBatchingKernel = true;
|
bool useNewBatchingKernel = true;
|
||||||
|
|
||||||
#define SOLVER_SETUP_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup.cl"
|
#define B3_SOLVER_SETUP_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup.cl"
|
||||||
#define SOLVER_SETUP2_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solverSetup2.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 B3_SOLVER_CONTACT_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveContact.cl"
|
||||||
#define SOLVER_FRICTION_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveFriction.cl"
|
#define B3_SOLVER_FRICTION_KERNEL_PATH "opencl/gpu_rigidbody/kernels/solveFriction.cl"
|
||||||
|
|
||||||
#define BATCHING_PATH "opencl/gpu_rigidbody/kernels/batchingKernels.cl"
|
#define BATCHING_PATH "opencl/gpu_rigidbody/kernels/batchingKernels.cl"
|
||||||
#define BATCHING_NEW_PATH "opencl/gpu_rigidbody/kernels/batchingKernelsNew.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);
|
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);
|
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);
|
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);
|
b3Assert(solverSetupProg);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "Bullet3Common/b3Scalar.h"
|
#include "Bullet3Common/b3Scalar.h"
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) b3UnsignedInt4
|
B3_ATTRIBUTE_ALIGNED16(struct) b3UnsignedInt4
|
||||||
{
|
{
|
||||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
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();
|
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;
|
b3Int4 v;
|
||||||
v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w;
|
v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w;
|
||||||
return v;
|
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;
|
b3UnsignedInt4 v;
|
||||||
v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w;
|
v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class b3OpenCLArray
|
|||||||
|
|
||||||
b3OpenCLArray<T>& operator=(const b3OpenCLArray<T>& src);
|
b3OpenCLArray<T>& operator=(const b3OpenCLArray<T>& src);
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int allocSize(int size)
|
B3_FORCE_INLINE int allocSize(int size)
|
||||||
{
|
{
|
||||||
return (size ? size*2 : 1);
|
return (size ? size*2 : 1);
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
m_capacity=0;
|
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();
|
int sz = size();
|
||||||
if( sz == capacity() )
|
if( sz == capacity() )
|
||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
m_size++;
|
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<capacity());
|
b3Assert(n<capacity());
|
||||||
@@ -101,7 +101,7 @@ public:
|
|||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE T at(int n) const
|
B3_FORCE_INLINE T at(int n) const
|
||||||
{
|
{
|
||||||
b3Assert(n>=0);
|
b3Assert(n>=0);
|
||||||
b3Assert(n<size());
|
b3Assert(n<size());
|
||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void resize(int newsize, bool copyOldContents=true)
|
B3_FORCE_INLINE void resize(int newsize, bool copyOldContents=true)
|
||||||
{
|
{
|
||||||
int curSize = size();
|
int curSize = size();
|
||||||
|
|
||||||
@@ -131,17 +131,17 @@ public:
|
|||||||
m_size = newsize;
|
m_size = newsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int size() const
|
B3_FORCE_INLINE int size() const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int capacity() const
|
B3_FORCE_INLINE int capacity() const
|
||||||
{
|
{
|
||||||
return m_capacity;
|
return m_capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void reserve(int _Count, bool copyOldContents=true)
|
B3_FORCE_INLINE void reserve(int _Count, bool copyOldContents=true)
|
||||||
{ // determine new minimum length of allocated storage
|
{ // determine new minimum length of allocated storage
|
||||||
if (capacity() < _Count)
|
if (capacity() < _Count)
|
||||||
{ // not enough room, reallocate
|
{ // not enough room, reallocate
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
/*
|
||||||
|
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_BROADPHASE_CALLBACK_H
|
#ifndef B3_BROADPHASE_CALLBACK_H
|
||||||
#define B3_BROADPHASE_CALLBACK_H
|
#define B3_BROADPHASE_CALLBACK_H
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
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.
|
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.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
@@ -17,38 +17,38 @@ subject to the following restrictions:
|
|||||||
#include "b3DynamicBvh.h"
|
#include "b3DynamicBvh.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
typedef b3AlignedObjectArray<b3DbvtNode*> tNodeArray;
|
typedef b3AlignedObjectArray<b3DbvtNode*> b3NodeArray;
|
||||||
typedef b3AlignedObjectArray<const b3DbvtNode*> tConstNodeArray;
|
typedef b3AlignedObjectArray<const b3DbvtNode*> b3ConstNodeArray;
|
||||||
|
|
||||||
//
|
//
|
||||||
struct b3DbvtNodeEnumerator : b3DynamicBvh::ICollide
|
struct b3DbvtNodeEnumerator : b3DynamicBvh::ICollide
|
||||||
{
|
{
|
||||||
tConstNodeArray nodes;
|
b3ConstNodeArray nodes;
|
||||||
void Process(const b3DbvtNode* n) { nodes.push_back(n); }
|
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);
|
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)
|
const b3DbvtVolume& b)
|
||||||
{
|
{
|
||||||
#if (DBVT_MERGE_IMPL==DBVT_IMPL_SSE)
|
#if (B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE)
|
||||||
ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtAabbMm)]);
|
B3_ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtAabbMm)]);
|
||||||
b3DbvtVolume& res=*(b3DbvtVolume*)locals;
|
b3DbvtVolume& res=*(b3DbvtVolume*)locals;
|
||||||
#else
|
#else
|
||||||
b3DbvtVolume res;
|
b3DbvtVolume res;
|
||||||
#endif
|
#endif
|
||||||
Merge(a,b,res);
|
b3Merge(a,b,res);
|
||||||
return(res);
|
return(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// volume+edge lengths
|
// 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();
|
const b3Vector3 edges=a.Lengths();
|
||||||
return( edges.x*edges.y*edges.z+
|
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())
|
if(node->isinternal())
|
||||||
{
|
{
|
||||||
getmaxdepth(node->childs[0],depth+1,maxdepth);
|
b3GetMaxDepth(node->childs[0],depth+1,maxdepth);
|
||||||
getmaxdepth(node->childs[1],depth+1,maxdepth);
|
b3GetMaxDepth(node->childs[1],depth+1,maxdepth);
|
||||||
} else maxdepth=b3Max(maxdepth,depth);
|
} else maxdepth=b3Max(maxdepth,depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static DBVT_INLINE void deletenode( b3DynamicBvh* pdbvt,
|
static B3_DBVT_INLINE void b3DeleteNode( b3DynamicBvh* pdbvt,
|
||||||
b3DbvtNode* node)
|
b3DbvtNode* node)
|
||||||
{
|
{
|
||||||
b3AlignedFree(pdbvt->m_free);
|
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)
|
b3DbvtNode* node)
|
||||||
{
|
{
|
||||||
if(!node->isleaf())
|
if(!node->isleaf())
|
||||||
{
|
{
|
||||||
recursedeletenode(pdbvt,node->childs[0]);
|
b3RecurseDeleteNode(pdbvt,node->childs[0]);
|
||||||
recursedeletenode(pdbvt,node->childs[1]);
|
b3RecurseDeleteNode(pdbvt,node->childs[1]);
|
||||||
}
|
}
|
||||||
if(node==pdbvt->m_root) pdbvt->m_root=0;
|
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,
|
b3DbvtNode* parent,
|
||||||
void* data)
|
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,
|
b3DbvtNode* parent,
|
||||||
const b3DbvtVolume& volume,
|
const b3DbvtVolume& volume,
|
||||||
void* data)
|
void* data)
|
||||||
{
|
{
|
||||||
b3DbvtNode* node=createnode(pdbvt,parent,data);
|
b3DbvtNode* node=b3CreateNode(pdbvt,parent,data);
|
||||||
node->volume=volume;
|
node->volume=volume;
|
||||||
return(node);
|
return(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt,
|
static B3_DBVT_INLINE b3DbvtNode* b3CreateNode( b3DynamicBvh* pdbvt,
|
||||||
b3DbvtNode* parent,
|
b3DbvtNode* parent,
|
||||||
const b3DbvtVolume& volume0,
|
const b3DbvtVolume& volume0,
|
||||||
const b3DbvtVolume& volume1,
|
const b3DbvtVolume& volume1,
|
||||||
void* data)
|
void* data)
|
||||||
{
|
{
|
||||||
b3DbvtNode* node=createnode(pdbvt,parent,data);
|
b3DbvtNode* node=b3CreateNode(pdbvt,parent,data);
|
||||||
Merge(volume0,volume1,node->volume);
|
b3Merge(volume0,volume1,node->volume);
|
||||||
return(node);
|
return(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static void insertleaf( b3DynamicBvh* pdbvt,
|
static void b3InsertLeaf( b3DynamicBvh* pdbvt,
|
||||||
b3DbvtNode* root,
|
b3DbvtNode* root,
|
||||||
b3DbvtNode* leaf)
|
b3DbvtNode* leaf)
|
||||||
{
|
{
|
||||||
@@ -140,21 +140,21 @@ static void insertleaf( b3DynamicBvh* pdbvt,
|
|||||||
if(!root->isleaf())
|
if(!root->isleaf())
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
root=root->childs[Select( leaf->volume,
|
root=root->childs[b3Select( leaf->volume,
|
||||||
root->childs[0]->volume,
|
root->childs[0]->volume,
|
||||||
root->childs[1]->volume)];
|
root->childs[1]->volume)];
|
||||||
} while(!root->isleaf());
|
} while(!root->isleaf());
|
||||||
}
|
}
|
||||||
b3DbvtNode* prev=root->parent;
|
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)
|
if(prev)
|
||||||
{
|
{
|
||||||
prev->childs[indexof(root)] = node;
|
prev->childs[b3IndexOf(root)] = node;
|
||||||
node->childs[0] = root;root->parent=node;
|
node->childs[0] = root;root->parent=node;
|
||||||
node->childs[1] = leaf;leaf->parent=node;
|
node->childs[1] = leaf;leaf->parent=node;
|
||||||
do {
|
do {
|
||||||
if(!prev->volume.Contain(node->volume))
|
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
|
else
|
||||||
break;
|
break;
|
||||||
node=prev;
|
node=prev;
|
||||||
@@ -170,7 +170,7 @@ static void insertleaf( b3DynamicBvh* pdbvt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt,
|
static b3DbvtNode* b3RemoveLeaf( b3DynamicBvh* pdbvt,
|
||||||
b3DbvtNode* leaf)
|
b3DbvtNode* leaf)
|
||||||
{
|
{
|
||||||
if(leaf==pdbvt->m_root)
|
if(leaf==pdbvt->m_root)
|
||||||
@@ -182,17 +182,17 @@ static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt,
|
|||||||
{
|
{
|
||||||
b3DbvtNode* parent=leaf->parent;
|
b3DbvtNode* parent=leaf->parent;
|
||||||
b3DbvtNode* prev=parent->parent;
|
b3DbvtNode* prev=parent->parent;
|
||||||
b3DbvtNode* sibling=parent->childs[1-indexof(leaf)];
|
b3DbvtNode* sibling=parent->childs[1-b3IndexOf(leaf)];
|
||||||
if(prev)
|
if(prev)
|
||||||
{
|
{
|
||||||
prev->childs[indexof(parent)]=sibling;
|
prev->childs[b3IndexOf(parent)]=sibling;
|
||||||
sibling->parent=prev;
|
sibling->parent=prev;
|
||||||
deletenode(pdbvt,parent);
|
b3DeleteNode(pdbvt,parent);
|
||||||
while(prev)
|
while(prev)
|
||||||
{
|
{
|
||||||
const b3DbvtVolume pb=prev->volume;
|
const b3DbvtVolume pb=prev->volume;
|
||||||
Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
|
b3Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
|
||||||
if(NotEqual(pb,prev->volume))
|
if(b3NotEqual(pb,prev->volume))
|
||||||
{
|
{
|
||||||
prev=prev->parent;
|
prev=prev->parent;
|
||||||
} else break;
|
} else break;
|
||||||
@@ -203,23 +203,23 @@ static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt,
|
|||||||
{
|
{
|
||||||
pdbvt->m_root=sibling;
|
pdbvt->m_root=sibling;
|
||||||
sibling->parent=0;
|
sibling->parent=0;
|
||||||
deletenode(pdbvt,parent);
|
b3DeleteNode(pdbvt,parent);
|
||||||
return(pdbvt->m_root);
|
return(pdbvt->m_root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static void fetchleaves(b3DynamicBvh* pdbvt,
|
static void b3FetchLeaves(b3DynamicBvh* pdbvt,
|
||||||
b3DbvtNode* root,
|
b3DbvtNode* root,
|
||||||
tNodeArray& leaves,
|
b3NodeArray& leaves,
|
||||||
int depth=-1)
|
int depth=-1)
|
||||||
{
|
{
|
||||||
if(root->isinternal()&&depth)
|
if(root->isinternal()&&depth)
|
||||||
{
|
{
|
||||||
fetchleaves(pdbvt,root->childs[0],leaves,depth-1);
|
b3FetchLeaves(pdbvt,root->childs[0],leaves,depth-1);
|
||||||
fetchleaves(pdbvt,root->childs[1],leaves,depth-1);
|
b3FetchLeaves(pdbvt,root->childs[1],leaves,depth-1);
|
||||||
deletenode(pdbvt,root);
|
b3DeleteNode(pdbvt,root);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -228,9 +228,9 @@ static void fetchleaves(b3DynamicBvh* pdbvt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static void split( const tNodeArray& leaves,
|
static void b3Split( const b3NodeArray& leaves,
|
||||||
tNodeArray& left,
|
b3NodeArray& left,
|
||||||
tNodeArray& right,
|
b3NodeArray& right,
|
||||||
const b3Vector3& org,
|
const b3Vector3& org,
|
||||||
const b3Vector3& axis)
|
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
|
#if B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE
|
||||||
ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtVolume)]);
|
B3_ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtVolume)]);
|
||||||
b3DbvtVolume& volume=*(b3DbvtVolume*)locals;
|
b3DbvtVolume& volume=*(b3DbvtVolume*)locals;
|
||||||
volume=leaves[0]->volume;
|
volume=leaves[0]->volume;
|
||||||
#else
|
#else
|
||||||
@@ -257,24 +257,24 @@ static b3DbvtVolume bounds( const tNodeArray& leaves)
|
|||||||
#endif
|
#endif
|
||||||
for(int i=1,ni=leaves.size();i<ni;++i)
|
for(int i=1,ni=leaves.size();i<ni;++i)
|
||||||
{
|
{
|
||||||
Merge(volume,leaves[i]->volume,volume);
|
b3Merge(volume,leaves[i]->volume,volume);
|
||||||
}
|
}
|
||||||
return(volume);
|
return(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static void bottomup( b3DynamicBvh* pdbvt,
|
static void b3BottomUp( b3DynamicBvh* pdbvt,
|
||||||
tNodeArray& leaves)
|
b3NodeArray& leaves)
|
||||||
{
|
{
|
||||||
while(leaves.size()>1)
|
while(leaves.size()>1)
|
||||||
{
|
{
|
||||||
b3Scalar minsize=SIMD_INFINITY;
|
b3Scalar minsize=B3_INFINITY;
|
||||||
int minidx[2]={-1,-1};
|
int minidx[2]={-1,-1};
|
||||||
for(int i=0;i<leaves.size();++i)
|
for(int i=0;i<leaves.size();++i)
|
||||||
{
|
{
|
||||||
for(int j=i+1;j<leaves.size();++j)
|
for(int j=i+1;j<leaves.size();++j)
|
||||||
{
|
{
|
||||||
const b3Scalar sz=size(merge(leaves[i]->volume,leaves[j]->volume));
|
const b3Scalar sz=b3Size(b3Merge(leaves[i]->volume,leaves[j]->volume));
|
||||||
if(sz<minsize)
|
if(sz<minsize)
|
||||||
{
|
{
|
||||||
minsize = sz;
|
minsize = sz;
|
||||||
@@ -284,7 +284,7 @@ static void bottomup( b3DynamicBvh* pdbvt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
b3DbvtNode* n[] = {leaves[minidx[0]],leaves[minidx[1]]};
|
b3DbvtNode* n[] = {leaves[minidx[0]],leaves[minidx[1]]};
|
||||||
b3DbvtNode* p = createnode(pdbvt,0,n[0]->volume,n[1]->volume,0);
|
b3DbvtNode* p = b3CreateNode(pdbvt,0,n[0]->volume,n[1]->volume,0);
|
||||||
p->childs[0] = n[0];
|
p->childs[0] = n[0];
|
||||||
p->childs[1] = n[1];
|
p->childs[1] = n[1];
|
||||||
n[0]->parent = p;
|
n[0]->parent = p;
|
||||||
@@ -296,8 +296,8 @@ static void bottomup( b3DynamicBvh* pdbvt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static b3DbvtNode* topdown(b3DynamicBvh* pdbvt,
|
static b3DbvtNode* b3TopDown(b3DynamicBvh* pdbvt,
|
||||||
tNodeArray& leaves,
|
b3NodeArray& leaves,
|
||||||
int bu_treshold)
|
int bu_treshold)
|
||||||
{
|
{
|
||||||
static const b3Vector3 axis[]={b3Vector3(1,0,0),
|
static const b3Vector3 axis[]={b3Vector3(1,0,0),
|
||||||
@@ -307,9 +307,9 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt,
|
|||||||
{
|
{
|
||||||
if(leaves.size()>bu_treshold)
|
if(leaves.size()>bu_treshold)
|
||||||
{
|
{
|
||||||
const b3DbvtVolume vol=bounds(leaves);
|
const b3DbvtVolume vol=b3Bounds(leaves);
|
||||||
const b3Vector3 org=vol.Center();
|
const b3Vector3 org=vol.Center();
|
||||||
tNodeArray sets[2];
|
b3NodeArray sets[2];
|
||||||
int bestaxis=-1;
|
int bestaxis=-1;
|
||||||
int bestmidp=leaves.size();
|
int bestmidp=leaves.size();
|
||||||
int splitcount[3][2]={{0,0},{0,0},{0,0}};
|
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[0].reserve(splitcount[bestaxis][0]);
|
||||||
sets[1].reserve(splitcount[bestaxis][1]);
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -349,16 +349,16 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt,
|
|||||||
sets[i&1].push_back(leaves[i]);
|
sets[i&1].push_back(leaves[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b3DbvtNode* node=createnode(pdbvt,0,vol,0);
|
b3DbvtNode* node=b3CreateNode(pdbvt,0,vol,0);
|
||||||
node->childs[0]=topdown(pdbvt,sets[0],bu_treshold);
|
node->childs[0]=b3TopDown(pdbvt,sets[0],bu_treshold);
|
||||||
node->childs[1]=topdown(pdbvt,sets[1],bu_treshold);
|
node->childs[1]=b3TopDown(pdbvt,sets[1],bu_treshold);
|
||||||
node->childs[0]->parent=node;
|
node->childs[0]->parent=node;
|
||||||
node->childs[1]->parent=node;
|
node->childs[1]->parent=node;
|
||||||
return(node);
|
return(node);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bottomup(pdbvt,leaves);
|
b3BottomUp(pdbvt,leaves);
|
||||||
return(leaves[0]);
|
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;
|
b3DbvtNode* p=n->parent;
|
||||||
b3Assert(n->isinternal());
|
b3Assert(n->isinternal());
|
||||||
if(p>n)
|
if(p>n)
|
||||||
{
|
{
|
||||||
const int i=indexof(n);
|
const int i=b3IndexOf(n);
|
||||||
const int j=1-i;
|
const int j=1-i;
|
||||||
b3DbvtNode* s=p->childs[j];
|
b3DbvtNode* s=p->childs[j];
|
||||||
b3DbvtNode* q=p->parent;
|
b3DbvtNode* q=p->parent;
|
||||||
b3Assert(n==p->childs[i]);
|
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;
|
s->parent=n;
|
||||||
p->parent=n;
|
p->parent=n;
|
||||||
n->parent=q;
|
n->parent=q;
|
||||||
@@ -394,7 +394,7 @@ static DBVT_INLINE b3DbvtNode* sort(b3DbvtNode* n,b3DbvtNode*& r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#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;
|
while(n&&(count--)) n=n->parent;
|
||||||
return(n);
|
return(n);
|
||||||
@@ -425,7 +425,7 @@ b3DynamicBvh::~b3DynamicBvh()
|
|||||||
void b3DynamicBvh::clear()
|
void b3DynamicBvh::clear()
|
||||||
{
|
{
|
||||||
if(m_root)
|
if(m_root)
|
||||||
recursedeletenode(this,m_root);
|
b3RecurseDeleteNode(this,m_root);
|
||||||
b3AlignedFree(m_free);
|
b3AlignedFree(m_free);
|
||||||
m_free=0;
|
m_free=0;
|
||||||
m_lkhd = -1;
|
m_lkhd = -1;
|
||||||
@@ -439,10 +439,10 @@ void b3DynamicBvh::optimizeBottomUp()
|
|||||||
{
|
{
|
||||||
if(m_root)
|
if(m_root)
|
||||||
{
|
{
|
||||||
tNodeArray leaves;
|
b3NodeArray leaves;
|
||||||
leaves.reserve(m_leaves);
|
leaves.reserve(m_leaves);
|
||||||
fetchleaves(this,m_root,leaves);
|
b3FetchLeaves(this,m_root,leaves);
|
||||||
bottomup(this,leaves);
|
b3BottomUp(this,leaves);
|
||||||
m_root=leaves[0];
|
m_root=leaves[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -452,10 +452,10 @@ void b3DynamicBvh::optimizeTopDown(int bu_treshold)
|
|||||||
{
|
{
|
||||||
if(m_root)
|
if(m_root)
|
||||||
{
|
{
|
||||||
tNodeArray leaves;
|
b3NodeArray leaves;
|
||||||
leaves.reserve(m_leaves);
|
leaves.reserve(m_leaves);
|
||||||
fetchleaves(this,m_root,leaves);
|
b3FetchLeaves(this,m_root,leaves);
|
||||||
m_root=topdown(this,leaves,bu_treshold);
|
m_root=b3TopDown(this,leaves,bu_treshold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ void b3DynamicBvh::optimizeIncremental(int passes)
|
|||||||
unsigned bit=0;
|
unsigned bit=0;
|
||||||
while(node->isinternal())
|
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);
|
bit=(bit+1)&(sizeof(unsigned)*8-1);
|
||||||
}
|
}
|
||||||
update(node);
|
update(node);
|
||||||
@@ -482,8 +482,8 @@ void b3DynamicBvh::optimizeIncremental(int passes)
|
|||||||
//
|
//
|
||||||
b3DbvtNode* b3DynamicBvh::insert(const b3DbvtVolume& volume,void* data)
|
b3DbvtNode* b3DynamicBvh::insert(const b3DbvtVolume& volume,void* data)
|
||||||
{
|
{
|
||||||
b3DbvtNode* leaf=createnode(this,0,volume,data);
|
b3DbvtNode* leaf=b3CreateNode(this,0,volume,data);
|
||||||
insertleaf(this,m_root,leaf);
|
b3InsertLeaf(this,m_root,leaf);
|
||||||
++m_leaves;
|
++m_leaves;
|
||||||
return(leaf);
|
return(leaf);
|
||||||
}
|
}
|
||||||
@@ -491,7 +491,7 @@ b3DbvtNode* b3DynamicBvh::insert(const b3DbvtVolume& volume,void* data)
|
|||||||
//
|
//
|
||||||
void b3DynamicBvh::update(b3DbvtNode* leaf,int lookahead)
|
void b3DynamicBvh::update(b3DbvtNode* leaf,int lookahead)
|
||||||
{
|
{
|
||||||
b3DbvtNode* root=removeleaf(this,leaf);
|
b3DbvtNode* root=b3RemoveLeaf(this,leaf);
|
||||||
if(root)
|
if(root)
|
||||||
{
|
{
|
||||||
if(lookahead>=0)
|
if(lookahead>=0)
|
||||||
@@ -502,13 +502,13 @@ void b3DynamicBvh::update(b3DbvtNode* leaf,int lookahead)
|
|||||||
}
|
}
|
||||||
} else root=m_root;
|
} else root=m_root;
|
||||||
}
|
}
|
||||||
insertleaf(this,root,leaf);
|
b3InsertLeaf(this,root,leaf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume)
|
void b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume)
|
||||||
{
|
{
|
||||||
b3DbvtNode* root=removeleaf(this,leaf);
|
b3DbvtNode* root=b3RemoveLeaf(this,leaf);
|
||||||
if(root)
|
if(root)
|
||||||
{
|
{
|
||||||
if(m_lkhd>=0)
|
if(m_lkhd>=0)
|
||||||
@@ -520,7 +520,7 @@ void b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume)
|
|||||||
} else root=m_root;
|
} else root=m_root;
|
||||||
}
|
}
|
||||||
leaf->volume=volume;
|
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)
|
void b3DynamicBvh::remove(b3DbvtNode* leaf)
|
||||||
{
|
{
|
||||||
removeleaf(this,leaf);
|
b3RemoveLeaf(this,leaf);
|
||||||
deletenode(this,leaf);
|
b3DeleteNode(this,leaf);
|
||||||
--m_leaves;
|
--m_leaves;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,7 +596,7 @@ void b3DynamicBvh::clone(b3DynamicBvh& dest,IClone* iclone) const
|
|||||||
do {
|
do {
|
||||||
const int i=stack.size()-1;
|
const int i=stack.size()-1;
|
||||||
const sStkCLN e=stack[i];
|
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();
|
stack.pop_back();
|
||||||
if(e.parent!=0)
|
if(e.parent!=0)
|
||||||
e.parent->childs[i&1]=n;
|
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 b3DynamicBvh::maxdepth(const b3DbvtNode* node)
|
||||||
{
|
{
|
||||||
int depth=0;
|
int depth=0;
|
||||||
if(node) getmaxdepth(node,1,depth);
|
if(node) b3GetMaxDepth(node,1,depth);
|
||||||
return(depth);
|
return(depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ void b3DynamicBvh::extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray<c
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
#if DBVT_ENABLE_BENCHMARK
|
#if B3_DBVT_ENABLE_BENCHMARK
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -692,7 +692,7 @@ struct b3DbvtBenchmark
|
|||||||
{
|
{
|
||||||
struct NilPolicy : b3DynamicBvh::ICollide
|
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*,const b3DbvtNode*) { ++m_pcount; }
|
||||||
void Process(const b3DbvtNode*) { ++m_pcount; }
|
void Process(const b3DbvtNode*) { ++m_pcount; }
|
||||||
void Process(const b3DbvtNode*,b3Scalar depth)
|
void Process(const b3DbvtNode*,b3Scalar depth)
|
||||||
@@ -768,7 +768,7 @@ struct b3DbvtBenchmark
|
|||||||
{
|
{
|
||||||
b3Transform t;
|
b3Transform t;
|
||||||
t.setOrigin(RandVector3(cs));
|
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);
|
return(t);
|
||||||
}
|
}
|
||||||
static void RandTree(b3Scalar cs,b3Scalar eb,b3Scalar es,int leaves,b3DynamicBvh& dbvt)
|
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<cfgBenchmark13_Iterations;++i)
|
for(int i=0;i<cfgBenchmark13_Iterations;++i)
|
||||||
{
|
{
|
||||||
static const b3Scalar offset=0;
|
static const b3Scalar offset=0;
|
||||||
policy.m_depth=-SIMD_INFINITY;
|
policy.m_depth=-B3_INFINITY;
|
||||||
dbvt.collideOCL(dbvt.m_root,&vectors[i],&offset,vectors[i],1,policy);
|
dbvt.collideOCL(dbvt.m_root,&vectors[i],&offset,vectors[i],1,policy);
|
||||||
}
|
}
|
||||||
const int time=(int)wallclock.getTimeMilliseconds();
|
const int time=(int)wallclock.getTimeMilliseconds();
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2007 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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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.
|
||||||
@@ -28,48 +28,48 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
// Implementation profiles
|
// Implementation profiles
|
||||||
#define DBVT_IMPL_GENERIC 0 // Generic implementation
|
#define B3_DBVT_IMPL_GENERIC 0 // Generic implementation
|
||||||
#define DBVT_IMPL_SSE 1 // SSE
|
#define B3_DBVT_IMPL_SSE 1 // SSE
|
||||||
|
|
||||||
// Template implementation of ICollide
|
// Template implementation of ICollide
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if (defined (_MSC_VER) && _MSC_VER >= 1400)
|
#if (defined (_MSC_VER) && _MSC_VER >= 1400)
|
||||||
#define DBVT_USE_TEMPLATE 1
|
#define B3_DBVT_USE_TEMPLATE 1
|
||||||
#else
|
#else
|
||||||
#define DBVT_USE_TEMPLATE 0
|
#define B3_DBVT_USE_TEMPLATE 0
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define DBVT_USE_TEMPLATE 0
|
#define B3_DBVT_USE_TEMPLATE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use only intrinsics instead of inline asm
|
// Use only intrinsics instead of inline asm
|
||||||
#define DBVT_USE_INTRINSIC_SSE 1
|
#define B3_DBVT_USE_INTRINSIC_SSE 1
|
||||||
|
|
||||||
// Using memmov for collideOCL
|
// Using memmov for collideOCL
|
||||||
#define DBVT_USE_MEMMOVE 1
|
#define B3_DBVT_USE_MEMMOVE 1
|
||||||
|
|
||||||
// Enable benchmarking code
|
// Enable benchmarking code
|
||||||
#define DBVT_ENABLE_BENCHMARK 0
|
#define B3_DBVT_ENABLE_BENCHMARK 0
|
||||||
|
|
||||||
// Inlining
|
// Inlining
|
||||||
#define DBVT_INLINE SIMD_FORCE_INLINE
|
#define B3_DBVT_INLINE B3_FORCE_INLINE
|
||||||
|
|
||||||
// Specific methods implementation
|
// Specific methods implementation
|
||||||
|
|
||||||
//SSE gives errors on a MSVC 7.1
|
//SSE gives errors on a MSVC 7.1
|
||||||
#if defined (B3_USE_SSE) //&& defined (_WIN32)
|
#if defined (B3_USE_SSE) //&& defined (_WIN32)
|
||||||
#define DBVT_SELECT_IMPL DBVT_IMPL_SSE
|
#define B3_DBVT_SELECT_IMPL B3_DBVT_IMPL_SSE
|
||||||
#define DBVT_MERGE_IMPL DBVT_IMPL_SSE
|
#define B3_DBVT_MERGE_IMPL B3_DBVT_IMPL_SSE
|
||||||
#define DBVT_INT0_IMPL DBVT_IMPL_SSE
|
#define B3_DBVT_INT0_IMPL B3_DBVT_IMPL_SSE
|
||||||
#else
|
#else
|
||||||
#define DBVT_SELECT_IMPL DBVT_IMPL_GENERIC
|
#define B3_DBVT_SELECT_IMPL B3_DBVT_IMPL_GENERIC
|
||||||
#define DBVT_MERGE_IMPL DBVT_IMPL_GENERIC
|
#define B3_DBVT_MERGE_IMPL B3_DBVT_IMPL_GENERIC
|
||||||
#define DBVT_INT0_IMPL DBVT_IMPL_GENERIC
|
#define B3_DBVT_INT0_IMPL B3_DBVT_IMPL_GENERIC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (DBVT_SELECT_IMPL==DBVT_IMPL_SSE)|| \
|
#if (B3_DBVT_SELECT_IMPL==B3_DBVT_IMPL_SSE)|| \
|
||||||
(DBVT_MERGE_IMPL==DBVT_IMPL_SSE)|| \
|
(B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE)|| \
|
||||||
(DBVT_INT0_IMPL==DBVT_IMPL_SSE)
|
(B3_DBVT_INT0_IMPL==B3_DBVT_IMPL_SSE)
|
||||||
#include <emmintrin.h>
|
#include <emmintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -77,49 +77,49 @@ subject to the following restrictions:
|
|||||||
// Auto config and checks
|
// Auto config and checks
|
||||||
//
|
//
|
||||||
|
|
||||||
#if DBVT_USE_TEMPLATE
|
#if B3_DBVT_USE_TEMPLATE
|
||||||
#define DBVT_VIRTUAL
|
#define B3_DBVT_VIRTUAL
|
||||||
#define DBVT_VIRTUAL_DTOR(a)
|
#define B3_DBVT_VIRTUAL_DTOR(a)
|
||||||
#define DBVT_PREFIX template <typename T>
|
#define B3_DBVT_PREFIX template <typename T>
|
||||||
#define DBVT_IPOLICY T& policy
|
#define B3_DBVT_IPOLICY T& policy
|
||||||
#define DBVT_CHECKTYPE static const ICollide& typechecker=*(T*)1;(void)typechecker;
|
#define B3_DBVT_CHECKTYPE static const ICollide& typechecker=*(T*)1;(void)typechecker;
|
||||||
#else
|
#else
|
||||||
#define DBVT_VIRTUAL_DTOR(a) virtual ~a() {}
|
#define B3_DBVT_VIRTUAL_DTOR(a) virtual ~a() {}
|
||||||
#define DBVT_VIRTUAL virtual
|
#define B3_DBVT_VIRTUAL virtual
|
||||||
#define DBVT_PREFIX
|
#define B3_DBVT_PREFIX
|
||||||
#define DBVT_IPOLICY ICollide& policy
|
#define B3_DBVT_IPOLICY ICollide& policy
|
||||||
#define DBVT_CHECKTYPE
|
#define B3_DBVT_CHECKTYPE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DBVT_USE_MEMMOVE
|
#if B3_DBVT_USE_MEMMOVE
|
||||||
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#endif
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DBVT_USE_TEMPLATE
|
#ifndef B3_DBVT_USE_TEMPLATE
|
||||||
#error "DBVT_USE_TEMPLATE undefined"
|
#error "B3_DBVT_USE_TEMPLATE undefined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DBVT_USE_MEMMOVE
|
#ifndef B3_DBVT_USE_MEMMOVE
|
||||||
#error "DBVT_USE_MEMMOVE undefined"
|
#error "B3_DBVT_USE_MEMMOVE undefined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DBVT_ENABLE_BENCHMARK
|
#ifndef B3_DBVT_ENABLE_BENCHMARK
|
||||||
#error "DBVT_ENABLE_BENCHMARK undefined"
|
#error "B3_DBVT_ENABLE_BENCHMARK undefined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DBVT_SELECT_IMPL
|
#ifndef B3_DBVT_SELECT_IMPL
|
||||||
#error "DBVT_SELECT_IMPL undefined"
|
#error "B3_DBVT_SELECT_IMPL undefined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DBVT_MERGE_IMPL
|
#ifndef B3_DBVT_MERGE_IMPL
|
||||||
#error "DBVT_MERGE_IMPL undefined"
|
#error "B3_DBVT_MERGE_IMPL undefined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DBVT_INT0_IMPL
|
#ifndef B3_DBVT_INT0_IMPL
|
||||||
#error "DBVT_INT0_IMPL undefined"
|
#error "B3_DBVT_INT0_IMPL undefined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -129,43 +129,43 @@ subject to the following restrictions:
|
|||||||
/* b3DbvtAabbMm */
|
/* b3DbvtAabbMm */
|
||||||
struct b3DbvtAabbMm
|
struct b3DbvtAabbMm
|
||||||
{
|
{
|
||||||
DBVT_INLINE b3Vector3 Center() const { return((mi+mx)/2); }
|
B3_DBVT_INLINE b3Vector3 Center() const { return((mi+mx)/2); }
|
||||||
DBVT_INLINE b3Vector3 Lengths() const { return(mx-mi); }
|
B3_DBVT_INLINE b3Vector3 Lengths() const { return(mx-mi); }
|
||||||
DBVT_INLINE b3Vector3 Extents() const { return((mx-mi)/2); }
|
B3_DBVT_INLINE b3Vector3 Extents() const { return((mx-mi)/2); }
|
||||||
DBVT_INLINE const b3Vector3& Mins() const { return(mi); }
|
B3_DBVT_INLINE const b3Vector3& Mins() const { return(mi); }
|
||||||
DBVT_INLINE const b3Vector3& Maxs() const { return(mx); }
|
B3_DBVT_INLINE const b3Vector3& Maxs() const { return(mx); }
|
||||||
static inline b3DbvtAabbMm FromCE(const b3Vector3& c,const b3Vector3& e);
|
static inline b3DbvtAabbMm FromCE(const b3Vector3& c,const b3Vector3& e);
|
||||||
static inline b3DbvtAabbMm FromCR(const b3Vector3& c,b3Scalar r);
|
static inline b3DbvtAabbMm FromCR(const b3Vector3& c,b3Scalar r);
|
||||||
static inline b3DbvtAabbMm FromMM(const b3Vector3& mi,const b3Vector3& mx);
|
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* pts,int n);
|
||||||
static inline b3DbvtAabbMm FromPoints(const b3Vector3** ppts,int n);
|
static inline b3DbvtAabbMm FromPoints(const b3Vector3** ppts,int n);
|
||||||
DBVT_INLINE void Expand(const b3Vector3& e);
|
B3_DBVT_INLINE void Expand(const b3Vector3& e);
|
||||||
DBVT_INLINE void SignedExpand(const b3Vector3& e);
|
B3_DBVT_INLINE void SignedExpand(const b3Vector3& e);
|
||||||
DBVT_INLINE bool Contain(const b3DbvtAabbMm& a) const;
|
B3_DBVT_INLINE bool Contain(const b3DbvtAabbMm& a) const;
|
||||||
DBVT_INLINE int Classify(const b3Vector3& n,b3Scalar o,int s) const;
|
B3_DBVT_INLINE int Classify(const b3Vector3& n,b3Scalar o,int s) const;
|
||||||
DBVT_INLINE b3Scalar ProjectMinimum(const b3Vector3& v,unsigned signs) const;
|
B3_DBVT_INLINE b3Scalar ProjectMinimum(const b3Vector3& v,unsigned signs) const;
|
||||||
DBVT_INLINE friend bool Intersect( const b3DbvtAabbMm& a,
|
B3_DBVT_INLINE friend bool b3Intersect( const b3DbvtAabbMm& a,
|
||||||
const b3DbvtAabbMm& b);
|
const b3DbvtAabbMm& b);
|
||||||
|
|
||||||
DBVT_INLINE friend bool Intersect( const b3DbvtAabbMm& a,
|
B3_DBVT_INLINE friend bool b3Intersect( const b3DbvtAabbMm& a,
|
||||||
const b3Vector3& b);
|
const b3Vector3& b);
|
||||||
|
|
||||||
DBVT_INLINE friend b3Scalar Proximity( const b3DbvtAabbMm& a,
|
B3_DBVT_INLINE friend b3Scalar b3Proximity( const b3DbvtAabbMm& a,
|
||||||
const b3DbvtAabbMm& b);
|
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& a,
|
||||||
const b3DbvtAabbMm& b);
|
const b3DbvtAabbMm& b);
|
||||||
DBVT_INLINE friend void Merge( const b3DbvtAabbMm& a,
|
B3_DBVT_INLINE friend void b3Merge( const b3DbvtAabbMm& a,
|
||||||
const b3DbvtAabbMm& b,
|
const b3DbvtAabbMm& b,
|
||||||
b3DbvtAabbMm& r);
|
b3DbvtAabbMm& r);
|
||||||
DBVT_INLINE friend bool NotEqual( const b3DbvtAabbMm& a,
|
B3_DBVT_INLINE friend bool b3NotEqual( const b3DbvtAabbMm& a,
|
||||||
const b3DbvtAabbMm& b);
|
const b3DbvtAabbMm& b);
|
||||||
|
|
||||||
DBVT_INLINE b3Vector3& tMins() { return(mi); }
|
B3_DBVT_INLINE b3Vector3& tMins() { return(mi); }
|
||||||
DBVT_INLINE b3Vector3& tMaxs() { return(mx); }
|
B3_DBVT_INLINE b3Vector3& tMaxs() { return(mx); }
|
||||||
|
|
||||||
private:
|
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:
|
private:
|
||||||
b3Vector3 mi,mx;
|
b3Vector3 mi,mx;
|
||||||
};
|
};
|
||||||
@@ -178,8 +178,8 @@ struct b3DbvtNode
|
|||||||
{
|
{
|
||||||
b3DbvtVolume volume;
|
b3DbvtVolume volume;
|
||||||
b3DbvtNode* parent;
|
b3DbvtNode* parent;
|
||||||
DBVT_INLINE bool isleaf() const { return(childs[1]==0); }
|
B3_DBVT_INLINE bool isleaf() const { return(childs[1]==0); }
|
||||||
DBVT_INLINE bool isinternal() const { return(!isleaf()); }
|
B3_DBVT_INLINE bool isinternal() const { return(!isleaf()); }
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
b3DbvtNode* childs[2];
|
b3DbvtNode* childs[2];
|
||||||
@@ -226,12 +226,12 @@ struct b3DynamicBvh
|
|||||||
/* ICollide */
|
/* ICollide */
|
||||||
struct ICollide
|
struct ICollide
|
||||||
{
|
{
|
||||||
DBVT_VIRTUAL_DTOR(ICollide)
|
B3_DBVT_VIRTUAL_DTOR(ICollide)
|
||||||
DBVT_VIRTUAL void Process(const b3DbvtNode*,const b3DbvtNode*) {}
|
B3_DBVT_VIRTUAL void Process(const b3DbvtNode*,const b3DbvtNode*) {}
|
||||||
DBVT_VIRTUAL void Process(const b3DbvtNode*) {}
|
B3_DBVT_VIRTUAL void Process(const b3DbvtNode*) {}
|
||||||
DBVT_VIRTUAL void Process(const b3DbvtNode* n,b3Scalar) { Process(n); }
|
B3_DBVT_VIRTUAL void Process(const b3DbvtNode* n,b3Scalar) { Process(n); }
|
||||||
DBVT_VIRTUAL bool Descent(const b3DbvtNode*) { return(true); }
|
B3_DBVT_VIRTUAL bool Descent(const b3DbvtNode*) { return(true); }
|
||||||
DBVT_VIRTUAL bool AllLeaves(const b3DbvtNode*) { return(true); }
|
B3_DBVT_VIRTUAL bool AllLeaves(const b3DbvtNode*) { return(true); }
|
||||||
};
|
};
|
||||||
/* IWriter */
|
/* IWriter */
|
||||||
struct IWriter
|
struct IWriter
|
||||||
@@ -250,8 +250,8 @@ struct b3DynamicBvh
|
|||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
enum {
|
enum {
|
||||||
SIMPLE_STACKSIZE = 64,
|
B3_SIMPLE_STACKSIZE = 64,
|
||||||
DOUBLE_STACKSIZE = SIMPLE_STACKSIZE*2
|
B3_DOUBLE_STACKSIZE = B3_SIMPLE_STACKSIZE*2
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
@@ -286,55 +286,55 @@ struct b3DynamicBvh
|
|||||||
static int maxdepth(const b3DbvtNode* node);
|
static int maxdepth(const b3DbvtNode* node);
|
||||||
static int countLeaves(const b3DbvtNode* node);
|
static int countLeaves(const b3DbvtNode* node);
|
||||||
static void extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray<const b3DbvtNode*>& leaves);
|
static void extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray<const b3DbvtNode*>& leaves);
|
||||||
#if DBVT_ENABLE_BENCHMARK
|
#if B3_DBVT_ENABLE_BENCHMARK
|
||||||
static void benchmark();
|
static void benchmark();
|
||||||
#else
|
#else
|
||||||
static void benchmark(){}
|
static void benchmark(){}
|
||||||
#endif
|
#endif
|
||||||
// DBVT_IPOLICY must support ICollide policy/interface
|
// B3_DBVT_IPOLICY must support ICollide policy/interface
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
static void enumNodes( const b3DbvtNode* root,
|
static void enumNodes( const b3DbvtNode* root,
|
||||||
DBVT_IPOLICY);
|
B3_DBVT_IPOLICY);
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
static void enumLeaves( const b3DbvtNode* root,
|
static void enumLeaves( const b3DbvtNode* root,
|
||||||
DBVT_IPOLICY);
|
B3_DBVT_IPOLICY);
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
void collideTT( const b3DbvtNode* root0,
|
void collideTT( const b3DbvtNode* root0,
|
||||||
const b3DbvtNode* root1,
|
const b3DbvtNode* root1,
|
||||||
DBVT_IPOLICY);
|
B3_DBVT_IPOLICY);
|
||||||
|
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
void collideTTpersistentStack( const b3DbvtNode* root0,
|
void collideTTpersistentStack( const b3DbvtNode* root0,
|
||||||
const b3DbvtNode* root1,
|
const b3DbvtNode* root1,
|
||||||
DBVT_IPOLICY);
|
B3_DBVT_IPOLICY);
|
||||||
#if 0
|
#if 0
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
void collideTT( const b3DbvtNode* root0,
|
void collideTT( const b3DbvtNode* root0,
|
||||||
const b3DbvtNode* root1,
|
const b3DbvtNode* root1,
|
||||||
const b3Transform& xform,
|
const b3Transform& xform,
|
||||||
DBVT_IPOLICY);
|
B3_DBVT_IPOLICY);
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
void collideTT( const b3DbvtNode* root0,
|
void collideTT( const b3DbvtNode* root0,
|
||||||
const b3Transform& xform0,
|
const b3Transform& xform0,
|
||||||
const b3DbvtNode* root1,
|
const b3DbvtNode* root1,
|
||||||
const b3Transform& xform1,
|
const b3Transform& xform1,
|
||||||
DBVT_IPOLICY);
|
B3_DBVT_IPOLICY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
void collideTV( const b3DbvtNode* root,
|
void collideTV( const b3DbvtNode* root,
|
||||||
const b3DbvtVolume& volume,
|
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 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
|
///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,
|
static void rayTest( const b3DbvtNode* root,
|
||||||
const b3Vector3& rayFrom,
|
const b3Vector3& rayFrom,
|
||||||
const b3Vector3& rayTo,
|
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 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
|
///rayTestInternal is used by b3DynamicBvhBroadphase to accelerate world ray casts
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
void rayTestInternal( const b3DbvtNode* root,
|
void rayTestInternal( const b3DbvtNode* root,
|
||||||
const b3Vector3& rayFrom,
|
const b3Vector3& rayFrom,
|
||||||
const b3Vector3& rayTo,
|
const b3Vector3& rayTo,
|
||||||
@@ -343,27 +343,27 @@ struct b3DynamicBvh
|
|||||||
b3Scalar lambda_max,
|
b3Scalar lambda_max,
|
||||||
const b3Vector3& aabbMin,
|
const b3Vector3& aabbMin,
|
||||||
const b3Vector3& aabbMax,
|
const b3Vector3& aabbMax,
|
||||||
DBVT_IPOLICY) const;
|
B3_DBVT_IPOLICY) const;
|
||||||
|
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
static void collideKDOP(const b3DbvtNode* root,
|
static void collideKDOP(const b3DbvtNode* root,
|
||||||
const b3Vector3* normals,
|
const b3Vector3* normals,
|
||||||
const b3Scalar* offsets,
|
const b3Scalar* offsets,
|
||||||
int count,
|
int count,
|
||||||
DBVT_IPOLICY);
|
B3_DBVT_IPOLICY);
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
static void collideOCL( const b3DbvtNode* root,
|
static void collideOCL( const b3DbvtNode* root,
|
||||||
const b3Vector3* normals,
|
const b3Vector3* normals,
|
||||||
const b3Scalar* offsets,
|
const b3Scalar* offsets,
|
||||||
const b3Vector3& sortaxis,
|
const b3Vector3& sortaxis,
|
||||||
int count,
|
int count,
|
||||||
DBVT_IPOLICY,
|
B3_DBVT_IPOLICY,
|
||||||
bool fullsort=true);
|
bool fullsort=true);
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
static void collideTU( const b3DbvtNode* root,
|
static void collideTU( const b3DbvtNode* root,
|
||||||
DBVT_IPOLICY);
|
B3_DBVT_IPOLICY);
|
||||||
// Helpers
|
// 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;
|
int m=0;
|
||||||
while(l<h)
|
while(l<h)
|
||||||
@@ -373,7 +373,7 @@ struct b3DynamicBvh
|
|||||||
}
|
}
|
||||||
return(h);
|
return(h);
|
||||||
}
|
}
|
||||||
static DBVT_INLINE int allocate( b3AlignedObjectArray<int>& ifree,
|
static B3_DBVT_INLINE int allocate( b3AlignedObjectArray<int>& ifree,
|
||||||
b3AlignedObjectArray<sStkNPS>& stock,
|
b3AlignedObjectArray<sStkNPS>& stock,
|
||||||
const sStkNPS& value)
|
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;
|
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.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]);
|
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)&&
|
return( (mi.x<=a.mi.x)&&
|
||||||
(mi.y<=a.mi.y)&&
|
(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;
|
b3Vector3 pi,px;
|
||||||
switch(s)
|
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* b[]={&mx,&mi};
|
||||||
const b3Vector3 p( b[(signs>>0)&1]->x,
|
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)
|
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)
|
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)),
|
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))));
|
_mm_cmplt_ps(_mm_load_ps(a.mx),_mm_load_ps(b.mi))));
|
||||||
#if defined (_WIN32)
|
#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)
|
const b3Vector3& b)
|
||||||
{
|
{
|
||||||
return( (b.x>=a.mi.x)&&
|
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 b3DbvtAabbMm& b)
|
||||||
{
|
{
|
||||||
const b3Vector3 d=(a.mi+a.mx)-(b.mi+b.mx);
|
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& a,
|
||||||
const b3DbvtAabbMm& b)
|
const b3DbvtAabbMm& b)
|
||||||
{
|
{
|
||||||
#if DBVT_SELECT_IMPL == DBVT_IMPL_SSE
|
#if B3_DBVT_SELECT_IMPL == B3_DBVT_IMPL_SSE
|
||||||
|
|
||||||
#if defined (_WIN32)
|
#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
|
#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
|
#endif
|
||||||
///@todo: the intrinsic version is 11% slower
|
///@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
|
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;
|
return tmp.ints[0]&1;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
ATTRIBUTE_ALIGNED16(__int32 r[1]);
|
B3_ATTRIBUTE_ALIGNED16(__int32 r[1]);
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov eax,o
|
mov eax,o
|
||||||
@@ -645,16 +645,16 @@ DBVT_INLINE int Select( const b3DbvtAabbMm& o,
|
|||||||
return(r[0]&1);
|
return(r[0]&1);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
return(Proximity(o,a)<Proximity(o,b)?0:1);
|
return(b3Proximity(o,a)<b3Proximity(o,b)?0:1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
DBVT_INLINE void Merge( const b3DbvtAabbMm& a,
|
B3_DBVT_INLINE void b3Merge( const b3DbvtAabbMm& a,
|
||||||
const b3DbvtAabbMm& b,
|
const b3DbvtAabbMm& b,
|
||||||
b3DbvtAabbMm& r)
|
b3DbvtAabbMm& r)
|
||||||
{
|
{
|
||||||
#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE
|
#if B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE
|
||||||
__m128 ami(_mm_load_ps(a.mi));
|
__m128 ami(_mm_load_ps(a.mi));
|
||||||
__m128 amx(_mm_load_ps(a.mx));
|
__m128 amx(_mm_load_ps(a.mx));
|
||||||
__m128 bmi(_mm_load_ps(b.mi));
|
__m128 bmi(_mm_load_ps(b.mi));
|
||||||
@@ -673,7 +673,7 @@ DBVT_INLINE void Merge( const b3DbvtAabbMm& a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
DBVT_INLINE bool NotEqual( const b3DbvtAabbMm& a,
|
B3_DBVT_INLINE bool b3NotEqual( const b3DbvtAabbMm& a,
|
||||||
const b3DbvtAabbMm& b)
|
const b3DbvtAabbMm& b)
|
||||||
{
|
{
|
||||||
return( (a.mi.x!=b.mi.x)||
|
return( (a.mi.x!=b.mi.x)||
|
||||||
@@ -689,11 +689,11 @@ DBVT_INLINE bool NotEqual( const b3DbvtAabbMm& a,
|
|||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
inline void b3DynamicBvh::enumNodes( const b3DbvtNode* root,
|
inline void b3DynamicBvh::enumNodes( const b3DbvtNode* root,
|
||||||
DBVT_IPOLICY)
|
B3_DBVT_IPOLICY)
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
policy.Process(root);
|
policy.Process(root);
|
||||||
if(root->isinternal())
|
if(root->isinternal())
|
||||||
{
|
{
|
||||||
@@ -703,11 +703,11 @@ inline void b3DynamicBvh::enumNodes( const b3DbvtNode* root,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
inline void b3DynamicBvh::enumLeaves( const b3DbvtNode* root,
|
inline void b3DynamicBvh::enumLeaves( const b3DbvtNode* root,
|
||||||
DBVT_IPOLICY)
|
B3_DBVT_IPOLICY)
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root->isinternal())
|
if(root->isinternal())
|
||||||
{
|
{
|
||||||
enumLeaves(root->childs[0],policy);
|
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,
|
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
|
||||||
const b3DbvtNode* root1,
|
const b3DbvtNode* root1,
|
||||||
DBVT_IPOLICY)
|
B3_DBVT_IPOLICY)
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root0&&root1)
|
if(root0&&root1)
|
||||||
{
|
{
|
||||||
int depth=1;
|
int depth=1;
|
||||||
int treshold=DOUBLE_STACKSIZE-4;
|
int treshold=B3_DOUBLE_STACKSIZE-4;
|
||||||
b3AlignedObjectArray<sStkNN> stkStack;
|
b3AlignedObjectArray<sStkNN> stkStack;
|
||||||
stkStack.resize(DOUBLE_STACKSIZE);
|
stkStack.resize(B3_DOUBLE_STACKSIZE);
|
||||||
stkStack[0]=sStkNN(root0,root1);
|
stkStack[0]=sStkNN(root0,root1);
|
||||||
do {
|
do {
|
||||||
sStkNN p=stkStack[--depth];
|
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]);
|
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())
|
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,
|
inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0,
|
||||||
const b3DbvtNode* root1,
|
const b3DbvtNode* root1,
|
||||||
DBVT_IPOLICY)
|
B3_DBVT_IPOLICY)
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root0&&root1)
|
if(root0&&root1)
|
||||||
{
|
{
|
||||||
int depth=1;
|
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);
|
m_stkStack[0]=sStkNN(root0,root1);
|
||||||
do {
|
do {
|
||||||
sStkNN p=m_stkStack[--depth];
|
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]);
|
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())
|
if(p.a->isinternal())
|
||||||
{
|
{
|
||||||
@@ -850,23 +850,23 @@ inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0,
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//
|
//
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
|
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
|
||||||
const b3DbvtNode* root1,
|
const b3DbvtNode* root1,
|
||||||
const b3Transform& xform,
|
const b3Transform& xform,
|
||||||
DBVT_IPOLICY)
|
B3_DBVT_IPOLICY)
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root0&&root1)
|
if(root0&&root1)
|
||||||
{
|
{
|
||||||
int depth=1;
|
int depth=1;
|
||||||
int treshold=DOUBLE_STACKSIZE-4;
|
int treshold=B3_DOUBLE_STACKSIZE-4;
|
||||||
b3AlignedObjectArray<sStkNN> stkStack;
|
b3AlignedObjectArray<sStkNN> stkStack;
|
||||||
stkStack.resize(DOUBLE_STACKSIZE);
|
stkStack.resize(B3_DOUBLE_STACKSIZE);
|
||||||
stkStack[0]=sStkNN(root0,root1);
|
stkStack[0]=sStkNN(root0,root1);
|
||||||
do {
|
do {
|
||||||
sStkNN p=stkStack[--depth];
|
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)
|
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,
|
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
|
||||||
const b3Transform& xform0,
|
const b3Transform& xform0,
|
||||||
const b3DbvtNode* root1,
|
const b3DbvtNode* root1,
|
||||||
const b3Transform& xform1,
|
const b3Transform& xform1,
|
||||||
DBVT_IPOLICY)
|
B3_DBVT_IPOLICY)
|
||||||
{
|
{
|
||||||
const b3Transform xform=xform0.inverse()*xform1;
|
const b3Transform xform=xform0.inverse()*xform1;
|
||||||
collideTT(root0,root1,xform,policy);
|
collideTT(root0,root1,xform,policy);
|
||||||
@@ -918,23 +918,23 @@ inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
inline void b3DynamicBvh::collideTV( const b3DbvtNode* root,
|
inline void b3DynamicBvh::collideTV( const b3DbvtNode* root,
|
||||||
const b3DbvtVolume& vol,
|
const b3DbvtVolume& vol,
|
||||||
DBVT_IPOLICY) const
|
B3_DBVT_IPOLICY) const
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root)
|
if(root)
|
||||||
{
|
{
|
||||||
ATTRIBUTE_ALIGNED16(b3DbvtVolume) volume(vol);
|
B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) volume(vol);
|
||||||
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
||||||
stack.resize(0);
|
stack.resize(0);
|
||||||
stack.reserve(SIMPLE_STACKSIZE);
|
stack.reserve(B3_SIMPLE_STACKSIZE);
|
||||||
stack.push_back(root);
|
stack.push_back(root);
|
||||||
do {
|
do {
|
||||||
const b3DbvtNode* n=stack[stack.size()-1];
|
const b3DbvtNode* n=stack[stack.size()-1];
|
||||||
stack.pop_back();
|
stack.pop_back();
|
||||||
if(Intersect(n->volume,volume))
|
if(b3Intersect(n->volume,volume))
|
||||||
{
|
{
|
||||||
if(n->isinternal())
|
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,
|
inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root,
|
||||||
const b3Vector3& rayFrom,
|
const b3Vector3& rayFrom,
|
||||||
const b3Vector3& rayTo,
|
const b3Vector3& rayTo,
|
||||||
@@ -959,18 +959,18 @@ inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root,
|
|||||||
b3Scalar lambda_max,
|
b3Scalar lambda_max,
|
||||||
const b3Vector3& aabbMin,
|
const b3Vector3& aabbMin,
|
||||||
const b3Vector3& aabbMax,
|
const b3Vector3& aabbMax,
|
||||||
DBVT_IPOLICY) const
|
B3_DBVT_IPOLICY) const
|
||||||
{
|
{
|
||||||
(void) rayTo;
|
(void) rayTo;
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root)
|
if(root)
|
||||||
{
|
{
|
||||||
b3Vector3 resultNormal;
|
b3Vector3 resultNormal;
|
||||||
|
|
||||||
int depth=1;
|
int depth=1;
|
||||||
int treshold=DOUBLE_STACKSIZE-2;
|
int treshold=B3_DOUBLE_STACKSIZE-2;
|
||||||
b3AlignedObjectArray<const b3DbvtNode*>& stack = m_rayTestStack;
|
b3AlignedObjectArray<const b3DbvtNode*>& stack = m_rayTestStack;
|
||||||
stack.resize(DOUBLE_STACKSIZE);
|
stack.resize(B3_DOUBLE_STACKSIZE);
|
||||||
stack[0]=root;
|
stack[0]=root;
|
||||||
b3Vector3 bounds[2];
|
b3Vector3 bounds[2];
|
||||||
do
|
do
|
||||||
@@ -1003,13 +1003,13 @@ inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
inline void b3DynamicBvh::rayTest( const b3DbvtNode* root,
|
inline void b3DynamicBvh::rayTest( const b3DbvtNode* root,
|
||||||
const b3Vector3& rayFrom,
|
const b3Vector3& rayFrom,
|
||||||
const b3Vector3& rayTo,
|
const b3Vector3& rayTo,
|
||||||
DBVT_IPOLICY)
|
B3_DBVT_IPOLICY)
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root)
|
if(root)
|
||||||
{
|
{
|
||||||
b3Vector3 rayDir = (rayTo-rayFrom);
|
b3Vector3 rayDir = (rayTo-rayFrom);
|
||||||
@@ -1029,9 +1029,9 @@ inline void b3DynamicBvh::rayTest( const b3DbvtNode* root,
|
|||||||
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
||||||
|
|
||||||
int depth=1;
|
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;
|
stack[0]=root;
|
||||||
b3Vector3 bounds[2];
|
b3Vector3 bounds[2];
|
||||||
do {
|
do {
|
||||||
@@ -1072,14 +1072,14 @@ inline void b3DynamicBvh::rayTest( const b3DbvtNode* root,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
DBVT_PREFIX
|
B3_DBVT_PREFIX
|
||||||
inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root,
|
inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root,
|
||||||
const b3Vector3* normals,
|
const b3Vector3* normals,
|
||||||
const b3Scalar* offsets,
|
const b3Scalar* offsets,
|
||||||
int count,
|
int count,
|
||||||
DBVT_IPOLICY)
|
B3_DBVT_IPOLICY)
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root)
|
if(root)
|
||||||
{
|
{
|
||||||
const int inside=(1<<count)-1;
|
const int inside=(1<<count)-1;
|
||||||
@@ -1092,7 +1092,7 @@ inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root,
|
|||||||
((normals[i].y>=0)?2:0)+
|
((normals[i].y>=0)?2:0)+
|
||||||
((normals[i].z>=0)?4:0);
|
((normals[i].z>=0)?4:0);
|
||||||
}
|
}
|
||||||
stack.reserve(SIMPLE_STACKSIZE);
|
stack.reserve(B3_SIMPLE_STACKSIZE);
|
||||||
stack.push_back(sStkNP(root,0));
|
stack.push_back(sStkNP(root,0));
|
||||||
do {
|
do {
|
||||||
sStkNP se=stack[stack.size()-1];
|
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,
|
inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root,
|
||||||
const b3Vector3* normals,
|
const b3Vector3* normals,
|
||||||
const b3Scalar* offsets,
|
const b3Scalar* offsets,
|
||||||
const b3Vector3& sortaxis,
|
const b3Vector3& sortaxis,
|
||||||
int count,
|
int count,
|
||||||
DBVT_IPOLICY,
|
B3_DBVT_IPOLICY,
|
||||||
bool fsort)
|
bool fsort)
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root)
|
if(root)
|
||||||
{
|
{
|
||||||
const unsigned srtsgns=(sortaxis[0]>=0?1:0)+
|
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].y>=0)?2:0)+
|
||||||
((normals[i].z>=0)?4:0);
|
((normals[i].z>=0)?4:0);
|
||||||
}
|
}
|
||||||
stock.reserve(SIMPLE_STACKSIZE);
|
stock.reserve(B3_SIMPLE_STACKSIZE);
|
||||||
stack.reserve(SIMPLE_STACKSIZE);
|
stack.reserve(B3_SIMPLE_STACKSIZE);
|
||||||
ifree.reserve(SIMPLE_STACKSIZE);
|
ifree.reserve(B3_SIMPLE_STACKSIZE);
|
||||||
stack.push_back(allocate(ifree,stock,sStkNPS(root,0,root->volume.ProjectMinimum(sortaxis,srtsgns))));
|
stack.push_back(allocate(ifree,stock,sStkNPS(root,0,root->volume.ProjectMinimum(sortaxis,srtsgns))));
|
||||||
do {
|
do {
|
||||||
const int id=stack[stack.size()-1];
|
const int id=stack[stack.size()-1];
|
||||||
@@ -1193,7 +1193,7 @@ inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root,
|
|||||||
/* Insert 0 */
|
/* Insert 0 */
|
||||||
j=nearest(&stack[0],&stock[0],nes[q].value,0,stack.size());
|
j=nearest(&stack[0],&stock[0],nes[q].value,0,stack.size());
|
||||||
stack.push_back(0);
|
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));
|
memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
|
||||||
#else
|
#else
|
||||||
for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
|
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 */
|
/* Insert 1 */
|
||||||
j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size());
|
j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size());
|
||||||
stack.push_back(0);
|
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));
|
memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
|
||||||
#else
|
#else
|
||||||
for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
|
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,
|
inline void b3DynamicBvh::collideTU( const b3DbvtNode* root,
|
||||||
DBVT_IPOLICY)
|
B3_DBVT_IPOLICY)
|
||||||
{
|
{
|
||||||
DBVT_CHECKTYPE
|
B3_DBVT_CHECKTYPE
|
||||||
if(root)
|
if(root)
|
||||||
{
|
{
|
||||||
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
||||||
stack.reserve(SIMPLE_STACKSIZE);
|
stack.reserve(B3_SIMPLE_STACKSIZE);
|
||||||
stack.push_back(root);
|
stack.push_back(root);
|
||||||
do {
|
do {
|
||||||
const b3DbvtNode* n=stack[stack.size()-1];
|
const b3DbvtNode* n=stack[stack.size()-1];
|
||||||
@@ -1253,18 +1253,18 @@ inline void b3DynamicBvh::collideTU( const b3DbvtNode* root,
|
|||||||
// PP Cleanup
|
// PP Cleanup
|
||||||
//
|
//
|
||||||
|
|
||||||
#undef DBVT_USE_MEMMOVE
|
#undef B3_DBVT_USE_MEMMOVE
|
||||||
#undef DBVT_USE_TEMPLATE
|
#undef B3_DBVT_USE_TEMPLATE
|
||||||
#undef DBVT_VIRTUAL_DTOR
|
#undef B3_DBVT_VIRTUAL_DTOR
|
||||||
#undef DBVT_VIRTUAL
|
#undef B3_DBVT_VIRTUAL
|
||||||
#undef DBVT_PREFIX
|
#undef B3_DBVT_PREFIX
|
||||||
#undef DBVT_IPOLICY
|
#undef B3_DBVT_IPOLICY
|
||||||
#undef DBVT_CHECKTYPE
|
#undef B3_DBVT_CHECKTYPE
|
||||||
#undef DBVT_IMPL_GENERIC
|
#undef B3_DBVT_IMPL_GENERIC
|
||||||
#undef DBVT_IMPL_SSE
|
#undef B3_DBVT_IMPL_SSE
|
||||||
#undef DBVT_USE_INTRINSIC_SSE
|
#undef B3_DBVT_USE_INTRINSIC_SSE
|
||||||
#undef DBVT_SELECT_IMPL
|
#undef B3_DBVT_SELECT_IMPL
|
||||||
#undef DBVT_MERGE_IMPL
|
#undef B3_DBVT_MERGE_IMPL
|
||||||
#undef DBVT_INT0_IMPL
|
#undef B3_DBVT_INT0_IMPL
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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
|
// Profiling
|
||||||
//
|
//
|
||||||
|
|
||||||
#if DBVT_BP_PROFILE||DBVT_BP_ENABLE_BENCHMARK
|
#if B3_DBVT_BP_PROFILE||B3_DBVT_BP_ENABLE_BENCHMARK
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DBVT_BP_PROFILE
|
#if B3_DBVT_BP_PROFILE
|
||||||
struct ProfileScope
|
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())
|
m_clock(&clock),m_value(&value),m_base(clock.getTimeMicroseconds())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
__forceinline ~ProfileScope()
|
__forceinline ~b3ProfileScope()
|
||||||
{
|
{
|
||||||
(*m_value)+=m_clock->getTimeMicroseconds()-m_base;
|
(*m_value)+=m_clock->getTimeMicroseconds()-m_base;
|
||||||
}
|
}
|
||||||
@@ -41,9 +41,9 @@ struct ProfileScope
|
|||||||
unsigned long* m_value;
|
unsigned long* m_value;
|
||||||
unsigned long m_base;
|
unsigned long m_base;
|
||||||
};
|
};
|
||||||
#define SPC(_value_) ProfileScope spc_scope(m_clock,_value_)
|
#define b3SPC(_value_) b3ProfileScope spc_scope(m_clock,_value_)
|
||||||
#else
|
#else
|
||||||
#define SPC(_value_)
|
#define b3SPC(_value_)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -52,7 +52,7 @@ struct ProfileScope
|
|||||||
|
|
||||||
//
|
//
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline void listappend(T* item,T*& list)
|
static inline void b3ListAppend(T* item,T*& list)
|
||||||
{
|
{
|
||||||
item->links[0]=0;
|
item->links[0]=0;
|
||||||
item->links[1]=list;
|
item->links[1]=list;
|
||||||
@@ -62,7 +62,7 @@ static inline void listappend(T* item,T*& list)
|
|||||||
|
|
||||||
//
|
//
|
||||||
template <typename T>
|
template <typename T>
|
||||||
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[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];
|
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 <typename T>
|
template <typename T>
|
||||||
static inline int listcount(T* root)
|
static inline int b3ListCount(T* root)
|
||||||
{
|
{
|
||||||
int n=0;
|
int n=0;
|
||||||
while(root) { ++n;root=root->links[1]; }
|
while(root) { ++n;root=root->links[1]; }
|
||||||
@@ -79,7 +79,7 @@ static inline int listcount(T* root)
|
|||||||
|
|
||||||
//
|
//
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline void clear(T& value)
|
static inline void b3Clear(T& value)
|
||||||
{
|
{
|
||||||
static const struct ZeroDummy : T {} zerodummy;
|
static const struct ZeroDummy : T {} zerodummy;
|
||||||
value=zerodummy;
|
value=zerodummy;
|
||||||
@@ -101,7 +101,7 @@ struct b3DbvtTreeCollider : b3DynamicBvh::ICollide
|
|||||||
{
|
{
|
||||||
b3DbvtProxy* pa=(b3DbvtProxy*)na->data;
|
b3DbvtProxy* pa=(b3DbvtProxy*)na->data;
|
||||||
b3DbvtProxy* pb=(b3DbvtProxy*)nb->data;
|
b3DbvtProxy* pb=(b3DbvtProxy*)nb->data;
|
||||||
#if DBVT_BP_SORTPAIRS
|
#if B3_DBVT_BP_SORTPAIRS
|
||||||
if(pa->m_uniqueId>pb->m_uniqueId)
|
if(pa->m_uniqueId>pb->m_uniqueId)
|
||||||
b3Swap(pa,pb);
|
b3Swap(pa,pb);
|
||||||
#endif
|
#endif
|
||||||
@@ -143,8 +143,8 @@ b3DynamicBvhBroadphase::b3DynamicBvhBroadphase(int proxyCapacity, b3OverlappingP
|
|||||||
{
|
{
|
||||||
m_stageRoots[i]=0;
|
m_stageRoots[i]=0;
|
||||||
}
|
}
|
||||||
#if DBVT_BP_PROFILE
|
#if B3_DBVT_BP_PROFILE
|
||||||
clear(m_profiling);
|
b3Clear(m_profiling);
|
||||||
#endif
|
#endif
|
||||||
m_proxies.resize(proxyCapacity);
|
m_proxies.resize(proxyCapacity);
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ b3BroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabb
|
|||||||
proxy->stage = m_stageCurrent;
|
proxy->stage = m_stageCurrent;
|
||||||
proxy->m_uniqueId = objectId;
|
proxy->m_uniqueId = objectId;
|
||||||
proxy->leaf = m_sets[0].insert(aabb,proxy);
|
proxy->leaf = m_sets[0].insert(aabb,proxy);
|
||||||
listappend(proxy,m_stageRoots[m_stageCurrent]);
|
b3ListAppend(proxy,m_stageRoots[m_stageCurrent]);
|
||||||
if(!m_deferedcollide)
|
if(!m_deferedcollide)
|
||||||
{
|
{
|
||||||
b3DbvtTreeCollider collider(this);
|
b3DbvtTreeCollider collider(this);
|
||||||
@@ -198,7 +198,7 @@ void b3DynamicBvhBroadphase::destroyProxy( b3BroadphaseProxy* absproxy,
|
|||||||
m_sets[1].remove(proxy->leaf);
|
m_sets[1].remove(proxy->leaf);
|
||||||
else
|
else
|
||||||
m_sets[0].remove(proxy->leaf);
|
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_paircache->removeOverlappingPairsContainingProxy(proxy->getUid(),dispatcher);
|
||||||
|
|
||||||
m_needcleanup=true;
|
m_needcleanup=true;
|
||||||
@@ -270,7 +270,7 @@ void b3DynamicBvhBroadphase::aabbTest(const b3Vector3& aabbMin,const b3Vector3&
|
|||||||
{
|
{
|
||||||
BroadphaseAabbTester callback(aabbCallback);
|
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
|
//process all children, that overlap with the given AABB bounds
|
||||||
m_sets[0].collideTV(m_sets[0].m_root,bounds,callback);
|
m_sets[0].collideTV(m_sets[0].m_root,bounds,callback);
|
||||||
m_sets[1].collideTV(m_sets[1].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*/)
|
b3Dispatcher* /*dispatcher*/)
|
||||||
{
|
{
|
||||||
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
|
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
|
||||||
ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
|
B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
|
||||||
#if DBVT_BP_PREVENTFALSEUPDATE
|
#if B3_DBVT_BP_PREVENTFALSEUPDATE
|
||||||
if(NotEqual(aabb,proxy->leaf->volume))
|
if(b3NotEqual(aabb,proxy->leaf->volume))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool docollide=false;
|
bool docollide=false;
|
||||||
@@ -301,7 +301,7 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy,
|
|||||||
else
|
else
|
||||||
{/* dynamic set */
|
{/* dynamic set */
|
||||||
++m_updates_call;
|
++m_updates_call;
|
||||||
if(Intersect(proxy->leaf->volume,aabb))
|
if(b3Intersect(proxy->leaf->volume,aabb))
|
||||||
{/* Moving */
|
{/* Moving */
|
||||||
|
|
||||||
const b3Vector3 delta=aabbMin-proxy->m_aabbMin;
|
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[1]<0) velocity[1]=-velocity[1];
|
||||||
if(delta[2]<0) velocity[2]=-velocity[2];
|
if(delta[2]<0) velocity[2]=-velocity[2];
|
||||||
if (
|
if (
|
||||||
#ifdef DBVT_BP_MARGIN
|
#ifdef B3_DBVT_BP_MARGIN
|
||||||
m_sets[0].update(proxy->leaf,aabb,velocity,DBVT_BP_MARGIN)
|
m_sets[0].update(proxy->leaf,aabb,velocity,B3_DBVT_BP_MARGIN)
|
||||||
#else
|
#else
|
||||||
m_sets[0].update(proxy->leaf,aabb,velocity)
|
m_sets[0].update(proxy->leaf,aabb,velocity)
|
||||||
#endif
|
#endif
|
||||||
@@ -328,11 +328,11 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy,
|
|||||||
docollide=true;
|
docollide=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listremove(proxy,m_stageRoots[proxy->stage]);
|
b3ListRemove(proxy,m_stageRoots[proxy->stage]);
|
||||||
proxy->m_aabbMin = aabbMin;
|
proxy->m_aabbMin = aabbMin;
|
||||||
proxy->m_aabbMax = aabbMax;
|
proxy->m_aabbMax = aabbMax;
|
||||||
proxy->stage = m_stageCurrent;
|
proxy->stage = m_stageCurrent;
|
||||||
listappend(proxy,m_stageRoots[m_stageCurrent]);
|
b3ListAppend(proxy,m_stageRoots[m_stageCurrent]);
|
||||||
if(docollide)
|
if(docollide)
|
||||||
{
|
{
|
||||||
m_needcleanup=true;
|
m_needcleanup=true;
|
||||||
@@ -354,7 +354,7 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* abspr
|
|||||||
b3Dispatcher* /*dispatcher*/)
|
b3Dispatcher* /*dispatcher*/)
|
||||||
{
|
{
|
||||||
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
|
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
|
||||||
ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
|
B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
|
||||||
bool docollide=false;
|
bool docollide=false;
|
||||||
if(proxy->stage==STAGECOUNT)
|
if(proxy->stage==STAGECOUNT)
|
||||||
{/* fixed -> dynamic set */
|
{/* fixed -> dynamic set */
|
||||||
@@ -370,11 +370,11 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* abspr
|
|||||||
++m_updates_done;
|
++m_updates_done;
|
||||||
docollide=true;
|
docollide=true;
|
||||||
}
|
}
|
||||||
listremove(proxy,m_stageRoots[proxy->stage]);
|
b3ListRemove(proxy,m_stageRoots[proxy->stage]);
|
||||||
proxy->m_aabbMin = aabbMin;
|
proxy->m_aabbMin = aabbMin;
|
||||||
proxy->m_aabbMax = aabbMax;
|
proxy->m_aabbMax = aabbMax;
|
||||||
proxy->stage = m_stageCurrent;
|
proxy->stage = m_stageCurrent;
|
||||||
listappend(proxy,m_stageRoots[m_stageCurrent]);
|
b3ListAppend(proxy,m_stageRoots[m_stageCurrent]);
|
||||||
if(docollide)
|
if(docollide)
|
||||||
{
|
{
|
||||||
m_needcleanup=true;
|
m_needcleanup=true;
|
||||||
@@ -391,22 +391,22 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* abspr
|
|||||||
void b3DynamicBvhBroadphase::calculateOverlappingPairs(b3Dispatcher* dispatcher)
|
void b3DynamicBvhBroadphase::calculateOverlappingPairs(b3Dispatcher* dispatcher)
|
||||||
{
|
{
|
||||||
collide(dispatcher);
|
collide(dispatcher);
|
||||||
#if DBVT_BP_PROFILE
|
#if B3_DBVT_BP_PROFILE
|
||||||
if(0==(m_pid%DBVT_BP_PROFILING_RATE))
|
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());
|
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;
|
unsigned int total=m_profiling.m_total;
|
||||||
if(total<=0) total=1;
|
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("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/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/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/DBVT_BP_PROFILING_RATE);
|
printf("total: %uus\r\n",total/B3_DBVT_BP_PROFILING_RATE);
|
||||||
const unsigned long sum=m_profiling.m_ddcollide+
|
const unsigned long sum=m_profiling.m_ddcollide+
|
||||||
m_profiling.m_fdcollide+
|
m_profiling.m_fdcollide+
|
||||||
m_profiling.m_cleanup;
|
m_profiling.m_cleanup;
|
||||||
printf("leaked: %u%% (%uus)\r\n",100-((50+sum*100)/total),(total-sum)/DBVT_BP_PROFILING_RATE);
|
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)*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));
|
||||||
clear(m_profiling);
|
b3Clear(m_profiling);
|
||||||
m_clock.reset();
|
m_clock.reset();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -451,7 +451,7 @@ void b3DynamicBvhBroadphase::performDeferredRemoval(b3Dispatcher* dispatcher)
|
|||||||
//important to perform AABB check that is consistent with the broadphase
|
//important to perform AABB check that is consistent with the broadphase
|
||||||
b3DbvtProxy* pa=&m_proxies[pair.x];
|
b3DbvtProxy* pa=&m_proxies[pair.x];
|
||||||
b3DbvtProxy* pb=&m_proxies[pair.y];
|
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)
|
if (hasOverlap)
|
||||||
{
|
{
|
||||||
@@ -504,7 +504,7 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
SPC(m_profiling.m_total);
|
b3SPC(m_profiling.m_total);
|
||||||
/* optimize */
|
/* optimize */
|
||||||
m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100);
|
m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100);
|
||||||
if(m_fixedleft)
|
if(m_fixedleft)
|
||||||
@@ -521,16 +521,16 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher)
|
|||||||
b3DbvtTreeCollider collider(this);
|
b3DbvtTreeCollider collider(this);
|
||||||
do {
|
do {
|
||||||
b3DbvtProxy* next=current->links[1];
|
b3DbvtProxy* next=current->links[1];
|
||||||
listremove(current,m_stageRoots[current->stage]);
|
b3ListRemove(current,m_stageRoots[current->stage]);
|
||||||
listappend(current,m_stageRoots[STAGECOUNT]);
|
b3ListAppend(current,m_stageRoots[STAGECOUNT]);
|
||||||
#if DBVT_BP_ACCURATESLEEPING
|
#if B3_DBVT_BP_ACCURATESLEEPING
|
||||||
m_paircache->removeOverlappingPairsContainingProxy(current,dispatcher);
|
m_paircache->removeOverlappingPairsContainingProxy(current,dispatcher);
|
||||||
collider.proxy=current;
|
collider.proxy=current;
|
||||||
b3DynamicBvh::collideTV(m_sets[0].m_root,current->aabb,collider);
|
b3DynamicBvh::collideTV(m_sets[0].m_root,current->aabb,collider);
|
||||||
b3DynamicBvh::collideTV(m_sets[1].m_root,current->aabb,collider);
|
b3DynamicBvh::collideTV(m_sets[1].m_root,current->aabb,collider);
|
||||||
#endif
|
#endif
|
||||||
m_sets[0].remove(current->leaf);
|
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->leaf = m_sets[1].insert(curAabb,current);
|
||||||
current->stage = STAGECOUNT;
|
current->stage = STAGECOUNT;
|
||||||
current = next;
|
current = next;
|
||||||
@@ -543,19 +543,19 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher)
|
|||||||
b3DbvtTreeCollider collider(this);
|
b3DbvtTreeCollider collider(this);
|
||||||
if(m_deferedcollide)
|
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);
|
m_sets[0].collideTTpersistentStack(m_sets[0].m_root,m_sets[1].m_root,collider);
|
||||||
}
|
}
|
||||||
if(m_deferedcollide)
|
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);
|
m_sets[0].collideTTpersistentStack(m_sets[0].m_root,m_sets[0].m_root,collider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* clean up */
|
/* clean up */
|
||||||
if(m_needcleanup)
|
if(m_needcleanup)
|
||||||
{
|
{
|
||||||
SPC(m_profiling.m_cleanup);
|
b3SPC(m_profiling.m_cleanup);
|
||||||
b3BroadphasePairArray& pairs=m_paircache->getOverlappingPairArray();
|
b3BroadphasePairArray& pairs=m_paircache->getOverlappingPairArray();
|
||||||
if(pairs.size()>0)
|
if(pairs.size()>0)
|
||||||
{
|
{
|
||||||
@@ -566,9 +566,9 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher)
|
|||||||
b3BroadphasePair& p=pairs[(m_cid+i)%pairs.size()];
|
b3BroadphasePair& p=pairs[(m_cid+i)%pairs.size()];
|
||||||
b3DbvtProxy* pa=&m_proxies[p.x];
|
b3DbvtProxy* pa=&m_proxies[p.x];
|
||||||
b3DbvtProxy* pb=&m_proxies[p.y];
|
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)
|
if(pa->m_uniqueId>pb->m_uniqueId)
|
||||||
b3Swap(pa,pb);
|
b3Swap(pa,pb);
|
||||||
#endif
|
#endif
|
||||||
@@ -613,10 +613,10 @@ const b3OverlappingPairCache* b3DynamicBvhBroadphase::getOverlappingPairCache()
|
|||||||
void b3DynamicBvhBroadphase::getBroadphaseAabb(b3Vector3& aabbMin,b3Vector3& aabbMax) const
|
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[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);
|
m_sets[1].m_root->volume,bounds);
|
||||||
else
|
else
|
||||||
bounds=m_sets[0].m_root->volume;
|
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
|
struct b3BroadphaseBenchmark
|
||||||
{
|
{
|
||||||
@@ -788,7 +788,7 @@ void b3DynamicBvhBroadphase::benchmark(b3BroadphaseInterface* pbi)
|
|||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DBVT_BP_PROFILE
|
#if B3_DBVT_BP_PROFILE
|
||||||
#undef SPC
|
#undef b3SPC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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
|
// Compile time config
|
||||||
//
|
//
|
||||||
|
|
||||||
#define DBVT_BP_PROFILE 0
|
#define B3_DBVT_BP_PROFILE 0
|
||||||
//#define DBVT_BP_SORTPAIRS 1
|
//#define B3_DBVT_BP_SORTPAIRS 1
|
||||||
#define DBVT_BP_PREVENTFALSEUPDATE 0
|
#define B3_DBVT_BP_PREVENTFALSEUPDATE 0
|
||||||
#define DBVT_BP_ACCURATESLEEPING 0
|
#define B3_DBVT_BP_ACCURATESLEEPING 0
|
||||||
#define DBVT_BP_ENABLE_BENCHMARK 0
|
#define B3_DBVT_BP_ENABLE_BENCHMARK 0
|
||||||
#define DBVT_BP_MARGIN (b3Scalar)0.05
|
#define B3_DBVT_BP_MARGIN (b3Scalar)0.05
|
||||||
|
|
||||||
#if DBVT_BP_PROFILE
|
#if B3_DBVT_BP_PROFILE
|
||||||
#define DBVT_BP_PROFILING_RATE 256
|
#define B3_DBVT_BP_PROFILING_RATE 256
|
||||||
#include "LinearMath/b3Quickprof.h"
|
#include "LinearMath/b3Quickprof.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) b3BroadphaseProxy
|
B3_ATTRIBUTE_ALIGNED16(struct) b3BroadphaseProxy
|
||||||
{
|
{
|
||||||
|
|
||||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
@@ -69,7 +69,7 @@ B3_DECLARE_ALIGNED_ALLOCATOR();
|
|||||||
b3Vector3 m_aabbMin;
|
b3Vector3 m_aabbMin;
|
||||||
b3Vector3 m_aabbMax;
|
b3Vector3 m_aabbMax;
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int getUid() const
|
B3_FORCE_INLINE int getUid() const
|
||||||
{
|
{
|
||||||
return m_uniqueId;
|
return m_uniqueId;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ struct b3DynamicBvhBroadphase
|
|||||||
bool m_releasepaircache; // Release pair cache on delete
|
bool m_releasepaircache; // Release pair cache on delete
|
||||||
bool m_deferedcollide; // Defere dynamic/static collision to collide call
|
bool m_deferedcollide; // Defere dynamic/static collision to collide call
|
||||||
bool m_needcleanup; // Need to run cleanup?
|
bool m_needcleanup; // Need to run cleanup?
|
||||||
#if DBVT_BP_PROFILE
|
#if B3_DBVT_BP_PROFILE
|
||||||
b3Clock m_clock;
|
b3Clock m_clock;
|
||||||
struct {
|
struct {
|
||||||
unsigned long m_total;
|
unsigned long m_total;
|
||||||
|
|||||||
@@ -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
|
#ifndef B3_OVERLAPPING_PAIR_H
|
||||||
#define 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 );
|
return (a.x == b.x ) && (a.y == b.y );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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 <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int gOverlappingPairs = 0;
|
int b3g_overlappingPairs = 0;
|
||||||
|
int b3g_removePairs =0;
|
||||||
int gRemovePairs =0;
|
int b3g_addedPairs =0;
|
||||||
int gAddedPairs =0;
|
int b3g_findPairs =0;
|
||||||
int gFindPairs =0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -136,7 +135,7 @@ void b3HashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro
|
|||||||
|
|
||||||
b3BroadphasePair* b3HashedOverlappingPairCache::findPair(int proxy0, int proxy1)
|
b3BroadphasePair* b3HashedOverlappingPairCache::findPair(int proxy0, int proxy1)
|
||||||
{
|
{
|
||||||
gFindPairs++;
|
b3g_findPairs++;
|
||||||
if(proxy0 >proxy1)
|
if(proxy0 >proxy1)
|
||||||
b3Swap(proxy0,proxy1);
|
b3Swap(proxy0,proxy1);
|
||||||
int proxyId1 = proxy0;
|
int proxyId1 = proxy0;
|
||||||
@@ -274,7 +273,7 @@ b3BroadphasePair* b3HashedOverlappingPairCache::internalAddPair(int proxy0, int
|
|||||||
|
|
||||||
void* b3HashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1,b3Dispatcher* dispatcher)
|
void* b3HashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1,b3Dispatcher* dispatcher)
|
||||||
{
|
{
|
||||||
gRemovePairs++;
|
b3g_removePairs++;
|
||||||
if(proxy0>proxy1)
|
if(proxy0>proxy1)
|
||||||
b3Swap(proxy0,proxy1);
|
b3Swap(proxy0,proxy1);
|
||||||
int proxyId1 = proxy0;
|
int proxyId1 = proxy0;
|
||||||
@@ -387,7 +386,7 @@ void b3HashedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback*
|
|||||||
{
|
{
|
||||||
removeOverlappingPair(pair->x,pair->y,dispatcher);
|
removeOverlappingPair(pair->x,pair->y,dispatcher);
|
||||||
|
|
||||||
gOverlappingPairs--;
|
b3g_overlappingPairs--;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@@ -440,7 +439,7 @@ void* b3SortedOverlappingPairCache::removeOverlappingPair(int proxy0,int proxy1,
|
|||||||
int findIndex = m_overlappingPairArray.findLinearSearch(findPair);
|
int findIndex = m_overlappingPairArray.findLinearSearch(findPair);
|
||||||
if (findIndex < m_overlappingPairArray.size())
|
if (findIndex < m_overlappingPairArray.size())
|
||||||
{
|
{
|
||||||
gOverlappingPairs--;
|
b3g_overlappingPairs--;
|
||||||
b3BroadphasePair& pair = m_overlappingPairArray[findIndex];
|
b3BroadphasePair& pair = m_overlappingPairArray[findIndex];
|
||||||
|
|
||||||
cleanOverlappingPair(pair,dispatcher);
|
cleanOverlappingPair(pair,dispatcher);
|
||||||
@@ -475,8 +474,8 @@ b3BroadphasePair* b3SortedOverlappingPairCache::addOverlappingPair(int proxy0,in
|
|||||||
b3BroadphasePair* pair = new (mem) b3BroadphasePair(proxy0,proxy1);
|
b3BroadphasePair* pair = new (mem) b3BroadphasePair(proxy0,proxy1);
|
||||||
|
|
||||||
|
|
||||||
gOverlappingPairs++;
|
b3g_overlappingPairs++;
|
||||||
gAddedPairs++;
|
b3g_addedPairs++;
|
||||||
|
|
||||||
// if (m_ghostPairCallback)
|
// if (m_ghostPairCallback)
|
||||||
// m_ghostPairCallback->addOverlappingPair(proxy0, proxy1);
|
// m_ghostPairCallback->addOverlappingPair(proxy0, proxy1);
|
||||||
@@ -532,7 +531,7 @@ void b3SortedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback*
|
|||||||
pair->y = -1;
|
pair->y = -1;
|
||||||
m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||||
m_overlappingPairArray.pop_back();
|
m_overlappingPairArray.pop_back();
|
||||||
gOverlappingPairs--;
|
b3g_overlappingPairs--;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@@ -565,7 +564,7 @@ void b3SortedOverlappingPairCache::cleanOverlappingPair(b3BroadphasePair& pair,b
|
|||||||
pair.m_algorithm->~b3CollisionAlgorithm();
|
pair.m_algorithm->~b3CollisionAlgorithm();
|
||||||
dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
|
dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
|
||||||
pair.m_algorithm=0;
|
pair.m_algorithm=0;
|
||||||
gRemovePairs--;
|
b3g_removePairs--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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 b3g_removePairs;
|
||||||
extern int gAddedPairs;
|
extern int b3g_addedPairs;
|
||||||
extern int gFindPairs;
|
extern int b3g_findPairs;
|
||||||
|
|
||||||
const int B3_NULL_PAIR=0xffffffff;
|
const int B3_NULL_PAIR=0xffffffff;
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
|
|
||||||
virtual void* removeOverlappingPair(int proxy0,int proxy1,b3Dispatcher* dispatcher);
|
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)
|
if (m_overlapFilterCallback)
|
||||||
return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
|
return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
|
||||||
@@ -125,7 +125,7 @@ public:
|
|||||||
// no new pair is created and the old one is returned.
|
// no new pair is created and the old one is returned.
|
||||||
virtual b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1)
|
virtual b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1)
|
||||||
{
|
{
|
||||||
gAddedPairs++;
|
b3g_addedPairs++;
|
||||||
|
|
||||||
if (!needsBroadphaseCollision(proxy0,proxy1))
|
if (!needsBroadphaseCollision(proxy0,proxy1))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -189,7 +189,7 @@ private:
|
|||||||
|
|
||||||
void growTables();
|
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;
|
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
|
// Thomas Wang's hash, see: http://www.concentric.net/~Ttwang/tech/inthash.htm
|
||||||
// This assumes proxyId1 and proxyId2 are 16-bit.
|
// 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;
|
int key = (proxyId2 << 16) | proxyId1;
|
||||||
key = ~key + (key << 15);
|
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<int>(((unsigned int)proxyId1) | (((unsigned int)proxyId2) <<16));
|
int key = static_cast<int>(((unsigned int)proxyId1) | (((unsigned int)proxyId2) <<16));
|
||||||
// Thomas Wang's hash
|
// 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 proxyId1 = proxy0;
|
||||||
int proxyId2 = proxy1;
|
int proxyId2 = proxy1;
|
||||||
|
|||||||
@@ -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
|
#ifndef B3_CONTACT4_H
|
||||||
#define B3_CONTACT4_H
|
#define B3_CONTACT4_H
|
||||||
|
|
||||||
#include "Bullet3Common/b3Vector3.h"
|
#include "Bullet3Common/b3Vector3.h"
|
||||||
|
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) b3Contact4
|
B3_ATTRIBUTE_ALIGNED16(struct) b3Contact4
|
||||||
{
|
{
|
||||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
#ifndef B3_RIGID_BODY_CL
|
||||||
#define B3_RIGID_BODY_CL
|
#define B3_RIGID_BODY_CL
|
||||||
|
|
||||||
#include "Bullet3Common/b3Scalar.h"
|
#include "Bullet3Common/b3Scalar.h"
|
||||||
#include "Bullet3Common/b3Matrix3x3.h"
|
#include "Bullet3Common/b3Matrix3x3.h"
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL
|
B3_ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL
|
||||||
{
|
{
|
||||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
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.
|
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.
|
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"
|
#include "b3AlignedAllocator.h"
|
||||||
|
|
||||||
int gNumAlignedAllocs = 0;
|
int b3g_numAlignedAllocs = 0;
|
||||||
int gNumAlignedFree = 0;
|
int b3g_numAlignedFree = 0;
|
||||||
int gTotalBytesAlignedAllocs = 0;//detect memory leaks
|
int b3g_totalBytesAlignedAllocs = 0;//detect memory leaks
|
||||||
|
|
||||||
static void *b3AllocDefault(size_t size)
|
static void *b3AllocDefault(size_t size)
|
||||||
{
|
{
|
||||||
@@ -29,8 +29,8 @@ static void b3FreeDefault(void *ptr)
|
|||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static b3AllocFunc *sAllocFunc = b3AllocDefault;
|
static b3AllocFunc* b3s_allocFunc = b3AllocDefault;
|
||||||
static b3FreeFunc *sFreeFunc = b3FreeDefault;
|
static b3FreeFunc* b3s_freeFunc = b3FreeDefault;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ static inline void *b3AlignedAllocDefault(size_t size, int alignment)
|
|||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
char *real;
|
char *real;
|
||||||
real = (char *)sAllocFunc(size + sizeof(void *) + (alignment-1));
|
real = (char *)b3s_allocFunc(size + sizeof(void *) + (alignment-1));
|
||||||
if (real) {
|
if (real) {
|
||||||
ret = b3AlignPointer(real + sizeof(void *),alignment);
|
ret = b3AlignPointer(real + sizeof(void *),alignment);
|
||||||
*((void **)(ret)-1) = (void *)(real);
|
*((void **)(ret)-1) = (void *)(real);
|
||||||
@@ -83,25 +83,25 @@ static inline void b3AlignedFreeDefault(void *ptr)
|
|||||||
|
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
real = *((void **)(ptr)-1);
|
real = *((void **)(ptr)-1);
|
||||||
sFreeFunc(real);
|
b3s_freeFunc(real);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static b3AlignedAllocFunc *sAlignedAllocFunc = b3AlignedAllocDefault;
|
static b3AlignedAllocFunc* b3s_alignedAllocFunc = b3AlignedAllocDefault;
|
||||||
static b3AlignedFreeFunc *sAlignedFreeFunc = b3AlignedFreeDefault;
|
static b3AlignedFreeFunc* b3s_alignedFreeFunc = b3AlignedFreeDefault;
|
||||||
|
|
||||||
void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *allocFunc, b3AlignedFreeFunc *freeFunc)
|
void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *allocFunc, b3AlignedFreeFunc *freeFunc)
|
||||||
{
|
{
|
||||||
sAlignedAllocFunc = allocFunc ? allocFunc : b3AlignedAllocDefault;
|
b3s_alignedAllocFunc = allocFunc ? allocFunc : b3AlignedAllocDefault;
|
||||||
sAlignedFreeFunc = freeFunc ? freeFunc : b3AlignedFreeDefault;
|
b3s_alignedFreeFunc = freeFunc ? freeFunc : b3AlignedFreeDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
void b3AlignedAllocSetCustom(b3AllocFunc *allocFunc, b3FreeFunc *freeFunc)
|
void b3AlignedAllocSetCustom(b3AllocFunc *allocFunc, b3FreeFunc *freeFunc)
|
||||||
{
|
{
|
||||||
sAllocFunc = allocFunc ? allocFunc : b3AllocDefault;
|
b3s_allocFunc = allocFunc ? allocFunc : b3AllocDefault;
|
||||||
sFreeFunc = freeFunc ? freeFunc : b3FreeDefault;
|
b3s_freeFunc = freeFunc ? freeFunc : b3FreeDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef B3_DEBUG_MEMORY_ALLOCATIONS
|
#ifdef B3_DEBUG_MEMORY_ALLOCATIONS
|
||||||
@@ -113,11 +113,11 @@ void* b3AlignedAllocInternal (size_t size, int alignment,int line,char* filen
|
|||||||
void *ret;
|
void *ret;
|
||||||
char *real;
|
char *real;
|
||||||
|
|
||||||
gTotalBytesAlignedAllocs += size;
|
b3g_totalBytesAlignedAllocs += size;
|
||||||
gNumAlignedAllocs++;
|
b3g_numAlignedAllocs++;
|
||||||
|
|
||||||
|
|
||||||
real = (char *)sAllocFunc(size + 2*sizeof(void *) + (alignment-1));
|
real = (char *)b3s_allocFunc(size + 2*sizeof(void *) + (alignment-1));
|
||||||
if (real) {
|
if (real) {
|
||||||
ret = (void*) b3AlignPointer(real + 2*sizeof(void *), alignment);
|
ret = (void*) b3AlignPointer(real + 2*sizeof(void *), alignment);
|
||||||
*((void **)(ret)-1) = (void *)(real);
|
*((void **)(ret)-1) = (void *)(real);
|
||||||
@@ -127,7 +127,7 @@ void* b3AlignedAllocInternal (size_t size, int alignment,int line,char* filen
|
|||||||
ret = (void *)(real);//??
|
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;
|
int* ptr = (int*)ret;
|
||||||
*ptr = 12;
|
*ptr = 12;
|
||||||
@@ -138,16 +138,16 @@ void b3AlignedFreeInternal (void* ptr,int line,char* filename)
|
|||||||
{
|
{
|
||||||
|
|
||||||
void* real;
|
void* real;
|
||||||
gNumAlignedFree++;
|
b3g_numAlignedFree++;
|
||||||
|
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
real = *((void **)(ptr)-1);
|
real = *((void **)(ptr)-1);
|
||||||
int size = *((int*)(ptr)-2);
|
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
|
} else
|
||||||
{
|
{
|
||||||
printf("NULL ptr\n");
|
printf("NULL ptr\n");
|
||||||
@@ -158,9 +158,9 @@ void b3AlignedFreeInternal (void* ptr,int line,char* filename)
|
|||||||
|
|
||||||
void* b3AlignedAllocInternal (size_t size, int alignment)
|
void* b3AlignedAllocInternal (size_t size, int alignment)
|
||||||
{
|
{
|
||||||
gNumAlignedAllocs++;
|
b3g_numAlignedAllocs++;
|
||||||
void* ptr;
|
void* ptr;
|
||||||
ptr = sAlignedAllocFunc(size, alignment);
|
ptr = b3s_alignedAllocFunc(size, alignment);
|
||||||
// printf("b3AlignedAllocInternal %d, %x\n",size,ptr);
|
// printf("b3AlignedAllocInternal %d, %x\n",size,ptr);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
@@ -172,9 +172,9 @@ void b3AlignedFreeInternal (void* ptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gNumAlignedFree++;
|
b3g_numAlignedFree++;
|
||||||
// printf("b3AlignedFreeInternal %x\n",ptr);
|
// printf("b3AlignedFreeInternal %x\n",ptr);
|
||||||
sAlignedFreeFunc(ptr);
|
b3s_alignedFreeFunc(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //B3_DEBUG_MEMORY_ALLOCATIONS
|
#endif //B3_DEBUG_MEMORY_ALLOCATIONS
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
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.
|
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.
|
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)
|
#define b3AlignedFree(ptr) b3AlignedFreeInternal(ptr)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
typedef int size_type;
|
typedef int btSizeType;
|
||||||
|
|
||||||
typedef void *(b3AlignedAllocFunc)(size_t size, int alignment);
|
typedef void *(b3AlignedAllocFunc)(size_t size, int alignment);
|
||||||
typedef void (b3AlignedFreeFunc)(void *memblock);
|
typedef void (b3AlignedFreeFunc)(void *memblock);
|
||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
|
|
||||||
pointer address ( reference ref ) const { return &ref; }
|
pointer address ( reference ref ) const { return &ref; }
|
||||||
const_pointer address ( const_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;
|
(void)hint;
|
||||||
return reinterpret_cast< pointer >(b3AlignedAlloc( sizeof(value_type) * n , Alignment ));
|
return reinterpret_cast< pointer >(b3AlignedAlloc( sizeof(value_type) * n , Alignment ));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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__
|
#ifndef B3_OBJECT_ARRAY__
|
||||||
#define 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"
|
#include "b3AlignedAllocator.h"
|
||||||
|
|
||||||
///If the platform doesn't support placement new, you can disable B3_USE_PLACEMENT_NEW
|
///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
|
#ifdef B3_ALLOW_ARRAY_COPY_OPERATOR
|
||||||
public:
|
public:
|
||||||
SIMD_FORCE_INLINE b3AlignedObjectArray<T>& operator=(const b3AlignedObjectArray<T> &other)
|
B3_FORCE_INLINE b3AlignedObjectArray<T>& operator=(const b3AlignedObjectArray<T> &other)
|
||||||
{
|
{
|
||||||
copyFromArray(other);
|
copyFromArray(other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#else//B3_ALLOW_ARRAY_COPY_OPERATOR
|
#else//B3_ALLOW_ARRAY_COPY_OPERATOR
|
||||||
private:
|
private:
|
||||||
SIMD_FORCE_INLINE b3AlignedObjectArray<T>& operator=(const b3AlignedObjectArray<T> &other);
|
B3_FORCE_INLINE b3AlignedObjectArray<T>& operator=(const b3AlignedObjectArray<T> &other);
|
||||||
#endif//B3_ALLOW_ARRAY_COPY_OPERATOR
|
#endif//B3_ALLOW_ARRAY_COPY_OPERATOR
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SIMD_FORCE_INLINE int allocSize(int size)
|
B3_FORCE_INLINE int allocSize(int size)
|
||||||
{
|
{
|
||||||
return (size ? size*2 : 1);
|
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;
|
int i;
|
||||||
for (i=start;i<end;++i)
|
for (i=start;i<end;++i)
|
||||||
@@ -82,7 +82,7 @@ protected:
|
|||||||
#endif //B3_USE_PLACEMENT_NEW
|
#endif //B3_USE_PLACEMENT_NEW
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void init()
|
B3_FORCE_INLINE void init()
|
||||||
{
|
{
|
||||||
//PCK: added this line
|
//PCK: added this line
|
||||||
m_ownsMemory = true;
|
m_ownsMemory = true;
|
||||||
@@ -90,7 +90,7 @@ protected:
|
|||||||
m_size = 0;
|
m_size = 0;
|
||||||
m_capacity = 0;
|
m_capacity = 0;
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE void destroy(int first,int last)
|
B3_FORCE_INLINE void destroy(int first,int last)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=first; i<last;i++)
|
for (i=first; i<last;i++)
|
||||||
@@ -99,14 +99,14 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void* allocate(int size)
|
B3_FORCE_INLINE void* allocate(int size)
|
||||||
{
|
{
|
||||||
if (size)
|
if (size)
|
||||||
return m_allocator.allocate(size);
|
return m_allocator.allocate(size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void deallocate()
|
B3_FORCE_INLINE void deallocate()
|
||||||
{
|
{
|
||||||
if(m_data) {
|
if(m_data) {
|
||||||
//PCK: enclosed the deallocation in this block
|
//PCK: enclosed the deallocation in this block
|
||||||
@@ -146,33 +146,33 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
/// return the number of elements in the array
|
/// return the number of elements in the array
|
||||||
SIMD_FORCE_INLINE int size() const
|
B3_FORCE_INLINE int size() const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE const T& at(int n) const
|
B3_FORCE_INLINE const T& at(int n) const
|
||||||
{
|
{
|
||||||
b3Assert(n>=0);
|
b3Assert(n>=0);
|
||||||
b3Assert(n<size());
|
b3Assert(n<size());
|
||||||
return m_data[n];
|
return m_data[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE T& at(int n)
|
B3_FORCE_INLINE T& at(int n)
|
||||||
{
|
{
|
||||||
b3Assert(n>=0);
|
b3Assert(n>=0);
|
||||||
b3Assert(n<size());
|
b3Assert(n<size());
|
||||||
return m_data[n];
|
return m_data[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE const T& operator[](int n) const
|
B3_FORCE_INLINE const T& operator[](int n) const
|
||||||
{
|
{
|
||||||
b3Assert(n>=0);
|
b3Assert(n>=0);
|
||||||
b3Assert(n<size());
|
b3Assert(n<size());
|
||||||
return m_data[n];
|
return m_data[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE T& operator[](int n)
|
B3_FORCE_INLINE T& operator[](int n)
|
||||||
{
|
{
|
||||||
b3Assert(n>=0);
|
b3Assert(n>=0);
|
||||||
b3Assert(n<size());
|
b3Assert(n<size());
|
||||||
@@ -181,7 +181,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
///clear the array, deallocated memory. Generally it is better to use array.resize(0), to reduce performance overhead of run-time memory (de)allocations.
|
///clear the array, deallocated memory. Generally it is better to use array.resize(0), to reduce performance overhead of run-time memory (de)allocations.
|
||||||
SIMD_FORCE_INLINE void clear()
|
B3_FORCE_INLINE void clear()
|
||||||
{
|
{
|
||||||
destroy(0,size());
|
destroy(0,size());
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ protected:
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void pop_back()
|
B3_FORCE_INLINE void pop_back()
|
||||||
{
|
{
|
||||||
b3Assert(m_size>0);
|
b3Assert(m_size>0);
|
||||||
m_size--;
|
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.
|
///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.
|
///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();
|
int curSize = size();
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ protected:
|
|||||||
m_size = newsize;
|
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();
|
int curSize = size();
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ protected:
|
|||||||
|
|
||||||
m_size = newsize;
|
m_size = newsize;
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE T& expandNonInitializing( )
|
B3_FORCE_INLINE T& expandNonInitializing( )
|
||||||
{
|
{
|
||||||
int sz = size();
|
int sz = size();
|
||||||
if( sz == capacity() )
|
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();
|
int sz = size();
|
||||||
if( sz == capacity() )
|
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();
|
int sz = size();
|
||||||
if( sz == capacity() )
|
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()
|
/// 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;
|
return m_capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void reserve(int _Count)
|
B3_FORCE_INLINE void reserve(int _Count)
|
||||||
{ // determine new minimum length of allocated storage
|
{ // determine new minimum length of allocated storage
|
||||||
if (capacity() < _Count)
|
if (capacity() < _Count)
|
||||||
{ // not enough room, reallocate
|
{ // not enough room, reallocate
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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;
|
const char* m_string;
|
||||||
unsigned int m_hash;
|
unsigned int m_hash;
|
||||||
|
|
||||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
B3_FORCE_INLINE unsigned int getHash()const
|
||||||
{
|
{
|
||||||
return m_hash;
|
return m_hash;
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ public:
|
|||||||
return getUid1() == other.getUid1();
|
return getUid1() == other.getUid1();
|
||||||
}
|
}
|
||||||
//to our success
|
//to our success
|
||||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
B3_FORCE_INLINE unsigned int getHash()const
|
||||||
{
|
{
|
||||||
int key = m_uid;
|
int key = m_uid;
|
||||||
// Thomas Wang's hash
|
// Thomas Wang's hash
|
||||||
@@ -136,7 +136,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//to our success
|
//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));
|
const bool VOID_IS_8 = ((sizeof(void*)==8));
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//to our success
|
//to our success
|
||||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
B3_FORCE_INLINE unsigned int getHash()const
|
||||||
{
|
{
|
||||||
int key = m_uid;
|
int key = m_uid;
|
||||||
// Thomas Wang's hash
|
// Thomas Wang's hash
|
||||||
@@ -204,7 +204,7 @@ public:
|
|||||||
return getUid1() == other.getUid1();
|
return getUid1() == other.getUid1();
|
||||||
}
|
}
|
||||||
//to our success
|
//to our success
|
||||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
B3_FORCE_INLINE unsigned int getHash()const
|
||||||
{
|
{
|
||||||
int key = m_uid;
|
int key = m_uid;
|
||||||
// Thomas Wang's hash
|
// Thomas Wang's hash
|
||||||
|
|||||||
@@ -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
|
#ifndef B3_INT2_H
|
||||||
#define B3_INT2_H
|
#define B3_INT2_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.
|
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.
|
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 <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef B3_USE_SSE
|
#ifdef B3_USE_SSE
|
||||||
//const __m128 ATTRIBUTE_ALIGNED16(v2220) = {2.0f, 2.0f, 2.0f, 0.0f};
|
//const __m128 B3_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(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(B3_USE_SSE) || defined(B3_USE_NEON)
|
#if defined(B3_USE_SSE) || defined(B3_USE_NEON)
|
||||||
const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v1000) = {1.0f, 0.0f, 0.0f, 0.0f};
|
const b3SimdFloat4 B3_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 B3_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(v0010) = {0.0f, 0.0f, 1.0f, 0.0f};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef B3_USE_DOUBLE_PRECISION
|
#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.
|
/**@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. */
|
* 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
|
///Data storage for the matrix, each vector is a row of the matrix
|
||||||
b3Vector3 m_el[3];
|
b3Vector3 m_el[3];
|
||||||
@@ -71,14 +71,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
#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[0].mVec128 = v0;
|
||||||
m_el[1].mVec128 = v1;
|
m_el[1].mVec128 = v1;
|
||||||
m_el[2].mVec128 = v2;
|
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[0] = v0;
|
||||||
m_el[1] = v1;
|
m_el[1] = v1;
|
||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy constructor
|
// 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[0].mVec128 = rhs.m_el[0].mVec128;
|
||||||
m_el[1].mVec128 = rhs.m_el[1].mVec128;
|
m_el[1].mVec128 = rhs.m_el[1].mVec128;
|
||||||
@@ -94,7 +94,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assignment Operator
|
// 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[0].mVec128 = m.m_el[0].mVec128;
|
||||||
m_el[1].mVec128 = m.m_el[1].mVec128;
|
m_el[1].mVec128 = m.m_el[1].mVec128;
|
||||||
@@ -106,7 +106,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
/** @brief Copy constructor */
|
/** @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[0] = other.m_el[0];
|
||||||
m_el[1] = other.m_el[1];
|
m_el[1] = other.m_el[1];
|
||||||
@@ -114,7 +114,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Assignment Operator */
|
/** @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[0] = other.m_el[0];
|
||||||
m_el[1] = other.m_el[1];
|
m_el[1] = other.m_el[1];
|
||||||
@@ -126,7 +126,7 @@ public:
|
|||||||
|
|
||||||
/** @brief Get a column of the matrix as a vector
|
/** @brief Get a column of the matrix as a vector
|
||||||
* @param i Column number 0 indexed */
|
* @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]);
|
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
|
/** @brief Get a row of the matrix as a vector
|
||||||
* @param i Row number 0 indexed */
|
* @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);
|
b3FullAssert(0 <= i && i < 3);
|
||||||
return m_el[i];
|
return m_el[i];
|
||||||
@@ -142,7 +142,7 @@ public:
|
|||||||
|
|
||||||
/** @brief Get a mutable reference to a row of the matrix as a vector
|
/** @brief Get a mutable reference to a row of the matrix as a vector
|
||||||
* @param i Row number 0 indexed */
|
* @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);
|
b3FullAssert(0 <= i && i < 3);
|
||||||
return m_el[i];
|
return m_el[i];
|
||||||
@@ -150,7 +150,7 @@ public:
|
|||||||
|
|
||||||
/** @brief Get a const reference to a row of the matrix as a vector
|
/** @brief Get a const reference to a row of the matrix as a vector
|
||||||
* @param i Row number 0 indexed */
|
* @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);
|
b3FullAssert(0 <= i && i < 3);
|
||||||
return m_el[i];
|
return m_el[i];
|
||||||
@@ -493,17 +493,17 @@ public:
|
|||||||
roll = b3Scalar(b3Atan2(m_el[2].getY(), m_el[2].getZ()));
|
roll = b3Scalar(b3Atan2(m_el[2].getY(), m_el[2].getZ()));
|
||||||
|
|
||||||
// on pitch = +/-HalfPI
|
// on pitch = +/-HalfPI
|
||||||
if (b3Fabs(pitch)==SIMD_HALF_PI)
|
if (b3Fabs(pitch)==B3_HALF_PI)
|
||||||
{
|
{
|
||||||
if (yaw>0)
|
if (yaw>0)
|
||||||
yaw-=SIMD_PI;
|
yaw-=B3_PI;
|
||||||
else
|
else
|
||||||
yaw+=SIMD_PI;
|
yaw+=B3_PI;
|
||||||
|
|
||||||
if (roll>0)
|
if (roll>0)
|
||||||
roll-=SIMD_PI;
|
roll-=B3_PI;
|
||||||
else
|
else
|
||||||
roll+=SIMD_PI;
|
roll+=B3_PI;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -536,15 +536,15 @@ public:
|
|||||||
b3Scalar delta = b3Atan2(m_el[0].getX(),m_el[0].getZ());
|
b3Scalar delta = b3Atan2(m_el[0].getX(),m_el[0].getZ());
|
||||||
if (m_el[2].getX() > 0) //gimbal locked up
|
if (m_el[2].getX() > 0) //gimbal locked up
|
||||||
{
|
{
|
||||||
euler_out.pitch = SIMD_PI / b3Scalar(2.0);
|
euler_out.pitch = B3_PI / b3Scalar(2.0);
|
||||||
euler_out2.pitch = SIMD_PI / b3Scalar(2.0);
|
euler_out2.pitch = B3_PI / b3Scalar(2.0);
|
||||||
euler_out.roll = euler_out.pitch + delta;
|
euler_out.roll = euler_out.pitch + delta;
|
||||||
euler_out2.roll = euler_out.pitch + delta;
|
euler_out2.roll = euler_out.pitch + delta;
|
||||||
}
|
}
|
||||||
else // gimbal locked down
|
else // gimbal locked down
|
||||||
{
|
{
|
||||||
euler_out.pitch = -SIMD_PI / b3Scalar(2.0);
|
euler_out.pitch = -B3_PI / b3Scalar(2.0);
|
||||||
euler_out2.pitch = -SIMD_PI / b3Scalar(2.0);
|
euler_out2.pitch = -B3_PI / b3Scalar(2.0);
|
||||||
euler_out.roll = -euler_out.pitch + delta;
|
euler_out.roll = -euler_out.pitch + delta;
|
||||||
euler_out2.roll = -euler_out.pitch + delta;
|
euler_out2.roll = -euler_out.pitch + delta;
|
||||||
}
|
}
|
||||||
@@ -552,7 +552,7 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
euler_out.pitch = - b3Asin(m_el[2].getX());
|
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),
|
euler_out.roll = b3Atan2(m_el[2].getY()/b3Cos(euler_out.pitch),
|
||||||
m_el[2].getZ()/b3Cos(euler_out.pitch));
|
m_el[2].getZ()/b3Cos(euler_out.pitch));
|
||||||
@@ -608,15 +608,15 @@ public:
|
|||||||
b3Matrix3x3 transposeTimes(const b3Matrix3x3& m) const;
|
b3Matrix3x3 transposeTimes(const b3Matrix3x3& m) const;
|
||||||
b3Matrix3x3 timesTranspose(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();
|
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();
|
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();
|
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]));
|
b3Scalar t = threshold * (b3Fabs(m_el[0][0]) + b3Fabs(m_el[1][1]) + b3Fabs(m_el[2][2]));
|
||||||
if (max <= t)
|
if (max <= t)
|
||||||
{
|
{
|
||||||
if (max <= SIMD_EPSILON * t)
|
if (max <= B3_EPSILON * t)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -673,7 +673,7 @@ public:
|
|||||||
b3Scalar theta2 = theta * theta;
|
b3Scalar theta2 = theta * theta;
|
||||||
b3Scalar cos;
|
b3Scalar cos;
|
||||||
b3Scalar sin;
|
b3Scalar sin;
|
||||||
if (theta2 * theta2 < b3Scalar(10 / SIMD_EPSILON))
|
if (theta2 * theta2 < b3Scalar(10 / B3_EPSILON))
|
||||||
{
|
{
|
||||||
t = (theta >= 0) ? 1 / (theta + b3Sqrt(1 + theta2))
|
t = (theta >= 0) ? 1 / (theta + b3Sqrt(1 + theta2))
|
||||||
: 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)
|
b3Matrix3x3::operator*=(const b3Matrix3x3& m)
|
||||||
{
|
{
|
||||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
@@ -827,7 +827,7 @@ b3Matrix3x3::operator*=(const b3Matrix3x3& m)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Matrix3x3&
|
B3_FORCE_INLINE b3Matrix3x3&
|
||||||
b3Matrix3x3::operator+=(const b3Matrix3x3& m)
|
b3Matrix3x3::operator+=(const b3Matrix3x3& m)
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
#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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Matrix3x3
|
B3_FORCE_INLINE b3Matrix3x3
|
||||||
operator*(const b3Matrix3x3& m, const b3Scalar & k)
|
operator*(const b3Matrix3x3& m, const b3Scalar & k)
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||||
@@ -871,7 +871,7 @@ operator*(const b3Matrix3x3& m, const b3Scalar & k)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Matrix3x3
|
B3_FORCE_INLINE b3Matrix3x3
|
||||||
operator+(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
operator+(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Matrix3x3
|
B3_FORCE_INLINE b3Matrix3x3
|
||||||
operator-(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
operator-(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
#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)
|
b3Matrix3x3::operator-=(const b3Matrix3x3& m)
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
#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
|
b3Matrix3x3::determinant() const
|
||||||
{
|
{
|
||||||
return b3Triple((*this)[0], (*this)[1], (*this)[2]);
|
return b3Triple((*this)[0], (*this)[1], (*this)[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Matrix3x3
|
B3_FORCE_INLINE b3Matrix3x3
|
||||||
b3Matrix3x3::absolute() const
|
b3Matrix3x3::absolute() const
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||||
@@ -971,7 +971,7 @@ b3Matrix3x3::absolute() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Matrix3x3
|
B3_FORCE_INLINE b3Matrix3x3
|
||||||
b3Matrix3x3::transpose() const
|
b3Matrix3x3::transpose() const
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||||
@@ -1008,7 +1008,7 @@ b3Matrix3x3::transpose() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Matrix3x3
|
B3_FORCE_INLINE b3Matrix3x3
|
||||||
b3Matrix3x3::adjoint() const
|
b3Matrix3x3::adjoint() const
|
||||||
{
|
{
|
||||||
return b3Matrix3x3(cofac(1, 1, 2, 2), cofac(0, 2, 2, 1), cofac(0, 1, 1, 2),
|
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));
|
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
|
b3Matrix3x3::inverse() const
|
||||||
{
|
{
|
||||||
b3Vector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1));
|
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);
|
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
|
b3Matrix3x3::transposeTimes(const b3Matrix3x3& m) const
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||||
@@ -1084,7 +1084,7 @@ b3Matrix3x3::transposeTimes(const b3Matrix3x3& m) const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Matrix3x3
|
B3_FORCE_INLINE b3Matrix3x3
|
||||||
b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const
|
b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||||
@@ -1137,7 +1137,7 @@ b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
operator*(const b3Matrix3x3& m, const b3Vector3& v)
|
operator*(const b3Matrix3x3& m, const b3Vector3& v)
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
#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)
|
operator*(const b3Vector3& v, const b3Matrix3x3& m)
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||||
@@ -1188,7 +1188,7 @@ operator*(const b3Vector3& v, const b3Matrix3x3& m)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Matrix3x3
|
B3_FORCE_INLINE b3Matrix3x3
|
||||||
operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||||
{
|
{
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
#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(
|
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][0] + m1[1][0] * m2[1][0] + m1[2][0] * m2[2][0],
|
||||||
m1[0][0] * m2[0][1] + m1[1][0] * m2[1][1] + m1[2][0] * m2[2][1],
|
m1[0][0] * m2[0][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
|
/**@brief Equality operator between two matrices
|
||||||
* It will test all elements are equal. */
|
* 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))
|
#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++)
|
for (int i=0;i<3;i++)
|
||||||
m_el[i].serialize(dataOut.m_el[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++)
|
for (int i=0;i<3;i++)
|
||||||
m_el[i].serializeFloat(dataOut.m_el[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++)
|
for (int i=0;i<3;i++)
|
||||||
m_el[i].deSerialize(dataIn.m_el[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++)
|
for (int i=0;i<3;i++)
|
||||||
m_el[i].deSerializeFloat(dataIn.m_el[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++)
|
for (int i=0;i<3;i++)
|
||||||
m_el[i].deSerializeDouble(dataIn.m_el[i]);
|
m_el[i].deSerializeDouble(dataIn.m_el[i]);
|
||||||
|
|||||||
@@ -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.
|
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.
|
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"
|
#include "b3Scalar.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
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 ;
|
return a < b ? a : b ;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
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;
|
return a > b ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
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);
|
return a < lb ? lb : (ub < a ? ub : a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
SIMD_FORCE_INLINE void b3SetMin(T& a, const T& b)
|
B3_FORCE_INLINE void b3SetMin(T& a, const T& b)
|
||||||
{
|
{
|
||||||
if (b < a)
|
if (b < a)
|
||||||
{
|
{
|
||||||
@@ -47,7 +47,7 @@ SIMD_FORCE_INLINE void b3SetMin(T& a, const T& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
SIMD_FORCE_INLINE void b3SetMax(T& a, const T& b)
|
B3_FORCE_INLINE void b3SetMax(T& a, const T& b)
|
||||||
{
|
{
|
||||||
if (a < b)
|
if (a < b)
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ SIMD_FORCE_INLINE void b3SetMax(T& a, const T& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
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)
|
if (a < lb)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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.
|
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.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|||||||
@@ -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.
|
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.
|
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.
|
* Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword.
|
||||||
*/
|
*/
|
||||||
#ifndef USE_LIBSPE2
|
#ifndef USE_LIBSPE2
|
||||||
ATTRIBUTE_ALIGNED16(class) b3QuadWord
|
B3_ATTRIBUTE_ALIGNED16(class) b3QuadWord
|
||||||
#else
|
#else
|
||||||
class b3QuadWord
|
class b3QuadWord
|
||||||
#endif
|
#endif
|
||||||
@@ -58,11 +58,11 @@ public:
|
|||||||
struct {b3Scalar x,y,z,w;};
|
struct {b3Scalar x,y,z,w;};
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
SIMD_FORCE_INLINE b3SimdFloat4 get128() const
|
B3_FORCE_INLINE b3SimdFloat4 get128() const
|
||||||
{
|
{
|
||||||
return mVec128;
|
return mVec128;
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE void set128(b3SimdFloat4 v128)
|
B3_FORCE_INLINE void set128(b3SimdFloat4 v128)
|
||||||
{
|
{
|
||||||
mVec128 = v128;
|
mVec128 = v128;
|
||||||
}
|
}
|
||||||
@@ -77,19 +77,19 @@ public:
|
|||||||
#if defined(B3_USE_SSE) || defined(B3_USE_NEON)
|
#if defined(B3_USE_SSE) || defined(B3_USE_NEON)
|
||||||
|
|
||||||
// Set Vector
|
// Set Vector
|
||||||
SIMD_FORCE_INLINE b3QuadWord(const b3SimdFloat4 vec)
|
B3_FORCE_INLINE b3QuadWord(const b3SimdFloat4 vec)
|
||||||
{
|
{
|
||||||
mVec128 = vec;
|
mVec128 = vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy constructor
|
// Copy constructor
|
||||||
SIMD_FORCE_INLINE b3QuadWord(const b3QuadWord& rhs)
|
B3_FORCE_INLINE b3QuadWord(const b3QuadWord& rhs)
|
||||||
{
|
{
|
||||||
mVec128 = rhs.mVec128;
|
mVec128 = rhs.mVec128;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assignment Operator
|
// Assignment Operator
|
||||||
SIMD_FORCE_INLINE b3QuadWord&
|
B3_FORCE_INLINE b3QuadWord&
|
||||||
operator=(const b3QuadWord& v)
|
operator=(const b3QuadWord& v)
|
||||||
{
|
{
|
||||||
mVec128 = v.mVec128;
|
mVec128 = v.mVec128;
|
||||||
@@ -100,29 +100,29 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**@brief Return the x value */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@brief Return the x value */
|
||||||
|
|
||||||
|
|
||||||
//SIMD_FORCE_INLINE b3Scalar& operator[](int i) { return (&m_floats[0])[i]; }
|
//B3_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 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.
|
///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]; }
|
B3_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; }
|
||||||
SIMD_FORCE_INLINE operator const b3Scalar *() const { 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
|
#ifdef B3_USE_SSE
|
||||||
return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128)));
|
return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128)));
|
||||||
@@ -134,7 +134,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE bool operator!=(const b3QuadWord& other) const
|
B3_FORCE_INLINE bool operator!=(const b3QuadWord& other) const
|
||||||
{
|
{
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ public:
|
|||||||
* @param y Value of y
|
* @param y Value of y
|
||||||
* @param z Value of z
|
* @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[0]=_x;
|
||||||
m_floats[1]=_y;
|
m_floats[1]=_y;
|
||||||
@@ -165,7 +165,7 @@ public:
|
|||||||
* @param z Value of z
|
* @param z Value of z
|
||||||
* @param w Value of w
|
* @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[0]=_x;
|
||||||
m_floats[1]=_y;
|
m_floats[1]=_y;
|
||||||
@@ -173,7 +173,7 @@ public:
|
|||||||
m_floats[3]=_w;
|
m_floats[3]=_w;
|
||||||
}
|
}
|
||||||
/**@brief No initialization constructor */
|
/**@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.))
|
// :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 y Value of y
|
||||||
* @param z Value of z
|
* @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;
|
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 z Value of z
|
||||||
* @param w Value of w
|
* @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;
|
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
|
/**@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
|
* @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
|
#ifdef B3_USE_SSE
|
||||||
mVec128 = _mm_max_ps(mVec128, other.mVec128);
|
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
|
/**@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
|
* @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
|
#ifdef B3_USE_SSE
|
||||||
mVec128 = _mm_min_ps(mVec128, other.mVec128);
|
mVec128 = _mm_min_ps(mVec128, other.mVec128);
|
||||||
|
|||||||
@@ -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.
|
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.
|
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
|
#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
|
#endif
|
||||||
|
|
||||||
#if defined(B3_USE_SSE) || defined(B3_USE_NEON)
|
#if defined(B3_USE_SSE) || defined(B3_USE_NEON)
|
||||||
|
|
||||||
const b3SimdFloat4 ATTRIBUTE_ALIGNED16(vQInv) = {-0.0f, -0.0f, -0.0f, +0.0f};
|
const b3SimdFloat4 B3_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(vPPPM) = {+0.0f, +0.0f, +0.0f, -0.0f};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -46,19 +46,19 @@ public:
|
|||||||
|
|
||||||
#if (defined(B3_USE_SSE_IN_API) && defined(B3_USE_SSE))|| defined(B3_USE_NEON)
|
#if (defined(B3_USE_SSE_IN_API) && defined(B3_USE_SSE))|| defined(B3_USE_NEON)
|
||||||
// Set Vector
|
// Set Vector
|
||||||
SIMD_FORCE_INLINE b3Quaternion(const b3SimdFloat4 vec)
|
B3_FORCE_INLINE b3Quaternion(const b3SimdFloat4 vec)
|
||||||
{
|
{
|
||||||
mVec128 = vec;
|
mVec128 = vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy constructor
|
// Copy constructor
|
||||||
SIMD_FORCE_INLINE b3Quaternion(const b3Quaternion& rhs)
|
B3_FORCE_INLINE b3Quaternion(const b3Quaternion& rhs)
|
||||||
{
|
{
|
||||||
mVec128 = rhs.mVec128;
|
mVec128 = rhs.mVec128;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assignment Operator
|
// Assignment Operator
|
||||||
SIMD_FORCE_INLINE b3Quaternion&
|
B3_FORCE_INLINE b3Quaternion&
|
||||||
operator=(const b3Quaternion& v)
|
operator=(const b3Quaternion& v)
|
||||||
{
|
{
|
||||||
mVec128 = v.mVec128;
|
mVec128 = v.mVec128;
|
||||||
@@ -148,7 +148,7 @@ public:
|
|||||||
}
|
}
|
||||||
/**@brief Add two quaternions
|
/**@brief Add two quaternions
|
||||||
* @param q The quaternion to add to this one */
|
* @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)
|
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
mVec128 = _mm_add_ps(mVec128, q.mVec128);
|
mVec128 = _mm_add_ps(mVec128, q.mVec128);
|
||||||
@@ -350,7 +350,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Return a scaled version of this quaternion
|
/**@brief Return a scaled version of this quaternion
|
||||||
* @param s The scale factor */
|
* @param s The scale factor */
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
operator*(const b3Scalar& s) const
|
operator*(const b3Scalar& s) const
|
||||||
{
|
{
|
||||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#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];
|
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
|
return b3Vector3(1.0, 0.0, 0.0); // Arbitrary
|
||||||
b3Scalar s = 1.f/b3Sqrt(s_squared);
|
b3Scalar s = 1.f/b3Sqrt(s_squared);
|
||||||
return b3Vector3(m_floats[0] * s, m_floats[1] * s, m_floats[2] * s);
|
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
|
/**@brief Return the sum of this quaternion and the other
|
||||||
* @param q2 The other quaternion */
|
* @param q2 The other quaternion */
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
operator+(const b3Quaternion& q2) const
|
operator+(const b3Quaternion& q2) const
|
||||||
{
|
{
|
||||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#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
|
/**@brief Return the difference between this quaternion and the other
|
||||||
* @param q2 The other quaternion */
|
* @param q2 The other quaternion */
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
operator-(const b3Quaternion& q2) const
|
operator-(const b3Quaternion& q2) const
|
||||||
{
|
{
|
||||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
@@ -456,7 +456,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Return the negative of this quaternion
|
/**@brief Return the negative of this quaternion
|
||||||
* This simply negates each element */
|
* 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)
|
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
return b3Quaternion(_mm_xor_ps(mVec128, b3vMzeroMask));
|
return b3Quaternion(_mm_xor_ps(mVec128, b3vMzeroMask));
|
||||||
@@ -468,7 +468,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/**@todo document this and it's use */
|
/**@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;
|
b3Quaternion diff,sum;
|
||||||
diff = *this - qd;
|
diff = *this - qd;
|
||||||
@@ -479,7 +479,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**@todo document this and it's use */
|
/**@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;
|
b3Quaternion diff,sum;
|
||||||
diff = *this - qd;
|
diff = *this - qd;
|
||||||
@@ -528,7 +528,7 @@ public:
|
|||||||
return identityQuat;
|
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 */
|
/**@brief Return the product of two quaternions */
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
operator*(const b3Quaternion& q1, const b3Quaternion& q2)
|
operator*(const b3Quaternion& q1, const b3Quaternion& q2)
|
||||||
{
|
{
|
||||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
@@ -626,7 +626,7 @@ operator*(const b3Quaternion& q1, const b3Quaternion& q2)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
operator*(const b3Quaternion& q, const b3Vector3& w)
|
operator*(const b3Quaternion& q, const b3Vector3& w)
|
||||||
{
|
{
|
||||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
@@ -709,7 +709,7 @@ operator*(const b3Quaternion& q, const b3Vector3& w)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
operator*(const b3Vector3& w, const b3Quaternion& q)
|
operator*(const b3Vector3& w, const b3Quaternion& q)
|
||||||
{
|
{
|
||||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#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 */
|
/**@brief Calculate the dot product between two quaternions */
|
||||||
SIMD_FORCE_INLINE b3Scalar
|
B3_FORCE_INLINE b3Scalar
|
||||||
dot(const b3Quaternion& q1, const b3Quaternion& q2)
|
b3Dot(const b3Quaternion& q1, const b3Quaternion& q2)
|
||||||
{
|
{
|
||||||
return q1.dot(q2);
|
return q1.dot(q2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**@brief Return the length of a quaternion */
|
/**@brief Return the length of a quaternion */
|
||||||
SIMD_FORCE_INLINE b3Scalar
|
B3_FORCE_INLINE b3Scalar
|
||||||
length(const b3Quaternion& q)
|
b3Length(const b3Quaternion& q)
|
||||||
{
|
{
|
||||||
return q.length();
|
return q.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the angle between two quaternions*/
|
/**@brief Return the angle between two quaternions*/
|
||||||
SIMD_FORCE_INLINE b3Scalar
|
B3_FORCE_INLINE b3Scalar
|
||||||
b3Angle(const b3Quaternion& q1, const b3Quaternion& q2)
|
b3Angle(const b3Quaternion& q1, const b3Quaternion& q2)
|
||||||
{
|
{
|
||||||
return q1.angle(q2);
|
return q1.angle(q2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the inverse of a quaternion*/
|
/**@brief Return the inverse of a quaternion*/
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
inverse(const b3Quaternion& q)
|
b3Inverse(const b3Quaternion& q)
|
||||||
{
|
{
|
||||||
return q.inverse();
|
return q.inverse();
|
||||||
}
|
}
|
||||||
@@ -826,14 +826,14 @@ inverse(const b3Quaternion& q)
|
|||||||
* @param q2 The second quaternion
|
* @param q2 The second quaternion
|
||||||
* @param t The ration between q1 and q2. t = 0 return q1, t=1 returns q2
|
* @param t The ration between q1 and q2. t = 0 return q1, t=1 returns q2
|
||||||
* Slerp assumes constant velocity between positions. */
|
* Slerp assumes constant velocity between positions. */
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
slerp(const b3Quaternion& q1, const b3Quaternion& q2, const b3Scalar& t)
|
b3Slerp(const b3Quaternion& q1, const b3Quaternion& q2, const b3Scalar& t)
|
||||||
{
|
{
|
||||||
return q1.slerp(q2, t);
|
return q1.slerp(q2, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
quatRotate(const b3Quaternion& rotation, const b3Vector3& v)
|
b3QuatRotate(const b3Quaternion& rotation, const b3Vector3& v)
|
||||||
{
|
{
|
||||||
b3Quaternion q = rotation * v;
|
b3Quaternion q = rotation * v;
|
||||||
q *= rotation.inverse();
|
q *= rotation.inverse();
|
||||||
@@ -846,13 +846,13 @@ quatRotate(const b3Quaternion& rotation, const b3Vector3& v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
shortestArcQuat(const b3Vector3& v0, const b3Vector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized
|
b3ShortestArcQuat(const b3Vector3& v0, const b3Vector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized
|
||||||
{
|
{
|
||||||
b3Vector3 c = v0.cross(v1);
|
b3Vector3 c = v0.cross(v1);
|
||||||
b3Scalar d = v0.dot(v1);
|
b3Scalar d = v0.dot(v1);
|
||||||
|
|
||||||
if (d < -1.0 + SIMD_EPSILON)
|
if (d < -1.0 + B3_EPSILON)
|
||||||
{
|
{
|
||||||
b3Vector3 n,unused;
|
b3Vector3 n,unused;
|
||||||
b3PlaneSpace1(v0,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);
|
return b3Quaternion(c.getX()*rs,c.getY()*rs,c.getZ()*rs,s * 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Quaternion
|
B3_FORCE_INLINE b3Quaternion
|
||||||
shortestArcQuatNormalize2(b3Vector3& v0,b3Vector3& v1)
|
b3ShortestArcQuatNormalize2(b3Vector3& v0,b3Vector3& v1)
|
||||||
{
|
{
|
||||||
v0.normalize();
|
v0.normalize();
|
||||||
v1.normalize();
|
v1.normalize();
|
||||||
return shortestArcQuat(v0,v1);
|
return b3ShortestArcQuat(v0,v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //B3_SIMD__QUATERNION_H_
|
#endif //B3_SIMD__QUATERNION_H_
|
||||||
|
|||||||
@@ -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).
|
// Ogre (www.ogre3d.org).
|
||||||
|
|
||||||
#include "b3Quickprof.h"
|
#include "b3Quickprof.h"
|
||||||
|
#include "b3MinMax.h"
|
||||||
|
|
||||||
#ifndef B3_NO_PROFILE
|
#ifndef B3_NO_PROFILE
|
||||||
|
|
||||||
|
|
||||||
static b3Clock gProfileClock;
|
static b3Clock b3s_profileClock;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __CELLOS_LV2__
|
#ifdef __CELLOS_LV2__
|
||||||
@@ -52,7 +67,7 @@ static b3Clock gProfileClock;
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
|
|
||||||
#define mymin(a,b) (a > b ? a : b)
|
|
||||||
|
|
||||||
struct b3ClockData
|
struct b3ClockData
|
||||||
{
|
{
|
||||||
@@ -141,7 +156,7 @@ unsigned long int b3Clock::getTimeMilliseconds()
|
|||||||
if (msecOff < -100 || msecOff > 100)
|
if (msecOff < -100 || msecOff > 100)
|
||||||
{
|
{
|
||||||
// Adjust the starting time forwards.
|
// Adjust the starting time forwards.
|
||||||
LONGLONG msecAdjustment = mymin(msecOff *
|
LONGLONG msecAdjustment = b3Min(msecOff *
|
||||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||||
m_data->mPrevElapsedTime);
|
m_data->mPrevElapsedTime);
|
||||||
m_data->mStartTime.QuadPart += msecAdjustment;
|
m_data->mStartTime.QuadPart += msecAdjustment;
|
||||||
@@ -199,7 +214,7 @@ unsigned long int b3Clock::getTimeMicroseconds()
|
|||||||
if (msecOff < -100 || msecOff > 100)
|
if (msecOff < -100 || msecOff > 100)
|
||||||
{
|
{
|
||||||
// Adjust the starting time forwards.
|
// Adjust the starting time forwards.
|
||||||
LONGLONG msecAdjustment = mymin(msecOff *
|
LONGLONG msecAdjustment = b3Min(msecOff *
|
||||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||||
m_data->mPrevElapsedTime);
|
m_data->mPrevElapsedTime);
|
||||||
m_data->mStartTime.QuadPart += msecAdjustment;
|
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 1000000.f;
|
||||||
return 1000.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 *
|
* The name is assumed to be a static pointer, only the pointer is stored and compared for *
|
||||||
* efficiency reasons. *
|
* efficiency reasons. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) :
|
b3ProfileNode::b3ProfileNode( const char * name, b3ProfileNode * parent ) :
|
||||||
Name( name ),
|
Name( name ),
|
||||||
TotalCalls( 0 ),
|
TotalCalls( 0 ),
|
||||||
TotalTime( 0 ),
|
TotalTime( 0 ),
|
||||||
@@ -283,7 +298,7 @@ CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CProfileNode::CleanupMemory()
|
void b3ProfileNode::CleanupMemory()
|
||||||
{
|
{
|
||||||
delete ( Child);
|
delete ( Child);
|
||||||
Child = NULL;
|
Child = NULL;
|
||||||
@@ -291,7 +306,7 @@ void CProfileNode::CleanupMemory()
|
|||||||
Sibling = NULL;
|
Sibling = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CProfileNode::~CProfileNode( void )
|
b3ProfileNode::~b3ProfileNode( void )
|
||||||
{
|
{
|
||||||
delete ( Child);
|
delete ( Child);
|
||||||
delete ( Sibling);
|
delete ( Sibling);
|
||||||
@@ -306,10 +321,10 @@ CProfileNode::~CProfileNode( void )
|
|||||||
* All profile names are assumed to be static strings so this function uses pointer compares *
|
* All profile names are assumed to be static strings so this function uses pointer compares *
|
||||||
* to find the named node. *
|
* 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
|
// Try to find this sub node
|
||||||
CProfileNode * child = Child;
|
b3ProfileNode * child = Child;
|
||||||
while ( child ) {
|
while ( child ) {
|
||||||
if ( child->Name == name ) {
|
if ( child->Name == name ) {
|
||||||
return child;
|
return child;
|
||||||
@@ -319,14 +334,14 @@ CProfileNode * CProfileNode::Get_Sub_Node( const char * name )
|
|||||||
|
|
||||||
// We didn't find it, so add it
|
// We didn't find it, so add it
|
||||||
|
|
||||||
CProfileNode * node = new CProfileNode( name, this );
|
b3ProfileNode * node = new b3ProfileNode( name, this );
|
||||||
node->Sibling = Child;
|
node->Sibling = Child;
|
||||||
Child = node;
|
Child = node;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CProfileNode::Reset( void )
|
void b3ProfileNode::Reset( void )
|
||||||
{
|
{
|
||||||
TotalCalls = 0;
|
TotalCalls = 0;
|
||||||
TotalTime = 0.0f;
|
TotalTime = 0.0f;
|
||||||
@@ -341,22 +356,22 @@ void CProfileNode::Reset( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CProfileNode::Call( void )
|
void b3ProfileNode::Call( void )
|
||||||
{
|
{
|
||||||
TotalCalls++;
|
TotalCalls++;
|
||||||
if (RecursionCounter++ == 0) {
|
if (RecursionCounter++ == 0) {
|
||||||
Profile_Get_Ticks(&StartTime);
|
b3Profile_Get_Ticks(&StartTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CProfileNode::Return( void )
|
bool b3ProfileNode::Return( void )
|
||||||
{
|
{
|
||||||
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
||||||
unsigned long int time;
|
unsigned long int time;
|
||||||
Profile_Get_Ticks(&time);
|
b3Profile_Get_Ticks(&time);
|
||||||
time-=StartTime;
|
time-=StartTime;
|
||||||
TotalTime += (float)time / Profile_Get_Tick_Rate();
|
TotalTime += (float)time / b3Profile_Get_Tick_Rate();
|
||||||
}
|
}
|
||||||
return ( RecursionCounter == 0 );
|
return ( RecursionCounter == 0 );
|
||||||
}
|
}
|
||||||
@@ -364,35 +379,35 @@ bool CProfileNode::Return( void )
|
|||||||
|
|
||||||
/***************************************************************************************************
|
/***************************************************************************************************
|
||||||
**
|
**
|
||||||
** CProfileIterator
|
** b3ProfileIterator
|
||||||
**
|
**
|
||||||
***************************************************************************************************/
|
***************************************************************************************************/
|
||||||
CProfileIterator::CProfileIterator( CProfileNode * start )
|
b3ProfileIterator::b3ProfileIterator( b3ProfileNode * start )
|
||||||
{
|
{
|
||||||
CurrentParent = start;
|
CurrentParent = start;
|
||||||
CurrentChild = CurrentParent->Get_Child();
|
CurrentChild = CurrentParent->Get_Child();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CProfileIterator::First(void)
|
void b3ProfileIterator::First(void)
|
||||||
{
|
{
|
||||||
CurrentChild = CurrentParent->Get_Child();
|
CurrentChild = CurrentParent->Get_Child();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CProfileIterator::Next(void)
|
void b3ProfileIterator::Next(void)
|
||||||
{
|
{
|
||||||
CurrentChild = CurrentChild->Get_Sibling();
|
CurrentChild = CurrentChild->Get_Sibling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CProfileIterator::Is_Done(void)
|
bool b3ProfileIterator::Is_Done(void)
|
||||||
{
|
{
|
||||||
return CurrentChild == NULL;
|
return CurrentChild == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CProfileIterator::Enter_Child( int index )
|
void b3ProfileIterator::Enter_Child( int index )
|
||||||
{
|
{
|
||||||
CurrentChild = CurrentParent->Get_Child();
|
CurrentChild = CurrentParent->Get_Child();
|
||||||
while ( (CurrentChild != NULL) && (index != 0) ) {
|
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 ) {
|
if ( CurrentParent->Get_Parent() != NULL ) {
|
||||||
CurrentParent = CurrentParent->Get_Parent();
|
CurrentParent = CurrentParent->Get_Parent();
|
||||||
@@ -418,18 +433,18 @@ void CProfileIterator::Enter_Parent( void )
|
|||||||
|
|
||||||
/***************************************************************************************************
|
/***************************************************************************************************
|
||||||
**
|
**
|
||||||
** CProfileManager
|
** b3ProfileManager
|
||||||
**
|
**
|
||||||
***************************************************************************************************/
|
***************************************************************************************************/
|
||||||
|
|
||||||
CProfileNode CProfileManager::Root( "Root", NULL );
|
b3ProfileNode b3ProfileManager::Root( "Root", NULL );
|
||||||
CProfileNode * CProfileManager::CurrentNode = &CProfileManager::Root;
|
b3ProfileNode * b3ProfileManager::CurrentNode = &b3ProfileManager::Root;
|
||||||
int CProfileManager::FrameCounter = 0;
|
int b3ProfileManager::FrameCounter = 0;
|
||||||
unsigned long int CProfileManager::ResetTime = 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 *
|
* 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. *
|
* 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 string used is assumed to be a static string; pointer compares are used throughout *
|
||||||
* the profiling code for efficiency. *
|
* the profiling code for efficiency. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
void CProfileManager::Start_Profile( const char * name )
|
void b3ProfileManager::Start_Profile( const char * name )
|
||||||
{
|
{
|
||||||
if (name != CurrentNode->Get_Name()) {
|
if (name != CurrentNode->Get_Name()) {
|
||||||
CurrentNode = CurrentNode->Get_Sub_Node( 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
|
// Return will indicate whether we should back up to our parent (we may
|
||||||
// be profiling a recursive function)
|
// 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. *
|
* 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.Reset();
|
||||||
Root.Call();
|
Root.Call();
|
||||||
FrameCounter = 0;
|
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++;
|
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;
|
unsigned long int time;
|
||||||
Profile_Get_Ticks(&time);
|
b3Profile_Get_Ticks(&time);
|
||||||
time -= ResetTime;
|
time -= ResetTime;
|
||||||
return (float)time / Profile_Get_Tick_Rate();
|
return (float)time / b3Profile_Get_Tick_Rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spacing)
|
void b3ProfileManager::dumpRecursive(b3ProfileIterator* profileIterator, int spacing)
|
||||||
{
|
{
|
||||||
profileIterator->First();
|
profileIterator->First();
|
||||||
if (profileIterator->Is_Done())
|
if (profileIterator->Is_Done())
|
||||||
return;
|
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 i;
|
||||||
int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset();
|
int frames_since_reset = b3ProfileManager::Get_Frame_Count_Since_Reset();
|
||||||
for (i=0;i<spacing;i++) printf(".");
|
for (i=0;i<spacing;i++) printf(".");
|
||||||
printf("----------------------------------\n");
|
printf("----------------------------------\n");
|
||||||
for (i=0;i<spacing;i++) printf(".");
|
for (i=0;i<spacing;i++) printf(".");
|
||||||
@@ -524,7 +539,7 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
|||||||
numChildren++;
|
numChildren++;
|
||||||
float current_total_time = profileIterator->Get_Current_Total_Time();
|
float current_total_time = profileIterator->Get_Current_Total_Time();
|
||||||
accumulated_time += 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<spacing;i++) printf(".");
|
int i; for (i=0;i<spacing;i++) printf(".");
|
||||||
}
|
}
|
||||||
@@ -538,7 +553,7 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
|||||||
printf("what's wrong\n");
|
printf("what's wrong\n");
|
||||||
}
|
}
|
||||||
for (i=0;i<spacing;i++) printf(".");
|
for (i=0;i<spacing;i++) printf(".");
|
||||||
printf("%s (%.3f %%) :: %.3f ms\n", "Unaccounted:",parent_time > 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<numChildren;i++)
|
for (i=0;i<numChildren;i++)
|
||||||
{
|
{
|
||||||
@@ -550,14 +565,14 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CProfileManager::dumpAll()
|
void b3ProfileManager::dumpAll()
|
||||||
{
|
{
|
||||||
CProfileIterator* profileIterator = 0;
|
b3ProfileIterator* profileIterator = 0;
|
||||||
profileIterator = CProfileManager::Get_Iterator();
|
profileIterator = b3ProfileManager::Get_Iterator();
|
||||||
|
|
||||||
dumpRecursive(profileIterator,0);
|
dumpRecursive(profileIterator,0);
|
||||||
|
|
||||||
CProfileManager::Release_Iterator(profileIterator);
|
b3ProfileManager::Release_Iterator(profileIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,16 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
/***************************************************************************************************
|
/***************************************************************************************************
|
||||||
**
|
**
|
||||||
@@ -27,9 +40,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define USE_BT_CLOCK 1
|
#define B3_USE_CLOCK 1
|
||||||
|
|
||||||
#ifdef USE_BT_CLOCK
|
#ifdef B3_USE_CLOCK
|
||||||
|
|
||||||
///The b3Clock is a portable basic clock that measures accurate time in seconds, use for profiling.
|
///The b3Clock is a portable basic clock that measures accurate time in seconds, use for profiling.
|
||||||
class b3Clock
|
class b3Clock
|
||||||
@@ -56,23 +69,23 @@ private:
|
|||||||
struct b3ClockData* m_data;
|
struct b3ClockData* m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //USE_BT_CLOCK
|
#endif //B3_USE_CLOCK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///A node in the Profile Hierarchy Tree
|
///A node in the Profile Hierarchy Tree
|
||||||
class CProfileNode {
|
class b3ProfileNode {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CProfileNode( const char * name, CProfileNode * parent );
|
b3ProfileNode( const char * name, b3ProfileNode * parent );
|
||||||
~CProfileNode( void );
|
~b3ProfileNode( void );
|
||||||
|
|
||||||
CProfileNode * Get_Sub_Node( const char * name );
|
b3ProfileNode * Get_Sub_Node( const char * name );
|
||||||
|
|
||||||
CProfileNode * Get_Parent( void ) { return Parent; }
|
b3ProfileNode * Get_Parent( void ) { return Parent; }
|
||||||
CProfileNode * Get_Sibling( void ) { return Sibling; }
|
b3ProfileNode * Get_Sibling( void ) { return Sibling; }
|
||||||
CProfileNode * Get_Child( void ) { return Child; }
|
b3ProfileNode * Get_Child( void ) { return Child; }
|
||||||
|
|
||||||
void CleanupMemory();
|
void CleanupMemory();
|
||||||
void Reset( void );
|
void Reset( void );
|
||||||
@@ -92,14 +105,14 @@ protected:
|
|||||||
unsigned long int StartTime;
|
unsigned long int StartTime;
|
||||||
int RecursionCounter;
|
int RecursionCounter;
|
||||||
|
|
||||||
CProfileNode * Parent;
|
b3ProfileNode * Parent;
|
||||||
CProfileNode * Child;
|
b3ProfileNode * Child;
|
||||||
CProfileNode * Sibling;
|
b3ProfileNode * Sibling;
|
||||||
void* m_userPtr;
|
void* m_userPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
///An iterator to navigate through the tree
|
///An iterator to navigate through the tree
|
||||||
class CProfileIterator
|
class b3ProfileIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Access all the children of the current parent
|
// Access all the children of the current parent
|
||||||
@@ -128,17 +141,17 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
CProfileNode * CurrentParent;
|
b3ProfileNode * CurrentParent;
|
||||||
CProfileNode * CurrentChild;
|
b3ProfileNode * CurrentChild;
|
||||||
|
|
||||||
|
|
||||||
CProfileIterator( CProfileNode * start );
|
b3ProfileIterator( b3ProfileNode * start );
|
||||||
friend class CProfileManager;
|
friend class b3ProfileManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///The Manager for the Profile system
|
///The Manager for the Profile system
|
||||||
class CProfileManager {
|
class b3ProfileManager {
|
||||||
public:
|
public:
|
||||||
static void Start_Profile( const char * name );
|
static void Start_Profile( const char * name );
|
||||||
static void Stop_Profile( void );
|
static void Stop_Profile( void );
|
||||||
@@ -153,20 +166,20 @@ public:
|
|||||||
static int Get_Frame_Count_Since_Reset( void ) { return FrameCounter; }
|
static int Get_Frame_Count_Since_Reset( void ) { return FrameCounter; }
|
||||||
static float Get_Time_Since_Reset( void );
|
static float Get_Time_Since_Reset( void );
|
||||||
|
|
||||||
static CProfileIterator * Get_Iterator( void )
|
static b3ProfileIterator * Get_Iterator( void )
|
||||||
{
|
{
|
||||||
|
|
||||||
return new CProfileIterator( &Root );
|
return new b3ProfileIterator( &Root );
|
||||||
}
|
}
|
||||||
static void Release_Iterator( CProfileIterator * iterator ) { delete ( iterator); }
|
static void Release_Iterator( b3ProfileIterator * iterator ) { delete ( iterator); }
|
||||||
|
|
||||||
static void dumpRecursive(CProfileIterator* profileIterator, int spacing);
|
static void dumpRecursive(b3ProfileIterator* profileIterator, int spacing);
|
||||||
|
|
||||||
static void dumpAll();
|
static void dumpAll();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static CProfileNode Root;
|
static b3ProfileNode Root;
|
||||||
static CProfileNode * CurrentNode;
|
static b3ProfileNode * CurrentNode;
|
||||||
static int FrameCounter;
|
static int FrameCounter;
|
||||||
static unsigned long int ResetTime;
|
static unsigned long int ResetTime;
|
||||||
};
|
};
|
||||||
@@ -174,21 +187,21 @@ private:
|
|||||||
|
|
||||||
///ProfileSampleClass is a simple way to profile a function's scope
|
///ProfileSampleClass is a simple way to profile a function's scope
|
||||||
///Use the B3_PROFILE macro at the start of scope to time
|
///Use the B3_PROFILE macro at the start of scope to time
|
||||||
class CProfileSample {
|
class b3ProfileSample {
|
||||||
public:
|
public:
|
||||||
CProfileSample( const char * name )
|
b3ProfileSample( const char * name )
|
||||||
{
|
{
|
||||||
CProfileManager::Start_Profile( name );
|
b3ProfileManager::Start_Profile( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
~CProfileSample( void )
|
~b3ProfileSample( void )
|
||||||
{
|
{
|
||||||
CProfileManager::Stop_Profile();
|
b3ProfileManager::Stop_Profile();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define B3_PROFILE( name ) CProfileSample __profile( name )
|
#define B3_PROFILE( name ) b3ProfileSample __profile( name )
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
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.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
@@ -22,19 +22,19 @@ subject to the following restrictions:
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <mt19937.h>
|
#include <mt19937.h>
|
||||||
|
|
||||||
#define GEN_RAND_MAX UINT_MAX
|
#define B3_RAND_MAX UINT_MAX
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void GEN_srand(unsigned int seed) { init_genrand(seed); }
|
B3_FORCE_INLINE void b3Srand(unsigned int seed) { init_genrand(seed); }
|
||||||
SIMD_FORCE_INLINE unsigned int GEN_rand() { return genrand_int32(); }
|
B3_FORCE_INLINE unsigned int b3rand() { return genrand_int32(); }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define GEN_RAND_MAX RAND_MAX
|
#define B3_RAND_MAX RAND_MAX
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void GEN_srand(unsigned int seed) { srand(seed); }
|
B3_FORCE_INLINE void b3Srand(unsigned int seed) { srand(seed); }
|
||||||
SIMD_FORCE_INLINE unsigned int GEN_rand() { return rand(); }
|
B3_FORCE_INLINE unsigned int b3rand() { return rand(); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
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.
|
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)
|
#if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300)
|
||||||
|
|
||||||
#define SIMD_FORCE_INLINE inline
|
#define B3_FORCE_INLINE inline
|
||||||
#define ATTRIBUTE_ALIGNED16(a) a
|
#define B3_ATTRIBUTE_ALIGNED16(a) a
|
||||||
#define ATTRIBUTE_ALIGNED64(a) a
|
#define B3_ATTRIBUTE_ALIGNED64(a) a
|
||||||
#define ATTRIBUTE_ALIGNED128(a) a
|
#define B3_ATTRIBUTE_ALIGNED128(a) a
|
||||||
#else
|
#else
|
||||||
//#define B3_HAS_ALIGNED_ALLOCATOR
|
//#define B3_HAS_ALIGNED_ALLOCATOR
|
||||||
#pragma warning(disable : 4324) // disable padding warning
|
#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:4996) //Turn off warnings about deprecated C routines
|
||||||
// #pragma warning(disable:4786) // Disable the "debug name too long" warning
|
// #pragma warning(disable:4786) // Disable the "debug name too long" warning
|
||||||
|
|
||||||
#define SIMD_FORCE_INLINE __forceinline
|
#define B3_FORCE_INLINE __forceinline
|
||||||
#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
|
#define B3_ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
|
||||||
#define ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a
|
#define B3_ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a
|
||||||
#define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a
|
#define B3_ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
#define B3_USE_VMX128
|
#define B3_USE_VMX128
|
||||||
|
|
||||||
@@ -105,10 +105,10 @@ inline int b3GetVersion()
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#if defined (__CELLOS_LV2__)
|
#if defined (__CELLOS_LV2__)
|
||||||
#define SIMD_FORCE_INLINE inline __attribute__((always_inline))
|
#define B3_FORCE_INLINE inline __attribute__((always_inline))
|
||||||
#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||||
#define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||||
#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||||
#ifndef assert
|
#ifndef assert
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -134,10 +134,10 @@ inline int b3GetVersion()
|
|||||||
|
|
||||||
#ifdef USE_LIBSPE2
|
#ifdef USE_LIBSPE2
|
||||||
|
|
||||||
#define SIMD_FORCE_INLINE __inline
|
#define B3_FORCE_INLINE __inline
|
||||||
#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||||
#define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||||
#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||||
#ifndef assert
|
#ifndef assert
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -185,11 +185,11 @@ inline int b3GetVersion()
|
|||||||
#endif //__clang__
|
#endif //__clang__
|
||||||
#endif//__arm__
|
#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
|
///@todo: check out alignment methods for other platforms/compilers
|
||||||
#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||||
#define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||||
#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||||
#ifndef assert
|
#ifndef assert
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -219,14 +219,14 @@ inline int b3GetVersion()
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define SIMD_FORCE_INLINE inline
|
#define B3_FORCE_INLINE inline
|
||||||
///@todo: check out alignment methods for other platforms/compilers
|
///@todo: check out alignment methods for other platforms/compilers
|
||||||
///#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
///#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||||
///#define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
///#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||||
///#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
///#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||||
#define ATTRIBUTE_ALIGNED16(a) a
|
#define B3_ATTRIBUTE_ALIGNED16(a) a
|
||||||
#define ATTRIBUTE_ALIGNED64(a) a
|
#define B3_ATTRIBUTE_ALIGNED64(a) a
|
||||||
#define ATTRIBUTE_ALIGNED128(a) a
|
#define B3_ATTRIBUTE_ALIGNED128(a) a
|
||||||
#ifndef assert
|
#ifndef assert
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -326,36 +326,36 @@ typedef float32x4_t b3SimdFloat4;
|
|||||||
|
|
||||||
|
|
||||||
#define B3_DECLARE_ALIGNED_ALLOCATOR() \
|
#define B3_DECLARE_ALIGNED_ALLOCATOR() \
|
||||||
SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \
|
B3_FORCE_INLINE void* operator new(size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \
|
||||||
SIMD_FORCE_INLINE void operator delete(void* ptr) { b3AlignedFree(ptr); } \
|
B3_FORCE_INLINE void operator delete(void* ptr) { b3AlignedFree(ptr); } \
|
||||||
SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
|
B3_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
|
||||||
SIMD_FORCE_INLINE void operator delete(void*, void*) { } \
|
B3_FORCE_INLINE void operator delete(void*, void*) { } \
|
||||||
SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \
|
B3_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \
|
||||||
SIMD_FORCE_INLINE void operator delete[](void* ptr) { b3AlignedFree(ptr); } \
|
B3_FORCE_INLINE void operator delete[](void* ptr) { b3AlignedFree(ptr); } \
|
||||||
SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \
|
B3_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \
|
||||||
SIMD_FORCE_INLINE void operator delete[](void*, void*) { } \
|
B3_FORCE_INLINE void operator delete[](void*, void*) { } \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(B3_USE_DOUBLE_PRECISION) || defined(B3_FORCE_DOUBLE_FUNCTIONS)
|
#if defined(B3_USE_DOUBLE_PRECISION) || defined(B3_FORCE_DOUBLE_FUNCTIONS)
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar x) { return sqrt(x); }
|
B3_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar x) { return sqrt(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabs(x); }
|
B3_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabs(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cos(x); }
|
B3_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cos(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sin(x); }
|
B3_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sin(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tan(x); }
|
B3_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tan(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { if (x<b3Scalar(-1)) x=b3Scalar(-1); if (x>b3Scalar(1)) x=b3Scalar(1); return acos(x); }
|
B3_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { if (x<b3Scalar(-1)) x=b3Scalar(-1); if (x>b3Scalar(1)) x=b3Scalar(1); return acos(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { if (x<b3Scalar(-1)) x=b3Scalar(-1); if (x>b3Scalar(1)) x=b3Scalar(1); return asin(x); }
|
B3_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { if (x<b3Scalar(-1)) x=b3Scalar(-1); if (x>b3Scalar(1)) x=b3Scalar(1); return asin(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atan(x); }
|
B3_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atan(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2(x, y); }
|
B3_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2(x, y); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return exp(x); }
|
B3_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return exp(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return log(x); }
|
B3_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return log(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return pow(x,y); }
|
B3_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 b3Fmod(b3Scalar x,b3Scalar y) { return fmod(x,y); }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y)
|
B3_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y)
|
||||||
{
|
{
|
||||||
#ifdef USE_APPROXIMATION
|
#ifdef USE_APPROXIMATION
|
||||||
double x, z, tempf;
|
double x, z, tempf;
|
||||||
@@ -375,54 +375,54 @@ SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y)
|
|||||||
return sqrtf(y);
|
return sqrtf(y);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabsf(x); }
|
B3_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabsf(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cosf(x); }
|
B3_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cosf(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sinf(x); }
|
B3_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sinf(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tanf(x); }
|
B3_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tanf(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) {
|
B3_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) {
|
||||||
if (x<b3Scalar(-1))
|
if (x<b3Scalar(-1))
|
||||||
x=b3Scalar(-1);
|
x=b3Scalar(-1);
|
||||||
if (x>b3Scalar(1))
|
if (x>b3Scalar(1))
|
||||||
x=b3Scalar(1);
|
x=b3Scalar(1);
|
||||||
return acosf(x);
|
return acosf(x);
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) {
|
B3_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) {
|
||||||
if (x<b3Scalar(-1))
|
if (x<b3Scalar(-1))
|
||||||
x=b3Scalar(-1);
|
x=b3Scalar(-1);
|
||||||
if (x>b3Scalar(1))
|
if (x>b3Scalar(1))
|
||||||
x=b3Scalar(1);
|
x=b3Scalar(1);
|
||||||
return asinf(x);
|
return asinf(x);
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atanf(x); }
|
B3_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atanf(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2f(x, y); }
|
B3_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2f(x, y); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return expf(x); }
|
B3_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return expf(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return logf(x); }
|
B3_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return logf(x); }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return powf(x,y); }
|
B3_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 b3Fmod(b3Scalar x,b3Scalar y) { return fmodf(x,y); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SIMD_2_PI b3Scalar(6.283185307179586232)
|
#define B3_2_PI b3Scalar(6.283185307179586232)
|
||||||
#define SIMD_PI (SIMD_2_PI * b3Scalar(0.5))
|
#define B3_PI (B3_2_PI * b3Scalar(0.5))
|
||||||
#define SIMD_HALF_PI (SIMD_2_PI * b3Scalar(0.25))
|
#define B3_HALF_PI (B3_2_PI * b3Scalar(0.25))
|
||||||
#define SIMD_RADS_PER_DEG (SIMD_2_PI / b3Scalar(360.0))
|
#define B3_RADS_PER_DEG (B3_2_PI / b3Scalar(360.0))
|
||||||
#define SIMD_DEGS_PER_RAD (b3Scalar(360.0) / SIMD_2_PI)
|
#define B3_DEGS_PER_RAD (b3Scalar(360.0) / B3_2_PI)
|
||||||
#define SIMDSQRT12 b3Scalar(0.7071067811865475244008443621048490)
|
#define B3_SQRT12 b3Scalar(0.7071067811865475244008443621048490)
|
||||||
|
|
||||||
#define b3RecipSqrt(x) ((b3Scalar)(b3Scalar(1.0)/b3Sqrt(b3Scalar(x)))) /* reciprocal square root */
|
#define b3RecipSqrt(x) ((b3Scalar)(b3Scalar(1.0)/b3Sqrt(b3Scalar(x)))) /* reciprocal square root */
|
||||||
|
|
||||||
|
|
||||||
#ifdef B3_USE_DOUBLE_PRECISION
|
#ifdef B3_USE_DOUBLE_PRECISION
|
||||||
#define SIMD_EPSILON DBL_EPSILON
|
#define B3_EPSILON DBL_EPSILON
|
||||||
#define SIMD_INFINITY DBL_MAX
|
#define B3_INFINITY DBL_MAX
|
||||||
#else
|
#else
|
||||||
#define SIMD_EPSILON FLT_EPSILON
|
#define B3_EPSILON FLT_EPSILON
|
||||||
#define SIMD_INFINITY FLT_MAX
|
#define B3_INFINITY FLT_MAX
|
||||||
#endif
|
#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 coeff_2 = 3.0f * coeff_1;
|
||||||
b3Scalar abs_y = b3Fabs(y);
|
b3Scalar abs_y = b3Fabs(y);
|
||||||
b3Scalar angle;
|
b3Scalar angle;
|
||||||
@@ -436,27 +436,27 @@ SIMD_FORCE_INLINE b3Scalar b3Atan2Fast(b3Scalar y, b3Scalar x)
|
|||||||
return (y < 0.0f) ? -angle : angle;
|
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));
|
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));
|
return (!((a) <= eps));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int b3IsNegative(b3Scalar x) {
|
B3_FORCE_INLINE int b3IsNegative(b3Scalar x) {
|
||||||
return x < b3Scalar(0.0) ? 1 : 0;
|
return x < b3Scalar(0.0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Radians(b3Scalar x) { return x * SIMD_RADS_PER_DEG; }
|
B3_FORCE_INLINE b3Scalar b3Radians(b3Scalar x) { return x * B3_RADS_PER_DEG; }
|
||||||
SIMD_FORCE_INLINE b3Scalar b3Degrees(b3Scalar x) { return x * SIMD_DEGS_PER_RAD; }
|
B3_FORCE_INLINE b3Scalar b3Degrees(b3Scalar x) { return x * B3_DEGS_PER_RAD; }
|
||||||
|
|
||||||
#define B3_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
|
#define B3_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
|
||||||
|
|
||||||
#ifndef b3Fsel
|
#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;
|
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)
|
#define b3Fsels(a,b,c) (b3Scalar)b3Fsel(a,b,c)
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE bool b3MachineIsLittleEndian()
|
B3_FORCE_INLINE bool b3MachineIsLittleEndian()
|
||||||
{
|
{
|
||||||
long int i = 1;
|
long int i = 1;
|
||||||
const char *p = (const char *) &i;
|
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
|
///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
|
///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
|
// 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
|
// 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;
|
unsigned testEqz = ~testNz;
|
||||||
return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
|
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 testNz = (unsigned)(((int)condition | -(int)condition) >> 31);
|
||||||
unsigned testEqz = ~testNz;
|
unsigned testEqz = ~testNz;
|
||||||
return static_cast<int>((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
|
return static_cast<int>((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
|
#ifdef B3_HAVE_NATIVE_FSEL
|
||||||
return (float)b3Fsel((b3Scalar)condition - b3Scalar(1.0f), valueIfConditionNonZero, valueIfConditionZero);
|
return (float)b3Fsel((b3Scalar)condition - b3Scalar(1.0f), valueIfConditionNonZero, valueIfConditionZero);
|
||||||
@@ -503,7 +503,7 @@ SIMD_FORCE_INLINE float b3Select(unsigned condition, float valueIfConditionNonZe
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> SIMD_FORCE_INLINE void b3Swap(T& a, T& b)
|
template<typename T> B3_FORCE_INLINE void b3Swap(T& a, T& b)
|
||||||
{
|
{
|
||||||
T tmp = a;
|
T tmp = a;
|
||||||
a = b;
|
a = b;
|
||||||
@@ -512,22 +512,22 @@ template<typename T> SIMD_FORCE_INLINE void b3Swap(T& a, T& b)
|
|||||||
|
|
||||||
|
|
||||||
//PCK: endian swapping functions
|
//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));
|
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<unsigned short>(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
|
return static_cast<unsigned short>(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE unsigned b3SwapEndian(int val)
|
B3_FORCE_INLINE unsigned b3SwapEndian(int val)
|
||||||
{
|
{
|
||||||
return b3SwapEndian((unsigned)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);
|
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.
|
///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.
|
///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
|
///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 int a = 0;
|
||||||
unsigned char *dst = (unsigned char *)&a;
|
unsigned char *dst = (unsigned char *)&a;
|
||||||
@@ -552,7 +552,7 @@ SIMD_FORCE_INLINE unsigned int b3SwapEndianFloat(float d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unswap using char pointers
|
// unswap using char pointers
|
||||||
SIMD_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a)
|
B3_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a)
|
||||||
{
|
{
|
||||||
float d = 0.0f;
|
float d = 0.0f;
|
||||||
unsigned char *src = (unsigned char *)&a;
|
unsigned char *src = (unsigned char *)&a;
|
||||||
@@ -568,7 +568,7 @@ SIMD_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a)
|
|||||||
|
|
||||||
|
|
||||||
// swap using char pointers
|
// 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;
|
unsigned char *src = (unsigned char *)&d;
|
||||||
|
|
||||||
@@ -584,7 +584,7 @@ SIMD_FORCE_INLINE void b3SwapEndianDouble(double d, unsigned char* dst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unswap using char pointers
|
// 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;
|
double d = 0.0;
|
||||||
unsigned char *dst = (unsigned char *)&d;
|
unsigned char *dst = (unsigned char *)&d;
|
||||||
@@ -601,17 +601,17 @@ SIMD_FORCE_INLINE double b3UnswapEndianDouble(const unsigned char *src)
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns normalized value in range [-SIMD_PI, SIMD_PI]
|
// returns normalized value in range [-B3_PI, B3_PI]
|
||||||
SIMD_FORCE_INLINE b3Scalar b3NormalizeAngle(b3Scalar angleInRadians)
|
B3_FORCE_INLINE b3Scalar b3NormalizeAngle(b3Scalar angleInRadians)
|
||||||
{
|
{
|
||||||
angleInRadians = b3Fmod(angleInRadians, SIMD_2_PI);
|
angleInRadians = b3Fmod(angleInRadians, B3_2_PI);
|
||||||
if(angleInRadians < -SIMD_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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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.
|
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.
|
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);
|
return(0);
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE b3Block* beginBlock()
|
B3_FORCE_INLINE b3Block* beginBlock()
|
||||||
{
|
{
|
||||||
b3Block* pb = (b3Block*)allocate(sizeof(b3Block));
|
b3Block* pb = (b3Block*)allocate(sizeof(b3Block));
|
||||||
pb->previous = current;
|
pb->previous = current;
|
||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
current = pb;
|
current = pb;
|
||||||
return(pb);
|
return(pb);
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE void endBlock(b3Block* block)
|
B3_FORCE_INLINE void endBlock(b3Block* block)
|
||||||
{
|
{
|
||||||
b3Assert(block==current);
|
b3Assert(block==current);
|
||||||
//Raise(L"Unmatched blocks");
|
//Raise(L"Unmatched blocks");
|
||||||
|
|||||||
@@ -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.
|
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.
|
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
|
#ifndef B3_TRANSFORM_H
|
||||||
#define 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.
|
/**@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. */
|
*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
|
///Storage for the rotation
|
||||||
b3Matrix3x3 m_basis;
|
b3Matrix3x3 m_basis;
|
||||||
@@ -45,7 +44,7 @@ public:
|
|||||||
/**@brief Constructor from b3Quaternion (optional b3Vector3 )
|
/**@brief Constructor from b3Quaternion (optional b3Vector3 )
|
||||||
* @param q Rotation from quaternion
|
* @param q Rotation from quaternion
|
||||||
* @param c Translation from Vector (default 0,0,0) */
|
* @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)))
|
const b3Vector3& c = b3Vector3(b3Scalar(0), b3Scalar(0), b3Scalar(0)))
|
||||||
: m_basis(q),
|
: m_basis(q),
|
||||||
m_origin(c)
|
m_origin(c)
|
||||||
@@ -54,19 +53,19 @@ public:
|
|||||||
/**@brief Constructor from b3Matrix3x3 (optional b3Vector3)
|
/**@brief Constructor from b3Matrix3x3 (optional b3Vector3)
|
||||||
* @param b Rotation from Matrix
|
* @param b Rotation from Matrix
|
||||||
* @param c Translation from Vector default (0,0,0)*/
|
* @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)))
|
const b3Vector3& c = b3Vector3(b3Scalar(0), b3Scalar(0), b3Scalar(0)))
|
||||||
: m_basis(b),
|
: m_basis(b),
|
||||||
m_origin(c)
|
m_origin(c)
|
||||||
{}
|
{}
|
||||||
/**@brief Copy constructor */
|
/**@brief Copy constructor */
|
||||||
SIMD_FORCE_INLINE b3Transform (const b3Transform& other)
|
B3_FORCE_INLINE b3Transform (const b3Transform& other)
|
||||||
: m_basis(other.m_basis),
|
: m_basis(other.m_basis),
|
||||||
m_origin(other.m_origin)
|
m_origin(other.m_origin)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
/**@brief Assignment Operator */
|
/**@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_basis = other.m_basis;
|
||||||
m_origin = other.m_origin;
|
m_origin = other.m_origin;
|
||||||
@@ -78,7 +77,7 @@ public:
|
|||||||
* @param t1 Transform 1
|
* @param t1 Transform 1
|
||||||
* @param t2 Transform 2
|
* @param t2 Transform 2
|
||||||
* This = Transform1 * Transform2 */
|
* 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_basis = t1.m_basis * t2.m_basis;
|
||||||
m_origin = t1(t2.m_origin);
|
m_origin = t1(t2.m_origin);
|
||||||
}
|
}
|
||||||
@@ -91,32 +90,32 @@ public:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**@brief Return the transform of the vector */
|
/**@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;
|
return x.dot3(m_basis[0], m_basis[1], m_basis[2]) + m_origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the transform of the vector */
|
/**@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);
|
return (*this)(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the transform of the b3Quaternion */
|
/**@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;
|
return getRotation() * q;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the basis matrix for the rotation */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@brief Return a quaternion representing the rotation */
|
||||||
b3Quaternion getRotation() const {
|
b3Quaternion getRotation() const {
|
||||||
@@ -147,22 +146,22 @@ public:
|
|||||||
|
|
||||||
/**@brief Set the translational element
|
/**@brief Set the translational element
|
||||||
* @param origin The vector to set the translation to */
|
* @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;
|
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 */
|
/**@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;
|
m_basis = basis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Set the rotational element by b3Quaternion */
|
/**@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);
|
m_basis.setRotation(q);
|
||||||
}
|
}
|
||||||
@@ -219,14 +218,14 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
b3Transform::invXform(const b3Vector3& inVec) const
|
b3Transform::invXform(const b3Vector3& inVec) const
|
||||||
{
|
{
|
||||||
b3Vector3 v = inVec - m_origin;
|
b3Vector3 v = inVec - m_origin;
|
||||||
return (m_basis.transpose() * v);
|
return (m_basis.transpose() * v);
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Transform
|
B3_FORCE_INLINE b3Transform
|
||||||
b3Transform::inverseTimes(const b3Transform& t) const
|
b3Transform::inverseTimes(const b3Transform& t) const
|
||||||
{
|
{
|
||||||
b3Vector3 v = t.getOrigin() - m_origin;
|
b3Vector3 v = t.getOrigin() - m_origin;
|
||||||
@@ -234,7 +233,7 @@ b3Transform::inverseTimes(const b3Transform& t) const
|
|||||||
v * m_basis);
|
v * m_basis);
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Transform
|
B3_FORCE_INLINE b3Transform
|
||||||
b3Transform::operator*(const b3Transform& t) const
|
b3Transform::operator*(const b3Transform& t) const
|
||||||
{
|
{
|
||||||
return b3Transform(m_basis * t.m_basis,
|
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 */
|
/**@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() &&
|
return ( t1.getBasis() == t2.getBasis() &&
|
||||||
t1.getOrigin() == t2.getOrigin() );
|
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_basis.serialize(dataOut.m_basis);
|
||||||
m_origin.serialize(dataOut.m_origin);
|
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_basis.serializeFloat(dataOut.m_basis);
|
||||||
m_origin.serializeFloat(dataOut.m_origin);
|
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_basis.deSerialize(dataIn.m_basis);
|
||||||
m_origin.deSerialize(dataIn.m_origin);
|
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_basis.deSerializeFloat(dataIn.m_basis);
|
||||||
m_origin.deSerializeFloat(dataIn.m_origin);
|
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_basis.deSerializeDouble(dataIn.m_basis);
|
||||||
m_origin.deSerializeDouble(dataIn.m_origin);
|
m_origin.deSerializeDouble(dataIn.m_origin);
|
||||||
|
|||||||
@@ -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.
|
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.
|
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
|
#define B3_TRANSFORM_UTIL_H
|
||||||
|
|
||||||
#include "b3Transform.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(),
|
return b3Vector3(supportDir.getX() < b3Scalar(0.0) ? -halfExtents.getX() : halfExtents.getX(),
|
||||||
supportDir.getY() < b3Scalar(0.0) ? -halfExtents.getY() : halfExtents.getY(),
|
supportDir.getY() < b3Scalar(0.0) ? -halfExtents.getY() : halfExtents.getY(),
|
||||||
@@ -55,9 +55,9 @@ public:
|
|||||||
b3Vector3 axis;
|
b3Vector3 axis;
|
||||||
b3Scalar fAngle = angvel.length();
|
b3Scalar fAngle = angvel.length();
|
||||||
//limit the angular motion
|
//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) )
|
if ( fAngle < b3Scalar(0.001) )
|
||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
axis[3] = b3Scalar(0.);
|
axis[3] = b3Scalar(0.);
|
||||||
//check for axis length
|
//check for axis length
|
||||||
b3Scalar len = axis.length2();
|
b3Scalar len = axis.length2();
|
||||||
if (len < SIMD_EPSILON*SIMD_EPSILON)
|
if (len < B3_EPSILON*B3_EPSILON)
|
||||||
axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.));
|
axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.));
|
||||||
else
|
else
|
||||||
axis /= b3Sqrt(len);
|
axis /= b3Sqrt(len);
|
||||||
@@ -132,7 +132,7 @@ public:
|
|||||||
axis[3] = b3Scalar(0.);
|
axis[3] = b3Scalar(0.);
|
||||||
//check for axis length
|
//check for axis length
|
||||||
b3Scalar len = axis.length2();
|
b3Scalar len = axis.length2();
|
||||||
if (len < SIMD_EPSILON*SIMD_EPSILON)
|
if (len < B3_EPSILON*B3_EPSILON)
|
||||||
axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.));
|
axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.));
|
||||||
else
|
else
|
||||||
axis /= b3Sqrt(len);
|
axis /= b3Sqrt(len);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2011 Apple Inc.
|
Copyright (c) 2011-213 Apple Inc. http://bulletphysics.org
|
||||||
http://continuousphysics.com/Bullet/
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
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.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|||||||
@@ -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.
|
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.
|
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 B3_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 B3_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 B3_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(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef B3_USE_NEON
|
#ifdef B3_USE_NEON
|
||||||
|
|
||||||
const float32x4_t ATTRIBUTE_ALIGNED16(b3vMzeroMask) = (float32x4_t){-0.0f, -0.0f, -0.0f, -0.0f};
|
const float32x4_t B3_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 B3_ATTRIBUTE_ALIGNED16(b3vFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0};
|
||||||
const int32x4_t ATTRIBUTE_ALIGNED16(b3vAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
|
const int32x4_t B3_ATTRIBUTE_ALIGNED16(b3vAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
|
||||||
const int32x4_t ATTRIBUTE_ALIGNED16(b3v3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0};
|
const int32x4_t B3_ATTRIBUTE_ALIGNED16(b3v3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0};
|
||||||
|
|
||||||
#endif
|
#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
|
* 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
|
* 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:
|
public:
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
#if defined (__SPU__) && defined (__CELLOS_LV2__)
|
#if defined (__SPU__) && defined (__CELLOS_LV2__)
|
||||||
b3Scalar m_floats[4];
|
b3Scalar m_floats[4];
|
||||||
public:
|
public:
|
||||||
SIMD_FORCE_INLINE const vec_float4& get128() const
|
B3_FORCE_INLINE const vec_float4& get128() const
|
||||||
{
|
{
|
||||||
return *((const vec_float4*)&m_floats[0]);
|
return *((const vec_float4*)&m_floats[0]);
|
||||||
}
|
}
|
||||||
@@ -97,11 +97,11 @@ public:
|
|||||||
struct {b3Scalar x,y,z,w;};
|
struct {b3Scalar x,y,z,w;};
|
||||||
|
|
||||||
};
|
};
|
||||||
SIMD_FORCE_INLINE b3SimdFloat4 get128() const
|
B3_FORCE_INLINE b3SimdFloat4 get128() const
|
||||||
{
|
{
|
||||||
return mVec128;
|
return mVec128;
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE void set128(b3SimdFloat4 v128)
|
B3_FORCE_INLINE void set128(b3SimdFloat4 v128)
|
||||||
{
|
{
|
||||||
mVec128 = v128;
|
mVec128 = v128;
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/**@brief No initialization constructor */
|
/**@brief No initialization constructor */
|
||||||
SIMD_FORCE_INLINE b3Vector3()
|
B3_FORCE_INLINE b3Vector3()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ public:
|
|||||||
* @param y Y value
|
* @param y Y value
|
||||||
* @param z Z 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[0] = _x;
|
||||||
m_floats[1] = _y;
|
m_floats[1] = _y;
|
||||||
@@ -135,19 +135,19 @@ public:
|
|||||||
|
|
||||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) )|| defined (B3_USE_NEON)
|
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) )|| defined (B3_USE_NEON)
|
||||||
// Set Vector
|
// Set Vector
|
||||||
SIMD_FORCE_INLINE b3Vector3( b3SimdFloat4 v)
|
B3_FORCE_INLINE b3Vector3( b3SimdFloat4 v)
|
||||||
{
|
{
|
||||||
mVec128 = v;
|
mVec128 = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy constructor
|
// Copy constructor
|
||||||
SIMD_FORCE_INLINE b3Vector3(const b3Vector3& rhs)
|
B3_FORCE_INLINE b3Vector3(const b3Vector3& rhs)
|
||||||
{
|
{
|
||||||
mVec128 = rhs.mVec128;
|
mVec128 = rhs.mVec128;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assignment Operator
|
// Assignment Operator
|
||||||
SIMD_FORCE_INLINE b3Vector3&
|
B3_FORCE_INLINE b3Vector3&
|
||||||
operator=(const b3Vector3& v)
|
operator=(const b3Vector3& v)
|
||||||
{
|
{
|
||||||
mVec128 = v.mVec128;
|
mVec128 = v.mVec128;
|
||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Add a vector to this one
|
/**@brief Add a vector to this one
|
||||||
* @param The vector to add 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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
mVec128 = _mm_add_ps(mVec128, v.mVec128);
|
mVec128 = _mm_add_ps(mVec128, v.mVec128);
|
||||||
@@ -175,7 +175,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Subtract a vector from this one
|
/**@brief Subtract a vector from this one
|
||||||
* @param The vector to subtract */
|
* @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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
mVec128 = _mm_sub_ps(mVec128, v.mVec128);
|
mVec128 = _mm_sub_ps(mVec128, v.mVec128);
|
||||||
@@ -191,7 +191,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Scale the vector
|
/**@brief Scale the vector
|
||||||
* @param s Scale factor */
|
* @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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
__m128 vs = _mm_load_ss(&s); // (S 0 0 0)
|
__m128 vs = _mm_load_ss(&s); // (S 0 0 0)
|
||||||
@@ -209,7 +209,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Inversely scale the vector
|
/**@brief Inversely scale the vector
|
||||||
* @param s Scale factor to divide by */
|
* @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));
|
b3FullAssert(s != b3Scalar(0.0));
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Return the dot product
|
/**@brief Return the dot product
|
||||||
* @param v The other vector in 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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
__m128 vd = _mm_mul_ps(mVec128, v.mVec128);
|
__m128 vd = _mm_mul_ps(mVec128, v.mVec128);
|
||||||
@@ -251,26 +251,26 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the length of the vector squared */
|
/**@brief Return the length of the vector squared */
|
||||||
SIMD_FORCE_INLINE b3Scalar length2() const
|
B3_FORCE_INLINE b3Scalar length2() const
|
||||||
{
|
{
|
||||||
return dot(*this);
|
return dot(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the length of the vector */
|
/**@brief Return the length of the vector */
|
||||||
SIMD_FORCE_INLINE b3Scalar length() const
|
B3_FORCE_INLINE b3Scalar length() const
|
||||||
{
|
{
|
||||||
return b3Sqrt(length2());
|
return b3Sqrt(length2());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the distance squared between the ends of this and another vector
|
/**@brief Return the distance squared between the ends of this and another vector
|
||||||
* This is symantically treating the vector like a point */
|
* 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
|
/**@brief Return the distance between the ends of this and another vector
|
||||||
* This is symantically treating the vector like a point */
|
* 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();
|
b3Vector3 absVec = this->absolute();
|
||||||
int maxIndex = absVec.maxAxis();
|
int maxIndex = absVec.maxAxis();
|
||||||
@@ -285,7 +285,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Normalize this vector
|
/**@brief Normalize this vector
|
||||||
* x^2 + y^2 + z^2 = 1 */
|
* 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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
// dot product first
|
// dot product first
|
||||||
@@ -328,16 +328,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return a normalized version of this vector */
|
/**@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
|
/**@brief Return a rotated version of this vector
|
||||||
* @param wAxis The axis to rotate about
|
* @param wAxis The axis to rotate about
|
||||||
* @param angle The angle to rotate by */
|
* @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
|
/**@brief Return the angle between this and another vector
|
||||||
* @param v The other 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());
|
b3Scalar s = b3Sqrt(length2() * v.length2());
|
||||||
b3FullAssert(s != b3Scalar(0.0));
|
b3FullAssert(s != b3Scalar(0.0));
|
||||||
@@ -345,7 +345,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return a vector will the absolute values of each element */
|
/**@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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
return b3Vector3(_mm_and_ps(mVec128, b3v3AbsfMask));
|
return b3Vector3(_mm_and_ps(mVec128, b3v3AbsfMask));
|
||||||
@@ -361,7 +361,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Return the cross product between this and another vector
|
/**@brief Return the cross product between this and another vector
|
||||||
* @param v The other 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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
__m128 T, V;
|
__m128 T, V;
|
||||||
@@ -400,7 +400,7 @@ public:
|
|||||||
#endif
|
#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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
// cross:
|
// cross:
|
||||||
@@ -452,30 +452,30 @@ public:
|
|||||||
|
|
||||||
/**@brief Return the axis with the smallest value
|
/**@brief Return the axis with the smallest value
|
||||||
* Note return values are 0,1,2 for x, y, or z */
|
* 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] <m_floats[2] ? 0 : 2) : (m_floats[1] <m_floats[2] ? 1 : 2);
|
return m_floats[0] < m_floats[1] ? (m_floats[0] <m_floats[2] ? 0 : 2) : (m_floats[1] <m_floats[2] ? 1 : 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the axis with the largest value
|
/**@brief Return the axis with the largest value
|
||||||
* Note return values are 0,1,2 for x, y, or z */
|
* Note return values are 0,1,2 for x, y, or z */
|
||||||
SIMD_FORCE_INLINE int maxAxis() const
|
B3_FORCE_INLINE int maxAxis() const
|
||||||
{
|
{
|
||||||
return m_floats[0] < m_floats[1] ? (m_floats[1] <m_floats[2] ? 2 : 1) : (m_floats[0] <m_floats[2] ? 2 : 0);
|
return m_floats[0] < m_floats[1] ? (m_floats[1] <m_floats[2] ? 2 : 1) : (m_floats[0] <m_floats[2] ? 2 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int furthestAxis() const
|
B3_FORCE_INLINE int furthestAxis() const
|
||||||
{
|
{
|
||||||
return absolute().minAxis();
|
return absolute().minAxis();
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int closestAxis() const
|
B3_FORCE_INLINE int closestAxis() const
|
||||||
{
|
{
|
||||||
return absolute().maxAxis();
|
return absolute().maxAxis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void setInterpolate3(const b3Vector3& v0, const b3Vector3& v1, b3Scalar rt)
|
B3_FORCE_INLINE void setInterpolate3(const b3Vector3& v0, const b3Vector3& v1, b3Scalar rt)
|
||||||
{
|
{
|
||||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
__m128 vrt = _mm_load_ss(&rt); // (rt 0 0 0)
|
__m128 vrt = _mm_load_ss(&rt); // (rt 0 0 0)
|
||||||
@@ -504,7 +504,7 @@ public:
|
|||||||
/**@brief Return the linear interpolation between this and another vector
|
/**@brief Return the linear interpolation between this and another vector
|
||||||
* @param v The other vector
|
* @param v The other vector
|
||||||
* @param t The ration of this to v (t = 0 => return this, t=1 => return other) */
|
* @param t The ration of this to v (t = 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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
__m128 vt = _mm_load_ss(&t); // (t 0 0 0)
|
__m128 vt = _mm_load_ss(&t); // (t 0 0 0)
|
||||||
@@ -530,7 +530,7 @@ public:
|
|||||||
|
|
||||||
/**@brief Elementwise multiply this vector by the other
|
/**@brief Elementwise multiply this vector by the other
|
||||||
* @param v The other vector */
|
* @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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
mVec128 = _mm_mul_ps(mVec128, v.mVec128);
|
mVec128 = _mm_mul_ps(mVec128, v.mVec128);
|
||||||
@@ -545,30 +545,30 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the x value */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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 */
|
/**@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]; }
|
//B3_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 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.
|
///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]; }
|
B3_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; }
|
||||||
SIMD_FORCE_INLINE operator const b3Scalar *() const { 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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128)));
|
return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128)));
|
||||||
@@ -580,7 +580,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE bool operator!=(const b3Vector3& other) const
|
B3_FORCE_INLINE bool operator!=(const b3Vector3& other) const
|
||||||
{
|
{
|
||||||
return !(*this == other);
|
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
|
/**@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
|
* @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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
mVec128 = _mm_max_ps(mVec128, other.mVec128);
|
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
|
/**@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
|
* @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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
mVec128 = _mm_min_ps(mVec128, other.mVec128);
|
mVec128 = _mm_min_ps(mVec128, other.mVec128);
|
||||||
@@ -619,7 +619,7 @@ public:
|
|||||||
#endif
|
#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[0]=_x;
|
||||||
m_floats[1]=_y;
|
m_floats[1]=_y;
|
||||||
@@ -662,42 +662,42 @@ public:
|
|||||||
#endif
|
#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);
|
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[]
|
/**@brief returns index of maximum dot product between this and vectors in array[]
|
||||||
* @param array The other vectors
|
* @param array The other vectors
|
||||||
* @param array_count The number of other vectors
|
* @param array_count The number of other vectors
|
||||||
* @param dotOut The maximum dot product */
|
* @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[]
|
/**@brief returns index of minimum dot product between this and vectors in array[]
|
||||||
* @param array The other vectors
|
* @param array The other vectors
|
||||||
* @param array_count The number of other vectors
|
* @param array_count The number of other vectors
|
||||||
* @param dotOut The minimum dot product */
|
* @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 )) */
|
/* 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)
|
#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)*/
|
/**@brief Return the sum of two vectors (Point symantics)*/
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
operator+(const b3Vector3& v1, const b3Vector3& v2)
|
operator+(const b3Vector3& v1, const b3Vector3& v2)
|
||||||
{
|
{
|
||||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#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 */
|
/**@brief Return the elementwise product of two vectors */
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
operator*(const b3Vector3& v1, const b3Vector3& v2)
|
operator*(const b3Vector3& v1, const b3Vector3& v2)
|
||||||
{
|
{
|
||||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#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 */
|
/**@brief Return the difference between two vectors */
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
operator-(const b3Vector3& v1, const b3Vector3& v2)
|
operator-(const b3Vector3& v1, const b3Vector3& v2)
|
||||||
{
|
{
|
||||||
#if (defined(B3_USE_SSE_IN_API) && defined(B3_USE_SSE))
|
#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 */
|
/**@brief Return the negative of the vector */
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
operator-(const b3Vector3& v)
|
operator-(const b3Vector3& v)
|
||||||
{
|
{
|
||||||
#if (defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
#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 */
|
/**@brief Return the vector scaled by s */
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
operator*(const b3Vector3& v, const b3Scalar& s)
|
operator*(const b3Vector3& v, const b3Scalar& s)
|
||||||
{
|
{
|
||||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
#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 */
|
/**@brief Return the vector scaled by s */
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
operator*(const b3Scalar& s, const b3Vector3& v)
|
operator*(const b3Scalar& s, const b3Vector3& v)
|
||||||
{
|
{
|
||||||
return v * s;
|
return v * s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the vector inversely scaled by s */
|
/**@brief Return the vector inversely scaled by s */
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
operator/(const b3Vector3& v, const b3Scalar& s)
|
operator/(const b3Vector3& v, const b3Scalar& s)
|
||||||
{
|
{
|
||||||
b3FullAssert(s != b3Scalar(0.0));
|
b3FullAssert(s != b3Scalar(0.0));
|
||||||
@@ -836,7 +836,7 @@ operator/(const b3Vector3& v, const b3Scalar& s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the vector inversely scaled by s */
|
/**@brief Return the vector inversely scaled by s */
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
operator/(const b3Vector3& v1, const b3Vector3& v2)
|
operator/(const b3Vector3& v1, const b3Vector3& v2)
|
||||||
{
|
{
|
||||||
#if (defined(B3_USE_SSE_IN_API)&& defined (B3_USE_SSE))
|
#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 */
|
/**@brief Return the dot product between two vectors */
|
||||||
SIMD_FORCE_INLINE b3Scalar
|
B3_FORCE_INLINE b3Scalar
|
||||||
b3Dot(const b3Vector3& v1, const b3Vector3& v2)
|
b3Dot(const b3Vector3& v1, const b3Vector3& v2)
|
||||||
{
|
{
|
||||||
return v1.dot(v2);
|
return v1.dot(v2);
|
||||||
@@ -874,7 +874,7 @@ b3Dot(const b3Vector3& v1, const b3Vector3& v2)
|
|||||||
|
|
||||||
|
|
||||||
/**@brief Return the distance squared between two vectors */
|
/**@brief Return the distance squared between two vectors */
|
||||||
SIMD_FORCE_INLINE b3Scalar
|
B3_FORCE_INLINE b3Scalar
|
||||||
b3Distance2(const b3Vector3& v1, const b3Vector3& v2)
|
b3Distance2(const b3Vector3& v1, const b3Vector3& v2)
|
||||||
{
|
{
|
||||||
return v1.distance2(v2);
|
return v1.distance2(v2);
|
||||||
@@ -882,27 +882,27 @@ b3Distance2(const b3Vector3& v1, const b3Vector3& v2)
|
|||||||
|
|
||||||
|
|
||||||
/**@brief Return the distance between two vectors */
|
/**@brief Return the distance between two vectors */
|
||||||
SIMD_FORCE_INLINE b3Scalar
|
B3_FORCE_INLINE b3Scalar
|
||||||
b3Distance(const b3Vector3& v1, const b3Vector3& v2)
|
b3Distance(const b3Vector3& v1, const b3Vector3& v2)
|
||||||
{
|
{
|
||||||
return v1.distance(v2);
|
return v1.distance(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the angle between two vectors */
|
/**@brief Return the angle between two vectors */
|
||||||
SIMD_FORCE_INLINE b3Scalar
|
B3_FORCE_INLINE b3Scalar
|
||||||
b3Angle(const b3Vector3& v1, const b3Vector3& v2)
|
b3Angle(const b3Vector3& v1, const b3Vector3& v2)
|
||||||
{
|
{
|
||||||
return v1.angle(v2);
|
return v1.angle(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Return the cross product of two vectors */
|
/**@brief Return the cross product of two vectors */
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
b3Cross(const b3Vector3& v1, const b3Vector3& v2)
|
b3Cross(const b3Vector3& v1, const b3Vector3& v2)
|
||||||
{
|
{
|
||||||
return v1.cross(v2);
|
return v1.cross(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Scalar
|
B3_FORCE_INLINE b3Scalar
|
||||||
b3Triple(const b3Vector3& v1, const b3Vector3& v2, const b3Vector3& v3)
|
b3Triple(const b3Vector3& v1, const b3Vector3& v2, const b3Vector3& v3)
|
||||||
{
|
{
|
||||||
return v1.triple(v2, 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 v1 One vector
|
||||||
* @param v2 The other vector
|
* @param v2 The other vector
|
||||||
* @param t The ration of this to v (t = 0 => return v1, t=1 => return v2) */
|
* @param t The ration of this to v (t = 0 => return v1, t=1 => return v2) */
|
||||||
SIMD_FORCE_INLINE b3Vector3
|
B3_FORCE_INLINE b3Vector3
|
||||||
lerp(const b3Vector3& v1, const b3Vector3& v2, const b3Scalar& t)
|
b3Lerp(const b3Vector3& v1, const b3Vector3& v2, const b3Scalar& t)
|
||||||
{
|
{
|
||||||
return v1.lerp(v2, 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();
|
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();
|
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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
b3Vector3 norm = *this;
|
b3Vector3 norm = *this;
|
||||||
@@ -941,7 +941,7 @@ SIMD_FORCE_INLINE b3Vector3 b3Vector3::normalized() const
|
|||||||
#endif
|
#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
|
// wAxis must be a unit lenght vector
|
||||||
|
|
||||||
@@ -983,7 +983,7 @@ SIMD_FORCE_INLINE b3Vector3 b3Vector3::rotate( const b3Vector3& wAxis, const b3S
|
|||||||
#endif
|
#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 (B3_USE_SSE) || defined (B3_USE_NEON)
|
||||||
#if defined _WIN32 || defined (B3_USE_SSE)
|
#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
|
#endif//B3_USE_SSE || B3_USE_NEON
|
||||||
{
|
{
|
||||||
b3Scalar maxDot = -SIMD_INFINITY;
|
b3Scalar maxDot = -B3_INFINITY;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int ptIndex = -1;
|
int ptIndex = -1;
|
||||||
for( i = 0; i < array_count; i++ )
|
for( i = 0; i < array_count; i++ )
|
||||||
@@ -1020,7 +1020,7 @@ SIMD_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long arra
|
|||||||
#endif
|
#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) || defined (B3_USE_NEON)
|
||||||
#if defined B3_USE_SSE
|
#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 )
|
if( array_count < scalar_cutoff )
|
||||||
#endif//B3_USE_SSE || B3_USE_NEON
|
#endif//B3_USE_SSE || B3_USE_NEON
|
||||||
{
|
{
|
||||||
b3Scalar minDot = SIMD_INFINITY;
|
b3Scalar minDot = B3_INFINITY;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int ptIndex = -1;
|
int ptIndex = -1;
|
||||||
|
|
||||||
@@ -1065,27 +1065,27 @@ class b3Vector4 : public b3Vector3
|
|||||||
{
|
{
|
||||||
public:
|
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)
|
: b3Vector3(_x,_y,_z)
|
||||||
{
|
{
|
||||||
m_floats[3] = _w;
|
m_floats[3] = _w;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined (B3_USE_SSE_IN_API)&& defined (B3_USE_SSE)) || defined (B3_USE_NEON)
|
#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;
|
mVec128 = vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Vector4(const b3Vector3& rhs)
|
B3_FORCE_INLINE b3Vector4(const b3Vector3& rhs)
|
||||||
{
|
{
|
||||||
mVec128 = rhs.mVec128;
|
mVec128 = rhs.mVec128;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3Vector4&
|
B3_FORCE_INLINE b3Vector4&
|
||||||
operator=(const b3Vector4& v)
|
operator=(const b3Vector4& v)
|
||||||
{
|
{
|
||||||
mVec128 = v.mVec128;
|
mVec128 = v.mVec128;
|
||||||
@@ -1093,7 +1093,7 @@ public:
|
|||||||
}
|
}
|
||||||
#endif // #if defined (B3_USE_SSE_IN_API) || defined (B3_USE_NEON)
|
#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)
|
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||||
return b3Vector4(_mm_and_ps(mVec128, b3vAbsfMask));
|
return b3Vector4(_mm_and_ps(mVec128, b3vAbsfMask));
|
||||||
@@ -1112,7 +1112,7 @@ public:
|
|||||||
b3Scalar getW() const { return m_floats[3];}
|
b3Scalar getW() const { return m_floats[3];}
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int maxAxis4() const
|
B3_FORCE_INLINE int maxAxis4() const
|
||||||
{
|
{
|
||||||
int maxIndex = -1;
|
int maxIndex = -1;
|
||||||
b3Scalar maxVal = b3Scalar(-B3_LARGE_FLOAT);
|
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;
|
int minIndex = -1;
|
||||||
b3Scalar minVal = b3Scalar(B3_LARGE_FLOAT);
|
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();
|
return absolute4().maxAxis4();
|
||||||
}
|
}
|
||||||
@@ -1198,7 +1198,7 @@ public:
|
|||||||
* @param z Value of z
|
* @param z Value of z
|
||||||
* @param w Value of w
|
* @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[0]=_x;
|
||||||
m_floats[1]=_y;
|
m_floats[1]=_y;
|
||||||
@@ -1211,7 +1211,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
///b3SwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
|
///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
|
#ifdef B3_USE_DOUBLE_PRECISION
|
||||||
unsigned char* dest = (unsigned char*) &destVal;
|
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
|
#endif //B3_USE_DOUBLE_PRECISION
|
||||||
}
|
}
|
||||||
///b3SwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
|
///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++)
|
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
|
///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;
|
b3Vector3 swappedVec;
|
||||||
@@ -1256,9 +1256,9 @@ SIMD_FORCE_INLINE void b3UnSwapVector3Endian(b3Vector3& vector)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
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
|
// choose p in y-z plane
|
||||||
b3Scalar a = n[1]*n[1] + n[2]*n[2];
|
b3Scalar a = n[1]*n[1] + n[2]*n[2];
|
||||||
b3Scalar k = b3RecipSqrt (a);
|
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
|
///could also do a memcpy, check if it is worth it
|
||||||
for (int i=0;i<4;i++)
|
for (int i=0;i<4;i++)
|
||||||
dataOut.m_floats[i] = float(m_floats[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++)
|
for (int i=0;i<4;i++)
|
||||||
m_floats[i] = b3Scalar(dataIn.m_floats[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
|
///could also do a memcpy, check if it is worth it
|
||||||
for (int i=0;i<4;i++)
|
for (int i=0;i<4;i++)
|
||||||
dataOut.m_floats[i] = double(m_floats[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++)
|
for (int i=0;i<4;i++)
|
||||||
m_floats[i] = b3Scalar(dataIn.m_floats[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
|
///could also do a memcpy, check if it is worth it
|
||||||
for (int i=0;i<4;i++)
|
for (int i=0;i<4;i++)
|
||||||
dataOut.m_floats[i] = m_floats[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++)
|
for (int i=0;i<4;i++)
|
||||||
m_floats[i] = dataIn.m_floats[i];
|
m_floats[i] = dataIn.m_floats[i];
|
||||||
|
|||||||
@@ -20,16 +20,16 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
enum b3SolverMode
|
enum b3SolverMode
|
||||||
{
|
{
|
||||||
SOLVER_RANDMIZE_ORDER = 1,
|
B3_SOLVER_RANDMIZE_ORDER = 1,
|
||||||
SOLVER_FRICTION_SEPARATE = 2,
|
B3_SOLVER_FRICTION_SEPARATE = 2,
|
||||||
SOLVER_USE_WARMSTARTING = 4,
|
B3_SOLVER_USE_WARMSTARTING = 4,
|
||||||
SOLVER_USE_2_FRICTION_DIRECTIONS = 16,
|
B3_SOLVER_USE_2_FRICTION_DIRECTIONS = 16,
|
||||||
SOLVER_ENABLE_FRICTION_DIRECTION_CACHING = 32,
|
B3_SOLVER_ENABLE_FRICTION_DIRECTION_CACHING = 32,
|
||||||
SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64,
|
B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64,
|
||||||
SOLVER_CACHE_FRIENDLY = 128,
|
B3_SOLVER_CACHE_FRIENDLY = 128,
|
||||||
SOLVER_SIMD = 256,
|
B3_SOLVER_SIMD = 256,
|
||||||
SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS = 512,
|
B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS = 512,
|
||||||
SOLVER_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024
|
B3_SOLVER_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024
|
||||||
};
|
};
|
||||||
|
|
||||||
struct b3ContactSolverInfoData
|
struct b3ContactSolverInfoData
|
||||||
@@ -85,8 +85,8 @@ struct b3ContactSolverInfo : public b3ContactSolverInfoData
|
|||||||
m_splitImpulseTurnErp = 0.1f;
|
m_splitImpulseTurnErp = 0.1f;
|
||||||
m_linearSlop = b3Scalar(0.0);
|
m_linearSlop = b3Scalar(0.0);
|
||||||
m_warmstartingFactor=b3Scalar(0.85);
|
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 = 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 = SOLVER_USE_WARMSTARTING | SOLVER_SIMD;// | 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_restingContactRestitutionThreshold = 2;//unused as of 2.81
|
||||||
m_minimumSolverBatchSize = 128; //try to combine islands until the amount of constraints reaches this limit
|
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)
|
m_maxGyroscopicForce = 100.f; ///only used to clamp forces for bodies that have their B3_ENABLE_GYROPSCOPIC_FORCE flag set (using b3RigidBody::setFlag)
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ subject to the following restrictions:
|
|||||||
//#include "../../dynamics/basic_demo/Stubs/AdlContact4.h"
|
//#include "../../dynamics/basic_demo/Stubs/AdlContact4.h"
|
||||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
||||||
|
|
||||||
bool usePgs = true;
|
|
||||||
int gNumSplitImpulseRecoveries2 = 0;
|
|
||||||
|
|
||||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||||
|
|
||||||
@@ -144,8 +142,9 @@ int getNumContacts(b3Contact4* contact)
|
|||||||
return contact->getNPoints();
|
return contact->getNPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
b3PgsJacobiSolver::b3PgsJacobiSolver()
|
b3PgsJacobiSolver::b3PgsJacobiSolver(bool usePgs)
|
||||||
:m_btSeed2(0),m_usePgs(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_splitImpulse = false;
|
||||||
infoGlobal.m_timeStep = 1.f/60.f;
|
infoGlobal.m_timeStep = 1.f/60.f;
|
||||||
infoGlobal.m_numIterations = 4;//4;
|
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|=B3_SOLVER_USE_2_FRICTION_DIRECTIONS|B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS|B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION;
|
||||||
//infoGlobal.m_solverMode|=SOLVER_USE_2_FRICTION_DIRECTIONS|SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS;
|
//infoGlobal.m_solverMode|=B3_SOLVER_USE_2_FRICTION_DIRECTIONS|B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS;
|
||||||
infoGlobal.m_solverMode|=SOLVER_USE_2_FRICTION_DIRECTIONS;
|
infoGlobal.m_solverMode|=B3_SOLVER_USE_2_FRICTION_DIRECTIONS;
|
||||||
|
|
||||||
//if (infoGlobal.m_solverMode & SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS)
|
//if (infoGlobal.m_solverMode & B3_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_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION))
|
||||||
|
|
||||||
|
|
||||||
solveGroup(bodies,inertias,numBodies,contacts,numContacts,constraints,numConstraints,infoGlobal);
|
solveGroup(bodies,inertias,numBodies,contacts,numContacts,constraints,numConstraints,infoGlobal);
|
||||||
@@ -344,7 +343,7 @@ void b3PgsJacobiSolver::resolveSplitPenetrationImpulseCacheFriendly(
|
|||||||
{
|
{
|
||||||
if (c.m_rhsPenetration)
|
if (c.m_rhsPenetration)
|
||||||
{
|
{
|
||||||
gNumSplitImpulseRecoveries2++;
|
m_numSplitImpulseRecoveries++;
|
||||||
b3Scalar deltaImpulse = c.m_rhsPenetration-b3Scalar(c.m_appliedPushImpulse)*c.m_cfm;
|
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 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());
|
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)
|
if (!c.m_rhsPenetration)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gNumSplitImpulseRecoveries2++;
|
m_numSplitImpulseRecoveries++;
|
||||||
|
|
||||||
__m128 cpAppliedImp = _mm_set1_ps(c.m_appliedPushImpulse);
|
__m128 cpAppliedImp = _mm_set1_ps(c.m_appliedPushImpulse);
|
||||||
__m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit);
|
__m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit);
|
||||||
@@ -804,7 +803,7 @@ void b3PgsJacobiSolver::setupContactConstraint(b3RigidBodyCL* bodies, b3InertiaC
|
|||||||
|
|
||||||
|
|
||||||
///warm starting (or zero if disabled)
|
///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;
|
solverConstraint.m_appliedImpulse = cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor;
|
||||||
if (rb0)
|
if (rb0)
|
||||||
@@ -883,7 +882,7 @@ void b3PgsJacobiSolver::setFrictionConstraintImpulse( b3RigidBodyCL* bodies, b3I
|
|||||||
|
|
||||||
{
|
{
|
||||||
b3SolverConstraint& frictionConstraint1 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex];
|
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;
|
frictionConstraint1.m_appliedImpulse = cp.m_appliedImpulseLateral1 * infoGlobal.m_warmstartingFactor;
|
||||||
if (bodies[bodyA->m_originalBodyIndex].m_invMass)
|
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];
|
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;
|
frictionConstraint2.m_appliedImpulse = cp.m_appliedImpulseLateral2 * infoGlobal.m_warmstartingFactor;
|
||||||
if (bodies[bodyA->m_originalBodyIndex].m_invMass)
|
if (bodies[bodyA->m_originalBodyIndex].m_invMass)
|
||||||
@@ -1003,24 +1002,24 @@ void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, b3InertiaCL* inert
|
|||||||
///based on the relative linear velocity.
|
///based on the relative linear velocity.
|
||||||
///If the relative velocity it zero, it will automatically compute a friction direction.
|
///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.
|
///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,
|
///The user can manually override the friction directions for certain contacts using a contact callback,
|
||||||
///and set the cp.m_lateralFrictionInitialized to true
|
///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)
|
///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
|
///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;
|
cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel;
|
||||||
b3Scalar lat_rel_vel = cp.m_lateralFrictionDir1.length2();
|
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);
|
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 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB);
|
||||||
cp.m_lateralFrictionDir2.normalize();//??
|
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);
|
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_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);
|
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;
|
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);
|
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);
|
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);
|
setFrictionConstraintImpulse( bodies,inertias,solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal);
|
||||||
@@ -1219,8 +1218,8 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies,
|
|||||||
for ( j=0;j<info1.m_numConstraintRows;j++)
|
for ( j=0;j<info1.m_numConstraintRows;j++)
|
||||||
{
|
{
|
||||||
memset(¤tConstraintRow[j],0,sizeof(b3SolverConstraint));
|
memset(¤tConstraintRow[j],0,sizeof(b3SolverConstraint));
|
||||||
currentConstraintRow[j].m_lowerLimit = -SIMD_INFINITY;
|
currentConstraintRow[j].m_lowerLimit = -B3_INFINITY;
|
||||||
currentConstraintRow[j].m_upperLimit = SIMD_INFINITY;
|
currentConstraintRow[j].m_upperLimit = B3_INFINITY;
|
||||||
currentConstraintRow[j].m_appliedImpulse = 0.f;
|
currentConstraintRow[j].m_appliedImpulse = 0.f;
|
||||||
currentConstraintRow[j].m_appliedPushImpulse = 0.f;
|
currentConstraintRow[j].m_appliedPushImpulse = 0.f;
|
||||||
currentConstraintRow[j].m_solverBodyIdA = solverBodyIdA;
|
currentConstraintRow[j].m_solverBodyIdA = solverBodyIdA;
|
||||||
@@ -1300,8 +1299,8 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies,
|
|||||||
sum += iMJlB.dot(solverConstraint.m_contactNormal);
|
sum += iMJlB.dot(solverConstraint.m_contactNormal);
|
||||||
sum += iMJaB.dot(solverConstraint.m_relpos2CrossNormal);
|
sum += iMJaB.dot(solverConstraint.m_relpos2CrossNormal);
|
||||||
b3Scalar fsum = b3Fabs(sum);
|
b3Scalar fsum = b3Fabs(sum);
|
||||||
b3Assert(fsum > SIMD_EPSILON);
|
b3Assert(fsum > B3_EPSILON);
|
||||||
solverConstraint.m_jacDiagABInv = fsum>SIMD_EPSILON?b3Scalar(1.)/sum : 0.f;
|
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
|
///@todo: use stack allocator for such temporarily memory, same for solver bodies/constraints
|
||||||
m_orderNonContactConstraintPool.resizeNoInitialize(numNonContactPool);
|
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);
|
m_orderTmpConstraintPool.resizeNoInitialize(numConstraintPool*2);
|
||||||
else
|
else
|
||||||
m_orderTmpConstraintPool.resizeNoInitialize(numConstraintPool);
|
m_orderTmpConstraintPool.resizeNoInitialize(numConstraintPool);
|
||||||
@@ -1385,7 +1384,7 @@ b3Scalar b3PgsJacobiSolver::solveSingleIteration(int iteration,b3TypedConstraint
|
|||||||
int numConstraintPool = m_tmpSolverContactConstraintPool.size();
|
int numConstraintPool = m_tmpSolverContactConstraintPool.size();
|
||||||
int numFrictionPool = m_tmpSolverContactFrictionConstraintPool.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)
|
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
|
///solve all joint constraints, using SIMD, if available
|
||||||
for (int j=0;j<m_tmpSolverNonContactConstraintPool.size();j++)
|
for (int j=0;j<m_tmpSolverNonContactConstraintPool.size();j++)
|
||||||
@@ -1431,10 +1430,10 @@ b3Scalar b3PgsJacobiSolver::solveSingleIteration(int iteration,b3TypedConstraint
|
|||||||
{
|
{
|
||||||
|
|
||||||
///solve all contact constraints using SIMD, if available
|
///solve all contact constraints using SIMD, if available
|
||||||
if (infoGlobal.m_solverMode & SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS)
|
if (infoGlobal.m_solverMode & B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS)
|
||||||
{
|
{
|
||||||
int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
|
int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
|
||||||
int multiplier = (infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)? 2 : 1;
|
int multiplier = (infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS)? 2 : 1;
|
||||||
|
|
||||||
for (int c=0;c<numPoolConstraints;c++)
|
for (int c=0;c<numPoolConstraints;c++)
|
||||||
{
|
{
|
||||||
@@ -1461,7 +1460,7 @@ b3Scalar b3PgsJacobiSolver::solveSingleIteration(int iteration,b3TypedConstraint
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)
|
if (infoGlobal.m_solverMode & B3_SOLVER_USE_2_FRICTION_DIRECTIONS)
|
||||||
{
|
{
|
||||||
|
|
||||||
b3SolverConstraint& solveManifold = m_tmpSolverContactFrictionConstraintPool[m_orderFrictionConstraintPool[c*multiplier+1]];
|
b3SolverConstraint& solveManifold = m_tmpSolverContactFrictionConstraintPool[m_orderFrictionConstraintPool[c*multiplier+1]];
|
||||||
@@ -1478,7 +1477,7 @@ b3Scalar b3PgsJacobiSolver::solveSingleIteration(int iteration,b3TypedConstraint
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else//SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS
|
else//B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS
|
||||||
{
|
{
|
||||||
//solve the friction constraints after all contact constraints, don't interleave them
|
//solve the friction constraints after all contact constraints, don't interleave them
|
||||||
int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
|
int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
|
||||||
@@ -1600,7 +1599,7 @@ void b3PgsJacobiSolver::solveGroupCacheFriendlySplitImpulseIterations(b3TypedCon
|
|||||||
int iteration;
|
int iteration;
|
||||||
if (infoGlobal.m_splitImpulse)
|
if (infoGlobal.m_splitImpulse)
|
||||||
{
|
{
|
||||||
if (infoGlobal.m_solverMode & SOLVER_SIMD)
|
if (infoGlobal.m_solverMode & B3_SOLVER_SIMD)
|
||||||
{
|
{
|
||||||
for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++)
|
for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++)
|
||||||
{
|
{
|
||||||
@@ -1706,7 +1705,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlyFinish(b3RigidBodyCL* bodies,
|
|||||||
int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
|
int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING)
|
if (infoGlobal.m_solverMode & B3_SOLVER_USE_WARMSTARTING)
|
||||||
{
|
{
|
||||||
for (j=0;j<numPoolConstraints;j++)
|
for (j=0;j<numPoolConstraints;j++)
|
||||||
{
|
{
|
||||||
@@ -1718,7 +1717,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlyFinish(b3RigidBodyCL* bodies,
|
|||||||
// printf("pt->m_appliedImpulseLateral1 = %f\n", f);
|
// printf("pt->m_appliedImpulseLateral1 = %f\n", f);
|
||||||
pt->m_appliedImpulseLateral1 = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse;
|
pt->m_appliedImpulseLateral1 = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse;
|
||||||
//printf("pt->m_appliedImpulseLateral1 = %f\n", pt->m_appliedImpulseLateral1);
|
//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;
|
pt->m_appliedImpulseLateral2 = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex+1].m_appliedImpulse;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ protected:
|
|||||||
void averageVelocities();
|
void averageVelocities();
|
||||||
|
|
||||||
int m_maxOverrideNumSolverIterations;
|
int m_maxOverrideNumSolverIterations;
|
||||||
|
|
||||||
|
int m_numSplitImpulseRecoveries;
|
||||||
|
|
||||||
b3Scalar getContactProcessingThreshold(b3Contact4* contact)
|
b3Scalar getContactProcessingThreshold(b3Contact4* contact)
|
||||||
{
|
{
|
||||||
return 0.02f;
|
return 0.02f;
|
||||||
@@ -113,7 +116,7 @@ public:
|
|||||||
|
|
||||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
b3PgsJacobiSolver();
|
b3PgsJacobiSolver(bool usePgs);
|
||||||
virtual ~b3PgsJacobiSolver();
|
virtual ~b3PgsJacobiSolver();
|
||||||
|
|
||||||
// void solveContacts(int numBodies, b3RigidBodyCL* bodies, b3InertiaCL* inertias, int numContacts, b3Contact4* contacts);
|
// void solveContacts(int numBodies, b3RigidBodyCL* bodies, b3InertiaCL* inertias, int numContacts, b3Contact4* contacts);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
b3Point2PointConstraint::b3Point2PointConstraint(int rbA,int rbB, const b3Vector3& pivotInA,const b3Vector3& pivotInB)
|
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_flags(0),
|
||||||
m_useSolveConstraintObsolete(false)
|
m_useSolveConstraintObsolete(false)
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ m_useSolveConstraintObsolete(false)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
b3Point2PointConstraint::b3Point2PointConstraint(int rbA,const b3Vector3& pivotInA)
|
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_flags(0),
|
||||||
m_useSolveConstraintObsolete(false)
|
m_useSolveConstraintObsolete(false)
|
||||||
{
|
{
|
||||||
@@ -197,7 +197,7 @@ void b3Point2PointConstraint::setParam(int num, b3Scalar value, int axis)
|
|||||||
///return the local value of parameter
|
///return the local value of parameter
|
||||||
b3Scalar b3Point2PointConstraint::getParam(int num, int axis) const
|
b3Scalar b3Point2PointConstraint::getParam(int num, int axis) const
|
||||||
{
|
{
|
||||||
b3Scalar retVal(SIMD_INFINITY);
|
b3Scalar retVal(B3_INFINITY);
|
||||||
if(axis != -1)
|
if(axis != -1)
|
||||||
{
|
{
|
||||||
b3AssertConstrParams(0);
|
b3AssertConstrParams(0);
|
||||||
|
|||||||
@@ -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
|
/// 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
|
#ifdef IN_PARALLELL_SOLVER
|
||||||
public:
|
public:
|
||||||
@@ -141,14 +141,14 @@ struct b3Point2PointConstraintDoubleData
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SIMD_FORCE_INLINE int b3Point2PointConstraint::calculateSerializeBufferSize() const
|
B3_FORCE_INLINE int b3Point2PointConstraint::calculateSerializeBufferSize() const
|
||||||
{
|
{
|
||||||
return sizeof(b3Point2PointConstraintData);
|
return sizeof(b3Point2PointConstraintData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
///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;
|
b3Point2PointConstraintData* p2pData = (b3Point2PointConstraintData*)dataBuffer;
|
||||||
|
|
||||||
|
|||||||
@@ -33,17 +33,17 @@ class b3RigidBody;
|
|||||||
|
|
||||||
struct b3SimdScalar
|
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))
|
:m_vec128 (_mm_set1_ps(fl))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE b3SimdScalar(__m128 v128)
|
B3_FORCE_INLINE b3SimdScalar(__m128 v128)
|
||||||
:m_vec128(v128)
|
:m_vec128(v128)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -54,31 +54,31 @@ struct b3SimdScalar
|
|||||||
int m_ints[4];
|
int m_ints[4];
|
||||||
b3Scalar m_unusedPadding;
|
b3Scalar m_unusedPadding;
|
||||||
};
|
};
|
||||||
SIMD_FORCE_INLINE __m128 get128()
|
B3_FORCE_INLINE __m128 get128()
|
||||||
{
|
{
|
||||||
return m_vec128;
|
return m_vec128;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE const __m128 get128() const
|
B3_FORCE_INLINE const __m128 get128() const
|
||||||
{
|
{
|
||||||
return m_vec128;
|
return m_vec128;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void set128(__m128 v128)
|
B3_FORCE_INLINE void set128(__m128 v128)
|
||||||
{
|
{
|
||||||
m_vec128 = v128;
|
m_vec128 = v128;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE operator __m128()
|
B3_FORCE_INLINE operator __m128()
|
||||||
{
|
{
|
||||||
return m_vec128;
|
return m_vec128;
|
||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE operator const __m128() const
|
B3_FORCE_INLINE operator const __m128() const
|
||||||
{
|
{
|
||||||
return m_vec128;
|
return m_vec128;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE operator float() const
|
B3_FORCE_INLINE operator float() const
|
||||||
{
|
{
|
||||||
return m_floats[0];
|
return m_floats[0];
|
||||||
}
|
}
|
||||||
@@ -86,14 +86,14 @@ struct b3SimdScalar
|
|||||||
};
|
};
|
||||||
|
|
||||||
///@brief Return the elementwise product of two b3SimdScalar
|
///@brief Return the elementwise product of two b3SimdScalar
|
||||||
SIMD_FORCE_INLINE b3SimdScalar
|
B3_FORCE_INLINE b3SimdScalar
|
||||||
operator*(const b3SimdScalar& v1, const b3SimdScalar& v2)
|
operator*(const b3SimdScalar& v1, const b3SimdScalar& v2)
|
||||||
{
|
{
|
||||||
return b3SimdScalar(_mm_mul_ps(v1.get128(),v2.get128()));
|
return b3SimdScalar(_mm_mul_ps(v1.get128(),v2.get128()));
|
||||||
}
|
}
|
||||||
|
|
||||||
///@brief Return the elementwise product of two b3SimdScalar
|
///@brief Return the elementwise product of two b3SimdScalar
|
||||||
SIMD_FORCE_INLINE b3SimdScalar
|
B3_FORCE_INLINE b3SimdScalar
|
||||||
operator+(const b3SimdScalar& v1, const b3SimdScalar& v2)
|
operator+(const b3SimdScalar& v1, const b3SimdScalar& v2)
|
||||||
{
|
{
|
||||||
return b3SimdScalar(_mm_add_ps(v1.get128(),v2.get128()));
|
return b3SimdScalar(_mm_add_ps(v1.get128(),v2.get128()));
|
||||||
@@ -105,7 +105,7 @@ operator+(const b3SimdScalar& v1, const b3SimdScalar& v2)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///The b3SolverBody is an internal datastructure for the constraint solver. Only necessary data is packed to increase cache coherence/performance.
|
///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();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
b3Transform m_worldTransform;
|
b3Transform m_worldTransform;
|
||||||
@@ -136,7 +136,7 @@ ATTRIBUTE_ALIGNED64 (struct) b3SolverBody
|
|||||||
return m_worldTransform;
|
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)
|
if (m_originalBody)
|
||||||
velocity = m_linearVelocity+m_deltaLinearVelocity + (m_angularVelocity+m_deltaAngularVelocity).cross(rel_pos);
|
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);
|
velocity.setValue(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void getAngularVelocity(b3Vector3& angVel) const
|
B3_FORCE_INLINE void getAngularVelocity(b3Vector3& angVel) const
|
||||||
{
|
{
|
||||||
if (m_originalBody)
|
if (m_originalBody)
|
||||||
angVel =m_angularVelocity+m_deltaAngularVelocity;
|
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
|
//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)
|
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)
|
if (m_originalBody)
|
||||||
{
|
{
|
||||||
@@ -233,19 +233,19 @@ ATTRIBUTE_ALIGNED64 (struct) b3SolverBody
|
|||||||
return m_turnVelocity;
|
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);
|
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;
|
angVel = m_angularVelocity+m_deltaAngularVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position
|
//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)
|
if (m_originalBody)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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.
|
///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();
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ subject to the following restrictions:
|
|||||||
//#include "Bullet3Common/b3Serializer.h"
|
//#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),
|
:b3TypedObject(type),
|
||||||
m_userConstraintType(-1),
|
m_userConstraintType(-1),
|
||||||
m_userConstraintId(-1),
|
m_userConstraintId(-1),
|
||||||
m_breakingImpulseThreshold(SIMD_INFINITY),
|
m_breakingImpulseThreshold(B3_INFINITY),
|
||||||
m_isEnabled(true),
|
m_isEnabled(true),
|
||||||
m_needsFeedback(false),
|
m_needsFeedback(false),
|
||||||
m_overrideNumSolverIterations(-1),
|
m_overrideNumSolverIterations(-1),
|
||||||
m_rbA(rbA),
|
m_rbA(rbA),
|
||||||
m_rbB(rbB),
|
m_rbB(rbB),
|
||||||
m_appliedImpulse(b3Scalar(0.)),
|
m_appliedImpulse(b3Scalar(0.)),
|
||||||
m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE),
|
m_dbgDrawSize(B3_DEFAULT_DEBUGDRAW_SIZE),
|
||||||
m_jointFeedback(0)
|
m_jointFeedback(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
//Don't change any of the existing enum values, so add enum types at the end for serialization compatibility
|
||||||
enum b3TypedConstraintType
|
enum b3TypedConstraintType
|
||||||
{
|
{
|
||||||
POINT2POINT_CONSTRAINT_TYPE=3,
|
B3_POINT2POINT_CONSTRAINT_TYPE=3,
|
||||||
HINGE_CONSTRAINT_TYPE,
|
B3_HINGE_CONSTRAINT_TYPE,
|
||||||
CONETWIST_CONSTRAINT_TYPE,
|
B3_CONETWIST_CONSTRAINT_TYPE,
|
||||||
D6_CONSTRAINT_TYPE,
|
B3_D6_CONSTRAINT_TYPE,
|
||||||
SLIDER_CONSTRAINT_TYPE,
|
B3_SLIDER_CONSTRAINT_TYPE,
|
||||||
CONTACT_CONSTRAINT_TYPE,
|
B3_CONTACT_CONSTRAINT_TYPE,
|
||||||
D6_SPRING_CONSTRAINT_TYPE,
|
B3_D6_SPRING_CONSTRAINT_TYPE,
|
||||||
GEAR_CONSTRAINT_TYPE,
|
B3_GEAR_CONSTRAINT_TYPE,
|
||||||
MAX_CONSTRAINT_TYPE
|
B3_MAX_CONSTRAINT_TYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ enum b3ConstraintParams
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) b3JointFeedback
|
B3_ATTRIBUTE_ALIGNED16(struct) b3JointFeedback
|
||||||
{
|
{
|
||||||
b3Vector3 m_appliedForceBodyA;
|
b3Vector3 m_appliedForceBodyA;
|
||||||
b3Vector3 m_appliedTorqueBodyA;
|
b3Vector3 m_appliedTorqueBodyA;
|
||||||
@@ -64,7 +64,7 @@ struct b3RigidBodyCL;
|
|||||||
|
|
||||||
|
|
||||||
///TypedConstraint is the baseclass for Bullet constraints and vehicles
|
///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;
|
int m_userConstraintType;
|
||||||
|
|
||||||
@@ -330,9 +330,9 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// returns angle in range [-SIMD_2_PI, SIMD_2_PI], closest to one of the limits
|
// 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 [-SIMD_PI, SIMD_PI])
|
// all arguments should be normalized angles (i.e. in range [-B3_PI, B3_PI])
|
||||||
SIMD_FORCE_INLINE b3Scalar b3AdjustAngleToLimits(b3Scalar angleInRadians, b3Scalar angleLowerLimitInRadians, b3Scalar angleUpperLimitInRadians)
|
B3_FORCE_INLINE b3Scalar b3AdjustAngleToLimits(b3Scalar angleInRadians, b3Scalar angleLowerLimitInRadians, b3Scalar angleUpperLimitInRadians)
|
||||||
{
|
{
|
||||||
if(angleLowerLimitInRadians >= angleUpperLimitInRadians)
|
if(angleLowerLimitInRadians >= angleUpperLimitInRadians)
|
||||||
{
|
{
|
||||||
@@ -342,13 +342,13 @@ SIMD_FORCE_INLINE b3Scalar b3AdjustAngleToLimits(b3Scalar angleInRadians, b3Scal
|
|||||||
{
|
{
|
||||||
b3Scalar diffLo = b3Fabs(b3NormalizeAngle(angleLowerLimitInRadians - angleInRadians));
|
b3Scalar diffLo = b3Fabs(b3NormalizeAngle(angleLowerLimitInRadians - angleInRadians));
|
||||||
b3Scalar diffHi = b3Fabs(b3NormalizeAngle(angleUpperLimitInRadians - 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)
|
else if(angleInRadians > angleUpperLimitInRadians)
|
||||||
{
|
{
|
||||||
b3Scalar diffHi = b3Fabs(b3NormalizeAngle(angleInRadians - angleUpperLimitInRadians));
|
b3Scalar diffHi = b3Fabs(b3NormalizeAngle(angleInRadians - angleUpperLimitInRadians));
|
||||||
b3Scalar diffLo = b3Fabs(b3NormalizeAngle(angleInRadians - angleLowerLimitInRadians));
|
b3Scalar diffLo = b3Fabs(b3NormalizeAngle(angleInRadians - angleLowerLimitInRadians));
|
||||||
return (diffLo < diffHi) ? (angleInRadians - SIMD_2_PI) : angleInRadians;
|
return (diffLo < diffHi) ? (angleInRadians - B3_2_PI) : angleInRadians;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -379,7 +379,7 @@ struct b3TypedConstraintData
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*SIMD_FORCE_INLINE int b3TypedConstraint::calculateSerializeBufferSize() const
|
/*B3_FORCE_INLINE int b3TypedConstraint::calculateSerializeBufferSize() const
|
||||||
{
|
{
|
||||||
return sizeof(b3TypedConstraintData);
|
return sizeof(b3TypedConstraintData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
b3Vector3& aabbMax,
|
||||||
const b3Vector3& expansionMin,
|
const b3Vector3& expansionMin,
|
||||||
const b3Vector3& expansionMax)
|
const b3Vector3& expansionMax)
|
||||||
@@ -33,7 +33,7 @@ SIMD_FORCE_INLINE void AabbExpand (b3Vector3& aabbMin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// conservative test for overlap between two aabbs
|
/// 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)
|
const b3Vector3 &point)
|
||||||
{
|
{
|
||||||
bool overlap = true;
|
bool overlap = true;
|
||||||
@@ -45,7 +45,7 @@ SIMD_FORCE_INLINE bool TestPointAgainstAabb2(const b3Vector3 &aabbMin1, const b3
|
|||||||
|
|
||||||
|
|
||||||
/// conservative test for overlap between two aabbs
|
/// 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)
|
const b3Vector3 &aabbMin2, const b3Vector3 &aabbMax2)
|
||||||
{
|
{
|
||||||
bool overlap = true;
|
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
|
/// 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 &aabbMin, const b3Vector3 &aabbMax)
|
||||||
{
|
{
|
||||||
const b3Vector3 &p1 = vertices[0];
|
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) |
|
return (p.getX() < -halfExtent.getX() ? 0x01 : 0x0) |
|
||||||
(p.getX() > halfExtent.getX() ? 0x08 : 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 b3Vector3& rayInvDirection,
|
||||||
const unsigned int raySign[3],
|
const unsigned int raySign[3],
|
||||||
const b3Vector3 bounds[2],
|
const b3Vector3 bounds[2],
|
||||||
@@ -122,7 +122,7 @@ SIMD_FORCE_INLINE bool b3RayAabb2(const b3Vector3& rayFrom,
|
|||||||
return ( (tmin < lambda_max) && (tmax > lambda_min) );
|
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& rayTo,
|
||||||
const b3Vector3& aabbMin,
|
const b3Vector3& aabbMin,
|
||||||
const b3Vector3& aabbMax,
|
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);
|
b3Vector3 halfExtentsWithMargin = halfExtents+b3Vector3(margin,margin,margin);
|
||||||
b3Matrix3x3 abs_b = t.getBasis().absolute();
|
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.getX() <= localAabbMax.getX());
|
||||||
b3Assert(localAabbMin.getY() <= localAabbMax.getY());
|
b3Assert(localAabbMin.getY() <= localAabbMax.getY());
|
||||||
@@ -206,10 +206,10 @@ SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& localAabbMin,const b3Vec
|
|||||||
aabbMaxOut = center+extent;
|
aabbMaxOut = center+extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define USE_BANCHLESS 1
|
#define B3_USE_BANCHLESS 1
|
||||||
#ifdef USE_BANCHLESS
|
#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)
|
//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<unsigned int>(b3Select((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0])
|
return static_cast<unsigned int>(b3Select((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0])
|
||||||
& (aabbMin1[2] <= aabbMax2[2]) & (aabbMax1[2] >= aabbMin2[2])
|
& (aabbMin1[2] <= aabbMax2[2]) & (aabbMax1[2] >= aabbMin2[2])
|
||||||
@@ -217,7 +217,7 @@ SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& localAabbMin,const b3Vec
|
|||||||
1, 0));
|
1, 0));
|
||||||
}
|
}
|
||||||
#else
|
#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;
|
bool overlap = true;
|
||||||
overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap;
|
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;
|
overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap;
|
||||||
return overlap;
|
return overlap;
|
||||||
}
|
}
|
||||||
#endif //USE_BANCHLESS
|
#endif //B3_USE_BANCHLESS
|
||||||
|
|
||||||
#endif //B3_AABB_UTIL2
|
#endif //B3_AABB_UTIL2
|
||||||
|
|
||||||
|
|||||||
@@ -21,16 +21,20 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
typedef int32_t btInt32_t;
|
||||||
|
typedef int64_t btInt64_t;
|
||||||
|
typedef uint32_t btUint32_t;
|
||||||
|
typedef uint64_t btUint64_t;
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
typedef __int32 int32_t;
|
typedef __int32 btInt32_t;
|
||||||
typedef __int64 int64_t;
|
typedef __int64 btInt64_t;
|
||||||
typedef unsigned __int32 uint32_t;
|
typedef unsigned __int32 btUint32_t;
|
||||||
typedef unsigned __int64 uint64_t;
|
typedef unsigned __int64 btUint64_t;
|
||||||
#else
|
#else
|
||||||
typedef int int32_t;
|
typedef int btInt32_t;
|
||||||
typedef long long int int64_t;
|
typedef long long int btInt64_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int btUint32_t;
|
||||||
typedef unsigned long long int uint64_t;
|
typedef unsigned long long int btUint64_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -56,11 +60,11 @@ class b3ConvexHullInternal
|
|||||||
class Point64
|
class Point64
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int64_t x;
|
btInt64_t x;
|
||||||
int64_t y;
|
btInt64_t y;
|
||||||
int64_t z;
|
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);
|
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;
|
return x * b.x + y * b.y + z * b.z;
|
||||||
}
|
}
|
||||||
@@ -78,16 +82,16 @@ class b3ConvexHullInternal
|
|||||||
class Point32
|
class Point32
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int32_t x;
|
btInt32_t x;
|
||||||
int32_t y;
|
btInt32_t y;
|
||||||
int32_t z;
|
btInt32_t z;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
Point32()
|
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);
|
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;
|
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;
|
return x * b.x + y * b.y + z * b.z;
|
||||||
}
|
}
|
||||||
@@ -140,32 +144,32 @@ class b3ConvexHullInternal
|
|||||||
class Int128
|
class Int128
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
uint64_t low;
|
btUint64_t low;
|
||||||
uint64_t high;
|
btUint64_t high;
|
||||||
|
|
||||||
Int128()
|
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
|
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
|
Int128 operator+(const Int128& b) const
|
||||||
@@ -179,7 +183,7 @@ class b3ConvexHullInternal
|
|||||||
: "cc" );
|
: "cc" );
|
||||||
return result;
|
return result;
|
||||||
#else
|
#else
|
||||||
uint64_t lo = low + b.low;
|
btUint64_t lo = low + b.low;
|
||||||
return Int128(lo, high + b.high + (lo < low));
|
return Int128(lo, high + b.high + (lo < low));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -208,7 +212,7 @@ class b3ConvexHullInternal
|
|||||||
: "0"(low), "1"(high), [bl] "g"(b.low), [bh] "g"(b.high)
|
: "0"(low), "1"(high), [bl] "g"(b.low), [bh] "g"(b.high)
|
||||||
: "cc" );
|
: "cc" );
|
||||||
#else
|
#else
|
||||||
uint64_t lo = low + b.low;
|
btUint64_t lo = low + b.low;
|
||||||
if (lo < low)
|
if (lo < low)
|
||||||
{
|
{
|
||||||
++high;
|
++high;
|
||||||
@@ -228,17 +232,17 @@ class b3ConvexHullInternal
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Int128 operator*(int64_t b) const;
|
Int128 operator*(btInt64_t b) const;
|
||||||
|
|
||||||
b3Scalar toScalar() 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();
|
: -(-*this).toScalar();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSign() const
|
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
|
bool operator<(const Int128& b) const
|
||||||
@@ -272,22 +276,22 @@ class b3ConvexHullInternal
|
|||||||
class Rational64
|
class Rational64
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
uint64_t m_numerator;
|
btUint64_t m_numerator;
|
||||||
uint64_t m_denominator;
|
btUint64_t m_denominator;
|
||||||
int sign;
|
int sign;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Rational64(int64_t numerator, int64_t denominator)
|
Rational64(btInt64_t numerator, btInt64_t denominator)
|
||||||
{
|
{
|
||||||
if (numerator > 0)
|
if (numerator > 0)
|
||||||
{
|
{
|
||||||
sign = 1;
|
sign = 1;
|
||||||
m_numerator = (uint64_t) numerator;
|
m_numerator = (btUint64_t) numerator;
|
||||||
}
|
}
|
||||||
else if (numerator < 0)
|
else if (numerator < 0)
|
||||||
{
|
{
|
||||||
sign = -1;
|
sign = -1;
|
||||||
m_numerator = (uint64_t) -numerator;
|
m_numerator = (btUint64_t) -numerator;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -296,12 +300,12 @@ class b3ConvexHullInternal
|
|||||||
}
|
}
|
||||||
if (denominator > 0)
|
if (denominator > 0)
|
||||||
{
|
{
|
||||||
m_denominator = (uint64_t) denominator;
|
m_denominator = (btUint64_t) denominator;
|
||||||
}
|
}
|
||||||
else if (denominator < 0)
|
else if (denominator < 0)
|
||||||
{
|
{
|
||||||
sign = -sign;
|
sign = -sign;
|
||||||
m_denominator = (uint64_t) -denominator;
|
m_denominator = (btUint64_t) -denominator;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -323,7 +327,7 @@ class b3ConvexHullInternal
|
|||||||
|
|
||||||
b3Scalar toScalar() const
|
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;
|
bool isInt64;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Rational128(int64_t value)
|
Rational128(btInt64_t value)
|
||||||
{
|
{
|
||||||
if (value > 0)
|
if (value > 0)
|
||||||
{
|
{
|
||||||
@@ -352,9 +356,9 @@ class b3ConvexHullInternal
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sign = 0;
|
sign = 0;
|
||||||
this->numerator = (uint64_t) 0;
|
this->numerator = (btUint64_t) 0;
|
||||||
}
|
}
|
||||||
this->denominator = (uint64_t) 1;
|
this->denominator = (btUint64_t) 1;
|
||||||
isInt64 = true;
|
isInt64 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,11 +388,11 @@ class b3ConvexHullInternal
|
|||||||
|
|
||||||
int compare(const Rational128& b) const;
|
int compare(const Rational128& b) const;
|
||||||
|
|
||||||
int compare(int64_t b) const;
|
int compare(btInt64_t b) const;
|
||||||
|
|
||||||
b3Scalar toScalar() 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<typename UWord, typename UHWord> class DMul
|
template<typename UWord, typename UHWord> class DMul
|
||||||
{
|
{
|
||||||
private:
|
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;
|
value <<= 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t high(Int128 value)
|
static btUint64_t high(Int128 value)
|
||||||
{
|
{
|
||||||
return value.high;
|
return value.high;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t low(Int128 value)
|
static btUint64_t low(Int128 value)
|
||||||
{
|
{
|
||||||
return value.low;
|
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);
|
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;
|
Int128 a = negative ? -*this : *this;
|
||||||
if (b < 0)
|
if (b < 0)
|
||||||
{
|
{
|
||||||
negative = !negative;
|
negative = !negative;
|
||||||
b = -b;
|
b = -b;
|
||||||
}
|
}
|
||||||
Int128 result = mul(a.low, (uint64_t) b);
|
Int128 result = mul(a.low, (btUint64_t) b);
|
||||||
result.high += a.high * (uint64_t) b;
|
result.high += a.high * (btUint64_t) b;
|
||||||
return negative ? -result : result;
|
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;
|
Int128 result;
|
||||||
|
|
||||||
@@ -871,12 +875,12 @@ b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(int64_t a, int64_
|
|||||||
negative = !negative;
|
negative = !negative;
|
||||||
b = -b;
|
b = -b;
|
||||||
}
|
}
|
||||||
DMul<uint64_t, uint32_t>::mul((uint64_t) a, (uint64_t) b, result.low, result.high);
|
DMul<btUint64_t, btUint32_t>::mul((btUint64_t) a, (btUint64_t) b, result.low, result.high);
|
||||||
return negative ? -result : result;
|
return negative ? -result : result;
|
||||||
#endif
|
#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;
|
Int128 result;
|
||||||
|
|
||||||
@@ -887,7 +891,7 @@ b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(uint64_t a, uint6
|
|||||||
: "cc" );
|
: "cc" );
|
||||||
|
|
||||||
#else
|
#else
|
||||||
DMul<uint64_t, uint32_t>::mul(a, b, result.low, result.high);
|
DMul<btUint64_t, btUint32_t>::mul(a, b, result.low, result.high);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -909,8 +913,8 @@ int b3ConvexHullInternal::Rational64::compare(const Rational64& b) const
|
|||||||
#ifdef USE_X86_64_ASM
|
#ifdef USE_X86_64_ASM
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
int64_t tmp;
|
btInt64_t tmp;
|
||||||
int64_t dummy;
|
btInt64_t dummy;
|
||||||
__asm__ ("mulq %[bn]\n\t"
|
__asm__ ("mulq %[bn]\n\t"
|
||||||
"movq %%rax, %[tmp]\n\t"
|
"movq %%rax, %[tmp]\n\t"
|
||||||
"movq %%rdx, %%rbx\n\t"
|
"movq %%rdx, %%rbx\n\t"
|
||||||
@@ -949,12 +953,12 @@ int b3ConvexHullInternal::Rational128::compare(const Rational128& b) const
|
|||||||
}
|
}
|
||||||
if (isInt64)
|
if (isInt64)
|
||||||
{
|
{
|
||||||
return -b.compare(sign * (int64_t) numerator.low);
|
return -b.compare(sign * (btInt64_t) numerator.low);
|
||||||
}
|
}
|
||||||
|
|
||||||
Int128 nbdLow, nbdHigh, dbnLow, dbnHigh;
|
Int128 nbdLow, nbdHigh, dbnLow, dbnHigh;
|
||||||
DMul<Int128, uint64_t>::mul(numerator, b.denominator, nbdLow, nbdHigh);
|
DMul<Int128, btUint64_t>::mul(numerator, b.denominator, nbdLow, nbdHigh);
|
||||||
DMul<Int128, uint64_t>::mul(denominator, b.numerator, dbnLow, dbnHigh);
|
DMul<Int128, btUint64_t>::mul(denominator, b.numerator, dbnLow, dbnHigh);
|
||||||
|
|
||||||
int cmp = nbdHigh.ucmp(dbnHigh);
|
int cmp = nbdHigh.ucmp(dbnHigh);
|
||||||
if (cmp)
|
if (cmp)
|
||||||
@@ -964,11 +968,11 @@ int b3ConvexHullInternal::Rational128::compare(const Rational128& b) const
|
|||||||
return nbdLow.ucmp(dbnLow) * sign;
|
return nbdLow.ucmp(dbnLow) * sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
int b3ConvexHullInternal::Rational128::compare(int64_t b) const
|
int b3ConvexHullInternal::Rational128::compare(btInt64_t b) const
|
||||||
{
|
{
|
||||||
if (isInt64)
|
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;
|
return (a > b) ? 1 : (a < b) ? -1 : 0;
|
||||||
}
|
}
|
||||||
if (b > 0)
|
if (b > 0)
|
||||||
@@ -1067,22 +1071,22 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
|||||||
v1 = h1.maxXy;
|
v1 = h1.maxXy;
|
||||||
Vertex* v00 = NULL;
|
Vertex* v00 = NULL;
|
||||||
Vertex* v10 = NULL;
|
Vertex* v10 = NULL;
|
||||||
int32_t sign = 1;
|
btInt32_t sign = 1;
|
||||||
|
|
||||||
for (int side = 0; side <= 1; side++)
|
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)
|
if (dx > 0)
|
||||||
{
|
{
|
||||||
while (true)
|
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;
|
Vertex* w0 = side ? v0->next : v0->prev;
|
||||||
if (w0 != v0)
|
if (w0 != v0)
|
||||||
{
|
{
|
||||||
int32_t dx0 = (w0->point.x - v0->point.x) * sign;
|
btInt32_t dx0 = (w0->point.x - v0->point.x) * sign;
|
||||||
int32_t dy0 = w0->point.y - v0->point.y;
|
btInt32_t dy0 = w0->point.y - v0->point.y;
|
||||||
if ((dy0 <= 0) && ((dx0 == 0) || ((dx0 < 0) && (dy0 * dx <= dy * dx0))))
|
if ((dy0 <= 0) && ((dx0 == 0) || ((dx0 < 0) && (dy0 * dx <= dy * dx0))))
|
||||||
{
|
{
|
||||||
v0 = w0;
|
v0 = w0;
|
||||||
@@ -1094,9 +1098,9 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
|||||||
Vertex* w1 = side ? v1->next : v1->prev;
|
Vertex* w1 = side ? v1->next : v1->prev;
|
||||||
if (w1 != v1)
|
if (w1 != v1)
|
||||||
{
|
{
|
||||||
int32_t dx1 = (w1->point.x - v1->point.x) * sign;
|
btInt32_t dx1 = (w1->point.x - v1->point.x) * sign;
|
||||||
int32_t dy1 = w1->point.y - v1->point.y;
|
btInt32_t dy1 = w1->point.y - v1->point.y;
|
||||||
int32_t dxn = (w1->point.x - v0->point.x) * sign;
|
btInt32_t dxn = (w1->point.x - v0->point.x) * sign;
|
||||||
if ((dxn > 0) && (dy1 < 0) && ((dx1 == 0) || ((dx1 < 0) && (dy1 * dx < dy * dx1))))
|
if ((dxn > 0) && (dy1 < 0) && ((dx1 == 0) || ((dx1 < 0) && (dy1 * dx < dy * dx1))))
|
||||||
{
|
{
|
||||||
v1 = w1;
|
v1 = w1;
|
||||||
@@ -1112,13 +1116,13 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
|||||||
{
|
{
|
||||||
while (true)
|
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;
|
Vertex* w1 = side ? v1->prev : v1->next;
|
||||||
if (w1 != v1)
|
if (w1 != v1)
|
||||||
{
|
{
|
||||||
int32_t dx1 = (w1->point.x - v1->point.x) * sign;
|
btInt32_t dx1 = (w1->point.x - v1->point.x) * sign;
|
||||||
int32_t dy1 = w1->point.y - v1->point.y;
|
btInt32_t dy1 = w1->point.y - v1->point.y;
|
||||||
if ((dy1 >= 0) && ((dx1 == 0) || ((dx1 < 0) && (dy1 * dx <= dy * dx1))))
|
if ((dy1 >= 0) && ((dx1 == 0) || ((dx1 < 0) && (dy1 * dx <= dy * dx1))))
|
||||||
{
|
{
|
||||||
v1 = w1;
|
v1 = w1;
|
||||||
@@ -1130,9 +1134,9 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
|||||||
Vertex* w0 = side ? v0->prev : v0->next;
|
Vertex* w0 = side ? v0->prev : v0->next;
|
||||||
if (w0 != v0)
|
if (w0 != v0)
|
||||||
{
|
{
|
||||||
int32_t dx0 = (w0->point.x - v0->point.x) * sign;
|
btInt32_t dx0 = (w0->point.x - v0->point.x) * sign;
|
||||||
int32_t dy0 = w0->point.y - v0->point.y;
|
btInt32_t dy0 = w0->point.y - v0->point.y;
|
||||||
int32_t dxn = (v1->point.x - w0->point.x) * sign;
|
btInt32_t dxn = (v1->point.x - w0->point.x) * sign;
|
||||||
if ((dxn < 0) && (dy0 > 0) && ((dx0 == 0) || ((dx0 < 0) && (dy0 * dx < dy * dx0))))
|
if ((dxn < 0) && (dy0 > 0) && ((dx0 == 0) || ((dx0 < 0) && (dy0 * dx < dy * dx0))))
|
||||||
{
|
{
|
||||||
v0 = w0;
|
v0 = w0;
|
||||||
@@ -1146,8 +1150,8 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int32_t x = v0->point.x;
|
btInt32_t x = v0->point.x;
|
||||||
int32_t y0 = v0->point.y;
|
btInt32_t y0 = v0->point.y;
|
||||||
Vertex* w0 = v0;
|
Vertex* w0 = v0;
|
||||||
Vertex* t;
|
Vertex* t;
|
||||||
while (((t = side ? w0->next : w0->prev) != v0) && (t->point.x == x) && (t->point.y <= y0))
|
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;
|
v0 = w0;
|
||||||
|
|
||||||
int32_t y1 = v1->point.y;
|
btInt32_t y1 = v1->point.y;
|
||||||
Vertex* w1 = v1;
|
Vertex* w1 = v1;
|
||||||
while (((t = side ? w1->prev : w1->next) != v1) && (t->point.x == x) && (t->point.y >= y1))
|
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;
|
Vertex* w = v + 1;
|
||||||
if (v->point != w->point)
|
if (v->point != w->point)
|
||||||
{
|
{
|
||||||
int32_t dx = v->point.x - w->point.x;
|
btInt32_t dx = v->point.x - w->point.x;
|
||||||
int32_t dy = v->point.y - w->point.y;
|
btInt32_t dy = v->point.y - w->point.y;
|
||||||
|
|
||||||
if ((dx == 0) && (dy == 0))
|
if ((dx == 0) && (dy == 0))
|
||||||
{
|
{
|
||||||
@@ -1392,7 +1396,7 @@ b3ConvexHullInternal::Orientation b3ConvexHullInternal::getOrientation(const Edg
|
|||||||
Point64 n = t.cross(s);
|
Point64 n = t.cross(s);
|
||||||
Point64 m = (*prev->target - *next->reverse->target).cross(*next->target - *next->reverse->target);
|
Point64 m = (*prev->target - *next->reverse->target).cross(*next->target - *next->reverse->target);
|
||||||
b3Assert(!m.isZero());
|
b3Assert(!m.isZero());
|
||||||
int64_t dot = n.dot(m);
|
btInt64_t dot = n.dot(m);
|
||||||
b3Assert(dot != 0);
|
b3Assert(dot != 0);
|
||||||
return (dot > 0) ? COUNTER_CLOCKWISE : CLOCKWISE;
|
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 et1 = start1 ? start1->target->point : c1->point;
|
||||||
Point32 s = c1->point - c0->point;
|
Point32 s = c1->point - c0->point;
|
||||||
Point64 normal = ((start0 ? start0 : start1)->target->point - c0->point).cross(s);
|
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));
|
b3Assert(!start1 || (start1->target->point.dot(normal) == dist));
|
||||||
Point64 perp = s.cross(normal);
|
Point64 perp = s.cross(normal);
|
||||||
b3Assert(!perp.isZero());
|
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);
|
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
|
#endif
|
||||||
|
|
||||||
int64_t maxDot0 = et0.dot(perp);
|
btInt64_t maxDot0 = et0.dot(perp);
|
||||||
if (e0)
|
if (e0)
|
||||||
{
|
{
|
||||||
while (e0->target != stop0)
|
while (e0->target != stop0)
|
||||||
@@ -1492,7 +1496,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int64_t dot = e->target->point.dot(perp);
|
btInt64_t dot = e->target->point.dot(perp);
|
||||||
if (dot <= maxDot0)
|
if (dot <= maxDot0)
|
||||||
{
|
{
|
||||||
break;
|
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)
|
if (e1)
|
||||||
{
|
{
|
||||||
while (e1->target != stop1)
|
while (e1->target != stop1)
|
||||||
@@ -1518,7 +1522,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int64_t dot = e->target->point.dot(perp);
|
btInt64_t dot = e->target->point.dot(perp);
|
||||||
if (dot <= maxDot1)
|
if (dot <= maxDot1)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -1533,20 +1537,20 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
|||||||
printf(" Starting at %d %d\n", et0.index, et1.index);
|
printf(" Starting at %d %d\n", et0.index, et1.index);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int64_t dx = maxDot1 - maxDot0;
|
btInt64_t dx = maxDot1 - maxDot0;
|
||||||
if (dx > 0)
|
if (dx > 0)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int64_t dy = (et1 - et0).dot(s);
|
btInt64_t dy = (et1 - et0).dot(s);
|
||||||
|
|
||||||
if (e0 && (e0->target != stop0))
|
if (e0 && (e0->target != stop0))
|
||||||
{
|
{
|
||||||
Edge* f0 = e0->next->reverse;
|
Edge* f0 = e0->next->reverse;
|
||||||
if (f0->copy > mergeStamp)
|
if (f0->copy > mergeStamp)
|
||||||
{
|
{
|
||||||
int64_t dx0 = (f0->target->point - et0).dot(perp);
|
btInt64_t dx0 = (f0->target->point - et0).dot(perp);
|
||||||
int64_t dy0 = (f0->target->point - et0).dot(s);
|
btInt64_t dy0 = (f0->target->point - et0).dot(s);
|
||||||
if ((dx0 == 0) ? (dy0 < 0) : ((dx0 < 0) && (Rational64(dy0, dx0).compare(Rational64(dy, dx)) >= 0)))
|
if ((dx0 == 0) ? (dy0 < 0) : ((dx0 < 0) && (Rational64(dy0, dx0).compare(Rational64(dy, dx)) >= 0)))
|
||||||
{
|
{
|
||||||
et0 = f0->target->point;
|
et0 = f0->target->point;
|
||||||
@@ -1565,9 +1569,9 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
|||||||
Point32 d1 = f1->target->point - et1;
|
Point32 d1 = f1->target->point - et1;
|
||||||
if (d1.dot(normal) == 0)
|
if (d1.dot(normal) == 0)
|
||||||
{
|
{
|
||||||
int64_t dx1 = d1.dot(perp);
|
btInt64_t dx1 = d1.dot(perp);
|
||||||
int64_t dy1 = d1.dot(s);
|
btInt64_t dy1 = d1.dot(s);
|
||||||
int64_t dxn = (f1->target->point - et0).dot(perp);
|
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))))
|
if ((dxn > 0) && ((dx1 == 0) ? (dy1 < 0) : ((dx1 < 0) && (Rational64(dy1, dx1).compare(Rational64(dy, dx)) > 0))))
|
||||||
{
|
{
|
||||||
e1 = f1;
|
e1 = f1;
|
||||||
@@ -1590,15 +1594,15 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int64_t dy = (et1 - et0).dot(s);
|
btInt64_t dy = (et1 - et0).dot(s);
|
||||||
|
|
||||||
if (e1 && (e1->target != stop1))
|
if (e1 && (e1->target != stop1))
|
||||||
{
|
{
|
||||||
Edge* f1 = e1->prev->reverse;
|
Edge* f1 = e1->prev->reverse;
|
||||||
if (f1->copy > mergeStamp)
|
if (f1->copy > mergeStamp)
|
||||||
{
|
{
|
||||||
int64_t dx1 = (f1->target->point - et1).dot(perp);
|
btInt64_t dx1 = (f1->target->point - et1).dot(perp);
|
||||||
int64_t dy1 = (f1->target->point - et1).dot(s);
|
btInt64_t dy1 = (f1->target->point - et1).dot(s);
|
||||||
if ((dx1 == 0) ? (dy1 > 0) : ((dx1 < 0) && (Rational64(dy1, dx1).compare(Rational64(dy, dx)) <= 0)))
|
if ((dx1 == 0) ? (dy1 > 0) : ((dx1 < 0) && (Rational64(dy1, dx1).compare(Rational64(dy, dx)) <= 0)))
|
||||||
{
|
{
|
||||||
et1 = f1->target->point;
|
et1 = f1->target->point;
|
||||||
@@ -1617,9 +1621,9 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
|||||||
Point32 d0 = f0->target->point - et0;
|
Point32 d0 = f0->target->point - et0;
|
||||||
if (d0.dot(normal) == 0)
|
if (d0.dot(normal) == 0)
|
||||||
{
|
{
|
||||||
int64_t dx0 = d0.dot(perp);
|
btInt64_t dx0 = d0.dot(perp);
|
||||||
int64_t dy0 = d0.dot(s);
|
btInt64_t dy0 = d0.dot(s);
|
||||||
int64_t dxn = (et1 - f0->target->point).dot(perp);
|
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))))
|
if ((dxn < 0) && ((dx0 == 0) ? (dy0 > 0) : ((dx0 < 0) && (Rational64(dy0, dx0).compare(Rational64(dy, dx)) < 0))))
|
||||||
{
|
{
|
||||||
e0 = f0;
|
e0 = f0;
|
||||||
@@ -1683,7 +1687,7 @@ void b3ConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1)
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int64_t dot = (*e->target - *c0).dot(normal);
|
btInt64_t dot = (*e->target - *c0).dot(normal);
|
||||||
b3Assert(dot <= 0);
|
b3Assert(dot <= 0);
|
||||||
if ((dot == 0) && ((*e->target - *c0).dot(t) > 0))
|
if ((dot == 0) && ((*e->target - *c0).dot(t) > 0))
|
||||||
{
|
{
|
||||||
@@ -1702,7 +1706,7 @@ void b3ConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1)
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int64_t dot = (*e->target - *c1).dot(normal);
|
btInt64_t dot = (*e->target - *c1).dot(normal);
|
||||||
b3Assert(dot <= 0);
|
b3Assert(dot <= 0);
|
||||||
if ((dot == 0) && ((*e->target - *c1).dot(t) > 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))));
|
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]);
|
b3Vector3 p((b3Scalar) v[0], (b3Scalar) v[1], (b3Scalar) v[2]);
|
||||||
ptr += stride;
|
ptr += stride;
|
||||||
p = (p - center) * s;
|
p = (p - center) * s;
|
||||||
points[i].x = (int32_t) p[medAxis];
|
points[i].x = (btInt32_t) p[medAxis];
|
||||||
points[i].y = (int32_t) p[maxAxis];
|
points[i].y = (btInt32_t) p[maxAxis];
|
||||||
points[i].z = (int32_t) p[minAxis];
|
points[i].z = (btInt32_t) p[minAxis];
|
||||||
points[i].index = i;
|
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]);
|
b3Vector3 p(v[0], v[1], v[2]);
|
||||||
ptr += stride;
|
ptr += stride;
|
||||||
p = (p - center) * s;
|
p = (p - center) * s;
|
||||||
points[i].x = (int32_t) p[medAxis];
|
points[i].x = (btInt32_t) p[medAxis];
|
||||||
points[i].y = (int32_t) p[maxAxis];
|
points[i].y = (btInt32_t) p[maxAxis];
|
||||||
points[i].z = (int32_t) p[minAxis];
|
points[i].z = (btInt32_t) p[minAxis];
|
||||||
points[i].index = i;
|
points[i].index = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
points.quickSort(pointCmp);
|
points.quickSort(b3PointCmp);
|
||||||
|
|
||||||
vertexPool.reset();
|
vertexPool.reset();
|
||||||
vertexPool.setArraySize(count);
|
vertexPool.setArraySize(count);
|
||||||
@@ -2126,7 +2130,7 @@ b3Scalar b3ConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount)
|
|||||||
{
|
{
|
||||||
if (a && b)
|
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);
|
b3Assert(vol >= 0);
|
||||||
Point32 c = v->point + a->point + b->point + ref;
|
Point32 c = v->point + a->point + b->point + ref;
|
||||||
hullCenterX += vol * c.x;
|
hullCenterX += vol * c.x;
|
||||||
@@ -2166,7 +2170,7 @@ b3Scalar b3ConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount)
|
|||||||
|
|
||||||
if (clampAmount > 0)
|
if (clampAmount > 0)
|
||||||
{
|
{
|
||||||
b3Scalar minDist = SIMD_INFINITY;
|
b3Scalar minDist = B3_INFINITY;
|
||||||
for (int i = 0; i < faceCount; i++)
|
for (int i = 0; i < faceCount; i++)
|
||||||
{
|
{
|
||||||
b3Vector3 normal = getBtNormal(faces[i]);
|
b3Vector3 normal = getBtNormal(faces[i]);
|
||||||
@@ -2217,7 +2221,7 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec
|
|||||||
{
|
{
|
||||||
origShift[2] /= scaling[2];
|
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())
|
if (shift.isZero())
|
||||||
{
|
{
|
||||||
return true;
|
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",
|
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);
|
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
|
#endif
|
||||||
int64_t origDot = face->origin.dot(normal);
|
btInt64_t origDot = face->origin.dot(normal);
|
||||||
Point32 shiftedOrigin = face->origin + shift;
|
Point32 shiftedOrigin = face->origin + shift;
|
||||||
int64_t shiftedDot = shiftedOrigin.dot(normal);
|
btInt64_t shiftedDot = shiftedOrigin.dot(normal);
|
||||||
b3Assert(shiftedDot <= origDot);
|
b3Assert(shiftedDot <= origDot);
|
||||||
if (shiftedDot >= origDot)
|
if (shiftedDot >= origDot)
|
||||||
{
|
{
|
||||||
@@ -2463,12 +2467,12 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec
|
|||||||
|
|
||||||
Point64 n0 = intersection->face->getNormal();
|
Point64 n0 = intersection->face->getNormal();
|
||||||
Point64 n1 = intersection->reverse->face->getNormal();
|
Point64 n1 = intersection->reverse->face->getNormal();
|
||||||
int64_t m00 = face->dir0.dot(n0);
|
btInt64_t m00 = face->dir0.dot(n0);
|
||||||
int64_t m01 = face->dir1.dot(n0);
|
btInt64_t m01 = face->dir1.dot(n0);
|
||||||
int64_t m10 = face->dir0.dot(n1);
|
btInt64_t m10 = face->dir0.dot(n1);
|
||||||
int64_t m11 = face->dir1.dot(n1);
|
btInt64_t m11 = face->dir1.dot(n1);
|
||||||
int64_t r0 = (intersection->face->origin - shiftedOrigin).dot(n0);
|
btInt64_t r0 = (intersection->face->origin - shiftedOrigin).dot(n0);
|
||||||
int64_t r1 = (intersection->reverse->face->origin - shiftedOrigin).dot(n1);
|
btInt64_t r1 = (intersection->reverse->face->origin - shiftedOrigin).dot(n1);
|
||||||
Int128 det = Int128::mul(m00, m11) - Int128::mul(m01, m10);
|
Int128 det = Int128::mul(m00, m11) - Int128::mul(m01, m10);
|
||||||
b3Assert(det.getSign() != 0);
|
b3Assert(det.getSign() != 0);
|
||||||
Vertex* v = vertexPool.newObject();
|
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->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,
|
+ Int128::mul(face->dir1.z * r1, m00) - Int128::mul(face->dir1.z * r0, m10) + det * shiftedOrigin.z,
|
||||||
det);
|
det);
|
||||||
v->point.x = (int32_t) v->point128.xvalue();
|
v->point.x = (btInt32_t) v->point128.xvalue();
|
||||||
v->point.y = (int32_t) v->point128.yvalue();
|
v->point.y = (btInt32_t) v->point128.yvalue();
|
||||||
v->point.z = (int32_t) v->point128.zvalue();
|
v->point.z = (btInt32_t) v->point128.zvalue();
|
||||||
intersection->target = v;
|
intersection->target = v;
|
||||||
v->edges = e;
|
v->edges = e;
|
||||||
|
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ subject to the following restrictions:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef GRAHAM_SCAN_2D_CONVEX_HULL_H
|
#ifndef B3_GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||||
#define GRAHAM_SCAN_2D_CONVEX_HULL_H
|
#define B3_GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||||
|
|
||||||
|
|
||||||
#include "Bullet3Common/b3Vector3.h"
|
#include "Bullet3Common/b3Vector3.h"
|
||||||
#include "Bullet3Common/b3AlignedObjectArray.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),
|
:b3Vector3(org),
|
||||||
m_orgIndex(orgIndex)
|
m_orgIndex(orgIndex)
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ struct b3AngleCompareFunc {
|
|||||||
: m_anchor(anchor)
|
: 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)
|
if (a.m_angle != b.m_angle)
|
||||||
return a.m_angle < b.m_angle;
|
return a.m_angle < b.m_angle;
|
||||||
else
|
else
|
||||||
@@ -56,7 +56,7 @@ struct b3AngleCompareFunc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void GrahamScanConvexHull2D(b3AlignedObjectArray<GrahamVector3>& originalPoints, b3AlignedObjectArray<GrahamVector3>& hull, const b3Vector3& normalAxis)
|
inline void b3GrahamScanConvexHull2D(b3AlignedObjectArray<b3GrahamVector3>& originalPoints, b3AlignedObjectArray<b3GrahamVector3>& hull, const b3Vector3& normalAxis)
|
||||||
{
|
{
|
||||||
b3Vector3 axis0,axis1;
|
b3Vector3 axis0,axis1;
|
||||||
b3PlaneSpace1(normalAxis,axis0,axis1);
|
b3PlaneSpace1(normalAxis,axis0,axis1);
|
||||||
@@ -114,4 +114,4 @@ inline void GrahamScanConvexHull2D(b3AlignedObjectArray<GrahamVector3>& original
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //GRAHAM_SCAN_2D_CONVEX_HULL_H
|
#endif //B3_GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
// Auto generated from Bullet/Extras/HeaderGenerator/bulletGenerate.py
|
// Auto generated from Bullet/Extras/HeaderGenerator/bulletGenerate.py
|
||||||
#ifndef __BULLET_H__
|
#ifndef __BULLET_H__
|
||||||
#define __BULLET_H__
|
#define __BULLET_H__
|
||||||
namespace Bullet {
|
namespace Bullet3SerializeBullet2 {
|
||||||
|
|
||||||
// put an empty struct in the case
|
// put an empty struct in the case
|
||||||
typedef struct bInvalidHandle {
|
typedef struct bInvalidHandle {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ subject to the following restrictions:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "b3BulletFile.h"
|
#include "b3BulletFile.h"
|
||||||
#include "bDefines.h"
|
#include "b3Defines.h"
|
||||||
#include "bDNA.h"
|
#include "b3DNA.h"
|
||||||
|
|
||||||
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
@@ -26,18 +26,18 @@ subject to the following restrictions:
|
|||||||
// 32 && 64 bit versions
|
// 32 && 64 bit versions
|
||||||
#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
extern char sBulletDNAstr64[];
|
extern char b3s_bulletDNAstr64[];
|
||||||
extern int sBulletDNAlen64;
|
extern int b3s_bulletDNAlen64;
|
||||||
#else
|
#else
|
||||||
extern char sBulletDNAstr[];
|
extern char b3s_bulletDNAstr[];
|
||||||
extern int sBulletDNAlen;
|
extern int b3s_bulletDNAlen;
|
||||||
#endif //_WIN64
|
#endif //_WIN64
|
||||||
#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
|
|
||||||
extern char sBulletDNAstr64[];
|
extern char b3s_bulletDNAstr64[];
|
||||||
extern int sBulletDNAlen64;
|
extern int b3s_bulletDNAlen64;
|
||||||
extern char sBulletDNAstr[];
|
extern char b3s_bulletDNAstr[];
|
||||||
extern int sBulletDNAlen;
|
extern int b3s_bulletDNAlen;
|
||||||
|
|
||||||
#endif //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#endif //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
|
|
||||||
@@ -53,26 +53,26 @@ b3BulletFile::b3BulletFile()
|
|||||||
|
|
||||||
#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16);
|
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen64,16);
|
||||||
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
|
memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64);
|
||||||
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64);
|
mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen64);
|
||||||
#else//_WIN64
|
#else//_WIN64
|
||||||
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16);
|
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen,16);
|
||||||
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
|
memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen);
|
||||||
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen);
|
mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen);
|
||||||
#endif//_WIN64
|
#endif//_WIN64
|
||||||
#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
if (VOID_IS_8)
|
if (VOID_IS_8)
|
||||||
{
|
{
|
||||||
m_DnaCopy = (char*) b3AlignedAlloc(sBulletDNAlen64,16);
|
m_DnaCopy = (char*) b3AlignedAlloc(b3s_bulletDNAlen64,16);
|
||||||
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
|
memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64);
|
||||||
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64);
|
mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen64);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_DnaCopy =(char*) b3AlignedAlloc(sBulletDNAlen,16);
|
m_DnaCopy =(char*) b3AlignedAlloc(b3s_bulletDNAlen,16);
|
||||||
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
|
memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen);
|
||||||
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen);
|
mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen);
|
||||||
}
|
}
|
||||||
#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
}
|
}
|
||||||
@@ -141,13 +141,13 @@ void b3BulletFile::parseData()
|
|||||||
//dataPtr += ChunkUtils::getOffset(mFlags);
|
//dataPtr += ChunkUtils::getOffset(mFlags);
|
||||||
char *dataPtrHead = 0;
|
char *dataPtrHead = 0;
|
||||||
|
|
||||||
while (dataChunk.code != DNA1)
|
while (dataChunk.code != B3_DNA1)
|
||||||
{
|
{
|
||||||
if (!brokenDNA || (dataChunk.code != B3_QUANTIZED_BVH_CODE) )
|
if (!brokenDNA || (dataChunk.code != B3_QUANTIZED_BVH_CODE) )
|
||||||
{
|
{
|
||||||
|
|
||||||
// one behind
|
// one behind
|
||||||
if (dataChunk.code == SDNA) break;
|
if (dataChunk.code == B3_SDNA) break;
|
||||||
//if (dataChunk.code == DNA1) break;
|
//if (dataChunk.code == DNA1) break;
|
||||||
|
|
||||||
// same as (BHEAD+DATA dependency)
|
// same as (BHEAD+DATA dependency)
|
||||||
@@ -250,17 +250,17 @@ void b3BulletFile::writeDNA(FILE* fp)
|
|||||||
{
|
{
|
||||||
|
|
||||||
bChunkInd dataChunk;
|
bChunkInd dataChunk;
|
||||||
dataChunk.code = DNA1;
|
dataChunk.code = B3_DNA1;
|
||||||
dataChunk.dna_nr = 0;
|
dataChunk.dna_nr = 0;
|
||||||
dataChunk.nr = 1;
|
dataChunk.nr = 1;
|
||||||
#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
if (VOID_IS_8)
|
if (VOID_IS_8)
|
||||||
{
|
{
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
dataChunk.len = sBulletDNAlen64;
|
dataChunk.len = b3s_bulletDNAlen64;
|
||||||
dataChunk.oldPtr = sBulletDNAstr64;
|
dataChunk.oldPtr = b3s_bulletDNAstr64;
|
||||||
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
||||||
fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp);
|
fwrite(b3s_bulletDNAstr64, b3s_bulletDNAlen64,1,fp);
|
||||||
#else
|
#else
|
||||||
b3Assert(0);
|
b3Assert(0);
|
||||||
#endif
|
#endif
|
||||||
@@ -268,10 +268,10 @@ void b3BulletFile::writeDNA(FILE* fp)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef _WIN64
|
#ifndef _WIN64
|
||||||
dataChunk.len = sBulletDNAlen;
|
dataChunk.len = b3s_bulletDNAlen;
|
||||||
dataChunk.oldPtr = sBulletDNAstr;
|
dataChunk.oldPtr = b3s_bulletDNAstr;
|
||||||
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
||||||
fwrite(sBulletDNAstr, sBulletDNAlen,1,fp);
|
fwrite(b3s_bulletDNAstr, b3s_bulletDNAlen,1,fp);
|
||||||
#else//_WIN64
|
#else//_WIN64
|
||||||
b3Assert(0);
|
b3Assert(0);
|
||||||
#endif//_WIN64
|
#endif//_WIN64
|
||||||
@@ -279,17 +279,17 @@ void b3BulletFile::writeDNA(FILE* fp)
|
|||||||
#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
if (VOID_IS_8)
|
if (VOID_IS_8)
|
||||||
{
|
{
|
||||||
dataChunk.len = sBulletDNAlen64;
|
dataChunk.len = b3s_bulletDNAlen64;
|
||||||
dataChunk.oldPtr = sBulletDNAstr64;
|
dataChunk.oldPtr = b3s_bulletDNAstr64;
|
||||||
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
||||||
fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp);
|
fwrite(b3s_bulletDNAstr64, b3s_bulletDNAlen64,1,fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dataChunk.len = sBulletDNAlen;
|
dataChunk.len = b3s_bulletDNAlen;
|
||||||
dataChunk.oldPtr = sBulletDNAstr;
|
dataChunk.oldPtr = b3s_bulletDNAstr;
|
||||||
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
||||||
fwrite(sBulletDNAstr, sBulletDNAlen,1,fp);
|
fwrite(b3s_bulletDNAstr, b3s_bulletDNAlen,1,fp);
|
||||||
}
|
}
|
||||||
#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
}
|
}
|
||||||
@@ -304,9 +304,9 @@ void b3BulletFile::parse(int verboseMode)
|
|||||||
|
|
||||||
if (m_DnaCopy)
|
if (m_DnaCopy)
|
||||||
delete m_DnaCopy;
|
delete m_DnaCopy;
|
||||||
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16);
|
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen64,16);
|
||||||
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
|
memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64);
|
||||||
parseInternal(verboseMode,(char*)sBulletDNAstr64,sBulletDNAlen64);
|
parseInternal(verboseMode,(char*)b3s_bulletDNAstr64,b3s_bulletDNAlen64);
|
||||||
#else
|
#else
|
||||||
b3Assert(0);
|
b3Assert(0);
|
||||||
#endif
|
#endif
|
||||||
@@ -317,9 +317,9 @@ void b3BulletFile::parse(int verboseMode)
|
|||||||
|
|
||||||
if (m_DnaCopy)
|
if (m_DnaCopy)
|
||||||
delete m_DnaCopy;
|
delete m_DnaCopy;
|
||||||
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16);
|
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen,16);
|
||||||
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
|
memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen);
|
||||||
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen);
|
parseInternal(verboseMode,m_DnaCopy,b3s_bulletDNAlen);
|
||||||
#else
|
#else
|
||||||
b3Assert(0);
|
b3Assert(0);
|
||||||
#endif
|
#endif
|
||||||
@@ -329,17 +329,17 @@ void b3BulletFile::parse(int verboseMode)
|
|||||||
{
|
{
|
||||||
if (m_DnaCopy)
|
if (m_DnaCopy)
|
||||||
delete m_DnaCopy;
|
delete m_DnaCopy;
|
||||||
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16);
|
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen64,16);
|
||||||
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
|
memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64);
|
||||||
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen64);
|
parseInternal(verboseMode,m_DnaCopy,b3s_bulletDNAlen64);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_DnaCopy)
|
if (m_DnaCopy)
|
||||||
delete m_DnaCopy;
|
delete m_DnaCopy;
|
||||||
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16);
|
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen,16);
|
||||||
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
|
memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen);
|
||||||
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen);
|
parseInternal(verboseMode,m_DnaCopy,b3s_bulletDNAlen);
|
||||||
}
|
}
|
||||||
#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ int b3BulletFile::write(const char* fileName, bool fixupPointers)
|
|||||||
FILE *fp = fopen(fileName, "wb");
|
FILE *fp = fopen(fileName, "wb");
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
char header[SIZEOFBLENDERHEADER] ;
|
char header[B3_SIZEOFBLENDERHEADER] ;
|
||||||
memcpy(header, m_headerString, 7);
|
memcpy(header, m_headerString, 7);
|
||||||
int endian= 1;
|
int endian= 1;
|
||||||
endian= ((char*)&endian)[0];
|
endian= ((char*)&endian)[0];
|
||||||
@@ -383,7 +383,7 @@ int b3BulletFile::write(const char* fileName, bool fixupPointers)
|
|||||||
header[10] = '7';
|
header[10] = '7';
|
||||||
header[11] = '5';
|
header[11] = '5';
|
||||||
|
|
||||||
fwrite(header,SIZEOFBLENDERHEADER,1,fp);
|
fwrite(header,B3_SIZEOFBLENDERHEADER,1,fp);
|
||||||
|
|
||||||
writeChunks(fp, fixupPointers);
|
writeChunks(fp, fixupPointers);
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ subject to the following restrictions:
|
|||||||
#define B3_BULLET_FILE_H
|
#define B3_BULLET_FILE_H
|
||||||
|
|
||||||
|
|
||||||
#include "bFile.h"
|
#include "b3File.h"
|
||||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||||
#include "bDefines.h"
|
#include "b3Defines.h"
|
||||||
|
|
||||||
#include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h"
|
#include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h"
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ subject to the following restrictions:
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bChunk.h"
|
#include "b3Chunk.h"
|
||||||
#include "bDefines.h"
|
#include "b3Defines.h"
|
||||||
#include "bFile.h"
|
#include "b3File.h"
|
||||||
|
|
||||||
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
@@ -29,21 +29,21 @@ using namespace bParse;
|
|||||||
// ----------------------------------------------------- //
|
// ----------------------------------------------------- //
|
||||||
short ChunkUtils::swapShort(short sht)
|
short ChunkUtils::swapShort(short sht)
|
||||||
{
|
{
|
||||||
SWITCH_SHORT(sht);
|
B3_SWITCH_SHORT(sht);
|
||||||
return sht;
|
return sht;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------- //
|
// ----------------------------------------------------- //
|
||||||
int ChunkUtils::swapInt(int inte)
|
int ChunkUtils::swapInt(int inte)
|
||||||
{
|
{
|
||||||
SWITCH_INT(inte);
|
B3_SWITCH_INT(inte);
|
||||||
return inte;
|
return inte;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------- //
|
// ----------------------------------------------------- //
|
||||||
long64 ChunkUtils::swapLong64(long64 lng)
|
b3Long64 ChunkUtils::swapLong64(b3Long64 lng)
|
||||||
{
|
{
|
||||||
SWITCH_LONGINT(lng);
|
B3_SWITCH_LONGINT(lng);
|
||||||
return lng;
|
return lng;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,12 +17,12 @@ subject to the following restrictions:
|
|||||||
#define __BCHUNK_H__
|
#define __BCHUNK_H__
|
||||||
|
|
||||||
#if defined (_WIN32) && ! defined (__MINGW32__)
|
#if defined (_WIN32) && ! defined (__MINGW32__)
|
||||||
#define long64 __int64
|
#define b3Long64 __int64
|
||||||
#elif defined (__MINGW32__)
|
#elif defined (__MINGW32__)
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#define long64 int64_t
|
#define b3Long64 int64_t
|
||||||
#else
|
#else
|
||||||
#define long64 long long
|
#define b3Long64 long long
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ namespace bParse {
|
|||||||
int code, len;
|
int code, len;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
long64 oldPrev;
|
b3Long64 oldPrev;
|
||||||
int m_uniqueInts[2];
|
int m_uniqueInts[2];
|
||||||
};
|
};
|
||||||
int dna_nr, nr;
|
int dna_nr, nr;
|
||||||
@@ -80,7 +80,7 @@ namespace bParse {
|
|||||||
// endian utils
|
// endian utils
|
||||||
static short swapShort(short sht);
|
static short swapShort(short sht);
|
||||||
static int swapInt(int inte);
|
static int swapInt(int inte);
|
||||||
static long64 swapLong64(long64 lng);
|
static b3Long64 swapLong64(b3Long64 lng);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ subject to the following restrictions:
|
|||||||
*/
|
*/
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "bDNA.h"
|
#include "b3DNA.h"
|
||||||
#include "bChunk.h"
|
#include "b3Chunk.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -17,7 +17,7 @@ subject to the following restrictions:
|
|||||||
#define __BDNA_H__
|
#define __BDNA_H__
|
||||||
|
|
||||||
|
|
||||||
#include "bCommon.h"
|
#include "b3Common.h"
|
||||||
|
|
||||||
namespace bParse {
|
namespace bParse {
|
||||||
|
|
||||||
136
src/Bullet3Serialize/Bullet2FileLoader/b3Defines.h
Normal file
136
src/Bullet3Serialize/Bullet2FileLoader/b3Defines.h
Normal file
@@ -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__
|
||||||
@@ -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.
|
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.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
#include "bFile.h"
|
#include "b3File.h"
|
||||||
#include "bCommon.h"
|
#include "b3Common.h"
|
||||||
#include "bChunk.h"
|
#include "b3Chunk.h"
|
||||||
#include "bDNA.h"
|
#include "b3DNA.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "bDefines.h"
|
#include "b3Defines.h"
|
||||||
#include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h"
|
#include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h"
|
||||||
#include "Bullet3Common/b3AlignedAllocator.h"
|
#include "Bullet3Common/b3AlignedAllocator.h"
|
||||||
#include "Bullet3Common/b3MinMax.h"
|
#include "Bullet3Common/b3MinMax.h"
|
||||||
|
|
||||||
#define SIZEOFBLENDERHEADER 12
|
#define B3_SIZEOFBLENDERHEADER 12
|
||||||
#define MAX_ARRAY_LENGTH 512
|
#define MAX_ARRAY_LENGTH 512
|
||||||
using namespace bParse;
|
using namespace bParse;
|
||||||
#define MAX_STRLEN 1024
|
#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])
|
bFile::bFile(const char *filename, const char headerString[7])
|
||||||
@@ -133,13 +132,13 @@ void bFile::parseHeader()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
char *blenderBuf = mFileBuffer;
|
char *blenderBuf = mFileBuffer;
|
||||||
char header[SIZEOFBLENDERHEADER+1] ;
|
char header[B3_SIZEOFBLENDERHEADER+1] ;
|
||||||
memcpy(header, blenderBuf, SIZEOFBLENDERHEADER);
|
memcpy(header, blenderBuf, B3_SIZEOFBLENDERHEADER);
|
||||||
header[SIZEOFBLENDERHEADER]='\0';
|
header[B3_SIZEOFBLENDERHEADER]='\0';
|
||||||
|
|
||||||
if (strncmp(header, m_headerString, 6)!=0)
|
if (strncmp(header, m_headerString, 6)!=0)
|
||||||
{
|
{
|
||||||
memcpy(header, m_headerString, SIZEOFBLENDERHEADER);
|
memcpy(header, m_headerString, B3_SIZEOFBLENDERHEADER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,17 +343,17 @@ void bFile::swapLen(char *dataPtr)
|
|||||||
bChunkPtr4*c = (bChunkPtr4*) dataPtr;
|
bChunkPtr4*c = (bChunkPtr4*) dataPtr;
|
||||||
if ((c->code & 0xFFFF)==0)
|
if ((c->code & 0xFFFF)==0)
|
||||||
c->code >>=16;
|
c->code >>=16;
|
||||||
SWITCH_INT(c->len);
|
B3_SWITCH_INT(c->len);
|
||||||
SWITCH_INT(c->dna_nr);
|
B3_SWITCH_INT(c->dna_nr);
|
||||||
SWITCH_INT(c->nr);
|
B3_SWITCH_INT(c->nr);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
bChunkPtr8* c = (bChunkPtr8*) dataPtr;
|
bChunkPtr8* c = (bChunkPtr8*) dataPtr;
|
||||||
if ((c->code & 0xFFFF)==0)
|
if ((c->code & 0xFFFF)==0)
|
||||||
c->code >>=16;
|
c->code >>=16;
|
||||||
SWITCH_INT(c->len);
|
B3_SWITCH_INT(c->len);
|
||||||
SWITCH_INT(c->dna_nr);
|
B3_SWITCH_INT(c->dna_nr);
|
||||||
SWITCH_INT(c->nr);
|
B3_SWITCH_INT(c->nr);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -364,19 +363,19 @@ void bFile::swapLen(char *dataPtr)
|
|||||||
bChunkPtr8*c = (bChunkPtr8*) dataPtr;
|
bChunkPtr8*c = (bChunkPtr8*) dataPtr;
|
||||||
if ((c->code & 0xFFFF)==0)
|
if ((c->code & 0xFFFF)==0)
|
||||||
c->code >>=16;
|
c->code >>=16;
|
||||||
SWITCH_INT(c->len);
|
B3_SWITCH_INT(c->len);
|
||||||
SWITCH_INT(c->dna_nr);
|
B3_SWITCH_INT(c->dna_nr);
|
||||||
SWITCH_INT(c->nr);
|
B3_SWITCH_INT(c->nr);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
bChunkPtr4* c = (bChunkPtr4*) dataPtr;
|
bChunkPtr4* c = (bChunkPtr4*) dataPtr;
|
||||||
if ((c->code & 0xFFFF)==0)
|
if ((c->code & 0xFFFF)==0)
|
||||||
c->code >>=16;
|
c->code >>=16;
|
||||||
SWITCH_INT(c->len);
|
B3_SWITCH_INT(c->len);
|
||||||
|
|
||||||
SWITCH_INT(c->dna_nr);
|
B3_SWITCH_INT(c->dna_nr);
|
||||||
SWITCH_INT(c->nr);
|
B3_SWITCH_INT(c->nr);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -596,7 +595,7 @@ void bFile::preSwap()
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
// one behind
|
// 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);
|
swapDNA(dataPtr);
|
||||||
@@ -678,7 +677,7 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
|
|||||||
dest[i] = src[i];
|
dest[i] = src[i];
|
||||||
if (mFlags &FD_ENDIAN_SWAP)
|
if (mFlags &FD_ENDIAN_SWAP)
|
||||||
{
|
{
|
||||||
SWITCH_SHORT(dest[i]);
|
B3_SWITCH_SHORT(dest[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addDataBlock(dataAlloc);
|
addDataBlock(dataAlloc);
|
||||||
@@ -709,7 +708,6 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
|
|||||||
assert((strcmp(oldType, newType)==0) && "internal error, struct mismatch!");
|
assert((strcmp(oldType, newType)==0) && "internal error, struct mismatch!");
|
||||||
|
|
||||||
|
|
||||||
numallocs++;
|
|
||||||
// numBlocks * length
|
// numBlocks * length
|
||||||
|
|
||||||
int allocLen = (curLen);
|
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)
|
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)\
|
if (strcmp(current, type)==0)\
|
||||||
{\
|
{\
|
||||||
value = (*(cast*)ptr);\
|
value = (*(cast*)ptr);\
|
||||||
ptr += size;\
|
ptr += size;\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define setEle(value, current, type, cast, size, ptr)\
|
#define b3SetEle(value, current, type, cast, size, ptr)\
|
||||||
if (strcmp(current, type)==0)\
|
if (strcmp(current, type)==0)\
|
||||||
{\
|
{\
|
||||||
(*(cast*)ptr) = (cast)value;\
|
(*(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<arrayLen; i++)
|
for (int i=0; i<arrayLen; i++)
|
||||||
{
|
{
|
||||||
getEle(value, old, "char", char, sizeof(char), oldPtr);
|
b3GetEle(value, old, "char", char, sizeof(char), oldPtr);
|
||||||
setEle(value, cur, "char", char, sizeof(char), curData);
|
b3SetEle(value, cur, "char", char, sizeof(char), curData);
|
||||||
getEle(value, old, "short", short, sizeof(short), oldPtr);
|
b3GetEle(value, old, "short", short, sizeof(short), oldPtr);
|
||||||
setEle(value, cur, "short", short, sizeof(short), curData);
|
b3SetEle(value, cur, "short", short, sizeof(short), curData);
|
||||||
getEle(value, old, "ushort", unsigned short, sizeof(unsigned short), oldPtr);
|
b3GetEle(value, old, "ushort", unsigned short, sizeof(unsigned short), oldPtr);
|
||||||
setEle(value, cur, "ushort", unsigned short, sizeof(unsigned short), curData);
|
b3SetEle(value, cur, "ushort", unsigned short, sizeof(unsigned short), curData);
|
||||||
getEle(value, old, "int", int, sizeof(int), oldPtr);
|
b3GetEle(value, old, "int", int, sizeof(int), oldPtr);
|
||||||
setEle(value, cur, "int", int, sizeof(int), curData);
|
b3SetEle(value, cur, "int", int, sizeof(int), curData);
|
||||||
getEle(value, old, "long", int, sizeof(int), oldPtr);
|
b3GetEle(value, old, "long", int, sizeof(int), oldPtr);
|
||||||
setEle(value, cur, "long", int, sizeof(int), curData);
|
b3SetEle(value, cur, "long", int, sizeof(int), curData);
|
||||||
getEle(value, old, "float", float, sizeof(float), oldPtr);
|
b3GetEle(value, old, "float", float, sizeof(float), oldPtr);
|
||||||
setEle(value, cur, "float", float, sizeof(float), curData);
|
b3SetEle(value, cur, "float", float, sizeof(float), curData);
|
||||||
getEle(value, old, "double", double, sizeof(double), oldPtr);
|
b3GetEle(value, old, "double", double, sizeof(double), oldPtr);
|
||||||
setEle(value, cur, "double", double, sizeof(double), curData);
|
b3SetEle(value, cur, "double", double, sizeof(double), curData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,10 +945,10 @@ void bFile::safeSwapPtr(char *dst, const char *src)
|
|||||||
{
|
{
|
||||||
//deal with pointers the Blender .blend style way, see
|
//deal with pointers the Blender .blend style way, see
|
||||||
//readfile.c in the Blender source tree
|
//readfile.c in the Blender source tree
|
||||||
long64 longValue = *((long64*)src);
|
b3Long64 longValue = *((b3Long64*)src);
|
||||||
//endian swap for 64bit pointer otherwise truncation will fail due to trailing zeros
|
//endian swap for 64bit pointer otherwise truncation will fail due to trailing zeros
|
||||||
if (mFlags & FD_ENDIAN_SWAP)
|
if (mFlags & FD_ENDIAN_SWAP)
|
||||||
SWITCH_LONGINT(longValue);
|
B3_SWITCH_LONGINT(longValue);
|
||||||
*((int*)dst) = (int)(longValue>>3);
|
*((int*)dst) = (int)(longValue>>3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -965,7 +963,7 @@ void bFile::safeSwapPtr(char *dst, const char *src)
|
|||||||
newPtr->m_uniqueIds[1] = 0;
|
newPtr->m_uniqueIds[1] = 0;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
*((long64*)dst)= *((int*)src);
|
*((b3Long64*)dst)= *((int*)src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1654,9 +1652,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
|
|||||||
if ((chunk.code & 0xFFFF)==0)
|
if ((chunk.code & 0xFFFF)==0)
|
||||||
chunk.code >>=16;
|
chunk.code >>=16;
|
||||||
|
|
||||||
SWITCH_INT(chunk.len);
|
B3_SWITCH_INT(chunk.len);
|
||||||
SWITCH_INT(chunk.dna_nr);
|
B3_SWITCH_INT(chunk.dna_nr);
|
||||||
SWITCH_INT(chunk.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)
|
if ((c.code & 0xFFFF)==0)
|
||||||
c.code >>=16;
|
c.code >>=16;
|
||||||
|
|
||||||
SWITCH_INT(c.len);
|
B3_SWITCH_INT(c.len);
|
||||||
SWITCH_INT(c.dna_nr);
|
B3_SWITCH_INT(c.dna_nr);
|
||||||
SWITCH_INT(c.nr);
|
B3_SWITCH_INT(c.nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dataChunk, &c, sizeof(bChunkInd));
|
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];
|
chunk.m_uniqueInt = head.m_uniqueInts[0];
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
long64 oldPtr =0;
|
b3Long64 oldPtr =0;
|
||||||
memcpy(&oldPtr, &head.m_uniqueInts[0], 8);
|
memcpy(&oldPtr, &head.m_uniqueInts[0], 8);
|
||||||
if (swap)
|
if (swap)
|
||||||
SWITCH_LONGINT(oldPtr);
|
B3_SWITCH_LONGINT(oldPtr);
|
||||||
chunk.m_uniqueInt = (int)(oldPtr >> 3);
|
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)
|
if ((chunk.code & 0xFFFF)==0)
|
||||||
chunk.code >>=16;
|
chunk.code >>=16;
|
||||||
|
|
||||||
SWITCH_INT(chunk.len);
|
B3_SWITCH_INT(chunk.len);
|
||||||
SWITCH_INT(chunk.dna_nr);
|
B3_SWITCH_INT(chunk.dna_nr);
|
||||||
SWITCH_INT(chunk.nr);
|
B3_SWITCH_INT(chunk.nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dataChunk, &chunk, sizeof(bChunkInd));
|
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)
|
if ((c.code & 0xFFFF)==0)
|
||||||
c.code >>=16;
|
c.code >>=16;
|
||||||
|
|
||||||
SWITCH_INT(c.len);
|
B3_SWITCH_INT(c.len);
|
||||||
SWITCH_INT(c.dna_nr);
|
B3_SWITCH_INT(c.dna_nr);
|
||||||
SWITCH_INT(c.nr);
|
B3_SWITCH_INT(c.nr);
|
||||||
}
|
}
|
||||||
memcpy(dataChunk, &c, sizeof(bChunkInd));
|
memcpy(dataChunk, &c, sizeof(bChunkInd));
|
||||||
}
|
}
|
||||||
@@ -16,8 +16,8 @@ subject to the following restrictions:
|
|||||||
#ifndef __BFILE_H__
|
#ifndef __BFILE_H__
|
||||||
#define __BFILE_H__
|
#define __BFILE_H__
|
||||||
|
|
||||||
#include "bCommon.h"
|
#include "b3Common.h"
|
||||||
#include "bChunk.h"
|
#include "b3Chunk.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace bParse {
|
namespace bParse {
|
||||||
@@ -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(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(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),
|
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(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(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),};
|
char(4),char(0),char(61),char(1),char(71),char(0),char(62),char(1),};
|
||||||
int sBulletDNAlen= sizeof(sBulletDNAstr);
|
int b3s_bulletDNAlen= sizeof(b3s_bulletDNAstr);
|
||||||
char sBulletDNAstr64[]= {
|
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(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(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),
|
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(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(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),};
|
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);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ subject to the following restrictions:
|
|||||||
#ifndef B3_SERIALIZER_H
|
#ifndef B3_SERIALIZER_H
|
||||||
#define 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/b3StackAlloc.h"
|
||||||
#include "Bullet3Common/b3HashMap.h"
|
#include "Bullet3Common/b3HashMap.h"
|
||||||
|
|
||||||
@@ -27,13 +27,12 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
///only the 32bit versions for now
|
extern char b3s_bulletDNAstr[];
|
||||||
extern char sBulletDNAstr[];
|
extern int b3s_bulletDNAlen;
|
||||||
extern int sBulletDNAlen;
|
extern char b3s_bulletDNAstr64[];
|
||||||
extern char sBulletDNAstr64[];
|
extern int b3s_bulletDNAlen64;
|
||||||
extern int sBulletDNAlen64;
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE int b3StrLen(const char* str)
|
B3_FORCE_INLINE int b3StrLen(const char* str)
|
||||||
{
|
{
|
||||||
if (!str)
|
if (!str)
|
||||||
return(0);
|
return(0);
|
||||||
@@ -374,14 +373,14 @@ public:
|
|||||||
if (VOID_IS_8)
|
if (VOID_IS_8)
|
||||||
{
|
{
|
||||||
#if _WIN64
|
#if _WIN64
|
||||||
initDNA((const char*)sBulletDNAstr64,sBulletDNAlen64);
|
initDNA((const char*)b3s_bulletDNAstr64,b3s_bulletDNAlen64);
|
||||||
#else
|
#else
|
||||||
b3Assert(0);
|
b3Assert(0);
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
#ifndef _WIN64
|
#ifndef _WIN64
|
||||||
initDNA((const char*)sBulletDNAstr,sBulletDNAlen);
|
initDNA((const char*)b3s_bulletDNAstr,b3s_bulletDNAlen);
|
||||||
#else
|
#else
|
||||||
b3Assert(0);
|
b3Assert(0);
|
||||||
#endif
|
#endif
|
||||||
@@ -390,10 +389,10 @@ public:
|
|||||||
#else //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#else //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
if (VOID_IS_8)
|
if (VOID_IS_8)
|
||||||
{
|
{
|
||||||
initDNA((const char*)sBulletDNAstr64,sBulletDNAlen64);
|
initDNA((const char*)b3s_bulletDNAstr64,b3s_bulletDNAlen64);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
initDNA((const char*)sBulletDNAstr,sBulletDNAlen);
|
initDNA((const char*)b3s_bulletDNAstr,b3s_bulletDNAlen);
|
||||||
}
|
}
|
||||||
#endif //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
#endif //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||||
|
|
||||||
|
|||||||
@@ -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__
|
|
||||||
@@ -35,7 +35,7 @@ inline void broadphaseTest()
|
|||||||
{
|
{
|
||||||
TEST_INIT;
|
TEST_INIT;
|
||||||
|
|
||||||
b3DynamicBvhBroadphase* bp = new b3DynamicBvhBroadphase(1);
|
b3DynamicBvhBroadphase* bp = new b3DynamicBvhBroadphase(2);
|
||||||
|
|
||||||
int group=1;
|
int group=1;
|
||||||
int mask=1;
|
int mask=1;
|
||||||
|
|||||||
Reference in New Issue
Block a user