Merge branch 'master' into vulkan

This commit is contained in:
Lynix
2018-04-26 22:48:49 +02:00
191 changed files with 5200 additions and 3554 deletions

View File

@@ -514,8 +514,16 @@ namespace Nz
FontGlyph fontGlyph;
if (ExtractGlyph(characterSize, character, style, &fontGlyph))
{
glyph.atlasRect.width = fontGlyph.image.GetWidth();
glyph.atlasRect.height = fontGlyph.image.GetHeight();
if (fontGlyph.image.IsValid())
{
glyph.atlasRect.width = fontGlyph.image.GetWidth();
glyph.atlasRect.height = fontGlyph.image.GetHeight();
}
else
{
glyph.atlasRect.width = 0;
glyph.atlasRect.height = 0;
}
// Insertion du rectangle dans l'un des atlas
if (glyph.atlasRect.width > 0 && glyph.atlasRect.height > 0) // Si l'image contient quelque chose

View File

@@ -250,6 +250,9 @@ namespace Nz
m_lineCount++;
m_currentLine = m_stream.ReadLine();
if (m_currentLine.IsEmpty())
continue;
m_currentLine = m_currentLine.SubStringTo("//"); // On ignore les commentaires
m_currentLine.Simplify(); // Pour un traitement plus simple
}

View File

@@ -182,6 +182,9 @@ namespace Nz
m_lineCount++;
m_currentLine = m_stream.ReadLine();
if (m_currentLine.IsEmpty())
continue;
m_currentLine = m_currentLine.SubStringTo("//"); // On ignore les commentaires
m_currentLine.Simplify(); // Pour un traitement plus simple
m_currentLine.Trim();

View File

@@ -251,6 +251,32 @@ namespace Nz
currentMaterial->reflectionMap = map;
}
}
else if (keyword == "map_normal" || keyword == "normal")
{
// <!> This is a custom keyword
std::size_t mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != String::npos)
{
String map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = AddMaterial("default");
currentMaterial->normalMap = map;
}
}
else if (keyword == "map_emissive" || keyword == "emissive")
{
// <!> This is a custom keyword
std::size_t mapPos = m_currentLine.GetWordPosition(1);
if (mapPos != String::npos)
{
String map = m_currentLine.SubString(mapPos);
if (!currentMaterial)
currentMaterial = AddMaterial("default");
currentMaterial->emissiveMap = map;
}
}
else if (keyword == "newmtl")
{
String materialName = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
@@ -424,6 +450,9 @@ namespace Nz
m_lineCount++;
m_currentLine = m_currentStream->ReadLine();
if (m_currentLine.IsEmpty())
continue;
m_currentLine = m_currentLine.SubStringTo("#"); // On ignore les commentaires
m_currentLine.Simplify(); // Pour un traitement plus simple
}

View File

@@ -107,6 +107,24 @@ namespace Nz
data.SetParameter(MaterialData::DiffuseTexturePath, fullPath);
}
if (!mtlMat->emissiveMap.IsEmpty())
{
String fullPath = mtlMat->emissiveMap;
if (!Nz::File::IsAbsolute(fullPath))
fullPath.Prepend(baseDir);
data.SetParameter(MaterialData::EmissiveTexturePath, fullPath);
}
if (!mtlMat->normalMap.IsEmpty())
{
String fullPath = mtlMat->normalMap;
if (!Nz::File::IsAbsolute(fullPath))
fullPath.Prepend(baseDir);
data.SetParameter(MaterialData::NormalTexturePath, fullPath);
}
if (!mtlMat->specularMap.IsEmpty())
{
String fullPath = mtlMat->specularMap;

View File

@@ -617,6 +617,9 @@ namespace Nz
m_lineCount++;
m_currentLine = m_currentStream->ReadLine();
if (m_currentLine.IsEmpty())
continue;
m_currentLine.Simplify(); // Simplify lines (convert multiple blanks into a single space and trims)
}
while (m_currentLine.IsEmpty());

View File

@@ -839,7 +839,7 @@ namespace Nz
if (pixelCount == 0)
return false;
auto seq = workingBitset.Read(GetConstPixels(), info.bitsPerPixel);
auto seq = workingBitset.Write(GetConstPixels(), info.bitsPerPixel);
do
{
workingBitset &= info.alphaMask;
@@ -847,7 +847,7 @@ namespace Nz
return true;
workingBitset.Clear();
workingBitset.Read(seq, info.bitsPerPixel);
workingBitset.Write(seq, info.bitsPerPixel);
}
while (--pixelCount > 0);

View File

@@ -354,42 +354,38 @@ namespace Nz
{
glyph.atlas = nullptr;
glyph.bounds.Set(float(m_drawPos.x), float(0.f), float(advance), float(sizeInfo.lineHeight));
glyph.bounds.Set(float(m_drawPos.x), m_lines.back().bounds.y, float(advance), float(sizeInfo.lineHeight));
glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner_LeftTop));
glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner_RightTop));
glyph.corners[2].Set(glyph.bounds.GetCorner(RectCorner_LeftBottom));
glyph.corners[3].Set(glyph.bounds.GetCorner(RectCorner_RightBottom));
switch (character)
{
case '\n':
{
// Extend the line bounding rect to the last glyph it contains, thus extending upon all glyphs of the line
if (!m_glyphs.empty())
{
Glyph& lastGlyph = m_glyphs.back();
m_lines.back().bounds.ExtendTo(lastGlyph.bounds);
}
// Reset cursor
advance = 0;
m_drawPos.x = 0;
m_drawPos.y += sizeInfo.lineHeight;
m_workingBounds.ExtendTo(m_lines.back().bounds);
m_lines.emplace_back(Line{Rectf(0.f, float(sizeInfo.lineHeight * m_lines.size()), 0.f, float(sizeInfo.lineHeight)), m_glyphs.size() + 1});
break;
}
}
}
m_lines.back().bounds.ExtendTo(glyph.bounds);
switch (character)
{
case '\n':
{
// Reset cursor
advance = 0;
m_drawPos.x = 0;
m_drawPos.y += sizeInfo.lineHeight;
m_workingBounds.ExtendTo(m_lines.back().bounds);
m_lines.emplace_back(Line{Rectf(0.f, float(sizeInfo.lineHeight * m_lines.size()), 0.f, float(sizeInfo.lineHeight)), m_glyphs.size() + 1});
break;
}
default:
m_drawPos.x += advance;
break;
}
m_drawPos.x += advance;
m_glyphs.push_back(glyph);
}
m_lines.back().bounds.ExtendTo(m_glyphs.back().bounds);
m_workingBounds.ExtendTo(m_lines.back().bounds);
m_bounds.Set(Rectf(std::floor(m_workingBounds.x), std::floor(m_workingBounds.y), std::ceil(m_workingBounds.width), std::ceil(m_workingBounds.height)));