remove glm dependency
This commit is contained in:
@@ -160,7 +160,7 @@ const Color* World::GetTileColor(TilePtr tile) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool World::CanPlaceLittleTower(const glm::vec2& worldPos, PlayerID playerID) const {
|
||||
bool World::CanPlaceLittleTower(const Vec2f& worldPos, PlayerID playerID) const {
|
||||
TilePtr tile = GetTile(worldPos.x, worldPos.y);
|
||||
const Player& player = m_Game->GetPlayers()[playerID];
|
||||
|
||||
@@ -186,7 +186,7 @@ bool World::CanPlaceLittleTower(const glm::vec2& worldPos, PlayerID playerID) co
|
||||
return false;
|
||||
}
|
||||
|
||||
bool World::CanPlaceBigTower(const glm::vec2& worldPos, PlayerID playerID) const {
|
||||
bool World::CanPlaceBigTower(const Vec2f& worldPos, PlayerID playerID) const {
|
||||
if (!CanPlaceLittleTower(worldPos, playerID)) return false;
|
||||
|
||||
TilePtr tile = GetTile(worldPos.x, worldPos.y);
|
||||
@@ -224,7 +224,7 @@ void World::CleanDeadMobs() {
|
||||
}
|
||||
}
|
||||
|
||||
TowerPtr World::GetTower(const glm::vec2& position) const {
|
||||
TowerPtr World::GetTower(const Vec2f& position) const {
|
||||
for (TowerPtr tower : m_Towers) {
|
||||
if (tower->GetSize() == TowerSize::Big) {
|
||||
if (tower->GetCenterX() - 2.5f < position.x && tower->GetCenterX() + 2.5f > position.x &&
|
||||
|
||||
@@ -59,7 +59,7 @@ void Client::SendMobs(const std::vector<protocol::MobSend>& mobSends) {
|
||||
m_Connexion.SendPacket(&packet);
|
||||
}
|
||||
|
||||
void Client::PlaceTower(game::TowerType type, const glm::vec2& position) {
|
||||
void Client::PlaceTower(game::TowerType type, const Vec2f& position) {
|
||||
protocol::PlaceTowerPacket packet(position.x, position.y, type);
|
||||
m_Connexion.SendPacket(&packet);
|
||||
}
|
||||
|
||||
@@ -151,11 +151,13 @@ void ServerConnexion::HandlePacket(const protocol::PlaceTowerPacket* packet) {
|
||||
const game::TowerInfo& towerInfo = game::GetTowerInfo(towerType);
|
||||
server::ServerWorld* world = m_Server->GetGame().GetServerWorld();
|
||||
|
||||
if (!world->CanPlaceLittleTower({ packet->GetTowerX(), packet->GetTowerY() }, m_ID))
|
||||
Vec2f towerPos = { static_cast<float>(packet->GetTowerX()), static_cast<float>(packet->GetTowerY()) };
|
||||
|
||||
if (!world->CanPlaceLittleTower(towerPos, m_ID))
|
||||
return;
|
||||
|
||||
if (towerInfo.IsBigTower())
|
||||
if (!world->CanPlaceBigTower({ packet->GetTowerX(), packet->GetTowerY() }, m_ID))
|
||||
if (!world->CanPlaceBigTower(towerPos, m_ID))
|
||||
return;
|
||||
|
||||
game::TowerPtr tower = world->PlaceTowerAt(towerType, packet->GetTowerX(), packet->GetTowerY(), m_ID);
|
||||
|
||||
@@ -39,6 +39,8 @@ void Renderer::InitShaders() {
|
||||
UpdateIsometricView();
|
||||
}
|
||||
|
||||
// TODO : change loader check
|
||||
|
||||
bool Renderer::Init() {
|
||||
#if __has_include(<glbinding/glbinding.h>)
|
||||
glbinding::initialize();
|
||||
@@ -110,13 +112,13 @@ void Renderer::SetZoom(float zoom) {
|
||||
m_EntityShader->SetZoom(zoom);
|
||||
}
|
||||
|
||||
void Renderer::SetCamMovement(const glm::vec2& mov) {
|
||||
void Renderer::SetCamMovement(const Vec2f& mov) {
|
||||
m_CamPos.x += mov.x * (1 - m_IsometricView) + (0.5 * mov.x - mov.y) * m_IsometricView;
|
||||
m_CamPos.y += -mov.y * (1 - m_IsometricView) + (-0.5 * mov.x - mov.y) * m_IsometricView;
|
||||
SetCamPos(m_CamPos);
|
||||
}
|
||||
|
||||
void Renderer::SetCamPos(const glm::vec2& newPos) {
|
||||
void Renderer::SetCamPos(const Vec2f& newPos) {
|
||||
m_CamPos = newPos;
|
||||
m_WorldShader->Start();
|
||||
m_WorldShader->SetCamPos(newPos);
|
||||
@@ -128,7 +130,7 @@ void Renderer::SetIsometricView(bool isometric) {
|
||||
m_IsometricView = isometric;
|
||||
}
|
||||
|
||||
glm::vec2 Renderer::GetCursorWorldPos(const glm::vec2& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight) {
|
||||
Vec2f Renderer::GetCursorWorldPos(const Vec2f& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight) {
|
||||
float isometricEased = utils::EaseInOutExpo(m_IsometricShade);
|
||||
|
||||
float relativeX = (cursorPos.x / windowWidth * 2) - 1;
|
||||
|
||||
@@ -70,7 +70,7 @@ void WorldRenderer::Update() {
|
||||
}
|
||||
|
||||
void WorldRenderer::RemoveTower() {
|
||||
glm::vec2 cursorPos = GetCursorWorldPos();
|
||||
Vec2f cursorPos = GetCursorWorldPos();
|
||||
|
||||
game::TowerPtr clickedTower = m_World->GetTower(cursorPos);
|
||||
|
||||
@@ -104,7 +104,7 @@ void WorldRenderer::RenderTileSelect() const {
|
||||
|
||||
Renderer::Model tileSelectModel;
|
||||
tileSelectModel.vao = m_SelectTileVao.get();
|
||||
tileSelectModel.positon = { (int)m_CursorPos.x, (int)m_CursorPos.y };
|
||||
tileSelectModel.positon = { std::floor(m_CursorPos.x), std::floor(m_CursorPos.y) };
|
||||
|
||||
m_Renderer->RenderModel(tileSelectModel);
|
||||
}
|
||||
@@ -237,7 +237,7 @@ void WorldRenderer::RenderTowerUpgradePopup() {
|
||||
void WorldRenderer::DetectClick() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (ImGui::IsMouseReleased(0) && !ImGui::IsAnyItemHovered() && !ImGui::IsAnyItemFocused()) {
|
||||
glm::vec2 cursorPos = { io.MousePos.x, io.MousePos.y };
|
||||
Vec2f cursorPos = { io.MousePos.x, io.MousePos.y };
|
||||
if (cursorPos == m_HoldCursorPos) {
|
||||
m_LastClicked = m_HoldCursorPos;
|
||||
Click();
|
||||
@@ -260,7 +260,7 @@ void WorldRenderer::RenderCastleTooltip() const {
|
||||
}
|
||||
|
||||
void WorldRenderer::DetectMobHovering() const {
|
||||
glm::vec2 cursorWorldPos = GetCursorWorldPos();
|
||||
Vec2f cursorWorldPos = GetCursorWorldPos();
|
||||
for (game::MobPtr mob : m_World->GetMobList()) {
|
||||
if (mob->CollidesWith({ cursorWorldPos.x, cursorWorldPos.y })) {
|
||||
m_MobTooltip->SetMob(mob.get());
|
||||
@@ -271,7 +271,7 @@ void WorldRenderer::DetectMobHovering() const {
|
||||
}
|
||||
|
||||
void WorldRenderer::DetectCastleHovering() const {
|
||||
glm::vec2 cursorWorldPos = GetCursorWorldPos();
|
||||
Vec2f cursorWorldPos = GetCursorWorldPos();
|
||||
for (const game::Team& team : m_World->GetTeams()) {
|
||||
if (team.GetCastle().CollidesWith({ cursorWorldPos.x, cursorWorldPos.y })) {
|
||||
m_CastleTooltip->SetCastle(&team.GetCastle());
|
||||
@@ -292,12 +292,12 @@ void WorldRenderer::OnTowerRemove(game::TowerPtr tower) {
|
||||
m_TowersCache.UpdateVertexArray();
|
||||
}
|
||||
|
||||
glm::vec2 WorldRenderer::GetCursorWorldPos() const {
|
||||
Vec2f WorldRenderer::GetCursorWorldPos() const {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
return m_Renderer->GetCursorWorldPos({ io.MousePos.x, io.MousePos.y }, Display::GetAspectRatio(), m_Zoom, Display::GetWindowWidth(), Display::GetWindowHeight());
|
||||
}
|
||||
|
||||
glm::vec2 WorldRenderer::GetClickWorldPos() const {
|
||||
Vec2f WorldRenderer::GetClickWorldPos() const {
|
||||
return m_Renderer->GetCursorWorldPos(m_LastClicked, Display::GetAspectRatio(), m_Zoom, Display::GetWindowWidth(), Display::GetWindowHeight());
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ void TowerPlacePopup::Render() {
|
||||
}
|
||||
}
|
||||
|
||||
void TowerPlacePopup::SetClickPos(const glm::vec2& worldPos) {
|
||||
void TowerPlacePopup::SetClickPos(const Vec2f& worldPos) {
|
||||
m_ClickWorldPos = worldPos;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void EntityShader::GetAllUniformLocation() {
|
||||
m_LocationViewtype = static_cast<unsigned int>(GetUniformLocation("isometricView"));
|
||||
}
|
||||
|
||||
void EntityShader::SetCamPos(const glm::vec2& camPos) {
|
||||
void EntityShader::SetCamPos(const Vec2f& camPos) {
|
||||
LoadVector(m_LocationCam, camPos);
|
||||
}
|
||||
void EntityShader::SetZoom(float zoom) {
|
||||
@@ -116,7 +116,7 @@ void EntityShader::SetZoom(float zoom) {
|
||||
void EntityShader::SetAspectRatio(float aspectRatio) {
|
||||
LoadFloat(m_LocationAspectRatio, aspectRatio);
|
||||
}
|
||||
void EntityShader::SetModelPos(const glm::vec2& modelPos) {
|
||||
void EntityShader::SetModelPos(const Vec2f& modelPos) {
|
||||
LoadVector(m_LocationTranslation, modelPos);
|
||||
}
|
||||
void EntityShader::SetIsometricView(float isometric) {
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
@@ -56,28 +54,19 @@ void ShaderProgram::LoadInt(unsigned int location, int value) const {
|
||||
}
|
||||
|
||||
void ShaderProgram::LoadVector(unsigned int location,
|
||||
const glm::vec2& vector) const {
|
||||
const Vec2f& vector) const {
|
||||
glUniform2f(static_cast<GLint>(location), vector.x, vector.y);
|
||||
}
|
||||
|
||||
void ShaderProgram::LoadVector(unsigned int location,
|
||||
const glm::vec3& vector) const {
|
||||
const Vec3f& vector) const {
|
||||
glUniform3f(static_cast<GLint>(location), vector.x, vector.y, vector.z);
|
||||
}
|
||||
|
||||
void ShaderProgram::LoadVector(unsigned int location,
|
||||
const glm::vec4& vector) const {
|
||||
glUniform4f(static_cast<GLint>(location), vector.x, vector.y, vector.z, vector.w);
|
||||
}
|
||||
|
||||
void ShaderProgram::LoadBoolean(unsigned int location, bool value) const {
|
||||
glUniform1i(static_cast<GLint>(location), value);
|
||||
}
|
||||
|
||||
void ShaderProgram::LoadMatrix(unsigned int location, const glm::mat4& matrix) const {
|
||||
glUniformMatrix4fv(static_cast<GLint>(location), 1, false, glm::value_ptr(matrix));
|
||||
}
|
||||
|
||||
void ShaderProgram::CleanUp() const {
|
||||
Stop();
|
||||
glDetachShader(m_ProgramID, m_VertexShaderID);
|
||||
|
||||
@@ -100,7 +100,7 @@ void WorldShader::GetAllUniformLocation() {
|
||||
m_LocationViewtype = static_cast<unsigned int>(GetUniformLocation("isometricView"));
|
||||
}
|
||||
|
||||
void WorldShader::SetCamPos(const glm::vec2& camPos) {
|
||||
void WorldShader::SetCamPos(const Vec2f& camPos) {
|
||||
LoadVector(m_LocationCam, camPos);
|
||||
}
|
||||
void WorldShader::SetZoom(float zoom) {
|
||||
|
||||
Reference in New Issue
Block a user