Remove irrMap and use std::map instead

This commit is contained in:
paradust7 2022-05-09 06:00:12 +00:00 committed by sfan5
parent 51ae495c4a
commit 00a7741cd4
9 changed files with 51 additions and 1136 deletions

File diff suppressed because it is too large Load Diff

@ -113,7 +113,6 @@
#include "IRenderTarget.h"
#include "IrrlichtDevice.h"
#include "irrList.h"
#include "irrMap.h"
#include "irrMath.h"
#include "irrString.h"
#include "irrTypes.h"

@ -14,7 +14,6 @@
#include "IMeshBuffer.h"
#include "IWriteFile.h"
#include "ITexture.h"
#include "irrMap.h"
namespace irr
@ -60,7 +59,7 @@ bool CB3DMeshWriter::writeMesh(io::IWriteFile* file, IMesh* const mesh, s32 flag
const u32 numMeshBuffers = mesh->getMeshBufferCount();
array<SB3dTexture> texs;
map<ITexture *, u32> tex2id; // TODO: texture pointer as key not sufficient as same texture can have several id's
std::map<ITexture *, u32> tex2id; // TODO: texture pointer as key not sufficient as same texture can have several id's
u32 texsizes = 0;
for (u32 i = 0; i < numMeshBuffers; i++)
{

@ -165,7 +165,7 @@ bool CGUIFont::load(io::IXMLReader* xml, const io::path& directory)
}
rectangle.LowerRightCorner.Y = val;
CharacterMap.insert(ch,Areas.size());
CharacterMap.emplace(ch, Areas.size());
// make frame
f.rectNumber = SpriteBank->getPositions().size();
@ -374,7 +374,7 @@ void CGUIFont::readPositions(video::IImage* image, s32& lowerRightPositions)
Areas.push_back(a);
// map letter to character
wchar_t ch = (wchar_t)(lowerRightPositions + 32);
CharacterMap.set(ch, lowerRightPositions);
CharacterMap[ch] = lowerRightPositions;
++lowerRightPositions;
}
@ -435,9 +435,9 @@ u32 CGUIFont::getSpriteNoFromChar(const wchar_t *c) const
s32 CGUIFont::getAreaFromCharacter(const wchar_t c) const
{
core::map<wchar_t, s32>::Node* n = CharacterMap.find(c);
if (n)
return n->getValue();
auto n = CharacterMap.find(c);
if (n != CharacterMap.end())
return n->second;
else
return WrongCharacter;
}

@ -10,9 +10,9 @@
#include "IGUIFontBitmap.h"
#include "irrString.h"
#include "irrMap.h"
#include "IReadFile.h"
#include "irrArray.h"
#include <map>
namespace irr
{
@ -97,7 +97,7 @@ private:
void popTextureCreationFlags(const bool(&flags)[3]);
core::array<SFontArea> Areas;
core::map<wchar_t, s32> CharacterMap;
std::map<wchar_t, s32> CharacterMap;
video::IVideoDriver* Driver;
IGUISpriteBank* SpriteBank;
IGUIEnvironment* Environment;

@ -8,8 +8,8 @@
#include "CMeshBuffer.h"
#include "SAnimatedMesh.h"
#include "os.h"
#include "irrMap.h"
#include "triangle3d.h"
#include <map>
namespace irr
{
@ -1789,8 +1789,8 @@ IMesh* CMeshManipulator::createForsythOptimizedMesh(const IMesh *mesh) const
buf->Vertices.reallocate(vcount);
buf->Indices.reallocate(icount);
core::map<const video::S3DVertex, const u16> sind; // search index for fast operation
typedef core::map<const video::S3DVertex, const u16>::Node snode;
std::map<const video::S3DVertex, const u16> sind; // search index for fast operation
typedef std::map<const video::S3DVertex, const u16>::iterator snode;
// Main algorithm
u32 highest = 0;
@ -1820,45 +1820,45 @@ IMesh* CMeshManipulator::createForsythOptimizedMesh(const IMesh *mesh) const
// Output the best triangle
u16 newind = buf->Vertices.size();
snode *s = sind.find(v[tc[highest].ind[0]]);
snode s = sind.find(v[tc[highest].ind[0]]);
if (!s)
if (s == sind.end())
{
buf->Vertices.push_back(v[tc[highest].ind[0]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[0]], newind);
sind.emplace(v[tc[highest].ind[0]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
buf->Indices.push_back(s->second);
}
s = sind.find(v[tc[highest].ind[1]]);
if (!s)
if (s == sind.end())
{
buf->Vertices.push_back(v[tc[highest].ind[1]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[1]], newind);
sind.emplace(v[tc[highest].ind[1]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
buf->Indices.push_back(s->second);
}
s = sind.find(v[tc[highest].ind[2]]);
if (!s)
if (s == sind.end())
{
buf->Vertices.push_back(v[tc[highest].ind[2]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[2]], newind);
sind.emplace(v[tc[highest].ind[2]], newind);
}
else
{
buf->Indices.push_back(s->getValue());
buf->Indices.push_back(s->second);
}
vc[tc[highest].ind[0]].NumActiveTris--;
@ -1901,8 +1901,8 @@ IMesh* CMeshManipulator::createForsythOptimizedMesh(const IMesh *mesh) const
buf->Vertices.reallocate(vcount);
buf->Indices.reallocate(icount);
core::map<const video::S3DVertex2TCoords, const u16> sind; // search index for fast operation
typedef core::map<const video::S3DVertex2TCoords, const u16>::Node snode;
std::map<const video::S3DVertex2TCoords, const u16> sind; // search index for fast operation
typedef std::map<const video::S3DVertex2TCoords, const u16>::iterator snode;
// Main algorithm
u32 highest = 0;
@ -1932,45 +1932,45 @@ IMesh* CMeshManipulator::createForsythOptimizedMesh(const IMesh *mesh) const
// Output the best triangle
u16 newind = buf->Vertices.size();
snode *s = sind.find(v[tc[highest].ind[0]]);
snode s = sind.find(v[tc[highest].ind[0]]);
if (!s)
if (s == sind.end())
{
buf->Vertices.push_back(v[tc[highest].ind[0]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[0]], newind);
sind.emplace(v[tc[highest].ind[0]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
buf->Indices.push_back(s->second);
}
s = sind.find(v[tc[highest].ind[1]]);
if (!s)
if (s == sind.end())
{
buf->Vertices.push_back(v[tc[highest].ind[1]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[1]], newind);
sind.emplace(v[tc[highest].ind[1]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
buf->Indices.push_back(s->second);
}
s = sind.find(v[tc[highest].ind[2]]);
if (!s)
if (s == sind.end())
{
buf->Vertices.push_back(v[tc[highest].ind[2]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[2]], newind);
sind.emplace(v[tc[highest].ind[2]], newind);
}
else
{
buf->Indices.push_back(s->getValue());
buf->Indices.push_back(s->second);
}
vc[tc[highest].ind[0]].NumActiveTris--;
@ -2014,8 +2014,8 @@ IMesh* CMeshManipulator::createForsythOptimizedMesh(const IMesh *mesh) const
buf->Vertices.reallocate(vcount);
buf->Indices.reallocate(icount);
core::map<const video::S3DVertexTangents, const u16> sind; // search index for fast operation
typedef core::map<const video::S3DVertexTangents, const u16>::Node snode;
std::map<const video::S3DVertexTangents, const u16> sind; // search index for fast operation
typedef std::map<const video::S3DVertexTangents, const u16>::iterator snode;
// Main algorithm
u32 highest = 0;
@ -2045,45 +2045,45 @@ IMesh* CMeshManipulator::createForsythOptimizedMesh(const IMesh *mesh) const
// Output the best triangle
u16 newind = buf->Vertices.size();
snode *s = sind.find(v[tc[highest].ind[0]]);
snode s = sind.find(v[tc[highest].ind[0]]);
if (!s)
if (s == sind.end())
{
buf->Vertices.push_back(v[tc[highest].ind[0]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[0]], newind);
sind.emplace(v[tc[highest].ind[0]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
buf->Indices.push_back(s->second);
}
s = sind.find(v[tc[highest].ind[1]]);
if (!s)
if (s == sind.end())
{
buf->Vertices.push_back(v[tc[highest].ind[1]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[1]], newind);
sind.emplace(v[tc[highest].ind[1]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
buf->Indices.push_back(s->second);
}
s = sind.find(v[tc[highest].ind[2]]);
if (!s)
if (s == sind.end())
{
buf->Vertices.push_back(v[tc[highest].ind[2]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[2]], newind);
sind.emplace(v[tc[highest].ind[2]], newind);
}
else
{
buf->Indices.push_back(s->getValue());
buf->Indices.push_back(s->second);
}
vc[tc[highest].ind[0]].NumActiveTris--;

@ -11,7 +11,6 @@
#include "IGPUProgrammingServices.h"
#include "irrArray.h"
#include "irrString.h"
#include "irrMap.h"
#include "IAttributes.h"
#include "IMesh.h"
#include "IMeshBuffer.h"

@ -250,16 +250,16 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
}
int vertLocation;
core::map<video::S3DVertex, int>::Node* n = currMtl->VertMap.find(v);
if (n)
auto n = currMtl->VertMap.find(v);
if (n != currMtl->VertMap.end())
{
vertLocation = n->getValue();
vertLocation = n->second;
}
else
{
currMtl->Meshbuffer->Vertices.push_back(v);
vertLocation = currMtl->Meshbuffer->Vertices.size() -1;
currMtl->VertMap.insert(v, vertLocation);
currMtl->VertMap.emplace(v, vertLocation);
}
faceCorners.push_back(vertLocation);

@ -5,12 +5,12 @@
#ifndef __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__
#define __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__
#include <map>
#include "IMeshLoader.h"
#include "IFileSystem.h"
#include "ISceneManager.h"
#include "irrString.h"
#include "SMeshBuffer.h"
#include "irrMap.h"
namespace irr
{
@ -61,7 +61,7 @@ private:
Meshbuffer->Material = o.Meshbuffer->Material;
}
core::map<video::S3DVertex, int> VertMap;
std::map<video::S3DVertex, int> VertMap;
scene::SMeshBuffer *Meshbuffer;
core::stringc Name;
core::stringc Group;