mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 18:09:40 +00:00
OEngine doesn't rely on OpenMW anymore
This commit is contained in:
parent
98b27813b7
commit
9d4cda6510
2 changed files with 2 additions and 227 deletions
|
@ -50,117 +50,6 @@ using namespace Nif;
|
|||
using namespace Mangle::VFS;
|
||||
|
||||
|
||||
BulletShape::BulletShape(Ogre::ResourceManager* creator, const Ogre::String &name,
|
||||
Ogre::ResourceHandle handle, const Ogre::String &group, bool isManual,
|
||||
Ogre::ManualResourceLoader *loader) :
|
||||
Ogre::Resource(creator, name, handle, group, isManual, loader)
|
||||
{
|
||||
/* If you were storing a pointer to an object, then you would set that pointer to NULL here.
|
||||
*/
|
||||
|
||||
/* For consistency with StringInterface, but we don't add any parameters here
|
||||
That's because the Resource implementation of StringInterface is to
|
||||
list all the options that need to be set before loading, of which
|
||||
we have none as such. Full details can be set through scripts.
|
||||
*/
|
||||
Shape = NULL;
|
||||
collide = true;
|
||||
createParamDictionary("BulletShape");
|
||||
}
|
||||
|
||||
BulletShape::~BulletShape()
|
||||
{
|
||||
}
|
||||
|
||||
// farm out to BulletShapeLoader
|
||||
void BulletShape::loadImpl()
|
||||
{
|
||||
mLoader->loadResource(this);
|
||||
}
|
||||
|
||||
void BulletShape::deleteShape(btCollisionShape* mShape)
|
||||
{
|
||||
if(mShape!=NULL)
|
||||
{
|
||||
if(mShape->isCompound())
|
||||
{
|
||||
btCompoundShape* ms = static_cast<btCompoundShape*>(Shape);
|
||||
int a = ms->getNumChildShapes();
|
||||
for(int i=0; i <a;i++)
|
||||
{
|
||||
deleteShape(ms->getChildShape(i));
|
||||
}
|
||||
}
|
||||
delete mShape;
|
||||
}
|
||||
mShape = NULL;
|
||||
}
|
||||
|
||||
void BulletShape::unloadImpl()
|
||||
{
|
||||
deleteShape(Shape);
|
||||
}
|
||||
|
||||
//TODO:change this?
|
||||
size_t BulletShape::calculateSize() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================================================
|
||||
template<> BulletShapeManager *Ogre::Singleton<BulletShapeManager>::ms_Singleton = 0;
|
||||
|
||||
BulletShapeManager *BulletShapeManager::getSingletonPtr()
|
||||
{
|
||||
return ms_Singleton;
|
||||
}
|
||||
|
||||
BulletShapeManager &BulletShapeManager::getSingleton()
|
||||
{
|
||||
assert(ms_Singleton);
|
||||
return(*ms_Singleton);
|
||||
}
|
||||
|
||||
BulletShapeManager::BulletShapeManager()
|
||||
{
|
||||
mResourceType = "BulletShape";
|
||||
|
||||
// low, because it will likely reference other resources
|
||||
mLoadOrder = 30.0f;
|
||||
|
||||
// this is how we register the ResourceManager with OGRE
|
||||
Ogre::ResourceGroupManager::getSingleton()._registerResourceManager(mResourceType, this);
|
||||
}
|
||||
|
||||
BulletShapeManager::~BulletShapeManager()
|
||||
{
|
||||
// and this is how we unregister it
|
||||
Ogre::ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType);
|
||||
}
|
||||
|
||||
BulletShapePtr BulletShapeManager::load(const Ogre::String &name, const Ogre::String &group)
|
||||
{
|
||||
BulletShapePtr textf = getByName(name);
|
||||
|
||||
if (textf.isNull())
|
||||
textf = create(name, group);
|
||||
|
||||
textf->load();
|
||||
return textf;
|
||||
}
|
||||
|
||||
Ogre::Resource *BulletShapeManager::createImpl(const Ogre::String &name, Ogre::ResourceHandle handle,
|
||||
const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader,
|
||||
const Ogre::NameValuePairList *createParams)
|
||||
{
|
||||
BulletShape* res = new BulletShape(this, name, handle, group, isManual, loader);
|
||||
//if(isManual)
|
||||
//{
|
||||
//loader->loadResource(res);
|
||||
//}
|
||||
return res;
|
||||
}
|
||||
|
||||
//====================================================================================================
|
||||
Ogre::Matrix3 ManualBulletShapeLoader::getMatrix(Nif::Transformation* tr)
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#ifndef _BULLET_NIF_LOADER_H_
|
||||
#define _BULLET_NIF_LOADER_H_
|
||||
|
||||
#include <OgreResource.h>
|
||||
#include <OgreResourceManager.h>
|
||||
#include <OgreMesh.h>
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
|
@ -33,7 +31,7 @@
|
|||
#include <BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h>
|
||||
#include <btBulletDynamicsCommon.h>
|
||||
#include <btBulletCollisionCommon.h>
|
||||
|
||||
#include "openengine/bullet/BulletShapeLoader.h"
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
@ -61,122 +59,10 @@ namespace Mangle
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*Define a new resource which describe a Shape usable by bullet.See BulletShapeManager for how to get/use them.
|
||||
*/
|
||||
class BulletShape : public Ogre::Resource
|
||||
{
|
||||
Ogre::String mString;
|
||||
|
||||
protected:
|
||||
void loadImpl();
|
||||
void unloadImpl();
|
||||
size_t calculateSize() const;
|
||||
|
||||
void deleteShape(btCollisionShape* mShape);
|
||||
|
||||
public:
|
||||
|
||||
BulletShape(Ogre::ResourceManager *creator, const Ogre::String &name,
|
||||
Ogre::ResourceHandle handle, const Ogre::String &group, bool isManual = false,
|
||||
Ogre::ManualResourceLoader *loader = 0);
|
||||
|
||||
virtual ~BulletShape();
|
||||
|
||||
btCollisionShape* Shape;
|
||||
//this flag indicate if the shape is used for collision or if it's for raycasting only.
|
||||
bool collide;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class BulletShapePtr : public Ogre::SharedPtr<BulletShape>
|
||||
{
|
||||
public:
|
||||
BulletShapePtr() : Ogre::SharedPtr<BulletShape>() {}
|
||||
explicit BulletShapePtr(BulletShape *rep) : Ogre::SharedPtr<BulletShape>(rep) {}
|
||||
BulletShapePtr(const BulletShapePtr &r) : Ogre::SharedPtr<BulletShape>(r) {}
|
||||
BulletShapePtr(const Ogre::ResourcePtr &r) : Ogre::SharedPtr<BulletShape>()
|
||||
{
|
||||
if( r.isNull() )
|
||||
return;
|
||||
// lock & copy other mutex pointer
|
||||
OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
|
||||
OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
|
||||
pRep = static_cast<BulletShape*>(r.getPointer());
|
||||
pUseCount = r.useCountPointer();
|
||||
useFreeMethod = r.freeMethod();
|
||||
if (pUseCount)
|
||||
{
|
||||
++(*pUseCount);
|
||||
}
|
||||
}
|
||||
|
||||
/// Operator used to convert a ResourcePtr to a BulletShapePtr
|
||||
BulletShapePtr& operator=(const Ogre::ResourcePtr& r)
|
||||
{
|
||||
if(pRep == static_cast<BulletShape*>(r.getPointer()))
|
||||
return *this;
|
||||
release();
|
||||
if( r.isNull() )
|
||||
return *this; // resource ptr is null, so the call to release above has done all we need to do.
|
||||
// lock & copy other mutex pointer
|
||||
OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
|
||||
OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
|
||||
pRep = static_cast<BulletShape*>(r.getPointer());
|
||||
pUseCount = r.useCountPointer();
|
||||
useFreeMethod = r.freeMethod();
|
||||
if (pUseCount)
|
||||
{
|
||||
++(*pUseCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*Hold any BulletShape that was created by the ManualBulletShapeLoader.
|
||||
*
|
||||
*To get a bulletShape, you must load it first.
|
||||
*First, create a manualBulletShapeLoader. Then call ManualBulletShapeManager->load(). This create an "empty" resource.
|
||||
*Then use BulletShapeManager->load(). This will fill the resource with the required info.
|
||||
*To get the resource,use BulletShapeManager::getByName.
|
||||
*When you use the resource no more, just use BulletShapeManager->unload(). It won't completly delete the resource, but it will
|
||||
*"empty" it.This allow a better management of memory: when you are leaving a cell, just unload every useless shape.
|
||||
*
|
||||
*Alternatively, you can call BulletShape->load() in order to actually load the resource.
|
||||
*When you are finished with it, just call BulletShape->unload().
|
||||
*
|
||||
*IMO: prefere the first methode, i am not completly sure about the 2nd.
|
||||
*
|
||||
*Important Note: i have no idea of what happen if you try to load two time the same resource without unloading.
|
||||
*It won't crash, but it might lead to memory leaks(I don't know how Ogre handle this). So don't do it!
|
||||
*/
|
||||
class BulletShapeManager : public Ogre::ResourceManager, public Ogre::Singleton<BulletShapeManager>
|
||||
{
|
||||
protected:
|
||||
|
||||
// must implement this from ResourceManager's interface
|
||||
Ogre::Resource *createImpl(const Ogre::String &name, Ogre::ResourceHandle handle,
|
||||
const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader,
|
||||
const Ogre::NameValuePairList *createParams);
|
||||
|
||||
public:
|
||||
|
||||
BulletShapeManager();
|
||||
virtual ~BulletShapeManager();
|
||||
|
||||
virtual BulletShapePtr load(const Ogre::String &name, const Ogre::String &group);
|
||||
|
||||
static BulletShapeManager &getSingleton();
|
||||
static BulletShapeManager *getSingletonPtr();
|
||||
};
|
||||
|
||||
/**
|
||||
*Load bulletShape from NIF files.
|
||||
*/
|
||||
class ManualBulletShapeLoader : public Ogre::ManualResourceLoader
|
||||
class ManualBulletShapeLoader : public BulletShapeLoader
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
Loading…
Reference in a new issue