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

View File

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

View File

@ -14,7 +14,6 @@
#include "IMeshBuffer.h" #include "IMeshBuffer.h"
#include "IWriteFile.h" #include "IWriteFile.h"
#include "ITexture.h" #include "ITexture.h"
#include "irrMap.h"
namespace irr namespace irr
@ -60,7 +59,7 @@ bool CB3DMeshWriter::writeMesh(io::IWriteFile* file, IMesh* const mesh, s32 flag
const u32 numMeshBuffers = mesh->getMeshBufferCount(); const u32 numMeshBuffers = mesh->getMeshBufferCount();
array<SB3dTexture> texs; 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; u32 texsizes = 0;
for (u32 i = 0; i < numMeshBuffers; i++) for (u32 i = 0; i < numMeshBuffers; i++)
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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