Removed vector.h, refactored redundant functions and moved remaining ones to func.h

dev
Tomasz Kapuściński 2022-01-04 20:43:36 +01:00
parent db3b1d74d1
commit 0bba168f94
73 changed files with 182 additions and 244 deletions

View File

@ -181,7 +181,6 @@ add_library(colobotbase STATIC
math/half.h
math/matrix.h
math/sphere.h
math/vector.h
object/auto/auto.cpp
object/auto/auto.h
object/auto/autobase.cpp

View File

@ -27,6 +27,7 @@
#include "level/robotmain.h"
#include "math/func.h"
#include <sstream>
#include <boost/lexical_cast.hpp>

View File

@ -27,11 +27,10 @@
#include "common/key.h"
#include "common/singleton.h"
#include "math/vector.h"
#include <glm/glm.hpp>
#include <map>
#include <string>
struct Event;

View File

@ -27,8 +27,6 @@
#include "common/key.h"
#include "common/make_unique.h"
#include "math/vector.h"
#include <glm/glm.hpp>
#include <memory>

View File

@ -27,7 +27,9 @@
#include "graphics/core/color.h"
#include "math/vector.h"
#include "math/const.h"
#include <glm/glm.hpp>
// Graphics module namespace

View File

@ -28,8 +28,6 @@
#include "graphics/core/color.h"
#include "graphics/core/type.h"
#include "math/vector.h"
#include <sstream>
#include <cstdint>

View File

@ -32,6 +32,7 @@
#include "level/robotmain.h"
#include "math/const.h"
#include "math/func.h"
#include "math/geometry.h"
#include "object/object.h"
@ -552,7 +553,7 @@ void CCamera::EffectFrame(const Event &event)
m_effectOffset.z = (Math::Rand() - 0.5f) * 0.2f;
}
float dist = Math::Distance(m_eyePt, m_effectPos);
float dist = glm::distance(m_eyePt, m_effectPos);
dist = Math::Norm((dist - 100.f) / 100.0f);
force *= 1.0f-dist;
@ -604,7 +605,7 @@ void CCamera::StartOver(CameraOverEffect effect, glm::vec3 pos, float force)
else
decay = 100.0f;
float dist = Math::Distance(m_eyePt, pos);
float dist = glm::distance(m_eyePt, pos);
dist = (dist - decay) / decay;
if (dist < 0.0f) dist = 0.0f;
if (dist > 1.0f) dist = 1.0f;
@ -765,7 +766,7 @@ void CCamera::UpdateCameraAnimation(const glm::vec3 &eyePt,
IsCollision(m_finalEye, m_finalLookat);
float prog = 0.0f;
float dist = Math::Distance(m_finalEye, m_actualEye);
float dist = glm::distance(m_finalEye, m_actualEye);
if (m_smooth == CAM_SMOOTH_NONE) prog = dist;
if (m_smooth == CAM_SMOOTH_NORM) prog = powf(dist, 1.5f) * rTime * 0.75f;
@ -781,7 +782,7 @@ void CCamera::UpdateCameraAnimation(const glm::vec3 &eyePt,
m_actualEye = (m_finalEye - m_actualEye) / dist * prog + m_actualEye;
}
dist = Math::Distance(m_finalLookat, m_actualLookat);
dist = glm::distance(m_finalLookat, m_actualLookat);
if ( m_smooth == CAM_SMOOTH_NONE ) prog = dist;
if ( m_smooth == CAM_SMOOTH_NORM ) prog = powf(dist, 1.5f) * rTime * 3.0f;
if ( m_smooth == CAM_SMOOTH_HARD ) prog = dist * rTime * 4.0f;
@ -881,7 +882,7 @@ void CCamera::IsCollisionBack()
oPos.z-oRadius > max.z ) continue;
glm::vec3 proj = Math::Projection(m_actualEye, m_actualLookat, oPos);
float dpp = Math::Distance(proj, oPos);
float dpp = glm::distance(proj, oPos);
if ( dpp > oRadius ) continue;
if ( oType == OBJECT_FACTORY )
@ -891,11 +892,11 @@ void CCamera::IsCollisionBack()
if ( fabs(angle) < 30.0f*Math::PI/180.0f ) continue; // in the gate?
}
float del = Math::Distance(m_actualEye, m_actualLookat);
float del = glm::distance(m_actualEye, m_actualLookat);
if (oType == OBJECT_FACTORY)
del += oRadius;
float len = Math::Distance(m_actualEye, proj);
float len = glm::distance(m_actualEye, proj);
if (len > del) continue;
SetTransparency(obj, 1.0f); // transparent object
@ -931,10 +932,10 @@ void CCamera::IsCollisionFix(glm::vec3 &eye, glm::vec3 lookat)
float objRadius = objSphere.radius;
if (objRadius == 0.0f) continue;
float dist = Math::Distance(eye, objPos);
float dist = glm::distance(eye, objPos);
if (dist < objRadius)
{
dist = Math::Distance(eye, lookat);
dist = glm::distance(eye, lookat);
glm::vec3 proj = Math::Projection(eye, lookat, objPos);
eye = (lookat - eye) * objRadius / dist + proj;
return;
@ -1438,7 +1439,7 @@ glm::vec3 CCamera::ExcludeObject(glm::vec3 eye, glm::vec3 lookat,
float oRad;
while (obj->GetCrashSphere(j++, oPos, oRad))
{
float dist = Math::Distance(oPos, eye);
float dist = glm::distance(oPos, eye);
if (dist < oRad + 2.0f)
eye.y = oPos.y + oRad + 2.0f;
}

View File

@ -26,7 +26,7 @@
#include "graphics/core/color.h"
#include "math/vector.h"
#include <glm/glm.hpp>
#include <vector>
#include <string>

View File

@ -3254,7 +3254,7 @@ float CEngine::GetEyeDirV()
bool CEngine::IsVisiblePoint(const glm::vec3 &pos)
{
return Math::Distance(m_eyePt, pos) <= (m_deepView[0] * m_clippingDistance);
return glm::distance(m_eyePt, pos) <= (m_deepView[0] * m_clippingDistance);
}
void CEngine::UpdateMatProj()
@ -4767,7 +4767,7 @@ void CEngine::DrawShadowSpots()
if ( h > max ) h = max;
if ( h > 4.0f ) h = 4.0f;
D = Math::Distance(m_eyePt, pos);
D = glm::distance(m_eyePt, pos);
if (D >= endDeepView)
continue;
@ -4785,7 +4785,7 @@ void CEngine::DrawShadowSpots()
if ( h > max ) h = max;
if ( h > 4.0f ) h = 4.0f;
D = Math::Distance(m_eyePt, pos);
D = glm::distance(m_eyePt, pos);
if (D >= endDeepView)
continue;

View File

@ -34,7 +34,6 @@
#include "math/matrix.h"
#include "math/sphere.h"
#include "math/vector.h"
#include <glm/glm.hpp>

View File

@ -28,7 +28,7 @@
#include "graphics/engine/engine.h"
#include "math/vector.h"
#include <glm/glm.hpp>
// Graphics module namespace

View File

@ -357,7 +357,7 @@ void CLightning::StrikeAtPos(glm::vec3 pos)
m_pos = pos;
glm::vec3 eye = m_engine->GetEyePt();
float dist = Math::Distance(m_pos, eye);
float dist = glm::distance(m_pos, eye);
float deep = m_engine->GetDeepView();
if (dist < deep)

View File

@ -24,8 +24,6 @@
#pragma once
#include "math/vector.h"
#include <glm/glm.hpp>
#include <vector>

View File

@ -413,9 +413,9 @@ int CParticle::CreateFrag(glm::vec3 pos, glm::vec3 speed,
p3.y = m_triangle[i].triangle[2].position.y;
p3.z = m_triangle[i].triangle[2].position.z;
float l1 = Math::Distance(p1, p2);
float l2 = Math::Distance(p2, p3);
float l3 = Math::Distance(p3, p1);
float l1 = glm::distance(p1, p2);
float l2 = glm::distance(p2, p3);
float l3 = glm::distance(p3, p1);
float dx = fabs(Math::Min(l1, l2, l3))*0.5f;
float dy = fabs(Math::Max(l1, l2, l3))*0.5f;
p1 = glm::vec3(-dx, dy, 0.0f);
@ -2478,7 +2478,7 @@ bool CParticle::TrackMove(int i, glm::vec3 pos, float progress)
last = m_track[i].pos[hh];
}
m_track[i].pos[h] = pos;
m_track[i].len[h] = Math::Distance(pos, last);
m_track[i].len[h] = glm::distance(pos, last);
m_track[i].head = h;
@ -2978,7 +2978,7 @@ void CParticle::DrawParticleRay(int i)
if (left) dim.y = -dim.y;
float len = Math::Distance(pos, goal);
float len = glm::distance(pos, goal);
float adv = 0.0f;
int step = static_cast<int>((len/(dim.x*2.0f))+1);
@ -3550,7 +3550,7 @@ CObject* CParticle::SearchObjectGun(glm::vec3 old, glm::vec3 pos,
float shieldRadius = shielder->GetActiveShieldRadius();
if (shieldRadius > 0.0f)
{
float dist = Math::Distance(oPos, pos);
float dist = glm::distance(oPos, pos);
if (dist <= shieldRadius)
{
best = obj;
@ -3563,8 +3563,8 @@ CObject* CParticle::SearchObjectGun(glm::vec3 old, glm::vec3 pos,
// Test the center of the object, which is necessary for objects
// that have no sphere in the center (station).
float dist = Math::Distance(oPos, pos)-4.0f;
float obj_dist = Math::Distance(old, oPos);
float dist = glm::distance(oPos, pos)-4.0f;
float obj_dist = glm::distance(old, oPos);
if (dist < min && obj_dist < best_dist)
{
best = obj;
@ -3581,8 +3581,8 @@ CObject* CParticle::SearchObjectGun(glm::vec3 old, glm::vec3 pos,
oPos.z+oRadius < box1.z || oPos.z-oRadius > box2.z ) continue;
glm::vec3 p = Math::Projection(old, pos, oPos);
float ddist = Math::Distance(p, oPos)-oRadius;
float obj_dist = Math::Distance(old, oPos);
float ddist = glm::distance(p, oPos)-oRadius;
float obj_dist = glm::distance(old, oPos);
if (ddist < min && obj_dist < best_dist)
{
best = obj;
@ -3640,7 +3640,7 @@ CObject* CParticle::SearchObjectRay(glm::vec3 pos, glm::vec3 goal,
oPos.z < box1.z || oPos.z > box2.z ) continue;
glm::vec3 p = Math::Projection(pos, goal, oPos);
float dist = Math::Distance(p, oPos);
float dist = glm::distance(p, oPos);
if (dist < min) return obj;
}

View File

@ -101,7 +101,7 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
}
else
{
m_size = Math::Distance(min, max)*2.0f;
m_size = glm::distance(min, max)*2.0f;
if ( m_size < 4.0f ) m_size = 4.0f;
if ( m_size > 80.0f ) m_size = 80.0f;
}
@ -1487,7 +1487,7 @@ void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part)
float h;
h = Math::Distance(p1, p2);
h = glm::distance(p1, p2);
if ( h > 5.0f )
{
p2.x = p1.x+((p2.x-p1.x)*5.0f/h);
@ -1495,7 +1495,7 @@ void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part)
p2.z = p1.z+((p2.z-p1.z)*5.0f/h);
}
h = Math::Distance(p2, p3);
h = glm::distance(p2, p3);
if ( h > 5.0f )
{
p3.x = p2.x+((p3.x-p2.x)*5.0f/h);
@ -1503,7 +1503,7 @@ void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part)
p3.z = p2.z+((p3.z-p2.z)*5.0f/h);
}
h = Math::Distance(p3, p1);
h = glm::distance(p3, p1);
if ( h > 5.0f )
{
p1.x = p3.x+((p1.x-p3.x)*5.0f/h);
@ -1628,7 +1628,7 @@ void CPyro::ExploStart()
{
glm::vec3 min, max;
m_engine->GetObjectBBox(objRank, min, max);
weight = Math::Distance(min, max); // weight according to size!
weight = glm::distance(min, max); // weight according to size!
speed.y = 10.0f+Math::Rand()*20.0f;
speed.x = (Math::Rand()-0.5f)*20.0f;
@ -2295,7 +2295,7 @@ CObject* CPyro::FallSearchBeeExplo()
float shieldRadius = dynamic_cast<CShielder&>(*obj).GetActiveShieldRadius();
if ( shieldRadius > 0.0f )
{
float distance = Math::Distance(oPos, bulletCrashSphere.sphere.pos);
float distance = glm::distance(oPos, bulletCrashSphere.sphere.pos);
if (distance <= shieldRadius)
return obj;
}
@ -2303,14 +2303,14 @@ CObject* CPyro::FallSearchBeeExplo()
if ( obj->GetType() == OBJECT_BASE )
{
float distance = Math::Distance(oPos, bulletCrashSphere.sphere.pos);
float distance = glm::distance(oPos, bulletCrashSphere.sphere.pos);
if (distance < 25.0f)
return obj;
}
// Test the center of the object, which is necessary for objects
// that have no sphere in the center (station).
float distance = Math::Distance(oPos, bulletCrashSphere.sphere.pos)-4.0f;
float distance = glm::distance(oPos, bulletCrashSphere.sphere.pos)-4.0f;
if (distance < 5.0f)
return obj;

View File

@ -27,7 +27,8 @@
#include "graphics/core/vertex.h"
#include "math/const.h"
#include "math/vector.h"
#include <glm/glm.hpp>
#include <string>
#include <vector>

View File

@ -376,7 +376,7 @@ void CWater::DrawSurf()
glm::vec3 p = pos;
p.x += size*(m_lines[i].len-1);
float radius = sqrtf(powf(size, 2.0f)+powf(size*m_lines[i].len, 2.0f));
if (Math::Distance(p, eye) > deep + radius)
if (glm::distance(p, eye) > deep + radius)
continue;
if (device->ComputeSphereVisibility(p, radius) != Gfx::FRUSTUM_PLANE_ALL)

View File

@ -26,8 +26,6 @@
#include "graphics/core/device.h"
#include "math/vector.h"
#include <GL/glew.h>
#include <glm/glm.hpp>

View File

@ -2432,7 +2432,7 @@ bool CRobotMain::EventFrame(const Event &event)
if ( obj->GetProxyActivate() ) // active if it is near?
{
glm::vec3 eye = m_engine->GetLookatPt();
float dist = Math::Distance(eye, obj->GetPosition());
float dist = glm::distance(eye, obj->GetPosition());
if ( dist < obj->GetProxyDistance() )
{
obj->SetProxyActivate(false);
@ -4123,7 +4123,7 @@ float SearchNearestObject(CObjectManager* objMan, glm::vec3 center, CObject* exc
if (oPos.x != center.x ||
oPos.z != center.z)
{
float dist = Math::Distance(center, oPos) - 80.0f;
float dist = glm::distance(center, oPos) - 80.0f;
if (dist < 0.0f) dist = 0.0f;
min = Math::Min(min, dist);
continue;
@ -4135,7 +4135,7 @@ float SearchNearestObject(CObjectManager* objMan, glm::vec3 center, CObject* exc
type == OBJECT_DESTROYER)
{
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(center, oPos) - 8.0f;
float dist = glm::distance(center, oPos) - 8.0f;
if (dist < 0.0f) dist = 0.0f;
min = Math::Min(min, dist);
}
@ -4145,7 +4145,7 @@ float SearchNearestObject(CObjectManager* objMan, glm::vec3 center, CObject* exc
glm::vec3 oPos = crashSphere.sphere.pos;
float oRadius = crashSphere.sphere.radius;
float dist = Math::Distance(center, oPos) - oRadius;
float dist = glm::distance(center, oPos) - oRadius;
if (dist < 0.0f) dist = 0.0f;
min = Math::Min(min, dist);
}
@ -4345,14 +4345,14 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* transporter)
if (type == OBJECT_BASE)
{
oPos = obj->GetPosition();
float dist = Math::Distance(center, oPos)-80.0f;
float dist = glm::distance(center, oPos)-80.0f;
oMax = Math::Min(oMax, dist);
}
else
{
for (const auto& crashSphere : obj->GetAllCrashSpheres())
{
float dist = Math::Distance(center, crashSphere.sphere.pos)-crashSphere.sphere.radius;
float dist = glm::distance(center, crashSphere.sphere.pos)-crashSphere.sphere.radius;
oMax = Math::Min(oMax, dist);
}
}
@ -4378,7 +4378,7 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* transporter)
{
for (const auto& crashSphere : obj->GetAllCrashSpheres())
{
float dist = Math::Distance(center, crashSphere.sphere.pos)-crashSphere.sphere.radius-BUILDMARGIN;
float dist = glm::distance(center, crashSphere.sphere.pos)-crashSphere.sphere.radius-BUILDMARGIN;
oMax = Math::Min(oMax, dist);
}
}
@ -6065,7 +6065,7 @@ void CRobotMain::StartDetectEffect(COldObject* object, CObject* target)
{
goal = target->GetPosition();
goal.y += 3.0f;
goal = Math::SegmentPoint(pos, goal, Math::Distance(pos, goal)-3.0f);
goal = Math::SegmentPoint(pos, goal, glm::distance(pos, goal)-3.0f);
}
dim.x = 3.0f;
@ -6076,7 +6076,7 @@ void CRobotMain::StartDetectEffect(COldObject* object, CObject* target)
{
goal = target->GetPosition();
goal.y += 3.0f;
goal = Math::SegmentPoint(pos, goal, Math::Distance(pos, goal)-1.0f);
goal = Math::SegmentPoint(pos, goal, glm::distance(pos, goal)-1.0f);
dim.x = 6.0f;
dim.y = dim.x;
m_particle->CreateParticle(goal, glm::vec3(0.0f, 0.0f, 0.0f), dim,

View File

@ -30,5 +30,4 @@
#include "math/geometry.h"
#include "math/half.h"
#include "math/matrix.h"
#include "math/vector.h"

View File

@ -34,26 +34,26 @@ namespace Math
//! Tolerance level -- minimum accepted float value
const float TOLERANCE = 1e-6f;
constexpr float TOLERANCE = 1e-6f;
//! Very small number (used in testing/returning some values)
const float VERY_SMALL_NUM = 1e-6f;
constexpr float VERY_SMALL_NUM = 1e-6f;
//! Very big number (used in testing/returning some values)
const float VERY_BIG_NUM = 1e6f;
constexpr float VERY_BIG_NUM = 1e6f;
//! Huge number
const float HUGE_NUM = 1.0e+38f;
constexpr float HUGE_NUM = 1.0e+38f;
//! PI
const float PI = 3.14159265358979323846f;
constexpr float PI = 3.14159265358979323846f;
//! Degrees to radians multiplier
const float DEG_TO_RAD = 0.01745329251994329547f;
constexpr float DEG_TO_RAD = 0.01745329251994329547f;
//! Radians to degrees multiplier
const float RAD_TO_DEG = 57.29577951308232286465f;
constexpr float RAD_TO_DEG = 57.29577951308232286465f;
//! Natural logarithm of 2
const float LOG_2 = log(2.0f);
const float LOG_2 = std::log(2.0f);
} // namespace Math

View File

@ -27,9 +27,12 @@
#include "math/const.h"
#include <glm/glm.hpp>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <string>
// Math module namespace
@ -264,6 +267,20 @@ inline float Bounce(float progress, float middle = 0.3f, float bounce = 0.4f)
}
}
//! Convenience function for calculating angle (in radians) between two vectors
inline float Angle(const glm::vec3& a, const glm::vec3& b)
{
return std::acosf(glm::dot(a, b) / (glm::length(a) * glm::length(b)));
}
inline std::string ToString(const glm::vec3& vector)
{
std::stringstream s;
s.precision(3);
s << "[" << vector.x << ", " << vector.y << ", " << vector.z << "]";
return s.str();
}
} // namespace Math

View File

@ -28,7 +28,6 @@
#include "math/const.h"
#include "math/func.h"
#include "math/matrix.h"
#include "math/vector.h"
#include <glm/glm.hpp>

View File

@ -27,7 +27,6 @@
#include "math/const.h"
#include "math/func.h"
#include "math/vector.h"
#include <cmath>

View File

@ -19,14 +19,14 @@
#pragma once
#include "math/vector.h"
#include <glm/glm.hpp>
namespace Math
{
struct Sphere
{
Sphere(const glm::vec3& pos = glm::vec3(), float radius = 0.0f)
Sphere(const glm::vec3& pos = glm::vec3(0, 0, 0), float radius = 0.0f)
: pos(pos), radius(radius) {}
glm::vec3 pos;
@ -36,12 +36,12 @@ struct Sphere
//! Compute distance between given \a point and \a sphere
inline float DistanceToSphere(const glm::vec3& point, const Sphere& sphere)
{
return Math::Distance(point, sphere.pos) - sphere.radius;
return glm::distance(point, sphere.pos) - sphere.radius;
}
inline float DistanceBetweenSpheres(const Sphere& sphere1, const Sphere& sphere2)
{
return Math::Distance(sphere1.pos, sphere2.pos) - sphere1.radius - sphere2.radius;
return glm::distance(sphere1.pos, sphere2.pos) - sphere1.radius - sphere2.radius;
}
inline Sphere BoundingSphereForBox(glm::vec3 mins, glm::vec3 maxs)

View File

@ -1,70 +0,0 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2021, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
/**
* \file math/vector.h
* \brief Vector struct and related functions
*/
#pragma once
#include "math/const.h"
#include "math/func.h"
#include <cmath>
#include <sstream>
#include <glm/glm.hpp>
// Math module namespace
namespace Math
{
//! Checks if two vectors are equal within given \a tolerance
inline bool VectorsEqual(const glm::vec3 &a, const glm::vec3 &b, float tolerance = TOLERANCE)
{
return IsEqual(a.x, b.x, tolerance)
&& IsEqual(a.y, b.y, tolerance)
&& IsEqual(a.z, b.z, tolerance);
}
//! Convenience function for calculating angle (in radians) between two vectors
inline float Angle(const glm::vec3 &a, const glm::vec3 &b)
{
return std::acosf(glm::dot(a, b) / (glm::length(a) * glm::length(b)));
}
//! Returns the distance between the ends of two vectors
inline float Distance(const glm::vec3 &a, const glm::vec3 &b)
{
return glm::distance(a, b);
}
inline std::string ToString(const glm::vec3& vector)
{
std::stringstream s;
s.precision(3);
s << "[" << vector.x << ", " << vector.y << ", " << vector.z << "]";
return s.str();
}
} // namespace Math

View File

@ -406,7 +406,7 @@ CObject* CAutoConvert::SearchStone(ObjectType type)
if (IsObjectBeingTransported(obj)) continue;
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(oPos, cPos);
float dist = glm::distance(oPos, cPos);
if ( dist <= 5.0f ) return obj;
}

View File

@ -493,7 +493,7 @@ bool CAutoDerrick::SearchFree(glm::vec3 pos)
glm::vec3 sPos = crashSphere.sphere.pos;
float sRadius = crashSphere.sphere.radius;
float distance = Math::Distance(sPos, pos);
float distance = glm::distance(sPos, pos);
distance -= sRadius;
if ( distance < 2.0f ) return false; // location occupied
}

View File

@ -288,7 +288,7 @@ CObject* CAutoDestroyer::SearchPlastic()
if (obj->GetType() == OBJECT_HUMAN || obj->GetType() == OBJECT_TECH) continue;
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(oPos, sPos);
float dist = glm::distance(oPos, sPos);
if ( dist <= 5.0f ) return obj;
}

View File

@ -570,7 +570,7 @@ CObject* CAutoFactory::SearchCargo()
if (IsObjectBeingTransported(obj)) continue;
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(oPos, m_cargoPos);
float dist = glm::distance(oPos, m_cargoPos);
if ( dist < 8.0f ) return obj;
}
@ -701,7 +701,7 @@ CObject* CAutoFactory::SearchVehicle()
if (IsObjectBeingTransported(obj)) continue;
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(oPos, m_cargoPos);
float dist = glm::distance(oPos, m_cargoPos);
if ( dist < 8.0f ) return obj;
}

View File

@ -282,7 +282,7 @@ bool CAutoMush::SearchTarget()
type != OBJECT_HUMAN ) continue;
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(oPos, iPos);
float dist = glm::distance(oPos, iPos);
if ( dist < 50.0f ) return true;
}

View File

@ -157,7 +157,7 @@ bool CAutoNest::SearchFree(glm::vec3 pos)
glm::vec3 sPos = crashSphere.sphere.pos;
float sRadius = crashSphere.sphere.radius;
float distance = Math::Distance(sPos, pos);
float distance = glm::distance(sPos, pos);
distance -= sRadius;
if ( distance < 2.0f ) return false; // location occupied
}

View File

@ -252,7 +252,7 @@ void CAutoPowerCaptor::ChargeObject(float rTime)
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
{
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(oPos, sPos);
float dist = glm::distance(oPos, sPos);
if ( dist > 20.0f ) continue;
if (! IsObjectBeingTransported(obj) && obj->Implements(ObjectInterfaceType::PowerContainer) )

View File

@ -284,7 +284,7 @@ CObject* CAutoPowerStation::SearchVehicle()
type != OBJECT_MOBILEdr ) continue;
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(oPos, sPos);
float dist = glm::distance(oPos, sPos);
if ( dist <= 5.0f ) return obj;
}

View File

@ -285,7 +285,7 @@ bool CAutoRadar::SearchEnemy(glm::vec3 &pos)
m_totalDetect ++;
glm::vec3 oPos = obj->GetPosition();
float distance = Math::Distance(oPos, iPos);
float distance = glm::distance(oPos, iPos);
if ( distance < min )
{
min = distance;

View File

@ -248,7 +248,7 @@ CObject* CAutoRepair::SearchVehicle()
if ( obj->Implements(ObjectInterfaceType::Movable) && !dynamic_cast<CMovableObject&>(*obj).GetPhysics()->GetLand() ) continue; // in flight?
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(oPos, sPos);
float dist = glm::distance(oPos, sPos);
if ( dist <= 5.0f ) return obj;
}

View File

@ -298,7 +298,7 @@ CObject* CAutoTower::SearchTarget(glm::vec3 &impact)
if (obj->GetCrashSphereCount() == 0) continue;
glm::vec3 oPos = obj->GetFirstCrashSphere().sphere.pos;
float distance = Math::Distance(oPos, iPos);
float distance = glm::distance(oPos, iPos);
if ( distance > TOWER_SCOPE ) continue; // too far
if ( distance < min )
{

View File

@ -21,7 +21,7 @@
#include "object/interface/program_storage_object.h"
#include "math/vector.h"
#include <glm/glm.hpp>
#include <sstream>

View File

@ -20,12 +20,11 @@
#pragma once
#include "object/interface/programmable_object.h"
#include "math/vector.h"
#include "object/interface/interactive_object.h"
#include "object/interface/trace_drawing_object.h"
#include <glm/glm.hpp>
#include <sstream>
class CObject;

View File

@ -21,8 +21,6 @@
#include "common/error.h"
#include "math/vector.h"
#include "object/object_type.h"
#include <glm/glm.hpp>

View File

@ -427,7 +427,7 @@ bool CMotionToto::EventFrame(const Event &event)
if ( m_bStartAction )
{
m_bStartAction = false;
m_speedAction = Math::Distance(nPos, aPos)/15.0f;
m_speedAction = glm::distance(nPos, aPos)/15.0f;
if ( m_speedAction < 20.0f ) m_speedAction = 20.0f;
}
level = m_speedAction;

View File

@ -1486,7 +1486,7 @@ bool CMotionVehicle::EventFrame(const Event &event)
radius = 1.0f;
}
if ( Math::Distance(pos, m_engine->GetEyePt()) < 50.0f ) // suspension?
if ( glm::distance(pos, m_engine->GetEyePt()) < 50.0f ) // suspension?
{
character = m_object->GetCharacter();
mat = m_object->GetWorldMatrix(0);
@ -1622,7 +1622,7 @@ bool CMotionVehicle::EventFrame(const Event &event)
limit[1] = -10.0f*Math::PI/180.0f;
}
if ( Math::Distance(pos, m_engine->GetEyePt()) < 50.0f ) // suspension?
if ( glm::distance(pos, m_engine->GetEyePt()) < 50.0f ) // suspension?
{
character = m_object->GetCharacter();
mat = m_object->GetWorldMatrix(0);

View File

@ -19,10 +19,10 @@
#pragma once
#include "math/vector.h"
#include "object/object_type.h"
#include <glm/glm.hpp>
struct ObjectCreateParams
{
glm::vec3 pos;

View File

@ -27,7 +27,6 @@
#include "common/singleton.h"
#include "math/const.h"
#include "math/vector.h"
#include "object/object_create_params.h"
#include "object/object_interface_type.h"
@ -35,6 +34,8 @@
#include "object/interface/destroyable_object.h"
#include <glm/glm.hpp>
#include <map>
#include <vector>
#include <memory>

View File

@ -22,7 +22,7 @@
#include "object/task/task.h"
#include "math/vector.h"
#include <glm/glm.hpp>

View File

@ -246,7 +246,7 @@ bool CTaskBuild::EventProcess(const Event &event)
if ( m_phase == TBP_MOVE ) // preliminary forward/backward?
{
dist = Math::Distance(m_object->GetPosition(), m_metal->GetPosition());
dist = glm::distance(m_object->GetPosition(), m_metal->GetPosition());
linSpeed = 0.0f;
if ( m_physics->GetLand() )
{
@ -362,7 +362,7 @@ bool CTaskBuild::EventProcess(const Event &event)
{
pv = m_object->GetPosition();
pm = m_metal->GetPosition();
dist = Math::Distance(pv, pm);
dist = glm::distance(pv, pm);
diff = pm.y - 8.0f - pv.y;
tilt = m_object->GetRotation();
m_object->StartTaskGunGoal(asin(diff/dist)-tilt.z, 0.0f);
@ -453,7 +453,7 @@ Error CTaskBuild::IsEnded()
{
m_physics->SetMotorSpeedZ(0.0f);
dist = Math::Distance(m_object->GetPosition(), m_metal->GetPosition());
dist = glm::distance(m_object->GetPosition(), m_metal->GetPosition());
if ( dist > 30.0f )
{
time = m_physics->GetLinTimeLength(dist-30.0f, 1.0f);
@ -472,7 +472,7 @@ Error CTaskBuild::IsEnded()
if ( m_phase == TBP_MOVE ) // preliminary forward/backward?
{
dist = Math::Distance(m_object->GetPosition(), m_metal->GetPosition());
dist = glm::distance(m_object->GetPosition(), m_metal->GetPosition());
if ( !m_physics->GetLand())
{
@ -526,7 +526,7 @@ Error CTaskBuild::IsEnded()
m_object->SetObjectParent(1, 0);
pv = m_object->GetPosition();
pm = m_metal->GetPosition();
dist = Math::Distance(pv, pm);
dist = glm::distance(pv, pm);
diff = pm.y - 8.0f - pv.y;
tilt = m_object->GetRotation();
if(dist) m_object->StartTaskGunGoal(asin(diff/dist)-tilt.z, 0.0f);
@ -714,7 +714,7 @@ Error CTaskBuild::FlatFloor()
if ( type == OBJECT_BASE )
{
glm::vec3 oPos = pObj->GetPosition();
dist = Math::Distance(center, oPos)-80.0f;
dist = glm::distance(center, oPos)-80.0f;
if ( dist < max )
{
max = dist;
@ -730,7 +730,7 @@ Error CTaskBuild::FlatFloor()
glm::vec3 oPos = crashSphere.sphere.pos;
float oRadius = crashSphere.sphere.radius;
dist = Math::Distance(center, oPos)-oRadius;
dist = glm::distance(center, oPos)-oRadius;
if ( dist < max )
{
max = dist;
@ -782,7 +782,7 @@ Error CTaskBuild::FlatFloor()
glm::vec3 oPos = crashSphere.sphere.pos;
float oRadius = crashSphere.sphere.radius;
dist = Math::Distance(center, oPos)-oRadius;
dist = glm::distance(center, oPos)-oRadius;
if ( dist < max )
{
max = dist;
@ -831,7 +831,7 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
bMetal = true; // metal exists
oPos = pObj->GetPosition();
distance = Math::Distance(oPos, iPos);
distance = glm::distance(oPos, iPos);
a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW!
if ( distance > dMax ) continue;
@ -886,7 +886,7 @@ void CTaskBuild::DeleteMark(glm::vec3 pos, float radius)
type != OBJECT_MARKPOWER ) continue;
glm::vec3 oPos = obj->GetPosition();
float distance = Math::Distance(oPos, pos);
float distance = glm::distance(oPos, pos);
if ( distance <= radius )
{
objectsToDelete.push_back(obj);

View File

@ -22,10 +22,10 @@
#include "object/task/task.h"
#include "math/vector.h"
#include "object/object_type.h"
#include <glm/glm.hpp>
class CObject;

View File

@ -171,7 +171,7 @@ Error CTaskFireAnt::IsEnded()
pos = glm::vec3(-2.5f, -0.7f, 0.0f);
mat = m_object->GetWorldMatrix(2);
pos = Math::Transform(*mat, pos);
dist = Math::Distance(pos, m_impact);
dist = glm::distance(pos, m_impact);
speed = m_impact-pos;
speed.x += (Math::Rand()-0.5f)*dist*1.2f;
speed.y += (Math::Rand()-0.5f)*dist*0.4f+50.0f;

View File

@ -22,7 +22,7 @@
#include "object/task/task.h"
#include "math/vector.h"
#include <glm/glm.hpp>
enum TaskFireAnt

View File

@ -265,7 +265,7 @@ Error CTaskFlag::CreateFlag(int rank)
CObject* pObj = SearchNearest(pos, OBJECT_NULL);
if ( pObj != nullptr )
{
float dist = Math::Distance(pos, pObj->GetPosition());
float dist = glm::distance(pos, pObj->GetPosition());
if ( dist < 10.0f )
{
return ERR_FLAG_PROXY;
@ -305,7 +305,7 @@ Error CTaskFlag::DeleteFlag()
{
return ERR_FLAG_DELETE;
}
dist = Math::Distance(iPos, pObj->GetPosition());
dist = glm::distance(iPos, pObj->GetPosition());
if ( dist > 10.0f )
{
return ERR_FLAG_DELETE;

View File

@ -21,10 +21,10 @@
#include "object/task/task.h"
#include "math/vector.h"
#include "object/object_type.h"
#include <glm/glm.hpp>
class CObject;

View File

@ -638,7 +638,7 @@ void CTaskGoto::WormFrame(float rTime)
if ( pObj != nullptr )
{
pos = m_object->GetPosition();
dist = Math::Distance(pos, impact);
dist = glm::distance(pos, impact);
if ( dist <= 15.0f )
{
pObj->SetVirusMode(true); // bam, infected!
@ -1019,7 +1019,7 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_CRADVANCE ) // advance after collision?
{
if ( Math::Distance(pos, m_pos) >= 5.0f )
if ( glm::distance(pos, m_pos) >= 5.0f )
{
m_phase = TGP_ADVANCE;
}
@ -1052,7 +1052,7 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_CLADVANCE ) // advance after collision?
{
if ( Math::Distance(pos, m_pos) >= 10.0f )
if ( glm::distance(pos, m_pos) >= 10.0f )
{
m_phase = TGP_ADVANCE;
m_try ++;
@ -1068,7 +1068,7 @@ Error CTaskGoto::IsEnded()
return ERR_STOP;
}
dist = Math::Distance(m_bmFinalPos, m_object->GetPosition());
dist = glm::distance(m_bmFinalPos, m_object->GetPosition());
if ( dist < m_bmFinalDist ) return ERR_CONTINUE;
m_physics->SetMotorSpeedX(0.0f); // stops the advance
return ERR_STOP;
@ -1153,7 +1153,7 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, glm::vec3 &pos, float &distance)
{
pos = m_object->GetPosition();
goal = pObj->GetPosition();
dist = Math::Distance(goal, pos);
dist = glm::distance(goal, pos);
pos = (pos-goal)*(TAKE_DIST+distance)/dist + goal;
return true; // approach from all sites
}
@ -1162,7 +1162,7 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, glm::vec3 &pos, float &distance)
{
pos = m_object->GetPosition();
goal = pObj->GetPosition();
dist = Math::Distance(goal, pos);
dist = glm::distance(goal, pos);
pos = (pos-goal)*(TAKE_DIST+distance)/dist + goal;
return true; // approach from all sites
}
@ -1439,7 +1439,7 @@ void CTaskGoto::ComputeRepulse(glm::vec2&dir)
glm::vec3 iPos = firstCrashSphere.sphere.pos;
float iRadius = firstCrashSphere.sphere.radius;
gDist = Math::Distance(iPos, m_goal);
gDist = glm::distance(iPos, m_goal);
add = m_physics->GetLinStopLength()*1.1f; // braking distance
fac = 2.0f;
@ -1551,7 +1551,7 @@ void CTaskGoto::ComputeRepulse(glm::vec2&dir)
if ( oPos.y-oRadius > iPos.y+iRadius ) continue;
if ( oPos.y+oRadius < iPos.y-iRadius ) continue;
dist = Math::Distance(oPos, m_goal);
dist = glm::distance(oPos, m_goal);
if ( dist <= 1.0f ) continue; // on purpose?
oRadius += iRadius+addi;

View File

@ -21,8 +21,6 @@
#include "object/task/task.h"
#include "math/vector.h"
#include <glm/glm.hpp>
#include <memory>

View File

@ -461,7 +461,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
}
dist = Math::Distance(m_object->GetPosition(), m_targetPos);
dist = glm::distance(m_object->GetPosition(), m_targetPos);
len = dist-TAKE_DIST;
if ( m_arm == TMA_OTHER ) len -= TAKE_DIST_OTHER;
if ( len < 0.0f ) len = 0.0f;
@ -548,7 +548,7 @@ Error CTaskManip::IsEnded()
if ( m_timeLimit <= 0.0f )
{
//OK 1.9
dist = Math::Distance(m_object->GetPosition(), m_targetPos);
dist = glm::distance(m_object->GetPosition(), m_targetPos);
if ( dist <= m_advanceLength + 2.0f )
{
m_move = 0.0f; // advance ended
@ -566,7 +566,7 @@ Error CTaskManip::IsEnded()
}
}
dist = Math::Distance(m_object->GetPosition(), m_targetPos);
dist = glm::distance(m_object->GetPosition(), m_targetPos);
if ( dist <= m_advanceLength )
{
m_move = 0.0f; // advance ended
@ -714,7 +714,7 @@ CObject* CTaskManip::SearchTakeUnderObject(glm::vec3 &pos, float dLimit)
if ( pObj->GetScaleY() != 1.0f ) continue;
oPos = pObj->GetPosition();
distance = Math::Distance(oPos, iPos);
distance = glm::distance(oPos, iPos);
if ( distance <= dLimit &&
distance < min )
{
@ -766,7 +766,7 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, glm::vec3 &pos,
if ( pObj->GetScaleY() != 1.0f ) continue;
oPos = pObj->GetPosition();
distance = fabs(Math::Distance(oPos, iPos)-TAKE_DIST);
distance = fabs(glm::distance(oPos, iPos)-TAKE_DIST);
f = 1.0f-distance/50.0f;
if ( f < 0.5f ) f = 0.5f;
@ -833,7 +833,7 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, glm::vec3 &pos,
if ( pObj->GetScaleY() != 1.0f ) continue;
oPos = pObj->GetPosition();
distance = fabs(Math::Distance(oPos, iPos)-TAKE_DIST);
distance = fabs(glm::distance(oPos, iPos)-TAKE_DIST);
f = 1.0f-distance/50.0f;
if ( f < 0.5f ) f = 0.5f;
@ -940,7 +940,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, glm::vec3 &pos,
angle = Math::RotateAngle(iPos.x-oPos.x, oPos.z-iPos.z); // CW !
if ( !Math::TestAngle(angle, oAngle-oLimit, oAngle+oLimit) ) continue;
distance = fabs(Math::Distance(oPos, iPos)-TAKE_DIST);
distance = fabs(glm::distance(oPos, iPos)-TAKE_DIST);
if ( distance <= dLimit )
{
angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
@ -1232,7 +1232,7 @@ bool CTaskManip::IsFreeDeposeObject(glm::vec3 pos)
for (const auto& crashSphere : obj->GetAllCrashSpheres())
{
if ( Math::Distance(iPos, crashSphere.sphere.pos)-(crashSphere.sphere.radius+1.0f) < 2.0f )
if ( glm::distance(iPos, crashSphere.sphere.pos)-(crashSphere.sphere.radius+1.0f) < 2.0f )
{
return false; // location occupied
}

View File

@ -22,10 +22,10 @@
#include "object/task/task.h"
#include "math/vector.h"
#include "object/object_type.h"
#include <glm/glm.hpp>
class CObject;

View File

@ -21,10 +21,10 @@
#include "object/task/task.h"
#include "math/vector.h"
#include "object/interface/trace_drawing_object.h"
#include <glm/glm.hpp>
enum TaskPenPhase
{

View File

@ -98,7 +98,7 @@ bool CTaskRecover::EventProcess(const Event &event)
if ( m_phase == TRP_MOVE ) // preliminary forward/backward?
{
dist = Math::Distance(m_object->GetPosition(), m_ruin->GetPosition());
dist = glm::distance(m_object->GetPosition(), m_ruin->GetPosition());
linSpeed = 0.0f;
if ( dist > RECOVER_DIST ) linSpeed = 1.0f;
if ( dist < RECOVER_DIST ) linSpeed = -1.0f;
@ -246,7 +246,7 @@ Error CTaskRecover::IsEnded()
{
m_physics->SetMotorSpeedZ(0.0f);
dist = Math::Distance(m_object->GetPosition(), m_ruin->GetPosition());
dist = glm::distance(m_object->GetPosition(), m_ruin->GetPosition());
if ( dist > RECOVER_DIST )
{
time = m_physics->GetLinTimeLength(dist-RECOVER_DIST, 1.0f);
@ -265,7 +265,7 @@ Error CTaskRecover::IsEnded()
if ( m_phase == TRP_MOVE ) // preliminary advance?
{
dist = Math::Distance(m_object->GetPosition(), m_ruin->GetPosition());
dist = glm::distance(m_object->GetPosition(), m_ruin->GetPosition());
if ( dist >= RECOVER_DIST-1.0f &&
dist <= RECOVER_DIST+1.0f )

View File

@ -22,7 +22,7 @@
#include "object/task/task.h"
#include "math/vector.h"
#include <glm/glm.hpp>
class CObject;

View File

@ -553,7 +553,7 @@ void CTaskShield::IncreaseShield()
if (!shielded->IsRepairable()) continue; // NOTE: Looks like the original code forgot to check that
glm::vec3 oPos = obj->GetPosition();
float dist = Math::Distance(oPos, m_shieldPos);
float dist = glm::distance(oPos, m_shieldPos);
if ( dist <= GetRadius()+10.0f )
{
shielded->SetShield(shielded->GetShield() + 0.1f);

View File

@ -22,7 +22,7 @@
#include "object/task/task.h"
#include "math/vector.h"
#include <glm/glm.hpp>
const float RADIUS_SHIELD_MIN = 40.0f; // minimum radius of the protected zone

View File

@ -309,7 +309,7 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
if ( pObj->GetScaleY() != 1.0f ) continue;
oPos = pObj->GetPosition();
distance = Math::Distance(oPos, iPos);
distance = glm::distance(oPos, iPos);
if ( distance >= 4.0f-dLimit &&
distance <= 4.0f+dLimit )
{
@ -400,7 +400,7 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
Math::Matrix* mat = pObj->GetWorldMatrix(0);
glm::vec3 oPos = Math::Transform(*mat, dynamic_cast<CPoweredObject&>(*pObj).GetPowerPosition());
float distance = fabs(Math::Distance(oPos, iPos) - (iRad+1.0f));
float distance = fabs(glm::distance(oPos, iPos) - (iRad+1.0f));
if ( distance <= dLimit )
{
angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
@ -541,7 +541,7 @@ bool CTaskTake::IsFreeDeposeObject(glm::vec3 pos)
for (const auto& crashSphere : pObj->GetAllCrashSpheres())
{
if ( Math::Distance(iPos, crashSphere.sphere.pos)-(crashSphere.sphere.radius+1.0f) < 1.0f )
if ( glm::distance(iPos, crashSphere.sphere.pos)-(crashSphere.sphere.radius+1.0f) < 1.0f )
{
return false; // location occupied
}

View File

@ -21,10 +21,10 @@
#include "object/task/task.h"
#include "math/vector.h"
#include "object/object_type.h"
#include <glm/glm.hpp>
class CObject;

View File

@ -282,7 +282,7 @@ Error CTaskTerraform::IsEnded()
pos.z = m_terraPos.z+(Math::Rand()-0.5f)*80.0f;
pos.y = m_terraPos.y;
m_terrain->AdjustToFloor(pos);
dist = Math::Distance(pos, m_terraPos);
dist = glm::distance(pos, m_terraPos);
speed = glm::vec3(0.0f, 0.0f, 0.0f);
dim.x = 2.0f+(40.0f-dist)/(1.0f+Math::Rand()*4.0f);
dim.y = dim.x;
@ -412,7 +412,7 @@ bool CTaskTerraform::Terraform()
type == OBJECT_BARRIER3 ||
type == OBJECT_APOLLO4 ) // everything what fits?
{
dist = Math::Distance(m_terraPos, pObj->GetPosition());
dist = glm::distance(m_terraPos, pObj->GetPosition());
if ( type == OBJECT_BULLET ||
type == OBJECT_NEST ||
@ -457,7 +457,7 @@ bool CTaskTerraform::Terraform()
if ( !pObj->Implements(ObjectInterfaceType::Movable) ) continue;
motion = dynamic_cast<CMovableObject&>(*pObj).GetMotion();
dist = Math::Distance(m_terraPos, pObj->GetPosition());
dist = glm::distance(m_terraPos, pObj->GetPosition());
if ( dist > ACTION_RADIUS ) continue;
if ( type == OBJECT_ANT || type == OBJECT_SPIDER )

View File

@ -22,7 +22,7 @@
#include "object/task/task.h"
#include "math/vector.h"
#include <glm/glm.hpp>
enum TaskTerraPhase

View File

@ -2552,7 +2552,7 @@ int CPhysics::ObjectAdapt(const glm::vec3 &pos, const glm::vec3 &angle)
if ( oType == OBJECT_TARGET2 && !pObj->GetLock() )
{
glm::vec3 oPos = pObj->GetPosition();
distance = Math::Distance(oPos, iPos);
distance = glm::distance(oPos, iPos);
if ( distance < 10.0f*1.5f )
{
m_sound->Play(SOUND_WAYPOINT, m_object->GetPosition());
@ -2573,10 +2573,10 @@ int CPhysics::ObjectAdapt(const glm::vec3 &pos, const glm::vec3 &angle)
if ( iType == OBJECT_BEE && oRad <= 1.2f ) continue;
if ( iType == OBJECT_WORM && oRad <= 1.2f ) continue;
distance = Math::Distance(oPos, iPos);
distance = glm::distance(oPos, iPos);
if ( distance < iRad+oRad ) // collision?
{
distance = Math::Distance(oPos, iiPos);
distance = glm::distance(oPos, iiPos);
if ( distance >= iRad+oRad ) // view (*)
{
m_bCollision = true;
@ -2664,7 +2664,7 @@ bool CPhysics::JostleObject(CJostleableObject* pObj, glm::vec3 iPos, float iRad)
{
Math::Sphere jostlingSphere = pObj->GetJostlingSphere();
float distance = Math::Distance(jostlingSphere.pos, iPos);
float distance = glm::distance(jostlingSphere.pos, iPos);
if ( distance >= iRad+jostlingSphere.radius) return false;
float d = (iRad+jostlingSphere.radius)/2.0f;
@ -3041,7 +3041,7 @@ void CPhysics::CrashParticle(float crash)
ppos.x = pos.x + (Math::Rand()-0.5f)*15.0f*crash;
ppos.z = pos.z + (Math::Rand()-0.5f)*15.0f*crash;
ppos.y = pos.y + Math::Rand()*4.0f;
len = 1.0f-(Math::Distance(ppos, pos)/(15.0f+5.0f));
len = 1.0f-(glm::distance(ppos, pos)/(15.0f+5.0f));
if ( len <= 0.0f ) continue;
speed.x = (ppos.x-pos.x)*0.1f;
speed.z = (ppos.z-pos.z)*0.1f;
@ -3731,10 +3731,10 @@ void CPhysics::WheelParticle(TraceColor color, float width)
while ( true )
{
dist1 = Math::Distance(m_wheelParticlePos[0], goal1);
dist1 = glm::distance(m_wheelParticlePos[0], goal1);
if ( dist1 < step ) break;
dist2 = Math::Distance(m_wheelParticlePos[1], goal2);
dist2 = glm::distance(m_wheelParticlePos[1], goal2);
wheel1 = Math::SegmentPoint(m_wheelParticlePos[0], goal1, step);
wheel2 = Math::SegmentPoint(m_wheelParticlePos[1], goal2, step * dist2 / dist1);

View File

@ -27,12 +27,12 @@
#include "common/error.h"
#include "math/vector.h"
#include "object/object_type.h"
#include "object/interface/trace_drawing_object.h"
#include <glm/glm.hpp>
class CObject;
class COldObject;

View File

@ -1732,7 +1732,7 @@ bool CScriptFunctions::rDistance(CBotVar* var, CBotVar* result, int& exception,
if ( !GetPoint(var, exception, p1) ) return true;
if ( !GetPoint(var, exception, p2) ) return true;
value = Math::Distance(p1, p2);
value = glm::distance(p1, p2);
result->SetValFloat(value/g_unit);
return true;
}

View File

@ -24,12 +24,12 @@
#pragma once
#include "math/vector.h"
#include "sound/sound.h"
#include "sound/oalsound/check.h"
#include <glm/glm.hpp>
#include <string>
#include <deque>
#include <cassert>

View File

@ -21,7 +21,7 @@
#include "common/logger.h"
#include "math/vector.h"
#include "math/func.h"
#include <iostream>
#include <iomanip>

View File

@ -26,7 +26,7 @@
#include "sound/sound_type.h"
#include "math/vector.h"
#include <glm/glm.hpp>
#include <string>

View File

@ -23,6 +23,8 @@
#include "graphics/model/model_io_exception.h"
#include "graphics/model/model_output.h"
#include "math/func.h"
#include <iostream>
#include <fstream>
#include <map>

View File

@ -275,7 +275,7 @@ TEST(MatrixTest, MultiplyVectorTest)
const glm::vec3 expectedMultiply1(0.608932463260470f, -1.356893266403749f, 3.457156276255142f);
glm::vec3 multiply1 = Math::MatrixVectorMultiply(mat1, vec1, false);
EXPECT_TRUE(Math::VectorsEqual(multiply1, expectedMultiply1, TEST_TOLERANCE));
EXPECT_TRUE(glm::all(glm::epsilonEqual(multiply1, expectedMultiply1, TEST_TOLERANCE)));
const Math::Matrix mat2(
{
@ -291,5 +291,5 @@ TEST(MatrixTest, MultiplyVectorTest)
const glm::vec3 expectedMultiply2(0.2816820577317669f, 0.0334468811767428f, 0.1996974284970455f);
glm::vec3 multiply2 = Math::MatrixVectorMultiply(mat2, vec2, true);
EXPECT_TRUE(Math::VectorsEqual(multiply2, expectedMultiply2, TEST_TOLERANCE));
EXPECT_TRUE(glm::all(glm::epsilonEqual(multiply2, expectedMultiply2, TEST_TOLERANCE)));
}

View File

@ -25,7 +25,9 @@
*/
#include "math/func.h"
#include "math/vector.h"
#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include <gtest/gtest.h>
@ -48,7 +50,7 @@ TEST(VectorTest, NormalizeTest)
vec = glm::normalize(vec);
EXPECT_TRUE(Math::VectorsEqual(vec, expectedNormalized, TEST_TOLERANCE));
EXPECT_TRUE(glm::all(glm::epsilonEqual(vec, expectedNormalized, TEST_TOLERANCE)));
}
TEST(VectorTest, DotTest)
@ -69,7 +71,7 @@ TEST(VectorTest, CrossTest)
glm::vec3 expectedCross(-1.937932065431669, 2.978844370287636, -0.437739173833581);
glm::vec3 expectedReverseCross = -expectedCross;
EXPECT_TRUE(Math::VectorsEqual(glm::cross(vecA, vecB), expectedCross, TEST_TOLERANCE));
EXPECT_TRUE(glm::all(glm::epsilonEqual(glm::cross(vecA, vecB), expectedCross, TEST_TOLERANCE)));
EXPECT_TRUE(Math::VectorsEqual(glm::cross(vecB, vecA), expectedReverseCross, TEST_TOLERANCE));
EXPECT_TRUE(glm::all(glm::epsilonEqual(glm::cross(vecB, vecA), expectedReverseCross, TEST_TOLERANCE)));
}