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

@@ -22,13 +22,14 @@ namespace Nz
{
const ParameterList& matData = model->GetMesh()->GetMaterialData(i);
String filePath;
if (matData.GetStringParameter(MaterialData::FilePath, &filePath))
String path;
if (matData.GetStringParameter(MaterialData::FilePath, &path))
{
if (!File::Exists(filePath))
std::filesystem::path filePath = path.ToStdString();
if (!std::filesystem::exists(filePath))
{
NazaraWarning("Shader name does not refer to an existing file, \".tga\" is used by default");
filePath += ".tga";
filePath.replace_extension(".tga");
}
if (MaterialRef material = Material::LoadFromFile(filePath, parameters.material))

View File

@@ -115,7 +115,7 @@ namespace Nz
bool isEnabled;
double dValue;
long long iValue;
String path;
Nz::String path;
ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled, true);
@@ -247,22 +247,22 @@ namespace Nz
// Textures
if (matParams.loadAlphaMap && matData.GetStringParameter(MaterialData::AlphaTexturePath, &path))
SetAlphaMap(path);
SetAlphaMap(path.ToStdString());
if (matParams.loadDiffuseMap && matData.GetStringParameter(MaterialData::DiffuseTexturePath, &path))
SetDiffuseMap(path);
SetDiffuseMap(path.ToStdString());
if (matParams.loadEmissiveMap && matData.GetStringParameter(MaterialData::EmissiveTexturePath, &path))
SetEmissiveMap(path);
SetEmissiveMap(path.ToStdString());
if (matParams.loadHeightMap && matData.GetStringParameter(MaterialData::HeightTexturePath, &path))
SetHeightMap(path);
SetHeightMap(path.ToStdString());
if (matParams.loadNormalMap && matData.GetStringParameter(MaterialData::NormalTexturePath, &path))
SetNormalMap(path);
SetNormalMap(path.ToStdString());
if (matParams.loadSpecularMap && matData.GetStringParameter(MaterialData::SpecularTexturePath, &path))
SetSpecularMap(path);
SetSpecularMap(path.ToStdString());
SetShader(matParams.shaderName);
}
@@ -329,44 +329,44 @@ namespace Nz
// Textures
if (HasAlphaMap())
{
const String& path = GetAlphaMap()->GetFilePath();
if (!path.IsEmpty())
matData->SetParameter(MaterialData::AlphaTexturePath, path);
const std::filesystem::path& path = GetAlphaMap()->GetFilePath();
if (!path.empty())
matData->SetParameter(MaterialData::AlphaTexturePath, path.generic_u8string());
}
if (HasDiffuseMap())
{
const String& path = GetDiffuseMap()->GetFilePath();
if (!path.IsEmpty())
matData->SetParameter(MaterialData::DiffuseTexturePath, path);
const std::filesystem::path& path = GetDiffuseMap()->GetFilePath();
if (!path.empty())
matData->SetParameter(MaterialData::DiffuseTexturePath, path.generic_u8string());
}
if (HasEmissiveMap())
{
const String& path = GetEmissiveMap()->GetFilePath();
if (!path.IsEmpty())
matData->SetParameter(MaterialData::EmissiveTexturePath, path);
const std::filesystem::path& path = GetEmissiveMap()->GetFilePath();
if (!path.empty())
matData->SetParameter(MaterialData::EmissiveTexturePath, path.generic_u8string());
}
if (HasHeightMap())
{
const String& path = GetHeightMap()->GetFilePath();
if (!path.IsEmpty())
matData->SetParameter(MaterialData::HeightTexturePath, path);
const std::filesystem::path& path = GetHeightMap()->GetFilePath();
if (!path.empty())
matData->SetParameter(MaterialData::HeightTexturePath, path.generic_u8string());
}
if (HasNormalMap())
{
const String& path = GetNormalMap()->GetFilePath();
if (!path.IsEmpty())
matData->SetParameter(MaterialData::NormalTexturePath, path);
const std::filesystem::path& path = GetNormalMap()->GetFilePath();
if (!path.empty())
matData->SetParameter(MaterialData::NormalTexturePath, path.generic_u8string());
}
if (HasSpecularMap())
{
const String& path = GetSpecularMap()->GetFilePath();
if (!path.IsEmpty())
matData->SetParameter(MaterialData::SpecularTexturePath, path);
const std::filesystem::path& path = GetSpecularMap()->GetFilePath();
if (!path.empty())
matData->SetParameter(MaterialData::SpecularTexturePath, path.generic_u8string());
}
}

View File

@@ -7,6 +7,7 @@
#include <Nazara/Core/Log.hpp>
#include <Nazara/Graphics/Material.hpp>
#include <Nazara/Renderer/UberShaderPreprocessor.hpp>
#include <filesystem>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
@@ -29,7 +30,7 @@ namespace Nz
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h>
};
void OverrideShader(const String& path, String* source)
void OverrideShader(const std::filesystem::path& path, String* source)
{
ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled);
@@ -46,7 +47,7 @@ namespace Nz
*source = shaderSource;
NazaraNotice(path + " will be used to override built-in shader");
NazaraNotice(path.generic_u8string() + " will be used to override built-in shader");
}
}
}

View File

@@ -86,7 +86,7 @@ namespace Nz
* \remark Produces a NazaraError if there is no subMesh with that name
* \remark Produces a NazaraError if material is invalid
*/
const MaterialRef& Model::GetMaterial(const String& subMeshName) const
const MaterialRef& Model::GetMaterial(const std::string& subMeshName) const
{
NazaraAssert(m_mesh, "Model has no mesh");
@@ -113,7 +113,7 @@ namespace Nz
* \remark Produces a NazaraError if there is no subMesh with that name
* \remark Produces a NazaraError if material index is invalid
*/
const MaterialRef& Model::GetMaterial(std::size_t skinIndex, const String& subMeshName) const
const MaterialRef& Model::GetMaterial(std::size_t skinIndex, const std::string& subMeshName) const
{
NazaraAssert(m_mesh, "Model has no mesh");
@@ -160,7 +160,7 @@ namespace Nz
* \remark Produces a NazaraError if material index is invalid
*/
bool Model::SetMaterial(const String& subMeshName, MaterialRef material)
bool Model::SetMaterial(const std::string& subMeshName, MaterialRef material)
{
SubMesh* subMesh = m_mesh->GetSubMesh(subMeshName);
if (!subMesh)
@@ -185,7 +185,7 @@ namespace Nz
* \remark Produces a NazaraError if there is no subMesh with that name
* \remark Produces a NazaraError if material index is invalid
*/
bool Model::SetMaterial(std::size_t skinIndex, const String& subMeshName, MaterialRef material)
bool Model::SetMaterial(std::size_t skinIndex, const std::string& subMeshName, MaterialRef material)
{
SubMesh* subMesh = m_mesh->GetSubMesh(subMeshName);
if (!subMesh)
@@ -239,7 +239,7 @@ namespace Nz
* \param filePath Path to the file
* \param params Parameters for the model
*/
ModelRef Model::LoadFromFile(const String& filePath, const ModelParameters& params)
ModelRef Model::LoadFromFile(const std::filesystem::path& filePath, const ModelParameters& params)
{
return ModelLoader::LoadFromFile(filePath, params);
}

View File

@@ -56,7 +56,7 @@ namespace Nz
*
* \return True if the material was found or loaded from its name/path, false if it couldn't
*/
bool Sprite::SetMaterial(String materialName, bool resizeSprite)
bool Sprite::SetMaterial(std::string materialName, bool resizeSprite)
{
MaterialRef material = MaterialLibrary::Query(materialName);
if (!material)
@@ -85,7 +85,7 @@ namespace Nz
*
* \return True if the material was found or loaded from its name/path, false if it couldn't
*/
bool Sprite::SetMaterial(std::size_t skinIndex, String materialName, bool resizeSprite)
bool Sprite::SetMaterial(std::size_t skinIndex, std::string materialName, bool resizeSprite)
{
MaterialRef material = MaterialLibrary::Query(materialName);
if (!material)
@@ -114,7 +114,7 @@ namespace Nz
*
* \remark The sprite material gets copied to prevent accidentally changing other drawable materials
*/
bool Sprite::SetTexture(String textureName, bool resizeSprite)
bool Sprite::SetTexture(std::string textureName, bool resizeSprite)
{
TextureRef texture = TextureLibrary::Query(textureName);
if (!texture)
@@ -144,7 +144,7 @@ namespace Nz
*
* \remark The sprite material gets copied to prevent accidentally changing other drawable materials
*/
bool Sprite::SetTexture(std::size_t skinIndex, String textureName, bool resizeSprite)
bool Sprite::SetTexture(std::size_t skinIndex, std::string textureName, bool resizeSprite)
{
TextureRef texture = TextureLibrary::Query(textureName);
if (!texture)