Refactored Math::Point in CRobotMain, CObjectFactory, CBaseBuilding, CAutoInfo, CScript, CDebugMenu, CDisplayText and CObjectInterface

dev
Tomasz Kapuściński 2021-12-24 20:08:04 +01:00
parent dc99e19ed9
commit 77c6f8e54f
11 changed files with 116 additions and 114 deletions

View File

@ -230,7 +230,7 @@ CRobotMain::CRobotMain()
m_movieInfoIndex = -1; m_movieInfoIndex = -1;
m_tooltipPos = Math::Point(0.0f, 0.0f); m_tooltipPos = { 0.0f, 0.0f };
m_tooltipName.clear(); m_tooltipName.clear();
m_tooltipTime = 0.0f; m_tooltipTime = 0.0f;
@ -469,7 +469,7 @@ void CRobotMain::ChangePhase(Phase phase)
} }
ClearInterface(); ClearInterface();
Math::Point dim, pos; glm::vec2 dim, pos;
// Creates and hide the command console. // Creates and hide the command console.
dim.x = 200.0f/640.0f; dim.x = 200.0f/640.0f;
@ -585,7 +585,7 @@ void CRobotMain::ChangePhase(Phase phase)
CreateScene(false, true, false); // sets scene CreateScene(false, true, false); // sets scene
pos.x = ox+sx*1; pos.y = oy+sy*1; pos.x = ox+sx*1; pos.y = oy+sy*1;
Math::Point ddim; glm::vec2 ddim;
ddim.x = dim.x*2; ddim.y = dim.y*2; ddim.x = dim.x*2; ddim.y = dim.y*2;
m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK); m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK);
@ -629,7 +629,7 @@ void CRobotMain::ChangePhase(Phase phase)
CreateScene(false, true, false); // sets scene CreateScene(false, true, false); // sets scene
pos.x = ox+sx*1; pos.y = oy+sy*1; pos.x = ox+sx*1; pos.y = oy+sy*1;
Math::Point ddim; glm::vec2 ddim;
ddim.x = dim.x*2; ddim.y = dim.y*2; ddim.x = dim.x*2; ddim.y = dim.y*2;
m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK); m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK);
m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 1000.0f); m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 1000.0f);
@ -1760,7 +1760,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
// Creates the "continue" button. // Creates the "continue" button.
if (m_interface->SearchControl(EVENT_DT_END) == nullptr) if (m_interface->SearchControl(EVENT_DT_END) == nullptr)
{ {
Math::Point pos, dim; glm::vec2 pos, dim;
pos.x = 10.0f/640.0f; pos.x = 10.0f/640.0f;
pos.y = 10.0f/480.0f; pos.y = 10.0f/480.0f;
dim.x = 50.0f/640.0f; dim.x = 50.0f/640.0f;
@ -1820,7 +1820,7 @@ void CRobotMain::FrameVisit(float rTime)
float level = m_terrain->GetFloorLevel(pos)+2.0f; float level = m_terrain->GetFloorLevel(pos)+2.0f;
if (pos.y < level) pos.y = level; // not below the ground if (pos.y < level) pos.y = level; // not below the ground
Math::Vector speed(0.0f, 0.0f, 0.0f); Math::Vector speed(0.0f, 0.0f, 0.0f);
Math::Point dim; glm::vec2 dim;
dim.x = 30.0f; dim.x = 30.0f;
dim.y = dim.x; dim.y = dim.x;
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISHOW, 2.0f); m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISHOW, 2.0f);
@ -2024,7 +2024,7 @@ CObject* CRobotMain::GetSelect()
} }
//! Detects the object aimed by the mouse //! Detects the object aimed by the mouse
CObject* CRobotMain::DetectObject(Math::Point pos) CObject* CRobotMain::DetectObject(const glm::vec2& pos)
{ {
Math::Vector p; Math::Vector p;
int objRank = m_engine->DetectObject(pos, p); int objRank = m_engine->DetectObject(pos, p);
@ -2112,7 +2112,7 @@ void CRobotMain::HiliteClear()
} }
//! Highlights the object with the mouse hovers over //! Highlights the object with the mouse hovers over
void CRobotMain::HiliteObject(Math::Point pos) void CRobotMain::HiliteObject(const glm::vec2& pos)
{ {
if (m_fixScene && m_phase != PHASE_APPERANCE) return; if (m_fixScene && m_phase != PHASE_APPERANCE) return;
if (m_movieLock) return; if (m_movieLock) return;
@ -2195,13 +2195,15 @@ void CRobotMain::HiliteFrame(float rTime)
} }
//! Creates a tooltip //! Creates a tooltip
void CRobotMain::CreateTooltip(Math::Point pos, const std::string& text) void CRobotMain::CreateTooltip(const glm::vec2& position, const std::string& text)
{ {
Math::Point corner; glm::vec2 pos = position;
glm::vec2 corner;
corner.x = pos.x+0.022f; corner.x = pos.x+0.022f;
corner.y = pos.y-0.052f; corner.y = pos.y-0.052f;
Math::Point start, end; glm::vec2 start, end;
m_engine->GetText()->SizeText(text, Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL, m_engine->GetText()->SizeText(text, Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL,
corner, Gfx::TEXT_ALIGN_LEFT, corner, Gfx::TEXT_ALIGN_LEFT,
@ -2215,11 +2217,11 @@ void CRobotMain::CreateTooltip(Math::Point pos, const std::string& text)
pos.x = start.x; pos.x = start.x;
pos.y = start.y; pos.y = start.y;
Math::Point dim; glm::vec2 dim;
dim.x = end.x-start.x; dim.x = end.x-start.x;
dim.y = end.y-start.y; dim.y = end.y-start.y;
Math::Point offset; glm::vec2 offset;
offset.x = 0.0f; offset.x = 0.0f;
offset.y = 0.0f; offset.y = 0.0f;
if (pos.x+dim.x > 1.0f) offset.x = 1.0f-(pos.x+dim.x); if (pos.x+dim.x > 1.0f) offset.x = 1.0f-(pos.x+dim.x);
@ -2517,7 +2519,7 @@ bool CRobotMain::EventFrame(const Event &event)
Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_MOVIELOCK); Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_MOVIELOCK);
if (pc != nullptr) if (pc != nullptr)
{ {
Math::Point pos, dim; glm::vec2 pos, dim;
dim.x = 32.0f/640.0f; dim.x = 32.0f/640.0f;
dim.y = 32.0f/480.0f; dim.y = 32.0f/480.0f;
@ -2541,7 +2543,7 @@ bool CRobotMain::EventFrame(const Event &event)
Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK); Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK);
if (pc != nullptr) if (pc != nullptr)
{ {
Math::Point pos, dim; glm::vec2 pos, dim;
if (m_editFull || m_editLock) if (m_editFull || m_editLock)
{ {
@ -2571,7 +2573,7 @@ bool CRobotMain::EventFrame(const Event &event)
Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_SAVING); Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_SAVING);
if (pc != nullptr) if (pc != nullptr)
{ {
Math::Point pos, dim; glm::vec2 pos, dim;
if (m_shotSaving <= 0) if (m_shotSaving <= 0)
{ {
@ -2671,7 +2673,7 @@ void CRobotMain::ShowSaveIndicator(bool show)
Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_SAVING); Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_SAVING);
if (pc != nullptr) if (pc != nullptr)
{ {
Math::Point pos, dim; glm::vec2 pos, dim;
if (!show) if (!show)
{ {
@ -3159,13 +3161,13 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
uv1 = line->GetParam("uv1")->AsPoint(); uv1 = line->GetParam("uv1")->AsPoint();
uv2 = line->GetParam("uv2")->AsPoint(); uv2 = line->GetParam("uv2")->AsPoint();
m_planet->Create(line->GetParam("mode")->AsPlanetType(), m_planet->Create(line->GetParam("mode")->AsPlanetType(),
Math::Point(ppos.x, ppos.z), { ppos.x, ppos.z },
line->GetParam("dim")->AsFloat(0.2f), line->GetParam("dim")->AsFloat(0.2f),
line->GetParam("speed")->AsFloat(0.0f), line->GetParam("speed")->AsFloat(0.0f),
line->GetParam("dir")->AsFloat(0.0f), line->GetParam("dir")->AsFloat(0.0f),
line->GetParam("image")->AsPath("textures"), line->GetParam("image")->AsPath("textures"),
Math::Point(uv1.x, uv1.z), { uv1.x, uv1.z },
Math::Point(uv2.x, uv2.z), { uv2.x, uv2.z },
line->GetParam("image")->AsPath("textures").find("planet") != std::string::npos // TODO: add transparent op or modify textures line->GetParam("image")->AsPath("textures").find("planet") != std::string::npos // TODO: add transparent op or modify textures
); );
continue; continue;
@ -3336,8 +3338,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_terrain->AddMaterial(line->GetParam("id")->AsInt(0), m_terrain->AddMaterial(line->GetParam("id")->AsInt(0),
name.c_str(), name.c_str(),
Math::Point(line->GetParam("u")->AsFloat(), { line->GetParam("u")->AsFloat(),
line->GetParam("v")->AsFloat()), line->GetParam("v")->AsFloat() },
line->GetParam("up")->AsInt(), line->GetParam("up")->AsInt(),
line->GetParam("right")->AsInt(), line->GetParam("right")->AsInt(),
line->GetParam("down")->AsInt(), line->GetParam("down")->AsInt(),
@ -3497,7 +3499,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
float delay = line->GetParam("delay")->AsFloat(2.0f); float delay = line->GetParam("delay")->AsFloat(2.0f);
m_terrain->AdjustToFloor(pos); m_terrain->AdjustToFloor(pos);
pos.y += height; pos.y += height;
Math::Point dim; glm::vec2 dim;
dim.x = ddim; dim.x = ddim;
dim.y = dim.x; dim.y = dim.x;
m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, type, delay, 0.0f, 0.0f); m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, type, delay, 0.0f, 0.0f);
@ -3962,8 +3964,8 @@ void CRobotMain::ChangeColor()
// Player texture // Player texture
Math::Point ts = Math::Point(0.0f, 0.0f); glm::vec2 ts = { 0.0f, 0.0f };
Math::Point ti = Math::Point(1.0f, 1.0f); // the entire image glm::vec2 ti = { 1.0f, 1.0f }; // the entire image
Gfx::Color colorRef1, colorNew1, colorRef2, colorNew2; Gfx::Color colorRef1, colorNew1, colorRef2, colorNew2;
@ -3979,13 +3981,13 @@ void CRobotMain::ChangeColor()
colorRef2.b = 1.0f/256.0f; // orange colorRef2.b = 1.0f/256.0f; // orange
colorNew2 = m_playerProfile->GetApperance().colorBand; colorNew2 = m_playerProfile->GetApperance().colorBand;
Math::Point exclu[6]; glm::vec2 exclu[6];
exclu[0] = Math::Point(192.0f/256.0f, 0.0f/256.0f); exclu[0] = { 192.0f / 256.0f, 0.0f / 256.0f };
exclu[1] = Math::Point(256.0f/256.0f, 64.0f/256.0f); // crystals + cylinders exclu[1] = { 256.0f / 256.0f, 64.0f / 256.0f }; // crystals + cylinders
exclu[2] = Math::Point(208.0f/256.0f, 224.0f/256.0f); exclu[2] = { 208.0f / 256.0f, 224.0f / 256.0f };
exclu[3] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom screen exclu[3] = { 256.0f / 256.0f, 256.0f / 256.0f }; // SatCom screen
exclu[4] = Math::Point(0.0f, 0.0f); exclu[4] = { 0.0f, 0.0f };
exclu[5] = Math::Point(0.0f, 0.0f); // terminator exclu[5] = { 0.0f, 0.0f }; // terminator
m_engine->ChangeTextureColor("textures/objects/human.png", colorRef1, colorNew1, colorRef2, colorNew2, 0.30f, 0.01f, ts, ti, exclu); m_engine->ChangeTextureColor("textures/objects/human.png", colorRef1, colorNew1, colorRef2, colorNew2, 0.30f, 0.01f, ts, ti, exclu);
float tolerance; float tolerance;
@ -4029,10 +4031,10 @@ void CRobotMain::ChangeColor()
char name[100]; char name[100];
sprintf(name, "textures/objects/face%.2d.png", face+1); sprintf(name, "textures/objects/face%.2d.png", face+1);
exclu[0] = Math::Point(105.0f/256.0f, 47.0f/166.0f); exclu[0] = { 105.0f / 256.0f, 47.0f / 166.0f };
exclu[1] = Math::Point(153.0f/256.0f, 79.0f/166.0f); // blue canister exclu[1] = { 153.0f / 256.0f, 79.0f / 166.0f }; // blue canister
exclu[2] = Math::Point(0.0f, 0.0f); exclu[2] = { 0.0f, 0.0f };
exclu[3] = Math::Point(0.0f, 0.0f); // terminator exclu[3] = { 0.0f, 0.0f }; // terminator
m_engine->ChangeTextureColor(name, colorRef1, colorNew1, colorRef2, colorNew2, tolerance, 0.00f, ts, ti, exclu); m_engine->ChangeTextureColor(name, colorRef1, colorNew1, colorRef2, colorNew2, tolerance, 0.00f, ts, ti, exclu);
colorRef2.r = 0.0f; colorRef2.r = 0.0f;
@ -4044,7 +4046,7 @@ void CRobotMain::ChangeColor()
// VehicleColor // VehicleColor
for (auto it : m_colorNewBot) for (const auto& it : m_colorNewBot)
{ {
int team = it.first; int team = it.first;
Gfx::Color newColor = it.second; Gfx::Color newColor = it.second;
@ -4060,27 +4062,27 @@ void CRobotMain::ChangeColor()
m_engine->ChangeTextureColor("textures/objects/search.png"+teamStr, "textures/objects/search.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, nullptr, 0, true); m_engine->ChangeTextureColor("textures/objects/search.png"+teamStr, "textures/objects/search.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, nullptr, 0, true);
m_engine->ChangeTextureColor("textures/objects/rollert.png"+teamStr, "textures/objects/rollert.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, nullptr, 0, true); m_engine->ChangeTextureColor("textures/objects/rollert.png"+teamStr, "textures/objects/rollert.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, nullptr, 0, true);
exclu[0] = Math::Point( 0.0f/256.0f, 160.0f/256.0f); exclu[0] = { 0.0f / 256.0f, 160.0f / 256.0f };
exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // pencils exclu[1] = { 256.0f / 256.0f, 256.0f / 256.0f }; // pencils
exclu[2] = Math::Point(0.0f, 0.0f); exclu[2] = { 0.0f, 0.0f };
exclu[3] = Math::Point(0.0f, 0.0f); // terminator exclu[3] = { 0.0f, 0.0f }; // terminator
m_engine->ChangeTextureColor("textures/objects/drawer.png"+teamStr, "textures/objects/drawer.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); m_engine->ChangeTextureColor("textures/objects/drawer.png"+teamStr, "textures/objects/drawer.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true);
exclu[0] = Math::Point(237.0f/256.0f, 176.0f/256.0f); exclu[0] = { 237.0f / 256.0f, 176.0f / 256.0f };
exclu[1] = Math::Point(256.0f/256.0f, 220.0f/256.0f); // blue canister exclu[1] = { 256.0f / 256.0f, 220.0f / 256.0f }; // blue canister
exclu[2] = Math::Point(106.0f/256.0f, 150.0f/256.0f); exclu[2] = { 106.0f / 256.0f, 150.0f / 256.0f };
exclu[3] = Math::Point(130.0f/256.0f, 214.0f/256.0f); // safe location exclu[3] = { 130.0f / 256.0f, 214.0f / 256.0f }; // safe location
exclu[4] = Math::Point(0.0f, 0.0f); exclu[4] = { 0.0f, 0.0f };
exclu[5] = Math::Point(0.0f, 0.0f); // terminator exclu[5] = { 0.0f, 0.0f }; // terminator
m_engine->ChangeTextureColor("textures/objects/subm.png"+teamStr, "textures/objects/subm.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); m_engine->ChangeTextureColor("textures/objects/subm.png"+teamStr, "textures/objects/subm.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true);
} }
// AlienColor // AlienColor
exclu[0] = Math::Point(128.0f/256.0f, 160.0f/256.0f); exclu[0] = { 128.0f / 256.0f, 160.0f / 256.0f };
exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom exclu[1] = { 256.0f / 256.0f, 256.0f / 256.0f }; // SatCom
exclu[2] = Math::Point(0.0f, 0.0f); exclu[2] = { 0.0f, 0.0f };
exclu[3] = Math::Point(0.0f, 0.0f); // terminator exclu[3] = { 0.0f, 0.0f }; // terminator
m_engine->ChangeTextureColor("textures/objects/ant.png", COLOR_REF_ALIEN, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti, exclu); m_engine->ChangeTextureColor("textures/objects/ant.png", COLOR_REF_ALIEN, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti, exclu);
m_engine->ChangeTextureColor("textures/objects/mother.png", COLOR_REF_ALIEN, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti); m_engine->ChangeTextureColor("textures/objects/mother.png", COLOR_REF_ALIEN, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti);
@ -4090,13 +4092,13 @@ void CRobotMain::ChangeColor()
// water color // water color
// PARTIPLOUF0 and PARTIDROP : // PARTIPLOUF0 and PARTIDROP :
ts = Math::Point(0.500f, 0.500f); ts = { 0.500f, 0.500f };
ti = Math::Point(0.875f, 0.750f); ti = { 0.875f, 0.750f };
m_engine->ChangeTextureColor("textures/effect00.png", COLOR_REF_WATER, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, nullptr, m_colorShiftWater, true); m_engine->ChangeTextureColor("textures/effect00.png", COLOR_REF_WATER, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, nullptr, m_colorShiftWater, true);
// PARTIFLIC : // PARTIFLIC :
ts = Math::Point(0.00f, 0.75f); ts = { 0.00f, 0.75f };
ti = Math::Point(0.25f, 1.00f); ti = { 0.25f, 1.00f };
m_engine->ChangeTextureColor("textures/effect02.png", COLOR_REF_WATER, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, nullptr, m_colorShiftWater, true); m_engine->ChangeTextureColor("textures/effect02.png", COLOR_REF_WATER, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, nullptr, m_colorShiftWater, true);
} }
@ -4163,10 +4165,10 @@ bool CRobotMain::FreeSpace(Math::Vector &center, float minRadius, float maxRadiu
float ia = space/radius; float ia = space/radius;
for (float angle = 0.0f; angle < Math::PI*2.0f; angle += ia) for (float angle = 0.0f; angle < Math::PI*2.0f; angle += ia)
{ {
Math::Point p; glm::vec2 p;
p.x = center.x+radius; p.x = center.x+radius;
p.y = center.z; p.y = center.z;
p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p); p = Math::RotatePoint({ center.x, center.z }, angle, p);
Math::Vector pos; Math::Vector pos;
pos.x = p.x; pos.x = p.x;
pos.z = p.y; pos.z = p.y;
@ -4192,10 +4194,10 @@ bool CRobotMain::FreeSpace(Math::Vector &center, float minRadius, float maxRadiu
float ia = space/radius; float ia = space/radius;
for (float angle=0.0f ; angle<Math::PI*2.0f ; angle+=ia ) for (float angle=0.0f ; angle<Math::PI*2.0f ; angle+=ia )
{ {
Math::Point p; glm::vec2 p;
p.x = center.x+radius; p.x = center.x+radius;
p.y = center.z; p.y = center.z;
p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p); p = Math::RotatePoint({ center.x, center.z }, angle, p);
Math::Vector pos; Math::Vector pos;
pos.x = p.x; pos.x = p.x;
pos.z = p.y; pos.z = p.y;
@ -4228,10 +4230,10 @@ bool CRobotMain::FlatFreeSpace(Math::Vector &center, float minFlat, float minRad
float ia = space/radius; float ia = space/radius;
for (float angle = 0.0f; angle < Math::PI*2.0f; angle += ia) for (float angle = 0.0f; angle < Math::PI*2.0f; angle += ia)
{ {
Math::Point p; glm::vec2 p;
p.x = center.x+radius; p.x = center.x+radius;
p.y = center.z; p.y = center.z;
p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p); p = Math::RotatePoint({ center.x, center.z }, angle, p);
Math::Vector pos; Math::Vector pos;
pos.x = p.x; pos.x = p.x;
pos.z = p.y; pos.z = p.y;
@ -4261,10 +4263,10 @@ bool CRobotMain::FlatFreeSpace(Math::Vector &center, float minFlat, float minRad
float ia = space/radius; float ia = space/radius;
for (float angle=0.0f ; angle<Math::PI*2.0f ; angle+=ia ) for (float angle=0.0f ; angle<Math::PI*2.0f ; angle+=ia )
{ {
Math::Point p; glm::vec2 p;
p.x = center.x+radius; p.x = center.x+radius;
p.y = center.z; p.y = center.z;
p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p); p = Math::RotatePoint({ center.x, center.z }, angle, p);
Math::Vector pos; Math::Vector pos;
pos.x = p.x; pos.x = p.x;
pos.z = p.y; pos.z = p.y;
@ -4417,16 +4419,16 @@ void CRobotMain::SetShowLimit(int i, Gfx::ParticleType parti, CObject *obj,
if (radius <= 0.0f) return; if (radius <= 0.0f) return;
Math::Point dim; glm::vec2 dim;
float dist; float dist;
if (radius <= 50.0f) if (radius <= 50.0f)
{ {
dim = Math::Point(0.3f, 0.3f); dim = { 0.3f, 0.3f };
dist = 2.5f; dist = 2.5f;
} }
else else
{ {
dim = Math::Point(1.5f, 1.5f); dim = { 1.5f, 1.5f };
dist = 10.0f; dist = 10.0f;
} }
@ -4494,10 +4496,10 @@ void CRobotMain::FrameShowLimit(float rTime)
{ {
if (m_showLimit[i].parti[j] == 0) continue; if (m_showLimit[i].parti[j] == 0) continue;
Math::Point center; glm::vec2 center;
center.x = m_showLimit[i].pos.x; center.x = m_showLimit[i].pos.x;
center.y = m_showLimit[i].pos.z; center.y = m_showLimit[i].pos.z;
Math::Point rotate; glm::vec2 rotate;
rotate.x = center.x+m_showLimit[i].radius*factor; rotate.x = center.x+m_showLimit[i].radius*factor;
rotate.y = center.y; rotate.y = center.y;
rotate = Math::RotatePoint(center, angle, rotate); rotate = Math::RotatePoint(center, angle, rotate);
@ -6050,7 +6052,7 @@ void CRobotMain::StartDetectEffect(COldObject* object, CObject* target)
{ {
Math::Matrix* mat; Math::Matrix* mat;
Math::Vector pos, goal; Math::Vector pos, goal;
Math::Point dim; glm::vec2 dim;
mat = object->GetWorldMatrix(0); mat = object->GetWorldMatrix(0);
pos = Math::Transform(*mat, Math::Vector(2.0f, 3.0f, 0.0f)); pos = Math::Transform(*mat, Math::Vector(2.0f, 3.0f, 0.0f));
@ -6088,7 +6090,7 @@ void CRobotMain::CreateCodeBattleInterface()
{ {
if (m_phase == PHASE_SIMUL) if (m_phase == PHASE_SIMUL)
{ {
Math::Point pos, ddim; glm::vec2 pos, ddim;
float offset = (ceil(m_viewpoints.size() / 2.0f) * 50); float offset = (ceil(m_viewpoints.size() / 2.0f) * 50);
int numTeams = m_scoreboard ? GetAllTeams().size() : 0; int numTeams = m_scoreboard ? GetAllTeams().size() : 0;

View File

@ -501,11 +501,11 @@ protected:
int CreateLight(Math::Vector direction, Gfx::Color color); int CreateLight(Math::Vector direction, Gfx::Color color);
void HiliteClear(); void HiliteClear();
void HiliteObject(Math::Point pos); void HiliteObject(const glm::vec2& pos);
void HiliteFrame(float rTime); void HiliteFrame(float rTime);
void CreateTooltip(Math::Point pos, const std::string& text); void CreateTooltip(const glm::vec2& pos, const std::string& text);
void ClearTooltip(); void ClearTooltip();
CObject* DetectObject(Math::Point pos); CObject* DetectObject(const glm::vec2& pos);
void ChangeCamera(); void ChangeCamera();
void AbortMovie(); void AbortMovie();
//! \brief Select an object, without deselecting the previous one //! \brief Select an object, without deselecting the previous one
@ -640,7 +640,7 @@ protected:
ActivePause* m_suspend = nullptr; ActivePause* m_suspend = nullptr;
Math::Point m_tooltipPos; glm::vec2 m_tooltipPos;
std::string m_tooltipName; std::string m_tooltipName;
float m_tooltipTime = 0.0f; float m_tooltipTime = 0.0f;

View File

@ -1184,7 +1184,7 @@ CObjectUPtr CObjectFactory::CreateTeen(const ObjectCreateParams& params)
Math::Matrix* mat = obj->GetWorldMatrix(0); Math::Matrix* mat = obj->GetWorldMatrix(0);
pos = Math::Transform(*mat, Math::Vector(-56.0f, 22.0f, 0.0f)); pos = Math::Transform(*mat, Math::Vector(-56.0f, 22.0f, 0.0f));
m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(20.0f, 20.0f), Gfx::PARTISELY, 1.0f, 0.0f, 0.0f); m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), { 20.0f, 20.0f }, Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
pos = Math::Transform(*mat, Math::Vector(-65.0f, 40.0f, 0.0f)); pos = Math::Transform(*mat, Math::Vector(-65.0f, 40.0f, 0.0f));
Gfx::Color color; Gfx::Color color;
@ -1446,7 +1446,7 @@ CObjectUPtr CObjectFactory::CreateTeen(const ObjectCreateParams& params)
Math::Matrix* mat = obj->GetWorldMatrix(0); Math::Matrix* mat = obj->GetWorldMatrix(0);
pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f)); pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f));
m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(100.0f, 100.0f), Gfx::PARTISELY, 1.0f, 0.0f, 0.0f); m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), { 100.0f, 100.0f }, Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f)); pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f));
Gfx::Color color; Gfx::Color color;
@ -1834,8 +1834,8 @@ CObjectUPtr CObjectFactory::CreateQuartz(const ObjectCreateParams& params)
pos.y += 16.0f; pos.y += 16.0f;
radius = 8.0f; radius = 8.0f;
} }
m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f); m_particle->CreateParticle(pos, pos, { 2.0f, 2.0f }, Gfx::PARTIQUARTZ, 0.7f + Math::Rand() * 0.7f, radius, 0.0f);
m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f); m_particle->CreateParticle(pos, pos, { 2.0f, 2.0f }, Gfx::PARTIQUARTZ, 0.7f + Math::Rand() * 0.7f, radius, 0.0f);
return std::move(obj); return std::move(obj);
} }

View File

@ -1368,14 +1368,14 @@ void COldObject::SetFloorHeight(float height)
void COldObject::FloorAdjust() void COldObject::FloorAdjust()
{ {
Math::Vector pos, n; Math::Vector pos, n;
Math::Point nn; glm::vec2 nn;
float a; float a;
pos = GetPosition(); pos = GetPosition();
if ( m_terrain->GetNormal(n, pos) ) if ( m_terrain->GetNormal(n, pos) )
{ {
a = GetRotationY(); a = GetRotationY();
nn = Math::RotatePoint(-a, Math::Point(n.z, n.x)); nn = Math::RotatePoint(-a, { n.z, n.x });
SetRotationX( sinf(nn.x)); SetRotationX( sinf(nn.x));
SetRotationZ(-sinf(nn.y)); SetRotationZ(-sinf(nn.y));
} }
@ -2304,7 +2304,7 @@ void COldObject::VirusFrame(float rTime)
speed.x = (Math::Rand()-0.5f)*2.0f; speed.x = (Math::Rand()-0.5f)*2.0f;
speed.z = (Math::Rand()-0.5f)*2.0f; speed.z = (Math::Rand()-0.5f)*2.0f;
speed.y = Math::Rand()*4.0f+4.0f; speed.y = Math::Rand()*4.0f+4.0f;
Math::Point dim; glm::vec2 dim;
dim.x = Math::Rand()*0.3f+0.3f; dim.x = Math::Rand()*0.3f+0.3f;
dim.y = dim.x; dim.y = dim.x;
@ -2921,7 +2921,7 @@ float COldObject::GetShowLimitRadius()
void COldObject::CreateSelectParticle() void COldObject::CreateSelectParticle()
{ {
Math::Vector pos, speed; Math::Vector pos, speed;
Math::Point dim; glm::vec2 dim;
int i; int i;
// Removes particles preceding. // Removes particles preceding.
@ -2989,7 +2989,7 @@ void COldObject::CreateSelectParticle()
void COldObject::UpdateSelectParticle() void COldObject::UpdateSelectParticle()
{ {
Math::Vector pos[4]; Math::Vector pos[4];
Math::Point dim[4]; glm::vec2 dim[4];
float zoom[4]; float zoom[4];
float angle; float angle;
int i; int i;

View File

@ -197,7 +197,7 @@ std::unique_ptr<CBaseBuilding> CBaseBuilding::Create(
obj->SetObjectRank(1+i, rank); obj->SetObjectRank(1+i, rank);
obj->SetObjectParent(1+i, 0); obj->SetObjectParent(1+i, 0);
modelManager->AddModelReference("base2.mod", false, rank, params.team); modelManager->AddModelReference("base2.mod", false, rank, params.team);
Math::Point p = Math::RotatePoint(-Math::PI/4.0f*i, 27.8f); glm::vec2 p = Math::RotatePoint(-Math::PI/4.0f*i, 27.8f);
obj->SetPartPosition(1+i, Math::Vector(p.x, 30.0f, p.y)); obj->SetPartPosition(1+i, Math::Vector(p.x, 30.0f, p.y));
obj->SetPartRotationY(1+i, Math::PI/4.0f*i); obj->SetPartRotationY(1+i, Math::PI/4.0f*i);
obj->SetPartRotationZ(1+i, Math::PI/2.0f); obj->SetPartRotationZ(1+i, Math::PI/2.0f);

View File

@ -313,7 +313,7 @@ void CAutoInfo::Start(int param)
m_goal = m_object->GetPosition(); m_goal = m_object->GetPosition();
Math::Vector pos, speed; Math::Vector pos, speed;
Math::Point dim; glm::vec2 dim;
if (m_phase == Phase::Send) if (m_phase == Phase::Send)
{ {
@ -411,7 +411,7 @@ bool CAutoInfo::EventProcess(const Event &event)
speed.z = (Math::Rand()-0.5f)*50.0f; speed.z = (Math::Rand()-0.5f)*50.0f;
speed.y = (Math::Rand()-0.5f)*50.0f; speed.y = (Math::Rand()-0.5f)*50.0f;
speed *= 0.5f+m_progress*0.5f; speed *= 0.5f+m_progress*0.5f;
Math::Point dim(0.6f, 0.6f); glm::vec2 dim(0.6f, 0.6f);
float duration = Math::Rand()*0.5f+0.5f; float duration = Math::Rand()*0.5f+0.5f;
m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6, m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
duration, 0.0f, duration, 0.0f,
@ -458,7 +458,7 @@ bool CAutoInfo::EventProcess(const Event &event)
pos.z += (Math::Rand()-0.5f)*40.0f; pos.z += (Math::Rand()-0.5f)*40.0f;
speed = (speed-pos)*1.0f; speed = (speed-pos)*1.0f;
//? speed *= 0.5f+m_progress*0.5f; //? speed *= 0.5f+m_progress*0.5f;
Math::Point dim(0.6f, 0.6f); glm::vec2 dim(0.6f, 0.6f);
float duration = Math::Rand()*0.5f+0.5f; float duration = Math::Rand()*0.5f+0.5f;
m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6, m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
duration, 0.0f, duration, 0.0f,
@ -500,7 +500,7 @@ bool CAutoInfo::EventProcess(const Event &event)
speed.x = (Math::Rand()-0.5f)*5.0f; speed.x = (Math::Rand()-0.5f)*5.0f;
speed.z = (Math::Rand()-0.5f)*5.0f; speed.z = (Math::Rand()-0.5f)*5.0f;
speed.y = 5.0f+Math::Rand()*5.0f; speed.y = 5.0f+Math::Rand()*5.0f;
Math::Point dim; glm::vec2 dim;
dim.x = 5.0f+Math::Rand()*5.0f; dim.x = 5.0f+Math::Rand()*5.0f;
dim.y = dim.x; dim.y = dim.x;
float duration = 4.0f; float duration = 4.0f;
@ -578,7 +578,7 @@ bool CAutoInfo::CreateInterface(bool select)
float sx = 33.0f/640.0f; float sx = 33.0f/640.0f;
float sy = 33.0f/480.0f; float sy = 33.0f/480.0f;
Math::Point pos, ddim; glm::vec2 pos, ddim;
pos.x = ox+sx*7.0f; pos.x = ox+sx*7.0f;
pos.y = oy+sy*0.0f; pos.y = oy+sy*0.0f;

View File

@ -985,7 +985,7 @@ bool CScript::SendScript(const char* text)
if ( !CheckToken() ) return false; if ( !CheckToken() ) return false;
if ( !Compile() ) return false;*/ if ( !Compile() ) return false;*/
Ui::CEdit* edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9); Ui::CEdit* edit = m_interface->CreateEdit({ 0.0f, 0.0f }, { 0.0f, 0.0f }, 0, EVENT_EDIT9);
edit->SetAutoIndent(m_engine->GetEditIndentMode()); edit->SetAutoIndent(m_engine->GetEditIndentMode());
edit->SetText(text, true); edit->SetText(text, true);
GetScript(edit); GetScript(edit);
@ -1004,7 +1004,7 @@ bool CScript::ReadScript(const char* filename)
m_script.reset(); m_script.reset();
edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9); edit = m_interface->CreateEdit({ 0.0f, 0.0f }, { 0.0f, 0.0f }, 0, EVENT_EDIT9);
edit->SetAutoIndent(m_engine->GetEditIndentMode()); edit->SetAutoIndent(m_engine->GetEditIndentMode());
edit->ReadText(filename); edit->ReadText(filename);
GetScript(edit); GetScript(edit);
@ -1022,7 +1022,7 @@ bool CScript::WriteScript(const char* filename)
return false; return false;
} }
Ui::CEdit* edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9); Ui::CEdit* edit = m_interface->CreateEdit({ 0.0f, 0.0f }, { 0.0f, 0.0f }, 0, EVENT_EDIT9);
edit->SetAutoIndent(m_engine->GetEditIndentMode()); edit->SetAutoIndent(m_engine->GetEditIndentMode());
edit->SetText(m_script.get()); edit->SetText(m_script.get());
edit->WriteText(filename); edit->WriteText(filename);

View File

@ -64,7 +64,7 @@ void CDebugMenu::ToggleInterface()
if (!IsActive()) if (!IsActive())
{ {
CreateInterface(); CreateInterface();
CLabel* pl = m_interface->CreateLabel(Math::Point(0.0f, 0.9f), Math::Point(1.0f, 0.1f), -1, EVENT_LABEL19, "??"); CLabel* pl = m_interface->CreateLabel({ 0.0f, 0.9f }, { 1.0f, 0.1f }, -1, EVENT_LABEL19, "??");
pl->SetFontType(Gfx::FONT_STUDIO); pl->SetFontType(Gfx::FONT_STUDIO);
} }
else else
@ -74,14 +74,14 @@ void CDebugMenu::ToggleInterface()
} }
} }
const Math::Point dim = Math::Point(33.0f/640.0f, 33.0f/480.0f); constexpr glm::vec2 dim = { 33.0f / 640.0f, 33.0f / 480.0f };
const float ox = 3.0f/640.0f, oy = 3.0f/480.0f; constexpr float ox = 3.0f/640.0f, oy = 3.0f/480.0f;
const float /*sx = 33.0f/640.0f,*/ sy = 33.0f/480.0f; constexpr float /*sx = 33.0f/640.0f,*/ sy = 33.0f/480.0f;
void CDebugMenu::CreateInterface() void CDebugMenu::CreateInterface()
{ {
CWindow* pw = m_interface->CreateWindows(Math::Point(), Math::Point(), 0, EVENT_WINDOW7); CWindow* pw = m_interface->CreateWindows({ 0, 0 }, { 0, 0 }, 0, EVENT_WINDOW7);
Math::Point pos, ddim; glm::vec2 pos, ddim;
CCheck* pc; CCheck* pc;
CButton* pb; CButton* pb;
@ -128,8 +128,8 @@ void CDebugMenu::CreateInterface()
void CDebugMenu::CreateSpawnInterface() void CDebugMenu::CreateSpawnInterface()
{ {
CWindow* pw = m_interface->CreateWindows(Math::Point(), Math::Point(), 0, EVENT_WINDOW7); CWindow* pw = m_interface->CreateWindows({ 0, 0 }, { 0, 0 }, 0, EVENT_WINDOW7);
Math::Point pos, ddim; glm::vec2 pos, ddim;
CButton* pb; CButton* pb;
ddim.x = 4*dim.x+4*ox; ddim.x = 4*dim.x+4*ox;
@ -391,7 +391,7 @@ bool CDebugMenu::EventProcess(const Event &event)
return true; return true;
} }
bool CDebugMenu::HandleSpawnObject(ObjectType type, Math::Point mousePos) bool CDebugMenu::HandleSpawnObject(ObjectType type, const glm::vec2& mousePos)
{ {
Math::Vector pos; Math::Vector pos;
if (m_engine->DetectObject(mousePos, pos, true) == -1) if (m_engine->DetectObject(mousePos, pos, true) == -1)
@ -414,7 +414,7 @@ bool CDebugMenu::HandleSpawnObject(ObjectType type, Math::Point mousePos)
return true; return true;
} }
bool CDebugMenu::HandleLightning(Math::Point mousePos) bool CDebugMenu::HandleLightning(const glm::vec2& mousePos)
{ {
Math::Vector pos; Math::Vector pos;
if (m_engine->DetectObject(mousePos, pos, true) == -1) if (m_engine->DetectObject(mousePos, pos, true) == -1)
@ -428,7 +428,7 @@ bool CDebugMenu::HandleLightning(Math::Point mousePos)
return true; return true;
} }
bool CDebugMenu::HandleTeleport(Math::Point mousePos) bool CDebugMenu::HandleTeleport(const glm::vec2& mousePos)
{ {
CObject* select = m_main->GetSelect(); CObject* select = m_main->GetSelect();
@ -465,7 +465,7 @@ void CDebugMenu::HandleFrameUpdate(const Event &event)
pl->SetName(str.c_str()); pl->SetName(str.c_str());
} }
bool CDebugMenu::HandleCopy(Math::Point mousePos) bool CDebugMenu::HandleCopy(const glm::vec2& mousePos)
{ {
Math::Vector pos; Math::Vector pos;
if (m_engine->DetectObject(mousePos, pos, true) == -1) if (m_engine->DetectObject(mousePos, pos, true) == -1)

View File

@ -19,10 +19,10 @@
#pragma once #pragma once
#include "math/point.h"
#include "object/object_type.h" #include "object/object_type.h"
#include <glm/glm.hpp>
class CRobotMain; class CRobotMain;
class CObjectManager; class CObjectManager;
class CSoundInterface; class CSoundInterface;
@ -76,16 +76,16 @@ protected:
//! Handle spawning a new object at mouse position //! Handle spawning a new object at mouse position
//! \return true on success, false on error //! \return true on success, false on error
bool HandleSpawnObject(ObjectType type, Math::Point mousePos); bool HandleSpawnObject(ObjectType type, const glm::vec2& mousePos);
//! Handle lightning at position //! Handle lightning at position
//! \return true on success, false on error //! \return true on success, false on error
bool HandleLightning(Math::Point mousePos); bool HandleLightning(const glm::vec2& mousePos);
//! Handle teleport to position //! Handle teleport to position
//! \return true on success, false on error //! \return true on success, false on error
bool HandleTeleport(Math::Point mousePos); bool HandleTeleport(const glm::vec2& mousePos);
//! Handle ctrl+c (copy coordinates under cursor to clipboard) //! Handle ctrl+c (copy coordinates under cursor to clipboard)
//! \return true on success, false on error //! \return true on success, false on error
bool HandleCopy(Math::Point mousePos); bool HandleCopy(const glm::vec2& mousePos);
protected: protected:
CRobotMain* m_main; CRobotMain* m_main;

View File

@ -179,7 +179,7 @@ void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height
Ui::CButton* button; Ui::CButton* button;
Ui::CGroup* group; Ui::CGroup* group;
Ui::CLabel* label; Ui::CLabel* label;
Math::Point pos, ppos, dim; glm::vec2 pos, ppos, dim;
SoundType sound; SoundType sound;
float hLine, hBox; float hLine, hBox;
int nLine, icon, i; int nLine, icon, i;

View File

@ -762,7 +762,7 @@ void CObjectInterface::StopEditScript(bool closeWithErrors)
void CObjectInterface::GroundFlat() void CObjectInterface::GroundFlat()
{ {
Math::Vector pos, speed; Math::Vector pos, speed;
Math::Point dim; glm::vec2 dim;
Error err; Error err;
float level; float level;
@ -807,7 +807,7 @@ bool CObjectInterface::CreateInterface(bool bSelect)
CColor* pc; CColor* pc;
CTarget* pt; CTarget* pt;
CLabel* pl; CLabel* pl;
Math::Point pos, dim, ddim; glm::vec2 pos, dim, ddim;
float ox, oy, sx, sy; float ox, oy, sx, sy;
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
@ -1547,7 +1547,7 @@ void CObjectInterface::UpdateInterface(float rTime)
CGroup* pgr; CGroup* pgr;
CTarget* ptg; CTarget* ptg;
Math::Vector pos, hPos; Math::Vector pos, hPos;
Math::Point ppos; glm::vec2 ppos;
float range; float range;
int icon; int icon;
bool bOnBoard; bool bOnBoard;