diff --git a/irr/include/CMeshBuffer.h b/irr/include/CMeshBuffer.h index 8f8158ff1..0b0c3bb92 100644 --- a/irr/include/CMeshBuffer.h +++ b/irr/include/CMeshBuffer.h @@ -4,7 +4,7 @@ #pragma once -#include "irrArray.h" +#include #include "IMeshBuffer.h" namespace irr @@ -43,21 +43,21 @@ public: /** \return Pointer to vertices. */ const void *getVertices() const override { - return Vertices.const_pointer(); + return Vertices.data(); } //! Get pointer to vertices /** \return Pointer to vertices. */ void *getVertices() override { - return Vertices.pointer(); + return Vertices.data(); } //! Get number of vertices /** \return Number of vertices. */ u32 getVertexCount() const override { - return Vertices.size(); + return static_cast(Vertices.size()); } //! Get type of index data which is stored in this meshbuffer. @@ -71,21 +71,21 @@ public: /** \return Pointer to indices. */ const u16 *getIndices() const override { - return Indices.const_pointer(); + return Indices.data(); } //! Get pointer to indices /** \return Pointer to indices. */ u16 *getIndices() override { - return Indices.pointer(); + return Indices.data(); } //! Get number of indices /** \return Number of indices. */ u32 getIndexCount() const override { - return Indices.size(); + return static_cast(Indices.size()); } //! Get the axis aligned bounding box @@ -160,27 +160,23 @@ public: } //! Append the vertices and indices to the current buffer - /** Only works for compatible types, i.e. either the same type - or the main buffer is of standard type. Otherwise, behavior is - undefined. - */ void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override { if (vertices == getVertices()) return; const u32 vertexCount = getVertexCount(); - u32 i; + const u32 indexCount = getIndexCount(); - Vertices.reallocate(vertexCount + numVertices); - for (i = 0; i < numVertices; ++i) { - Vertices.push_back(static_cast(vertices)[i]); - BoundingBox.addInternalPoint(static_cast(vertices)[i].Pos); - } + auto *vt = static_cast(vertices); + Vertices.insert(Vertices.end(), vt, vt + numVertices); + for (u32 i = vertexCount; i < getVertexCount(); i++) + BoundingBox.addInternalPoint(Vertices[i].Pos); - Indices.reallocate(getIndexCount() + numIndices); - for (i = 0; i < numIndices; ++i) { - Indices.push_back(indices[i] + vertexCount); + Indices.insert(Indices.end(), indices, indices + numIndices); + if (vertexCount != 0) { + for (u32 i = indexCount; i < getIndexCount(); i++) + Indices[i] += vertexCount; } } @@ -255,9 +251,9 @@ public: //! Material for this meshbuffer. video::SMaterial Material; //! Vertices of this buffer - core::array Vertices; + std::vector Vertices; //! Indices into the vertices of this buffer. - core::array Indices; + std::vector Indices; //! Bounding box of this meshbuffer. core::aabbox3d BoundingBox; //! Primitive type used for rendering (triangles, lines, ...) diff --git a/irr/include/IAttributes.h b/irr/include/IAttributes.h index 906d334a2..4606c5710 100644 --- a/irr/include/IAttributes.h +++ b/irr/include/IAttributes.h @@ -23,27 +23,13 @@ namespace io class IAttributes : public virtual IReferenceCounted { public: - //! Returns amount of attributes in this collection of attributes. - virtual u32 getAttributeCount() const = 0; - - //! Returns attribute name by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const c8 *getAttributeName(s32 index) const = 0; - //! Returns the type of an attribute //! \param attributeName: Name for the attribute virtual E_ATTRIBUTE_TYPE getAttributeType(const c8 *attributeName) const = 0; - //! Returns attribute type by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index) const = 0; - //! Returns if an attribute with a name exists virtual bool existsAttribute(const c8 *attributeName) const = 0; - //! Returns attribute index from name, -1 if not found - virtual s32 findAttribute(const c8 *attributeName) const = 0; - //! Removes all attributes virtual void clear() = 0; @@ -65,13 +51,6 @@ public: //! \return Returns value of the attribute previously set by setAttribute() virtual s32 getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound = 0) const = 0; - //! Gets an attribute as integer value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual s32 getAttributeAsInt(s32 index) const = 0; - - //! Sets an attribute as integer value - virtual void setAttribute(s32 index, s32 value) = 0; - /* Float Attribute @@ -90,13 +69,6 @@ public: //! \return Returns value of the attribute previously set by setAttribute() virtual f32 getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound = 0.f) const = 0; - //! Gets an attribute as float value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual f32 getAttributeAsFloat(s32 index) const = 0; - - //! Sets an attribute as float value - virtual void setAttribute(s32 index, f32 value) = 0; - /* Bool Attribute */ @@ -112,13 +84,6 @@ public: //! \param defaultNotFound Value returned when attributeName was not found //! \return Returns value of the attribute previously set by setAttribute() virtual bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound = false) const = 0; - - //! Gets an attribute as boolean value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual bool getAttributeAsBool(s32 index) const = 0; - - //! Sets an attribute as boolean value - virtual void setAttribute(s32 index, bool value) = 0; }; } // end namespace io diff --git a/irr/include/IFileSystem.h b/irr/include/IFileSystem.h index 1fe9fe6f2..f144bbaee 100644 --- a/irr/include/IFileSystem.h +++ b/irr/include/IFileSystem.h @@ -85,113 +85,6 @@ public: See IReferenceCounted::drop() for more information. */ virtual IWriteFile *createAndWriteFile(const path &filename, bool append = false) = 0; - //! Adds an archive to the file system. - /** After calling this, the Irrlicht Engine will also search and open - files directly from this archive. This is useful for hiding data from - the end user, speeding up file access and making it possible to access - for example Quake3 .pk3 files, which are just renamed .zip files. By - default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as - archives. You can provide your own archive types by implementing - IArchiveLoader and passing an instance to addArchiveLoader. - Irrlicht supports AES-encrypted zip files, and the advanced compression - techniques lzma and bzip2. - \param filename: Filename of the archive to add to the file system. - \param ignoreCase: If set to true, files in the archive can be accessed without - writing all letters in the right case. - \param ignorePaths: If set to true, files in the added archive can be accessed - without its complete path. - \param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then - the type of archive will depend on the extension of the file name. If - you use a different extension then you can use this parameter to force - a specific type of archive. - \param password An optional password, which is used in case of encrypted archives. - \param retArchive A pointer that will be set to the archive that is added. - \return True if the archive was added successfully, false if not. */ - virtual bool addFileArchive(const path &filename, bool ignoreCase = true, - bool ignorePaths = true, - E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN, - const core::stringc &password = "", - IFileArchive **retArchive = 0) = 0; - - //! Adds an archive to the file system. - /** After calling this, the Irrlicht Engine will also search and open - files directly from this archive. This is useful for hiding data from - the end user, speeding up file access and making it possible to access - for example Quake3 .pk3 files, which are just renamed .zip files. By - default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as - archives. You can provide your own archive types by implementing - IArchiveLoader and passing an instance to addArchiveLoader. - Irrlicht supports AES-encrypted zip files, and the advanced compression - techniques lzma and bzip2. - If you want to add a directory as an archive, prefix its name with a - slash in order to let Irrlicht recognize it as a folder mount (mypath/). - Using this technique one can build up a search order, because archives - are read first, and can be used more easily with relative filenames. - \param file: Archive to add to the file system. - \param ignoreCase: If set to true, files in the archive can be accessed without - writing all letters in the right case. - \param ignorePaths: If set to true, files in the added archive can be accessed - without its complete path. - \param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then - the type of archive will depend on the extension of the file name. If - you use a different extension then you can use this parameter to force - a specific type of archive. - \param password An optional password, which is used in case of encrypted archives. - \param retArchive A pointer that will be set to the archive that is added. - \return True if the archive was added successfully, false if not. */ - virtual bool addFileArchive(IReadFile *file, bool ignoreCase = true, - bool ignorePaths = true, - E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN, - const core::stringc &password = "", - IFileArchive **retArchive = 0) = 0; - - //! Adds an archive to the file system. - /** \param archive: The archive to add to the file system. - \return True if the archive was added successfully, false if not. */ - virtual bool addFileArchive(IFileArchive *archive) = 0; - - //! Get the number of archives currently attached to the file system - virtual u32 getFileArchiveCount() const = 0; - - //! Removes an archive from the file system. - /** This will close the archive and free any file handles, but will not - close resources which have already been loaded and are now cached, for - example textures and meshes. - \param index: The index of the archive to remove - \return True on success, false on failure */ - virtual bool removeFileArchive(u32 index) = 0; - - //! Removes an archive from the file system. - /** This will close the archive and free any file handles, but will not - close resources which have already been loaded and are now cached, for - example textures and meshes. Note that a relative filename might be - interpreted differently on each call, depending on the current working - directory. In case you want to remove an archive that was added using - a relative path name, you have to change to the same working directory - again. This means, that the filename given on creation is not an - identifier for the archive, but just a usual filename that is used for - locating the archive to work with. - \param filename The archive pointed to by the name will be removed - \return True on success, false on failure */ - virtual bool removeFileArchive(const path &filename) = 0; - - //! Removes an archive from the file system. - /** This will close the archive and free any file handles, but will not - close resources which have already been loaded and are now cached, for - example textures and meshes. - \param archive The archive to remove. - \return True on success, false on failure */ - virtual bool removeFileArchive(const IFileArchive *archive) = 0; - - //! Changes the search order of attached archives. - /** - \param sourceIndex: The index of the archive to change - \param relative: The relative change in position, archives with a lower index are searched first */ - virtual bool moveFileArchive(u32 sourceIndex, s32 relative) = 0; - - //! Get the archive at a given index. - virtual IFileArchive *getFileArchive(u32 index) = 0; - //! Adds an external archive loader to the engine. /** Use this function to add support for new archive types to the engine, for example proprietary or encrypted file storage. */ diff --git a/irr/include/ISceneNode.h b/irr/include/ISceneNode.h index 7a03a2256..1eab3a3fd 100644 --- a/irr/include/ISceneNode.h +++ b/irr/include/ISceneNode.h @@ -10,6 +10,7 @@ #include "EDebugSceneTypes.h" #include "SMaterial.h" #include "irrString.h" +#include "irrArray.h" #include "aabbox3d.h" #include "matrix4.h" #include "IAttributes.h" diff --git a/irr/include/IVideoDriver.h b/irr/include/IVideoDriver.h index 2d651c6bf..888e4a9f7 100644 --- a/irr/include/IVideoDriver.h +++ b/irr/include/IVideoDriver.h @@ -182,7 +182,6 @@ public: MaxSupportedTextures (int) The maximum number of simultaneous textures supported by the fixed function pipeline of the (hw) driver. The actual supported number of textures supported by the engine can be lower. MaxLights (int) Number of hardware lights supported in the fixed function pipeline of the driver, typically 6-8. Use light manager or deferred shading for more. MaxAnisotropy (int) Number of anisotropy levels supported for filtering. At least 1, max is typically at 16 or 32. - MaxUserClipPlanes (int) Number of additional clip planes, which can be set by the user via dedicated driver methods. MaxAuxBuffers (int) Special render buffers, which are currently not really usable inside Irrlicht. Only supported by OpenGL MaxMultipleRenderTargets (int) Number of render targets which can be bound simultaneously. Rendering to MRTs is done via shaders. MaxIndices (int) Number of indices which can be used in one render call (i.e. one mesh buffer). @@ -1109,26 +1108,6 @@ public: \return Pointer to loaded texture, or 0 if not found. */ virtual video::ITexture *findTexture(const io::path &filename) = 0; - //! Set or unset a clipping plane. - /** There are at least 6 clipping planes available for the user - to set at will. - \param index The plane index. Must be between 0 and - MaxUserClipPlanes. - \param plane The plane itself. - \param enable If true, enable the clipping plane else disable - it. - \return True if the clipping plane is usable. */ - virtual bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) = 0; - - //! Enable or disable a clipping plane. - /** There are at least 6 clipping planes available for the user - to set at will. - \param index The plane index. Must be between 0 and - MaxUserClipPlanes. - \param enable If true, enable the clipping plane else disable - it. */ - virtual void enableClipPlane(u32 index, bool enable) = 0; - //! Set the minimum number of vertices for which a hw buffer will be created /** \param count Number of vertices to set as minimum. */ virtual void setMinHardwareBufferVertexCount(u32 count) = 0; diff --git a/irr/include/SAnimatedMesh.h b/irr/include/SAnimatedMesh.h index 8fdaae0ee..42ba6b952 100644 --- a/irr/include/SAnimatedMesh.h +++ b/irr/include/SAnimatedMesh.h @@ -4,10 +4,10 @@ #pragma once +#include #include "IAnimatedMesh.h" #include "IMesh.h" #include "aabbox3d.h" -#include "irrArray.h" namespace irr { @@ -32,15 +32,15 @@ struct SAnimatedMesh : public IAnimatedMesh virtual ~SAnimatedMesh() { // drop meshes - for (u32 i = 0; i < Meshes.size(); ++i) - Meshes[i]->drop(); + for (auto *mesh : Meshes) + mesh->drop(); } //! Gets the frame count of the animated mesh. /** \return Amount of frames. If the amount is 1, it is a static, non animated mesh. */ u32 getFrameCount() const override { - return Meshes.size(); + return static_cast(Meshes.size()); } //! Gets the default animation speed of the animated mesh. @@ -161,7 +161,7 @@ struct SAnimatedMesh : public IAnimatedMesh } //! All meshes defining the animated mesh - core::array Meshes; + std::vector Meshes; //! The bounding box of this mesh core::aabbox3d Box; diff --git a/irr/include/SMaterial.h b/irr/include/SMaterial.h index c803f5fde..8f24b9984 100644 --- a/irr/include/SMaterial.h +++ b/irr/include/SMaterial.h @@ -6,7 +6,6 @@ #include "SColor.h" #include "matrix4.h" -#include "irrArray.h" #include "irrMath.h" #include "EMaterialTypes.h" #include "EMaterialProps.h" diff --git a/irr/include/SMesh.h b/irr/include/SMesh.h index e865a5d2d..a391255a1 100644 --- a/irr/include/SMesh.h +++ b/irr/include/SMesh.h @@ -4,10 +4,10 @@ #pragma once +#include #include "IMesh.h" #include "IMeshBuffer.h" #include "aabbox3d.h" -#include "irrArray.h" namespace irr { @@ -28,15 +28,15 @@ struct SMesh : public IMesh virtual ~SMesh() { // drop buffers - for (u32 i = 0; i < MeshBuffers.size(); ++i) - MeshBuffers[i]->drop(); + for (auto *buf : MeshBuffers) + buf->drop(); } //! clean mesh virtual void clear() { - for (u32 i = 0; i < MeshBuffers.size(); ++i) - MeshBuffers[i]->drop(); + for (auto *buf : MeshBuffers) + buf->drop(); MeshBuffers.clear(); BoundingBox.reset(0.f, 0.f, 0.f); } @@ -44,7 +44,7 @@ struct SMesh : public IMesh //! returns amount of mesh buffers. u32 getMeshBufferCount() const override { - return MeshBuffers.size(); + return static_cast(MeshBuffers.size()); } //! returns pointer to a mesh buffer @@ -57,12 +57,11 @@ struct SMesh : public IMesh /** reverse search */ IMeshBuffer *getMeshBuffer(const video::SMaterial &material) const override { - for (s32 i = (s32)MeshBuffers.size() - 1; i >= 0; --i) { - if (material == MeshBuffers[i]->getMaterial()) - return MeshBuffers[i]; + for (auto it = MeshBuffers.rbegin(); it != MeshBuffers.rend(); it++) { + if (material == (*it)->getMaterial()) + return *it; } - - return 0; + return nullptr; } //! returns an axis aligned bounding box @@ -81,8 +80,8 @@ struct SMesh : public IMesh void recalculateBoundingBox() { bool hasMeshBufferBBox = false; - for (u32 i = 0; i < MeshBuffers.size(); ++i) { - const core::aabbox3df &bb = MeshBuffers[i]->getBoundingBox(); + for (auto *buf : MeshBuffers) { + const core::aabbox3df &bb = buf->getBoundingBox(); if (!bb.isEmpty()) { if (!hasMeshBufferBBox) { hasMeshBufferBBox = true; @@ -110,19 +109,19 @@ struct SMesh : public IMesh //! set the hardware mapping hint, for driver void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) override { - for (u32 i = 0; i < MeshBuffers.size(); ++i) - MeshBuffers[i]->setHardwareMappingHint(newMappingHint, buffer); + for (auto *buf : MeshBuffers) + buf->setHardwareMappingHint(newMappingHint, buffer); } //! flags the meshbuffer as changed, reloads hardware buffers void setDirty(E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) override { - for (u32 i = 0; i < MeshBuffers.size(); ++i) - MeshBuffers[i]->setDirty(buffer); + for (auto *buf : MeshBuffers) + buf->setDirty(buffer); } //! The meshbuffers of this mesh - core::array MeshBuffers; + std::vector MeshBuffers; //! The bounding box of this mesh core::aabbox3d BoundingBox; diff --git a/irr/include/SOverrideMaterial.h b/irr/include/SOverrideMaterial.h index 6de6e6ebb..c52a55b55 100644 --- a/irr/include/SOverrideMaterial.h +++ b/irr/include/SOverrideMaterial.h @@ -4,6 +4,7 @@ #pragma once +#include #include "SMaterial.h" namespace irr @@ -57,7 +58,7 @@ struct SOverrideMaterial }; //! To overwrite SMaterial::MaterialType - core::array MaterialTypes; + std::vector MaterialTypes; //! Default constructor SOverrideMaterial() : @@ -83,9 +84,8 @@ struct SOverrideMaterial void apply(SMaterial &material) { if (Enabled) { - for (u32 i = 0; i < MaterialTypes.size(); ++i) { - const SMaterialTypeReplacement &mtr = MaterialTypes[i]; - if (mtr.Original < 0 || (s32)mtr.Original == material.MaterialType) + for (const auto &mtr : MaterialTypes) { + if (mtr.Original < 0 || mtr.Original == (s32)material.MaterialType) material.MaterialType = (E_MATERIAL_TYPE)mtr.Replacement; } for (u32 f = 0; f < 32; ++f) { diff --git a/irr/include/SSkinMeshBuffer.h b/irr/include/SSkinMeshBuffer.h index 5ced6057d..fe9d78321 100644 --- a/irr/include/SSkinMeshBuffer.h +++ b/irr/include/SSkinMeshBuffer.h @@ -18,9 +18,8 @@ struct SSkinMeshBuffer : public IMeshBuffer //! Default constructor SSkinMeshBuffer(video::E_VERTEX_TYPE vt = video::EVT_STANDARD) : ChangedID_Vertex(1), ChangedID_Index(1), VertexType(vt), - PrimitiveType(EPT_TRIANGLES), + PrimitiveType(EPT_TRIANGLES), HWBuffer(nullptr), MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER), - HWBuffer(NULL), BoundingBoxNeedsRecalculated(true) { #ifdef _DEBUG @@ -58,11 +57,11 @@ struct SSkinMeshBuffer : public IMeshBuffer { switch (VertexType) { case video::EVT_2TCOORDS: - return Vertices_2TCoords.const_pointer(); + return Vertices_2TCoords.data(); case video::EVT_TANGENTS: - return Vertices_Tangents.const_pointer(); + return Vertices_Tangents.data(); default: - return Vertices_Standard.const_pointer(); + return Vertices_Standard.data(); } } @@ -71,11 +70,11 @@ struct SSkinMeshBuffer : public IMeshBuffer { switch (VertexType) { case video::EVT_2TCOORDS: - return Vertices_2TCoords.pointer(); + return Vertices_2TCoords.data(); case video::EVT_TANGENTS: - return Vertices_Tangents.pointer(); + return Vertices_Tangents.data(); default: - return Vertices_Standard.pointer(); + return Vertices_Standard.data(); } } @@ -84,11 +83,11 @@ struct SSkinMeshBuffer : public IMeshBuffer { switch (VertexType) { case video::EVT_2TCOORDS: - return Vertices_2TCoords.size(); + return static_cast(Vertices_2TCoords.size()); case video::EVT_TANGENTS: - return Vertices_Tangents.size(); + return static_cast(Vertices_Tangents.size()); default: - return Vertices_Standard.size(); + return static_cast(Vertices_Standard.size()); } } @@ -102,19 +101,19 @@ struct SSkinMeshBuffer : public IMeshBuffer //! Get pointer to index array const u16 *getIndices() const override { - return Indices.const_pointer(); + return Indices.data(); } //! Get pointer to index array u16 *getIndices() override { - return Indices.pointer(); + return Indices.data(); } //! Get index count u32 getIndexCount() const override { - return Indices.size(); + return static_cast(Indices.size()); } //! Get bounding box @@ -143,7 +142,7 @@ struct SSkinMeshBuffer : public IMeshBuffer BoundingBox.reset(0, 0, 0); else { BoundingBox.reset(Vertices_Standard[0].Pos); - for (u32 i = 1; i < Vertices_Standard.size(); ++i) + for (size_t i = 1; i < Vertices_Standard.size(); ++i) BoundingBox.addInternalPoint(Vertices_Standard[i].Pos); } break; @@ -153,7 +152,7 @@ struct SSkinMeshBuffer : public IMeshBuffer BoundingBox.reset(0, 0, 0); else { BoundingBox.reset(Vertices_2TCoords[0].Pos); - for (u32 i = 1; i < Vertices_2TCoords.size(); ++i) + for (size_t i = 1; i < Vertices_2TCoords.size(); ++i) BoundingBox.addInternalPoint(Vertices_2TCoords[i].Pos); } break; @@ -163,7 +162,7 @@ struct SSkinMeshBuffer : public IMeshBuffer BoundingBox.reset(0, 0, 0); else { BoundingBox.reset(Vertices_Tangents[0].Pos); - for (u32 i = 1; i < Vertices_Tangents.size(); ++i) + for (size_t i = 1; i < Vertices_Tangents.size(); ++i) BoundingBox.addInternalPoint(Vertices_Tangents[i].Pos); } break; @@ -181,12 +180,12 @@ struct SSkinMeshBuffer : public IMeshBuffer void convertTo2TCoords() { if (VertexType == video::EVT_STANDARD) { - for (u32 n = 0; n < Vertices_Standard.size(); ++n) { + for (const auto &Vertex_Standard : Vertices_Standard) { video::S3DVertex2TCoords Vertex; - Vertex.Color = Vertices_Standard[n].Color; - Vertex.Pos = Vertices_Standard[n].Pos; - Vertex.Normal = Vertices_Standard[n].Normal; - Vertex.TCoords = Vertices_Standard[n].TCoords; + Vertex.Color = Vertex_Standard.Color; + Vertex.Pos = Vertex_Standard.Pos; + Vertex.Normal = Vertex_Standard.Normal; + Vertex.TCoords = Vertex_Standard.TCoords; Vertices_2TCoords.push_back(Vertex); } Vertices_Standard.clear(); @@ -198,23 +197,23 @@ struct SSkinMeshBuffer : public IMeshBuffer void convertToTangents() { if (VertexType == video::EVT_STANDARD) { - for (u32 n = 0; n < Vertices_Standard.size(); ++n) { + for (const auto &Vertex_Standard : Vertices_Standard) { video::S3DVertexTangents Vertex; - Vertex.Color = Vertices_Standard[n].Color; - Vertex.Pos = Vertices_Standard[n].Pos; - Vertex.Normal = Vertices_Standard[n].Normal; - Vertex.TCoords = Vertices_Standard[n].TCoords; + Vertex.Color = Vertex_Standard.Color; + Vertex.Pos = Vertex_Standard.Pos; + Vertex.Normal = Vertex_Standard.Normal; + Vertex.TCoords = Vertex_Standard.TCoords; Vertices_Tangents.push_back(Vertex); } Vertices_Standard.clear(); VertexType = video::EVT_TANGENTS; } else if (VertexType == video::EVT_2TCOORDS) { - for (u32 n = 0; n < Vertices_2TCoords.size(); ++n) { + for (const auto &Vertex_2TCoords : Vertices_2TCoords) { video::S3DVertexTangents Vertex; - Vertex.Color = Vertices_2TCoords[n].Color; - Vertex.Pos = Vertices_2TCoords[n].Pos; - Vertex.Normal = Vertices_2TCoords[n].Normal; - Vertex.TCoords = Vertices_2TCoords[n].TCoords; + Vertex.Color = Vertex_2TCoords.Color; + Vertex.Pos = Vertex_2TCoords.Pos; + Vertex.Normal = Vertex_2TCoords.Normal; + Vertex.TCoords = Vertex_2TCoords.TCoords; Vertices_Tangents.push_back(Vertex); } Vertices_2TCoords.clear(); @@ -301,7 +300,10 @@ struct SSkinMeshBuffer : public IMeshBuffer } //! append the vertices and indices to the current buffer - void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override {} + void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override + { + _IRR_DEBUG_BREAK_IF(true); + } //! get the current hardware mapping hint for vertex buffers E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const override @@ -366,10 +368,10 @@ struct SSkinMeshBuffer : public IMeshBuffer //! Call this after changing the positions of any vertex. void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; } - core::array Vertices_Tangents; - core::array Vertices_2TCoords; - core::array Vertices_Standard; - core::array Indices; + std::vector Vertices_Tangents; + std::vector Vertices_2TCoords; + std::vector Vertices_Standard; + std::vector Indices; u32 ChangedID_Vertex; u32 ChangedID_Index; @@ -385,12 +387,12 @@ struct SSkinMeshBuffer : public IMeshBuffer //! Primitive type used for rendering (triangles, lines, ...) E_PRIMITIVE_TYPE PrimitiveType; + mutable void *HWBuffer; + // hardware mapping hint E_HARDWARE_MAPPING MappingHint_Vertex : 3; E_HARDWARE_MAPPING MappingHint_Index : 3; - mutable void *HWBuffer; - bool BoundingBoxNeedsRecalculated : 1; }; diff --git a/irr/include/irrArray.h b/irr/include/irrArray.h index b6f573a79..66978048f 100644 --- a/irr/include/irrArray.h +++ b/irr/include/irrArray.h @@ -167,13 +167,6 @@ public: return *this; } - array &operator=(std::vector &&other) - { - m_data = std::move(other); - is_sorted = false; - return *this; - } - //! Equality operator bool operator==(const array &other) const { @@ -400,16 +393,6 @@ public: std::swap(is_sorted, other.is_sorted); } - //! Pull the contents of this array as a vector. - // The array is left empty. - std::vector steal() - { - std::vector ret = std::move(m_data); - m_data.clear(); - is_sorted = true; - return ret; - } - typedef T value_type; typedef u32 size_type; diff --git a/irr/src/CAttributeImpl.h b/irr/src/CAttributeImpl.h index 9065a7342..e9436a407 100644 --- a/irr/src/CAttributeImpl.h +++ b/irr/src/CAttributeImpl.h @@ -3,9 +3,6 @@ // For conditions of distribution and use, see copyright notice in irrlicht.h #include "CAttributes.h" -#include "fast_atof.h" -#include "ITexture.h" -#include "IVideoDriver.h" namespace irr { diff --git a/irr/src/CAttributes.cpp b/irr/src/CAttributes.cpp index 2696d6bcf..b1509e455 100644 --- a/irr/src/CAttributes.cpp +++ b/irr/src/CAttributes.cpp @@ -12,61 +12,34 @@ namespace irr namespace io { -CAttributes::CAttributes(video::IVideoDriver *driver) : - Driver(driver) +CAttributes::CAttributes() { #ifdef _DEBUG setDebugName("CAttributes"); #endif - - if (Driver) - Driver->grab(); } CAttributes::~CAttributes() { clear(); - - if (Driver) - Driver->drop(); } //! Removes all attributes void CAttributes::clear() { - for (u32 i = 0; i < Attributes.size(); ++i) - Attributes[i]->drop(); - + for (auto it : Attributes) + delete it.second; Attributes.clear(); } -//! Returns attribute index from name, -1 if not found -s32 CAttributes::findAttribute(const c8 *attributeName) const -{ - for (u32 i = 0; i < Attributes.size(); ++i) - if (Attributes[i]->Name == attributeName) - return i; - - return -1; -} - -IAttribute *CAttributes::getAttributeP(const c8 *attributeName) const -{ - for (u32 i = 0; i < Attributes.size(); ++i) - if (Attributes[i]->Name == attributeName) - return Attributes[i]; - - return 0; -} - //! Sets a attribute as boolean value void CAttributes::setAttribute(const c8 *attributeName, bool value) { - IAttribute *att = getAttributeP(attributeName); - if (att) - att->setBool(value); - else { - Attributes.push_back(new CBoolAttribute(attributeName, value)); + auto it = Attributes.find(attributeName); + if (it != Attributes.end()) { + it->second->setBool(value); + } else { + Attributes[attributeName] = new CBoolAttribute(attributeName, value); } } @@ -76,9 +49,9 @@ void CAttributes::setAttribute(const c8 *attributeName, bool value) //! or 0 if attribute is not set. bool CAttributes::getAttributeAsBool(const c8 *attributeName, bool defaultNotFound) const { - const IAttribute *att = getAttributeP(attributeName); - if (att) - return att->getBool(); + auto it = Attributes.find(attributeName); + if (it != Attributes.end()) + return it->second->getBool(); else return defaultNotFound; } @@ -86,11 +59,11 @@ bool CAttributes::getAttributeAsBool(const c8 *attributeName, bool defaultNotFou //! Sets a attribute as integer value void CAttributes::setAttribute(const c8 *attributeName, s32 value) { - IAttribute *att = getAttributeP(attributeName); - if (att) - att->setInt(value); - else { - Attributes.push_back(new CIntAttribute(attributeName, value)); + auto it = Attributes.find(attributeName); + if (it != Attributes.end()) { + it->second->setInt(value); + } else { + Attributes[attributeName] = new CIntAttribute(attributeName, value); } } @@ -100,9 +73,9 @@ void CAttributes::setAttribute(const c8 *attributeName, s32 value) //! or 0 if attribute is not set. s32 CAttributes::getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound) const { - const IAttribute *att = getAttributeP(attributeName); - if (att) - return att->getInt(); + auto it = Attributes.find(attributeName); + if (it != Attributes.end()) + return it->second->getInt(); else return defaultNotFound; } @@ -110,11 +83,12 @@ s32 CAttributes::getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotF //! Sets a attribute as float value void CAttributes::setAttribute(const c8 *attributeName, f32 value) { - IAttribute *att = getAttributeP(attributeName); - if (att) - att->setFloat(value); - else - Attributes.push_back(new CFloatAttribute(attributeName, value)); + auto it = Attributes.find(attributeName); + if (it != Attributes.end()) { + it->second->setFloat(value); + } else { + Attributes[attributeName] = new CFloatAttribute(attributeName, value); + } } //! Gets a attribute as integer value @@ -123,27 +97,11 @@ void CAttributes::setAttribute(const c8 *attributeName, f32 value) //! or 0 if attribute is not set. f32 CAttributes::getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound) const { - const IAttribute *att = getAttributeP(attributeName); - if (att) - return att->getFloat(); - - return defaultNotFound; -} - -//! Returns amount of string attributes set in this scene manager. -u32 CAttributes::getAttributeCount() const -{ - return Attributes.size(); -} - -//! Returns string attribute name by index. -//! \param index: Index value, must be between 0 and getStringAttributeCount()-1. -const c8 *CAttributes::getAttributeName(s32 index) const -{ - if ((u32)index >= Attributes.size()) - return 0; - - return Attributes[index]->Name.c_str(); + auto it = Attributes.find(attributeName); + if (it != Attributes.end()) + return it->second->getFloat(); + else + return defaultNotFound; } //! Returns the type of an attribute @@ -151,98 +109,17 @@ E_ATTRIBUTE_TYPE CAttributes::getAttributeType(const c8 *attributeName) const { E_ATTRIBUTE_TYPE ret = EAT_UNKNOWN; - const IAttribute *att = getAttributeP(attributeName); - if (att) - ret = att->getType(); + auto it = Attributes.find(attributeName); + if (it != Attributes.end()) + ret = it->second->getType(); return ret; } -//! Returns attribute type by index. -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -E_ATTRIBUTE_TYPE CAttributes::getAttributeType(s32 index) const -{ - if ((u32)index >= Attributes.size()) - return EAT_UNKNOWN; - - return Attributes[index]->getType(); -} - -//! Gets an attribute as integer value -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -s32 CAttributes::getAttributeAsInt(s32 index) const -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getInt(); - else - return 0; -} - -//! Gets an attribute as float value -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -f32 CAttributes::getAttributeAsFloat(s32 index) const -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getFloat(); - else - return 0.f; -} - -//! Gets an attribute as boolean value -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -bool CAttributes::getAttributeAsBool(s32 index) const -{ - bool ret = false; - - if ((u32)index < Attributes.size()) - ret = Attributes[index]->getBool(); - - return ret; -} - -//! Adds an attribute as integer -void CAttributes::addInt(const c8 *attributeName, s32 value) -{ - Attributes.push_back(new CIntAttribute(attributeName, value)); -} - -//! Adds an attribute as float -void CAttributes::addFloat(const c8 *attributeName, f32 value) -{ - Attributes.push_back(new CFloatAttribute(attributeName, value)); -} - -//! Adds an attribute as bool -void CAttributes::addBool(const c8 *attributeName, bool value) -{ - Attributes.push_back(new CBoolAttribute(attributeName, value)); -} - //! Returns if an attribute with a name exists bool CAttributes::existsAttribute(const c8 *attributeName) const { - return getAttributeP(attributeName) != 0; -} - -//! Sets an attribute as boolean value -void CAttributes::setAttribute(s32 index, bool value) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setBool(value); -} - -//! Sets an attribute as integer value -void CAttributes::setAttribute(s32 index, s32 value) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setInt(value); -} - -//! Sets a attribute as float value -void CAttributes::setAttribute(s32 index, f32 value) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setFloat(value); + return Attributes.find(attributeName) != Attributes.end(); } } // end namespace io diff --git a/irr/src/CAttributes.h b/irr/src/CAttributes.h index 0fe2739b6..8ea3ecf19 100644 --- a/irr/src/CAttributes.h +++ b/irr/src/CAttributes.h @@ -4,16 +4,14 @@ #pragma once +#include +#include #include "IAttributes.h" #include "IAttribute.h" namespace irr { -namespace video -{ -class ITexture; -class IVideoDriver; -} + namespace io { @@ -21,30 +19,16 @@ namespace io class CAttributes : public IAttributes { public: - CAttributes(video::IVideoDriver *driver = 0); + CAttributes(); ~CAttributes(); - //! Returns amount of attributes in this collection of attributes. - u32 getAttributeCount() const override; - - //! Returns attribute name by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - const c8 *getAttributeName(s32 index) const override; - //! Returns the type of an attribute //! \param attributeName: Name for the attribute E_ATTRIBUTE_TYPE getAttributeType(const c8 *attributeName) const override; - //! Returns attribute type by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - E_ATTRIBUTE_TYPE getAttributeType(s32 index) const override; - //! Returns if an attribute with a name exists bool existsAttribute(const c8 *attributeName) const override; - //! Returns attribute index from name, -1 if not found - s32 findAttribute(const c8 *attributeName) const override; - //! Removes all attributes void clear() override; @@ -55,7 +39,9 @@ public: */ //! Adds an attribute as integer - void addInt(const c8 *attributeName, s32 value) override; + void addInt(const c8 *attributeName, s32 value) override { + setAttribute(attributeName, value); + } //! Sets an attribute as integer value void setAttribute(const c8 *attributeName, s32 value) override; @@ -66,13 +52,6 @@ public: //! \return Returns value of the attribute previously set by setAttribute() s32 getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound = 0) const override; - //! Gets an attribute as integer value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - s32 getAttributeAsInt(s32 index) const override; - - //! Sets an attribute as integer value - void setAttribute(s32 index, s32 value) override; - /* Float Attribute @@ -80,7 +59,9 @@ public: */ //! Adds an attribute as float - void addFloat(const c8 *attributeName, f32 value) override; + void addFloat(const c8 *attributeName, f32 value) override { + setAttribute(attributeName, value); + } //! Sets a attribute as float value void setAttribute(const c8 *attributeName, f32 value) override; @@ -91,19 +72,14 @@ public: //! \return Returns value of the attribute previously set by setAttribute() f32 getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound = 0.f) const override; - //! Gets an attribute as float value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - f32 getAttributeAsFloat(s32 index) const override; - - //! Sets an attribute as float value - void setAttribute(s32 index, f32 value) override; - /* Bool Attribute */ //! Adds an attribute as bool - void addBool(const c8 *attributeName, bool value) override; + void addBool(const c8 *attributeName, bool value) override { + setAttribute(attributeName, value); + } //! Sets an attribute as boolean value void setAttribute(const c8 *attributeName, bool value) override; @@ -114,19 +90,12 @@ public: //! \return Returns value of the attribute previously set by setAttribute() bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound = false) const override; - //! Gets an attribute as boolean value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - bool getAttributeAsBool(s32 index) const override; - - //! Sets an attribute as boolean value - void setAttribute(s32 index, bool value) override; - protected: - core::array Attributes; + typedef std::basic_string string; - IAttribute *getAttributeP(const c8 *attributeName) const; - - video::IVideoDriver *Driver; + // specify a comparator so we can directly look up in the map with const c8* + // (works since C++14) + std::map> Attributes; }; } // end namespace io diff --git a/irr/src/CB3DMeshFileLoader.cpp b/irr/src/CB3DMeshFileLoader.cpp index 6ee24af0e..008169bd7 100644 --- a/irr/src/CB3DMeshFileLoader.cpp +++ b/irr/src/CB3DMeshFileLoader.cpp @@ -433,7 +433,7 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *meshBuffer, u32 m } const s32 memoryNeeded = B3dStack.getLast().length / sizeof(s32); - meshBuffer->Indices.reallocate(memoryNeeded + meshBuffer->Indices.size() + 1); + meshBuffer->Indices.reserve(memoryNeeded + meshBuffer->Indices.size() + 1); while ((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats { diff --git a/irr/src/CBillboardSceneNode.cpp b/irr/src/CBillboardSceneNode.cpp index ddb9d465a..7be139f96 100644 --- a/irr/src/CBillboardSceneNode.cpp +++ b/irr/src/CBillboardSceneNode.cpp @@ -26,8 +26,8 @@ CBillboardSceneNode::CBillboardSceneNode(ISceneNode *parent, ISceneManager *mgr, setSize(size); - Buffer->Vertices.set_used(4); - Buffer->Indices.set_used(6); + Buffer->Vertices.resize(4); + Buffer->Indices.resize(6); Buffer->Indices[0] = 0; Buffer->Indices[1] = 2; @@ -114,7 +114,7 @@ void CBillboardSceneNode::updateMesh(const irr::scene::ICameraSceneNode *camera) view *= -1.0f; - core::array &vertices = Buffer->Vertices; + auto *vertices = Buffer->Vertices.data(); for (s32 i = 0; i < 4; ++i) vertices[i].Normal = view; diff --git a/irr/src/CFileSystem.cpp b/irr/src/CFileSystem.cpp index bffb703dd..386bb389c 100644 --- a/irr/src/CFileSystem.cpp +++ b/irr/src/CFileSystem.cpp @@ -58,14 +58,8 @@ CFileSystem::CFileSystem() //! destructor CFileSystem::~CFileSystem() { - u32 i; - - for (i = 0; i < FileArchives.size(); ++i) { - FileArchives[i]->drop(); - } - - for (i = 0; i < ArchiveLoader.size(); ++i) { - ArchiveLoader[i]->drop(); + for (auto *it : ArchiveLoader) { + it->drop(); } } @@ -75,15 +69,6 @@ IReadFile *CFileSystem::createAndOpenFile(const io::path &filename) if (filename.empty()) return 0; - IReadFile *file = 0; - u32 i; - - for (i = 0; i < FileArchives.size(); ++i) { - file = FileArchives[i]->createAndOpenFile(filename); - if (file) - return file; - } - // Create the file using an absolute path so that it matches // the scheme used by CNullDriver::getTexture(). return CReadFile::createReadFile(getAbsolutePath(filename)); @@ -150,241 +135,6 @@ IArchiveLoader *CFileSystem::getArchiveLoader(u32 index) const return 0; } -//! move the hirarchy of the filesystem. moves sourceIndex relative up or down -bool CFileSystem::moveFileArchive(u32 sourceIndex, s32 relative) -{ - bool r = false; - const s32 dest = (s32)sourceIndex + relative; - const s32 dir = relative < 0 ? -1 : 1; - const s32 sourceEnd = ((s32)FileArchives.size()) - 1; - IFileArchive *t; - - for (s32 s = (s32)sourceIndex; s != dest; s += dir) { - if (s < 0 || s > sourceEnd || s + dir < 0 || s + dir > sourceEnd) - continue; - - t = FileArchives[s + dir]; - FileArchives[s + dir] = FileArchives[s]; - FileArchives[s] = t; - r = true; - } - return r; -} - -//! Adds an archive to the file system. -bool CFileSystem::addFileArchive(const io::path &filename, bool ignoreCase, - bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType, - const core::stringc &password, - IFileArchive **retArchive) -{ - IFileArchive *archive = 0; - bool ret = false; - - // see if archive is already added - - s32 i; - - // do we know what type it should be? - if (archiveType == EFAT_UNKNOWN) { - // try to load archive based on file name - for (i = ArchiveLoader.size() - 1; i >= 0; --i) { - if (ArchiveLoader[i]->isALoadableFileFormat(filename)) { - archive = ArchiveLoader[i]->createArchive(filename, ignoreCase, ignorePaths); - if (archive) - break; - } - } - - // try to load archive based on content - if (!archive) { - io::IReadFile *file = createAndOpenFile(filename); - if (file) { - for (i = ArchiveLoader.size() - 1; i >= 0; --i) { - file->seek(0); - if (ArchiveLoader[i]->isALoadableFileFormat(file)) { - file->seek(0); - archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); - if (archive) - break; - } - } - file->drop(); - } - } - } else { - // try to open archive based on archive loader type - - io::IReadFile *file = 0; - - for (i = ArchiveLoader.size() - 1; i >= 0; --i) { - if (ArchiveLoader[i]->isALoadableFileFormat(archiveType)) { - // attempt to open file - if (!file) - file = createAndOpenFile(filename); - - // is the file open? - if (file) { - // attempt to open archive - file->seek(0); - if (ArchiveLoader[i]->isALoadableFileFormat(file)) { - file->seek(0); - archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); - if (archive) - break; - } - } else { - // couldn't open file - break; - } - } - } - - // if open, close the file - if (file) - file->drop(); - } - - if (archive) { - FileArchives.push_back(archive); - if (password.size()) - archive->Password = password; - if (retArchive) - *retArchive = archive; - ret = true; - } else { - os::Printer::log("Could not create archive for", filename, ELL_ERROR); - } - - return ret; -} - -bool CFileSystem::addFileArchive(IReadFile *file, bool ignoreCase, - bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType, - const core::stringc &password, IFileArchive **retArchive) -{ - if (!file) - return false; - - if (file) { - IFileArchive *archive = 0; - s32 i; - - if (archiveType == EFAT_UNKNOWN) { - // try to load archive based on file name - for (i = ArchiveLoader.size() - 1; i >= 0; --i) { - if (ArchiveLoader[i]->isALoadableFileFormat(file->getFileName())) { - archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); - if (archive) - break; - } - } - - // try to load archive based on content - if (!archive) { - for (i = ArchiveLoader.size() - 1; i >= 0; --i) { - file->seek(0); - if (ArchiveLoader[i]->isALoadableFileFormat(file)) { - file->seek(0); - archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); - if (archive) - break; - } - } - } - } else { - // try to open archive based on archive loader type - for (i = ArchiveLoader.size() - 1; i >= 0; --i) { - if (ArchiveLoader[i]->isALoadableFileFormat(archiveType)) { - // attempt to open archive - file->seek(0); - if (ArchiveLoader[i]->isALoadableFileFormat(file)) { - file->seek(0); - archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); - if (archive) - break; - } - } - } - } - - if (archive) { - FileArchives.push_back(archive); - if (password.size()) - archive->Password = password; - if (retArchive) - *retArchive = archive; - return true; - } else { - os::Printer::log("Could not create archive for", file->getFileName(), ELL_ERROR); - } - } - - return false; -} - -//! Adds an archive to the file system. -bool CFileSystem::addFileArchive(IFileArchive *archive) -{ - if (archive) { - for (u32 i = 0; i < FileArchives.size(); ++i) { - if (archive == FileArchives[i]) { - return false; - } - } - FileArchives.push_back(archive); - archive->grab(); - - return true; - } - - return false; -} - -//! removes an archive from the file system. -bool CFileSystem::removeFileArchive(u32 index) -{ - bool ret = false; - if (index < FileArchives.size()) { - FileArchives[index]->drop(); - FileArchives.erase(index); - ret = true; - } - return ret; -} - -//! removes an archive from the file system. -bool CFileSystem::removeFileArchive(const io::path &filename) -{ - const path absPath = getAbsolutePath(filename); - for (u32 i = 0; i < FileArchives.size(); ++i) { - if (absPath == FileArchives[i]->getFileList()->getPath()) - return removeFileArchive(i); - } - return false; -} - -//! Removes an archive from the file system. -bool CFileSystem::removeFileArchive(const IFileArchive *archive) -{ - for (u32 i = 0; i < FileArchives.size(); ++i) { - if (archive == FileArchives[i]) { - return removeFileArchive(i); - } - } - return false; -} - -//! gets an archive -u32 CFileSystem::getFileArchiveCount() const -{ - return FileArchives.size(); -} - -IFileArchive *CFileSystem::getFileArchive(u32 index) -{ - return index < getFileArchiveCount() ? FileArchives[index] : 0; -} - //! Returns the string of the current working directory const io::path &CFileSystem::getWorkingDirectory() { @@ -711,17 +461,6 @@ IFileList *CFileSystem::createFileList() //! parent r->addItem(Path + _IRR_TEXT(".."), 0, 0, true, 0); - - //! merge archives - for (u32 i = 0; i < FileArchives.size(); ++i) { - const IFileList *merge = FileArchives[i]->getFileList(); - - for (u32 j = 0; j < merge->getFileCount(); ++j) { - if (core::isInSameDirectory(Path, merge->getFullFileName(j)) == 0) { - r->addItem(merge->getFullFileName(j), merge->getFileOffset(j), merge->getFileSize(j), merge->isDirectory(j), 0); - } - } - } } if (r) @@ -738,10 +477,6 @@ IFileList *CFileSystem::createEmptyFileList(const io::path &path, bool ignoreCas //! determines if a file exists and would be able to be opened. bool CFileSystem::existFile(const io::path &filename) const { - for (u32 i = 0; i < FileArchives.size(); ++i) - if (FileArchives[i]->getFileList()->findFile(filename) != -1) - return true; - #if defined(_MSC_VER) return (_access(filename.c_str(), 0) != -1); #elif defined(F_OK) diff --git a/irr/src/CFileSystem.h b/irr/src/CFileSystem.h index 18bc7ff3f..208a1ac41 100644 --- a/irr/src/CFileSystem.h +++ b/irr/src/CFileSystem.h @@ -4,8 +4,8 @@ #pragma once +#include #include "IFileSystem.h" -#include "irrArray.h" namespace irr { @@ -41,25 +41,6 @@ public: //! Opens a file for write access. IWriteFile *createAndWriteFile(const io::path &filename, bool append = false) override; - //! Adds an archive to the file system. - virtual bool addFileArchive(const io::path &filename, - bool ignoreCase = true, bool ignorePaths = true, - E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN, - const core::stringc &password = "", - IFileArchive **retArchive = 0) override; - - //! Adds an archive to the file system. - virtual bool addFileArchive(IReadFile *file, bool ignoreCase = true, - bool ignorePaths = true, - E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN, - const core::stringc &password = "", - IFileArchive **retArchive = 0) override; - - //! Adds an archive to the file system. - bool addFileArchive(IFileArchive *archive) override; - - //! move the hirarchy of the filesystem. moves sourceIndex relative up or down - bool moveFileArchive(u32 sourceIndex, s32 relative) override; //! Adds an external archive loader to the engine. void addArchiveLoader(IArchiveLoader *loader) override; @@ -70,21 +51,6 @@ public: //! Gets the archive loader by index. IArchiveLoader *getArchiveLoader(u32 index) const override; - //! gets the file archive count - u32 getFileArchiveCount() const override; - - //! gets an archive - IFileArchive *getFileArchive(u32 index) override; - - //! removes an archive from the file system. - bool removeFileArchive(u32 index) override; - - //! removes an archive from the file system. - bool removeFileArchive(const io::path &filename) override; - - //! Removes an archive from the file system. - bool removeFileArchive(const IFileArchive *archive) override; - //! Returns the string of the current working directory const io::path &getWorkingDirectory() override; @@ -129,9 +95,7 @@ private: //! WorkingDirectory for Native and Virtual filesystems io::path WorkingDirectory[2]; //! currently attached ArchiveLoaders - core::array ArchiveLoader; - //! currently attached Archives - core::array FileArchives; + std::vector ArchiveLoader; }; } // end namespace irr diff --git a/irr/src/CMeshManipulator.cpp b/irr/src/CMeshManipulator.cpp index 3309fea3f..db6c39812 100644 --- a/irr/src/CMeshManipulator.cpp +++ b/irr/src/CMeshManipulator.cpp @@ -132,48 +132,30 @@ SMesh *CMeshManipulator::createMeshCopy(scene::IMesh *mesh) const case video::EVT_STANDARD: { SMeshBuffer *buffer = new SMeshBuffer(); buffer->Material = mb->getMaterial(); - const u32 vcount = mb->getVertexCount(); - buffer->Vertices.reallocate(vcount); - video::S3DVertex *vertices = (video::S3DVertex *)mb->getVertices(); - for (u32 i = 0; i < vcount; ++i) - buffer->Vertices.push_back(vertices[i]); - const u32 icount = mb->getIndexCount(); - buffer->Indices.reallocate(icount); - const u16 *indices = mb->getIndices(); - for (u32 i = 0; i < icount; ++i) - buffer->Indices.push_back(indices[i]); + auto *vt = static_cast(mb->getVertices()); + buffer->Vertices.insert(buffer->Vertices.end(), vt, vt + mb->getVertexCount()); + auto *indices = mb->getIndices(); + buffer->Indices.insert(buffer->Indices.end(), indices, indices + mb->getIndexCount()); clone->addMeshBuffer(buffer); buffer->drop(); } break; case video::EVT_2TCOORDS: { SMeshBufferLightMap *buffer = new SMeshBufferLightMap(); buffer->Material = mb->getMaterial(); - const u32 vcount = mb->getVertexCount(); - buffer->Vertices.reallocate(vcount); - video::S3DVertex2TCoords *vertices = (video::S3DVertex2TCoords *)mb->getVertices(); - for (u32 i = 0; i < vcount; ++i) - buffer->Vertices.push_back(vertices[i]); - const u32 icount = mb->getIndexCount(); - buffer->Indices.reallocate(icount); - const u16 *indices = mb->getIndices(); - for (u32 i = 0; i < icount; ++i) - buffer->Indices.push_back(indices[i]); + auto *vt = static_cast(mb->getVertices()); + buffer->Vertices.insert(buffer->Vertices.end(), vt, vt + mb->getVertexCount()); + auto *indices = mb->getIndices(); + buffer->Indices.insert(buffer->Indices.end(), indices, indices + mb->getIndexCount()); clone->addMeshBuffer(buffer); buffer->drop(); } break; case video::EVT_TANGENTS: { SMeshBufferTangents *buffer = new SMeshBufferTangents(); buffer->Material = mb->getMaterial(); - const u32 vcount = mb->getVertexCount(); - buffer->Vertices.reallocate(vcount); - video::S3DVertexTangents *vertices = (video::S3DVertexTangents *)mb->getVertices(); - for (u32 i = 0; i < vcount; ++i) - buffer->Vertices.push_back(vertices[i]); - const u32 icount = mb->getIndexCount(); - buffer->Indices.reallocate(icount); - const u16 *indices = mb->getIndices(); - for (u32 i = 0; i < icount; ++i) - buffer->Indices.push_back(indices[i]); + auto *vt = static_cast(mb->getVertices()); + buffer->Vertices.insert(buffer->Vertices.end(), vt, vt + mb->getVertexCount()); + auto *indices = mb->getIndices(); + buffer->Indices.insert(buffer->Indices.end(), indices, indices + mb->getIndexCount()); clone->addMeshBuffer(buffer); buffer->drop(); } break; diff --git a/irr/src/CNullDriver.cpp b/irr/src/CNullDriver.cpp index 92450e5d7..c1cecbe8c 100644 --- a/irr/src/CNullDriver.cpp +++ b/irr/src/CNullDriver.cpp @@ -64,7 +64,6 @@ CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d &scre DriverAttributes->addInt("MaxTextures", MATERIAL_MAX_TEXTURES); DriverAttributes->addInt("MaxSupportedTextures", MATERIAL_MAX_TEXTURES); DriverAttributes->addInt("MaxAnisotropy", 1); - // DriverAttributes->addInt("MaxUserClipPlanes", 0); // DriverAttributes->addInt("MaxAuxBuffers", 0); DriverAttributes->addInt("MaxMultipleRenderTargets", 1); DriverAttributes->addInt("MaxIndices", -1); @@ -361,7 +360,7 @@ ITexture *CNullDriver::addTextureCubemap(const io::path &name, IImage *imagePosX ITexture *t = 0; - core::array imageArray(6); + std::vector imageArray; imageArray.push_back(imagePosX); imageArray.push_back(imageNegX); imageArray.push_back(imagePosY); @@ -391,7 +390,7 @@ ITexture *CNullDriver::addTextureCubemap(const irr::u32 sideLen, const io::path return 0; } - core::array imageArray(6); + std::vector imageArray; for (int i = 0; i < 6; ++i) imageArray.push_back(new CImage(format, core::dimension2du(sideLen, sideLen))); @@ -548,7 +547,7 @@ ITexture *CNullDriver::createDeviceDependentTexture(const io::path &name, IImage return dummy; } -ITexture *CNullDriver::createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) +ITexture *CNullDriver::createDeviceDependentTextureCubemap(const io::path &name, const std::vector &image) { return new SDummyTexture(name, ETT_CUBEMAP); } @@ -913,17 +912,17 @@ bool CNullDriver::checkImage(IImage *image) const return true; } -bool CNullDriver::checkImage(const core::array &image) const +bool CNullDriver::checkImage(const std::vector &image) const { - if (!image.size()) + if (image.empty()) return false; ECOLOR_FORMAT lastFormat = image[0]->getColorFormat(); - core::dimension2d lastSize = image[0]->getDimension(); + auto lastSize = image[0]->getDimension(); - for (u32 i = 0; i < image.size(); ++i) { + for (size_t i = 0; i < image.size(); ++i) { ECOLOR_FORMAT format = image[i]->getColorFormat(); - core::dimension2d size = image[i]->getDimension(); + auto size = image[i]->getDimension(); if (!checkImage(image[i])) return false; @@ -1699,22 +1698,6 @@ IVideoDriver *createNullDriver(io::IFileSystem *io, const core::dimension2d return nullDriver; } -//! Set/unset a clipping plane. -//! There are at least 6 clipping planes available for the user to set at will. -//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. -//! \param plane: The plane itself. -//! \param enable: If true, enable the clipping plane else disable it. -bool CNullDriver::setClipPlane(u32 index, const core::plane3df &plane, bool enable) -{ - return false; -} - -//! Enable/disable a clipping plane. -void CNullDriver::enableClipPlane(u32 index, bool enable) -{ - // not necessary -} - void CNullDriver::setMinHardwareBufferVertexCount(u32 count) { MinVertexCountForVBO = count; diff --git a/irr/src/CNullDriver.h b/irr/src/CNullDriver.h index d47212c0f..30911b7a6 100644 --- a/irr/src/CNullDriver.h +++ b/irr/src/CNullDriver.h @@ -494,19 +494,6 @@ public: //! looks if the image is already loaded video::ITexture *findTexture(const io::path &filename) override; - //! Set/unset a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param plane: The plane itself. - //! \param enable: If true, enable the clipping plane else disable it. - bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) override; - - //! Enable/disable a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param enable: If true, enable the clipping plane else disable it. - void enableClipPlane(u32 index, bool enable) override; - //! Returns the graphics card vendor name. core::stringc getVendorInfo() override { return "Not available on this driver."; } @@ -565,14 +552,14 @@ protected: virtual ITexture *createDeviceDependentTexture(const io::path &name, IImage *image); - virtual ITexture *createDeviceDependentTextureCubemap(const io::path &name, const core::array &image); + virtual ITexture *createDeviceDependentTextureCubemap(const io::path &name, const std::vector &image); //! checks triangle count and print warning if wrong bool checkPrimitiveCount(u32 prmcnt) const; bool checkImage(IImage *image) const; - bool checkImage(const core::array &image) const; + bool checkImage(const std::vector &image) const; // adds a material renderer and drops it afterwards. To be used for internal creation s32 addAndDropMaterialRenderer(IMaterialRenderer *m); diff --git a/irr/src/COGLESDriver.cpp b/irr/src/COGLESDriver.cpp index 524aedd50..d5feda58e 100644 --- a/irr/src/COGLESDriver.cpp +++ b/irr/src/COGLESDriver.cpp @@ -103,14 +103,6 @@ bool COGLES1Driver::genericDriverInit(const core::dimension2d &screenSize, glPixelStorei(GL_PACK_ALIGNMENT, 1); - UserClipPlane.reallocate(MaxUserClipPlanes); - UserClipPlaneEnabled.resize(MaxUserClipPlanes); - - for (s32 i = 0; i < MaxUserClipPlanes; ++i) { - UserClipPlane.push_back(core::plane3df()); - UserClipPlaneEnabled[i] = false; - } - for (s32 i = 0; i < ETS_COUNT; ++i) setTransform(static_cast(i), core::IdentityMatrix); @@ -195,10 +187,6 @@ void COGLES1Driver::setTransform(E_TRANSFORMATION_STATE state, const core::matri // OGLES1 only has a model matrix, view and world is not existent. so lets fake these two. glMatrixMode(GL_MODELVIEW); glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer()); - // we have to update the clip planes to the latest view matrix - for (u32 i = 0; i < MaxUserClipPlanes; ++i) - if (UserClipPlaneEnabled[i]) - uploadClipPlane(i); } break; case ETS_PROJECTION: { GLfloat glmat[16]; @@ -1149,15 +1137,14 @@ inline void COGLES1Driver::getGLTextureMatrix(GLfloat *o, const core::matrix4 &m ITexture *COGLES1Driver::createDeviceDependentTexture(const io::path &name, IImage *image) { - core::array imageArray(1); - imageArray.push_back(image); + std::vector tmp { image }; - COGLES1Texture *texture = new COGLES1Texture(name, imageArray, ETT_2D, this); + COGLES1Texture *texture = new COGLES1Texture(name, tmp, ETT_2D, this); return texture; } -ITexture *COGLES1Driver::createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) +ITexture *COGLES1Driver::createDeviceDependentTextureCubemap(const io::path &name, const std::vector &image) { COGLES1Texture *texture = new COGLES1Texture(name, image, ETT_CUBEMAP, this); @@ -2158,44 +2145,6 @@ void COGLES1Driver::removeTexture(ITexture *texture) CNullDriver::removeTexture(texture); } -//! Set/unset a clipping plane. -bool COGLES1Driver::setClipPlane(u32 index, const core::plane3df &plane, bool enable) -{ - if (index >= MaxUserClipPlanes) - return false; - - UserClipPlane[index] = plane; - enableClipPlane(index, enable); - return true; -} - -void COGLES1Driver::uploadClipPlane(u32 index) -{ - // opengl needs an array of doubles for the plane equation - float clip_plane[4]; - clip_plane[0] = UserClipPlane[index].Normal.X; - clip_plane[1] = UserClipPlane[index].Normal.Y; - clip_plane[2] = UserClipPlane[index].Normal.Z; - clip_plane[3] = UserClipPlane[index].D; - glClipPlanef(GL_CLIP_PLANE0 + index, clip_plane); -} - -//! Enable/disable a clipping plane. -void COGLES1Driver::enableClipPlane(u32 index, bool enable) -{ - if (index >= MaxUserClipPlanes) - return; - if (enable) { - if (!UserClipPlaneEnabled[index]) { - uploadClipPlane(index); - glEnable(GL_CLIP_PLANE0 + index); - } - } else - glDisable(GL_CLIP_PLANE0 + index); - - UserClipPlaneEnabled[index] = enable; -} - core::dimension2du COGLES1Driver::getMaxTextureSize() const { return core::dimension2du(MaxTextureSize, MaxTextureSize); diff --git a/irr/src/COGLESDriver.h b/irr/src/COGLESDriver.h index 29e0d94f1..8b9152cea 100644 --- a/irr/src/COGLESDriver.h +++ b/irr/src/COGLESDriver.h @@ -215,12 +215,6 @@ public: //! checks if an OpenGL error has happened and prints it (+ some internal code which is usually the line number) bool testGLError(int code = 0); - //! Set/unset a clipping plane. - bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) override; - - //! Enable/disable a clipping plane. - void enableClipPlane(u32 index, bool enable) override; - //! Returns the graphics card vendor name. core::stringc getVendorInfo() override { @@ -250,14 +244,12 @@ public: COGLES1CacheHandler *getCacheHandler() const; private: - void uploadClipPlane(u32 index); - //! inits the opengl-es driver bool genericDriverInit(const core::dimension2d &screenSize, bool stencilBuffer); ITexture *createDeviceDependentTexture(const io::path &name, IImage *image) override; - ITexture *createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) override; + ITexture *createDeviceDependentTextureCubemap(const io::path &name, const std::vector &image) override; //! creates a transposed matrix in supplied GLfloat array to pass to OGLES1 inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4 &m); @@ -306,8 +298,6 @@ private: u8 AntiAlias; SMaterial Material, LastMaterial; - core::array UserClipPlane; - std::vector UserClipPlaneEnabled; core::stringc VendorName; diff --git a/irr/src/COGLESExtensionHandler.cpp b/irr/src/COGLESExtensionHandler.cpp index 82f8e9261..866a984d8 100644 --- a/irr/src/COGLESExtensionHandler.cpp +++ b/irr/src/COGLESExtensionHandler.cpp @@ -25,7 +25,7 @@ namespace video COGLES1ExtensionHandler::COGLES1ExtensionHandler() : COGLESCoreExtensionHandler(), - MaxUserClipPlanes(0), MaxLights(0), pGlBlendEquationOES(0), pGlBlendFuncSeparateOES(0), + MaxLights(0), pGlBlendEquationOES(0), pGlBlendFuncSeparateOES(0), pGlBindFramebufferOES(0), pGlDeleteFramebuffersOES(0), pGlGenFramebuffersOES(0), pGlCheckFramebufferStatusOES(0), pGlFramebufferTexture2DOES(0), pGlGenerateMipmapOES(0) @@ -45,11 +45,6 @@ void COGLES1ExtensionHandler::initExtensions() GLint val = 0; - if (Version > 100 || FeatureAvailable[IRR_GL_IMG_user_clip_plane]) { - glGetIntegerv(GL_MAX_CLIP_PLANES, &val); - MaxUserClipPlanes = static_cast(val); - } - glGetIntegerv(GL_MAX_LIGHTS, &val); MaxLights = static_cast(val); diff --git a/irr/src/COGLESExtensionHandler.h b/irr/src/COGLESExtensionHandler.h index d9e1ac4bc..a316afaad 100644 --- a/irr/src/COGLESExtensionHandler.h +++ b/irr/src/COGLESExtensionHandler.h @@ -171,7 +171,6 @@ public: } protected: - u8 MaxUserClipPlanes; u8 MaxLights; PFNGLBLENDEQUATIONOESPROC pGlBlendEquationOES; diff --git a/irr/src/COpenGLCoreTexture.h b/irr/src/COpenGLCoreTexture.h index 79a855cc1..218eabece 100644 --- a/irr/src/COpenGLCoreTexture.h +++ b/irr/src/COpenGLCoreTexture.h @@ -4,7 +4,7 @@ #pragma once -#include "irrArray.h" +#include #include "SMaterialLayer.h" #include "ITexture.h" #include "EDriverFeatures.h" @@ -43,19 +43,19 @@ public: bool IsCached; }; - COpenGLCoreTexture(const io::path &name, const core::array &images, E_TEXTURE_TYPE type, TOpenGLDriver *driver) : + COpenGLCoreTexture(const io::path &name, const std::vector &srcImages, E_TEXTURE_TYPE type, TOpenGLDriver *driver) : ITexture(name, type), Driver(driver), TextureType(GL_TEXTURE_2D), TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_RGBA), PixelType(GL_UNSIGNED_BYTE), Converter(0), LockReadOnly(false), LockImage(0), LockLayer(0), KeepImage(false), MipLevelStored(0), LegacyAutoGenerateMipMaps(false) { - _IRR_DEBUG_BREAK_IF(images.size() == 0) + _IRR_DEBUG_BREAK_IF(srcImages.empty()) DriverType = Driver->getDriverType(); TextureType = TextureTypeIrrToGL(Type); HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); KeepImage = Driver->getTextureCreationFlag(ETCF_ALLOW_MEMORY_COPY); - getImageValues(images[0]); + getImageValues(srcImages[0]); if (!InternalFormat) return; @@ -71,22 +71,22 @@ public: os::Printer::log(lbuf, ELL_DEBUG); #endif - const core::array *tmpImages = &images; + const auto *tmpImages = &srcImages; if (KeepImage || OriginalSize != Size || OriginalColorFormat != ColorFormat) { - Images.set_used(images.size()); + Images.resize(srcImages.size()); - for (u32 i = 0; i < images.size(); ++i) { + for (size_t i = 0; i < srcImages.size(); ++i) { Images[i] = Driver->createImage(ColorFormat, Size); - if (images[i]->getDimension() == Size) - images[i]->copyTo(Images[i]); + if (srcImages[i]->getDimension() == Size) + srcImages[i]->copyTo(Images[i]); else - images[i]->copyToScaling(Images[i]); + srcImages[i]->copyToScaling(Images[i]); - if (images[i]->getMipMapsData()) { + if (srcImages[i]->getMipMapsData()) { if (OriginalSize == Size && OriginalColorFormat == ColorFormat) { - Images[i]->setMipMapsData(images[i]->getMipMapsData(), false); + Images[i]->setMipMapsData(srcImages[i]->getMipMapsData(), false); } else { // TODO: handle at least mipmap with changing color format os::Printer::log("COpenGLCoreTexture: Can't handle format changes for mipmap data. Mipmap data dropped", ELL_WARNING); @@ -118,19 +118,19 @@ public: TEST_GL_ERROR(Driver); - for (u32 i = 0; i < (*tmpImages).size(); ++i) + for (size_t i = 0; i < tmpImages->size(); ++i) uploadTexture(true, i, 0, (*tmpImages)[i]->getData()); if (HasMipMaps && !LegacyAutoGenerateMipMaps) { // Create mipmaps (either from image mipmaps or generate them) - for (u32 i = 0; i < (*tmpImages).size(); ++i) { + for (size_t i = 0; i < tmpImages->size(); ++i) { void *mipmapsData = (*tmpImages)[i]->getMipMapsData(); regenerateMipMapLevels(mipmapsData, i); } } if (!KeepImage) { - for (u32 i = 0; i < Images.size(); ++i) + for (size_t i = 0; i < Images.size(); ++i) Images[i]->drop(); Images.clear(); @@ -227,8 +227,8 @@ public: if (LockImage) LockImage->drop(); - for (u32 i = 0; i < Images.size(); ++i) - Images[i]->drop(); + for (auto *image : Images) + image->drop(); } void *lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel = 0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) override @@ -621,7 +621,7 @@ protected: u32 LockLayer; bool KeepImage; - core::array Images; + std::vector Images; u8 MipLevelStored; bool LegacyAutoGenerateMipMaps; diff --git a/irr/src/COpenGLDriver.cpp b/irr/src/COpenGLDriver.cpp index 1ad66aef9..1c6342090 100644 --- a/irr/src/COpenGLDriver.cpp +++ b/irr/src/COpenGLDriver.cpp @@ -122,7 +122,6 @@ bool COpenGLDriver::genericDriverInit() DriverAttributes->setAttribute("MaxSupportedTextures", (s32)Feature.MaxTextureUnits); DriverAttributes->setAttribute("MaxLights", MaxLights); DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy); - DriverAttributes->setAttribute("MaxUserClipPlanes", MaxUserClipPlanes); DriverAttributes->setAttribute("MaxAuxBuffers", MaxAuxBuffers); DriverAttributes->setAttribute("MaxMultipleRenderTargets", (s32)Feature.MultipleRenderTarget); DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices); @@ -135,10 +134,6 @@ bool COpenGLDriver::genericDriverInit() glPixelStorei(GL_PACK_ALIGNMENT, 1); - UserClipPlanes.reallocate(MaxUserClipPlanes); - for (i = 0; i < MaxUserClipPlanes; ++i) - UserClipPlanes.push_back(SUserClipPlane()); - for (i = 0; i < ETS_COUNT; ++i) setTransform(static_cast(i), core::IdentityMatrix); @@ -244,11 +239,6 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri // first load the viewing transformation for user clip planes glLoadMatrixf((Matrices[ETS_VIEW]).pointer()); - // we have to update the clip planes to the latest view matrix - for (u32 i = 0; i < MaxUserClipPlanes; ++i) - if (UserClipPlanes[i].Enabled) - uploadClipPlane(i); - // now the real model-view matrix glMultMatrixf(Matrices[ETS_WORLD].pointer()); } break; @@ -1597,15 +1587,14 @@ inline void COpenGLDriver::getGLTextureMatrix(GLfloat *o, const core::matrix4 &m ITexture *COpenGLDriver::createDeviceDependentTexture(const io::path &name, IImage *image) { - core::array imageArray(1); - imageArray.push_back(image); + std::vector tmp { image }; - COpenGLTexture *texture = new COpenGLTexture(name, imageArray, ETT_2D, this); + COpenGLTexture *texture = new COpenGLTexture(name, tmp, ETT_2D, this); return texture; } -ITexture *COpenGLDriver::createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) +ITexture *COpenGLDriver::createDeviceDependentTextureCubemap(const io::path &name, const std::vector &image) { COpenGLTexture *texture = new COpenGLTexture(name, image, ETT_CUBEMAP, this); @@ -3062,44 +3051,6 @@ IImage *COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE return newImage; } -//! Set/unset a clipping plane. -bool COpenGLDriver::setClipPlane(u32 index, const core::plane3df &plane, bool enable) -{ - if (index >= MaxUserClipPlanes) - return false; - - UserClipPlanes[index].Plane = plane; - enableClipPlane(index, enable); - return true; -} - -void COpenGLDriver::uploadClipPlane(u32 index) -{ - // opengl needs an array of doubles for the plane equation - GLdouble clip_plane[4]; - clip_plane[0] = UserClipPlanes[index].Plane.Normal.X; - clip_plane[1] = UserClipPlanes[index].Plane.Normal.Y; - clip_plane[2] = UserClipPlanes[index].Plane.Normal.Z; - clip_plane[3] = UserClipPlanes[index].Plane.D; - glClipPlane(GL_CLIP_PLANE0 + index, clip_plane); -} - -//! Enable/disable a clipping plane. -void COpenGLDriver::enableClipPlane(u32 index, bool enable) -{ - if (index >= MaxUserClipPlanes) - return; - if (enable) { - if (!UserClipPlanes[index].Enabled) { - uploadClipPlane(index); - glEnable(GL_CLIP_PLANE0 + index); - } - } else - glDisable(GL_CLIP_PLANE0 + index); - - UserClipPlanes[index].Enabled = enable; -} - core::dimension2du COpenGLDriver::getMaxTextureSize() const { return core::dimension2du(MaxTextureSize, MaxTextureSize); diff --git a/irr/src/COpenGLDriver.h b/irr/src/COpenGLDriver.h index 6fe8ac37d..3c0a718fc 100644 --- a/irr/src/COpenGLDriver.h +++ b/irr/src/COpenGLDriver.h @@ -285,19 +285,6 @@ public: //! for performance reasons only available in debug mode bool testGLError(int code = 0); - //! Set/unset a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param plane: The plane itself. - //! \param enable: If true, enable the clipping plane else disable it. - bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) override; - - //! Enable/disable a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param enable: If true, enable the clipping plane else disable it. - void enableClipPlane(u32 index, bool enable) override; - //! Enable the 2d override material void enableMaterial2D(bool enable = true) override; @@ -343,14 +330,12 @@ private: bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); - void uploadClipPlane(u32 index); - //! inits the parts of the open gl driver used on all platforms bool genericDriverInit(); ITexture *createDeviceDependentTexture(const io::path &name, IImage *image) override; - ITexture *createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) override; + ITexture *createDeviceDependentTextureCubemap(const io::path &name, const std::vector &image) override; //! creates a transposed matrix in supplied GLfloat array to pass to OpenGL inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4 &m); @@ -404,15 +389,6 @@ private: SMaterial Material, LastMaterial; - struct SUserClipPlane - { - SUserClipPlane() : - Enabled(false) {} - core::plane3df Plane; - bool Enabled; - }; - core::array UserClipPlanes; - core::stringc VendorName; core::matrix4 TextureFlipMatrix; diff --git a/irr/src/COpenGLExtensionHandler.cpp b/irr/src/COpenGLExtensionHandler.cpp index d5aade126..6127d6e46 100644 --- a/irr/src/COpenGLExtensionHandler.cpp +++ b/irr/src/COpenGLExtensionHandler.cpp @@ -20,7 +20,7 @@ bool COpenGLExtensionHandler::needsDSAFramebufferHack = true; COpenGLExtensionHandler::COpenGLExtensionHandler() : StencilBuffer(false), TextureCompressionExtension(false), MaxLights(1), - MaxAnisotropy(1), MaxUserClipPlanes(0), MaxAuxBuffers(0), MaxIndices(65535), + MaxAnisotropy(1), MaxAuxBuffers(0), MaxIndices(65535), MaxTextureSize(1), MaxGeometryVerticesOut(0), MaxTextureLODBias(0.f), Version(0), ShaderLanguageVersion(0), OcclusionQuerySupport(false), IsAtiRadeonX(false), pGlActiveTexture(0), pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), @@ -428,8 +428,6 @@ void COpenGLExtensionHandler::initExtensions(video::IContextManager *cmgr, bool if (FeatureAvailable[IRR_EXT_texture_lod_bias]) glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias); #endif - glGetIntegerv(GL_MAX_CLIP_PLANES, &num); - MaxUserClipPlanes = static_cast(num); glGetIntegerv(GL_AUX_BUFFERS, &num); MaxAuxBuffers = static_cast(num); #ifdef GL_ARB_draw_buffers diff --git a/irr/src/COpenGLExtensionHandler.h b/irr/src/COpenGLExtensionHandler.h index ada1c9a3a..cdff911b9 100644 --- a/irr/src/COpenGLExtensionHandler.h +++ b/irr/src/COpenGLExtensionHandler.h @@ -1019,8 +1019,6 @@ public: u8 MaxLights; //! Maximal Anisotropy u8 MaxAnisotropy; - //! Number of user clipplanes - u8 MaxUserClipPlanes; //! Number of auxiliary buffers u8 MaxAuxBuffers; //! Optimal number of indices per meshbuffer diff --git a/irr/src/CSceneManager.cpp b/irr/src/CSceneManager.cpp index b20f6010a..cd88e1a6e 100644 --- a/irr/src/CSceneManager.cpp +++ b/irr/src/CSceneManager.cpp @@ -2,6 +2,8 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h +#include + #include "CSceneManager.h" #include "IVideoDriver.h" #include "IFileSystem.h" @@ -95,9 +97,8 @@ CSceneManager::~CSceneManager() if (CollisionManager) CollisionManager->drop(); - u32 i; - for (i = 0; i < MeshLoaderList.size(); ++i) - MeshLoaderList[i]->drop(); + for (auto *loader : MeshLoaderList) + loader->drop(); if (ActiveCamera) ActiveCamera->drop(); @@ -140,12 +141,11 @@ IAnimatedMesh *CSceneManager::getUncachedMesh(io::IReadFile *file, const io::pat IAnimatedMesh *msh = 0; // iterate the list in reverse order so user-added loaders can override the built-in ones - s32 count = MeshLoaderList.size(); - for (s32 i = count - 1; i >= 0; --i) { - if (MeshLoaderList[i]->isALoadableFileExtension(filename)) { + for (auto it = MeshLoaderList.rbegin(); it != MeshLoaderList.rend(); it++) { + if ((*it)->isALoadableFileExtension(filename)) { // reset file to avoid side effects of previous calls to createMesh file->seek(0); - msh = MeshLoaderList[i]->createMesh(file); + msh = (*it)->createMesh(file); if (msh) { MeshCache->addMesh(cachename, msh); msh->drop(); @@ -388,14 +388,8 @@ u32 CSceneManager::registerNodeForRendering(ISceneNode *node, E_SCENE_NODE_RENDE switch (pass) { // take camera if it is not already registered case ESNRP_CAMERA: { - taken = 1; - for (u32 i = 0; i != CameraList.size(); ++i) { - if (CameraList[i] == node) { - taken = 0; - break; - } - } - if (taken) { + if (std::find(CameraList.begin(), CameraList.end(), node) == CameraList.end()) { + taken = 1; CameraList.push_back(node); } } break; @@ -405,19 +399,19 @@ u32 CSceneManager::registerNodeForRendering(ISceneNode *node, E_SCENE_NODE_RENDE break; case ESNRP_SOLID: if (!isCulled(node)) { - SolidNodeList.push_back(node); + SolidNodeList.emplace_back(node); taken = 1; } break; case ESNRP_TRANSPARENT: if (!isCulled(node)) { - TransparentNodeList.push_back(TransparentNodeEntry(node, camWorldPos)); + TransparentNodeList.emplace_back(node, camWorldPos); taken = 1; } break; case ESNRP_TRANSPARENT_EFFECT: if (!isCulled(node)) { - TransparentEffectNodeList.push_back(TransparentNodeEntry(node, camWorldPos)); + TransparentEffectNodeList.emplace_back(node, camWorldPos); taken = 1; } break; @@ -429,8 +423,7 @@ u32 CSceneManager::registerNodeForRendering(ISceneNode *node, E_SCENE_NODE_RENDE for (u32 i = 0; i < count; ++i) { if (Driver->needsTransparentRenderPass(node->getMaterial(i))) { // register as transparent node - TransparentNodeEntry e(node, camWorldPos); - TransparentNodeList.push_back(e); + TransparentNodeList.emplace_back(node, camWorldPos); taken = 1; break; } @@ -438,7 +431,7 @@ u32 CSceneManager::registerNodeForRendering(ISceneNode *node, E_SCENE_NODE_RENDE // not transparent, register as solid if (!taken) { - SolidNodeList.push_back(node); + SolidNodeList.emplace_back(node); taken = 1; } } @@ -509,10 +502,10 @@ void CSceneManager::drawAll() CurrentRenderPass = ESNRP_CAMERA; Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); - for (i = 0; i < CameraList.size(); ++i) - CameraList[i]->render(); + for (auto *node : CameraList) + node->render(); - CameraList.set_used(0); + CameraList.clear(); } // render skyboxes @@ -520,10 +513,10 @@ void CSceneManager::drawAll() CurrentRenderPass = ESNRP_SKY_BOX; Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); - for (i = 0; i < SkyBoxList.size(); ++i) - SkyBoxList[i]->render(); + for (auto *node : SkyBoxList) + node->render(); - SkyBoxList.set_used(0); + SkyBoxList.clear(); } // render default objects @@ -531,12 +524,12 @@ void CSceneManager::drawAll() CurrentRenderPass = ESNRP_SOLID; Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); - SolidNodeList.sort(); // sort by textures + std::sort(SolidNodeList.begin(), SolidNodeList.end()); - for (i = 0; i < SolidNodeList.size(); ++i) - SolidNodeList[i].Node->render(); + for (auto &it : SolidNodeList) + it.Node->render(); - SolidNodeList.set_used(0); + SolidNodeList.clear(); } // render transparent objects. @@ -544,11 +537,12 @@ void CSceneManager::drawAll() CurrentRenderPass = ESNRP_TRANSPARENT; Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); - TransparentNodeList.sort(); // sort by distance from camera - for (i = 0; i < TransparentNodeList.size(); ++i) - TransparentNodeList[i].Node->render(); + std::sort(TransparentNodeList.begin(), TransparentNodeList.end()); - TransparentNodeList.set_used(0); + for (auto &it : TransparentNodeList) + it.Node->render(); + + TransparentNodeList.clear(); } // render transparent effect objects. @@ -556,12 +550,12 @@ void CSceneManager::drawAll() CurrentRenderPass = ESNRP_TRANSPARENT_EFFECT; Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); - TransparentEffectNodeList.sort(); // sort by distance from camera + std::sort(TransparentEffectNodeList.begin(), TransparentEffectNodeList.end()); - for (i = 0; i < TransparentEffectNodeList.size(); ++i) - TransparentEffectNodeList[i].Node->render(); + for (auto &it : TransparentEffectNodeList) + it.Node->render(); - TransparentEffectNodeList.set_used(0); + TransparentEffectNodeList.clear(); } // render custom gui nodes @@ -569,10 +563,10 @@ void CSceneManager::drawAll() CurrentRenderPass = ESNRP_GUI; Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); - for (i = 0; i < GuiNodeList.size(); ++i) - GuiNodeList[i]->render(); + for (auto *node : GuiNodeList) + node->render(); - GuiNodeList.set_used(0); + GuiNodeList.clear(); } clearDeletionList(); @@ -592,7 +586,7 @@ void CSceneManager::addExternalMeshLoader(IMeshLoader *externalLoader) //! Returns the number of mesh loaders supported by Irrlicht at this time u32 CSceneManager::getMeshLoaderCount() const { - return MeshLoaderList.size(); + return static_cast(MeshLoaderList.size()); } //! Retrieve the given mesh loader @@ -629,12 +623,9 @@ void CSceneManager::addToDeletionQueue(ISceneNode *node) //! clears the deletion list void CSceneManager::clearDeletionList() { - if (DeletionList.empty()) - return; - - for (u32 i = 0; i < DeletionList.size(); ++i) { - DeletionList[i]->remove(); - DeletionList[i]->drop(); + for (auto *node : DeletionList) { + node->remove(); + node->drop(); } DeletionList.clear(); diff --git a/irr/src/CSceneManager.h b/irr/src/CSceneManager.h index 0e27290a8..32df145ec 100644 --- a/irr/src/CSceneManager.h +++ b/irr/src/CSceneManager.h @@ -277,15 +277,15 @@ private: ISceneCollisionManager *CollisionManager; //! render pass lists - core::array CameraList; - core::array SkyBoxList; - core::array SolidNodeList; - core::array TransparentNodeList; - core::array TransparentEffectNodeList; - core::array GuiNodeList; + std::vector CameraList; + std::vector SkyBoxList; + std::vector SolidNodeList; + std::vector TransparentNodeList; + std::vector TransparentEffectNodeList; + std::vector GuiNodeList; - core::array MeshLoaderList; - core::array DeletionList; + std::vector MeshLoaderList; + std::vector DeletionList; //! current active camera ICameraSceneNode *ActiveCamera; diff --git a/irr/src/CXMeshFileLoader.cpp b/irr/src/CXMeshFileLoader.cpp index 5978980f4..4e11fe352 100644 --- a/irr/src/CXMeshFileLoader.cpp +++ b/irr/src/CXMeshFileLoader.cpp @@ -273,12 +273,12 @@ bool CXMeshFileLoader::load(io::IReadFile *file) } if (mesh->TCoords2.size()) { for (i = 0; i != mesh->Buffers.size(); ++i) { - mesh->Buffers[i]->Vertices_2TCoords.reallocate(vCountArray[i]); + mesh->Buffers[i]->Vertices_2TCoords.reserve(vCountArray[i]); mesh->Buffers[i]->VertexType = video::EVT_2TCOORDS; } } else { for (i = 0; i != mesh->Buffers.size(); ++i) - mesh->Buffers[i]->Vertices_Standard.reallocate(vCountArray[i]); + mesh->Buffers[i]->Vertices_Standard.reserve(vCountArray[i]); } verticesLinkIndex.set_used(mesh->Vertices.size()); @@ -291,10 +291,10 @@ bool CXMeshFileLoader::load(io::IReadFile *file) if (mesh->TCoords2.size()) { verticesLinkIndex[i] = buffer->Vertices_2TCoords.size(); - buffer->Vertices_2TCoords.push_back(mesh->Vertices[i]); + buffer->Vertices_2TCoords.emplace_back(mesh->Vertices[i]); // We have a problem with correct tcoord2 handling here // crash fixed for now by checking the values - buffer->Vertices_2TCoords.getLast().TCoords2 = (i < mesh->TCoords2.size()) ? mesh->TCoords2[i] : mesh->Vertices[i].TCoords; + buffer->Vertices_2TCoords.back().TCoords2 = (i < mesh->TCoords2.size()) ? mesh->TCoords2[i] : mesh->Vertices[i].TCoords; } else { verticesLinkIndex[i] = buffer->Vertices_Standard.size(); buffer->Vertices_Standard.push_back(mesh->Vertices[i]); @@ -306,7 +306,7 @@ bool CXMeshFileLoader::load(io::IReadFile *file) for (i = 0; i < mesh->FaceMaterialIndices.size(); ++i) ++vCountArray[mesh->FaceMaterialIndices[i]]; for (i = 0; i != mesh->Buffers.size(); ++i) - mesh->Buffers[i]->Indices.reallocate(vCountArray[i]); + mesh->Buffers[i]->Indices.reserve(vCountArray[i]); delete[] vCountArray; // create indices per buffer for (i = 0; i < mesh->FaceMaterialIndices.size(); ++i) { diff --git a/irr/src/CZipReader.cpp b/irr/src/CZipReader.cpp index b761c72e8..2d2152719 100644 --- a/irr/src/CZipReader.cpp +++ b/irr/src/CZipReader.cpp @@ -325,7 +325,7 @@ bool CZipReader::scanZipHeader(bool ignoreGPBits) dirEnd.Offset = os::Byteswap::byteswap(dirEnd.Offset); dirEnd.CommentLength = os::Byteswap::byteswap(dirEnd.CommentLength); #endif - FileInfo.reallocate(dirEnd.TotalEntries); + FileInfo.reserve(dirEnd.TotalEntries); File->seek(dirEnd.Offset); while (scanCentralDirectoryHeader()) { } @@ -381,9 +381,10 @@ bool CZipReader::scanCentralDirectoryHeader() File->seek(entry.RelativeOffsetOfLocalHeader); scanZipHeader(true); File->seek(pos + entry.FilenameLength + entry.ExtraFieldLength + entry.FileCommentLength); - FileInfo.getLast().header.DataDescriptor.CompressedSize = entry.CompressedSize; - FileInfo.getLast().header.DataDescriptor.UncompressedSize = entry.UncompressedSize; - FileInfo.getLast().header.DataDescriptor.CRC32 = entry.CRC32; + auto &lastInfo = FileInfo.back(); + lastInfo.header.DataDescriptor.CompressedSize = entry.CompressedSize; + lastInfo.header.DataDescriptor.UncompressedSize = entry.UncompressedSize; + lastInfo.header.DataDescriptor.CRC32 = entry.CRC32; Files.getLast().Size = entry.UncompressedSize; return true; } diff --git a/irr/src/CZipReader.h b/irr/src/CZipReader.h index d9afd668a..b520c2030 100644 --- a/irr/src/CZipReader.h +++ b/irr/src/CZipReader.h @@ -4,8 +4,8 @@ #pragma once +#include #include "IReadFile.h" -#include "irrArray.h" #include "irrString.h" #include "IFileSystem.h" #include "CFileList.h" @@ -209,7 +209,7 @@ protected: IReadFile *File; // holds extended info about files - core::array FileInfo; + std::vector FileInfo; bool IsGZip; }; diff --git a/irr/src/IAttribute.h b/irr/src/IAttribute.h index b0dc76eee..23352a623 100644 --- a/irr/src/IAttribute.h +++ b/irr/src/IAttribute.h @@ -4,15 +4,8 @@ #pragma once -#include "IReferenceCounted.h" -#include "SColor.h" -#include "vector3d.h" -#include "vector2d.h" -#include "position2d.h" -#include "rect.h" -#include "dimension2d.h" +#include "irrTypes.h" #include "irrString.h" -#include "irrArray.h" #include "EAttributes.h" namespace irr @@ -20,16 +13,7 @@ namespace irr namespace io { -// All derived attribute types implement at least getter/setter for their own type (like CBoolAttribute will have setBool/getBool). -// Simple types will also implement getStringW and setString, but don't expect it to work for all types. -// String serialization makes no sense for some attribute-types (like stringw arrays or pointers), but is still useful for many types. -// (Note: I do _not_ know yet why the default string serialization is asymmetric with char* in set and wchar_t* in get). -// Additionally many attribute types will implement conversion functions like CBoolAttribute has p.E. getInt/setInt(). -// The reason for conversion functions is likely to make reading old formats easier which have changed in the meantime. For example -// an old xml can contain a bool attribute which is an int in a newer format. You can still call getInt() even thought the attribute has the wrong type. -// And please do _not_ confuse these attributes here with the ones used in the xml-reader (aka SAttribute which is just a key-value pair). - -class IAttribute : public virtual IReferenceCounted +class IAttribute { public: virtual ~IAttribute(){}; diff --git a/irr/src/OpenGL/Driver.cpp b/irr/src/OpenGL/Driver.cpp index 95d760548..1defa9abc 100644 --- a/irr/src/OpenGL/Driver.cpp +++ b/irr/src/OpenGL/Driver.cpp @@ -257,7 +257,6 @@ bool COpenGL3DriverBase::genericDriverInit(const core::dimension2d &screenS DriverAttributes->setAttribute("MaxSupportedTextures", (s32)Feature.MaxTextureUnits); // DriverAttributes->setAttribute("MaxLights", MaxLights); DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy); - // DriverAttributes->setAttribute("MaxUserClipPlanes", MaxUserClipPlanes); // DriverAttributes->setAttribute("MaxAuxBuffers", MaxAuxBuffers); // DriverAttributes->setAttribute("MaxMultipleRenderTargets", MaxMultipleRenderTargets); DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices); @@ -268,8 +267,6 @@ bool COpenGL3DriverBase::genericDriverInit(const core::dimension2d &screenS GL.PixelStorei(GL_PACK_ALIGNMENT, 1); - UserClipPlane.reallocate(0); - for (s32 i = 0; i < ETS_COUNT; ++i) setTransform(static_cast(i), core::IdentityMatrix); @@ -916,7 +913,8 @@ void COpenGL3DriverBase::draw2DImageBatch(const video::ITexture *texture, const irr::u32 drawCount = core::min_(positions.size(), sourceRects.size()); assert(6 * drawCount <= QuadIndexCount); // FIXME split the batch? or let it crash? - core::array vtx(drawCount * 4); + std::vector vtx; + vtx.reserve(drawCount * 4); for (u32 i = 0; i < drawCount; i++) { core::position2d targetPos = positions[i]; @@ -939,22 +937,22 @@ void COpenGL3DriverBase::draw2DImageBatch(const video::ITexture *texture, f32 down = 2.f - (f32)poss.LowerRightCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; f32 top = 2.f - (f32)poss.UpperLeftCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; - vtx.push_back(S3DVertex(left, top, 0.0f, + vtx.emplace_back(left, top, 0.0f, 0.0f, 0.0f, 0.0f, color, - tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y)); - vtx.push_back(S3DVertex(right, top, 0.0f, + tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + vtx.emplace_back(right, top, 0.0f, 0.0f, 0.0f, 0.0f, color, - tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y)); - vtx.push_back(S3DVertex(right, down, 0.0f, + tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + vtx.emplace_back(right, down, 0.0f, 0.0f, 0.0f, 0.0f, color, - tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y)); - vtx.push_back(S3DVertex(left, down, 0.0f, + tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + vtx.emplace_back(left, down, 0.0f, 0.0f, 0.0f, 0.0f, color, - tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y)); + tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); } GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, QuadIndexBuffer); - drawElements(GL_TRIANGLES, vt2DImage, vtx.const_pointer(), vtx.size(), 0, 6 * drawCount); + drawElements(GL_TRIANGLES, vt2DImage, vtx.data(), vtx.size(), 0, 6 * drawCount); GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); if (clipRect) @@ -1104,15 +1102,14 @@ void COpenGL3DriverBase::endDraw(const VertexType &vertexType) ITexture *COpenGL3DriverBase::createDeviceDependentTexture(const io::path &name, IImage *image) { - core::array imageArray(1); - imageArray.push_back(image); + std::vector tmp { image }; - COpenGL3Texture *texture = new COpenGL3Texture(name, imageArray, ETT_2D, this); + COpenGL3Texture *texture = new COpenGL3Texture(name, tmp, ETT_2D, this); return texture; } -ITexture *COpenGL3DriverBase::createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) +ITexture *COpenGL3DriverBase::createDeviceDependentTextureCubemap(const io::path &name, const std::vector &image) { COpenGL3Texture *texture = new COpenGL3Texture(name, image, ETT_CUBEMAP, this); @@ -1876,40 +1873,6 @@ void COpenGL3DriverBase::removeTexture(ITexture *texture) CNullDriver::removeTexture(texture); } -//! Set/unset a clipping plane. -bool COpenGL3DriverBase::setClipPlane(u32 index, const core::plane3df &plane, bool enable) -{ - if (index >= UserClipPlane.size()) - UserClipPlane.push_back(SUserClipPlane()); - - UserClipPlane[index].Plane = plane; - UserClipPlane[index].Enabled = enable; - return true; -} - -//! Enable/disable a clipping plane. -void COpenGL3DriverBase::enableClipPlane(u32 index, bool enable) -{ - UserClipPlane[index].Enabled = enable; -} - -//! Get the ClipPlane Count -u32 COpenGL3DriverBase::getClipPlaneCount() const -{ - return UserClipPlane.size(); -} - -const core::plane3df &COpenGL3DriverBase::getClipPlane(irr::u32 index) const -{ - if (index < UserClipPlane.size()) - return UserClipPlane[index].Plane; - else { - _IRR_DEBUG_BREAK_IF(true) // invalid index - static const core::plane3df dummy; - return dummy; - } -} - core::dimension2du COpenGL3DriverBase::getMaxTextureSize() const { return core::dimension2du(MaxTextureSize, MaxTextureSize); diff --git a/irr/src/OpenGL/Driver.h b/irr/src/OpenGL/Driver.h index 51554334b..be4e4db9e 100644 --- a/irr/src/OpenGL/Driver.h +++ b/irr/src/OpenGL/Driver.h @@ -7,7 +7,6 @@ #pragma once #include "SIrrCreationParameters.h" - #include "Common.h" #include "CNullDriver.h" #include "IMaterialRendererServices.h" @@ -227,18 +226,6 @@ public: // Does *nothing* unless in debug mode. bool testGLError(const char *file, int line); - //! Set/unset a clipping plane. - bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) override; - - //! returns the current amount of user clip planes set. - u32 getClipPlaneCount() const; - - //! returns the 0 indexed Plane - const core::plane3df &getClipPlane(u32 index) const; - - //! Enable/disable a clipping plane. - void enableClipPlane(u32 index, bool enable) override; - //! Returns the graphics card vendor name. core::stringc getVendorInfo() override { @@ -278,7 +265,7 @@ protected: ITexture *createDeviceDependentTexture(const io::path &name, IImage *image) override; - ITexture *createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) override; + ITexture *createDeviceDependentTextureCubemap(const io::path &name, const std::vector &image) override; //! Map Irrlicht wrap mode to OpenGL enum GLint getTextureWrapMode(u8 clamp) const; @@ -337,14 +324,6 @@ protected: bool LockRenderStateMode; u8 AntiAlias; - struct SUserClipPlane - { - core::plane3df Plane; - bool Enabled; - }; - - core::array UserClipPlane; - core::matrix4 TextureFlipMatrix; using FColorConverter = void (*)(const void *source, s32 count, void *dest); diff --git a/irr/src/OpenGL/MaterialRenderer.cpp b/irr/src/OpenGL/MaterialRenderer.cpp index 51a796d48..3c32ba318 100644 --- a/irr/src/OpenGL/MaterialRenderer.cpp +++ b/irr/src/OpenGL/MaterialRenderer.cpp @@ -262,35 +262,30 @@ bool COpenGL3MaterialRenderer::linkProgram() // seems that some implementations use an extra null terminator. ++maxlen; - c8 *buf = new c8[maxlen]; + std::vector buf(maxlen); UniformInfo.clear(); - UniformInfo.reallocate(num); + UniformInfo.reserve(num); for (GLint i = 0; i < num; ++i) { SUniformInfo ui; - memset(buf, 0, maxlen); + memset(buf.data(), 0, buf.size()); GLint size; - GL.GetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast(buf)); - - core::stringc name = ""; + GL.GetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast(buf.data())); // array support, workaround for some bugged drivers. for (s32 i = 0; i < maxlen; ++i) { if (buf[i] == '[' || buf[i] == '\0') break; - name += buf[i]; + ui.name += buf[i]; } - ui.name = name; - ui.location = GL.GetUniformLocation(Program, buf); + ui.location = GL.GetUniformLocation(Program, buf.data()); - UniformInfo.push_back(ui); + UniformInfo.push_back(std::move(ui)); } - - delete[] buf; } return true; diff --git a/irr/src/OpenGL/MaterialRenderer.h b/irr/src/OpenGL/MaterialRenderer.h index fa37cfff3..fca71478a 100644 --- a/irr/src/OpenGL/MaterialRenderer.h +++ b/irr/src/OpenGL/MaterialRenderer.h @@ -4,12 +4,12 @@ #pragma once +#include +#include #include "EMaterialTypes.h" #include "IMaterialRenderer.h" #include "IMaterialRendererServices.h" #include "IGPUProgrammingServices.h" -#include "irrArray.h" -#include "irrString.h" #include "Common.h" @@ -79,13 +79,13 @@ protected: struct SUniformInfo { - core::stringc name; + std::string name; GLenum type; GLint location; }; GLuint Program; - core::array UniformInfo; + std::vector UniformInfo; s32 UserData; }; diff --git a/src/client/clouds.cpp b/src/client/clouds.cpp index d53d52957..ebb8b9000 100644 --- a/src/client/clouds.cpp +++ b/src/client/clouds.cpp @@ -184,15 +184,15 @@ void Clouds::updateMesh() const u32 index_count = quad_count * 6; // reserve memory - mb->Vertices.reallocate(vertex_count); - mb->Indices.reallocate(index_count); + mb->Vertices.reserve(vertex_count); + mb->Indices.reserve(index_count); } #define GETINDEX(x, z, radius) (((z)+(radius))*(radius)*2 + (x)+(radius)) #define INAREA(x, z, radius) \ ((x) >= -(radius) && (x) < (radius) && (z) >= -(radius) && (z) < (radius)) - mb->Vertices.set_used(0); + mb->Vertices.clear(); for (s16 zi0= -m_cloud_radius_i; zi0 < m_cloud_radius_i; zi0++) for (s16 xi0= -m_cloud_radius_i; xi0 < m_cloud_radius_i; xi0++) { @@ -322,7 +322,7 @@ void Clouds::updateMesh() const u32 index_count = quad_count * 6; // rewrite index array as needed if (mb->getIndexCount() > index_count) { - mb->Indices.set_used(index_count); + mb->Indices.resize(index_count); mb->setDirty(scene::EBT_INDEX); } else if (mb->getIndexCount() < index_count) { const u32 start = mb->getIndexCount() / 6; diff --git a/src/client/hud.cpp b/src/client/hud.cpp index 3a0e25a07..962818b8f 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -119,27 +119,28 @@ Hud::Hud(Client *client, LocalPlayer *player, } // Prepare mesh for compass drawing - m_rotation_mesh_buffer.Vertices.set_used(4); - m_rotation_mesh_buffer.Indices.set_used(6); + auto &b = m_rotation_mesh_buffer; + b.Vertices.resize(4); + b.Indices.resize(6); video::SColor white(255, 255, 255, 255); v3f normal(0.f, 0.f, 1.f); - m_rotation_mesh_buffer.Vertices[0] = video::S3DVertex(v3f(-1.f, -1.f, 0.f), normal, white, v2f(0.f, 1.f)); - m_rotation_mesh_buffer.Vertices[1] = video::S3DVertex(v3f(-1.f, 1.f, 0.f), normal, white, v2f(0.f, 0.f)); - m_rotation_mesh_buffer.Vertices[2] = video::S3DVertex(v3f( 1.f, 1.f, 0.f), normal, white, v2f(1.f, 0.f)); - m_rotation_mesh_buffer.Vertices[3] = video::S3DVertex(v3f( 1.f, -1.f, 0.f), normal, white, v2f(1.f, 1.f)); + b.Vertices[0] = video::S3DVertex(v3f(-1.f, -1.f, 0.f), normal, white, v2f(0.f, 1.f)); + b.Vertices[1] = video::S3DVertex(v3f(-1.f, 1.f, 0.f), normal, white, v2f(0.f, 0.f)); + b.Vertices[2] = video::S3DVertex(v3f( 1.f, 1.f, 0.f), normal, white, v2f(1.f, 0.f)); + b.Vertices[3] = video::S3DVertex(v3f( 1.f, -1.f, 0.f), normal, white, v2f(1.f, 1.f)); - m_rotation_mesh_buffer.Indices[0] = 0; - m_rotation_mesh_buffer.Indices[1] = 1; - m_rotation_mesh_buffer.Indices[2] = 2; - m_rotation_mesh_buffer.Indices[3] = 2; - m_rotation_mesh_buffer.Indices[4] = 3; - m_rotation_mesh_buffer.Indices[5] = 0; + b.Indices[0] = 0; + b.Indices[1] = 1; + b.Indices[2] = 2; + b.Indices[3] = 2; + b.Indices[4] = 3; + b.Indices[5] = 0; - m_rotation_mesh_buffer.getMaterial().Lighting = false; - m_rotation_mesh_buffer.getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - m_rotation_mesh_buffer.setHardwareMappingHint(scene::EHM_STATIC); + b.getMaterial().Lighting = false; + b.getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + b.setHardwareMappingHint(scene::EHM_STATIC); } void Hud::readScalingSetting() diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 429464e04..9b5612148 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -602,7 +602,7 @@ void PartialMeshBuffer::beforeDraw() const void PartialMeshBuffer::afterDraw() const { // Take the data back - m_vertex_indexes = m_buffer->Indices.steal(); + m_vertex_indexes = std::move(m_buffer->Indices); } /* diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index afac89843..9f1f04359 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -555,8 +555,8 @@ v3f Minimap::getYawVec() scene::SMeshBuffer *Minimap::getMinimapMeshBuffer() { scene::SMeshBuffer *buf = new scene::SMeshBuffer(); - buf->Vertices.set_used(4); - buf->Indices.set_used(6); + buf->Vertices.resize(4); + buf->Indices.resize(6); static const video::SColor c(255, 255, 255, 255); buf->Vertices[0] = video::S3DVertex(-1, -1, 0, 0, 0, 1, c, 0, 1); diff --git a/src/client/sky.cpp b/src/client/sky.cpp index 92e5df218..c68d13984 100644 --- a/src/client/sky.cpp +++ b/src/client/sky.cpp @@ -830,8 +830,8 @@ void Sky::updateStars() warningstream << "Requested " << m_star_params.count << " stars but " << 0x4000 << " is the max\n"; m_star_params.count = 0x4000; } - m_stars->Vertices.reallocate(4 * m_star_params.count); - m_stars->Indices.reallocate(6 * m_star_params.count); + m_stars->Vertices.reserve(4 * m_star_params.count); + m_stars->Indices.reserve(6 * m_star_params.count); video::SColor fallback_color = m_star_params.starcolor; // used on GLES 2 “without shaders” PcgRandom rgen(m_seed);