Refactored Math::Point in CApplication, CInput, CCamera, CCloud and Event

dev
Tomasz Kapuściński 2021-12-24 01:38:54 +01:00
parent b36ec266f0
commit 498f15cc92
9 changed files with 19 additions and 18 deletions

View File

@ -1040,7 +1040,7 @@ int CApplication::Run()
m_lastTimeStamp = m_systemUtils->GetCurrentTimeStamp();
m_curTimeStamp = m_systemUtils->GetCurrentTimeStamp();
MoveMouse(Math::Point(0.5f, 0.5f)); // center mouse on start
MoveMouse({ 0.5f, 0.5f }); // center mouse on start
TimeStamp previousTimeStamp{};
TimeStamp currentTimeStamp{};
@ -1712,7 +1712,7 @@ MouseMode CApplication::GetMouseMode() const
return m_mouseMode;
}
void CApplication::MoveMouse(Math::Point pos)
void CApplication::MoveMouse(const glm::vec2& pos)
{
glm::ivec2 windowPos = m_engine->InterfaceToWindowCoords(pos);
m_input->MouseMove(windowPos);

View File

@ -257,7 +257,7 @@ public:
void SetTextInput(bool textInputEnabled, int id);
//! Moves (warps) the mouse cursor to the specified position (in interface coords)
void MoveMouse(Math::Point pos);
void MoveMouse(const glm::vec2& pos);
//! Management of debug modes (printing more info in logger)
//@{

View File

@ -68,7 +68,7 @@ CInput::CInput()
{ INPUT_SLOT_CMDLINE, "cmdline" },
};
m_mousePos = Math::Point();
m_mousePos = { 0, 0 };
m_mouseButtonsState = 0;
std::fill_n(m_keyPresses, static_cast<std::size_t>(INPUT_SLOT_MAX), false);
@ -227,7 +227,7 @@ void CInput::ResetKeyStates()
m_keyPresses[i] = false;
}
Math::Point CInput::GetMousePos() const
glm::vec2 CInput::GetMousePos() const
{
return m_mousePos;
}

View File

@ -92,7 +92,7 @@ public:
void ResetKeyStates();
//! Returns the position of mouse cursor (in interface coords)
Math::Point GetMousePos() const;
glm::vec2 GetMousePos() const;
//! Sets the default input bindings (keys and joystick axes)
@ -140,7 +140,7 @@ private:
//! Current position of mouse cursor
Math::Point m_mousePos;
glm::vec2 m_mousePos;
//! Current state of mouse buttons (bitmask of MouseButton enum values)
unsigned int m_mouseButtonsState;

View File

@ -27,9 +27,10 @@
#include "common/key.h"
#include "common/make_unique.h"
#include "math/point.h"
#include "math/vector.h"
#include <glm/glm.hpp>
#include <memory>
#include <mutex>
@ -878,7 +879,7 @@ struct Event
//! Current position of mouse cursor in interface coords
//! Scope: all system events
Math::Point mousePos;
glm::vec2 mousePos;
//! Current state of mouse buttons: bitmask of MouseButton enum values
//! Scope: all system events

View File

@ -957,7 +957,7 @@ bool CCamera::EventProcess(const Event &event)
if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0 || (event.mouseButtonsState & MOUSE_BUTTON_MIDDLE) != 0)
{
Math::Point newDelta = event.mousePos - m_mousePos;
glm::vec2 newDelta = event.mousePos - m_mousePos;
if (m_cameraInvertX)
newDelta.x = -newDelta.x;
if (m_cameraInvertY)
@ -1031,7 +1031,7 @@ bool CCamera::EventProcess(const Event &event)
if (event.type == EVENT_FRAME && !m_freeze)
{
Math::Point newDelta = m_mouseDeltaEdge * m_speed * event.rTime;
glm::vec2 newDelta = m_mouseDeltaEdge * m_speed * event.rTime;
if (m_cameraInvertX)
newDelta.x = -newDelta.x;
if (m_cameraInvertY)

View File

@ -361,11 +361,11 @@ protected:
float m_visitDirectionV;
//! Last known mouse position, used to calculate change since last frame
Math::Point m_mousePos = Math::Point(0.5f, 0.5f);
glm::vec2 m_mousePos = { 0.5f, 0.5f };
//! Change of mouse position since last frame
Math::Point m_mouseDelta = Math::Point(0.0f, 0.0f);
glm::vec2 m_mouseDelta = { 0.0f, 0.0f };
//! Change of camera position caused by edge camera
Math::Point m_mouseDeltaEdge = Math::Point(0.0f, 0.0f);
glm::vec2 m_mouseDeltaEdge = { 0.0f, 0.0f };
//! Change of mouse wheel since last frame
float m_mouseWheelDelta = 0.0f;

View File

@ -77,7 +77,7 @@ bool CCloud::EventFrame(const Event &event)
}
void CCloud::AdjustLevel(Math::Vector& pos, Math::Vector& eye, float deep,
Math::Point& uv1, Math::Point& uv2)
glm::vec2& uv1, glm::vec2& uv2)
{
uv1.x = (pos.x+20000.0f)/1280.0f;
uv1.y = (pos.z+20000.0f)/1280.0f;
@ -146,7 +146,7 @@ void CCloud::Draw()
int vertexIndex = 0;
Math::Vector p;
Math::Point uv1, uv2;
glm::vec2 uv1, uv2;
p.x = pos.x-size;
p.z = pos.z+size;

View File

@ -83,7 +83,7 @@ protected:
bool EventFrame(const Event &event);
//! Adjusts the position to normal, to imitate the clouds at movement
void AdjustLevel(Math::Vector& pos, Math::Vector& eye, float deep,
Math::Point& uv1, Math::Point& uv2);
glm::vec2& uv1, glm::vec2& uv2);
//! Updates the positions, relative to the ground
void CreateLine(int x, int y, int len);
@ -97,7 +97,7 @@ protected:
//! Texture
std::string m_fileName;
//! Feedrate (wind)
Math::Point m_speed;
glm::vec2 m_speed;
//! Diffuse color
Color m_diffuse;
//! Ambient color