tweak OpenCL particle demo
This commit is contained in:
@@ -23,7 +23,7 @@ subject to the following restrictions:
|
|||||||
#define ARRAY_SIZE_X 32
|
#define ARRAY_SIZE_X 32
|
||||||
#define ARRAY_SIZE_Y 32
|
#define ARRAY_SIZE_Y 32
|
||||||
//#define ARRAY_SIZE_Y 16
|
//#define ARRAY_SIZE_Y 16
|
||||||
#define ARRAY_SIZE_Z 16
|
#define ARRAY_SIZE_Z 32
|
||||||
//16
|
//16
|
||||||
//#define ARRAY_SIZE_Z 1
|
//#define ARRAY_SIZE_Z 1
|
||||||
//#define DIST btScalar(2.f)
|
//#define DIST btScalar(2.f)
|
||||||
@@ -308,9 +308,9 @@ void ParticlesDemo::init_scene_directly()
|
|||||||
{
|
{
|
||||||
btVector3 jitter = 0.01f * 0.03f * btVector3(frand(), frand(), frand());
|
btVector3 jitter = 0.01f * 0.03f * btVector3(frand(), frand(), frand());
|
||||||
m_pWorld->m_hVel[i]= btVector3(0,0,0);
|
m_pWorld->m_hVel[i]= btVector3(0,0,0);
|
||||||
m_pWorld->m_hPos[i].setX((spacing * x) + DEF_PARTICLE_RADIUS -WORLD_SIZE+jitter.getX());
|
m_pWorld->m_hPos[i].setX((spacing * x) + 2*DEF_PARTICLE_RADIUS -WORLD_SIZE+jitter.getX());
|
||||||
m_pWorld->m_hPos[i].setY((spacing * y) + DEF_PARTICLE_RADIUS -WORLD_SIZE+jitter.getY());
|
m_pWorld->m_hPos[i].setY((spacing * y) + 2*DEF_PARTICLE_RADIUS -WORLD_SIZE+jitter.getY());
|
||||||
m_pWorld->m_hPos[i].setZ((spacing * z) + DEF_PARTICLE_RADIUS -WORLD_SIZE+jitter.getZ());
|
m_pWorld->m_hPos[i].setZ((spacing * z) + 2*DEF_PARTICLE_RADIUS -WORLD_SIZE+jitter.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,34 +144,34 @@ __kernel void kIntegrateMotion( int numParticles,
|
|||||||
float4 worldMax = *((__global float4*)(pParams + 2));
|
float4 worldMax = *((__global float4*)(pParams + 2));
|
||||||
|
|
||||||
|
|
||||||
if(pos.x < (worldMin.x + particleRad))
|
if(pos.x < (worldMin.x + 2*particleRad))
|
||||||
{
|
{
|
||||||
pos.x = worldMin.x + particleRad;
|
pos.x = worldMin.x + 2*particleRad;
|
||||||
vel.x *= boundaryDamping;
|
vel.x *= boundaryDamping;
|
||||||
}
|
}
|
||||||
if(pos.x > (worldMax.x - particleRad))
|
if(pos.x > (worldMax.x - 2*particleRad))
|
||||||
{
|
{
|
||||||
pos.x = worldMax.x - particleRad;
|
pos.x = worldMax.x - 2*particleRad;
|
||||||
vel.x *= boundaryDamping;
|
vel.x *= boundaryDamping;
|
||||||
}
|
}
|
||||||
if(pos.y < (worldMin.y + particleRad))
|
if(pos.y < (worldMin.y + 2*particleRad))
|
||||||
{
|
{
|
||||||
pos.y = worldMin.y + particleRad;
|
pos.y = worldMin.y + 2*particleRad;
|
||||||
vel.y *= boundaryDamping;
|
vel.y *= boundaryDamping;
|
||||||
}
|
}
|
||||||
if(pos.y > (worldMax.y - particleRad))
|
if(pos.y > (worldMax.y - 2*particleRad))
|
||||||
{
|
{
|
||||||
pos.y = worldMax.y - particleRad;
|
pos.y = worldMax.y - 2*particleRad;
|
||||||
vel.y *= boundaryDamping;
|
vel.y *= boundaryDamping;
|
||||||
}
|
}
|
||||||
if(pos.z < (worldMin.z + particleRad))
|
if(pos.z < (worldMin.z + 2*particleRad))
|
||||||
{
|
{
|
||||||
pos.z = worldMin.z + particleRad;
|
pos.z = worldMin.z + 2*particleRad;
|
||||||
vel.z *= boundaryDamping;
|
vel.z *= boundaryDamping;
|
||||||
}
|
}
|
||||||
if(pos.z > (worldMax.z - particleRad))
|
if(pos.z > (worldMax.z - 2*particleRad))
|
||||||
{
|
{
|
||||||
pos.z = worldMax.z - particleRad;
|
pos.z = worldMax.z - 2*particleRad;
|
||||||
vel.z *= boundaryDamping;
|
vel.z *= boundaryDamping;
|
||||||
}
|
}
|
||||||
// write back position and velocity
|
// write back position and velocity
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ void btParticlesDynamicsWorld::grabSimulationData()
|
|||||||
m_simParams.m_collisionDamping = 0.025f;//0.02f;
|
m_simParams.m_collisionDamping = 0.025f;//0.02f;
|
||||||
m_simParams.m_spring = 0.5f;
|
m_simParams.m_spring = 0.5f;
|
||||||
m_simParams.m_shear = 0.1f;
|
m_simParams.m_shear = 0.1f;
|
||||||
m_simParams.m_attraction = 0.0f;
|
m_simParams.m_attraction = 0.001f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,10 +42,11 @@ subject to the following restrictions:
|
|||||||
#include "btParticlesSharedDefs.h"
|
#include "btParticlesSharedDefs.h"
|
||||||
#include "btParticlesSharedTypes.h"
|
#include "btParticlesSharedTypes.h"
|
||||||
|
|
||||||
#define PARTICLES_MAX_PARTICLES (65536)
|
|
||||||
#define PARTICLES_MAX_NEIGHBORS (32)
|
#define PARTICLES_MAX_NEIGHBORS (32)
|
||||||
#define DEF_PARTICLE_RADIUS (0.023f)
|
#define DEF_PARTICLE_RADIUS (0.023f)
|
||||||
#define WORLD_SIZE 1.9f
|
//#define WORLD_SIZE 1.9f
|
||||||
|
#define WORLD_SIZE 1.f
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -137,7 +138,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
btParticlesDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration,
|
btParticlesDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration,
|
||||||
int maxObjs = PARTICLES_MAX_PARTICLES, int maxNeighbors = PARTICLES_MAX_NEIGHBORS)
|
int maxObjs , int maxNeighbors = PARTICLES_MAX_NEIGHBORS)
|
||||||
: btDiscreteDynamicsWorld(dispatcher, pairCache, constraintSolver, collisionConfiguration)
|
: btDiscreteDynamicsWorld(dispatcher, pairCache, constraintSolver, collisionConfiguration)
|
||||||
{
|
{
|
||||||
m_cxMainContext = 0;
|
m_cxMainContext = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user