+ Fix btSubsimplexConvexCast
Thanks to Nacho, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2422) Fix in rendering, GL_STENCIL + btTriangleIndexVertexArray indices should be unsigned int/unsigned short int, + Made InternalProcessAllTriangles virtual, thanks to Both thank to Fullmetalcoder, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2401 +clamp impulse for btPoint2PointConstraint Thanks to Martijn Reuvers, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2418 + Free memory of bvh, pass in scaling factor (optional) Thanks to Roy Eltham, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2375
This commit is contained in:
@@ -335,7 +335,7 @@ int main(int argc, char** argv)
|
|||||||
printf("Bullet version %d\n",bulletVersion);
|
printf("Bullet version %d\n",bulletVersion);
|
||||||
|
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE |GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE |GLUT_DEPTH | GLUT_STENCIL);
|
||||||
glutInitWindowSize(width, height);
|
glutInitWindowSize(width, height);
|
||||||
mainWindow = glutCreateWindow("http://bulletphysics.com");
|
mainWindow = glutCreateWindow("http://bulletphysics.com");
|
||||||
#ifdef BT_USE_FREEGLUT
|
#ifdef BT_USE_FREEGLUT
|
||||||
|
|||||||
@@ -184,7 +184,9 @@ void ConcaveDemo::initPhysics()
|
|||||||
//comment out the next line to read the BVH from disk (first run the demo once to create the BVH)
|
//comment out the next line to read the BVH from disk (first run the demo once to create the BVH)
|
||||||
#define SERIALIZE_TO_DISK 1
|
#define SERIALIZE_TO_DISK 1
|
||||||
#ifdef SERIALIZE_TO_DISK
|
#ifdef SERIALIZE_TO_DISK
|
||||||
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression);
|
btVector3 aabbMin(-1000,-1000,-1000),aabbMax(1000,1000,1000);
|
||||||
|
|
||||||
|
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,aabbMin,aabbMax);
|
||||||
m_collisionShapes.push_back(trimeshShape);
|
m_collisionShapes.push_back(trimeshShape);
|
||||||
|
|
||||||
|
|
||||||
@@ -295,7 +297,7 @@ void ConcaveDemo::initPhysics()
|
|||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
staticBody = localCreateRigidBody(mass, startTransform,groundShape);
|
staticBody = localCreateRigidBody(mass, startTransform,groundShape);
|
||||||
|
|
||||||
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT);
|
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);//STATIC_OBJECT);
|
||||||
|
|
||||||
//enable custom material callback
|
//enable custom material callback
|
||||||
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||||
|
|||||||
@@ -2,13 +2,17 @@
|
|||||||
#include "ConcaveDemo.h"
|
#include "ConcaveDemo.h"
|
||||||
#include "GlutStuff.h"
|
#include "GlutStuff.h"
|
||||||
|
|
||||||
|
#include "GLDebugDrawer.h"
|
||||||
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
|
||||||
|
GLDebugDrawer gDebugDrawer;
|
||||||
int main(int argc,char** argv)
|
int main(int argc,char** argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
ConcaveDemo* concaveDemo = new ConcaveDemo();
|
ConcaveDemo* concaveDemo = new ConcaveDemo();
|
||||||
concaveDemo->initPhysics();
|
concaveDemo->initPhysics();
|
||||||
concaveDemo->setCameraDistance(30.f);
|
concaveDemo->setCameraDistance(30.f);
|
||||||
|
concaveDemo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
|
||||||
|
|
||||||
return glutmain(argc, argv,640,480,"Static Concave Mesh Demo",concaveDemo);
|
return glutmain(argc, argv,640,480,"Static Concave Mesh Demo",concaveDemo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -599,6 +599,8 @@ btVector3 DemoApplication::getRayTo(int x,int y)
|
|||||||
return rayTo;
|
return rayTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btScalar mousePickClamping = 3.f;
|
||||||
|
|
||||||
|
|
||||||
void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
||||||
{
|
{
|
||||||
@@ -686,6 +688,8 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
|||||||
btVector3 localPivot = body->getCenterOfMassTransform().inverse() * pickPos;
|
btVector3 localPivot = body->getCenterOfMassTransform().inverse() * pickPos;
|
||||||
|
|
||||||
btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*body,localPivot);
|
btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*body,localPivot);
|
||||||
|
p2p->m_setting.m_impulseClamp = mousePickClamping;
|
||||||
|
|
||||||
m_dynamicsWorld->addConstraint(p2p);
|
m_dynamicsWorld->addConstraint(p2p);
|
||||||
m_pickConstraint = p2p;
|
m_pickConstraint = p2p;
|
||||||
|
|
||||||
@@ -965,6 +969,8 @@ for(int i=0;i<numObjects;i++)
|
|||||||
//
|
//
|
||||||
void DemoApplication::renderme()
|
void DemoApplication::renderme()
|
||||||
{
|
{
|
||||||
|
myinit();
|
||||||
|
|
||||||
updateCamera();
|
updateCamera();
|
||||||
|
|
||||||
if (m_dynamicsWorld)
|
if (m_dynamicsWorld)
|
||||||
|
|||||||
@@ -116,14 +116,14 @@ public:
|
|||||||
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
||||||
glEnd();*/
|
glEnd();*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GLuint OGL_get_displaylist_for_shape(btCollisionShape * shape)
|
GLuint OGL_get_displaylist_for_shape(btCollisionShape * shape)
|
||||||
{
|
{
|
||||||
TRIMESH_KEY_MAP::iterator map_iter;
|
TRIMESH_KEY_MAP::iterator map_iter;
|
||||||
|
|
||||||
unsigned long key = (unsigned long)shape;
|
unsigned long key = (unsigned long)shape;
|
||||||
map_iter = g_display_lists.find(key);
|
map_iter = g_display_lists.find(key);
|
||||||
if(map_iter!=g_display_lists.end())
|
if(map_iter!=g_display_lists.end())
|
||||||
@@ -163,7 +163,7 @@ void OGL_displaylist_register_shape(btCollisionShape * shape)
|
|||||||
unsigned long key = (unsigned long)shape;
|
unsigned long key = (unsigned long)shape;
|
||||||
|
|
||||||
g_display_lists.insert(TRIMESH_KEY_PAIR(key,dlist));
|
g_display_lists.insert(TRIMESH_KEY_PAIR(key,dlist));
|
||||||
|
|
||||||
glNewList(dlist.m_dlist,GL_COMPILE);
|
glNewList(dlist.m_dlist,GL_COMPILE);
|
||||||
|
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
@@ -184,18 +184,18 @@ void OGL_displaylist_register_shape(btCollisionShape * shape)
|
|||||||
#endif //USE_DISPLAY_LISTS
|
#endif //USE_DISPLAY_LISTS
|
||||||
|
|
||||||
void GL_ShapeDrawer::drawCoordSystem() {
|
void GL_ShapeDrawer::drawCoordSystem() {
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
glVertex3d(0, 0, 0);
|
glVertex3d(0, 0, 0);
|
||||||
glVertex3d(1, 0, 0);
|
glVertex3d(1, 0, 0);
|
||||||
glColor3f(0, 1, 0);
|
glColor3f(0, 1, 0);
|
||||||
glVertex3d(0, 0, 0);
|
glVertex3d(0, 0, 0);
|
||||||
glVertex3d(0, 1, 0);
|
glVertex3d(0, 1, 0);
|
||||||
glColor3f(0, 0, 1);
|
glColor3f(0, 0, 1);
|
||||||
glVertex3d(0, 0, 0);
|
glVertex3d(0, 0, 0);
|
||||||
glVertex3d(0, 0, 1);
|
glVertex3d(0, 0, 1);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ public:
|
|||||||
|
|
||||||
void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
|
void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
switch (upAxis)
|
switch (upAxis)
|
||||||
@@ -287,7 +287,7 @@ void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
|
|||||||
glTranslatef(0.0, 0.0, -halfHeight);
|
glTranslatef(0.0, 0.0, -halfHeight);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
glTranslatef(0.0, 0.0, -halfHeight);
|
glTranslatef(0.0, 0.0, -halfHeight);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -296,18 +296,18 @@ void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLUquadricObj *quadObj = gluNewQuadric();
|
GLUquadricObj *quadObj = gluNewQuadric();
|
||||||
|
|
||||||
//The gluCylinder subroutine draws a cylinder that is oriented along the z axis.
|
//The gluCylinder subroutine draws a cylinder that is oriented along the z axis.
|
||||||
//The base of the cylinder is placed at z = 0; the top of the cylinder is placed at z=height.
|
//The base of the cylinder is placed at z = 0; the top of the cylinder is placed at z=height.
|
||||||
//Like a sphere, the cylinder is subdivided around the z axis into slices and along the z axis into stacks.
|
//Like a sphere, the cylinder is subdivided around the z axis into slices and along the z axis into stacks.
|
||||||
|
|
||||||
gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
|
gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
|
||||||
gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
|
gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
|
||||||
|
|
||||||
gluDisk(quadObj,0,radius,15, 10);
|
gluDisk(quadObj,0,radius,15, 10);
|
||||||
|
|
||||||
gluCylinder(quadObj, radius, radius, 2.f*halfHeight, 15, 10);
|
gluCylinder(quadObj, radius, radius, 2.f*halfHeight, 15, 10);
|
||||||
glTranslatef(0.0, 0.0, 2.*halfHeight);
|
glTranslatef(0.0, 0.0, 2.*halfHeight);
|
||||||
glRotatef(-180.0, 0.0, 1.0, 0.0);
|
glRotatef(-180.0, 0.0, 1.0, 0.0);
|
||||||
@@ -319,53 +319,53 @@ void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
|
|||||||
|
|
||||||
GL_ShapeDrawer::ShapeCache* GL_ShapeDrawer::cache(btConvexShape* shape)
|
GL_ShapeDrawer::ShapeCache* GL_ShapeDrawer::cache(btConvexShape* shape)
|
||||||
{
|
{
|
||||||
ShapeCache* sc=(ShapeCache*)shape->getUserPointer();
|
ShapeCache* sc=(ShapeCache*)shape->getUserPointer();
|
||||||
if(!sc)
|
if(!sc)
|
||||||
{
|
{
|
||||||
sc=new(btAlignedAlloc(sizeof(ShapeCache),16)) ShapeCache(shape);
|
sc=new(btAlignedAlloc(sizeof(ShapeCache),16)) ShapeCache(shape);
|
||||||
sc->m_shapehull.buildHull(shape->getMargin());
|
sc->m_shapehull.buildHull(shape->getMargin());
|
||||||
m_shapecaches.push_back(sc);
|
m_shapecaches.push_back(sc);
|
||||||
shape->setUserPointer(sc);
|
shape->setUserPointer(sc);
|
||||||
/* Build edges */
|
/* Build edges */
|
||||||
const int ni=sc->m_shapehull.numIndices();
|
const int ni=sc->m_shapehull.numIndices();
|
||||||
const int nv=sc->m_shapehull.numVertices();
|
const int nv=sc->m_shapehull.numVertices();
|
||||||
const unsigned int* pi=sc->m_shapehull.getIndexPointer();
|
const unsigned int* pi=sc->m_shapehull.getIndexPointer();
|
||||||
const btVector3* pv=sc->m_shapehull.getVertexPointer();
|
const btVector3* pv=sc->m_shapehull.getVertexPointer();
|
||||||
btAlignedObjectArray<ShapeCache::Edge*> edges;
|
btAlignedObjectArray<ShapeCache::Edge*> edges;
|
||||||
sc->m_edges.reserve(ni);
|
sc->m_edges.reserve(ni);
|
||||||
edges.resize(nv*nv,0);
|
edges.resize(nv*nv,0);
|
||||||
for(int i=0;i<ni;i+=3)
|
for(int i=0;i<ni;i+=3)
|
||||||
{
|
{
|
||||||
const unsigned int* ti=pi+i;
|
const unsigned int* ti=pi+i;
|
||||||
const btVector3 nrm=cross(pv[ti[1]]-pv[ti[0]],pv[ti[2]]-pv[ti[0]]).normalized();
|
const btVector3 nrm=cross(pv[ti[1]]-pv[ti[0]],pv[ti[2]]-pv[ti[0]]).normalized();
|
||||||
for(int j=2,k=0;k<3;j=k++)
|
for(int j=2,k=0;k<3;j=k++)
|
||||||
{
|
{
|
||||||
const unsigned int a=ti[j];
|
const unsigned int a=ti[j];
|
||||||
const unsigned int b=ti[k];
|
const unsigned int b=ti[k];
|
||||||
ShapeCache::Edge*& e=edges[btMin(a,b)*nv+btMax(a,b)];
|
ShapeCache::Edge*& e=edges[btMin(a,b)*nv+btMax(a,b)];
|
||||||
if(!e)
|
if(!e)
|
||||||
{
|
{
|
||||||
sc->m_edges.push_back(ShapeCache::Edge());
|
sc->m_edges.push_back(ShapeCache::Edge());
|
||||||
e=&sc->m_edges[sc->m_edges.size()-1];
|
e=&sc->m_edges[sc->m_edges.size()-1];
|
||||||
e->n[0]=nrm;e->n[1]=-nrm;
|
e->n[0]=nrm;e->n[1]=-nrm;
|
||||||
e->v[0]=a;e->v[1]=b;
|
e->v[0]=a;e->v[1]=b;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e->n[1]=nrm;
|
e->n[1]=nrm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(sc);
|
return(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode)
|
void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
btglMultMatrix(m);
|
btglMultMatrix(m);
|
||||||
|
|
||||||
if (shape->getShapeType() == UNIFORM_SCALING_SHAPE_PROXYTYPE)
|
if (shape->getShapeType() == UNIFORM_SCALING_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
@@ -374,10 +374,10 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
float scalingFactor = (float)scalingShape->getUniformScalingFactor();
|
float scalingFactor = (float)scalingShape->getUniformScalingFactor();
|
||||||
{
|
{
|
||||||
btScalar tmpScaling[4][4]={{scalingFactor,0,0,0},
|
btScalar tmpScaling[4][4]={{scalingFactor,0,0,0},
|
||||||
{0,scalingFactor,0,0},
|
{0,scalingFactor,0,0},
|
||||||
{0,0,scalingFactor,0},
|
{0,0,scalingFactor,0},
|
||||||
{0,0,0,1}};
|
{0,0,0,1}};
|
||||||
|
|
||||||
drawOpenGL( (btScalar*)tmpScaling,convexShape,color,debugMode);
|
drawOpenGL( (btScalar*)tmpScaling,convexShape,color,debugMode);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
@@ -399,20 +399,20 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if(m_textureenabled&&(!m_textureinitialized))
|
if(m_textureenabled&&(!m_textureinitialized))
|
||||||
{
|
{
|
||||||
GLubyte* image=new GLubyte[256*256*3];
|
GLubyte* image=new GLubyte[256*256*3];
|
||||||
for(int y=0;y<256;++y)
|
for(int y=0;y<256;++y)
|
||||||
{
|
{
|
||||||
const int t=y>>4;
|
const int t=y>>4;
|
||||||
GLubyte* pi=image+y*256*3;
|
GLubyte* pi=image+y*256*3;
|
||||||
for(int x=0;x<256;++x)
|
for(int x=0;x<256;++x)
|
||||||
{
|
{
|
||||||
const int s=x>>4;
|
const int s=x>>4;
|
||||||
const GLubyte b=180;
|
const GLubyte b=180;
|
||||||
GLubyte c=b+((s+t&1)&1)*(255-b);
|
GLubyte c=b+((s+t&1)&1)*(255-b);
|
||||||
pi[0]=pi[1]=pi[2]=c;pi+=3;
|
pi[0]=pi[1]=pi[2]=c;pi+=3;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
glGenTextures(1,&m_texturehandle);
|
glGenTextures(1,&m_texturehandle);
|
||||||
glBindTexture(GL_TEXTURE_2D,m_texturehandle);
|
glBindTexture(GL_TEXTURE_2D,m_texturehandle);
|
||||||
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
|
||||||
@@ -422,11 +422,11 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
|
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
|
||||||
gluBuild2DMipmaps(GL_TEXTURE_2D,3,256,256,GL_RGB,GL_UNSIGNED_BYTE,image);
|
gluBuild2DMipmaps(GL_TEXTURE_2D,3,256,256,GL_RGB,GL_UNSIGNED_BYTE,image);
|
||||||
delete[] image;
|
delete[] image;
|
||||||
|
|
||||||
glMatrixMode(GL_TEXTURE);
|
glMatrixMode(GL_TEXTURE);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glScalef(0.025,0.025,0.025);
|
glScalef(0.025,0.025,0.025);
|
||||||
|
|
||||||
static const GLfloat planex[]={1,0,0,0};
|
static const GLfloat planex[]={1,0,0,0};
|
||||||
static const GLfloat planey[]={0,1,0,0};
|
static const GLfloat planey[]={0,1,0,0};
|
||||||
static const GLfloat planez[]={0,0,1,0};
|
static const GLfloat planez[]={0,0,1,0};
|
||||||
@@ -438,12 +438,18 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
glEnable(GL_TEXTURE_GEN_T);
|
glEnable(GL_TEXTURE_GEN_T);
|
||||||
glEnable(GL_TEXTURE_GEN_R);
|
glEnable(GL_TEXTURE_GEN_R);
|
||||||
m_textureinitialized=true;
|
m_textureinitialized=true;
|
||||||
}
|
}
|
||||||
//drawCoordSystem();
|
//drawCoordSystem();
|
||||||
|
|
||||||
//glPushMatrix();
|
//glPushMatrix();
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
if(m_textureenabled) glEnable(GL_TEXTURE_2D);
|
if(m_textureenabled)
|
||||||
|
{
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D,m_texturehandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
glColor3f(color.x(),color.y(), color.z());
|
glColor3f(color.x(),color.y(), color.z());
|
||||||
|
|
||||||
bool useWireframeFallback = true;
|
bool useWireframeFallback = true;
|
||||||
@@ -464,8 +470,8 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
useWireframeFallback = false;
|
useWireframeFallback = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case SPHERE_SHAPE_PROXYTYPE:
|
case SPHERE_SHAPE_PROXYTYPE:
|
||||||
{
|
{
|
||||||
const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
|
const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
|
||||||
@@ -474,7 +480,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
useWireframeFallback = false;
|
useWireframeFallback = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CONE_SHAPE_PROXYTYPE:
|
case CONE_SHAPE_PROXYTYPE:
|
||||||
{
|
{
|
||||||
const btConeShape* coneShape = static_cast<const btConeShape*>(shape);
|
const btConeShape* coneShape = static_cast<const btConeShape*>(shape);
|
||||||
@@ -495,14 +501,14 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
glTranslatef(0.0, 0.0, -0.5*height);
|
glTranslatef(0.0, 0.0, -0.5*height);
|
||||||
glutSolidCone(radius,height,10,10);
|
glutSolidCone(radius,height,10,10);
|
||||||
useWireframeFallback = false;
|
useWireframeFallback = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case STATIC_PLANE_PROXYTYPE:
|
case STATIC_PLANE_PROXYTYPE:
|
||||||
{
|
{
|
||||||
@@ -524,7 +530,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
glVertex3f(pt3.getX(),pt3.getY(),pt3.getZ());
|
glVertex3f(pt3.getX(),pt3.getY(),pt3.getZ());
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -533,8 +539,8 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
{
|
{
|
||||||
const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
|
const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
|
||||||
int upAxis = cylinder->getUpAxis();
|
int upAxis = cylinder->getUpAxis();
|
||||||
|
|
||||||
|
|
||||||
float radius = cylinder->getRadius();
|
float radius = cylinder->getRadius();
|
||||||
float halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis];
|
float halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis];
|
||||||
|
|
||||||
@@ -542,22 +548,22 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (shape->isConvex())
|
if (shape->isConvex())
|
||||||
{
|
{
|
||||||
ShapeCache* sc=cache((btConvexShape*)shape);
|
ShapeCache* sc=cache((btConvexShape*)shape);
|
||||||
#if 0
|
#if 0
|
||||||
btConvexShape* convexShape = (btConvexShape*)shape;
|
btConvexShape* convexShape = (btConvexShape*)shape;
|
||||||
if (!shape->getUserPointer())
|
if (!shape->getUserPointer())
|
||||||
{
|
{
|
||||||
//create a hull approximation
|
//create a hull approximation
|
||||||
void* mem = btAlignedAlloc(sizeof(btShapeHull),16);
|
void* mem = btAlignedAlloc(sizeof(btShapeHull),16);
|
||||||
btShapeHull* hull = new(mem) btShapeHull(convexShape);
|
btShapeHull* hull = new(mem) btShapeHull(convexShape);
|
||||||
|
|
||||||
///cleanup memory
|
///cleanup memory
|
||||||
m_shapeHulls.push_back(hull);
|
m_shapeHulls.push_back(hull);
|
||||||
|
|
||||||
@@ -565,15 +571,15 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
hull->buildHull(margin);
|
hull->buildHull(margin);
|
||||||
convexShape->setUserPointer(hull);
|
convexShape->setUserPointer(hull);
|
||||||
|
|
||||||
|
|
||||||
// printf("numTriangles = %d\n", hull->numTriangles ());
|
// printf("numTriangles = %d\n", hull->numTriangles ());
|
||||||
// printf("numIndices = %d\n", hull->numIndices ());
|
// printf("numIndices = %d\n", hull->numIndices ());
|
||||||
// printf("numVertices = %d\n", hull->numVertices ());
|
// printf("numVertices = %d\n", hull->numVertices ());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//if (shape->getUserPointer())
|
//if (shape->getUserPointer())
|
||||||
@@ -581,13 +587,13 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
//glutSolidCube(1.0);
|
//glutSolidCube(1.0);
|
||||||
btShapeHull* hull = &sc->m_shapehull/*(btShapeHull*)shape->getUserPointer()*/;
|
btShapeHull* hull = &sc->m_shapehull/*(btShapeHull*)shape->getUserPointer()*/;
|
||||||
|
|
||||||
|
|
||||||
if (hull->numTriangles () > 0)
|
if (hull->numTriangles () > 0)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
const unsigned int* idx = hull->getIndexPointer();
|
const unsigned int* idx = hull->getIndexPointer();
|
||||||
const btVector3* vtx = hull->getVertexPointer();
|
const btVector3* vtx = hull->getVertexPointer();
|
||||||
|
|
||||||
glBegin (GL_TRIANGLES);
|
glBegin (GL_TRIANGLES);
|
||||||
|
|
||||||
for (int i = 0; i < hull->numTriangles (); i++)
|
for (int i = 0; i < hull->numTriangles (); i++)
|
||||||
@@ -611,31 +617,31 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
btVector3 v3 = vtx[index3];
|
btVector3 v3 = vtx[index3];
|
||||||
btVector3 normal = (v3-v1).cross(v2-v1);
|
btVector3 normal = (v3-v1).cross(v2-v1);
|
||||||
normal.normalize ();
|
normal.normalize ();
|
||||||
|
|
||||||
glNormal3f(normal.getX(),normal.getY(),normal.getZ());
|
glNormal3f(normal.getX(),normal.getY(),normal.getZ());
|
||||||
glVertex3f (v1.x(), v1.y(), v1.z());
|
glVertex3f (v1.x(), v1.y(), v1.z());
|
||||||
glVertex3f (v2.x(), v2.y(), v2.z());
|
glVertex3f (v2.x(), v2.y(), v2.z());
|
||||||
glVertex3f (v3.x(), v3.y(), v3.z());
|
glVertex3f (v3.x(), v3.y(), v3.z());
|
||||||
|
|
||||||
}
|
}
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// for polyhedral shapes
|
/// for polyhedral shapes
|
||||||
if (debugMode==btIDebugDraw::DBG_DrawFeaturesText && (shape->isPolyhedral()))
|
if (debugMode==btIDebugDraw::DBG_DrawFeaturesText && (shape->isPolyhedral()))
|
||||||
{
|
{
|
||||||
btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
|
btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
|
||||||
|
|
||||||
{
|
{
|
||||||
glRasterPos3f(0.0, 0.0, 0.0);
|
glRasterPos3f(0.0, 0.0, 0.0);
|
||||||
//BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->getExtraDebugInfo());
|
//BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->getExtraDebugInfo());
|
||||||
@@ -663,16 +669,16 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
char buf[12];
|
char buf[12];
|
||||||
sprintf(buf," plane %d",i);
|
sprintf(buf," plane %d",i);
|
||||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_DISPLAY_LISTS
|
#ifdef USE_DISPLAY_LISTS
|
||||||
|
|
||||||
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
GLuint dlist = OGL_get_displaylist_for_shape((btCollisionShape * )shape);
|
GLuint dlist = OGL_get_displaylist_for_shape((btCollisionShape * )shape);
|
||||||
if (dlist)
|
if (dlist)
|
||||||
@@ -682,8 +688,8 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#else
|
#else
|
||||||
if (shape->isConcave())//>getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
if (shape->isConcave())//>getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
||||||
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
||||||
//btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
//btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
@@ -702,133 +708,133 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_DISPLAY_LISTS
|
#ifdef USE_DISPLAY_LISTS
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
|
if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
|
btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
|
||||||
|
|
||||||
//todo: pass camera for some culling
|
|
||||||
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
|
||||||
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
|
||||||
TriangleGlDrawcallback drawCallback;
|
|
||||||
convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
|
|
||||||
|
|
||||||
}
|
//todo: pass camera for some culling
|
||||||
*/
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
|
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
||||||
|
TriangleGlDrawcallback drawCallback;
|
||||||
|
convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
glDisable(GL_DEPTH_BUFFER_BIT);
|
|
||||||
glRasterPos3f(0,0,0);//mvtx.x(), vtx.y(), vtx.z());
|
|
||||||
if (debugMode&btIDebugDraw::DBG_DrawText)
|
|
||||||
{
|
|
||||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debugMode& btIDebugDraw::DBG_DrawFeaturesText)
|
|
||||||
{
|
|
||||||
//BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getExtraDebugInfo());
|
|
||||||
}
|
|
||||||
glEnable(GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
// glPopMatrix();
|
glDisable(GL_DEPTH_BUFFER_BIT);
|
||||||
if(m_textureenabled) glDisable(GL_TEXTURE_2D);
|
glRasterPos3f(0,0,0);//mvtx.x(), vtx.y(), vtx.z());
|
||||||
|
if (debugMode&btIDebugDraw::DBG_DrawText)
|
||||||
|
{
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debugMode& btIDebugDraw::DBG_DrawFeaturesText)
|
||||||
|
{
|
||||||
|
//BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getExtraDebugInfo());
|
||||||
|
}
|
||||||
|
glEnable(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
// glPopMatrix();
|
||||||
|
if(m_textureenabled) glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrusion,const btCollisionShape* shape)
|
void GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrusion,const btCollisionShape* shape)
|
||||||
{
|
{
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
btglMultMatrix(m);
|
btglMultMatrix(m);
|
||||||
if(shape->getShapeType() == UNIFORM_SCALING_SHAPE_PROXYTYPE)
|
if(shape->getShapeType() == UNIFORM_SCALING_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
const btUniformScalingShape* scalingShape = static_cast<const btUniformScalingShape*>(shape);
|
const btUniformScalingShape* scalingShape = static_cast<const btUniformScalingShape*>(shape);
|
||||||
const btConvexShape* convexShape = scalingShape->getChildShape();
|
const btConvexShape* convexShape = scalingShape->getChildShape();
|
||||||
float scalingFactor = (float)scalingShape->getUniformScalingFactor();
|
float scalingFactor = (float)scalingShape->getUniformScalingFactor();
|
||||||
btScalar tmpScaling[4][4]={ {scalingFactor,0,0,0},
|
btScalar tmpScaling[4][4]={ {scalingFactor,0,0,0},
|
||||||
{0,scalingFactor,0,0},
|
{0,scalingFactor,0,0},
|
||||||
{0,0,scalingFactor,0},
|
{0,0,scalingFactor,0},
|
||||||
{0,0,0,1}};
|
{0,0,0,1}};
|
||||||
drawShadow((btScalar*)tmpScaling,extrusion,convexShape);
|
drawShadow((btScalar*)tmpScaling,extrusion,convexShape);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(shape->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
|
else if(shape->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
|
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
|
||||||
for (int i=compoundShape->getNumChildShapes()-1;i>=0;i--)
|
for (int i=compoundShape->getNumChildShapes()-1;i>=0;i--)
|
||||||
{
|
{
|
||||||
btTransform childTrans = compoundShape->getChildTransform(i);
|
btTransform childTrans = compoundShape->getChildTransform(i);
|
||||||
const btCollisionShape* colShape = compoundShape->getChildShape(i);
|
const btCollisionShape* colShape = compoundShape->getChildShape(i);
|
||||||
btScalar childMat[16];
|
btScalar childMat[16];
|
||||||
childTrans.getOpenGLMatrix(childMat);
|
childTrans.getOpenGLMatrix(childMat);
|
||||||
drawShadow(childMat,extrusion*childTrans.getBasis(),colShape);
|
drawShadow(childMat,extrusion*childTrans.getBasis(),colShape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool useWireframeFallback = true;
|
bool useWireframeFallback = true;
|
||||||
if (shape->isConvex())
|
if (shape->isConvex())
|
||||||
|
{
|
||||||
|
ShapeCache* sc=cache((btConvexShape*)shape);
|
||||||
|
btShapeHull* hull =&sc->m_shapehull;
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
for(int i=0;i<sc->m_edges.size();++i)
|
||||||
|
{
|
||||||
|
const btScalar d=dot(sc->m_edges[i].n[0],extrusion);
|
||||||
|
if((d*dot(sc->m_edges[i].n[1],extrusion))<0)
|
||||||
{
|
{
|
||||||
ShapeCache* sc=cache((btConvexShape*)shape);
|
const int q= d<0?1:0;
|
||||||
btShapeHull* hull =&sc->m_shapehull;
|
const btVector3& a= hull->getVertexPointer()[sc->m_edges[i].v[q]];
|
||||||
glBegin(GL_QUADS);
|
const btVector3& b= hull->getVertexPointer()[sc->m_edges[i].v[1-q]];
|
||||||
for(int i=0;i<sc->m_edges.size();++i)
|
glVertex3f(a[0],a[1],a[2]);
|
||||||
{
|
glVertex3f(b[0],b[1],b[2]);
|
||||||
const btScalar d=dot(sc->m_edges[i].n[0],extrusion);
|
glVertex3f(b[0]+extrusion[0],b[1]+extrusion[1],b[2]+extrusion[2]);
|
||||||
if((d*dot(sc->m_edges[i].n[1],extrusion))<0)
|
glVertex3f(a[0]+extrusion[0],a[1]+extrusion[1],a[2]+extrusion[2]);
|
||||||
{
|
}
|
||||||
const int q= d<0?1:0;
|
}
|
||||||
const btVector3& a= hull->getVertexPointer()[sc->m_edges[i].v[q]];
|
glEnd();
|
||||||
const btVector3& b= hull->getVertexPointer()[sc->m_edges[i].v[1-q]];
|
}
|
||||||
glVertex3f(a[0],a[1],a[2]);
|
|
||||||
glVertex3f(b[0],b[1],b[2]);
|
|
||||||
glVertex3f(b[0]+extrusion[0],b[1]+extrusion[1],b[2]+extrusion[2]);
|
|
||||||
glVertex3f(a[0]+extrusion[0],a[1]+extrusion[1],a[2]+extrusion[2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (shape->isConcave())//>getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
if (shape->isConcave())//>getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
||||||
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
||||||
//btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
//btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
//btVector3 aabbMax(100,100,100);//btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
//btVector3 aabbMax(100,100,100);//btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
|
|
||||||
//todo pass camera, for some culling
|
//todo pass camera, for some culling
|
||||||
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
||||||
|
|
||||||
GlDrawcallback drawCallback;
|
GlDrawcallback drawCallback;
|
||||||
drawCallback.m_wireframe = false;
|
drawCallback.m_wireframe = false;
|
||||||
|
|
||||||
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||||
|
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
}
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
GL_ShapeDrawer::GL_ShapeDrawer()
|
GL_ShapeDrawer::GL_ShapeDrawer()
|
||||||
{
|
{
|
||||||
m_texturehandle = 0;
|
m_texturehandle = 0;
|
||||||
m_textureenabled = false;
|
m_textureenabled = false;
|
||||||
m_textureinitialized = false;
|
m_textureinitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_ShapeDrawer::~GL_ShapeDrawer()
|
GL_ShapeDrawer::~GL_ShapeDrawer()
|
||||||
@@ -836,14 +842,14 @@ GL_ShapeDrawer::~GL_ShapeDrawer()
|
|||||||
int i;
|
int i;
|
||||||
for (i=0;i<m_shapecaches.size();i++)
|
for (i=0;i<m_shapecaches.size();i++)
|
||||||
{
|
{
|
||||||
m_shapecaches[i]->~ShapeCache();
|
m_shapecaches[i]->~ShapeCache();
|
||||||
btAlignedFree(m_shapecaches[i]);
|
btAlignedFree(m_shapecaches[i]);
|
||||||
}
|
}
|
||||||
m_shapecaches.clear();
|
m_shapecaches.clear();
|
||||||
if(m_textureinitialized)
|
if(m_textureinitialized)
|
||||||
{
|
{
|
||||||
glDeleteTextures(1,&m_texturehandle);
|
glDeleteTextures(1,&m_texturehandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1597,7 +1597,7 @@ ColladaConverter::addConcaveMesh(btCollisionShape* shape, const char* nodeName)
|
|||||||
{
|
{
|
||||||
for (int t = 0; t < numFaces; t++)
|
for (int t = 0; t < numFaces; t++)
|
||||||
{
|
{
|
||||||
short int* index = (short int*)indexBase;
|
unsigned short int* index = (unsigned short int*)indexBase;
|
||||||
indices.append3( index[0], index[1], index[2]);
|
indices.append3( index[0], index[1], index[2]);
|
||||||
indexBase += indexStride;
|
indexBase += indexStride;
|
||||||
}
|
}
|
||||||
@@ -1605,7 +1605,7 @@ ColladaConverter::addConcaveMesh(btCollisionShape* shape, const char* nodeName)
|
|||||||
{
|
{
|
||||||
for (int t = 0; t < numFaces; t++)
|
for (int t = 0; t < numFaces; t++)
|
||||||
{
|
{
|
||||||
int* index = (int*)indexBase;
|
unsigned int* index = (unsigned int*)indexBase;
|
||||||
indices.append3( index[0], index[1], index[2]);
|
indices.append3( index[0], index[1], index[2]);
|
||||||
indexBase += indexStride;
|
indexBase += indexStride;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,19 +181,23 @@ void SpuGatheringCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPai
|
|||||||
{
|
{
|
||||||
btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
|
btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
|
||||||
btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject;
|
btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject;
|
||||||
btManifoldResult contactPointResult(colObj0,colObj1);
|
|
||||||
|
|
||||||
if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
|
|
||||||
{
|
|
||||||
//discrete collision detection query
|
|
||||||
collisionPair.m_algorithm->processCollision(colObj0,colObj1,dispatchInfo,&contactPointResult);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//continuous collision detection query, time of impact (toi)
|
|
||||||
btScalar toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult);
|
|
||||||
if (dispatchInfo.m_timeOfImpact > toi)
|
|
||||||
dispatchInfo.m_timeOfImpact = toi;
|
|
||||||
|
|
||||||
|
if (dispatcher->needsCollision(colObj0,colObj1))
|
||||||
|
{
|
||||||
|
btManifoldResult contactPointResult(colObj0,colObj1);
|
||||||
|
|
||||||
|
if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
|
||||||
|
{
|
||||||
|
//discrete collision detection query
|
||||||
|
collisionPair.m_algorithm->processCollision(colObj0,colObj1,dispatchInfo,&contactPointResult);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//continuous collision detection query, time of impact (toi)
|
||||||
|
btScalar toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult);
|
||||||
|
if (dispatchInfo.m_timeOfImpact > toi)
|
||||||
|
dispatchInfo.m_timeOfImpact = toi;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,20 +270,20 @@ public:
|
|||||||
// ugly solution to support both 16bit and 32bit indices
|
// ugly solution to support both 16bit and 32bit indices
|
||||||
if (m_lsMemPtr->bvhShapeData.gIndexMesh.m_indexType == PHY_SHORT)
|
if (m_lsMemPtr->bvhShapeData.gIndexMesh.m_indexType == PHY_SHORT)
|
||||||
{
|
{
|
||||||
short int* indexBasePtr = (short int*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexBase+triangleIndex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexStride);
|
unsigned short int* indexBasePtr = (unsigned short int*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexBase+triangleIndex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexStride);
|
||||||
ATTRIBUTE_ALIGNED16(short int tmpIndices[3]);
|
ATTRIBUTE_ALIGNED16(unsigned short int tmpIndices[3]);
|
||||||
|
|
||||||
small_cache_read_triple(&tmpIndices[0],(ppu_address_t)&indexBasePtr[0],
|
small_cache_read_triple(&tmpIndices[0],(ppu_address_t)&indexBasePtr[0],
|
||||||
&tmpIndices[1],(ppu_address_t)&indexBasePtr[1],
|
&tmpIndices[1],(ppu_address_t)&indexBasePtr[1],
|
||||||
&tmpIndices[2],(ppu_address_t)&indexBasePtr[2],
|
&tmpIndices[2],(ppu_address_t)&indexBasePtr[2],
|
||||||
sizeof(short int));
|
sizeof(unsigned short int));
|
||||||
|
|
||||||
m_lsMemPtr->spuIndices[0] = int(tmpIndices[0]);
|
m_lsMemPtr->spuIndices[0] = int(tmpIndices[0]);
|
||||||
m_lsMemPtr->spuIndices[1] = int(tmpIndices[1]);
|
m_lsMemPtr->spuIndices[1] = int(tmpIndices[1]);
|
||||||
m_lsMemPtr->spuIndices[2] = int(tmpIndices[2]);
|
m_lsMemPtr->spuIndices[2] = int(tmpIndices[2]);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
int* indexBasePtr = (int*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexBase+triangleIndex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexStride);
|
unsigned int* indexBasePtr = (unsigned int*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexBase+triangleIndex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexStride);
|
||||||
|
|
||||||
small_cache_read_triple(&m_lsMemPtr->spuIndices[0],(ppu_address_t)&indexBasePtr[0],
|
small_cache_read_triple(&m_lsMemPtr->spuIndices[0],(ppu_address_t)&indexBasePtr[0],
|
||||||
&m_lsMemPtr->spuIndices[1],(ppu_address_t)&indexBasePtr[1],
|
&m_lsMemPtr->spuIndices[1],(ppu_address_t)&indexBasePtr[1],
|
||||||
@@ -978,9 +978,12 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
|||||||
// Get the collision objects
|
// Get the collision objects
|
||||||
dmaAndSetupCollisionObjects(collisionPairInput, lsMem);
|
dmaAndSetupCollisionObjects(collisionPairInput, lsMem);
|
||||||
|
|
||||||
handleCollisionPair(collisionPairInput, lsMem, spuContacts,
|
if (lsMem.getColObj0()->isActive() || lsMem.getColObj1()->isActive())
|
||||||
(ppu_address_t)lsMem.getColObj0()->getCollisionShape(), &lsMem.gCollisionShapes[0].collisionShape,
|
{
|
||||||
(ppu_address_t)lsMem.getColObj1()->getCollisionShape(), &lsMem.gCollisionShapes[1].collisionShape);
|
handleCollisionPair(collisionPairInput, lsMem, spuContacts,
|
||||||
|
(ppu_address_t)lsMem.getColObj0()->getCollisionShape(), &lsMem.gCollisionShapes[0].collisionShape,
|
||||||
|
(ppu_address_t)lsMem.getColObj1()->getCollisionShape(), &lsMem.gCollisionShapes[1].collisionShape);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -404,9 +404,9 @@ void spuWalkStacklessQuantizedTreeAgainstRays(RaycastTask_LocalStoreMemory* lsMe
|
|||||||
|
|
||||||
#define RAYAABB2
|
#define RAYAABB2
|
||||||
#ifdef RAYAABB2
|
#ifdef RAYAABB2
|
||||||
unsigned int sign[numWorkUnits][3];
|
unsigned int sign[SPU_RAYCAST_WORK_UNITS_PER_TASK][3];
|
||||||
btVector3 rayInvDirection[numWorkUnits];
|
btVector3 rayInvDirection[SPU_RAYCAST_WORK_UNITS_PER_TASK];
|
||||||
btScalar lambda_max[numWorkUnits];
|
btScalar lambda_max[SPU_RAYCAST_WORK_UNITS_PER_TASK];
|
||||||
for (int i = 0; i < numWorkUnits; i++)
|
for (int i = 0; i < numWorkUnits; i++)
|
||||||
{
|
{
|
||||||
btVector3 rayDirection = (rayTo[i]-rayFrom[i]);
|
btVector3 rayDirection = (rayTo[i]-rayFrom[i]);
|
||||||
@@ -512,10 +512,10 @@ void performRaycastAgainstConcave (RaycastGatheredObjectData* gatheredObjectData
|
|||||||
//need the mesh interface, for access to triangle vertices
|
//need the mesh interface, for access to triangle vertices
|
||||||
dmaBvhShapeData (&(lsMemPtr->bvhShapeData), trimeshShape);
|
dmaBvhShapeData (&(lsMemPtr->bvhShapeData), trimeshShape);
|
||||||
|
|
||||||
unsigned short int quantizedQueryAabbMin[numWorkUnits][3];
|
unsigned short int quantizedQueryAabbMin[SPU_RAYCAST_WORK_UNITS_PER_TASK][3];
|
||||||
unsigned short int quantizedQueryAabbMax[numWorkUnits][3];
|
unsigned short int quantizedQueryAabbMax[SPU_RAYCAST_WORK_UNITS_PER_TASK][3];
|
||||||
btVector3 rayFromInTriangleSpace[numWorkUnits];
|
btVector3 rayFromInTriangleSpace[SPU_RAYCAST_WORK_UNITS_PER_TASK];
|
||||||
btVector3 rayToInTriangleSpace[numWorkUnits];
|
btVector3 rayToInTriangleSpace[SPU_RAYCAST_WORK_UNITS_PER_TASK];
|
||||||
|
|
||||||
/* Calculate the AABB for the ray in the triangle mesh shape */
|
/* Calculate the AABB for the ray in the triangle mesh shape */
|
||||||
btTransform rayInTriangleSpace;
|
btTransform rayInTriangleSpace;
|
||||||
@@ -781,4 +781,4 @@ void processRaycastTask(void* userPtr, void* lsMemory)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration::getCollisionAlg
|
|||||||
|
|
||||||
if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE))
|
if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE))
|
||||||
{
|
{
|
||||||
return m_boxBoxCF;
|
//return m_boxBoxCF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE))
|
if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE))
|
||||||
|
|||||||
@@ -143,17 +143,13 @@ class btPersistentManifoldSortPredicate
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects)
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// todo: this is random access, it can be walked 'cache friendly'!
|
|
||||||
//
|
|
||||||
void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
BT_PROFILE("islandUnionFindAndQuickSort");
|
BT_PROFILE("islandUnionFindAndQuickSort");
|
||||||
|
|
||||||
|
m_islandmanifold.resize(0);
|
||||||
|
|
||||||
//we are going to sort the unionfind array, and store the element id in the size
|
//we are going to sort the unionfind array, and store the element id in the size
|
||||||
//afterwards, we clean unionfind, to make sure no-one uses it anymore
|
//afterwards, we clean unionfind, to make sure no-one uses it anymore
|
||||||
|
|
||||||
@@ -287,6 +283,23 @@ void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,
|
|||||||
#endif //SPLIT_ISLANDS
|
#endif //SPLIT_ISLANDS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// todo: this is random access, it can be walked 'cache friendly'!
|
||||||
|
//
|
||||||
|
void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback)
|
||||||
|
{
|
||||||
|
|
||||||
|
buildIslands(dispatcher,collisionObjects);
|
||||||
|
|
||||||
|
int endIslandIndex=1;
|
||||||
|
int startIslandIndex;
|
||||||
|
int numElem = getUnionFind().getNumElements();
|
||||||
|
|
||||||
|
BT_PROFILE("processIslands");
|
||||||
|
|
||||||
#ifndef SPLIT_ISLANDS
|
#ifndef SPLIT_ISLANDS
|
||||||
btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
|
btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
|
||||||
@@ -367,5 +380,5 @@ void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,
|
|||||||
}
|
}
|
||||||
#endif //SPLIT_ISLANDS
|
#endif //SPLIT_ISLANDS
|
||||||
|
|
||||||
m_islandmanifold.resize(0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ public:
|
|||||||
|
|
||||||
void buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback);
|
void buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback);
|
||||||
|
|
||||||
|
void buildIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SIMULATION_ISLAND_MANAGER_H
|
#endif //SIMULATION_ISLAND_MANAGER_H
|
||||||
|
|||||||
@@ -127,13 +127,13 @@ void btBvhTriangleMeshShape::performRaycast (btTriangleCallback* callback, const
|
|||||||
indicestype,
|
indicestype,
|
||||||
nodeSubPart);
|
nodeSubPart);
|
||||||
|
|
||||||
int* gfxbase = (int*)(indexbase+nodeTriangleIndex*indexstride);
|
unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
|
||||||
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
|
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
|
||||||
|
|
||||||
const btVector3& meshScaling = m_meshInterface->getScaling();
|
const btVector3& meshScaling = m_meshInterface->getScaling();
|
||||||
for (int j=2;j>=0;j--)
|
for (int j=2;j>=0;j--)
|
||||||
{
|
{
|
||||||
int graphicsindex = indicestype==PHY_SHORT?((short*)gfxbase)[j]:gfxbase[j];
|
int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
|
||||||
|
|
||||||
btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
|
btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
|
||||||
|
|
||||||
@@ -187,13 +187,13 @@ void btBvhTriangleMeshShape::performConvexcast (btTriangleCallback* callback, co
|
|||||||
indicestype,
|
indicestype,
|
||||||
nodeSubPart);
|
nodeSubPart);
|
||||||
|
|
||||||
int* gfxbase = (int*)(indexbase+nodeTriangleIndex*indexstride);
|
unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
|
||||||
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
|
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
|
||||||
|
|
||||||
const btVector3& meshScaling = m_meshInterface->getScaling();
|
const btVector3& meshScaling = m_meshInterface->getScaling();
|
||||||
for (int j=2;j>=0;j--)
|
for (int j=2;j>=0;j--)
|
||||||
{
|
{
|
||||||
int graphicsindex = indicestype==PHY_SHORT?((short*)gfxbase)[j]:gfxbase[j];
|
int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
|
||||||
|
|
||||||
btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
|
btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
|
||||||
|
|
||||||
@@ -259,14 +259,14 @@ void btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,co
|
|||||||
indicestype,
|
indicestype,
|
||||||
nodeSubPart);
|
nodeSubPart);
|
||||||
|
|
||||||
int* gfxbase = (int*)(indexbase+nodeTriangleIndex*indexstride);
|
unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
|
||||||
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
|
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
|
||||||
|
|
||||||
const btVector3& meshScaling = m_meshInterface->getScaling();
|
const btVector3& meshScaling = m_meshInterface->getScaling();
|
||||||
for (int j=2;j>=0;j--)
|
for (int j=2;j>=0;j--)
|
||||||
{
|
{
|
||||||
|
|
||||||
int graphicsindex = indicestype==PHY_SHORT?((short*)gfxbase)[j]:gfxbase[j];
|
int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_TRIANGLE_MESH
|
#ifdef DEBUG_TRIANGLE_MESH
|
||||||
@@ -299,22 +299,37 @@ void btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,co
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void btBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling)
|
||||||
void btBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling)
|
|
||||||
{
|
{
|
||||||
if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON)
|
if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON)
|
||||||
{
|
{
|
||||||
btTriangleMeshShape::setLocalScaling(scaling);
|
btTriangleMeshShape::setLocalScaling(scaling);
|
||||||
if (m_ownsBvh)
|
if (m_ownsBvh)
|
||||||
{
|
{
|
||||||
m_bvh->~btOptimizedBvh();
|
m_bvh->~btOptimizedBvh();
|
||||||
btAlignedFree(m_bvh);
|
btAlignedFree(m_bvh);
|
||||||
}
|
}
|
||||||
///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work
|
///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work
|
||||||
void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
|
void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
|
||||||
m_bvh = new(mem) btOptimizedBvh();
|
m_bvh = new(mem) btOptimizedBvh();
|
||||||
//rebuild the bvh...
|
//rebuild the bvh...
|
||||||
m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax);
|
m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax);
|
||||||
|
m_ownsBvh = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void btBvhTriangleMeshShape::setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& scaling)
|
||||||
|
{
|
||||||
|
btAssert(!m_bvh);
|
||||||
|
btAssert(!m_ownsBvh);
|
||||||
|
|
||||||
|
m_bvh = bvh;
|
||||||
|
m_ownsBvh = false;
|
||||||
|
// update the scaling without rebuilding the bvh
|
||||||
|
if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON)
|
||||||
|
{
|
||||||
|
btTriangleMeshShape::setLocalScaling(scaling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,14 +75,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setOptimizedBvh(btOptimizedBvh* bvh)
|
void setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1));
|
||||||
{
|
|
||||||
btAssert(!m_bvh);
|
|
||||||
btAssert(!m_ownsBvh);
|
|
||||||
|
|
||||||
m_bvh = bvh;
|
|
||||||
m_ownsBvh = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool usesQuantizedAabbCompression() const
|
bool usesQuantizedAabbCompression() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -334,13 +334,13 @@ void btOptimizedBvh::updateBvhNodes(btStridingMeshInterface* meshInterface,int f
|
|||||||
}
|
}
|
||||||
//triangles->getLockedReadOnlyVertexIndexBase(vertexBase,numVerts,
|
//triangles->getLockedReadOnlyVertexIndexBase(vertexBase,numVerts,
|
||||||
|
|
||||||
int* gfxbase = (int*)(indexbase+nodeTriangleIndex*indexstride);
|
unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
|
||||||
|
|
||||||
|
|
||||||
for (int j=2;j>=0;j--)
|
for (int j=2;j>=0;j--)
|
||||||
{
|
{
|
||||||
|
|
||||||
int graphicsindex = indicestype==PHY_SHORT?((short*)gfxbase)[j]:gfxbase[j];
|
int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
|
||||||
btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
|
btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
|
||||||
#ifdef DEBUG_PATCH_COLORS
|
#ifdef DEBUG_PATCH_COLORS
|
||||||
btVector3 mycolor = color[index&3];
|
btVector3 mycolor = color[index&3];
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
|
|||||||
{
|
{
|
||||||
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
|
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
|
||||||
{
|
{
|
||||||
int* tri_indices= (int*)(indexbase+gfxindex*indexstride);
|
unsigned int* tri_indices= (unsigned int*)(indexbase+gfxindex*indexstride);
|
||||||
graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
|
||||||
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
|
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
|
||||||
graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
|
||||||
@@ -66,7 +66,7 @@ void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
|
|||||||
{
|
{
|
||||||
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
|
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
|
||||||
{
|
{
|
||||||
short int* tri_indices= (short int*)(indexbase+gfxindex*indexstride);
|
unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride);
|
||||||
graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
|
||||||
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
|
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
|
||||||
graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class btStridingMeshInterface
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
||||||
|
|
||||||
///brute force method to calculate aabb
|
///brute force method to calculate aabb
|
||||||
void calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax);
|
void calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class btTriangleMesh : public btTriangleIndexVertexArray
|
|||||||
btAlignedObjectArray<btVector3> m_4componentVertices;
|
btAlignedObjectArray<btVector3> m_4componentVertices;
|
||||||
btAlignedObjectArray<float> m_3componentVertices;
|
btAlignedObjectArray<float> m_3componentVertices;
|
||||||
|
|
||||||
btAlignedObjectArray<int> m_32bitIndices;
|
btAlignedObjectArray<unsigned int> m_32bitIndices;
|
||||||
btAlignedObjectArray<short int> m_16bitIndices;
|
btAlignedObjectArray<unsigned short int> m_16bitIndices;
|
||||||
bool m_use32bitIndices;
|
bool m_use32bitIndices;
|
||||||
bool m_use4componentVertices;
|
bool m_use4componentVertices;
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ bool btSubsimplexConvexCast::calcTimeOfImpact(
|
|||||||
dist2 = v.length2();
|
dist2 = v.length2();
|
||||||
hasResult = true;
|
hasResult = true;
|
||||||
//todo: check this normal for validity
|
//todo: check this normal for validity
|
||||||
n=v;
|
//n=v;
|
||||||
//printf("V=%f , %f, %f\n",v[0],v[1],v[2]);
|
//printf("V=%f , %f, %f\n",v[0],v[1],v[2]);
|
||||||
//printf("DIST2=%f\n",dist2);
|
//printf("DIST2=%f\n",dist2);
|
||||||
//printf("numverts = %i\n",m_simplexSolver->numVertices());
|
//printf("numverts = %i\n",m_simplexSolver->numVertices());
|
||||||
|
|||||||
@@ -100,6 +100,16 @@ void btPoint2PointConstraint::solveConstraint(btScalar timeStep)
|
|||||||
btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal
|
btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal
|
||||||
|
|
||||||
btScalar impulse = depth*m_setting.m_tau/timeStep * jacDiagABInv - m_setting.m_damping * rel_vel * jacDiagABInv;
|
btScalar impulse = depth*m_setting.m_tau/timeStep * jacDiagABInv - m_setting.m_damping * rel_vel * jacDiagABInv;
|
||||||
|
|
||||||
|
btScalar impulseClamp = m_setting.m_impulseClamp;
|
||||||
|
if (impulseClamp > 0)
|
||||||
|
{
|
||||||
|
if (impulse < -impulseClamp)
|
||||||
|
impulse = -impulseClamp;
|
||||||
|
if (impulse > impulseClamp)
|
||||||
|
impulse = impulseClamp;
|
||||||
|
}
|
||||||
|
|
||||||
m_appliedImpulse+=impulse;
|
m_appliedImpulse+=impulse;
|
||||||
btVector3 impulse_vector = normal * impulse;
|
btVector3 impulse_vector = normal * impulse;
|
||||||
m_rbA.applyImpulse(impulse_vector, pivotAInW - m_rbA.getCenterOfMassPosition());
|
m_rbA.applyImpulse(impulse_vector, pivotAInW - m_rbA.getCenterOfMassPosition());
|
||||||
|
|||||||
@@ -26,11 +26,13 @@ struct btConstraintSetting
|
|||||||
{
|
{
|
||||||
btConstraintSetting() :
|
btConstraintSetting() :
|
||||||
m_tau(btScalar(0.3)),
|
m_tau(btScalar(0.3)),
|
||||||
m_damping(btScalar(1.))
|
m_damping(btScalar(1.)),
|
||||||
|
m_impulseClamp(btScalar(0.))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
btScalar m_tau;
|
btScalar m_tau;
|
||||||
btScalar m_damping;
|
btScalar m_damping;
|
||||||
|
btScalar m_impulseClamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 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
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int gNumSplitImpulseRecoveries = 0;
|
int gNumSplitImpulseRecoveries = 0;
|
||||||
|
|
||||||
btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
|
btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
|
||||||
|
|||||||
Reference in New Issue
Block a user