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