Added 'cache friendly' tree traversal format, and traversal. Array of subtrees with specified maximum size. This is useful to fit tree traversals on SPU.

This commit is contained in:
ejcoumans
2007-03-27 21:02:45 +00:00
parent 7adc0742e3
commit 9546633ade
9 changed files with 295 additions and 134 deletions

View File

@@ -21,8 +21,15 @@ subject to the following restrictions:
///It also shows per-triangle material (friction/restitution) through CustomMaterialCombinerCallback
class ConcaveDemo : public DemoApplication
{
bool m_animatedMesh;
public:
ConcaveDemo() : m_animatedMesh(false)
{
}
void initPhysics();
virtual void clientMoveAndDisplay();
@@ -32,6 +39,7 @@ class ConcaveDemo : public DemoApplication
//to show refit works
void setVertexPositions(float waveheight, float offset);
virtual void keyboardCallback(unsigned char key, int x, int y);
};
#endif //CONCAVE_DEMO_H

View File

@@ -22,7 +22,7 @@ subject to the following restrictions:
GLDebugDrawer debugDrawer;
class btIDebugDraw* debugDrawerPtr=0;
btVector3* gVertices=0;
int* gIndices=0;
@@ -123,6 +123,27 @@ void ConcaveDemo::setVertexPositions(float waveheight, float offset)
}
}
}
void ConcaveDemo::keyboardCallback(unsigned char key, int x, int y)
{
if (key == 'g')
{
m_animatedMesh = !m_animatedMesh;
if (m_animatedMesh)
{
staticBody->setCollisionFlags( staticBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
staticBody->setActivationState(DISABLE_DEACTIVATION);
} else
{
staticBody->setCollisionFlags( staticBody->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT);
staticBody->forceActivationState(ACTIVE_TAG);
}
}
DemoApplication::keyboardCallback(key,x,y);
}
void ConcaveDemo::initPhysics()
{
#define TRISIZE 10.f
@@ -173,6 +194,7 @@ void ConcaveDemo::initPhysics()
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
debugDrawerPtr = &debugDrawer;
float mass = 0.f;
btTransform startTransform;
@@ -204,18 +226,18 @@ void ConcaveDemo::clientMoveAndDisplay()
float dt = m_clock.getTimeMicroseconds() * 0.000001f;
m_clock.reset();
if (m_animatedMesh)
{
static float offset=0.f;
offset+=0.01f;
static float offset=0.f;
offset+=0.01f;
setVertexPositions(waveheight,offset);
setVertexPositions(waveheight,offset);
trimeshShape->refitTree();
trimeshShape->refitTree();
//clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
m_dynamicsWorld->getBroadphase()->cleanProxyFromPairs(staticBody->getBroadphaseHandle());
//clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
m_dynamicsWorld->getBroadphase()->cleanProxyFromPairs(staticBody->getBroadphaseHandle());
}
m_dynamicsWorld->stepSimulation(dt);

View File

@@ -509,6 +509,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
{
if (state==0)
{
shootBox(rayTo);
}
break;
@@ -519,6 +520,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
if (state==0)
{
//apply an impulse
if (m_dynamicsWorld)
@@ -554,6 +556,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
{
if (state==0)
{
//add a point to point constraint for picking
if (m_dynamicsWorld)
@@ -829,13 +832,12 @@ void DemoApplication::renderme()
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
/*
glRasterPos3f(xOffset,yStart,0);
sprintf(buf,"a to draw temporal AABBs");
sprintf(buf,"g to toggle mesh animation (ConcaveDemo)");
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
*/
glRasterPos3f(xOffset,yStart,0);
sprintf(buf,"h to toggle help text");

View File

@@ -68,35 +68,5 @@ void GLDebugDrawer::drawContactPoint(const btVector3& pointOnB,const btVector3&
}
void GLDebugDrawer::drawAabb(const btVector3& from,const btVector3& to,const btVector3& color)
{
btVector3 halfExtents = (to-from)* 0.5f;
btVector3 center = (to+from) *0.5f;
int i,j;
btVector3 edgecoord(1.f,1.f,1.f),pa,pb;
for (i=0;i<4;i++)
{
for (j=0;j<3;j++)
{
pa = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],
edgecoord[2]*halfExtents[2]);
pa+=center;
int othercoord = j%3;
edgecoord[othercoord]*=-1.f;
pb = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],
edgecoord[2]*halfExtents[2]);
pb+=center;
drawLine(pa,pb,color);
}
edgecoord = btVector3(-1.f,-1.f,-1.f);
if (i<3)
edgecoord[i]*=-1.f;
}
}

View File

@@ -13,7 +13,6 @@ public:
GLDebugDrawer();
void drawAabb(const btVector3& from,const btVector3& to,const btVector3& color);
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color);