Fixed non-compiling bullet code

git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@52 ea6a568a-9f4f-0410-981a-c910a81bb256
pull/7/head
nkorslund 16 years ago
parent ebf1862971
commit 8f2c6bad9a

@ -75,10 +75,10 @@ nifobjs/%.o: %.d
$(DMD) $(NIFFLAGS) -c $< -of$@
openmw: openmw.d cpp_ogre.o cpp_avcodec.o cpp_bullet.o $(obj)
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat bullet/libBulletDynamics.a bullet/libBulletCollision.a bullet/libLinearMath.a
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
esmtool: esmtool.d cpp_ogre.o cpp_avcodec.o $(obj)
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
niftool: niftool.d $(obj_nif)
$(DMD) $^ -of$@

@ -286,6 +286,49 @@ const short cube_tris[] =
const int cube_num_verts = 8;
const int cube_num_tris = 12;
// Internal version that does not copy buffers
void createTriShape(int32_t numFaces, void *triArray,
int32_t numVerts, void *vertArray,
float *trans, float *matrix)
{
// This struct holds the index and vertex buffers of a single
// trimesh.
btIndexedMesh im;
// Set up the triangles
int numTriangles = numFaces / 3;
im.m_numTriangles = numTriangles;
im.m_triangleIndexStride = 6; // 3 indices * 2 bytes per short
im.m_triangleIndexBase = (unsigned char*)triArray;
// Set up the vertices
im.m_numVertices = numVerts;
im.m_vertexStride = 12; // 4 bytes per float * 3 floats per vertex
im.m_vertexBase = (unsigned char*)vertArray;
// Transform vertex values in vb according to 'trans' and 'matrix'
float *vb = (float*)im.m_vertexBase;
for(int i=0; i<numVerts; i++)
{
float x,y,z;
// Reinventing basic linear algebra for the win!
x = matrix[0]*vb[0]+matrix[1]*vb[1]+matrix[2]*vb[2] + trans[0];
y = matrix[3]*vb[0]+matrix[4]*vb[1]+matrix[5]*vb[2] + trans[1];
z = matrix[6]*vb[0]+matrix[7]*vb[1]+matrix[8]*vb[2] + trans[2];
*(vb++) = x;
*(vb++) = y;
*(vb++) = z;
}
// If no mesh is currently active, create one
if(g_currentMesh == NULL)
g_currentMesh = new btTriangleIndexVertexArray;
// Add the mesh. Nif data stores triangle indices as shorts.
g_currentMesh->addIndexedMesh(im, PHY_SHORT);
}
// Create a (trimesh) box with the given dimensions. Used for bounding
// boxes. TODO: I guess we have to use the NIF-specified bounding box
// for this, not our automatically calculated one.
@ -327,54 +370,11 @@ extern "C" void bullet_createTriShape(int32_t numFaces,
float *trans,
float *matrix)
{
createTriShape(numFaces, copyBuffer(triArray, 2, numFaces)
createTriShape(numFaces, copyBuffer(triArray, 2, numFaces),
numVerts, copyBuffer(vertArray, 12, numVerts),
trans, matrix);
}
// Internal version that does not copy buffers
void createTriShape(int32_t numFaces, void *triArray,
int32_t numVerts, void *vertArray,
float *trans, float *matrix)
{
// This struct holds the index and vertex buffers of a single
// trimesh.
btIndexedMesh im;
// Set up the triangles
int numTriangles = numFaces / 3;
im.m_numTriangles = numTriangles;
im.m_triangleIndexStride = 6; // 3 indices * 2 bytes per short
im.m_triangleIndexBase = (unsigned char*)triArray;
// Set up the vertices
im.m_numVertices = numVerts;
im.m_vertexStride = 12; // 4 bytes per float * 3 floats per vertex
im.m_vertexBase = (unsigned char*)vertArray;
// Transform vertex values in vb according to 'trans' and 'matrix'
float *vb = (float*)im.m_vertexBase;
for(int i=0; i<numVerts; i++)
{
float x,y,z;
// Reinventing basic linear algebra for the win!
x = matrix[0]*vb[0]+matrix[1]*vb[1]+matrix[2]*vb[2] + trans[0];
y = matrix[3]*vb[0]+matrix[4]*vb[1]+matrix[5]*vb[2] + trans[1];
z = matrix[6]*vb[0]+matrix[7]*vb[1]+matrix[8]*vb[2] + trans[2];
*(vb++) = x;
*(vb++) = y;
*(vb++) = z;
}
// If no mesh is currently active, create one
if(g_currentMesh == NULL)
g_currentMesh = new btTriangleIndexVertexArray;
// Add the mesh. Nif data stores triangle indices as shorts.
g_currentMesh->addIndexedMesh(im, PHY_SHORT);
}
// Get the shape built up so far, if any. This clears g_currentMesh,
// so the next call to createTriShape will start a new shape.
extern "C" btCollisionShape *bullet_getFinalShape()

@ -4,7 +4,7 @@
[openmw.d]
# Add libraries and the two C++ object files
buildflags = -llOgreMain -llopenal -llOIS -llavcodec -llavformat cpp_ogre.o cpp_avcodec.o cpp_bullet.o bullet/libBulletDynamics.a bullet/libBulletCollision.a bullet/libLinearMath.a
buildflags = -llOgreMain -llopenal -llOIS -llavcodec -llavformat cpp_ogre.o cpp_avcodec.o cpp_bullet.o bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
# Make sure the C++ object files are built first
version(Windows) {
@ -34,7 +34,7 @@ prebuild += dsss clean niftool
[esmtool.d]
# Because of interdepencies between the ESM code and the resource
# manager, we have to include all the C++ stuff.
buildflags = -llOgreMain -llopenal -llOIS -llavcodec -llavformat cpp_ogre.o cpp_avcodec.o cpp_bullet.o bullet/libBulletDynamics.a bullet/libBulletCollision.a bullet/libLinearMath.a
buildflags = -llOgreMain -llopenal -llOIS -llavcodec -llavformat cpp_ogre.o cpp_avcodec.o cpp_bullet.o bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a

@ -82,6 +82,8 @@ public:
return ptr;
}
time_t getModifiedTime(const String&) { return 0; }
// After load() is called, find("*") is called once. It doesn't seem
// to matter that we return an empty list, exists() gets called on
// the correct files anyway.

@ -193,8 +193,9 @@ extern "C" void ogre_makeScene()
// Turn the entire scene (represented by the 'root' node) -90
// degrees around the x axis. This makes Z go upwards, and Y go into
// the screen. This is the orientation that Morrowind uses, and it
// automagically makes everything work as it should.
// the screen (when x is to the right.) This is the orientation that
// Morrowind uses, and it automagically makes everything work as it
// should.
SceneNode *rt = mSceneMgr->getRootSceneNode();
root = rt->createChildSceneNode();
root->pitch(Degree(-90));

Loading…
Cancel
Save