Drop dependency on FileSystem from SceneManager

This commit is contained in:
numzero
2023-03-14 18:34:47 +03:00
committed by sfan5
parent 0160cdc51d
commit 52a0b9d8e5
6 changed files with 14 additions and 74 deletions

View File

@ -92,7 +92,7 @@ void CIrrDeviceStub::createGUIAndScene()
GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator);
// create Scene manager
SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl);
SceneManager = scene::createSceneManager(VideoDriver, CursorControl);
setEventReceiver(UserReceiver);
}

View File

@ -24,7 +24,7 @@ namespace irr
namespace scene
{
ISceneManager* createSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, gui::ICursorControl* cc);
ISceneManager* createSceneManager(video::IVideoDriver* driver, gui::ICursorControl* cc);
}
namespace io

View File

@ -33,9 +33,9 @@ namespace scene
{
//! constructor
CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
CSceneManager::CSceneManager(video::IVideoDriver* driver,
gui::ICursorControl* cursorControl, IMeshCache* cache)
: ISceneNode(0, 0), Driver(driver), FileSystem(fs),
: ISceneNode(0, 0), Driver(driver),
CursorControl(cursorControl),
ActiveCamera(0), ShadowColor(150,0,0,0), AmbientLight(0,0,0,0), Parameters(0),
MeshCache(cache), CurrentRenderPass(ESNRP_NONE)
@ -51,9 +51,6 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
if (Driver)
Driver->grab();
if (FileSystem)
FileSystem->grab();
if (CursorControl)
CursorControl->grab();
@ -92,9 +89,6 @@ CSceneManager::~CSceneManager()
if (Driver)
Driver->removeAllHardwareBuffers();
if (FileSystem)
FileSystem->drop();
if (CursorControl)
CursorControl->drop();
@ -125,29 +119,6 @@ CSceneManager::~CSceneManager()
}
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* CSceneManager::getMesh(const io::path& filename, const io::path& alternativeCacheName)
{
io::path cacheName = alternativeCacheName.empty() ? filename : alternativeCacheName;
IAnimatedMesh* msh = MeshCache->getMeshByName(cacheName);
if (msh)
return msh;
io::IReadFile* file = FileSystem->createAndOpenFile(filename);
if (!file)
{
os::Printer::log("Could not load mesh, because file could not be opened: ", filename, ELL_ERROR);
return 0;
}
msh = getUncachedMesh(file, filename, cacheName);
file->drop();
return msh;
}
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* CSceneManager::getMesh(io::IReadFile* file)
{
@ -202,15 +173,6 @@ video::IVideoDriver* CSceneManager::getVideoDriver()
}
//! Get the active FileSystem
/** \return Pointer to the FileSystem
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
io::IFileSystem* CSceneManager::getFileSystem()
{
return FileSystem;
}
//! adds a scene node for rendering a static mesh
//! the returned pointer must not be dropped.
IMeshSceneNode* CSceneManager::addMeshSceneNode(IMesh* mesh, ISceneNode* parent, s32 id,
@ -875,7 +837,7 @@ IMeshCache* CSceneManager::getMeshCache()
//! Creates a new scene manager.
ISceneManager* CSceneManager::createNewSceneManager(bool cloneContent)
{
CSceneManager* manager = new CSceneManager(Driver, FileSystem, CursorControl, MeshCache);
CSceneManager* manager = new CSceneManager(Driver, CursorControl, MeshCache);
if (cloneContent)
manager->cloneMembers(this, manager);
@ -912,10 +874,9 @@ IMeshWriter* CSceneManager::createMeshWriter(EMESH_WRITER_TYPE type)
// creates a scenemanager
ISceneManager* createSceneManager(video::IVideoDriver* driver,
io::IFileSystem* fs, gui::ICursorControl* cursorcontrol)
ISceneManager* createSceneManager(video::IVideoDriver* driver, gui::ICursorControl* cursorcontrol)
{
return new CSceneManager(driver, fs, cursorcontrol, nullptr);
return new CSceneManager(driver, cursorcontrol, nullptr);
}

View File

@ -31,15 +31,11 @@ namespace scene
public:
//! constructor
CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
gui::ICursorControl* cursorControl, IMeshCache* cache = nullptr);
CSceneManager(video::IVideoDriver* driver, gui::ICursorControl* cursorControl, IMeshCache* cache = 0);
//! destructor
virtual ~CSceneManager();
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* getMesh(const io::path& filename, const io::path& alternativeCacheName) override;
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* getMesh(io::IReadFile* file) override;
@ -49,9 +45,6 @@ namespace scene
//! returns the video driver
video::IVideoDriver* getVideoDriver() override;
//! return the filesystem
io::IFileSystem* getFileSystem() override;
//! adds a scene node for rendering an animated mesh model
virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1,
const core::vector3df& position = core::vector3df(0,0,0),
@ -278,9 +271,6 @@ namespace scene
//! video driver
video::IVideoDriver* Driver;
//! file system
io::IFileSystem* FileSystem;
//! cursor control
gui::ICursorControl* CursorControl;