Merge branch 'development' into redcode/crythread-2nd-pass
Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <AzCore/std/parallel/shared_mutex.h>
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <AzFramework/Font/FontInterface.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
@@ -82,7 +83,7 @@ namespace AZ
|
||||
FontFamilyPtr GetFontFamily(const char* fontFamilyName) override;
|
||||
void AddCharsToFontTextures(FontFamilyPtr fontFamily, const char* chars, int glyphSizeX = ICryFont::defaultGlyphSizeX, int glyphSizeY = ICryFont::defaultGlyphSizeY) override;
|
||||
void GetMemoryUsage([[maybe_unused]] ICrySizer* sizer) const override {}
|
||||
string GetLoadedFontNames() const;
|
||||
AZStd::string GetLoadedFontNames() const;
|
||||
void OnLanguageChanged() override;
|
||||
void ReloadAllFonts() override;
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -124,7 +125,7 @@ namespace AZ
|
||||
//! \param fontFamilyName The name of the font family, or path to a font family file.
|
||||
//! \param outputDirectory Path to loaded font family (no filename), may need resolving with PathUtil::MakeGamePath.
|
||||
//! \param outputFullPath Full path to loaded font family, may need resolving with PathUtil::MakeGamePath.
|
||||
XmlNodeRef LoadFontFamilyXml(const char* fontFamilyName, string& outputDirectory, string& outputFullPath);
|
||||
XmlNodeRef LoadFontFamilyXml(const char* fontFamilyName, AZStd::string& outputDirectory, AZStd::string& outputFullPath);
|
||||
|
||||
// Data::AssetBus::Handler overrides...
|
||||
void OnAssetReady(Data::Asset<Data::AssetData> asset) override;
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ namespace AZ
|
||||
|
||||
size_t GetTextLength([[maybe_unused]] const char* str, [[maybe_unused]] const bool asciiMultiLine) const override { return 0; }
|
||||
|
||||
void WrapText(string& result, [[maybe_unused]] float maxWidth, const char* str, [[maybe_unused]] const TextDrawContext& ctx) override { result = str; }
|
||||
void WrapText(AZStd::string& result, [[maybe_unused]] float maxWidth, const char* str, [[maybe_unused]] const TextDrawContext& ctx) override { result = str; }
|
||||
|
||||
void GetMemoryUsage([[maybe_unused]] ICrySizer* sizer) const override {}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace AZ
|
||||
virtual FontFamilyPtr GetFontFamily([[maybe_unused]] const char* fontFamilyName) override { CRY_ASSERT(false); return nullptr; }
|
||||
virtual void AddCharsToFontTextures([[maybe_unused]] FontFamilyPtr fontFamily, [[maybe_unused]] const char* chars, [[maybe_unused]] int glyphSizeX, [[maybe_unused]] int glyphSizeY) override {};
|
||||
virtual void GetMemoryUsage([[maybe_unused]] ICrySizer* sizer) const override {}
|
||||
virtual string GetLoadedFontNames() const override { return ""; }
|
||||
virtual AZStd::string GetLoadedFontNames() const override { return ""; }
|
||||
virtual void OnLanguageChanged() override { }
|
||||
virtual void ReloadAllFonts() override { }
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace AZ
|
||||
int Create(int width, int height);
|
||||
int Release();
|
||||
|
||||
int SaveBitmap(const string& fileName);
|
||||
int SaveBitmap(const AZStd::string& fileName);
|
||||
int Get32Bpp(unsigned int** buffer)
|
||||
{
|
||||
(*buffer) = new unsigned int[m_width * m_height];
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <vector>
|
||||
#include <CryCommon/Cry_Math.h>
|
||||
#include <CryCommon/Cry_Color.h>
|
||||
#include <CryCommon/CryString.h>
|
||||
#include <CryCommon/VertexFormats.h>
|
||||
#include <CryCommon/IRenderer.h>
|
||||
#include "AtomFont.h"
|
||||
@@ -123,7 +122,7 @@ namespace AZ
|
||||
|
||||
struct FontEffect
|
||||
{
|
||||
string m_name;
|
||||
AZStd::string m_name;
|
||||
std::vector<FontRenderingPass> m_passes;
|
||||
|
||||
FontEffect(const char* name)
|
||||
@@ -179,7 +178,7 @@ namespace AZ
|
||||
void DrawString(float x, float y, float z, const char* str, const bool asciiMultiLine, const TextDrawContext& ctx) override;
|
||||
Vec2 GetTextSize(const char* str, const bool asciiMultiLine, const TextDrawContext& ctx) override;
|
||||
size_t GetTextLength(const char* str, const bool asciiMultiLine) const override;
|
||||
void WrapText(string& result, float maxWidth, const char* str, const TextDrawContext& ctx) override;
|
||||
void WrapText(AZStd::string& result, float maxWidth, const char* str, const TextDrawContext& ctx) override;
|
||||
void GetMemoryUsage([[maybe_unused]] ICrySizer* sizer) const override {};
|
||||
void GetGradientTextureCoord(float& minU, float& minV, float& maxU, float& maxV) const override;
|
||||
unsigned int GetEffectId(const char* effectName) const override;
|
||||
@@ -216,7 +215,7 @@ namespace AZ
|
||||
FFont(AtomFont* atomFont, const char* fontName);
|
||||
|
||||
FontTexture* GetFontTexture() const { return m_fontTexture; }
|
||||
const string& GetName() const { return m_name; }
|
||||
const AZStd::string& GetName() const { return m_name; }
|
||||
|
||||
FontEffect* AddEffect(const char* effectName);
|
||||
FontEffect* GetDefaultEffect();
|
||||
@@ -292,8 +291,8 @@ namespace AZ
|
||||
static constexpr uint32_t NumBuffers = 2;
|
||||
static constexpr float WindowScaleWidth = 800.0f;
|
||||
static constexpr float WindowScaleHeight = 600.0f;
|
||||
string m_name;
|
||||
string m_curPath;
|
||||
AZStd::string m_name;
|
||||
AZStd::string m_curPath;
|
||||
|
||||
AZ::Name m_dynamicDrawContextName = AZ::Name(AZ::AtomFontDynamicDrawContextName);
|
||||
|
||||
@@ -342,7 +341,7 @@ namespace AZ
|
||||
FFont* font = const_cast<FFont*>(static_cast<const FFont*>(ptr));
|
||||
if (font && font->m_atomFont)
|
||||
{
|
||||
font->m_atomFont->UnregisterFont(font->m_name);
|
||||
font->m_atomFont->UnregisterFont(font->m_name.c_str());
|
||||
font->m_atomFont = nullptr;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ namespace AZ
|
||||
FontRenderer();
|
||||
~FontRenderer();
|
||||
|
||||
int LoadFromFile(const string& fileName);
|
||||
int LoadFromFile(const AZStd::string& fileName);
|
||||
int LoadFromMemory(unsigned char* buffer, int bufferSize);
|
||||
int Release();
|
||||
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ namespace AZ
|
||||
FontTexture();
|
||||
~FontTexture();
|
||||
|
||||
int CreateFromFile(const string& fileName, int width, int height, AZ::FontSmoothMethod smoothMethod, AZ::FontSmoothAmount smoothAmount, int widthCharCount = 16, int heightCharCount = 16);
|
||||
int CreateFromFile(const AZStd::string& fileName, int width, int height, AZ::FontSmoothMethod smoothMethod, AZ::FontSmoothAmount smoothAmount, int widthCharCount = 16, int heightCharCount = 16);
|
||||
|
||||
//! Default texture slot width/height is 16x8 slots, allowing for 128 glyphs to be stored in the font texture. This was
|
||||
//! previously 16x16, allowing 256 glyphs to be stored. For reference, there are 95 printable ASCII characters, so by
|
||||
@@ -129,7 +129,7 @@ namespace AZ
|
||||
// useful for special feature rendering interleaved with fonts (e.g. box behind the text)
|
||||
void CreateGradientSlot();
|
||||
|
||||
int WriteToFile(const string& fileName);
|
||||
int WriteToFile(const AZStd::string& fileName);
|
||||
|
||||
void GetMemoryUsage([[maybe_unused]] ICrySizer* sizer) const {}
|
||||
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ namespace AZ
|
||||
int Create(int iCacheSize, int glyphBitmapWidth, int glyphBitmapHeight, FontSmoothMethod smoothMethod, FontSmoothAmount smoothAmount, float sizeRatio);
|
||||
int Release();
|
||||
|
||||
int LoadFontFromFile(const string& fileName);
|
||||
int LoadFontFromFile(const AZStd::string& fileName);
|
||||
int LoadFontFromMemory(unsigned char* fileBuffer, int dataSize);
|
||||
int ReleaseFont();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <AtomLyIntegration/AtomFont/FontTexture.h>
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int AZ::FontTexture::WriteToFile([[maybe_unused]] const string& fileName)
|
||||
int AZ::FontTexture::WriteToFile([[maybe_unused]] const AZStd::string& fileName)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -8,22 +8,25 @@
|
||||
|
||||
#include <FFontXML_Internal.h>
|
||||
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
#include <shlobj_core.h>
|
||||
|
||||
namespace AtomFontInternal
|
||||
{
|
||||
void XmlFontShader::FoundElementImpl()
|
||||
{
|
||||
TCHAR sysFontPath[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_FONTS, 0, SHGFP_TYPE_DEFAULT, sysFontPath)))
|
||||
wchar_t sysFontPathW[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_FONTS, 0, SHGFP_TYPE_DEFAULT, sysFontPathW)))
|
||||
{
|
||||
const char* fontPath = m_strFontPath.c_str();
|
||||
const char* fontName = CryStringUtils::FindFileNameInPath(fontPath);
|
||||
const AZ::IO::PathView fontName = AZ::IO::PathView(m_strFontPath.c_str()).Filename();
|
||||
|
||||
string newFontPath(sysFontPath);
|
||||
newFontPath += "/";
|
||||
newFontPath += fontName;
|
||||
m_font->Load(newFontPath, m_FontTexSize.x, m_FontTexSize.y, m_slotSizes.x, m_slotSizes.y, CreateTTFFontFlag(m_FontSmoothMethod, m_FontSmoothAmount), m_SizeRatio);
|
||||
AZStd::string sysFontPath;
|
||||
AZStd::to_string(sysFontPath, sysFontPathW);
|
||||
AZ::IO::Path newFontPath(sysFontPath);
|
||||
newFontPath /= fontName;
|
||||
m_font->Load(newFontPath.c_str(), m_FontTexSize.x, m_FontTexSize.y, m_slotSizes.x, m_slotSizes.y, CreateTTFFontFlag(m_FontSmoothMethod, m_FontSmoothAmount), m_SizeRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <AtomLyIntegration/AtomFont/FontTexture.h>
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int AZ::FontTexture::WriteToFile(const string& fileName)
|
||||
int AZ::FontTexture::WriteToFile(const AZStd::string& fileName)
|
||||
{
|
||||
AZ::IO::FileIOStream outputFile(fileName.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ static void DumfontTexture(IConsoleCmdArgs* cmdArgs)
|
||||
|
||||
if (fontName && *fontName && *fontName != '0')
|
||||
{
|
||||
string fontFilePath("@devroot@/");
|
||||
AZStd::string fontFilePath("@devroot@/");
|
||||
fontFilePath += fontName;
|
||||
fontFilePath += ".bmp";
|
||||
|
||||
@@ -61,7 +61,7 @@ static void DumfontTexture(IConsoleCmdArgs* cmdArgs)
|
||||
|
||||
static void DumfontNames([[maybe_unused]] IConsoleCmdArgs* cmdArgs)
|
||||
{
|
||||
string names = gEnv->pCryFont->GetLoadedFontNames();
|
||||
AZStd::string names = gEnv->pCryFont->GetLoadedFontNames();
|
||||
gEnv->pLog->LogWithType(IMiniLog::eInputResponse, "Currently loaded fonts: %s", names.c_str());
|
||||
}
|
||||
|
||||
@@ -97,15 +97,15 @@ namespace
|
||||
&& !m_boldItalicFontFilename.empty();
|
||||
}
|
||||
|
||||
string m_lang; //!< Stores a comma-separated list of languages this collection of fonts applies to.
|
||||
AZStd::string m_lang; //!< Stores a comma-separated list of languages this collection of fonts applies to.
|
||||
//!< If this is an empty string, it implies that these set of fonts will be applied
|
||||
//!< by default (when a language is being used but no fonts in the font family are
|
||||
//!< mapped to that language).
|
||||
|
||||
string m_fontFilename; //!< Font used when no styling is applied.
|
||||
string m_boldFontFilename; //!< Bold-styled font
|
||||
string m_italicFontFilename; //!< Italic-styled font
|
||||
string m_boldItalicFontFilename; //!< Bold-italic-styled font
|
||||
AZStd::string m_fontFilename; //!< Font used when no styling is applied.
|
||||
AZStd::string m_boldFontFilename; //!< Bold-styled font
|
||||
AZStd::string m_italicFontFilename; //!< Italic-styled font
|
||||
AZStd::string m_boldItalicFontFilename; //!< Bold-italic-styled font
|
||||
};
|
||||
|
||||
//! Stores parsed font family XML data.
|
||||
@@ -152,7 +152,7 @@ namespace
|
||||
return !m_fontFamilyName.empty();
|
||||
}
|
||||
|
||||
string m_fontFamilyName; //!< Value of the "name" font-family tag attribute
|
||||
AZStd::string m_fontFamilyName; //!< Value of the "name" font-family tag attribute
|
||||
AZStd::list<FontTagXml> m_fontTagsXml; //!< List of child <font> tag data.
|
||||
};
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace
|
||||
return false;
|
||||
}
|
||||
|
||||
string name;
|
||||
AZStd::string name;
|
||||
|
||||
for (int i = 0, count = node->getNumAttributes(); i < count; ++i)
|
||||
{
|
||||
@@ -187,7 +187,7 @@ namespace
|
||||
const char* value = "";
|
||||
if (node->getAttributeByIndex(i, &key, &value))
|
||||
{
|
||||
if (string(key) == "name")
|
||||
if (AZStd::string(key) == "name")
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
name.Trim();
|
||||
AZ::StringFunc::TrimWhiteSpace(name, true, true);
|
||||
if (!name.empty())
|
||||
{
|
||||
xmlData.m_fontFamilyName = name;
|
||||
@@ -216,14 +216,14 @@ namespace
|
||||
{
|
||||
xmlData.m_fontTagsXml.push_back(FontTagXml());
|
||||
|
||||
string lang;
|
||||
AZStd::string lang;
|
||||
for (int i = 0, count = node->getNumAttributes(); i < count; ++i)
|
||||
{
|
||||
const char* key = "";
|
||||
const char* value = "";
|
||||
if (node->getAttributeByIndex(i, &key, &value))
|
||||
{
|
||||
if (string(key) == "lang")
|
||||
if (AZStd::string(key) == "lang")
|
||||
{
|
||||
lang = value;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
lang.Trim();
|
||||
AZ::StringFunc::TrimWhiteSpace(lang, true, true);
|
||||
if (!lang.empty())
|
||||
{
|
||||
xmlData.m_fontTagsXml.back().m_lang = lang;
|
||||
@@ -253,8 +253,8 @@ namespace
|
||||
return false;
|
||||
}
|
||||
|
||||
string path;
|
||||
string tags;
|
||||
AZStd::string path;
|
||||
AZStd::string tags;
|
||||
|
||||
for (int i = 0, count = node->getNumAttributes(); i < count; ++i)
|
||||
{
|
||||
@@ -262,11 +262,11 @@ namespace
|
||||
const char* value = "";
|
||||
if (node->getAttributeByIndex(i, &key, &value))
|
||||
{
|
||||
if (string(key) == "path")
|
||||
if (AZStd::string(key) == "path")
|
||||
{
|
||||
path = value;
|
||||
}
|
||||
else if (string(key) == "tags")
|
||||
else if (AZStd::string(key) == "tags")
|
||||
{
|
||||
tags = value;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
tags.Trim();
|
||||
AZ::StringFunc::TrimWhiteSpace(tags, true, true);
|
||||
if (tags.empty())
|
||||
{
|
||||
xmlData.m_fontTagsXml.back().m_fontFilename = path;
|
||||
@@ -315,7 +315,7 @@ namespace
|
||||
//! when referencing font family names from font family XML files), and
|
||||
//! attempting to load the XML files directly via ISystem() methods can
|
||||
//! produce a lot of warning noise.
|
||||
XmlNodeRef SafeLoadXmlFromFile(const string& xmlPath)
|
||||
XmlNodeRef SafeLoadXmlFromFile(const AZStd::string& xmlPath)
|
||||
{
|
||||
if (gEnv->pCryPak->IsFileExist(xmlPath.c_str()))
|
||||
{
|
||||
@@ -383,8 +383,8 @@ void AZ::AtomFont::Release()
|
||||
|
||||
IFFont* AZ::AtomFont::NewFont(const char* fontName)
|
||||
{
|
||||
string name = fontName;
|
||||
name.MakeLower();
|
||||
AZStd::string name = fontName;
|
||||
AZStd::to_lower(name.begin(), name.end());
|
||||
AzFramework::FontId fontId = GetFontId(name.c_str());
|
||||
|
||||
FontMapItor it = m_fonts.find(fontId);
|
||||
@@ -404,7 +404,9 @@ IFFont* AZ::AtomFont::NewFont(const char* fontName)
|
||||
|
||||
IFFont* AZ::AtomFont::GetFont(const char* fontName) const
|
||||
{
|
||||
AzFramework::FontId fontId = GetFontId(string(fontName).MakeLower().c_str());
|
||||
AZStd::string name = fontName;
|
||||
AZStd::to_lower(name.begin(), name.end());
|
||||
AzFramework::FontId fontId = GetFontId(name.c_str());
|
||||
FontMapConstItor it = m_fonts.find(fontId);
|
||||
return it != m_fonts.end() ? it->second : 0;
|
||||
}
|
||||
@@ -423,8 +425,8 @@ AzFramework::FontDrawInterface* AZ::AtomFont::GetDefaultFontDrawInterface() cons
|
||||
FontFamilyPtr AZ::AtomFont::LoadFontFamily(const char* fontFamilyName)
|
||||
{
|
||||
FontFamilyPtr fontFamily(nullptr);
|
||||
string fontFamilyPath;
|
||||
string fontFamilyFullPath;
|
||||
AZStd::string fontFamilyPath;
|
||||
AZStd::string fontFamilyFullPath;
|
||||
|
||||
XmlNodeRef root = LoadFontFamilyXml(fontFamilyName, fontFamilyPath, fontFamilyFullPath);
|
||||
|
||||
@@ -450,13 +452,13 @@ FontFamilyPtr AZ::AtomFont::LoadFontFamily(const char* fontFamilyName)
|
||||
}
|
||||
else
|
||||
{
|
||||
int searchPos = 0;
|
||||
string langToken;
|
||||
|
||||
// "lang" font-tag attribute could be comma-separated
|
||||
while (!(langToken = fontTagXml.m_lang.Tokenize(",", searchPos)).empty())
|
||||
AZStd::vector<AZStd::string> tokens;
|
||||
AZ::StringFunc::Tokenize(fontTagXml.m_lang, tokens, ',');
|
||||
for(AZStd::string& langToken : tokens)
|
||||
{
|
||||
if (langToken.Trim() == currentLanguage)
|
||||
AZ::StringFunc::TrimWhiteSpace(langToken, true, true);
|
||||
if (langToken == currentLanguage)
|
||||
{
|
||||
langSpecificFont = &fontTagXml;
|
||||
break;
|
||||
@@ -494,7 +496,7 @@ FontFamilyPtr AZ::AtomFont::LoadFontFamily(const char* fontFamilyName)
|
||||
// Map the font family name both by path and by name defined
|
||||
// within the Font Family XML itself. This allows font
|
||||
// families to also be referenced simply by name.
|
||||
if (!AddFontFamilyToMaps(fontFamilyFullPath, xmlData.m_fontFamilyName, fontFamily))
|
||||
if (!AddFontFamilyToMaps(fontFamilyFullPath.c_str(), xmlData.m_fontFamilyName.c_str(), fontFamily))
|
||||
{
|
||||
SAFE_RELEASE(normal);
|
||||
SAFE_RELEASE(bold);
|
||||
@@ -540,7 +542,7 @@ FontFamilyPtr AZ::AtomFont::LoadFontFamily(const char* fontFamilyName)
|
||||
// Use filepath as familyName so font loading/unloading doesn't break with duplicate file names
|
||||
fontFamily->familyName = fontFamilyName;
|
||||
|
||||
if (!AddFontFamilyToMaps(fontFamilyName, fontFamily->familyName, fontFamily))
|
||||
if (!AddFontFamilyToMaps(fontFamilyName, fontFamily->familyName.c_str(), fontFamily))
|
||||
{
|
||||
SAFE_RELEASE(font);
|
||||
|
||||
@@ -581,7 +583,9 @@ FontFamilyPtr AZ::AtomFont::GetFontFamily(const char* fontFamilyName)
|
||||
// or just the filename of a font itself. Fonts are mapped by font family
|
||||
// name or by filepath, so attempt lookup using the map first since it's
|
||||
// the fastest.
|
||||
string loweredName = string(fontFamilyName).Trim().MakeLower();
|
||||
AZStd::string loweredName = AZStd::string(fontFamilyName);
|
||||
AZ::StringFunc::TrimWhiteSpace(loweredName, true, true);
|
||||
AZStd::to_lower(loweredName.begin(), loweredName.end());
|
||||
auto it = m_fontFamilies.find(PathUtil::MakeGamePath(loweredName).c_str());
|
||||
if (it != m_fontFamilies.end())
|
||||
{
|
||||
@@ -596,9 +600,9 @@ FontFamilyPtr AZ::AtomFont::GetFontFamily(const char* fontFamilyName)
|
||||
for (const auto& fontFamilyIter : m_fontFamilies)
|
||||
{
|
||||
const AZStd::string& mappedFontFamilyName = fontFamilyIter.first;
|
||||
string mappedFilenameNoExtension = PathUtil::GetFileName(mappedFontFamilyName.c_str());
|
||||
AZStd::string mappedFilenameNoExtension = PathUtil::GetFileName(mappedFontFamilyName.c_str());
|
||||
|
||||
string searchStringFilenameNoExtension = PathUtil::GetFileName(loweredName);
|
||||
AZStd::string searchStringFilenameNoExtension = PathUtil::GetFileName(loweredName);
|
||||
|
||||
if (mappedFilenameNoExtension == searchStringFilenameNoExtension)
|
||||
{
|
||||
@@ -619,9 +623,9 @@ void AZ::AtomFont::AddCharsToFontTextures(FontFamilyPtr fontFamily, const char*
|
||||
fontFamily->boldItalic->AddCharsToFontTexture(chars, glyphSizeX, glyphSizeY);
|
||||
}
|
||||
|
||||
string AZ::AtomFont::GetLoadedFontNames() const
|
||||
AZStd::string AZ::AtomFont::GetLoadedFontNames() const
|
||||
{
|
||||
string ret;
|
||||
AZStd::string ret;
|
||||
for (FontMapConstItor it = m_fonts.begin(), itEnd = m_fonts.end(); it != itEnd; ++it)
|
||||
{
|
||||
FFont* font = it->second;
|
||||
@@ -678,7 +682,9 @@ void AZ::AtomFont::ReloadAllFonts()
|
||||
|
||||
void AZ::AtomFont::UnregisterFont(const char* fontName)
|
||||
{
|
||||
AzFramework::FontId fontId = GetFontId(string(fontName).MakeLower().c_str());
|
||||
AZStd::string name(fontName);
|
||||
AZStd::to_lower(name.begin(), name.end());
|
||||
AzFramework::FontId fontId = GetFontId(name.c_str());
|
||||
FontMapItor it = m_fonts.find(fontId);
|
||||
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
@@ -715,10 +721,10 @@ void AZ::AtomFont::UnregisterFont(const char* fontName)
|
||||
|
||||
IFFont* AZ::AtomFont::LoadFont(const char* fontName)
|
||||
{
|
||||
string fontNameLower = fontName;
|
||||
fontNameLower.MakeLower();
|
||||
AZStd::string fontNameLower = fontName;
|
||||
AZStd::to_lower(fontNameLower.begin(), fontNameLower.end());
|
||||
|
||||
IFFont* font = GetFont(fontNameLower);
|
||||
IFFont* font = GetFont(fontNameLower.c_str());
|
||||
if (font)
|
||||
{
|
||||
font->AddRef(); // use existing loaded font
|
||||
@@ -726,10 +732,10 @@ IFFont* AZ::AtomFont::LoadFont(const char* fontName)
|
||||
else
|
||||
{
|
||||
// attempt to create and load a new font, use the font pathname as the font name
|
||||
font = NewFont(fontNameLower);
|
||||
font = NewFont(fontNameLower.c_str());
|
||||
if (!font)
|
||||
{
|
||||
string errorMsg = "Error creating a new font named ";
|
||||
AZStd::string errorMsg = "Error creating a new font named ";
|
||||
errorMsg += fontNameLower;
|
||||
errorMsg += ".";
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR, errorMsg.c_str());
|
||||
@@ -737,12 +743,12 @@ IFFont* AZ::AtomFont::LoadFont(const char* fontName)
|
||||
else
|
||||
{
|
||||
// creating font adds one to its refcount so no need for AddRef here
|
||||
if (!font->Load(fontNameLower))
|
||||
if (!font->Load(fontNameLower.c_str()))
|
||||
{
|
||||
string errorMsg = "Error loading a font from ";
|
||||
AZStd::string errorMsg = "Error loading a font from ";
|
||||
errorMsg += fontNameLower;
|
||||
errorMsg += ".";
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR, errorMsg);
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR, errorMsg.c_str());
|
||||
font->Release();
|
||||
font = nullptr;
|
||||
}
|
||||
@@ -764,8 +770,9 @@ void AZ::AtomFont::ReleaseFontFamily(FontFamily* fontFamily)
|
||||
// Note that the FontFamily is mapped both by filename and by "family name"
|
||||
auto it = m_fontFamilyReverseLookup[fontFamily];
|
||||
m_fontFamilies.erase(it);
|
||||
string familyName(fontFamily->familyName);
|
||||
m_fontFamilies.erase(familyName.MakeLower().c_str());
|
||||
AZStd::string familyName(fontFamily->familyName);
|
||||
AZStd::to_lower(familyName.begin(), familyName.end());
|
||||
m_fontFamilies.erase(familyName.c_str());
|
||||
|
||||
// Reverse lookup is used to avoid needing to store filename path with
|
||||
// the font family, so we need to remove that entry also.
|
||||
@@ -785,12 +792,11 @@ bool AZ::AtomFont::AddFontFamilyToMaps(const char* fontFamilyFilename, const cha
|
||||
}
|
||||
|
||||
// We don't support "updating" mapped values.
|
||||
AZStd::string loweredFilename(PathUtil::MakeGamePath(string(fontFamilyFilename)).c_str());
|
||||
AZStd::string loweredFilename(PathUtil::MakeGamePath(AZStd::string(fontFamilyFilename)).c_str());
|
||||
AZStd::to_lower<AZStd::string::iterator>(loweredFilename.begin(), loweredFilename.end());
|
||||
if (m_fontFamilies.find(loweredFilename) != m_fontFamilies.end())
|
||||
{
|
||||
string warnMsg;
|
||||
warnMsg.Format("Couldn't load Font Family '%s': already loaded", fontFamilyFilename);
|
||||
AZStd::string warnMsg = AZStd::string::format("Couldn't load Font Family '%s': already loaded", fontFamilyFilename);
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, warnMsg.c_str());
|
||||
return false;
|
||||
}
|
||||
@@ -801,8 +807,7 @@ bool AZ::AtomFont::AddFontFamilyToMaps(const char* fontFamilyFilename, const cha
|
||||
AZStd::to_lower<AZStd::string::iterator>(loweredFontFamilyName.begin(), loweredFontFamilyName.end());
|
||||
if (m_fontFamilies.find(loweredFontFamilyName) != m_fontFamilies.end())
|
||||
{
|
||||
string warnMsg;
|
||||
warnMsg.Format("Couldn't load Font Family '%s': already loaded", fontFamilyName);
|
||||
AZStd::string warnMsg = AZStd::string::format("Couldn't load Font Family '%s': already loaded", fontFamilyName);
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, warnMsg.c_str());
|
||||
return false;
|
||||
}
|
||||
@@ -819,7 +824,7 @@ bool AZ::AtomFont::AddFontFamilyToMaps(const char* fontFamilyFilename, const cha
|
||||
return true;
|
||||
}
|
||||
|
||||
XmlNodeRef AZ::AtomFont::LoadFontFamilyXml(const char* fontFamilyName, string& outputDirectory, string& outputFullPath)
|
||||
XmlNodeRef AZ::AtomFont::LoadFontFamilyXml(const char* fontFamilyName, AZStd::string& outputDirectory, AZStd::string& outputFullPath)
|
||||
{
|
||||
outputFullPath = fontFamilyName;
|
||||
outputDirectory = PathUtil::GetPath(fontFamilyName);
|
||||
@@ -829,8 +834,8 @@ XmlNodeRef AZ::AtomFont::LoadFontFamilyXml(const char* fontFamilyName, string& o
|
||||
// not a path, so we try to build a "best guess" path from the name.
|
||||
if (!root)
|
||||
{
|
||||
string fileNoExtension(PathUtil::GetFileName(fontFamilyName));
|
||||
string fileExtension(PathUtil::GetExt(fontFamilyName));
|
||||
AZStd::string fileNoExtension(PathUtil::GetFileName(fontFamilyName));
|
||||
AZStd::string fileExtension(PathUtil::GetExt(fontFamilyName));
|
||||
|
||||
if (fileExtension.empty())
|
||||
{
|
||||
@@ -838,14 +843,14 @@ XmlNodeRef AZ::AtomFont::LoadFontFamilyXml(const char* fontFamilyName, string& o
|
||||
}
|
||||
|
||||
// Try: "fonts/fontName.fontfamily"
|
||||
outputDirectory = string("fonts/");
|
||||
outputDirectory = AZStd::string("fonts/");
|
||||
outputFullPath = outputDirectory + fileNoExtension + fileExtension;
|
||||
root = SafeLoadXmlFromFile(outputFullPath);
|
||||
|
||||
// Finally, try: "fonts/fontName/fontName.fontfamily"
|
||||
if (!root)
|
||||
{
|
||||
outputDirectory = string("fonts/") + fileNoExtension + "/";
|
||||
outputDirectory = AZStd::string("fonts/") + fileNoExtension + "/";
|
||||
outputFullPath = outputDirectory + fileNoExtension + fileExtension;
|
||||
root = SafeLoadXmlFromFile(outputFullPath);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include <CryCommon/ISystem.h>
|
||||
|
||||
#include <AzCore/Math/Color.h>
|
||||
#include <AzCore/Math/Matrix4x4.h>
|
||||
#include <AzCore/Math/MatrixUtils.h>
|
||||
@@ -26,7 +28,6 @@
|
||||
#include <AtomLyIntegration/AtomFont/FFont.h>
|
||||
#include <AtomLyIntegration/AtomFont/AtomFont.h>
|
||||
#include <AtomLyIntegration/AtomFont/FontTexture.h>
|
||||
#include <CryCommon/UnicodeIterator.h>
|
||||
#include <CryCommon/MathConversion.h>
|
||||
|
||||
#include <AzCore/std/parallel/lock.h>
|
||||
@@ -126,7 +127,7 @@ bool AZ::FFont::Load(const char* fontFilePath, unsigned int width, unsigned int
|
||||
|
||||
auto pPak = gEnv->pCryPak;
|
||||
|
||||
string fullFile;
|
||||
AZStd::string fullFile;
|
||||
if (pPak->IsAbsPath(fontFilePath))
|
||||
{
|
||||
fullFile = fontFilePath;
|
||||
@@ -409,6 +410,9 @@ Vec2 AZ::FFont::GetTextSizeUInternal(
|
||||
const size_t fxIdx = ctx.m_fxIdx < fxSize ? ctx.m_fxIdx : 0;
|
||||
const FontEffect& fx = m_effects[fxIdx];
|
||||
|
||||
AZStd::wstring strW;
|
||||
AZStd::to_wstring(strW, str);
|
||||
|
||||
for (size_t i = 0, numPasses = fx.m_passes.size(); i < numPasses; ++i)
|
||||
{
|
||||
const FontRenderingPass* pass = &fx.m_passes[numPasses - i - 1];
|
||||
@@ -426,7 +430,7 @@ Vec2 AZ::FFont::GetTextSizeUInternal(
|
||||
|
||||
// parse the string, ignoring control characters
|
||||
uint32_t nextCh = 0;
|
||||
Unicode::CIterator<const char*, false> pChar(str);
|
||||
const wchar_t* pChar = strW.c_str();
|
||||
while (uint32_t ch = *pChar)
|
||||
{
|
||||
++pChar;
|
||||
@@ -556,6 +560,9 @@ uint32_t AZ::FFont::GetNumQuadsForText(const char* str, const bool asciiMultiLin
|
||||
const size_t fxIdx = ctx.m_fxIdx < fxSize ? ctx.m_fxIdx : 0;
|
||||
const FontEffect& fx = m_effects[fxIdx];
|
||||
|
||||
AZStd::wstring strW;
|
||||
AZStd::to_wstring(strW, str);
|
||||
|
||||
for (size_t j = 0, numPasses = fx.m_passes.size(); j < numPasses; ++j)
|
||||
{
|
||||
size_t i = numPasses - j - 1;
|
||||
@@ -567,7 +574,7 @@ uint32_t AZ::FFont::GetNumQuadsForText(const char* str, const bool asciiMultiLin
|
||||
}
|
||||
|
||||
uint32_t nextCh = 0;
|
||||
Unicode::CIterator<const char*, false> pChar(str);
|
||||
const wchar_t* pChar = strW.c_str();
|
||||
while (uint32_t ch = *pChar)
|
||||
{
|
||||
++pChar;
|
||||
@@ -862,9 +869,12 @@ int AZ::FFont::CreateQuadsForText(const RHI::Viewport& viewport, float x, float
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::wstring strW;
|
||||
AZStd::to_wstring(strW, str);
|
||||
|
||||
// parse the string, ignoring control characters
|
||||
uint32_t nextCh = 0;
|
||||
Unicode::CIterator<const char*, false> pChar(str);
|
||||
const wchar_t* pChar = strW.c_str();
|
||||
while (uint32_t ch = *pChar)
|
||||
{
|
||||
++pChar;
|
||||
@@ -1166,7 +1176,7 @@ size_t AZ::FFont::GetTextLength(const char* str, const bool asciiMultiLine) cons
|
||||
return len;
|
||||
}
|
||||
|
||||
void AZ::FFont::WrapText(string& result, float maxWidth, const char* str, const TextDrawContext& ctx)
|
||||
void AZ::FFont::WrapText(AZStd::string& result, float maxWidth, const char* str, const TextDrawContext& ctx)
|
||||
{
|
||||
result = str;
|
||||
|
||||
@@ -1188,7 +1198,7 @@ void AZ::FFont::WrapText(string& result, float maxWidth, const char* str, const
|
||||
const bool multiLine = strSize.y > GetRestoredFontSize(ctx).y;
|
||||
|
||||
int lastSpace = -1;
|
||||
const char* pLastSpace = NULL;
|
||||
const wchar_t* pLastSpace = NULL;
|
||||
float lastSpaceWidth = 0.0f;
|
||||
|
||||
float curCharWidth = 0.0f;
|
||||
@@ -1197,7 +1207,9 @@ void AZ::FFont::WrapText(string& result, float maxWidth, const char* str, const
|
||||
float widthSum = 0.0f;
|
||||
|
||||
int curChar = 0;
|
||||
Unicode::CIterator<const char*, false> pChar(result.c_str());
|
||||
AZStd::wstring resultW;
|
||||
AZStd::to_wstring(resultW, result.c_str());
|
||||
const wchar_t* pChar = resultW.c_str();
|
||||
while (uint32_t ch = *pChar)
|
||||
{
|
||||
// Dollar sign escape codes. The following scenarios can happen with dollar signs embedded in a string.
|
||||
@@ -1224,7 +1236,7 @@ void AZ::FFont::WrapText(string& result, float maxWidth, const char* str, const
|
||||
// get char width and sum it to the line width
|
||||
// Note: This is not unicode compatible, since char-width depends on surrounding context (ie, combining diacritics etc)
|
||||
char codepoint[5];
|
||||
Unicode::Convert(codepoint, ch);
|
||||
AZStd::to_string(codepoint, 5, { (wchar_t*)&ch, 1 });
|
||||
curCharWidth = GetTextSize(codepoint, true, ctx).x;
|
||||
|
||||
// keep track of spaces
|
||||
@@ -1233,15 +1245,15 @@ void AZ::FFont::WrapText(string& result, float maxWidth, const char* str, const
|
||||
{
|
||||
lastSpace = curChar;
|
||||
lastSpaceWidth = curLineWidth + curCharWidth;
|
||||
pLastSpace = pChar.GetPosition();
|
||||
pLastSpace = pChar;
|
||||
assert(*pLastSpace == ' ');
|
||||
}
|
||||
|
||||
bool prevCharWasNewline = false;
|
||||
const bool notFirstChar = pChar.GetPosition() != result.c_str();
|
||||
const bool notFirstChar = pChar != resultW.c_str();
|
||||
if (*pChar && notFirstChar)
|
||||
{
|
||||
const char* pPrevCharStr = pChar.GetPosition() - 1;
|
||||
const wchar_t* pPrevCharStr = pChar - 1;
|
||||
prevCharWasNewline = pPrevCharStr[0] == '\n';
|
||||
}
|
||||
|
||||
@@ -1268,12 +1280,12 @@ void AZ::FFont::WrapText(string& result, float maxWidth, const char* str, const
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* buf = pChar.GetPosition();
|
||||
size_t bytesProcessed = buf - result.c_str();
|
||||
result.insert(bytesProcessed, '\n'); // Insert the newline, this invalidates the iterator
|
||||
buf = result.c_str() + bytesProcessed; // In case reallocation occurs, we ensure we are inside the new buffer
|
||||
const wchar_t* buf = pChar;
|
||||
size_t bytesProcessed = buf - resultW.c_str();
|
||||
resultW.insert(resultW.begin() + bytesProcessed, L'\n'); // Insert the newline, this invalidates the iterator
|
||||
buf = resultW.c_str() + bytesProcessed; // In case reallocation occurs, we ensure we are inside the new buffer
|
||||
assert(*buf == '\n');
|
||||
pChar.SetPosition(buf); // pChar once again points inside the target string, at the current character
|
||||
pChar = buf; // pChar once again points inside the target string, at the current character
|
||||
assert(*pChar == ch);
|
||||
++pChar;
|
||||
++curChar;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace AtomFontInternal
|
||||
ELEMENT_PASS_BLEND = 14
|
||||
};
|
||||
|
||||
inline int GetBlendModeFromString(const string& str, bool dst)
|
||||
inline int GetBlendModeFromString(const AZStd::string& str, bool dst)
|
||||
{
|
||||
int blend = GS_BLSRC_ONE;
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace AtomFontInternal
|
||||
);
|
||||
}
|
||||
|
||||
inline AZ::FontSmoothMethod TranslateSmoothMethod(const string& value)
|
||||
inline AZ::FontSmoothMethod TranslateSmoothMethod(const AZStd::string& value)
|
||||
{
|
||||
AZ::FontSmoothMethod smoothMethod = AZ::FontSmoothMethod::None;
|
||||
if (value == "blur")
|
||||
@@ -179,9 +179,8 @@ namespace AtomFontInternal
|
||||
void FoundElementImpl();
|
||||
|
||||
// notify methods
|
||||
void FoundElement(const string& name)
|
||||
void FoundElement(const AZStd::string& name)
|
||||
{
|
||||
//MessageBox(NULL, string("[" + name + "]").c_str(), "FoundElement", MB_OK);
|
||||
// process the previous element
|
||||
switch (m_nElement)
|
||||
{
|
||||
@@ -246,9 +245,8 @@ namespace AtomFontInternal
|
||||
}
|
||||
}
|
||||
|
||||
void FoundAttribute(const string& name, const string& value)
|
||||
void FoundAttribute(const AZStd::string& name, const AZStd::string& value)
|
||||
{
|
||||
//MessageBox(NULL, string(name + "\n" + value).c_str(), "FoundAttribute", MB_OK);
|
||||
switch (m_nElement)
|
||||
{
|
||||
case ELEMENT_FONT:
|
||||
@@ -388,8 +386,8 @@ namespace AtomFontInternal
|
||||
AZ::FFont::FontEffect* m_effect;
|
||||
AZ::FFont::FontRenderingPass* m_pass;
|
||||
|
||||
string m_strFontPath;
|
||||
string m_strFontEffectPath;
|
||||
AZStd::string m_strFontPath;
|
||||
AZStd::string m_strFontEffectPath;
|
||||
vector2l m_FontTexSize;
|
||||
AZ::AtomFont::GlyphSize m_slotSizes;
|
||||
float m_SizeRatio = IFFontConstants::defaultSizeRatio;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include <AzCore/Casting/lossy_cast.h>
|
||||
|
||||
#include <CryCommon/ISystem.h>
|
||||
|
||||
// Sizes are defined in in 26.6 fixed float format (TT_F26Dot6), where
|
||||
// 1 unit is 1/64 of a pixel.
|
||||
constexpr int FractionalPixelUnits = 64;
|
||||
@@ -94,7 +96,7 @@ AZ::FontRenderer::~FontRenderer()
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int AZ::FontRenderer::LoadFromFile(const string& fileName)
|
||||
int AZ::FontRenderer::LoadFromFile(const AZStd::string& fileName)
|
||||
{
|
||||
int iError = FT_Init_FreeType(&m_library);
|
||||
|
||||
@@ -252,8 +254,8 @@ int AZ::FontRenderer::GetGlyph(GlyphBitmap* glyphBitmap, int* horizontalAdvance,
|
||||
const int textureSlotBufferHeight = glyphBitmap->GetHeight();
|
||||
|
||||
// might happen if font characters are too big or cache dimenstions in font.xml is too small "<font path="VeraMono.ttf" w="320" h="368"/>"
|
||||
const bool charWidthFits = iX + m_glyph->bitmap.width <= textureSlotBufferWidth;
|
||||
const bool charHeightFits = iY + m_glyph->bitmap.rows <= textureSlotBufferHeight;
|
||||
const bool charWidthFits = static_cast<int>(iX + m_glyph->bitmap.width) <= textureSlotBufferWidth;
|
||||
const bool charHeightFits = static_cast<int>(iY + m_glyph->bitmap.rows) <= textureSlotBufferHeight;
|
||||
const bool charFitsInSlot = charWidthFits && charHeightFits;
|
||||
AZ_Error("Font", charFitsInSlot, "Character code %d doesn't fit in font texture; check 'sizeRatio' attribute in font XML or adjust this character's sizing in the font.", characterCode);
|
||||
|
||||
@@ -309,8 +311,7 @@ Vec2 AZ::FontRenderer::GetKerning(uint32_t leftGlyph, uint32_t rightGlyph)
|
||||
#if !defined(_RELEASE)
|
||||
if (0 != ftError)
|
||||
{
|
||||
string warnMsg;
|
||||
warnMsg.Format("FT_Get_Kerning returned %d", ftError);
|
||||
AZStd::string warnMsg = AZStd::string::format("FT_Get_Kerning returned %d", ftError);
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, warnMsg.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include <AtomLyIntegration/AtomFont/FontTexture.h>
|
||||
#include <CryCommon/UnicodeIterator.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
AZ::FontTexture::FontTexture()
|
||||
@@ -44,7 +44,7 @@ AZ::FontTexture::~FontTexture()
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int AZ::FontTexture::CreateFromFile(const string& fileName, int width, int height, AZ::FontSmoothMethod smoothMethod, AZ::FontSmoothAmount smoothAmount, int widthCellCount, int heightCellCount)
|
||||
int AZ::FontTexture::CreateFromFile(const AZStd::string& fileName, int width, int height, AZ::FontSmoothMethod smoothMethod, AZ::FontSmoothAmount smoothAmount, int widthCellCount, int heightCellCount)
|
||||
{
|
||||
if (!m_glyphCache.LoadFontFromFile(fileName))
|
||||
{
|
||||
@@ -255,10 +255,10 @@ int AZ::FontTexture::PreCacheString(const char* string, int* updated, float size
|
||||
uint16_t slotUsage = m_slotUsage++;
|
||||
int updateCount = 0;
|
||||
|
||||
uint32_t character;
|
||||
for (Unicode::CIterator<const char*, false> it(string); *it; ++it)
|
||||
AZStd::wstring stringW;
|
||||
AZStd::to_wstring(stringW, string);
|
||||
for (wchar_t character : stringW)
|
||||
{
|
||||
character = *it;
|
||||
TextureSlot* slot = GetCharSlot(character, clampedGlyphSize);
|
||||
|
||||
if (!slot)
|
||||
|
||||
@@ -124,7 +124,7 @@ int AZ::GlyphCache::Release()
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int AZ::GlyphCache::LoadFontFromFile(const string& fileName)
|
||||
int AZ::GlyphCache::LoadFontFromFile(const AZStd::string & fileName)
|
||||
{
|
||||
return m_fontRenderer.LoadFromFile(fileName);
|
||||
}
|
||||
|
||||
+10
-15
@@ -230,25 +230,20 @@ namespace AZ::Render
|
||||
AZ::RPI::ViewportContextPtr viewportContext = GetViewportContext();
|
||||
auto rootPass = viewportContext->GetCurrentPipeline()->GetRootPass();
|
||||
const RPI::PipelineStatisticsResult stats = rootPass->GetLatestPipelineStatisticsResult();
|
||||
AZStd::function<int(const AZ::RPI::Ptr<AZ::RPI::Pass>)> containingPassCount = [&containingPassCount](const AZ::RPI::Ptr<AZ::RPI::Pass> pass)
|
||||
{
|
||||
int count = 1;
|
||||
if (auto passAsParent = pass->AsParent())
|
||||
{
|
||||
for (const auto& child : passAsParent->GetChildren())
|
||||
{
|
||||
count += containingPassCount(child);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
};
|
||||
const int numPasses = containingPassCount(rootPass);
|
||||
|
||||
RPI::PassSystemFrameStatistics passSystemFrameStatistics = AZ::RPI::PassSystemInterface::Get()->GetFrameStatistics();
|
||||
|
||||
DrawLine(AZStd::string::format(
|
||||
"Total Passes: %d Vertex Count: %lld Primitive Count: %lld",
|
||||
numPasses,
|
||||
"RenderPasses: %d Vertex Count: %lld Primitive Count: %lld",
|
||||
passSystemFrameStatistics.m_numRenderPassesExecuted,
|
||||
aznumeric_cast<long long>(stats.m_vertexCount),
|
||||
aznumeric_cast<long long>(stats.m_primitiveCount)
|
||||
));
|
||||
DrawLine(AZStd::string::format(
|
||||
"Total Draw Item Count: %d Max Draw Items in a Pass: %d",
|
||||
passSystemFrameStatistics.m_totalDrawItemsRendered,
|
||||
passSystemFrameStatistics.m_maxDrawItemsRenderedInAPass
|
||||
));
|
||||
}
|
||||
|
||||
void AtomViewportDisplayInfoSystemComponent::UpdateFramerate()
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace
|
||||
const AZ::RHI::Format BoneIndexFormat = AZ::RHI::Format::R32G32B32A32_UINT;
|
||||
const AZ::RHI::Format BoneWeightFormat = AZ::RHI::Format::R32G32B32A32_FLOAT;
|
||||
|
||||
const size_t LinearSkinningFloatsPerBone = 12;
|
||||
const size_t DualQuaternionSkinningFloatsPerBone = 8;
|
||||
const uint32_t LinearSkinningFloatsPerBone = 12;
|
||||
const uint32_t DualQuaternionSkinningFloatsPerBone = 8;
|
||||
const uint32_t MaxSupportedSkinInfluences = 4;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
static void ProcessMorphsForLod(const EMotionFX::Actor* actor, const Data::Asset<RPI::BufferAsset>& morphBufferAsset, uint32_t lodIndex, const AZStd::string& fullFileName, SkinnedMeshInputLod& skinnedMeshLod)
|
||||
static void ProcessMorphsForLod(const EMotionFX::Actor* actor, const Data::Asset<RPI::BufferAsset>& morphBufferAsset, size_t lodIndex, const AZStd::string& fullFileName, SkinnedMeshInputLod& skinnedMeshLod)
|
||||
{
|
||||
EMotionFX::MorphSetup* morphSetup = actor->GetMorphSetup(lodIndex);
|
||||
if (morphSetup)
|
||||
@@ -275,8 +275,8 @@ namespace AZ
|
||||
const AZStd::vector<AZ::RPI::MorphTargetMetaAsset::MorphTarget>& metaDatas = actor->GetMorphTargetMetaAsset()->GetMorphTargets();
|
||||
|
||||
// Loop over all the EMotionFX morph targets
|
||||
const AZ::u32 numMorphTargets = morphSetup->GetNumMorphTargets();
|
||||
for (AZ::u32 morphTargetIndex = 0; morphTargetIndex < numMorphTargets; ++morphTargetIndex)
|
||||
const size_t numMorphTargets = morphSetup->GetNumMorphTargets();
|
||||
for (size_t morphTargetIndex = 0; morphTargetIndex < numMorphTargets; ++morphTargetIndex)
|
||||
{
|
||||
EMotionFX::MorphTargetStandard* morphTarget = static_cast<EMotionFX::MorphTargetStandard*>(morphSetup->GetMorphTarget(morphTargetIndex));
|
||||
for (const auto& metaData : metaDatas)
|
||||
@@ -288,7 +288,7 @@ namespace AZ
|
||||
if (metaData.m_morphTargetName == morphTarget->GetNameString() && metaData.m_numVertices > 0)
|
||||
{
|
||||
// The skinned mesh lod gets a unique morph for each meta, since each one has unique min/max delta values to use for decompression
|
||||
AZStd::string morphString = AZStd::string::format("%s_Lod%u_Morph_%s", fullFileName.c_str(), lodIndex, metaData.m_meshNodeName.c_str());
|
||||
const AZStd::string morphString = AZStd::string::format("%s_Lod%zu_Morph_%s", fullFileName.c_str(), lodIndex, metaData.m_meshNodeName.c_str());
|
||||
|
||||
float minWeight = morphTarget->GetRangeMin();
|
||||
float maxWeight = morphTarget->GetRangeMax();
|
||||
@@ -562,8 +562,8 @@ namespace AZ
|
||||
for (size_t i = 0; i < numBoneTransforms; ++i)
|
||||
{
|
||||
MCore::DualQuaternion dualQuat = MCore::DualQuaternion::ConvertFromTransform(AZ::Transform::CreateFromMatrix3x4(skinningMatrices[i]));
|
||||
dualQuat.mReal.StoreToFloat4(&boneTransforms[i * DualQuaternionSkinningFloatsPerBone]);
|
||||
dualQuat.mDual.StoreToFloat4(&boneTransforms[i * DualQuaternionSkinningFloatsPerBone + 4]);
|
||||
dualQuat.m_real.StoreToFloat4(&boneTransforms[i * DualQuaternionSkinningFloatsPerBone]);
|
||||
dualQuat.m_dual.StoreToFloat4(&boneTransforms[i * DualQuaternionSkinningFloatsPerBone + 4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -574,7 +574,7 @@ namespace AZ
|
||||
AZStd::vector<float> boneTransforms;
|
||||
GetBoneTransformsFromActorInstance(actorInstance, boneTransforms, skinningMethod);
|
||||
|
||||
size_t floatsPerBone = 0;
|
||||
uint32_t floatsPerBone = 0;
|
||||
if (skinningMethod == EMotionFX::Integration::SkinningMethod::Linear)
|
||||
{
|
||||
floatsPerBone = LinearSkinningFloatsPerBone;
|
||||
|
||||
@@ -83,10 +83,10 @@ namespace AZ
|
||||
// Update RenderActorInstance world bounding box
|
||||
// The bounding box is moving with the actor instance.
|
||||
// The entity and actor transforms are kept in sync already.
|
||||
m_worldAABB = AZ::Aabb::CreateFromMinMax(m_actorInstance->GetAABB().GetMin(), m_actorInstance->GetAABB().GetMax());
|
||||
m_worldAABB = m_actorInstance->GetAabb();
|
||||
|
||||
// Update RenderActorInstance local bounding box
|
||||
// NB: computing the local bbox from the world bbox makes the local bbox artifically larger than it should be
|
||||
// NB: computing the local bbox from the world bbox makes the local bbox artificially larger than it should be
|
||||
// instead EMFX should support getting the local bbox from the actor instance directly
|
||||
m_localAABB = m_worldAABB.GetTransformedAabb(m_transformInterface->GetWorldTM().GetInverse());
|
||||
|
||||
@@ -107,9 +107,8 @@ namespace AZ
|
||||
{
|
||||
if (debugOptions.m_drawAABB)
|
||||
{
|
||||
const MCore::AABB emfxAabb = m_actorInstance->GetAABB();
|
||||
const AZ::Aabb azAabb = AZ::Aabb::CreateFromMinMax(emfxAabb.GetMin(), emfxAabb.GetMax());
|
||||
auxGeom->DrawAabb(azAabb, AZ::Color(0.0f, 1.0f, 1.0f, 1.0f), RPI::AuxGeomDraw::DrawStyle::Line);
|
||||
const AZ::Aabb& aabb = m_actorInstance->GetAabb();
|
||||
auxGeom->DrawAabb(aabb, AZ::Color(0.0f, 1.0f, 1.0f, 1.0f), RPI::AuxGeomDraw::DrawStyle::Line);
|
||||
}
|
||||
|
||||
if (debugOptions.m_drawSkeleton)
|
||||
@@ -132,14 +131,13 @@ namespace AZ
|
||||
const EMotionFX::Skeleton* skeleton = m_actorInstance->GetActor()->GetSkeleton();
|
||||
const EMotionFX::Pose* pose = transformData->GetCurrentPose();
|
||||
|
||||
const AZ::u32 transformCount = transformData->GetNumTransforms();
|
||||
const AZ::u32 lodLevel = m_actorInstance->GetLODLevel();
|
||||
const AZ::u32 numJoints = skeleton->GetNumNodes();
|
||||
const size_t lodLevel = m_actorInstance->GetLODLevel();
|
||||
const size_t numJoints = skeleton->GetNumNodes();
|
||||
|
||||
m_auxVertices.clear();
|
||||
m_auxVertices.reserve(numJoints * 2);
|
||||
|
||||
for (AZ::u32 jointIndex = 0; jointIndex < numJoints; ++jointIndex)
|
||||
for (size_t jointIndex = 0; jointIndex < numJoints; ++jointIndex)
|
||||
{
|
||||
const EMotionFX::Node* joint = skeleton->GetNode(jointIndex);
|
||||
if (!joint->GetSkeletalLODStatus(lodLevel))
|
||||
@@ -147,23 +145,23 @@ namespace AZ
|
||||
continue;
|
||||
}
|
||||
|
||||
const AZ::u32 parentIndex = joint->GetParentIndex();
|
||||
if (parentIndex == InvalidIndex32)
|
||||
const size_t parentIndex = joint->GetParentIndex();
|
||||
if (parentIndex == InvalidIndex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const AZ::Vector3 parentPos = pose->GetWorldSpaceTransform(parentIndex).mPosition;
|
||||
const AZ::Vector3 parentPos = pose->GetWorldSpaceTransform(parentIndex).m_position;
|
||||
m_auxVertices.emplace_back(parentPos);
|
||||
|
||||
const AZ::Vector3 bonePos = pose->GetWorldSpaceTransform(jointIndex).mPosition;
|
||||
const AZ::Vector3 bonePos = pose->GetWorldSpaceTransform(jointIndex).m_position;
|
||||
m_auxVertices.emplace_back(bonePos);
|
||||
}
|
||||
|
||||
const AZ::Color skeletonColor(0.604f, 0.804f, 0.196f, 1.0f);
|
||||
RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs;
|
||||
lineArgs.m_verts = m_auxVertices.data();
|
||||
lineArgs.m_vertCount = static_cast<uint32_t>(m_auxVertices.size());
|
||||
lineArgs.m_vertCount = aznumeric_caster(m_auxVertices.size());
|
||||
lineArgs.m_colors = &skeletonColor;
|
||||
lineArgs.m_colorCount = 1;
|
||||
lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off;
|
||||
@@ -204,9 +202,9 @@ namespace AZ
|
||||
|
||||
RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs;
|
||||
lineArgs.m_verts = m_auxVertices.data();
|
||||
lineArgs.m_vertCount = static_cast<uint32_t>(m_auxVertices.size());
|
||||
lineArgs.m_vertCount = aznumeric_caster(m_auxVertices.size());
|
||||
lineArgs.m_colors = m_auxColors.data();
|
||||
lineArgs.m_colorCount = static_cast<uint32_t>(m_auxColors.size());
|
||||
lineArgs.m_colorCount = aznumeric_caster(m_auxColors.size());
|
||||
lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off;
|
||||
auxGeom->DrawLines(lineArgs);
|
||||
}
|
||||
@@ -451,13 +449,13 @@ namespace AZ
|
||||
|
||||
AZ::u32 AtomActorInstance::GetJointCount()
|
||||
{
|
||||
return m_actorInstance->GetActor()->GetSkeleton()->GetNumNodes();
|
||||
return aznumeric_caster(m_actorInstance->GetActor()->GetSkeleton()->GetNumNodes());
|
||||
}
|
||||
|
||||
const char* AtomActorInstance::GetJointNameByIndex(AZ::u32 jointIndex)
|
||||
{
|
||||
EMotionFX::Skeleton* skeleton = m_actorInstance->GetActor()->GetSkeleton();
|
||||
const AZ::u32 numNodes = skeleton->GetNumNodes();
|
||||
const size_t numNodes = skeleton->GetNumNodes();
|
||||
if (jointIndex < numNodes)
|
||||
{
|
||||
return skeleton->GetNode(jointIndex)->GetName();
|
||||
@@ -471,12 +469,12 @@ namespace AZ
|
||||
if (jointName)
|
||||
{
|
||||
EMotionFX::Skeleton* skeleton = m_actorInstance->GetActor()->GetSkeleton();
|
||||
const AZ::u32 numNodes = skeleton->GetNumNodes();
|
||||
for (AZ::u32 nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex)
|
||||
const size_t numNodes = skeleton->GetNumNodes();
|
||||
for (size_t nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex)
|
||||
{
|
||||
if (0 == azstricmp(jointName, skeleton->GetNode(nodeIndex)->GetName()))
|
||||
{
|
||||
return nodeIndex;
|
||||
return aznumeric_caster(nodeIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -585,7 +583,8 @@ namespace AZ
|
||||
|
||||
// Update the morph weights for every lod. This does not mean they will all be dispatched, but they will all have up to date weights
|
||||
// TODO: once culling is hooked up such that EMotionFX and Atom are always in sync about which lod to update, only update the currently visible lods [ATOM-13564]
|
||||
for (uint32_t lodIndex = 0; lodIndex < m_actorInstance->GetActor()->GetNumLODLevels(); ++lodIndex)
|
||||
const auto lodCount = aznumeric_cast<uint32_t>(m_actorInstance->GetActor()->GetNumLODLevels());
|
||||
for (uint32_t lodIndex = 0; lodIndex < lodCount; ++lodIndex)
|
||||
{
|
||||
EMotionFX::MorphSetup* morphSetup = m_actorInstance->GetActor()->GetMorphSetup(lodIndex);
|
||||
if (morphSetup)
|
||||
@@ -594,9 +593,9 @@ namespace AZ
|
||||
m_wrinkleMasks.clear();
|
||||
m_wrinkleMaskWeights.clear();
|
||||
|
||||
uint32_t morphTargetCount = morphSetup->GetNumMorphTargets();
|
||||
size_t morphTargetCount = morphSetup->GetNumMorphTargets();
|
||||
m_morphTargetWeights.clear();
|
||||
for (uint32_t morphTargetIndex = 0; morphTargetIndex < morphTargetCount; ++morphTargetIndex)
|
||||
for (size_t morphTargetIndex = 0; morphTargetIndex < morphTargetCount; ++morphTargetIndex)
|
||||
{
|
||||
EMotionFX::MorphTarget* morphTarget = morphSetup->GetMorphTarget(morphTargetIndex);
|
||||
// check if we are dealing with a standard morph target
|
||||
@@ -612,11 +611,11 @@ namespace AZ
|
||||
|
||||
// Each morph target is split into several deform datas, all of which share the same weight but have unique min/max delta values
|
||||
// and thus correspond with unique dispatches in the morph target pass
|
||||
for (uint32_t deformDataIndex = 0; deformDataIndex < morphTargetStandard->GetNumDeformDatas(); ++deformDataIndex)
|
||||
for (size_t deformDataIndex = 0; deformDataIndex < morphTargetStandard->GetNumDeformDatas(); ++deformDataIndex)
|
||||
{
|
||||
// Morph targets that don't deform any vertices (e.g. joint-based morph targets) are not registered in the render proxy. Skip adding their weights.
|
||||
const EMotionFX::MorphTargetStandard::DeformData* deformData = morphTargetStandard->GetDeformData(deformDataIndex);
|
||||
if (deformData->mNumVerts > 0)
|
||||
if (deformData->m_numVerts > 0)
|
||||
{
|
||||
float weight = morphTargetSetupInstance->GetWeight();
|
||||
m_morphTargetWeights.push_back(weight);
|
||||
@@ -817,8 +816,8 @@ namespace AZ
|
||||
{
|
||||
const AZStd::vector<AZ::RPI::MorphTargetMetaAsset::MorphTarget>& metaDatas = actor->GetMorphTargetMetaAsset()->GetMorphTargets();
|
||||
// Loop over all the EMotionFX morph targets
|
||||
uint32_t numMorphTargets = morphSetup->GetNumMorphTargets();
|
||||
for (uint32_t morphTargetIndex = 0; morphTargetIndex < numMorphTargets; ++morphTargetIndex)
|
||||
size_t numMorphTargets = morphSetup->GetNumMorphTargets();
|
||||
for (size_t morphTargetIndex = 0; morphTargetIndex < numMorphTargets; ++morphTargetIndex)
|
||||
{
|
||||
EMotionFX::MorphTargetStandard* morphTarget = static_cast<EMotionFX::MorphTargetStandard*>(morphSetup->GetMorphTarget(morphTargetIndex));
|
||||
for (const RPI::MorphTargetMetaAsset::MorphTarget& metaData : metaDatas)
|
||||
@@ -862,7 +861,7 @@ namespace AZ
|
||||
// Set the weights for any active masks
|
||||
for (size_t i = 0; i < m_wrinkleMaskWeights.size(); ++i)
|
||||
{
|
||||
wrinkleMaskObjectSrg->SetConstant(wrinkleMaskWeightsIndex, m_wrinkleMaskWeights[i], static_cast<uint32_t>(i));
|
||||
wrinkleMaskObjectSrg->SetConstant(wrinkleMaskWeightsIndex, m_wrinkleMaskWeights[i], aznumeric_caster(i));
|
||||
}
|
||||
AZ_Error("AtomActorInstance", m_wrinkleMaskWeights.size() <= s_maxActiveWrinkleMasks, "The skinning shader supports no more than %d active morph targets with wrinkle masks.", s_maxActiveWrinkleMasks);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user