Refactored Math::Vector in CLevelParserParam, CObjectCondition and CScoreboard
parent
6277e10b3f
commit
b4bfb8b242
|
@ -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<CLevelParserParam>(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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<float>::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<CTransportableObject&>(*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)
|
||||
|
|
|
@ -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 <glm/glm.hpp>
|
||||
|
||||
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 >=
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue