fixes in Jam msvcgen -> use SSE instead of SSE2 to stay compatible with older AMD Athlon XP processors, updated build files, minor compile fixes for GPU experimental code

This commit is contained in:
erwin.coumans
2009-05-09 21:25:42 +00:00
parent 9da45d5751
commit 0a360904b6
14 changed files with 312 additions and 251 deletions

View File

@@ -0,0 +1,32 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL }
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBox2dDemo
main.cpp
Box2dDemo.cpp
btBox2dBox2dCollisionAlgorithm.h
Box2dDemo.h
btBox2dShape.cpp
btBox2dBox2dCollisionAlgorithm.cpp
btBox2dShape.h
)

3
Demos/Box2dDemo/Jamfile Normal file
View File

@@ -0,0 +1,3 @@
SubDir TOP Demos Box2dDemo ;
BulletDemo Box2dDemo : [ Wildcard *.h *.cpp ] ;

View File

@@ -1,7 +1,7 @@
if (CMAKE_SIZEOF_VOID_P MATCHES "8") if (CMAKE_SIZEOF_VOID_P MATCHES "8")
SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld
CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer
RagdollDemo ForkLiftDemo BasicDemo BspDemo MovingConcaveDemo VehicleDemo RagdollDemo ForkLiftDemo BasicDemo Box2dDemo Gpu2dDemo BspDemo MovingConcaveDemo VehicleDemo
ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo HeightFieldFluidDemo ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo HeightFieldFluidDemo
CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo
DoublePrecisionDemo ConcaveDemo CollisionDemo DoublePrecisionDemo ConcaveDemo CollisionDemo
@@ -10,7 +10,7 @@ MultiMaterialDemo)
else (CMAKE_SIZEOF_VOID_P MATCHES "8") else (CMAKE_SIZEOF_VOID_P MATCHES "8")
SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld
MultiThreadedDemo CcdPhysicsDemo ConstraintDemo SliderConstraintDemo Raytracer MultiThreadedDemo CcdPhysicsDemo ConstraintDemo SliderConstraintDemo Raytracer
GenericJointDemo RagdollDemo ForkLiftDemo BasicDemo BspDemo MovingConcaveDemo GenericJointDemo RagdollDemo ForkLiftDemo BasicDemo Box2dDemo Gpu2dDemo BspDemo MovingConcaveDemo
VehicleDemo ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo VehicleDemo ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo
HeightFieldFluidDemo HeightFieldFluidDemo
CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo

View File

@@ -19,8 +19,20 @@ LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
) )
ADD_EXECUTABLE(AppBasicDemo ADD_EXECUTABLE(AppGpu2dDemo
main.cpp main.cpp
BasicDemo.cpp BasicDemo.cpp
BasicDemo.h
btGpuDemoPairCache.cpp
btGpuDemoPairCache.h
btGpuDemo2dSharedTypes.h
btGpuDemo2dCpuFunc.cpp
btGpuDemoDynamicsWorld.cpp
btGpuDemoDynamicsWorld.h
oecakeLoader.cpp
oecakeLoader.h
btGpuDemo2dSharedCode.h
btGpuDemo2dSharedDefs.h
) )

View File

@@ -1,3 +1,3 @@
SubDir TOP Demos BasicDemo ; SubDir TOP Demos Gpu2dDemo ;
BulletDemo BasicDemo : [ Wildcard *.h *.cpp ] ; BulletDemo Gpu2dDemo : [ Wildcard *.h *.cpp ] ;

View File

@@ -19,6 +19,7 @@ subject to the following restrictions:
#define FRICTION_BOX_GROUND_FACT 0.05f #define FRICTION_BOX_GROUND_FACT 0.05f
#define FRICTION_BOX_BOX_FACT 0.05f #define FRICTION_BOX_BOX_FACT 0.05f
#define USE_CENTERS 1 #define USE_CENTERS 1
#include "LinearMath/btMinMax.h"
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
@@ -58,6 +59,7 @@ BT_GPU___device__ void testSphSph(float3 aPos, float3 bPos, float radA, float ra
float dist = BT_GPU_dot(del, del); float dist = BT_GPU_dot(del, del);
dist = sqrtf(dist); dist = sqrtf(dist);
float maxD = radA + radB; float maxD = radA + radB;
if(dist > maxD) if(dist > maxD)
{ {
return; return;
@@ -76,7 +78,9 @@ BT_GPU___device__ void testSphSph(float3 aPos, float3 bPos, float radA, float ra
normal = BT_GPU_make_float3(1.f, 0.f, 0.f); normal = BT_GPU_make_float3(1.f, 0.f, 0.f);
} }
// float3 contact = (bPos + aPos + normal * (radB - radA)) * 0.5f; // float3 contact = (bPos + aPos + normal * (radB - radA)) * 0.5f;
float3 contact = aPos - normal * radA; float3 tmp = (normal * radA);
float3 contact = aPos - tmp;
// now add point // now add point
int numPoints = 0; int numPoints = 0;
for(int i = 0; i < MAX_VTX_PER_OBJ; i++) for(int i = 0; i < MAX_VTX_PER_OBJ; i++)
@@ -143,14 +147,20 @@ BT_GPU___global__ void setConstraintDataD(int2 *constraints,
for(i = 0; i < numSphA; i++) for(i = 0; i < numSphA; i++)
{ {
float3 va = aPos; float3 va = aPos;
va += ai * shapeA[i].x; float3 tmp = ai * shapeA[i].x;
va += aj * shapeA[i].y; float3 tmp2 = aj * shapeA[i].y;
va += tmp;
va += tmp2;
float radA = shapeA[i].w; float radA = shapeA[i].w;
for(j = 0; j < numSphB; j++) for(j = 0; j < numSphB; j++)
{ {
float3 vb = bPos; float3 vb = bPos;
vb += bi * shapeB[j].x; float3 tmp =bi * shapeB[j].x;
vb += bj * shapeB[j].y; float3 tmp2 = bj * shapeB[j].y;
vb += tmp;
vb += tmp2;
float radB = shapeB[j].w; float radB = shapeB[j].w;
testSphSph(va, vb, radA, radB, pOut); testSphSph(va, vb, radA, radB, pOut);
} }
@@ -174,7 +184,7 @@ BT_GPU___device__ float computeImpulse1(float3 rVel,
if(positionConstraint > 0) if(positionConstraint > 0)
return lambdaDt; return lambdaDt;
positionConstraint = min(0.0f,positionConstraint+penetrationError); positionConstraint = btMin(0.0f,positionConstraint+penetrationError);
lambdaDt = -(BT_GPU_dot(cNormal,rVel)*(1+collisionConstant)); lambdaDt = -(BT_GPU_dot(cNormal,rVel)*(1+collisionConstant));
lambdaDt -= (baumgarteConstant/dt*positionConstraint); lambdaDt -= (baumgarteConstant/dt*positionConstraint);
@@ -216,7 +226,8 @@ BT_GPU___global__ void collisionWithWallBoxD(float4 *pos,
float3 aVel = BT_GPU_make_float3(vel[idx].x, vel[idx].y, vel[idx].z); float3 aVel = BT_GPU_make_float3(vel[idx].x, vel[idx].y, vel[idx].z);
float aAngVel = angVel[idx]; float aAngVel = angVel[idx];
float3 rerVertex = ai * shape[iVtx].x; float3 rerVertex = ai * shape[iVtx].x;
rerVertex += aj * shape[iVtx].y; float3 tmp = aj * shape[iVtx].y;
rerVertex += tmp;
float3 vPos = aPos + rerVertex; float3 vPos = aPos + rerVertex;
float rad = shape[iVtx].w; float rad = shape[iVtx].w;
float3 vVel =aVel+BT_GPU_cross(BT_GPU_make_float3(0.0f,0.0f,aAngVel),rerVertex); float3 vVel =aVel+BT_GPU_cross(BT_GPU_make_float3(0.0f,0.0f,aAngVel),rerVertex);
@@ -239,11 +250,14 @@ BT_GPU___global__ void collisionWithWallBoxD(float4 *pos,
{ {
lat_vel_len = sqrtf(lat_vel_len); lat_vel_len = sqrtf(lat_vel_len);
lat_vel *= 1.f/lat_vel_len; lat_vel *= 1.f/lat_vel_len;
impulse -= lat_vel * BT_GPU_dot(lat_vel, vVel) * FRICTION_BOX_GROUND_FACT; float3 tmp = lat_vel * BT_GPU_dot(lat_vel, vVel) * FRICTION_BOX_GROUND_FACT;
impulse -= tmp;
} }
#endif //USE_FRICTION #endif //USE_FRICTION
vel[idx] += BT_GPU_make_float42(impulse,0.0f); float4 tmp = BT_GPU_make_float42(impulse,0.0f);
angVel[idx] += BT_GPU_cross(rerVertex,impulse).z; vel[idx] += tmp;
float tmp2 = BT_GPU_cross(rerVertex,impulse).z;
angVel[idx] += tmp2;
} }
} }
@@ -257,7 +271,8 @@ BT_GPU___global__ void collisionWithWallBoxD(float4 *pos,
BT_GPU_make_float3(1.0f,0.0f,0.0f), BT_GPU_make_float3(1.0f,0.0f,0.0f),
dt); dt);
vel[idx] += BT_GPU_make_float42(impulse,0.0f); float4 tmp = BT_GPU_make_float42(impulse,0.0f);
vel[idx] += tmp;
angVel[idx] += BT_GPU_cross(rerVertex,impulse).z; angVel[idx] += BT_GPU_cross(rerVertex,impulse).z;
} }
} }
@@ -272,7 +287,8 @@ BT_GPU___global__ void collisionWithWallBoxD(float4 *pos,
BT_GPU_make_float3(-1.0f,0.0f,0.0f), BT_GPU_make_float3(-1.0f,0.0f,0.0f),
dt); dt);
vel[idx] += BT_GPU_make_float42(impulse,0.0f); float4 tmp = BT_GPU_make_float42(impulse,0.0f);
vel[idx] += tmp;
angVel[idx] += BT_GPU_cross(rerVertex,impulse).z; angVel[idx] += BT_GPU_cross(rerVertex,impulse).z;
} }
} }
@@ -326,7 +342,7 @@ BT_GPU___device__ void collisionResolutionBox( int constrId,
{ {
float rLambdaDt=lambdaDtBox[(MAX_VTX_PER_OBJ)*(2*constrId)+iVtx]; float rLambdaDt=lambdaDtBox[(MAX_VTX_PER_OBJ)*(2*constrId)+iVtx];
float pLambdaDt=rLambdaDt; float pLambdaDt=rLambdaDt;
rLambdaDt=max(pLambdaDt+lambdaDt,0.0f); rLambdaDt=btMax(pLambdaDt+lambdaDt,0.0f);
lambdaDt=rLambdaDt-pLambdaDt; lambdaDt=rLambdaDt-pLambdaDt;
lambdaDtBox[(MAX_VTX_PER_OBJ)*(2*constrId)+iVtx]=rLambdaDt; lambdaDtBox[(MAX_VTX_PER_OBJ)*(2*constrId)+iVtx]=rLambdaDt;
} }
@@ -340,7 +356,8 @@ BT_GPU___device__ void collisionResolutionBox( int constrId,
{ {
lat_vel_len = sqrtf(lat_vel_len); lat_vel_len = sqrtf(lat_vel_len);
lat_vel *= 1.f/lat_vel_len; lat_vel *= 1.f/lat_vel_len;
impulse -= lat_vel * BT_GPU_dot(lat_vel , relVel) * FRICTION_BOX_BOX_FACT; float3 tmp = lat_vel * BT_GPU_dot(lat_vel , relVel) * FRICTION_BOX_BOX_FACT;
impulse -= tmp;
} }
} }
#endif //USE_FRICTION #endif //USE_FRICTION

View File

@@ -81,6 +81,8 @@ SubInclude TOP Demos EPAPenDepthDemo ;
SubInclude TOP Demos HelloWorld ; SubInclude TOP Demos HelloWorld ;
SubInclude TOP Demos BspDemo ; SubInclude TOP Demos BspDemo ;
SubInclude TOP Demos BasicDemo ; SubInclude TOP Demos BasicDemo ;
SubInclude TOP Demos Box2dDemo ;
SubInclude TOP Demos Gpu2dDemo ;
SubInclude TOP Demos ConvexDecompositionDemo ; SubInclude TOP Demos ConvexDecompositionDemo ;
SubInclude TOP Demos ColladaDemo ; SubInclude TOP Demos ColladaDemo ;
SubInclude TOP Demos CharacterDemo ; SubInclude TOP Demos CharacterDemo ;

View File

@@ -16,8 +16,9 @@ subject to the following restrictions:
#include "GLDebugFont.h" #include "GLDebugFont.h"
#include "GlutStuff.h" #include "GlutStuff.h"
#include <stdio.h> #include <stdio.h>
#include <string>
unsigned char sFontData[]; extern unsigned char sFontData[];
static GLuint sTexture = -1; static GLuint sTexture = -1;
static int sScreenWidth = 0; static int sScreenWidth = 0;
static int sScreenHeight = 0; static int sScreenHeight = 0;

View File

@@ -368,7 +368,7 @@ void renderSquareA(float x, float y, float z)
glEnd(); glEnd();
} }
inline void glDrawVector(btVector3& v) { glVertex3d(v[0], v[1], v[2]); } inline void glDrawVector(const btVector3& v) { glVertex3d(v[0], v[1], v[2]); }
void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax) void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax)

View File

@@ -219,7 +219,7 @@ projtypes = {
}, },
library => library =>
{ {
defines = ['_LIB', '_WINDOWS','_CRT_SECURE_NO_DEPRECATE','_CRT_NONSTDC_NO_DEPRECATE'] defines = ['_LIB', '_CONSOLE','_CRT_SECURE_NO_DEPRECATE','_CRT_NONSTDC_NO_DEPRECATE']
} }
}; };

View File

@@ -68,13 +68,13 @@
[% MACRO compiler_release BLOCK -%] [% MACRO compiler_release BLOCK -%]
EnableIntrinsicFunctions="true" EnableIntrinsicFunctions="true"
EnableEnhancedInstructionSet="2" EnableEnhancedInstructionSet="1"
FloatingPointModel="2" FloatingPointModel="2"
Optimization="2" Optimization="2"
StringPooling="TRUE" StringPooling="TRUE"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
RuntimeLibrary="0" RuntimeLibrary="0"
DebugInformationFormat="3" DebugInformationFormat="1"
BufferSecurityCheck="FALSE" BufferSecurityCheck="FALSE"
[% END %] [% END %]
[% MACRO compiler_release_dll BLOCK -%] [% MACRO compiler_release_dll BLOCK -%]
@@ -88,21 +88,21 @@
[% MACRO compiler_debug BLOCK -%] [% MACRO compiler_debug BLOCK -%]
Optimization="0" Optimization="0"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
DebugInformationFormat="4" DebugInformationFormat="3"
RuntimeTypeInfo="FALSE" RuntimeTypeInfo="FALSE"
RuntimeLibrary="1" RuntimeLibrary="1"
[% END %] [% END %]
[% MACRO compiler_debug_dll BLOCK -%] [% MACRO compiler_debug_dll BLOCK -%]
Optimization="0" Optimization="0"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
DebugInformationFormat="4" DebugInformationFormat="3"
RuntimeTypeInfo="FALSE" RuntimeTypeInfo="FALSE"
RuntimeLibrary="3" RuntimeLibrary="3"
[% END %] [% END %]
[% MACRO compiler_debug_dbl BLOCK -%] [% MACRO compiler_debug_dbl BLOCK -%]
Optimization="0" Optimization="0"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
DebugInformationFormat="4" DebugInformationFormat="3"
RuntimeTypeInfo="FALSE" RuntimeTypeInfo="FALSE"
RuntimeLibrary="1" RuntimeLibrary="1"
[% END %] [% END %]
@@ -110,7 +110,7 @@
LinkIncremental="1" LinkIncremental="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
GenerateDebugInformation="TRUE" GenerateDebugInformation="FALSE"
IgnoreDefaultLibraryNames="LIBC,LIBCD" IgnoreDefaultLibraryNames="LIBC,LIBCD"
[% END %] [% END %]
[% MACRO linker_debug BLOCK -%] [% MACRO linker_debug BLOCK -%]

View File

@@ -77,7 +77,7 @@
[% MACRO compiler_debug BLOCK -%] [% MACRO compiler_debug BLOCK -%]
Optimization="0" Optimization="0"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
DebugInformationFormat="4" DebugInformationFormat="3"
RuntimeTypeInfo="FALSE" RuntimeTypeInfo="FALSE"
RuntimeLibrary="3" RuntimeLibrary="3"
[% END %] [% END %]

View File

@@ -27,6 +27,7 @@ subject to the following restrictions:
#include "btGpu3DGridBroadphaseSharedDefs.h" #include "btGpu3DGridBroadphaseSharedDefs.h"
#include "btGpu3DGridBroadphase.h" #include "btGpu3DGridBroadphase.h"
#include <string> //for memset
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@@ -113,11 +113,11 @@ inline int3 operator+(int3 a, int3 b)
return bt3dGrid_make_int3(a.x + b.x, a.y + b.y, a.z + b.z); return bt3dGrid_make_int3(a.x + b.x, a.y + b.y, a.z + b.z);
} }
inline float4 operator+(float4& a, float4& b) inline float4 operator+(const float4& a, const float4& b)
{ {
float4 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; r.w = a.w+b.w; return r; float4 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; r.w = a.w+b.w; return r;
} }
inline float4 operator*(float4& a, float fact) inline float4 operator*(const float4& a, float fact)
{ {
float4 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; r.w = a.w*fact; return r; float4 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; r.w = a.w*fact; return r;
} }
@@ -136,15 +136,11 @@ inline float4& operator+=(float4& a, float4& b)
return a; return a;
} }
inline float3 operator+(float3& a, float3& b)
{
float3 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; return r;
}
inline float3 operator+(const float3& a, const float3& b) inline float3 operator+(const float3& a, const float3& b)
{ {
float3 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; return r; float3 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; return r;
} }
inline float3 operator-(float3& a, float3& b) inline float3 operator-(const float3& a, const float3& b)
{ {
float3 r; r.x = a.x-b.x; r.y = a.y-b.y; r.z = a.z-b.z; return r; float3 r; r.x = a.x-b.x; r.y = a.y-b.y; r.z = a.z-b.z; return r;
} }
@@ -160,16 +156,13 @@ static inline float bt3dGrid_dot4(float4& a, float4& b)
} }
#define BT_GPU_dot4(a,b) bt3dGrid_dot4(a,b) #define BT_GPU_dot4(a,b) bt3dGrid_dot4(a,b)
static inline float3 bt3dGrid_cross(float3& a, float3& b) static inline float3 bt3dGrid_cross(const float3& a, const float3& b)
{ {
float3 r; r.x = a.y*b.z-a.z*b.y; r.y = -a.x*b.z+a.z*b.x; r.z = a.x*b.y-a.y*b.x; return r; float3 r; r.x = a.y*b.z-a.z*b.y; r.y = -a.x*b.z+a.z*b.x; r.z = a.x*b.y-a.y*b.x; return r;
} }
#define BT_GPU_cross(a,b) bt3dGrid_cross(a,b) #define BT_GPU_cross(a,b) bt3dGrid_cross(a,b)
inline float3 operator*(float3& a, float fact)
{
float3 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; return r;
}
inline float3 operator*(const float3& a, float fact) inline float3 operator*(const float3& a, float fact)
{ {
float3 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; return r; float3 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; return r;