From b4bfb8b242df4e3e9025c6ea96ed34a8638941f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Wed, 29 Dec 2021 02:19:22 +0100 Subject: [PATCH] Refactored Math::Vector in CLevelParserParam, CObjectCondition and CScoreboard --- src/level/parser/parserparam.cpp | 10 +++++----- src/level/parser/parserparam.h | 6 +++--- src/level/scene_conditions.cpp | 6 +++--- src/level/scene_conditions.h | 6 +++--- src/level/scoreboard.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/level/parser/parserparam.cpp b/src/level/parser/parserparam.cpp index d8d22125..17694245 100644 --- a/src/level/parser/parserparam.cpp +++ b/src/level/parser/parserparam.cpp @@ -81,7 +81,7 @@ CLevelParserParam::CLevelParserParam(glm::vec2 value) LoadArray(); } -CLevelParserParam::CLevelParserParam(Math::Vector value) +CLevelParserParam::CLevelParserParam(glm::vec3 value) { m_array.push_back(MakeUnique(value.x)); if(value.y != 0.0f) @@ -304,7 +304,7 @@ Gfx::Color CLevelParserParam::AsColor(Gfx::Color def) } -Math::Vector CLevelParserParam::AsPoint() +glm::vec3 CLevelParserParam::AsPoint() { if (m_empty) throw CLevelParserExceptionMissingParam(this); @@ -313,11 +313,11 @@ Math::Vector CLevelParserParam::AsPoint() if (m_array.size() == 2) //XZ { - return Math::Vector(m_array[0]->AsFloat(), 0.0f, m_array[1]->AsFloat()); + return glm::vec3(m_array[0]->AsFloat(), 0.0f, m_array[1]->AsFloat()); } else if (m_array.size() == 3) //XYZ { - return Math::Vector(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat()); + return glm::vec3(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat()); } else { @@ -325,7 +325,7 @@ Math::Vector CLevelParserParam::AsPoint() } } -Math::Vector CLevelParserParam::AsPoint(Math::Vector def) +glm::vec3 CLevelParserParam::AsPoint(glm::vec3 def) { if (m_empty) return def; diff --git a/src/level/parser/parserparam.h b/src/level/parser/parserparam.h index 115a5917..b0dd5ea7 100644 --- a/src/level/parser/parserparam.h +++ b/src/level/parser/parserparam.h @@ -61,7 +61,7 @@ public: CLevelParserParam(bool value); CLevelParserParam(Gfx::Color value); CLevelParserParam(glm::vec2 value); - CLevelParserParam(Math::Vector value); + CLevelParserParam(glm::vec3 value); CLevelParserParam(ObjectType value); CLevelParserParam(Gfx::CameraType value); CLevelParserParam(CLevelParserParamVec&& array); @@ -79,7 +79,7 @@ public: bool AsBool(); std::string AsPath(const std::string defaultDir); Gfx::Color AsColor(); - Math::Vector AsPoint(); + glm::vec3 AsPoint(); ObjectType AsObjectType(); DriveType AsDriveType(); ToolType AsToolType(); @@ -103,7 +103,7 @@ public: bool AsBool(bool def); std::string AsPath(const std::string defaultDir, std::string def); Gfx::Color AsColor(Gfx::Color def); - Math::Vector AsPoint(Math::Vector def); + glm::vec3 AsPoint(glm::vec3 def); ObjectType AsObjectType(ObjectType def); DriveType AsDriveType(DriveType def); ToolType AsToolType(ToolType def); diff --git a/src/level/scene_conditions.cpp b/src/level/scene_conditions.cpp index b5c0965f..c71c2b7a 100644 --- a/src/level/scene_conditions.cpp +++ b/src/level/scene_conditions.cpp @@ -34,7 +34,7 @@ void CObjectCondition::Read(CLevelParserLine* line) { - this->pos = line->GetParam("pos")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f))*g_unit; + this->pos = line->GetParam("pos")->AsPoint(glm::vec3(0.0f, 0.0f, 0.0f))*g_unit; this->dist = line->GetParam("dist")->AsFloat(std::numeric_limits::infinity())*g_unit; this->type = line->GetParam("type")->AsObjectType(OBJECT_NULL); this->powermin = line->GetParam("powermin")->AsFloat(-1); @@ -96,14 +96,14 @@ bool CObjectCondition::CheckForObject(CObject* obj) } if (energyLevel < this->powermin || energyLevel > this->powermax) return false; - Math::Vector oPos; + glm::vec3 oPos{}; if (IsObjectBeingTransported(obj)) oPos = dynamic_cast(*obj).GetTransporter()->GetPosition(); else oPos = obj->GetPosition(); oPos.y = 0.0f; - Math::Vector bPos = this->pos; + glm::vec3 bPos = this->pos; bPos.y = 0.0f; if (Math::DistanceProjected(oPos, bPos) <= this->dist) diff --git a/src/level/scene_conditions.h b/src/level/scene_conditions.h index f225faaa..7b5b9109 100644 --- a/src/level/scene_conditions.h +++ b/src/level/scene_conditions.h @@ -27,12 +27,12 @@ #include "common/error.h" #include "common/global.h" -#include "math/vector.h" - #include "object/drive_type.h" #include "object/object_type.h" #include "object/tool_type.h" +#include + class CLevelParserLine; class CObject; @@ -43,7 +43,7 @@ class CObject; class CObjectCondition { public: - Math::Vector pos = Math::Vector(0.0f, 0.0f, 0.0f)*g_unit; + glm::vec3 pos = glm::vec3(0.0f, 0.0f, 0.0f) * g_unit; float dist = 8.0f*g_unit; ObjectType type = OBJECT_NULL; float powermin = -1; // wins if energy cell >= diff --git a/src/level/scoreboard.cpp b/src/level/scoreboard.cpp index 1acc2322..92420333 100644 --- a/src/level/scoreboard.cpp +++ b/src/level/scoreboard.cpp @@ -127,7 +127,7 @@ void CScoreboard::AddPoints(int team, int points) std::string text; GetResource(RES_ERR, INFO_TEAM_SCORE, text); text = StrUtils::Format(text.c_str(), main->GetTeamName(team).c_str(), points); - main->GetDisplayText()->DisplayText(text.c_str(), Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 10.0f, Ui::TT_WARNING); + main->GetDisplayText()->DisplayText(text.c_str(), glm::vec3(0.0f,0.0f,0.0f), 15.0f, 60.0f, 10.0f, Ui::TT_WARNING); m_score[team].points += points; m_score[team].time = main->GetGameTime();