Irrlicht cleanups (mostly getting rid of core::array)

Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
This commit is contained in:
sfan5 2024-08-17 19:49:11 +02:00 committed by GitHub
parent 5acc2736db
commit 5d226268df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
45 changed files with 308 additions and 1227 deletions

@ -4,7 +4,7 @@
#pragma once
#include "irrArray.h"
#include <vector>
#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<u32>(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<u32>(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<const T *>(vertices)[i]);
BoundingBox.addInternalPoint(static_cast<const T *>(vertices)[i].Pos);
}
auto *vt = static_cast<const T *>(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<T> Vertices;
std::vector<T> Vertices;
//! Indices into the vertices of this buffer.
core::array<u16> Indices;
std::vector<u16> Indices;
//! Bounding box of this meshbuffer.
core::aabbox3d<f32> BoundingBox;
//! Primitive type used for rendering (triangles, lines, ...)

@ -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

@ -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. */

@ -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"

@ -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;

@ -4,10 +4,10 @@
#pragma once
#include <vector>
#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<u32>(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<IMesh *> Meshes;
std::vector<IMesh *> Meshes;
//! The bounding box of this mesh
core::aabbox3d<f32> Box;

@ -6,7 +6,6 @@
#include "SColor.h"
#include "matrix4.h"
#include "irrArray.h"
#include "irrMath.h"
#include "EMaterialTypes.h"
#include "EMaterialProps.h"

@ -4,10 +4,10 @@
#pragma once
#include <vector>
#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<u32>(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<IMeshBuffer *> MeshBuffers;
std::vector<IMeshBuffer *> MeshBuffers;
//! The bounding box of this mesh
core::aabbox3d<f32> BoundingBox;

@ -4,6 +4,7 @@
#pragma once
#include <vector>
#include "SMaterial.h"
namespace irr
@ -57,7 +58,7 @@ struct SOverrideMaterial
};
//! To overwrite SMaterial::MaterialType
core::array<SMaterialTypeReplacement> MaterialTypes;
std::vector<SMaterialTypeReplacement> 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) {

@ -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<u32>(Vertices_2TCoords.size());
case video::EVT_TANGENTS:
return Vertices_Tangents.size();
return static_cast<u32>(Vertices_Tangents.size());
default:
return Vertices_Standard.size();
return static_cast<u32>(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<u32>(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<video::S3DVertexTangents> Vertices_Tangents;
core::array<video::S3DVertex2TCoords> Vertices_2TCoords;
core::array<video::S3DVertex> Vertices_Standard;
core::array<u16> Indices;
std::vector<video::S3DVertexTangents> Vertices_Tangents;
std::vector<video::S3DVertex2TCoords> Vertices_2TCoords;
std::vector<video::S3DVertex> Vertices_Standard;
std::vector<u16> 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;
};

@ -167,13 +167,6 @@ public:
return *this;
}
array<T> &operator=(std::vector<T> &&other)
{
m_data = std::move(other);
is_sorted = false;
return *this;
}
//! Equality operator
bool operator==(const array<T> &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<T> steal()
{
std::vector<T> ret = std::move(m_data);
m_data.clear();
is_sorted = true;
return ret;
}
typedef T value_type;
typedef u32 size_type;

@ -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
{

@ -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

@ -4,16 +4,14 @@
#pragma once
#include <map>
#include <string>
#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<IAttribute *> Attributes;
typedef std::basic_string<c8> 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<string, IAttribute*, std::less<>> Attributes;
};
} // end namespace io

@ -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
{

@ -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<video::S3DVertex> &vertices = Buffer->Vertices;
auto *vertices = Buffer->Vertices.data();
for (s32 i = 0; i < 4; ++i)
vertices[i].Normal = view;

@ -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)

@ -4,8 +4,8 @@
#pragma once
#include <vector>
#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<IArchiveLoader *> ArchiveLoader;
//! currently attached Archives
core::array<IFileArchive *> FileArchives;
std::vector<IArchiveLoader *> ArchiveLoader;
};
} // end namespace irr

@ -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<const video::S3DVertex*>(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<const video::S3DVertex2TCoords*>(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<const video::S3DVertexTangents*>(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;

@ -64,7 +64,6 @@ CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d<u32> &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<IImage *> imageArray(6);
std::vector<IImage*> 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<IImage *> imageArray(6);
std::vector<IImage*> 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<IImage *> &image)
ITexture *CNullDriver::createDeviceDependentTextureCubemap(const io::path &name, const std::vector<IImage*> &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<IImage *> &image) const
bool CNullDriver::checkImage(const std::vector<IImage*> &image) const
{
if (!image.size())
if (image.empty())
return false;
ECOLOR_FORMAT lastFormat = image[0]->getColorFormat();
core::dimension2d<u32> 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<u32> 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<u32>
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;

@ -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<IImage *> &image);
virtual ITexture *createDeviceDependentTextureCubemap(const io::path &name, const std::vector<IImage*> &image);
//! checks triangle count and print warning if wrong
bool checkPrimitiveCount(u32 prmcnt) const;
bool checkImage(IImage *image) const;
bool checkImage(const core::array<IImage *> &image) const;
bool checkImage(const std::vector<IImage*> &image) const;
// adds a material renderer and drops it afterwards. To be used for internal creation
s32 addAndDropMaterialRenderer(IMaterialRenderer *m);

@ -103,14 +103,6 @@ bool COGLES1Driver::genericDriverInit(const core::dimension2d<u32> &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<E_TRANSFORMATION_STATE>(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<IImage *> imageArray(1);
imageArray.push_back(image);
std::vector<IImage*> 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<IImage *> &image)
ITexture *COGLES1Driver::createDeviceDependentTextureCubemap(const io::path &name, const std::vector<IImage *> &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);

@ -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<u32> &screenSize, bool stencilBuffer);
ITexture *createDeviceDependentTexture(const io::path &name, IImage *image) override;
ITexture *createDeviceDependentTextureCubemap(const io::path &name, const core::array<IImage *> &image) override;
ITexture *createDeviceDependentTextureCubemap(const io::path &name, const std::vector<IImage*> &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<core::plane3df> UserClipPlane;
std::vector<bool> UserClipPlaneEnabled;
core::stringc VendorName;

@ -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<u8>(val);
}
glGetIntegerv(GL_MAX_LIGHTS, &val);
MaxLights = static_cast<u8>(val);

@ -171,7 +171,6 @@ public:
}
protected:
u8 MaxUserClipPlanes;
u8 MaxLights;
PFNGLBLENDEQUATIONOESPROC pGlBlendEquationOES;

@ -4,7 +4,7 @@
#pragma once
#include "irrArray.h"
#include <vector>
#include "SMaterialLayer.h"
#include "ITexture.h"
#include "EDriverFeatures.h"
@ -43,19 +43,19 @@ public:
bool IsCached;
};
COpenGLCoreTexture(const io::path &name, const core::array<IImage *> &images, E_TEXTURE_TYPE type, TOpenGLDriver *driver) :
COpenGLCoreTexture(const io::path &name, const std::vector<IImage *> &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<IImage *> *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<IImage *> Images;
std::vector<IImage*> Images;
u8 MipLevelStored;
bool LegacyAutoGenerateMipMaps;

@ -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<E_TRANSFORMATION_STATE>(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<IImage *> 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<IImage *> &image)
ITexture *COpenGLDriver::createDeviceDependentTextureCubemap(const io::path &name, const std::vector<IImage *> &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);

@ -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<IImage *> &image) override;
ITexture *createDeviceDependentTextureCubemap(const io::path &name, const std::vector<IImage *> &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<SUserClipPlane> UserClipPlanes;
core::stringc VendorName;
core::matrix4 TextureFlipMatrix;

@ -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<u8>(num);
glGetIntegerv(GL_AUX_BUFFERS, &num);
MaxAuxBuffers = static_cast<u8>(num);
#ifdef GL_ARB_draw_buffers

@ -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

@ -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 <algorithm>
#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<u32>(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();

@ -277,15 +277,15 @@ private:
ISceneCollisionManager *CollisionManager;
//! render pass lists
core::array<ISceneNode *> CameraList;
core::array<ISceneNode *> SkyBoxList;
core::array<DefaultNodeEntry> SolidNodeList;
core::array<TransparentNodeEntry> TransparentNodeList;
core::array<TransparentNodeEntry> TransparentEffectNodeList;
core::array<ISceneNode *> GuiNodeList;
std::vector<ISceneNode *> CameraList;
std::vector<ISceneNode *> SkyBoxList;
std::vector<DefaultNodeEntry> SolidNodeList;
std::vector<TransparentNodeEntry> TransparentNodeList;
std::vector<TransparentNodeEntry> TransparentEffectNodeList;
std::vector<ISceneNode *> GuiNodeList;
core::array<IMeshLoader *> MeshLoaderList;
core::array<ISceneNode *> DeletionList;
std::vector<IMeshLoader *> MeshLoaderList;
std::vector<ISceneNode *> DeletionList;
//! current active camera
ICameraSceneNode *ActiveCamera;

@ -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) {

@ -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;
}

@ -4,8 +4,8 @@
#pragma once
#include <vector>
#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<SZipFileEntry> FileInfo;
std::vector<SZipFileEntry> FileInfo;
bool IsGZip;
};

@ -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(){};

@ -257,7 +257,6 @@ bool COpenGL3DriverBase::genericDriverInit(const core::dimension2d<u32> &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<u32> &screenS
GL.PixelStorei(GL_PACK_ALIGNMENT, 1);
UserClipPlane.reallocate(0);
for (s32 i = 0; i < ETS_COUNT; ++i)
setTransform(static_cast<E_TRANSFORMATION_STATE>(i), core::IdentityMatrix);
@ -916,7 +913,8 @@ void COpenGL3DriverBase::draw2DImageBatch(const video::ITexture *texture,
const irr::u32 drawCount = core::min_<u32>(positions.size(), sourceRects.size());
assert(6 * drawCount <= QuadIndexCount); // FIXME split the batch? or let it crash?
core::array<S3DVertex> vtx(drawCount * 4);
std::vector<S3DVertex> vtx;
vtx.reserve(drawCount * 4);
for (u32 i = 0; i < drawCount; i++) {
core::position2d<s32> 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<IImage *> imageArray(1);
imageArray.push_back(image);
std::vector<IImage*> 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<IImage *> &image)
ITexture *COpenGL3DriverBase::createDeviceDependentTextureCubemap(const io::path &name, const std::vector<IImage*> &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);

@ -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<IImage *> &image) override;
ITexture *createDeviceDependentTextureCubemap(const io::path &name, const std::vector<IImage*> &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<SUserClipPlane> UserClipPlane;
core::matrix4 TextureFlipMatrix;
using FColorConverter = void (*)(const void *source, s32 count, void *dest);

@ -262,35 +262,30 @@ bool COpenGL3MaterialRenderer::linkProgram()
// seems that some implementations use an extra null terminator.
++maxlen;
c8 *buf = new c8[maxlen];
std::vector<c8> 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<GLchar *>(buf));
core::stringc name = "";
GL.GetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast<GLchar *>(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;

@ -4,12 +4,12 @@
#pragma once
#include <string>
#include <vector>
#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<SUniformInfo> UniformInfo;
std::vector<SUniformInfo> UniformInfo;
s32 UserData;
};

@ -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;

@ -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()

@ -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);
}
/*

@ -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);

@ -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);