diff options
author | sfan5 <sfan5@live.de> | 2021-03-12 19:36:58 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2021-03-12 20:56:02 +0100 |
commit | 1bc85a47cb794a4a23cd8a2a1142aa20c1c1cfae (patch) | |
tree | 609207782fc1ec9fbdc2cd5ca615463140608350 /src/client | |
parent | cff35cf0b328635b2c77c024343f8e7f2d016990 (diff) | |
download | minetest-1bc85a47cb794a4a23cd8a2a1142aa20c1c1cfae.tar.gz minetest-1bc85a47cb794a4a23cd8a2a1142aa20c1c1cfae.tar.bz2 minetest-1bc85a47cb794a4a23cd8a2a1142aa20c1c1cfae.zip |
Avoid unnecessary copies during media/mesh loading
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/client.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp index 746c6c080..0486bc0a9 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -663,12 +663,15 @@ bool Client::loadMedia(const std::string &data, const std::string &filename, io::IFileSystem *irrfs = RenderingEngine::get_filesystem(); video::IVideoDriver *vdrv = RenderingEngine::get_video_driver(); +#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR > 8 + io::IReadFile *rfile = irrfs->createMemoryReadFile( + data.c_str(), data.size(), "_tempreadfile"); +#else // Silly irrlicht's const-incorrectness Buffer<char> data_rw(data.c_str(), data.size()); - - // Create an irrlicht memory file io::IReadFile *rfile = irrfs->createMemoryReadFile( *data_rw, data_rw.getSize(), "_tempreadfile"); +#endif FATAL_ERROR_IF(!rfile, "Could not create irrlicht memory file."); @@ -1914,9 +1917,14 @@ scene::IAnimatedMesh* Client::getMesh(const std::string &filename, bool cache) // Create the mesh, remove it from cache and return it // This allows unique vertex colors and other properties for each instance +#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR > 8 + io::IReadFile *rfile = RenderingEngine::get_filesystem()->createMemoryReadFile( + data.c_str(), data.size(), filename.c_str()); +#else Buffer<char> data_rw(data.c_str(), data.size()); // Const-incorrect Irrlicht - io::IReadFile *rfile = RenderingEngine::get_filesystem()->createMemoryReadFile( + io::IReadFile *rfile = RenderingEngine::get_filesystem()->createMemoryReadFile( *data_rw, data_rw.getSize(), filename.c_str()); +#endif FATAL_ERROR_IF(!rfile, "Could not create/open RAM file"); scene::IAnimatedMesh *mesh = RenderingEngine::get_scene_manager()->getMesh(rfile); |