Big f***ing cleanup part 1

This commit is contained in:
Lynix
2020-02-23 00:42:22 +01:00
parent 67d0e0a689
commit 3d22321109
178 changed files with 2190 additions and 5113 deletions

View File

@@ -49,7 +49,7 @@ namespace Nz
std::vector<Triangle> triangles;
std::vector<Vertex> vertices;
std::vector<Weight> weights;
String shader;
std::string shader;
};
MD5MeshParser(Stream& stream);
@@ -66,17 +66,17 @@ namespace Nz
private:
bool Advance(bool required = true);
void Error(const String& message);
void Error(const std::string& message);
bool ParseJoints();
bool ParseMesh();
void Warning(const String& message);
void Warning(const std::string& message);
void UnrecognizedLine(bool error = false);
std::vector<Joint> m_joints;
std::vector<Mesh> m_meshes;
Stream& m_stream;
StreamOptionFlags m_streamFlags;
String m_currentLine;
std::string m_currentLine;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_meshIndex;

View File

@@ -9,7 +9,6 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/Config.hpp>
#include <unordered_map>
@@ -23,12 +22,12 @@ namespace Nz
MTLParser() = default;
~MTLParser() = default;
inline Material* AddMaterial(const String& matName);
inline Material* AddMaterial(const std::string& matName);
inline void Clear();
inline const Material* GetMaterial(const String& materialName) const;
inline const std::unordered_map<String, Material>& GetMaterials() const;
inline const Material* GetMaterial(const std::string& materialName) const;
inline const std::unordered_map<std::string, Material>& GetMaterials() const;
bool Parse(Stream& stream);
@@ -39,17 +38,17 @@ namespace Nz
Color ambient = Color::White;
Color diffuse = Color::White;
Color specular = Color::White;
String alphaMap;
String ambientMap;
String bumpMap;
String decalMap;
String diffuseMap;
String displacementMap;
String emissiveMap; //< <!> Custom addition: not present in MTL
String normalMap; //< <!> Custom addition: not present in MTL
String reflectionMap;
String shininessMap;
String specularMap;
std::string alphaMap;
std::string ambientMap;
std::string bumpMap;
std::string decalMap;
std::string diffuseMap;
std::string displacementMap;
std::string emissiveMap; //< <!> Custom addition: not present in MTL
std::string normalMap; //< <!> Custom addition: not present in MTL
std::string reflectionMap;
std::string shininessMap;
std::string specularMap;
float alpha = 1.f;
float refractionIndex = 1.f;
float shininess = 1.f;
@@ -61,14 +60,14 @@ namespace Nz
template<typename T> void Emit(const T& text) const;
inline void EmitLine() const;
template<typename T> void EmitLine(const T& line) const;
inline void Error(const String& message);
inline void Error(const std::string& message);
inline void Flush() const;
inline void Warning(const String& message);
inline void Warning(const std::string& message);
inline void UnrecognizedLine(bool error = false);
std::unordered_map<String, Material> m_materials;
std::unordered_map<std::string, Material> m_materials;
mutable Stream* m_currentStream;
String m_currentLine;
std::string m_currentLine;
mutable StringStream m_outputStream;
bool m_keepLastLine;
unsigned int m_lineCount;

View File

@@ -7,7 +7,7 @@
namespace Nz
{
inline MTLParser::Material* MTLParser::AddMaterial(const String& matName)
inline MTLParser::Material* MTLParser::AddMaterial(const std::string& matName)
{
return &m_materials[matName];
}
@@ -17,7 +17,7 @@ namespace Nz
m_materials.clear();
}
inline const MTLParser::Material* MTLParser::GetMaterial(const String& materialName) const
inline const MTLParser::Material* MTLParser::GetMaterial(const std::string& materialName) const
{
auto it = m_materials.find(materialName);
if (it != m_materials.end())
@@ -26,7 +26,7 @@ namespace Nz
return nullptr;
}
inline const std::unordered_map<String, MTLParser::Material>& MTLParser::GetMaterials() const
inline const std::unordered_map<std::string, MTLParser::Material>& MTLParser::GetMaterials() const
{
return m_materials;
}
@@ -51,9 +51,9 @@ namespace Nz
Emit('\n');
}
inline void MTLParser::Error(const String& message)
inline void MTLParser::Error(const std::string& message)
{
NazaraError(message + " at line #" + String::Number(m_lineCount));
NazaraError(message + " at line #" + std::to_string(m_lineCount));
}
inline void MTLParser::Flush() const
@@ -62,14 +62,14 @@ namespace Nz
m_outputStream.Clear();
}
inline void MTLParser::Warning(const String& message)
inline void MTLParser::Warning(const std::string& message)
{
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
NazaraWarning(message + " at line #" + std::to_string(m_lineCount));
}
inline void MTLParser::UnrecognizedLine(bool error)
{
String message = "Unrecognized \"" + m_currentLine + '"';
std::string message = "Unrecognized \"" + m_currentLine + '"';
if (error)
Error(message);

View File

@@ -8,7 +8,6 @@
#define NAZARA_FORMATS_OBJPARSER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Math/Vector4.hpp>
#include <Nazara/Utility/Config.hpp>
@@ -28,53 +27,53 @@ namespace Nz
bool Check(Stream& stream);
inline String* GetMaterials();
inline const String* GetMaterials() const;
inline UInt32 GetMaterialCount() const;
inline std::string* GetMaterials();
inline const std::string* GetMaterials() const;
inline std::size_t GetMaterialCount() const;
inline Mesh* GetMeshes();
inline const Mesh* GetMeshes() const;
inline UInt32 GetMeshCount() const;
inline const String& GetMtlLib() const;
inline std::size_t GetMeshCount() const;
inline const std::filesystem::path& GetMtlLib() const;
inline Vector3f* GetNormals();
inline const Vector3f* GetNormals() const;
inline UInt32 GetNormalCount() const;
inline std::size_t GetNormalCount() const;
inline Vector4f* GetPositions();
inline const Vector4f* GetPositions() const;
inline UInt32 GetPositionCount() const;
inline std::size_t GetPositionCount() const;
inline Vector3f* GetTexCoords();
inline const Vector3f* GetTexCoords() const;
inline UInt32 GetTexCoordCount() const;
inline std::size_t GetTexCoordCount() const;
bool Parse(Stream& stream, UInt32 reservedVertexCount = 100);
bool Parse(Stream& stream, std::size_t reservedVertexCount = 100);
bool Save(Stream& stream) const;
inline String* SetMaterialCount(UInt32 materialCount);
inline Mesh* SetMeshCount(UInt32 meshCount);
inline void SetMtlLib(const String& mtlLib);
inline Vector3f* SetNormalCount(UInt32 normalCount);
inline Vector4f* SetPositionCount(UInt32 positionCount);
inline Vector3f* SetTexCoordCount(UInt32 texCoordCount);
inline std::string* SetMaterialCount(std::size_t materialCount);
inline Mesh* SetMeshCount(std::size_t meshCount);
inline void SetMtlLib(const std::filesystem::path& mtlLib);
inline Vector3f* SetNormalCount(std::size_t normalCount);
inline Vector4f* SetPositionCount(std::size_t positionCount);
inline Vector3f* SetTexCoordCount(std::size_t texCoordCount);
struct Face
{
UInt32 firstVertex;
UInt32 vertexCount;
std::size_t firstVertex;
std::size_t vertexCount;
};
struct FaceVertex
{
UInt32 normal;
UInt32 position;
UInt32 texCoord;
std::size_t normal;
std::size_t position;
std::size_t texCoord;
};
struct Mesh
{
std::vector<Face> faces;
std::vector<FaceVertex> vertices;
String name;
UInt32 material;
std::string name;
std::size_t material;
};
private:
@@ -82,19 +81,19 @@ namespace Nz
template<typename T> void Emit(const T& text) const;
inline void EmitLine() const;
template<typename T> void EmitLine(const T& line) const;
inline void Error(const String& message);
inline void Error(const std::string& message);
inline void Flush() const;
inline void Warning(const String& message);
inline void Warning(const std::string& message);
inline bool UnrecognizedLine(bool error = false);
std::vector<Mesh> m_meshes;
std::vector<String> m_materials;
std::vector<std::string> m_materials;
std::vector<Vector3f> m_normals;
std::vector<Vector4f> m_positions;
std::vector<Vector3f> m_texCoords;
mutable Stream* m_currentStream;
String m_currentLine;
String m_mtlLib;
std::string m_currentLine;
std::filesystem::path m_mtlLib;
mutable StringStream m_outputStream;
bool m_keepLastLine;
unsigned int m_lineCount;

View File

@@ -16,19 +16,19 @@ namespace Nz
m_texCoords.clear();
}
inline String* OBJParser::GetMaterials()
inline std::string* OBJParser::GetMaterials()
{
return m_materials.data();
}
inline const String* OBJParser::GetMaterials() const
inline const std::string* OBJParser::GetMaterials() const
{
return m_materials.data();
}
inline UInt32 OBJParser::GetMaterialCount() const
inline std::size_t OBJParser::GetMaterialCount() const
{
return static_cast<UInt32>(m_materials.size());
return m_materials.size();
}
inline OBJParser::Mesh* OBJParser::GetMeshes()
@@ -41,12 +41,12 @@ namespace Nz
return m_meshes.data();
}
inline UInt32 OBJParser::GetMeshCount() const
inline std::size_t OBJParser::GetMeshCount() const
{
return static_cast<UInt32>(m_meshes.size());
return m_meshes.size();
}
inline const String& OBJParser::GetMtlLib() const
inline const std::filesystem::path& OBJParser::GetMtlLib() const
{
return m_mtlLib;
}
@@ -61,9 +61,9 @@ namespace Nz
return m_normals.data();
}
inline UInt32 OBJParser::GetNormalCount() const
inline std::size_t OBJParser::GetNormalCount() const
{
return static_cast<UInt32>(m_normals.size());
return m_normals.size();
}
inline Vector4f* OBJParser::GetPositions()
@@ -76,9 +76,9 @@ namespace Nz
return m_positions.data();
}
inline UInt32 OBJParser::GetPositionCount() const
inline std::size_t OBJParser::GetPositionCount() const
{
return static_cast<UInt32>(m_positions.size());
return m_positions.size();
}
inline Vector3f* OBJParser::GetTexCoords()
@@ -91,41 +91,41 @@ namespace Nz
return m_texCoords.data();
}
inline UInt32 OBJParser::GetTexCoordCount() const
inline std::size_t OBJParser::GetTexCoordCount() const
{
return static_cast<UInt32>(m_texCoords.size());
return m_texCoords.size();
}
inline String* OBJParser::SetMaterialCount(UInt32 materialCount)
inline std::string* OBJParser::SetMaterialCount(std::size_t materialCount)
{
m_materials.resize(materialCount);
return m_materials.data();
}
inline OBJParser::Mesh* OBJParser::SetMeshCount(UInt32 meshCount)
inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount)
{
m_meshes.resize(meshCount);
return m_meshes.data();
}
inline void OBJParser::SetMtlLib(const String& mtlLib)
inline void OBJParser::SetMtlLib(const std::filesystem::path& mtlLib)
{
m_mtlLib = mtlLib;
}
inline Vector3f* OBJParser::SetNormalCount(UInt32 normalCount)
inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount)
{
m_normals.resize(normalCount);
return m_normals.data();
}
inline Vector4f* OBJParser::SetPositionCount(UInt32 positionCount)
inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount)
{
m_positions.resize(positionCount);
return m_positions.data();
}
inline Vector3f* OBJParser::SetTexCoordCount(UInt32 texCoordCount)
inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount)
{
m_texCoords.resize(texCoordCount);
return m_texCoords.data();
@@ -151,9 +151,9 @@ namespace Nz
Emit('\n');
}
inline void OBJParser::Error(const String& message)
inline void OBJParser::Error(const std::string& message)
{
NazaraError(message + " at line #" + String::Number(m_lineCount));
NazaraError(message + " at line #" + std::to_string(m_lineCount));
}
inline void OBJParser::Flush() const
@@ -162,14 +162,14 @@ namespace Nz
m_outputStream.Clear();
}
inline void OBJParser::Warning(const String& message)
inline void OBJParser::Warning(const std::string& message)
{
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
NazaraWarning(message + " at line #" + std::to_string(m_lineCount));
}
inline bool OBJParser::UnrecognizedLine(bool error)
{
String message = "Unrecognized \"" + m_currentLine + '"';
std::string message = "Unrecognized \"" + m_currentLine + '"';
if (error)
Error(message);