More stable parameters for solver (GpuDemo2d)
Added a possibility to switch between GPU/Bullet narrowphase ('j' key)
This commit is contained in:
@@ -97,6 +97,7 @@ bool gUseCPUSolver = false;
|
||||
bool gUseCPUSolver = true;
|
||||
#endif //BT_USE_CUDA
|
||||
|
||||
bool gUseBulletNarrowphase = false;
|
||||
|
||||
#include "oecakeLoader.h"
|
||||
|
||||
@@ -303,6 +304,8 @@ void BasicDemo::initPhysics()
|
||||
pDdw->setWorldMax(gWorldMax);
|
||||
// gUseCPUSolver = true;
|
||||
pDdw->setUseCPUSolver(gUseCPUSolver);
|
||||
gUseBulletNarrowphase = false;
|
||||
pDdw->setUseBulletNarrowphase(gUseBulletNarrowphase);
|
||||
|
||||
// m_dynamicsWorld->setGravity(btVector3(0,0,0));
|
||||
m_dynamicsWorld->setGravity(btVector3(0,-10.,0));
|
||||
@@ -586,6 +589,21 @@ void BasicDemo::keyboardCallback(unsigned char key, int x, int y)
|
||||
pDdw->setUseCPUSolver(gUseCPUSolver);
|
||||
break;
|
||||
}
|
||||
case 'j' :
|
||||
{
|
||||
btGpuDemoDynamicsWorld* pDdw = (btGpuDemoDynamicsWorld*)m_dynamicsWorld;
|
||||
gUseBulletNarrowphase = !gUseBulletNarrowphase;
|
||||
pDdw->setUseBulletNarrowphase(gUseBulletNarrowphase);
|
||||
if(gUseBulletNarrowphase)
|
||||
{
|
||||
m_dispatcher->setNearCallback(btCollisionDispatcher::defaultNearCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dispatcher->setNearCallback(cudaDemoNearCallback);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
DemoApplication::keyboardCallback(key, x, y);
|
||||
|
||||
@@ -174,8 +174,11 @@ BT_GPU___device__ float computeImpulse1(float3 rVel,
|
||||
float3 cNormal,
|
||||
float dt)
|
||||
{
|
||||
const float collisionConstant = 0.1f;
|
||||
const float baumgarteConstant = 0.5f;
|
||||
// const float collisionConstant = 0.1f;
|
||||
// const float baumgarteConstant = 0.5f;
|
||||
// const float penetrationError = 0.02f;
|
||||
const float collisionConstant = -0.1f;
|
||||
const float baumgarteConstant = 0.3f;
|
||||
const float penetrationError = 0.02f;
|
||||
|
||||
float lambdaDt=0;
|
||||
@@ -231,12 +234,14 @@ BT_GPU___global__ void collisionWithWallBoxD(float4 *pos,
|
||||
float3 vPos = aPos + rerVertex;
|
||||
float rad = shape[iVtx].w;
|
||||
float3 vVel =aVel+BT_GPU_cross(BT_GPU_make_float3(0.0f,0.0f,aAngVel),rerVertex);
|
||||
float restitution=1.0;
|
||||
// float restitution=1.0;
|
||||
float restitution=0.3f;
|
||||
{
|
||||
positionConstraint =vPos.y - rad - gProp.minY;
|
||||
impulse =BT_GPU_make_float31(0.0f);
|
||||
|
||||
if(positionConstraint < 0){
|
||||
if(positionConstraint < 0)
|
||||
{
|
||||
float3 groundNormal;
|
||||
groundNormal = BT_GPU_make_float3(0.0f,1.0f,0.0f);
|
||||
impulse =groundNormal*
|
||||
@@ -266,7 +271,7 @@ BT_GPU___global__ void collisionWithWallBoxD(float4 *pos,
|
||||
impulse =BT_GPU_make_float31(0.0f);
|
||||
|
||||
if(positionConstraint < 0){
|
||||
impulse =BT_GPU_make_float3(1.0f,0.0f,0.0f)*
|
||||
impulse =BT_GPU_make_float3(1.0f,0.0f,0.0f)* restitution *
|
||||
computeImpulse1(vVel,positionConstraint,
|
||||
BT_GPU_make_float3(1.0f,0.0f,0.0f),
|
||||
dt);
|
||||
@@ -282,7 +287,7 @@ BT_GPU___global__ void collisionWithWallBoxD(float4 *pos,
|
||||
impulse =BT_GPU_make_float31(0.0f);
|
||||
|
||||
if(positionConstraint < 0){
|
||||
impulse =BT_GPU_make_float3(-1.0f,0.0f,0.0f)*
|
||||
impulse =BT_GPU_make_float3(-1.0f,0.0f,0.0f)* restitution *
|
||||
computeImpulse1(vVel,positionConstraint,
|
||||
BT_GPU_make_float3(-1.0f,0.0f,0.0f),
|
||||
dt);
|
||||
|
||||
@@ -66,6 +66,7 @@ protected:
|
||||
int m_numObj;
|
||||
int m_numSimStep;
|
||||
bool m_useCPUSolver;
|
||||
bool m_useBulletNarrowphase;
|
||||
|
||||
float4* m_hPos;
|
||||
float* m_hRot;
|
||||
@@ -254,11 +255,13 @@ public:
|
||||
void setWorldMax(const btVector3& worldMax) { m_worldMax = worldMax; }
|
||||
|
||||
void grabData();
|
||||
void grabContactData();
|
||||
void copyDataToGPU();
|
||||
void setConstraintData(btCudaPartProps& partProps);
|
||||
void copyDataFromGPU();
|
||||
void writebackData();
|
||||
void setUseCPUSolver(bool useCPU) { m_useCPUSolver = useCPU; }
|
||||
void setUseBulletNarrowphase(bool useBulletNarrowphase) {m_useBulletNarrowphase = useBulletNarrowphase; }
|
||||
|
||||
void createBatches2();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user