Commit 00c112d5 authored by hybrid's avatar hybrid

Make geometry creator reference counted.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2299 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 6abb6f14
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef __I_GEOMETRY_CREATOR_H_INCLUDED__ #ifndef __I_GEOMETRY_CREATOR_H_INCLUDED__
#define __I_GEOMETRY_CREATOR_H_INCLUDED__ #define __I_GEOMETRY_CREATOR_H_INCLUDED__
#include "IReferenceCounted.h"
#include "IMesh.h" #include "IMesh.h"
#include "IImage.h" #include "IImage.h"
...@@ -21,7 +22,7 @@ namespace scene ...@@ -21,7 +22,7 @@ namespace scene
//! Helper class for creating geometry on the fly. //! Helper class for creating geometry on the fly.
/** You can get an instance of this class through ISceneManager::getGeometryCreator() */ /** You can get an instance of this class through ISceneManager::getGeometryCreator() */
class IGeometryCreator class IGeometryCreator : public IReferenceCounted
{ {
public: public:
......
...@@ -27,9 +27,6 @@ namespace scene ...@@ -27,9 +27,6 @@ namespace scene
class ISceneNodeFactory : public virtual IReferenceCounted class ISceneNodeFactory : public virtual IReferenceCounted
{ {
public: public:
virtual ~ISceneNodeFactory() {}
//! adds a scene node to the scene graph based on its type id //! adds a scene node to the scene graph based on its type id
/** \param type: Type of the scene node to add. /** \param type: Type of the scene node to add.
\param parent: Parent scene node of the new node, can be null to add the scene node to the root. \param parent: Parent scene node of the new node, can be null to add the scene node to the root.
......
...@@ -152,6 +152,7 @@ ...@@ -152,6 +152,7 @@
#include "CQuake3ShaderSceneNode.h" #include "CQuake3ShaderSceneNode.h"
#include "CVolumeLightSceneNode.h" #include "CVolumeLightSceneNode.h"
#include "CGeometryCreator.h"
//! Enable debug features //! Enable debug features
#define SCENEMANAGER_DEBUG #define SCENEMANAGER_DEBUG
...@@ -200,6 +201,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, ...@@ -200,6 +201,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
// create collision manager // create collision manager
CollisionManager = new CSceneCollisionManager(this, Driver); CollisionManager = new CSceneCollisionManager(this, Driver);
// create geometry creator
GeometryCreator = new CGeometryCreator();
// add file format loaders // add file format loaders
#ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_ #ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_
...@@ -268,11 +272,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, ...@@ -268,11 +272,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
ISceneNodeAnimatorFactory* animatorFactory = new CDefaultSceneNodeAnimatorFactory(this, CursorControl); ISceneNodeAnimatorFactory* animatorFactory = new CDefaultSceneNodeAnimatorFactory(this, CursorControl);
registerSceneNodeAnimatorFactory(animatorFactory); registerSceneNodeAnimatorFactory(animatorFactory);
animatorFactory->drop(); animatorFactory->drop();
} }
//! destructor //! destructor
CSceneManager::~CSceneManager() CSceneManager::~CSceneManager()
{ {
...@@ -287,6 +289,9 @@ CSceneManager::~CSceneManager() ...@@ -287,6 +289,9 @@ CSceneManager::~CSceneManager()
if (CollisionManager) if (CollisionManager)
CollisionManager->drop(); CollisionManager->drop();
if (GeometryCreator)
GeometryCreator->drop();
if (GUIEnvironment) if (GUIEnvironment)
GUIEnvironment->drop(); GUIEnvironment->drop();
...@@ -911,7 +916,7 @@ IAnimatedMesh* CSceneManager::addHillPlaneMesh(const core::string<c16>& name, ...@@ -911,7 +916,7 @@ IAnimatedMesh* CSceneManager::addHillPlaneMesh(const core::string<c16>& name,
if (MeshCache->isMeshLoaded(name)) if (MeshCache->isMeshLoaded(name))
return MeshCache->getMeshByFilename(name); return MeshCache->getMeshByFilename(name);
IMesh* mesh = GeometryCreator.createHillPlaneMesh(tileSize, IMesh* mesh = GeometryCreator->createHillPlaneMesh(tileSize,
tileCount, material, hillHeight, countHills, tileCount, material, hillHeight, countHills,
textureRepeatCount); textureRepeatCount);
if (!mesh) if (!mesh)
...@@ -945,7 +950,7 @@ IAnimatedMesh* CSceneManager::addTerrainMesh(const core::string<c16>& name, ...@@ -945,7 +950,7 @@ IAnimatedMesh* CSceneManager::addTerrainMesh(const core::string<c16>& name,
if (MeshCache->isMeshLoaded(name)) if (MeshCache->isMeshLoaded(name))
return MeshCache->getMeshByFilename(name); return MeshCache->getMeshByFilename(name);
IMesh* mesh = GeometryCreator.createTerrainMesh(texture, heightmap, IMesh* mesh = GeometryCreator->createTerrainMesh(texture, heightmap,
stretchSize, maxHeight, getVideoDriver(), stretchSize, maxHeight, getVideoDriver(),
defaultVertexBlockSize); defaultVertexBlockSize);
if (!mesh) if (!mesh)
...@@ -978,7 +983,7 @@ IAnimatedMesh* CSceneManager::addArrowMesh(const core::string<c16>& name, ...@@ -978,7 +983,7 @@ IAnimatedMesh* CSceneManager::addArrowMesh(const core::string<c16>& name,
if (MeshCache->isMeshLoaded(name)) if (MeshCache->isMeshLoaded(name))
return MeshCache->getMeshByFilename(name); return MeshCache->getMeshByFilename(name);
IMesh* mesh = GeometryCreator.createArrowMesh( tesselationCylinder, IMesh* mesh = GeometryCreator->createArrowMesh( tesselationCylinder,
tesselationCone, height, cylinderHeight, width0,width1, tesselationCone, height, cylinderHeight, width0,width1,
vtxColor0, vtxColor1); vtxColor0, vtxColor1);
if (!mesh) if (!mesh)
...@@ -1009,7 +1014,7 @@ IAnimatedMesh* CSceneManager::addSphereMesh(const core::string<c16>& name, ...@@ -1009,7 +1014,7 @@ IAnimatedMesh* CSceneManager::addSphereMesh(const core::string<c16>& name,
if (MeshCache->isMeshLoaded(name)) if (MeshCache->isMeshLoaded(name))
return MeshCache->getMeshByFilename(name); return MeshCache->getMeshByFilename(name);
IMesh* mesh = GeometryCreator.createSphereMesh(radius, polyCountX, polyCountY); IMesh* mesh = GeometryCreator->createSphereMesh(radius, polyCountX, polyCountY);
if (!mesh) if (!mesh)
return 0; return 0;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "IMeshLoader.h" #include "IMeshLoader.h"
#include "CAttributes.h" #include "CAttributes.h"
#include "ILightManager.h" #include "ILightManager.h"
#include "CGeometryCreator.h"
namespace irr namespace irr
{ {
...@@ -25,6 +24,7 @@ namespace io ...@@ -25,6 +24,7 @@ namespace io
namespace scene namespace scene
{ {
class IMeshCache; class IMeshCache;
class IGeometryCreator;
/*! /*!
The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff. The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff.
...@@ -477,7 +477,7 @@ namespace scene ...@@ -477,7 +477,7 @@ namespace scene
virtual void setLightManager(ILightManager* lightManager); virtual void setLightManager(ILightManager* lightManager);
//! Get an instance of a geometry creator. //! Get an instance of a geometry creator.
virtual const IGeometryCreator* getGeometryCreator(void) const { return &GeometryCreator; } virtual const IGeometryCreator* getGeometryCreator(void) const { return GeometryCreator; }
private: private:
...@@ -623,7 +623,7 @@ namespace scene ...@@ -623,7 +623,7 @@ namespace scene
const core::stringw IRR_XML_FORMAT_NODE; const core::stringw IRR_XML_FORMAT_NODE;
const core::stringw IRR_XML_FORMAT_NODE_ATTR_TYPE; const core::stringw IRR_XML_FORMAT_NODE_ATTR_TYPE;
CGeometryCreator GeometryCreator; IGeometryCreator* GeometryCreator;
}; };
} // end namespace video } // end namespace video
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment