Refactored Math::Vector in remaining UI classes
parent
dbe127569b
commit
1a7ffa693b
|
@ -393,7 +393,7 @@ bool CDebugMenu::EventProcess(const Event &event)
|
|||
|
||||
bool CDebugMenu::HandleSpawnObject(ObjectType type, const glm::vec2& mousePos)
|
||||
{
|
||||
Math::Vector pos;
|
||||
glm::vec3 pos;
|
||||
if (m_engine->DetectObject(mousePos, pos, true) == -1)
|
||||
{
|
||||
m_sound->Play(SOUND_CLICK, 1.0f, 0.5f);
|
||||
|
@ -416,7 +416,7 @@ bool CDebugMenu::HandleSpawnObject(ObjectType type, const glm::vec2& mousePos)
|
|||
|
||||
bool CDebugMenu::HandleLightning(const glm::vec2& mousePos)
|
||||
{
|
||||
Math::Vector pos;
|
||||
glm::vec3 pos;
|
||||
if (m_engine->DetectObject(mousePos, pos, true) == -1)
|
||||
{
|
||||
m_sound->Play(SOUND_CLICK, 1.0f, 0.5f);
|
||||
|
@ -432,7 +432,7 @@ bool CDebugMenu::HandleTeleport(const glm::vec2& mousePos)
|
|||
{
|
||||
CObject* select = m_main->GetSelect();
|
||||
|
||||
Math::Vector pos;
|
||||
glm::vec3 pos;
|
||||
if (m_engine->DetectObject(mousePos, pos, true) == -1 || !m_engine->GetTerrain()->AdjustToFloor(pos) || select == nullptr)
|
||||
{
|
||||
m_sound->Play(SOUND_CLICK, 1.0f, 0.5f);
|
||||
|
@ -455,7 +455,7 @@ bool CDebugMenu::HandleTeleport(const glm::vec2& mousePos)
|
|||
void CDebugMenu::HandleFrameUpdate(const Event &event)
|
||||
{
|
||||
std::string str = "-";
|
||||
Math::Vector pos;
|
||||
glm::vec3 pos;
|
||||
int obj;
|
||||
if ((obj = m_engine->DetectObject(event.mousePos, pos, true)) != -1)
|
||||
str = StrUtils::Format("pos=% 3.2f; % 3.2f height=% 3.2f objId=% 4d", pos.x, pos.z, pos.y, obj);
|
||||
|
@ -467,7 +467,7 @@ void CDebugMenu::HandleFrameUpdate(const Event &event)
|
|||
|
||||
bool CDebugMenu::HandleCopy(const glm::vec2& mousePos)
|
||||
{
|
||||
Math::Vector pos;
|
||||
glm::vec3 pos;
|
||||
if (m_engine->DetectObject(mousePos, pos, true) == -1)
|
||||
{
|
||||
m_sound->Play(SOUND_CLICK, 1.0f, 0.5f);
|
||||
|
|
|
@ -457,7 +457,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
|
|||
light.type = Gfx::LIGHT_DIRECTIONAL;
|
||||
light.ambient = Gfx::Color(0.0f, 0.0f, 0.0f);
|
||||
light.diffuse = Gfx::Color(1.0f, 0.1f, 0.1f);
|
||||
light.direction = Math::Vector(1.0f, 0.0f, 1.0f);
|
||||
light.direction = glm::vec3(1.0f, 0.0f, 1.0f);
|
||||
|
||||
m_lightSuppl = m_light->CreateLight();
|
||||
m_light->SetLight(m_lightSuppl, light);
|
||||
|
|
|
@ -123,7 +123,7 @@ void CDisplayText::DisplayError(Error err, CObject* pObj, float time)
|
|||
if (pObj == nullptr)
|
||||
return;
|
||||
|
||||
Math::Vector pos = pObj->GetPosition();
|
||||
glm::vec3 pos = pObj->GetPosition();
|
||||
float h = GetIdealHeight(pObj);
|
||||
float d = GetIdealDist(pObj);
|
||||
DisplayError(err, pos, h, d, time);
|
||||
|
@ -131,7 +131,7 @@ void CDisplayText::DisplayError(Error err, CObject* pObj, float time)
|
|||
|
||||
// Displays an error.
|
||||
|
||||
void CDisplayText::DisplayError(Error err, Math::Vector goal, float height,
|
||||
void CDisplayText::DisplayError(Error err, glm::vec3 goal, float height,
|
||||
float dist, float time)
|
||||
{
|
||||
if ( err == ERR_OK ) return;
|
||||
|
@ -162,7 +162,7 @@ void CDisplayText::DisplayText(const char *text, CObject* pObj,
|
|||
{
|
||||
if (pObj == nullptr) return;
|
||||
|
||||
Math::Vector pos = pObj->GetPosition();
|
||||
glm::vec3 pos = pObj->GetPosition();
|
||||
float h = GetIdealHeight(pObj);
|
||||
float d = GetIdealDist(pObj);
|
||||
DisplayText(text, pos, h, d, time, type);
|
||||
|
@ -170,7 +170,7 @@ void CDisplayText::DisplayText(const char *text, CObject* pObj,
|
|||
|
||||
// Displays text.
|
||||
|
||||
void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height,
|
||||
void CDisplayText::DisplayText(const char *text, glm::vec3 goal, float height,
|
||||
float dist, float time, TextType type)
|
||||
{
|
||||
CObject* toto;
|
||||
|
@ -421,10 +421,10 @@ void CDisplayText::SetEnable(bool bEnable)
|
|||
|
||||
// Returns the goal during a visit.
|
||||
|
||||
Math::Vector CDisplayText::GetVisitGoal(EventType event)
|
||||
glm::vec3 CDisplayText::GetVisitGoal(EventType event)
|
||||
{
|
||||
int i = event - EVENT_DT_VISIT0;
|
||||
if (i < 0 || i >= MAXDTLINE) return Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
if (i < 0 || i >= MAXDTLINE) return glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
return m_textLines[i].visitGoal;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,16 +59,16 @@ public:
|
|||
bool EventProcess(const Event &event);
|
||||
|
||||
void DisplayError(Error err, CObject* pObj, float time=10.0f);
|
||||
void DisplayError(Error err, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f);
|
||||
void DisplayError(Error err, glm::vec3 goal, float height=15.0f, float dist=60.0f, float time=10.0f);
|
||||
void DisplayText(const char *text, CObject* pObj, float time=10.0f, TextType type=TT_INFO);
|
||||
void DisplayText(const char *text, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f, TextType type=TT_INFO);
|
||||
void DisplayText(const char *text, glm::vec3 goal, float height=15.0f, float dist=60.0f, float time=10.0f, TextType type=TT_INFO);
|
||||
void HideText(bool bHide);
|
||||
void ClearText();
|
||||
bool ClearLastText();
|
||||
void SetDelay(float factor);
|
||||
void SetEnable(bool bEnable);
|
||||
|
||||
Math::Vector GetVisitGoal(EventType event);
|
||||
glm::vec3 GetVisitGoal(EventType event);
|
||||
float GetVisitDist(EventType event);
|
||||
float GetVisitHeight(EventType event);
|
||||
|
||||
|
@ -91,7 +91,7 @@ protected:
|
|||
{
|
||||
bool exist = false;
|
||||
float time = 0.0f;
|
||||
Math::Vector visitGoal;
|
||||
glm::vec3 visitGoal = { 0, 0, 0 };
|
||||
float visitDist = 0.0f;
|
||||
float visitHeight = 0.0f;
|
||||
};
|
||||
|
|
|
@ -404,7 +404,7 @@ void CMainDialog::StartDialog(const glm::vec2& dim, bool fireParticles)
|
|||
void CMainDialog::FrameDialog(float rTime)
|
||||
{
|
||||
CWindow* pw;
|
||||
Math::Vector pos, speed;
|
||||
glm::vec3 pos, speed;
|
||||
glm::vec2 dim, dpos, ddim;
|
||||
float zoom;
|
||||
int i;
|
||||
|
@ -452,7 +452,7 @@ void CMainDialog::FrameDialog(float rTime)
|
|||
ddim = m_dialogDim;
|
||||
|
||||
pos.z = 0.0f;
|
||||
speed = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
speed = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
for ( i=0 ; i<2 ; i++ )
|
||||
{
|
||||
|
|
|
@ -424,9 +424,9 @@ void CMainUserInterface::GlintMove()
|
|||
|
||||
// Returns the position for a sound.
|
||||
|
||||
static Math::Vector SoundPos(const glm::vec2& pos)
|
||||
static glm::vec3 SoundPos(const glm::vec2& pos)
|
||||
{
|
||||
Math::Vector s;
|
||||
glm::vec3 s;
|
||||
|
||||
s.x = (pos.x-0.5f)*2.0f;
|
||||
s.y = (pos.y-0.5f)*2.0f;
|
||||
|
@ -437,9 +437,9 @@ static Math::Vector SoundPos(const glm::vec2& pos)
|
|||
|
||||
// Returns a random position for a sound.
|
||||
|
||||
static Math::Vector SoundRand()
|
||||
static glm::vec3 SoundRand()
|
||||
{
|
||||
Math::Vector s;
|
||||
glm::vec3 s;
|
||||
|
||||
s.x = (Math::Rand()-0.5f)*2.0f;
|
||||
s.y = (Math::Rand()-0.5f)*2.0f;
|
||||
|
@ -452,7 +452,7 @@ static Math::Vector SoundRand()
|
|||
|
||||
void CMainUserInterface::FrameParticle(float rTime)
|
||||
{
|
||||
Math::Vector pos, speed;
|
||||
glm::vec3 pos, speed;
|
||||
glm::vec2 dim;
|
||||
float *pParti, *pGlint;
|
||||
int nParti, nGlint;
|
||||
|
|
|
@ -761,7 +761,7 @@ void CObjectInterface::StopEditScript(bool closeWithErrors)
|
|||
|
||||
void CObjectInterface::GroundFlat()
|
||||
{
|
||||
Math::Vector pos, speed;
|
||||
glm::vec3 pos, speed;
|
||||
glm::vec2 dim;
|
||||
Error err;
|
||||
float level;
|
||||
|
@ -781,7 +781,7 @@ void CObjectInterface::GroundFlat()
|
|||
|
||||
level = m_terrain->GetFloorLevel(pos)+2.0f;
|
||||
if ( pos.y < level ) pos.y = level; // not below the soil
|
||||
speed = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
speed = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
dim.x = 40.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGFLAT, 1.0f);
|
||||
|
@ -1546,7 +1546,7 @@ void CObjectInterface::UpdateInterface(float rTime)
|
|||
CButton* pb;
|
||||
CGroup* pgr;
|
||||
CTarget* ptg;
|
||||
Math::Vector pos, hPos;
|
||||
glm::vec3 pos, hPos;
|
||||
glm::vec2 ppos;
|
||||
float range;
|
||||
int icon;
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace UI
|
|||
void CParticlesGenerator::GenerateMouseParticles(const glm::vec2& mousePosition, bool buttonPressed)
|
||||
{
|
||||
Gfx::ParticleType particleType = buttonPressed ? Gfx::ParticleType::PARTISCRAPS : Gfx::ParticleType::PARTILENS1;
|
||||
m_particleManager->CreateParticle(Math::Vector(mousePosition.x, mousePosition.y, 0), CreateRandomSpeedForMouseParticles(),
|
||||
m_particleManager->CreateParticle(glm::vec3(mousePosition.x, mousePosition.y, 0), CreateRandomSpeedForMouseParticles(),
|
||||
CreateRandomDimensionsForMouseParticles(buttonPressed), particleType,
|
||||
CreateRandomDurationForMouseParticles(), 2.0f, 0.0f, Gfx::SH_INTERFACE);
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ namespace UI
|
|||
return { dimensionX, dimensionX / 0.75f };
|
||||
}
|
||||
|
||||
Math::Vector CParticlesGenerator::CreateRandomSpeedForMouseParticles()
|
||||
glm::vec3 CParticlesGenerator::CreateRandomSpeedForMouseParticles()
|
||||
{
|
||||
return Math::Vector((Math::Rand() - 0.5f) * 0.5f, 0.3f + Math::Rand() * 0.3f, 0.0f);
|
||||
return glm::vec3((Math::Rand() - 0.5f) * 0.5f, 0.3f + Math::Rand() * 0.3f, 0.0f);
|
||||
}
|
||||
|
||||
float CParticlesGenerator::CreateRandomDurationForMouseParticles()
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "graphics/engine/particle.h"
|
||||
|
||||
#include "math/vector.h"
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace UI
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ namespace UI
|
|||
private:
|
||||
Gfx::CParticle* m_particleManager;
|
||||
glm::vec2 CreateRandomDimensionsForMouseParticles(bool buttonPressed);
|
||||
Math::Vector CreateRandomSpeedForMouseParticles();
|
||||
glm::vec3 CreateRandomSpeedForMouseParticles();
|
||||
float CreateRandomDurationForMouseParticles();
|
||||
};
|
||||
|
||||
|
|
|
@ -704,14 +704,14 @@ void CScreenApperance::SetCamera(float x, float y, float cameraDistance)
|
|||
|
||||
camera->SetType(Gfx::CAM_TYPE_SCRIPT);
|
||||
|
||||
Math::Vector p2D(x, y, cameraDistance);
|
||||
Math::Vector p3D;
|
||||
glm::vec3 p2D(x, y, cameraDistance);
|
||||
glm::vec3 p3D{};
|
||||
Math::Matrix matView;
|
||||
Math::Matrix matProj = engine->GetMatProj();
|
||||
|
||||
Math::LoadViewMatrix(matView, Math::Vector(0.0f, 0.0f, -cameraDistance),
|
||||
Math::Vector(0.0f, 0.0f, 0.0f),
|
||||
Math::Vector(0.0f, 0.0f, 1.0f));
|
||||
Math::LoadViewMatrix(matView, glm::vec3(0.0f, 0.0f, -cameraDistance),
|
||||
glm::vec3(0.0f, 0.0f, 0.0f),
|
||||
glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
p2D.x = p2D.x * 2.0f - 1.0f; // [0..1] -> [-1..1]
|
||||
p2D.y = p2D.y * 2.0f - 1.0f;
|
||||
|
@ -723,8 +723,8 @@ void CScreenApperance::SetCamera(float x, float y, float cameraDistance)
|
|||
p3D = Math::Transform(matView.Inverse(), p3D);
|
||||
p3D = -p3D;
|
||||
|
||||
camera->SetScriptCamera(Math::Vector(cameraDistance, p3D.y, p3D.x),
|
||||
Math::Vector(0.0f, p3D.y, p3D.x));
|
||||
camera->SetScriptCamera(glm::vec3(cameraDistance, p3D.y, p3D.x),
|
||||
glm::vec3(0.0f, p3D.y, p3D.x));
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
Loading…
Reference in New Issue