Optimisations

Former-commit-id: 81d277a49b57f061a6339678bd953054e434c613
This commit is contained in:
Lynix
2013-07-03 01:17:22 +02:00
parent 3c1c04b2aa
commit b035852576
14 changed files with 179 additions and 173 deletions

View File

@@ -115,11 +115,11 @@ namespace
bool hasTexCoords = true;
NzBufferMapper<NzVertexBuffer> vertexMapper(vertexBuffer.get(), nzBufferAccess_WriteOnly);
NzMeshVertex* meshVertices = static_cast<NzMeshVertex*>(vertexMapper.GetPointer());
for (auto uvIt : vertices)
for (auto& uvIt : vertices)
{
for (auto normalIt : uvIt.second)
for (auto& normalIt : uvIt.second)
{
for (auto positionIt : normalIt.second)
for (auto& positionIt : normalIt.second)
{
NzMeshVertex& vertex = meshVertices[positionIt.second];
@@ -261,7 +261,7 @@ namespace
specularMap.release();
}
else
NazaraWarning("Failed to load specular map (" + mtlMat->diffuseMap + ')');
NazaraWarning("Failed to load specular map (" + mtlMat->specularMap + ')');
}
// Si nous avons une alpha map ou des couleurs transparentes,

View File

@@ -151,123 +151,99 @@ bool NzMTLParser::Parse()
}
else if (keyword == "map_ka")
{
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
if (!map.IsEmpty())
unsigned int mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != NzString::npos)
{
NzString map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->ambientMap = map;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "map_kd")
{
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
if (!map.IsEmpty())
unsigned int mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != NzString::npos)
{
NzString map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->diffuseMap = map;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "map_ks")
{
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
if (!map.IsEmpty())
unsigned int mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != NzString::npos)
{
NzString map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->specularMap = map;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "map_bump" || keyword == "bump")
{
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
if (!map.IsEmpty())
unsigned int mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != NzString::npos)
{
NzString map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->bumpMap = map;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "map_d")
{
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
if (!map.IsEmpty())
unsigned int mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != NzString::npos)
{
NzString map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->alphaMap = map;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "map_decal" || keyword == "decal")
{
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
if (!map.IsEmpty())
unsigned int mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != NzString::npos)
{
NzString map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->decalMap = map;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "map_disp" || keyword == "disp")
{
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
if (!map.IsEmpty())
unsigned int mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != NzString::npos)
{
NzString map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->displacementMap = map;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "map_refl" || keyword == "refl")
{
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
if (!map.IsEmpty())
unsigned int mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != NzString::npos)
{
NzString map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = &m_materials["default"];
currentMaterial->reflectionMap = map;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "newmtl")
{

View File

@@ -351,9 +351,9 @@ bool NzOBJParser::Parse()
std::unordered_map<NzString, unsigned int> materials;
unsigned int matCount = 0;
for (auto meshIt : meshes)
for (auto& meshIt : meshes)
{
for (auto matIt : meshIt.second)
for (auto& matIt : meshIt.second)
{
if (!matIt.second.empty())
{
@@ -382,8 +382,8 @@ bool NzOBJParser::Parse()
}
m_materials.resize(matCount);
for (auto it : materials)
m_materials[it.second] = it.first;
for (const std::pair<NzString, unsigned int>& pair : materials)
m_materials[pair.second] = pair.first;
return true;
}