From 1bf7c4e53dde506788e3f521effd98ae152495ef Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 3 Aug 2011 11:41:16 +0200 Subject: [PATCH] Improve bullet performances --- components/nifbullet/bullet_nif_loader.cpp | 10 ++++------ components/nifbullet/bullet_nif_loader.hpp | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 94a3a5aac8..32ca8c41c7 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -88,8 +88,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) resourceName = cShape->getName(); cShape->collide = false; - currentShape = new btCompoundShape(); - cShape->Shape = currentShape; + mTriMesh = new btTriangleMesh(); if (!vfs) vfs = new OgreVFS(resourceGroup); @@ -135,6 +134,9 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) { handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,hasCollisionNode,false,true); } + + currentShape = new btBvhTriangleMeshShape(mTriMesh,true); + cShape->Shape = currentShape; } bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node* node) @@ -247,7 +249,6 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags bool raycastingOnly) { assert(shape != NULL); - btCollisionShape* NodeShape; // Interpret flags bool hidden = (flags & 0x01) != 0; // Not displayed @@ -289,7 +290,6 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags /* Do in-place transformation.the only needed transfo is the scale. (maybe not in fact) */ - btTriangleMesh *mTriMesh = new btTriangleMesh(); Nif::NiTriShapeData *data = shape->data.getPtr(); @@ -303,8 +303,6 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags btVector3 b3(vertices[triangles[i+2]*3]*parentScale,vertices[triangles[i+2]*3+1]*parentScale,vertices[triangles[i+2]*3+2]*parentScale); mTriMesh->addTriangle(b1,b2,b3); } - NodeShape = new btBvhTriangleMeshShape(mTriMesh,true); - currentShape->addChildShape(tr,NodeShape); } void ManualBulletShapeLoader::load(const std::string &name,const std::string &group) diff --git a/components/nifbullet/bullet_nif_loader.hpp b/components/nifbullet/bullet_nif_loader.hpp index 360d9850bf..1fa2b6aa5f 100644 --- a/components/nifbullet/bullet_nif_loader.hpp +++ b/components/nifbullet/bullet_nif_loader.hpp @@ -125,7 +125,8 @@ private: std::string resourceGroup; BulletShape* cShape;//current shape - btCompoundShape* currentShape;//the shape curently under construction + btTriangleMesh *mTriMesh; + btBvhTriangleMeshShape* currentShape;//the shape curently under construction }; }