From 8f2c6bad9a8c7c25fd4d8fa58c63fd823f4dd74b Mon Sep 17 00:00:00 2001 From: nkorslund Date: Wed, 22 Oct 2008 09:34:30 +0000 Subject: [PATCH] Fixed non-compiling bullet code git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@52 ea6a568a-9f4f-0410-981a-c910a81bb256 --- Makefile | 4 +- bullet/cpp_bullet.cpp | 88 ++++++++++++++++++++--------------------- dsss.conf | 4 +- ogre/cpp_bsaarchive.cpp | 2 + ogre/cpp_interface.cpp | 5 ++- 5 files changed, 53 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index a681562f1..0f4bbff0f 100644 --- a/Makefile +++ b/Makefile @@ -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$@ diff --git a/bullet/cpp_bullet.cpp b/bullet/cpp_bullet.cpp index 83d1e8b28..f33a38f5a 100644 --- a/bullet/cpp_bullet.cpp +++ b/bullet/cpp_bullet.cpp @@ -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; iaddIndexedMesh(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; iaddIndexedMesh(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() diff --git a/dsss.conf b/dsss.conf index 359883bad..df7354800 100644 --- a/dsss.conf +++ b/dsss.conf @@ -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 diff --git a/ogre/cpp_bsaarchive.cpp b/ogre/cpp_bsaarchive.cpp index 1eaabe20c..abe2b31ab 100644 --- a/ogre/cpp_bsaarchive.cpp +++ b/ogre/cpp_bsaarchive.cpp @@ -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. diff --git a/ogre/cpp_interface.cpp b/ogre/cpp_interface.cpp index e7329181b..7a46a70b8 100644 --- a/ogre/cpp_interface.cpp +++ b/ogre/cpp_interface.cpp @@ -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));