Replaced the internal Vector3f and Vector4f data types and functions with the GLM library equivalents.

This commit is contained in:
Leon Styhre 2021-08-15 22:03:17 +02:00
parent 722468129e
commit 64a7b8e54a
14 changed files with 50 additions and 61 deletions

View file

@ -78,8 +78,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
folderPath + Utils::FileSystem::getFileName(scraperParams.game->getPath()) + " [" + folderPath + Utils::FileSystem::getFileName(scraperParams.game->getPath()) + " [" +
Utils::String::toUpper(scraperParams.system->getName()) + "]" + Utils::String::toUpper(scraperParams.system->getName()) + "]" +
(scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""), (scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""),
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER, Vector3f(0.0f, 0.0f, 0.0f), Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER, glm::vec3 {}, Vector2f(0.0f, 0.0f),
Vector2f(0.0f, 0.0f), 0x00000000, 0.05f); 0x00000000, 0.05f);
mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true); mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true);
mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true); mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true);

View file

@ -87,18 +87,14 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
mMD_ReleaseDate = std::make_shared<DateTimeEditComponent>(mWindow); mMD_ReleaseDate = std::make_shared<DateTimeEditComponent>(mWindow);
mMD_ReleaseDate->setColor(mdColor); mMD_ReleaseDate->setColor(mdColor);
mMD_ReleaseDate->setUppercase(true); mMD_ReleaseDate->setUppercase(true);
mMD_Developer = mMD_Developer = std::make_shared<TextComponent>(
std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT, Vector3f::Zero(), mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3 {}, Vector2f::Zero(), 0x00000000, 0.02f);
Vector2f::Zero(), 0x00000000, 0.02f); mMD_Publisher = std::make_shared<TextComponent>(
mMD_Publisher = mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3 {}, Vector2f::Zero(), 0x00000000, 0.02f);
std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT, Vector3f::Zero(), mMD_Genre = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT,
Vector2f::Zero(), 0x00000000, 0.02f); glm::vec3 {}, Vector2f::Zero(), 0x00000000, 0.02f);
mMD_Genre = mMD_Players = std::make_shared<TextComponent>(
std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT, Vector3f::Zero(), mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3 {}, Vector2f::Zero(), 0x00000000, 0.02f);
Vector2f::Zero(), 0x00000000, 0.02f);
mMD_Players =
std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT, Vector3f::Zero(),
Vector2f::Zero(), 0x00000000, 0.02f);
mMD_Filler = std::make_shared<TextComponent>(mWindow, "", font, mdColor); mMD_Filler = std::make_shared<TextComponent>(mWindow, "", font, mdColor);
if (Settings::getInstance()->getString("Scraper") != "thegamesdb") if (Settings::getInstance()->getString("Scraper") != "thegamesdb")

View file

@ -450,20 +450,20 @@ void ThemeData::parseElement(const pugi::xml_node& root,
switch (typeIt->second) { switch (typeIt->second) {
case NORMALIZED_RECT: { case NORMALIZED_RECT: {
Vector4f val; glm::vec4 val;
auto splits = Utils::String::delimitedStringToVector(str, " "); auto splits = Utils::String::delimitedStringToVector(str, " ");
if (splits.size() == 2) { if (splits.size() == 2) {
val = Vector4f(static_cast<float>(atof(splits.at(0).c_str())), val = glm::vec4(static_cast<float>(atof(splits.at(0).c_str())),
static_cast<float>(atof(splits.at(1).c_str())), static_cast<float>(atof(splits.at(1).c_str())),
static_cast<float>(atof(splits.at(0).c_str())), static_cast<float>(atof(splits.at(0).c_str())),
static_cast<float>(atof(splits.at(1).c_str()))); static_cast<float>(atof(splits.at(1).c_str())));
} }
else if (splits.size() == 4) { else if (splits.size() == 4) {
val = Vector4f(static_cast<float>(atof(splits.at(0).c_str())), val = glm::vec4(static_cast<float>(atof(splits.at(0).c_str())),
static_cast<float>(atof(splits.at(1).c_str())), static_cast<float>(atof(splits.at(1).c_str())),
static_cast<float>(atof(splits.at(2).c_str())), static_cast<float>(atof(splits.at(2).c_str())),
static_cast<float>(atof(splits.at(3).c_str()))); static_cast<float>(atof(splits.at(3).c_str())));
} }
element.properties[node.name()] = val; element.properties[node.name()] = val;

View file

@ -12,7 +12,6 @@
#define ES_CORE_THEME_DATA_H #define ES_CORE_THEME_DATA_H
#include "math/Vector2f.h" #include "math/Vector2f.h"
#include "math/Vector4f.h"
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include <deque> #include <deque>
@ -103,11 +102,11 @@ public:
std::string type; std::string type;
struct Property { struct Property {
void operator=(const Vector4f& value) void operator=(const glm::vec4& value)
{ {
r = value; r = value;
const Vector4f initVector = value; const glm::vec4 initVector = value;
v = Vector2f(initVector.x(), initVector.y()); v = Vector2f(initVector.x, initVector.y);
} }
void operator=(const Vector2f& value) { v = value; } void operator=(const Vector2f& value) { v = value; }
void operator=(const std::string& value) { s = value; } void operator=(const std::string& value) { s = value; }
@ -115,7 +114,7 @@ public:
void operator=(const float& value) { f = value; } void operator=(const float& value) { f = value; }
void operator=(const bool& value) { b = value; } void operator=(const bool& value) { b = value; }
Vector4f r; glm::vec4 r;
Vector2f v; Vector2f v;
std::string s; std::string s;
unsigned int i; unsigned int i;
@ -137,7 +136,7 @@ public:
return *(const T*)&properties.at(prop).f; return *(const T*)&properties.at(prop).f;
else if (std::is_same<T, bool>::value) else if (std::is_same<T, bool>::value)
return *(const T*)&properties.at(prop).b; return *(const T*)&properties.at(prop).b;
else if (std::is_same<T, Vector4f>::value) else if (std::is_same<T, glm::vec4>::value)
return *(const T*)&properties.at(prop).r; return *(const T*)&properties.at(prop).r;
return T(); return T();
} }

View file

@ -27,7 +27,7 @@ DateTimeComponent::DateTimeComponent(Window* window,
const std::shared_ptr<Font>& font, const std::shared_ptr<Font>& font,
unsigned int color, unsigned int color,
Alignment align, Alignment align,
Vector3f pos, glm::vec3 pos,
Vector2f size, Vector2f size,
unsigned int bgcolor) unsigned int bgcolor)
: TextComponent(window, text, font, color, align, pos, size, bgcolor) : TextComponent(window, text, font, color, align, pos, size, bgcolor)

View file

@ -26,7 +26,7 @@ public:
const std::shared_ptr<Font>& font, const std::shared_ptr<Font>& font,
unsigned int color = 0x000000FF, unsigned int color = 0x000000FF,
Alignment align = ALIGN_LEFT, Alignment align = ALIGN_LEFT,
Vector3f pos = Vector3f::Zero(), glm::vec3 pos = {},
Vector2f size = Vector2f::Zero(), Vector2f size = Vector2f::Zero(),
unsigned int bgcolor = 0x00000000); unsigned int bgcolor = 0x00000000);

View file

@ -303,19 +303,19 @@ void DateTimeEditComponent::updateTextCache()
Vector2f start(0, 0); Vector2f start(0, 0);
Vector2f end = font->sizeText(dispString.substr(0, 4)); Vector2f end = font->sizeText(dispString.substr(0, 4));
Vector2f diff = end - start; Vector2f diff = end - start;
mCursorBoxes.push_back(Vector4f(start[0], start[1], diff[0], diff[1])); mCursorBoxes.push_back(glm::vec4(start[0], start[1], diff[0], diff[1]));
// Month. // Month.
start[0] = font->sizeText(dispString.substr(0, 5)).x(); start[0] = font->sizeText(dispString.substr(0, 5)).x();
end = font->sizeText(dispString.substr(0, 7)); end = font->sizeText(dispString.substr(0, 7));
diff = end - start; diff = end - start;
mCursorBoxes.push_back(Vector4f(start[0], start[1], diff[0], diff[1])); mCursorBoxes.push_back(glm::vec4(start[0], start[1], diff[0], diff[1]));
// Day. // Day.
start[0] = font->sizeText(dispString.substr(0, 8)).x(); start[0] = font->sizeText(dispString.substr(0, 8)).x();
end = font->sizeText(dispString.substr(0, 10)); end = font->sizeText(dispString.substr(0, 10));
diff = end - start; diff = end - start;
mCursorBoxes.push_back(Vector4f(start[0], start[1], diff[0], diff[1])); mCursorBoxes.push_back(glm::vec4(start[0], start[1], diff[0], diff[1]));
// The logic for handling time for 'mode = DISP_DATE_TIME' is missing, but // The logic for handling time for 'mode = DISP_DATE_TIME' is missing, but
// nobody will use it anyway so it's not worthwhile implementing. // nobody will use it anyway so it's not worthwhile implementing.

View file

@ -82,7 +82,7 @@ private:
int mRelativeUpdateAccumulator; int mRelativeUpdateAccumulator;
std::unique_ptr<TextCache> mTextCache; std::unique_ptr<TextCache> mTextCache;
std::vector<Vector4f> mCursorBoxes; std::vector<glm::vec4> mCursorBoxes;
unsigned int mColor; unsigned int mColor;
Utils::Time::DateTime mOriginalValue; Utils::Time::DateTime mOriginalValue;

View file

@ -184,15 +184,15 @@ void GridTileComponent::setSelected(bool selected,
cancelAnimation(3); cancelAnimation(3);
this->setSelectedZoom(1); this->setSelectedZoom(1);
mAnimPosition = Vector3f(0, 0, 0); mAnimPosition = {};
resize(); resize();
} }
else { else {
mAnimPosition = Vector3f(pPosition->x, pPosition->y, pPosition->z); mAnimPosition = glm::vec3(pPosition->x, pPosition->y, pPosition->z);
auto func = [this](float t) { auto func = [this](float t) {
t -= 1; // Cubic ease out. t -= 1;
float pct = Math::lerp(0, 1, t * t * t + 1); float pct = Math::lerp(0, 1, t * t * t + 1);
this->setSelectedZoom(pct); this->setSelectedZoom(pct);
}; };
@ -202,7 +202,7 @@ void GridTileComponent::setSelected(bool selected,
new LambdaAnimation(func, 250), 0, new LambdaAnimation(func, 250), 0,
[this] { [this] {
this->setSelectedZoom(1); this->setSelectedZoom(1);
mAnimPosition = Vector3f(0, 0, 0); mAnimPosition = {};
}, },
false, 3); false, 3);
} }
@ -218,7 +218,7 @@ void GridTileComponent::setSelected(bool selected,
this->setSelectedZoom(1); this->setSelectedZoom(1);
auto func = [this](float t) { auto func = [this](float t) {
t -= 1.0f; // Cubic ease out. t -= 1.0f;
float pct = Math::lerp(0, 1, t * t * t + 1.0f); float pct = Math::lerp(0, 1, t * t * t + 1.0f);
this->setSelectedZoom(1.0f - pct); this->setSelectedZoom(1.0f - pct);
}; };

View file

@ -73,7 +73,7 @@ private:
bool mSelected; bool mSelected;
bool mVisible; bool mVisible;
Vector3f mAnimPosition; glm::vec3 mAnimPosition;
}; };
#endif // ES_CORE_COMPONENTS_GRID_TILE_COMPONENT_H #endif // ES_CORE_COMPONENTS_GRID_TILE_COMPONENT_H

View file

@ -101,7 +101,7 @@ private:
Vector2f mAutoLayout; Vector2f mAutoLayout;
float mAutoLayoutZoom; float mAutoLayoutZoom;
Vector4f mPadding; glm::vec4 mPadding;
Vector2f mMargin; Vector2f mMargin;
Vector2f mTileSize; Vector2f mTileSize;
Vector2i mGridDimension; Vector2i mGridDimension;
@ -144,7 +144,7 @@ ImageGridComponent<T>::ImageGridComponent(Window* window)
mSize = screen * 0.80f; mSize = screen * 0.80f;
mMargin = screen * 0.07f; mMargin = screen * 0.07f;
mPadding = Vector4f::Zero(); mPadding = {};
mTileSize = GridTileComponent::getDefaultTileSize(); mTileSize = GridTileComponent::getDefaultTileSize();
mAnimate = true; mAnimate = true;
@ -280,8 +280,8 @@ void ImageGridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
mMargin = elem->get<Vector2f>("margin") * screen; mMargin = elem->get<Vector2f>("margin") * screen;
if (elem->has("padding")) if (elem->has("padding"))
mPadding = elem->get<Vector4f>("padding") * mPadding = elem->get<glm::vec4>("padding") *
Vector4f(screen.x(), screen.y(), screen.x(), screen.y()); glm::vec4(screen.x(), screen.y(), screen.x(), screen.y());
if (elem->has("autoLayout")) if (elem->has("autoLayout"))
mAutoLayout = elem->get<Vector2f>("autoLayout"); mAutoLayout = elem->get<Vector2f>("autoLayout");
@ -506,7 +506,7 @@ template <typename T> void ImageGridComponent<T>::onCursorChanged(const CursorSt
if (!moveCamera) if (!moveCamera)
return; return;
t -= 1.0f; // Cubic ease out. t -= 1.0f;
float pct = Math::lerp(0, 1.0f, t * t * t + 1.0f); float pct = Math::lerp(0, 1.0f, t * t * t + 1.0f);
t = startPos * (1.0f - pct) + endPos * pct; t = startPos * (1.0f - pct) + endPos * pct;
mCamera = t; mCamera = t;
@ -538,12 +538,10 @@ template <typename T> void ImageGridComponent<T>::buildTiles()
Vector2f tileDistance = mTileSize + mMargin; Vector2f tileDistance = mTileSize + mMargin;
if (mAutoLayout.x() != 0.0f && mAutoLayout.y() != 0.0f) { if (mAutoLayout.x() != 0.0f && mAutoLayout.y() != 0.0f) {
auto x = auto x = (mSize.x() - (mMargin.x() * (mAutoLayout.x() - 1.0f)) - mPadding.x - mPadding.z) /
(mSize.x() - (mMargin.x() * (mAutoLayout.x() - 1.0f)) - mPadding.x() - mPadding.z()) / static_cast<int>(mAutoLayout.x());
static_cast<int>(mAutoLayout.x()); auto y = (mSize.y() - (mMargin.y() * (mAutoLayout.y() - 1.0f)) - mPadding.y - mPadding.w) /
auto y = static_cast<int>(mAutoLayout.y());
(mSize.y() - (mMargin.y() * (mAutoLayout.y() - 1.0f)) - mPadding.y() - mPadding.w()) /
static_cast<int>(mAutoLayout.y());
mTileSize = Vector2f(x, y); mTileSize = Vector2f(x, y);
tileDistance = mTileSize + mMargin; tileDistance = mTileSize + mMargin;
@ -551,7 +549,8 @@ template <typename T> void ImageGridComponent<T>::buildTiles()
bool vert = isVertical(); bool vert = isVertical();
Vector2f startPosition = mTileSize / 2.0f; Vector2f startPosition = mTileSize / 2.0f;
startPosition += mPadding.v2(); startPosition.x() += mPadding.x;
startPosition.y() += mPadding.y;
int X; int X;
int Y; int Y;

View file

@ -33,7 +33,7 @@ TextComponent::TextComponent(Window* window,
const std::shared_ptr<Font>& font, const std::shared_ptr<Font>& font,
unsigned int color, unsigned int color,
Alignment align, Alignment align,
Vector3f pos, glm::vec3 pos,
Vector2f size, Vector2f size,
unsigned int bgcolor, unsigned int bgcolor,
float margin) float margin)
@ -54,11 +54,7 @@ TextComponent::TextComponent(Window* window,
setColor(color); setColor(color);
setBackgroundColor(bgcolor); setBackgroundColor(bgcolor);
setText(text); setText(text);
setPosition(pos);
// TEMPORARY
glm::vec3 tempvec = { pos.x(), pos.y(), pos.z() };
setPosition(tempvec);
setSize(size); setSize(size);
} }

View file

@ -30,7 +30,7 @@ public:
const std::shared_ptr<Font>& font, const std::shared_ptr<Font>& font,
unsigned int color = 0x000000FF, unsigned int color = 0x000000FF,
Alignment align = ALIGN_LEFT, Alignment align = ALIGN_LEFT,
Vector3f pos = Vector3f::Zero(), glm::vec3 pos = {},
Vector2f size = Vector2f::Zero(), Vector2f size = Vector2f::Zero(),
unsigned int bgcolor = 0x00000000, unsigned int bgcolor = 0x00000000,
float margin = 0.0f); float margin = 0.0f);

View file

@ -12,7 +12,6 @@
#define GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES
#include "math/Misc.h" #include "math/Misc.h"
#include "math/Vector3f.h"
#if defined(_WIN64) #if defined(_WIN64)
#include <GL/glew.h> #include <GL/glew.h>