mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
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:
parent
5acc2736db
commit
5d226268df
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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue