|
|
|
@@ -47,144 +47,84 @@ subject to the following restrictions:
|
|
|
|
#include "BMF_Api.h"
|
|
|
|
#include "BMF_Api.h"
|
|
|
|
#include <stdio.h> //printf debugging
|
|
|
|
#include <stdio.h> //printf debugging
|
|
|
|
|
|
|
|
|
|
|
|
class GlDrawcallback : public btTriangleCallback
|
|
|
|
//#define USE_DISPLAY_LISTS 1
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
bool m_wireframe;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (m_wireframe)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
|
|
|
glColor3f(1, 0, 0);
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
glColor3f(0, 1, 0);
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
glColor3f(0, 0, 1);
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
btVector3 diff1 = triangle[1] - triangle[0];
|
|
|
|
|
|
|
|
btVector3 diff2 = triangle[2] - triangle[0];
|
|
|
|
|
|
|
|
btVector3 normal = diff1.cross(diff2);
|
|
|
|
|
|
|
|
normal.normalize();
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
|
|
|
|
glColor3f(1.0f, 0.3f, 0.6f);
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
glColor3f(1.0f, 0.3f, 0.6f);
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
glColor3f(1.0f, 0.3f, 0.6f);
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GlDrawcallback_plane : public btTriangleCallback
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
bool m_wireframe;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(m_wireframe)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
|
|
|
glColor3f(0.5, 0, 1);
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
glColor3f(0.5, 0, 1);
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
glColor3f(0.5, 0, 1);
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
|
|
|
|
glColor3f(0.4, -0.4, 0.5);
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glColor3f(0.4, -0.4, 1.0);
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glColor3f(0.4, -0.4, 0.5);
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TriangleGlDrawcallback : public btInternalTriangleIndexCallback
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLES);//LINES);
|
|
|
|
|
|
|
|
glColor3f(1, 0, 0);
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
glColor3f(0, 1, 0);
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
glColor3f(0, 0, 1);
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define USE_DISPLAY_LISTS 1
|
|
|
|
|
|
|
|
#ifdef USE_DISPLAY_LISTS
|
|
|
|
#ifdef USE_DISPLAY_LISTS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
//Set for storing Display list per trimesh
|
|
|
|
//Set for storing Display list per trimesh
|
|
|
|
struct TRIMESH_KEY
|
|
|
|
struct TRIMESH_KEY
|
|
|
|
{
|
|
|
|
{
|
|
|
|
btCollisionShape* m_shape;
|
|
|
|
btCollisionShape* m_shape;
|
|
|
|
GLuint m_dlist;//OpenGL display list
|
|
|
|
GLuint m_dlist;//OpenGL display list
|
|
|
|
GLuint m_dlist_wireframe;//OpenGL display list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline bool operator <(const TRIMESH_KEY& other) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (m_shape < other.m_shape);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline bool operator >(const TRIMESH_KEY& other) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (m_shape > other.m_shape);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef btAlignedObjectArray<TRIMESH_KEY> TRIMESH_KEY_MAP;
|
|
|
|
typedef map<unsigned long,TRIMESH_KEY> TRIMESH_KEY_MAP;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef pair<unsigned long,TRIMESH_KEY> TRIMESH_KEY_PAIR;
|
|
|
|
|
|
|
|
|
|
|
|
TRIMESH_KEY_MAP g_display_lists;
|
|
|
|
TRIMESH_KEY_MAP g_display_lists;
|
|
|
|
|
|
|
|
|
|
|
|
TRIMESH_KEY * OGL_get_displaylist_for_shape(btCollisionShape * shape)
|
|
|
|
class GlDisplaylistDrawcallback : public btTriangleCallback
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(g_display_lists.size()==0) return 0;
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
TRIMESH_KEY searchkey;
|
|
|
|
virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
|
|
|
|
searchkey.m_shape = shape;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int map_iter = g_display_lists.findBinarySearch(searchkey);
|
|
|
|
|
|
|
|
if(map_iter < g_display_lists.size())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return &g_display_lists[map_iter];
|
|
|
|
|
|
|
|
|
|
|
|
btVector3 diff1 = triangle[1] - triangle[0];
|
|
|
|
|
|
|
|
btVector3 diff2 = triangle[2] - triangle[0];
|
|
|
|
|
|
|
|
btVector3 normal = diff1.cross(diff2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
normal.normalize();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
|
|
|
|
glColor3f(0, 1, 0);
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glColor3f(0, 1, 0);
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glColor3f(0, 1, 0);
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*glBegin(GL_LINES);
|
|
|
|
|
|
|
|
glColor3f(1, 1, 0);
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
glColor3f(1, 1, 0);
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
|
|
|
|
|
|
|
glColor3f(1, 1, 0);
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
|
|
|
|
|
|
|
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
|
|
|
|
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
|
|
|
|
glEnd();*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GLuint OGL_get_displaylist_for_shape(btCollisionShape * shape)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TRIMESH_KEY_MAP::iterator map_iter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned long key = (unsigned long)shape;
|
|
|
|
|
|
|
|
map_iter = g_display_lists.find(key);
|
|
|
|
|
|
|
|
if(map_iter!=g_display_lists.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return map_iter->second.m_dlist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
@@ -192,119 +132,51 @@ TRIMESH_KEY * OGL_get_displaylist_for_shape(btCollisionShape * shape)
|
|
|
|
|
|
|
|
|
|
|
|
void OGL_displaylist_clean()
|
|
|
|
void OGL_displaylist_clean()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int map_iter = g_display_lists.size();
|
|
|
|
TRIMESH_KEY_MAP::iterator map_iter,map_itend;
|
|
|
|
|
|
|
|
|
|
|
|
while(map_iter--)
|
|
|
|
map_iter = g_display_lists.begin();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(map_iter!=map_itend)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glDeleteLists(g_display_lists[map_iter].m_dlist,1);
|
|
|
|
glDeleteLists(map_iter->second.m_dlist,1);
|
|
|
|
glDeleteLists(g_display_lists[map_iter].m_dlist_wireframe,1);
|
|
|
|
map_iter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
g_display_lists.clear();
|
|
|
|
g_display_lists.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TRIMESH_KEY * OGL_displaylist_register_shape(btCollisionShape * shape)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
|
|
|
|
|
|
|
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
|
|
|
|
|
|
|
GlDrawcallback drawCallback;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OGL_displaylist_register_shape(btCollisionShape * shape)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
|
|
|
|
|
|
|
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
|
|
|
|
|
|
|
GlDisplaylistDrawcallback drawCallback;
|
|
|
|
TRIMESH_KEY dlist;
|
|
|
|
TRIMESH_KEY dlist;
|
|
|
|
|
|
|
|
|
|
|
|
dlist.m_dlist = glGenLists(1);
|
|
|
|
dlist.m_dlist = glGenLists(1);
|
|
|
|
dlist.m_dlist_wireframe = glGenLists(1);
|
|
|
|
|
|
|
|
dlist.m_shape = shape;
|
|
|
|
dlist.m_shape = shape;
|
|
|
|
|
|
|
|
|
|
|
|
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
|
|
|
unsigned long key = (unsigned long)shape;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_display_lists.insert(TRIMESH_KEY_PAIR(key,dlist));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glNewList(dlist.m_dlist,GL_COMPILE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (shape->isConcave())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
|
|
|
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
|
|
|
//Draw
|
|
|
|
//todo pass camera, for some culling
|
|
|
|
glNewList(dlist.m_dlist,GL_COMPILE);
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
drawCallback.m_wireframe = false;
|
|
|
|
|
|
|
|
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
|
|
|
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
|
|
|
glEndList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Draw wireframe
|
|
|
|
|
|
|
|
glNewList(dlist.m_dlist_wireframe,GL_COMPILE);
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
drawCallback.m_wireframe = true;
|
|
|
|
|
|
|
|
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
|
|
|
|
|
|
|
glEndList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
btConcaveShape* gimpactMesh = (btConcaveShape*) shape;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Draw
|
|
|
|
|
|
|
|
glNewList(dlist.m_dlist,GL_COMPILE);
|
|
|
|
|
|
|
|
//glEnable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
//glCullFace(GL_BACK);
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
drawCallback.m_wireframe = false;
|
|
|
|
|
|
|
|
gimpactMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
|
|
|
|
|
|
|
//glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
glEndList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Draw wireframe
|
|
|
|
|
|
|
|
glNewList(dlist.m_dlist_wireframe,GL_COMPILE);
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
drawCallback.m_wireframe = true;
|
|
|
|
|
|
|
|
gimpactMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
|
|
|
|
|
|
|
glEndList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (shape->getShapeType() == STATIC_PLANE_PROXYTYPE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
GlDrawcallback_plane drawPlaneCallback;
|
|
|
|
|
|
|
|
btVector3 paabbMax(100.f,100.f,100.f);
|
|
|
|
|
|
|
|
btVector3 paabbMin(-100.f,-100.f,-100.f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btConcaveShape* planeshape = (btConcaveShape*) shape;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Draw
|
|
|
|
|
|
|
|
glNewList(dlist.m_dlist,GL_COMPILE);
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
drawPlaneCallback.m_wireframe = false;
|
|
|
|
|
|
|
|
planeshape->processAllTriangles(&drawPlaneCallback,paabbMin,paabbMax);
|
|
|
|
|
|
|
|
glEndList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Draw wireframe
|
|
|
|
|
|
|
|
glNewList(dlist.m_dlist_wireframe,GL_COMPILE);
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
drawPlaneCallback.m_wireframe = true;
|
|
|
|
|
|
|
|
planeshape->processAllTriangles(&drawPlaneCallback,paabbMin,paabbMax);
|
|
|
|
|
|
|
|
glEndList();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
g_display_lists.push_back(dlist);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
g_display_lists.heapSort(TRIMESH_KEY_MAP::less());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int inserted = g_display_lists.findBinarySearch(dlist);
|
|
|
|
glEndList();
|
|
|
|
|
|
|
|
|
|
|
|
return &g_display_lists[inserted];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OGL_draw_shape(btCollisionShape* shape, bool wireframe)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TRIMESH_KEY * dlist = OGL_get_displaylist_for_shape(shape);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(dlist == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dlist = OGL_displaylist_register_shape(shape);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(wireframe)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
glCallList(dlist->m_dlist_wireframe);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
glCallList(dlist->m_dlist);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif //USE_DISPLAY_LISTS
|
|
|
|
#endif //USE_DISPLAY_LISTS
|
|
|
|
|
|
|
|
|
|
|
|
void GL_ShapeDrawer::drawCoordSystem() {
|
|
|
|
void GL_ShapeDrawer::drawCoordSystem() {
|
|
|
|
@@ -325,7 +197,7 @@ void GL_ShapeDrawer::drawCoordSystem() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
class GlDrawcallback : public btTriangleCallback
|
|
|
|
class GlDrawcallback : public btTriangleCallback
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
@@ -371,9 +243,8 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*class TriangleGlDrawcallback : public btInternalTriangleIndexCallback
|
|
|
|
class TriangleGlDrawcallback : public btInternalTriangleIndexCallback
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
|
|
|
|
virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
|
|
|
|
@@ -394,7 +265,7 @@ public:
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
|
|
|
glEnd();
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};*/
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
|
|
|
|
void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -442,7 +313,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
glPushMatrix();
|
|
|
|
btglMultMatrix(m);
|
|
|
|
btglMultMatrix(m);
|
|
|
|
|
|
|
|
|
|
|
|
if (shape->getShapeType() == UNIFORM_SCALING_SHAPE_PROXYTYPE)
|
|
|
|
if (shape->getShapeType() == UNIFORM_SCALING_SHAPE_PROXYTYPE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -643,31 +514,27 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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)
|
|
|
|
shape->getShapeType() == STATIC_PLANE_PROXYTYPE)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if((debugMode & btIDebugDraw::DBG_DrawWireframe)!=0)
|
|
|
|
GLuint dlist = OGL_get_displaylist_for_shape((btCollisionShape * )shape);
|
|
|
|
|
|
|
|
if (dlist)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OGL_draw_shape((btCollisionShape *)shape,true);
|
|
|
|
glCallList(dlist);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OGL_draw_shape((btCollisionShape *)shape,false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
if (shape->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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
btConcaveShape* concaveMesh = (btTriangleMeshShape*) shape;
|
|
|
|
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
|
|
|
//btVector3 aabbMax(1e30f,1e30f,1e30f);
|
|
|
|
//btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
|
|
|
//btVector3 aabbMax(100,100,100);//1e30f,1e30f,1e30f);
|
|
|
|
//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(1e30f,1e30f,1e30f);
|
|
|
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
|
|
|
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
|
|
|
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
|
|
|
|
|
|
|
|
|
|
|
GlDrawcallback drawCallback;
|
|
|
|
GlDrawcallback drawCallback;
|
|
|
|
drawCallback.m_wireframe = (debugMode & btIDebugDraw::DBG_DrawWireframe)!=0;
|
|
|
|
drawCallback.m_wireframe = (debugMode & btIDebugDraw::DBG_DrawWireframe)!=0;
|
|
|
|
@@ -675,24 +542,12 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|
|
|
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
|
|
|
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (shape->getShapeType() == STATIC_PLANE_PROXYTYPE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GlDrawcallback_plane drawPlaneCallback;
|
|
|
|
|
|
|
|
btVector3 paabbMax(100.f,100.f,100.f);
|
|
|
|
|
|
|
|
btVector3 paabbMin(-100.f,-100.f,-100.f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btConcaveShape* planeshape = (btConcaveShape*) shape;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drawPlaneCallback.m_wireframe = (debugMode & btIDebugDraw::DBG_DrawWireframe)!=0;
|
|
|
|
|
|
|
|
//Draw
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
planeshape->processAllTriangles(&drawPlaneCallback,paabbMin,paabbMax);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_DISPLAY_LISTS
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
|
|
|
|
if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|