Fully refactored Math::Matrix, removed matrix.h and moved remaining functions to other files
parent
208f142cd2
commit
9c37f6cbd5
|
@ -179,7 +179,6 @@ add_library(colobotbase STATIC
|
|||
math/geometry.h
|
||||
math/half.cpp
|
||||
math/half.h
|
||||
math/matrix.h
|
||||
math/sphere.h
|
||||
object/auto/auto.cpp
|
||||
object/auto/auto.h
|
||||
|
|
|
@ -127,7 +127,7 @@ void CCloud::Draw()
|
|||
|
||||
m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK | ENG_RSTATE_FOG | ENG_RSTATE_WRAP);
|
||||
|
||||
Math::Matrix matrix = glm::mat4(1.0f);
|
||||
glm::mat4 matrix = glm::mat4(1.0f);
|
||||
device->SetTransform(TRANSFORM_WORLD, matrix);
|
||||
|
||||
float size = m_brickSize/2.0f;
|
||||
|
|
|
@ -232,7 +232,7 @@ CEngine::CEngine(CApplication *app, CSystemUtils* systemUtils)
|
|||
m_terrainTexParams.filter = TEX_FILTER_BILINEAR;
|
||||
|
||||
// Compute bias matrix for shadow mapping
|
||||
Math::Matrix temp1, temp2;
|
||||
glm::mat4 temp1, temp2;
|
||||
Math::LoadScaleMatrix(temp1, glm::vec3(0.5f, 0.5f, 0.5f));
|
||||
Math::LoadTranslationMatrix(temp2, glm::vec3(1.0f, 1.0f, 1.0f));
|
||||
m_shadowBias = temp1 * temp2;
|
||||
|
@ -899,8 +899,7 @@ int CEngine::CreateObject()
|
|||
|
||||
m_objects[objRank].used = true;
|
||||
|
||||
Math::Matrix mat;
|
||||
mat = glm::mat4(1.0f);
|
||||
glm::mat4 mat = glm::mat4(1.0f);
|
||||
SetObjectTransform(objRank, mat);
|
||||
|
||||
m_objects[objRank].drawWorld = true;
|
||||
|
@ -959,14 +958,14 @@ EngineObjectType CEngine::GetObjectType(int objRank)
|
|||
}
|
||||
|
||||
|
||||
void CEngine::SetObjectTransform(int objRank, const Math::Matrix& transform)
|
||||
void CEngine::SetObjectTransform(int objRank, const glm::mat4& transform)
|
||||
{
|
||||
assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
|
||||
|
||||
m_objects[objRank].transform = transform;
|
||||
}
|
||||
|
||||
void CEngine::GetObjectTransform(int objRank, Math::Matrix& transform)
|
||||
void CEngine::GetObjectTransform(int objRank, glm::mat4& transform)
|
||||
{
|
||||
assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
|
||||
|
||||
|
@ -1928,7 +1927,7 @@ bool CEngine::DetectTriangle(const glm::vec2& mouse, Vertex3D* triangle, int obj
|
|||
}
|
||||
|
||||
//! Use only after world transform already set
|
||||
bool CEngine::IsVisible(const Math::Matrix& matrix, int objRank)
|
||||
bool CEngine::IsVisible(const glm::mat4& matrix, int objRank)
|
||||
{
|
||||
assert(objRank >= 0 && objRank < static_cast<int>(m_objects.size()));
|
||||
|
||||
|
@ -1949,7 +1948,7 @@ bool CEngine::IsVisible(const Math::Matrix& matrix, int objRank)
|
|||
return false;
|
||||
}
|
||||
|
||||
int CEngine::ComputeSphereVisibility(const Math::Matrix& m, const glm::vec3& center, float radius)
|
||||
int CEngine::ComputeSphereVisibility(const glm::mat4& m, const glm::vec3& center, float radius)
|
||||
{
|
||||
glm::vec3 vec[6];
|
||||
float originPlane[6];
|
||||
|
@ -3225,12 +3224,12 @@ bool CEngine::GetPauseBlurEnabled()
|
|||
return m_pauseBlurEnabled;
|
||||
}
|
||||
|
||||
const Math::Matrix& CEngine::GetMatView()
|
||||
const glm::mat4& CEngine::GetMatView()
|
||||
{
|
||||
return m_matView;
|
||||
}
|
||||
|
||||
const Math::Matrix& CEngine::GetMatProj()
|
||||
const glm::mat4& CEngine::GetMatProj()
|
||||
{
|
||||
return m_matProj;
|
||||
}
|
||||
|
@ -3670,7 +3669,7 @@ void CEngine::Draw3DScene()
|
|||
|
||||
if (m_debugGoto)
|
||||
{
|
||||
Math::Matrix worldMatrix = glm::mat4(1.0f);
|
||||
glm::mat4 worldMatrix = glm::mat4(1.0f);
|
||||
m_device->SetTransform(TRANSFORM_WORLD, worldMatrix);
|
||||
|
||||
SetState(ENG_RSTATE_OPAQUE_COLOR);
|
||||
|
@ -3807,7 +3806,7 @@ void CEngine::Capture3DScene()
|
|||
|
||||
void CEngine::DrawCaptured3DScene()
|
||||
{
|
||||
Math::Matrix identity;
|
||||
glm::mat4 identity = glm::mat4(1.0f);
|
||||
|
||||
m_device->SetTransform(TRANSFORM_PROJECTION, identity);
|
||||
m_device->SetTransform(TRANSFORM_VIEW, identity);
|
||||
|
@ -3831,7 +3830,7 @@ void CEngine::DrawCaptured3DScene()
|
|||
renderer->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, 4, vertices);
|
||||
}
|
||||
|
||||
void CEngine::RenderDebugSphere(const Math::Sphere& sphere, const Math::Matrix& transform, const Gfx::Color& color)
|
||||
void CEngine::RenderDebugSphere(const Math::Sphere& sphere, const glm::mat4& transform, const Gfx::Color& color)
|
||||
{
|
||||
static constexpr int LONGITUDE_DIVISIONS = 16;
|
||||
static constexpr int LATITUDE_DIVISIONS = 8;
|
||||
|
@ -3895,12 +3894,12 @@ void CEngine::RenderDebugSphere(const Math::Sphere& sphere, const Math::Matrix&
|
|||
|
||||
for (std::size_t i = 0; i < verticesTemplate.size(); ++i)
|
||||
{
|
||||
auto pos = Math::MatrixVectorMultiply(transform, sphere.pos + verticesTemplate[i] * sphere.radius);
|
||||
auto pos = Math::Transform(transform, sphere.pos + verticesTemplate[i] * sphere.radius);
|
||||
m_pendingDebugDraws.vertices[i + firstVert] = VertexCol{pos, color};
|
||||
}
|
||||
}
|
||||
|
||||
void CEngine::RenderDebugBox(const glm::vec3& mins, const glm::vec3& maxs, const Math::Matrix& transform, const Gfx::Color& color)
|
||||
void CEngine::RenderDebugBox(const glm::vec3& mins, const glm::vec3& maxs, const glm::mat4& transform, const Gfx::Color& color)
|
||||
{
|
||||
static constexpr int NUM_LINE_STRIPS = 4;
|
||||
static constexpr int VERTS_IN_LINE_STRIP = 4;
|
||||
|
@ -3949,7 +3948,7 @@ void CEngine::RenderPendingDebugDraws()
|
|||
{
|
||||
if (m_pendingDebugDraws.firsts.empty()) return;
|
||||
|
||||
m_device->SetTransform(TRANSFORM_WORLD, Math::Matrix{});
|
||||
m_device->SetTransform(TRANSFORM_WORLD, glm::mat4(1.0f));
|
||||
|
||||
SetState(ENG_RSTATE_OPAQUE_COLOR);
|
||||
|
||||
|
@ -4070,7 +4069,7 @@ void CEngine::RenderShadowMap()
|
|||
// To prevent 'shadow shimmering', we ensure that the position only moves in texel-sized
|
||||
// increments. To do this we transform the position to a space where the light's forward/right/up
|
||||
// axes are aligned with the x/y/z axes (not necessarily in that order, and +/- signs don't matter).
|
||||
Math::Matrix lightRotation;
|
||||
glm::mat4 lightRotation;
|
||||
Math::LoadViewMatrix(lightRotation, glm::vec3{0, 0, 0}, lightDir, worldUp);
|
||||
pos = Math::MatrixVectorMultiply(lightRotation, pos);
|
||||
// ...then we round to the nearest worldUnitsPerTexel:
|
||||
|
@ -4089,11 +4088,11 @@ void CEngine::RenderShadowMap()
|
|||
Math::LoadOrthoProjectionMatrix(m_shadowProjMat, -dist, dist, -dist, dist, -depth, depth);
|
||||
Math::LoadViewMatrix(m_shadowViewMat, pos, lookAt, worldUp);
|
||||
|
||||
Math::Matrix scaleMat;
|
||||
glm::mat4 scaleMat;
|
||||
Math::LoadScaleMatrix(scaleMat, glm::vec3(1.0f, 1.0f, -1.0f));
|
||||
m_shadowViewMat = scaleMat * m_shadowViewMat;
|
||||
|
||||
Math::Matrix temporary = m_shadowProjMat * m_shadowViewMat;
|
||||
glm::mat4 temporary = m_shadowProjMat * m_shadowViewMat;
|
||||
m_shadowTextureMat = m_shadowBias * temporary;
|
||||
|
||||
m_shadowViewMat = scaleMat * m_shadowViewMat;
|
||||
|
@ -4719,7 +4718,7 @@ void CEngine::DrawShadowSpots()
|
|||
m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, false);
|
||||
m_device->SetRenderState(RENDER_STATE_LIGHTING, false);
|
||||
|
||||
Math::Matrix matrix = glm::mat4(1.0f);
|
||||
glm::mat4 matrix = glm::mat4(1.0f);
|
||||
m_device->SetTransform(TRANSFORM_WORLD, matrix);
|
||||
|
||||
|
||||
|
@ -5579,7 +5578,7 @@ void CEngine::UpdateObjectShadowSpotNormal(int objRank)
|
|||
m_shadowSpots[shadowRank].normal = norm;
|
||||
}
|
||||
|
||||
int CEngine::AddStaticMesh(const std::string& key, const CModelMesh* mesh, const Math::Matrix& worldMatrix)
|
||||
int CEngine::AddStaticMesh(const std::string& key, const CModelMesh* mesh, const glm::mat4& worldMatrix)
|
||||
{
|
||||
int baseObjRank = -1;
|
||||
|
||||
|
@ -5624,7 +5623,7 @@ void CEngine::DeleteStaticMesh(int meshHandle)
|
|||
DeleteObject(objRank);
|
||||
}
|
||||
|
||||
const Math::Matrix& CEngine::GetStaticMeshWorldMatrix(int meshHandle)
|
||||
const glm::mat4& CEngine::GetStaticMeshWorldMatrix(int meshHandle)
|
||||
{
|
||||
int objRank = meshHandle;
|
||||
return m_objects[objRank].transform;
|
||||
|
@ -5715,11 +5714,11 @@ void CEngine::DisablePauseBlur()
|
|||
|
||||
void CEngine::SetWindowCoordinates()
|
||||
{
|
||||
Math::Matrix matWorldWindow = glm::mat4(1.0f);
|
||||
glm::mat4 matWorldWindow = glm::mat4(1.0f);
|
||||
|
||||
Math::Matrix matViewWindow = glm::mat4(1.0f);
|
||||
glm::mat4 matViewWindow = glm::mat4(1.0f);
|
||||
|
||||
Math::Matrix matProjWindow;
|
||||
glm::mat4 matProjWindow;
|
||||
Math::LoadOrthoProjectionMatrix(matProjWindow, 0.0f, m_size.x, m_size.y, 0.0f, -1.0f, 1.0f);
|
||||
|
||||
m_device->SetTransform(TRANSFORM_VIEW, matViewWindow);
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "graphics/core/texture.h"
|
||||
#include "graphics/core/vertex.h"
|
||||
|
||||
#include "math/matrix.h"
|
||||
#include "math/sphere.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
@ -275,7 +274,7 @@ struct EngineObject
|
|||
//! Type of object
|
||||
EngineObjectType type = ENG_OBJTYPE_NULL;
|
||||
//! Transformation matrix
|
||||
Math::Matrix transform;
|
||||
glm::mat4 transform;
|
||||
//! Distance to object from eye point
|
||||
float distance = 0.0f;
|
||||
//! Rank of the associated shadow
|
||||
|
@ -700,7 +699,7 @@ public:
|
|||
* @param key key unique per object class
|
||||
* @return mesh instance handle
|
||||
*/
|
||||
int AddStaticMesh(const std::string& key, const Gfx::CModelMesh* mesh, const Math::Matrix& worldMatrix);
|
||||
int AddStaticMesh(const std::string& key, const Gfx::CModelMesh* mesh, const glm::mat4& worldMatrix);
|
||||
|
||||
//! Removes given static mesh
|
||||
void DeleteStaticMesh(int meshHandle);
|
||||
|
@ -709,7 +708,7 @@ public:
|
|||
void AddStaticMeshShadowSpot(int meshHandle, const Gfx::ModelShadowSpot& shadowSpot);
|
||||
|
||||
//! Returns static mesh world matrix
|
||||
const Math::Matrix& GetStaticMeshWorldMatrix(int meshHandle);
|
||||
const glm::mat4& GetStaticMeshWorldMatrix(int meshHandle);
|
||||
|
||||
//! Sets transparency for static mesh
|
||||
void SetStaticMeshTransparency(int meshHandle, float value);
|
||||
|
@ -763,8 +762,8 @@ public:
|
|||
|
||||
//@{
|
||||
//! Management of object transform
|
||||
void SetObjectTransform(int objRank, const Math::Matrix& transform);
|
||||
void GetObjectTransform(int objRank, Math::Matrix& transform);
|
||||
void SetObjectTransform(int objRank, const glm::mat4& transform);
|
||||
void GetObjectTransform(int objRank, glm::mat4& transform);
|
||||
//@}
|
||||
|
||||
//! Sets drawWorld for given object
|
||||
|
@ -1153,9 +1152,9 @@ public:
|
|||
//@}
|
||||
|
||||
//! Returns the view matrix
|
||||
const Math::Matrix& GetMatView();
|
||||
const glm::mat4& GetMatView();
|
||||
//! Returns the projection matrix
|
||||
const Math::Matrix& GetMatProj();
|
||||
const glm::mat4& GetMatProj();
|
||||
//! Returns the camera center point
|
||||
TEST_VIRTUAL glm::vec3 GetEyePt();
|
||||
//! Returns the camera target point
|
||||
|
@ -1173,8 +1172,8 @@ public:
|
|||
//! Updates the scene after a change of parameters
|
||||
void ApplyChange();
|
||||
|
||||
void RenderDebugSphere(const Math::Sphere&, const Math::Matrix& transform = Math::Matrix{}, const Color& = Color{0.0f, 0.0f, 1.0f, 1.0f});
|
||||
void RenderDebugBox(const glm::vec3& mins, const glm::vec3& maxs, const Math::Matrix& transform = Math::Matrix{}, const Color& = Color{0.0f, 0.0f, 1.0f, 1.0f});
|
||||
void RenderDebugSphere(const Math::Sphere&, const glm::mat4& transform = glm::mat4(1.0f), const Color & = Color{0.0f, 0.0f, 1.0f, 1.0f});
|
||||
void RenderDebugBox(const glm::vec3& mins, const glm::vec3& maxs, const glm::mat4& transform = glm::mat4(1.0f), const Color & = Color{0.0f, 0.0f, 1.0f, 1.0f});
|
||||
|
||||
void SetDebugLights(bool debugLights);
|
||||
bool GetDebugLights();
|
||||
|
@ -1260,9 +1259,9 @@ protected:
|
|||
Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr);
|
||||
|
||||
//! Tests whether the given object is visible
|
||||
bool IsVisible(const Math::Matrix& matrix, int objRank);
|
||||
bool IsVisible(const glm::mat4& matrix, int objRank);
|
||||
|
||||
int ComputeSphereVisibility(const Math::Matrix& m, const glm::vec3& center, float radius);
|
||||
int ComputeSphereVisibility(const glm::mat4& m, const glm::vec3& center, float radius);
|
||||
|
||||
bool InPlane(glm::vec3 normal, float originPlane, glm::vec3 center, float radius);
|
||||
|
||||
|
@ -1339,32 +1338,32 @@ protected:
|
|||
bool m_screenshotMode;
|
||||
|
||||
//! Projection matrix for 3D scene
|
||||
Math::Matrix m_matProj;
|
||||
glm::mat4 m_matProj;
|
||||
//! View matrix for 3D scene
|
||||
Math::Matrix m_matView;
|
||||
glm::mat4 m_matView;
|
||||
//! Camera vertical field-of-view angle for 3D scene. A.k.a. m_vfov
|
||||
float m_focus;
|
||||
//! Horizontal field-of-view angle, calculated from vertical FOV and aspect ratio
|
||||
float m_hfov;
|
||||
|
||||
//! Projection matrix for rendering shadow maps
|
||||
Math::Matrix m_shadowProjMat;
|
||||
glm::mat4 m_shadowProjMat;
|
||||
//! View matrix for rendering shadow maps
|
||||
Math::Matrix m_shadowViewMat;
|
||||
glm::mat4 m_shadowViewMat;
|
||||
//! Texture matrix for rendering shadow maps
|
||||
Math::Matrix m_shadowTextureMat;
|
||||
glm::mat4 m_shadowTextureMat;
|
||||
//! Texture bias for sampling shadow maps
|
||||
Math::Matrix m_shadowBias;
|
||||
glm::mat4 m_shadowBias;
|
||||
|
||||
//! Vertical synchronization controll
|
||||
int m_vsync;
|
||||
|
||||
//! World matrix for 2D interface
|
||||
Math::Matrix m_matWorldInterface;
|
||||
glm::mat4 m_matWorldInterface;
|
||||
//! Projection matrix for 2D interface
|
||||
Math::Matrix m_matProjInterface;
|
||||
glm::mat4 m_matProjInterface;
|
||||
//! View matrix for 2D interface
|
||||
Math::Matrix m_matViewInterface;
|
||||
glm::mat4 m_matViewInterface;
|
||||
|
||||
//! Current size of viewport window
|
||||
glm::ivec2 m_size;
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include "graphics/engine/engine.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
|
||||
// Graphics module namespace
|
||||
namespace Gfx
|
||||
|
|
|
@ -140,8 +140,8 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
m_power = true;
|
||||
pos = power->GetPosition();
|
||||
pos.y += 1.0f;
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(0);
|
||||
m_posPower = Math::Transform(*mat, pos);
|
||||
glm::mat4 mat = obj->GetWorldMatrix(0);
|
||||
m_posPower = Math::Transform(mat, pos);
|
||||
}
|
||||
|
||||
if ( oType == OBJECT_POWER ||
|
||||
|
@ -158,15 +158,15 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
if ( oType == OBJECT_STATION )
|
||||
{
|
||||
m_power = true;
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(0);
|
||||
m_posPower = Math::Transform(*mat, glm::vec3(-15.0f, 7.0f, 0.0f));
|
||||
glm::mat4 mat = obj->GetWorldMatrix(0);
|
||||
m_posPower = Math::Transform(mat, glm::vec3(-15.0f, 7.0f, 0.0f));
|
||||
m_pos = m_posPower;
|
||||
}
|
||||
if ( oType == OBJECT_ENERGY )
|
||||
{
|
||||
m_power = true;
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(0);
|
||||
m_posPower = Math::Transform(*mat, glm::vec3(-7.0f, 6.0f, 0.0f));
|
||||
glm::mat4 mat = obj->GetWorldMatrix(0);
|
||||
m_posPower = Math::Transform(mat, glm::vec3(-7.0f, 6.0f, 0.0f));
|
||||
m_pos = m_posPower;
|
||||
}
|
||||
if ( oType == OBJECT_NUCLEAR )
|
||||
|
@ -396,8 +396,8 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
m_speed = 1.0f/15.0f;
|
||||
|
||||
pos = glm::vec3(-3.0f, 2.0f, 0.0f);
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(0);
|
||||
m_pos = Math::Transform(*mat, pos);
|
||||
glm::mat4 mat = obj->GetWorldMatrix(0);
|
||||
m_pos = Math::Transform(mat, pos);
|
||||
|
||||
m_engine->DeleteShadowSpot(m_object->GetObjectRank(0));
|
||||
}
|
||||
|
@ -1541,8 +1541,8 @@ void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part)
|
|||
glm::vec3 speed;
|
||||
float mass;
|
||||
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(part);
|
||||
glm::vec3 pos = Math::Transform(*mat, offset);
|
||||
glm::mat4 mat = obj->GetWorldMatrix(part);
|
||||
glm::vec3 pos = Math::Transform(mat, offset);
|
||||
if ( m_type == PT_FRAGV || m_type == PT_EGG )
|
||||
{
|
||||
speed.x = (Math::Rand()-0.5f)*10.0f;
|
||||
|
|
|
@ -117,7 +117,7 @@ void CGL33Device::DebugLights()
|
|||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
Math::Matrix saveWorldMat = m_worldMat;
|
||||
glm::mat4 saveWorldMat = m_worldMat;
|
||||
glm::mat4 identity = glm::mat4(1.0f);
|
||||
SetTransform(TRANSFORM_WORLD, identity);
|
||||
|
||||
|
@ -577,7 +577,7 @@ void CGL33Device::Restore()
|
|||
//UpdateTextureState(2);
|
||||
}
|
||||
|
||||
void CGL33Device::SetTransform(TransformType type, const Math::Matrix &matrix)
|
||||
void CGL33Device::SetTransform(TransformType type, const glm::mat4 &matrix)
|
||||
{
|
||||
if (type == TRANSFORM_WORLD)
|
||||
{
|
||||
|
@ -588,13 +588,13 @@ void CGL33Device::SetTransform(TransformType type, const Math::Matrix &matrix)
|
|||
m_combinedMatrixOutdated = true;
|
||||
|
||||
// normal transform
|
||||
Math::Matrix normalMat = glm::inverse(normalMat);
|
||||
glm::mat4 normalMat = glm::inverse(normalMat);
|
||||
|
||||
glUniformMatrix4fv(m_uniforms.normalMatrix, 1, GL_TRUE, glm::value_ptr(normalMat));
|
||||
}
|
||||
else if (type == TRANSFORM_VIEW)
|
||||
{
|
||||
Math::Matrix scale = glm::mat4(1.0f);
|
||||
glm::mat4 scale = glm::mat4(1.0f);
|
||||
scale[2][2] = -1.0f;
|
||||
m_viewMat = scale * matrix;
|
||||
|
||||
|
@ -619,7 +619,7 @@ void CGL33Device::SetTransform(TransformType type, const Math::Matrix &matrix)
|
|||
}
|
||||
else if (type == TRANSFORM_SHADOW)
|
||||
{
|
||||
Math::Matrix temp = matrix;
|
||||
glm::mat4 temp = matrix;
|
||||
glUniformMatrix4fv(m_uniforms.shadowMatrix, 1, GL_FALSE, glm::value_ptr(temp));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
#include "graphics/opengl/glframebuffer.h"
|
||||
#include "graphics/opengl/glutil.h"
|
||||
|
||||
#include "math/matrix.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
@ -124,7 +122,7 @@ public:
|
|||
|
||||
void Restore() override;
|
||||
|
||||
void SetTransform(TransformType type, const Math::Matrix &matrix) override;
|
||||
void SetTransform(TransformType type, const glm::mat4 &matrix) override;
|
||||
|
||||
void SetMaterial(const Material &material) override;
|
||||
|
||||
|
@ -239,15 +237,15 @@ private:
|
|||
DeviceConfig m_config;
|
||||
|
||||
//! Current world matrix
|
||||
Math::Matrix m_worldMat;
|
||||
glm::mat4 m_worldMat;
|
||||
//! Current view matrix
|
||||
Math::Matrix m_viewMat;
|
||||
glm::mat4 m_viewMat;
|
||||
//! OpenGL modelview matrix = world matrix * view matrix
|
||||
Math::Matrix m_modelviewMat;
|
||||
glm::mat4 m_modelviewMat;
|
||||
//! Current projection matrix
|
||||
Math::Matrix m_projectionMat;
|
||||
glm::mat4 m_projectionMat;
|
||||
//! Combined world-view-projection matrix
|
||||
Math::Matrix m_combinedMatrix;
|
||||
glm::mat4 m_combinedMatrix;
|
||||
//! true means combined matrix is outdated
|
||||
bool m_combinedMatrixOutdated = true;
|
||||
|
||||
|
|
|
@ -6244,7 +6244,7 @@ void CRobotMain::UpdateDebugCrashSpheres()
|
|||
{
|
||||
for (const auto& crashSphere : obj->GetAllCrashSpheres())
|
||||
{
|
||||
m_engine->RenderDebugSphere(crashSphere.sphere, Math::Matrix{}, Gfx::Color{0.0f, 0.0f, 1.0f, 1.0f});
|
||||
m_engine->RenderDebugSphere(crashSphere.sphere, glm::mat4(1.0f), Gfx::Color{0.0f, 0.0f, 1.0f, 1.0f});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,5 +29,4 @@
|
|||
#include "math/func.h"
|
||||
#include "math/geometry.h"
|
||||
#include "math/half.h"
|
||||
#include "math/matrix.h"
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
|
||||
#include "math/const.h"
|
||||
#include "math/func.h"
|
||||
#include "math/matrix.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
@ -263,7 +263,7 @@ inline float RotateAngle(const glm::vec2¢er, const glm::vec2&p1, const glm::
|
|||
* \param at view direction
|
||||
* \param worldUp up vector
|
||||
*/
|
||||
inline void LoadViewMatrix(Math::Matrix &mat, const glm::vec3 &from,
|
||||
inline void LoadViewMatrix(glm::mat4 &mat, const glm::vec3 &from,
|
||||
const glm::vec3 &at, const glm::vec3 &worldUp)
|
||||
{
|
||||
// Get the z basis vector, which points straight ahead. This is the
|
||||
|
@ -332,7 +332,7 @@ inline void LoadViewMatrix(Math::Matrix &mat, const glm::vec3 &from,
|
|||
* \param nearPlane distance to near cut plane
|
||||
* \param farPlane distance to far cut plane
|
||||
*/
|
||||
inline void LoadProjectionMatrix(Math::Matrix &mat, float fov = Math::PI / 2.0f, float aspect = 1.0f,
|
||||
inline void LoadProjectionMatrix(glm::mat4 &mat, float fov = Math::PI / 2.0f, float aspect = 1.0f,
|
||||
float nearPlane = 1.0f, float farPlane = 1000.0f)
|
||||
{
|
||||
assert(fabs(farPlane - nearPlane) >= 0.01f);
|
||||
|
@ -356,7 +356,7 @@ inline void LoadProjectionMatrix(Math::Matrix &mat, float fov = Math::PI / 2.0f,
|
|||
* \param bottom,top coordinates for bottom and top horizontal clipping planes
|
||||
* \param zNear,zFar distance to nearer and farther depth clipping planes
|
||||
*/
|
||||
inline void LoadOrthoProjectionMatrix(Math::Matrix &mat, float left, float right, float bottom, float top,
|
||||
inline void LoadOrthoProjectionMatrix(glm::mat4 &mat, float left, float right, float bottom, float top,
|
||||
float zNear = -1.0f, float zFar = 1.0f)
|
||||
{
|
||||
mat = glm::mat4(1.0f);
|
||||
|
@ -375,7 +375,7 @@ inline void LoadOrthoProjectionMatrix(Math::Matrix &mat, float left, float right
|
|||
* \param mat result matrix
|
||||
* \param trans vector of translation
|
||||
*/
|
||||
inline void LoadTranslationMatrix(Math::Matrix &mat, const glm::vec3 &trans)
|
||||
inline void LoadTranslationMatrix(glm::mat4 &mat, const glm::vec3 &trans)
|
||||
{
|
||||
mat = glm::translate(glm::mat4(1.0f), trans);
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ inline void LoadTranslationMatrix(Math::Matrix &mat, const glm::vec3 &trans)
|
|||
* \param mat result matrix
|
||||
* \param scale vector with scaling factors for X, Y, Z
|
||||
*/
|
||||
inline void LoadScaleMatrix(Math::Matrix &mat, const glm::vec3 &scale)
|
||||
inline void LoadScaleMatrix(glm::mat4 &mat, const glm::vec3 &scale)
|
||||
{
|
||||
mat = glm::scale(glm::mat4(1.0f), scale);
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ inline void LoadScaleMatrix(Math::Matrix &mat, const glm::vec3 &scale)
|
|||
* \param mat result matrix
|
||||
* \param angle angle [radians]
|
||||
*/
|
||||
inline void LoadRotationXMatrix(Math::Matrix &mat, float angle)
|
||||
inline void LoadRotationXMatrix(glm::mat4 &mat, float angle)
|
||||
{
|
||||
mat = glm::mat4(1.0f);
|
||||
|
||||
|
@ -410,7 +410,7 @@ inline void LoadRotationXMatrix(Math::Matrix &mat, float angle)
|
|||
* \param mat result matrix
|
||||
* \param angle angle [radians]
|
||||
*/
|
||||
inline void LoadRotationYMatrix(Math::Matrix &mat, float angle)
|
||||
inline void LoadRotationYMatrix(glm::mat4 &mat, float angle)
|
||||
{
|
||||
mat = glm::mat4(1.0f);
|
||||
|
||||
|
@ -425,7 +425,7 @@ inline void LoadRotationYMatrix(Math::Matrix &mat, float angle)
|
|||
* \param mat result matrix
|
||||
* \param angle angle [radians]
|
||||
*/
|
||||
inline void LoadRotationZMatrix(Math::Matrix &mat, float angle)
|
||||
inline void LoadRotationZMatrix(glm::mat4 &mat, float angle)
|
||||
{
|
||||
mat = glm::mat4(1.0f);
|
||||
|
||||
|
@ -441,7 +441,7 @@ inline void LoadRotationZMatrix(Math::Matrix &mat, float angle)
|
|||
* \param dir axis of rotation
|
||||
* \param angle angle [radians]
|
||||
*/
|
||||
inline void LoadRotationMatrix(Math::Matrix &mat, const glm::vec3 &dir, float angle)
|
||||
inline void LoadRotationMatrix(glm::mat4 &mat, const glm::vec3 &dir, float angle)
|
||||
{
|
||||
float cos = cosf(angle);
|
||||
float sin = sinf(angle);
|
||||
|
@ -463,9 +463,9 @@ inline void LoadRotationMatrix(Math::Matrix &mat, const glm::vec3 &dir, float an
|
|||
}
|
||||
|
||||
//! Calculates the matrix to make three rotations in the order X, Z and Y
|
||||
inline void LoadRotationXZYMatrix(Math::Matrix &mat, const glm::vec3 &angles)
|
||||
inline void LoadRotationXZYMatrix(glm::mat4 &mat, const glm::vec3 &angles)
|
||||
{
|
||||
Math::Matrix temp;
|
||||
glm::mat4 temp;
|
||||
LoadRotationXMatrix(temp, angles.x);
|
||||
|
||||
LoadRotationZMatrix(mat, angles.z);
|
||||
|
@ -476,9 +476,9 @@ inline void LoadRotationXZYMatrix(Math::Matrix &mat, const glm::vec3 &angles)
|
|||
}
|
||||
|
||||
//! Calculates the matrix to make three rotations in the order Z, X and Y
|
||||
inline void LoadRotationZXYMatrix(Math::Matrix &mat, const glm::vec3 &angles)
|
||||
inline void LoadRotationZXYMatrix(glm::mat4 &mat, const glm::vec3 &angles)
|
||||
{
|
||||
Math::Matrix temp;
|
||||
glm::mat4 temp;
|
||||
LoadRotationZMatrix(temp, angles.z);
|
||||
|
||||
LoadRotationXMatrix(mat, angles.x);
|
||||
|
@ -606,11 +606,38 @@ inline glm::vec3 LookatPoint(const glm::vec3 &eye, float angleH, float angleV, f
|
|||
|
||||
//! Transforms the point \a p by matrix \a m
|
||||
/** Is equal to multiplying the matrix by the vector (of course without perspective divide). */
|
||||
inline glm::vec3 Transform(const Math::Matrix &m, const glm::vec3 &p)
|
||||
inline glm::vec3 Transform(const glm::mat4 &m, const glm::vec3 &p)
|
||||
{
|
||||
return glm::vec3(m * glm::vec4(p, 1.0f));
|
||||
}
|
||||
|
||||
|
||||
//! Calculates the result of multiplying m * v
|
||||
/**
|
||||
The multiplication is performed thus:
|
||||
|
||||
\verbatim
|
||||
[ m.m[0 ] m.m[4 ] m.m[8 ] m.m[12] ] [ v.x ]
|
||||
[ m.m[1 ] m.m[5 ] m.m[9 ] m.m[13] ] [ v.y ]
|
||||
[ m.m[2 ] m.m[6 ] m.m[10] m.m[14] ] * [ v.z ]
|
||||
[ m.m[3 ] m.m[7 ] m.m[11] m.m[15] ] [ 1 ]
|
||||
\endverbatim
|
||||
|
||||
The result, a 4x1 vector is then converted to 3x1 by dividing
|
||||
x,y,z coords by the fourth coord (w). */
|
||||
inline glm::vec3 MatrixVectorMultiply(const glm::mat4& m, const glm::vec3& v, bool wDivide = false)
|
||||
{
|
||||
glm::vec4 result = m * glm::vec4(v, 1.0f);
|
||||
|
||||
if (!wDivide)
|
||||
return result;
|
||||
|
||||
if (IsZero(result.w))
|
||||
return glm::vec3(result);
|
||||
|
||||
return glm::vec3(result) / result.w;
|
||||
}
|
||||
|
||||
//! Calculates the projection of the point \a p on a straight line \a a to \a b
|
||||
/**
|
||||
* \param p point to project
|
||||
|
@ -627,11 +654,11 @@ inline glm::vec3 Projection(const glm::vec3 &a, const glm::vec3 &b, const glm::v
|
|||
//! Calculates point of view to look at a center two angles and a distance
|
||||
inline glm::vec3 RotateView(glm::vec3 center, float angleH, float angleV, float dist)
|
||||
{
|
||||
Math::Matrix mat1, mat2;
|
||||
glm::mat4 mat1, mat2;
|
||||
LoadRotationZMatrix(mat1, -angleV);
|
||||
LoadRotationYMatrix(mat2, -angleH);
|
||||
|
||||
Math::Matrix mat = mat2 * mat1;
|
||||
glm::mat4 mat = mat2 * mat1;
|
||||
|
||||
glm::vec3 eye{};
|
||||
eye.x = 0.0f+dist;
|
||||
|
|
|
@ -1,72 +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/matrix.h
|
||||
* \brief Matrix struct and related functions
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "math/const.h"
|
||||
#include "math/func.h"
|
||||
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
|
||||
// Math module namespace
|
||||
namespace Math
|
||||
{
|
||||
|
||||
using Matrix = glm::mat4;
|
||||
|
||||
|
||||
//! Calculates the result of multiplying m * v
|
||||
/**
|
||||
The multiplication is performed thus:
|
||||
|
||||
\verbatim
|
||||
[ m.m[0 ] m.m[4 ] m.m[8 ] m.m[12] ] [ v.x ]
|
||||
[ m.m[1 ] m.m[5 ] m.m[9 ] m.m[13] ] [ v.y ]
|
||||
[ m.m[2 ] m.m[6 ] m.m[10] m.m[14] ] * [ v.z ]
|
||||
[ m.m[3 ] m.m[7 ] m.m[11] m.m[15] ] [ 1 ]
|
||||
\endverbatim
|
||||
|
||||
The result, a 4x1 vector is then converted to 3x1 by dividing
|
||||
x,y,z coords by the fourth coord (w). */
|
||||
inline glm::vec3 MatrixVectorMultiply(const Math::Matrix &m, const glm::vec3 &v, bool wDivide = false)
|
||||
{
|
||||
glm::vec4 result = m * glm::vec4(v, 1.0);
|
||||
|
||||
if (!wDivide)
|
||||
return result;
|
||||
|
||||
if (IsZero(result.w))
|
||||
return glm::vec3(result);
|
||||
|
||||
return glm::vec3(result) / result.w;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Math
|
|
@ -127,8 +127,8 @@ void CAutoDerrick::Init()
|
|||
glm::vec3 CAutoDerrick::GetCargoPos()
|
||||
{
|
||||
glm::vec3 pos = glm::vec3(7.0f, 0.0f, 0.0f);
|
||||
Math::Matrix* mat = m_object->GetWorldMatrix(0);
|
||||
pos = Math::Transform(*mat, pos);
|
||||
glm::mat4 mat = m_object->GetWorldMatrix(0);
|
||||
pos = Math::Transform(mat, pos);
|
||||
m_terrain->AdjustToFloor(pos);
|
||||
return pos;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "level/parser/parserline.h"
|
||||
#include "level/parser/parserparam.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/object_manager.h"
|
||||
#include "object/old_object.h"
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "graphics/engine/particle.h"
|
||||
#include "graphics/engine/water.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "level/parser/parserline.h"
|
||||
#include "level/parser/parserparam.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/object_manager.h"
|
||||
#include "object/old_object.h"
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "level/parser/parserline.h"
|
||||
#include "level/parser/parserparam.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/object_manager.h"
|
||||
#include "object/old_object.h"
|
||||
|
||||
|
|
|
@ -339,7 +339,6 @@ Error CAutoTower::GetError()
|
|||
|
||||
void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
|
||||
{
|
||||
Math::Matrix* mat;
|
||||
glm::vec3 pos, speed;
|
||||
glm::vec2 dim;
|
||||
int i;
|
||||
|
@ -365,7 +364,7 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
|
|||
return;
|
||||
}
|
||||
|
||||
mat = m_object->GetWorldMatrix(0);
|
||||
glm::mat4 mat = m_object->GetWorldMatrix(0);
|
||||
|
||||
speed = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
dim.x = 2.0f;
|
||||
|
@ -388,7 +387,7 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
|
|||
pos.x = listpos[i*2+0];
|
||||
pos.y = 18.0f;
|
||||
pos.z = listpos[i*2+1];
|
||||
pos = Transform(*mat, pos);
|
||||
pos = Math::Transform(mat, pos);
|
||||
|
||||
m_partiStop[i] = m_particle->CreateParticle(pos, speed,
|
||||
dim, Gfx::PARTISELR,
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "level/parser/parserline.h"
|
||||
#include "level/parser/parserparam.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "graphics/engine/oldmodelmanager.h"
|
||||
#include "graphics/engine/particle.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
|
||||
#include "object/subclass/base_alien.h"
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "graphics/engine/oldmodelmanager.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "graphics/engine/oldmodelmanager.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "graphics/engine/oldmodelmanager.h"
|
||||
#include "graphics/engine/particle.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
|
||||
#include "object/subclass/base_alien.h"
|
||||
|
|
|
@ -1719,7 +1719,6 @@ bool CMotionVehicle::EventFrame(const Event &event)
|
|||
|
||||
bool CMotionVehicle::EventFrameFly(const Event &event)
|
||||
{
|
||||
Math::Matrix* mat;
|
||||
glm::vec3 pos, angle, paw[3];
|
||||
float hope[3], actual, final, h, a;
|
||||
int i;
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "level/parser/parserline.h"
|
||||
#include "level/parser/parserparam.h"
|
||||
|
||||
#include "math/const.h"
|
||||
|
||||
#include "script/scriptfunc.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
|
|
@ -1182,11 +1182,11 @@ CObjectUPtr CObjectFactory::CreateTeen(const ObjectCreateParams& params)
|
|||
obj->SetRotationY(angle);
|
||||
obj->SetFloorHeight(0.0f);
|
||||
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(0);
|
||||
pos = Math::Transform(*mat, glm::vec3(-56.0f, 22.0f, 0.0f));
|
||||
glm::mat4 mat = obj->GetWorldMatrix(0);
|
||||
pos = Math::Transform(mat, glm::vec3(-56.0f, 22.0f, 0.0f));
|
||||
m_particle->CreateParticle(pos, glm::vec3(0.0f, 0.0f, 0.0f), { 20.0f, 20.0f }, Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
|
||||
|
||||
pos = Math::Transform(*mat, glm::vec3(-65.0f, 40.0f, 0.0f));
|
||||
pos = Math::Transform(mat, glm::vec3(-65.0f, 40.0f, 0.0f));
|
||||
Gfx::Color color;
|
||||
color.r = 4.0f;
|
||||
color.g = 2.0f;
|
||||
|
@ -1444,11 +1444,11 @@ CObjectUPtr CObjectFactory::CreateTeen(const ObjectCreateParams& params)
|
|||
obj->SetRotationY(angle);
|
||||
obj->SetFloorHeight(0.0f);
|
||||
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(0);
|
||||
pos = Math::Transform(*mat, glm::vec3(0.0f, 50.0f, 0.0f));
|
||||
glm::mat4 mat = obj->GetWorldMatrix(0);
|
||||
pos = Math::Transform(mat, glm::vec3(0.0f, 50.0f, 0.0f));
|
||||
m_particle->CreateParticle(pos, glm::vec3(0.0f, 0.0f, 0.0f), { 100.0f, 100.0f }, Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
|
||||
|
||||
pos = Math::Transform(*mat, glm::vec3(0.0f, 50.0f, 0.0f));
|
||||
pos = Math::Transform(mat, glm::vec3(0.0f, 50.0f, 0.0f));
|
||||
Gfx::Color color;
|
||||
color.r = 4.0f;
|
||||
color.g = 2.0f;
|
||||
|
|
|
@ -1720,12 +1720,12 @@ void COldObject::SetTransporterPart(int part)
|
|||
|
||||
// Returns matrices of an object portion.
|
||||
|
||||
Math::Matrix COldObject::GetRotateMatrix(int part)
|
||||
glm::mat4 COldObject::GetRotateMatrix(int part)
|
||||
{
|
||||
return m_objectPart[part].matRotate;
|
||||
}
|
||||
|
||||
Math::Matrix COldObject::GetWorldMatrix(int part)
|
||||
glm::mat4 COldObject::GetWorldMatrix(int part)
|
||||
{
|
||||
if ( m_objectPart[0].bTranslate ||
|
||||
m_objectPart[0].bRotate )
|
||||
|
|
|
@ -64,10 +64,10 @@ struct ObjectPart
|
|||
bool bTranslate = false;
|
||||
bool bRotate = false;
|
||||
bool bZoom = false;
|
||||
Math::Matrix matTranslate;
|
||||
Math::Matrix matRotate;
|
||||
Math::Matrix matTransform;
|
||||
Math::Matrix matWorld;
|
||||
glm::mat4 matTranslate;
|
||||
glm::mat4 matRotate;
|
||||
glm::mat4 matTransform;
|
||||
glm::mat4 matWorld;
|
||||
};
|
||||
|
||||
namespace Ui
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "level/parser/parserline.h"
|
||||
#include "level/parser/parserparam.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/object_create_params.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
|
|
@ -95,13 +95,13 @@ void CStaticObject::Write(CLevelParserLine* line)
|
|||
|
||||
void CStaticObject::TransformCrashSphere(Math::Sphere& crashSphere)
|
||||
{
|
||||
Math::Matrix worldMatrix = m_engine->GetStaticMeshWorldMatrix(m_meshHandle);
|
||||
glm::mat4 worldMatrix = m_engine->GetStaticMeshWorldMatrix(m_meshHandle);
|
||||
Math::Transform(worldMatrix, crashSphere.pos);
|
||||
}
|
||||
|
||||
void CStaticObject::TransformCameraCollisionSphere(Math::Sphere& collisionSphere)
|
||||
{
|
||||
Math::Matrix worldMatrix = m_engine->GetStaticMeshWorldMatrix(m_meshHandle);
|
||||
glm::mat4 worldMatrix = m_engine->GetStaticMeshWorldMatrix(m_meshHandle);
|
||||
Math::Transform(worldMatrix, collisionSphere.pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,6 @@ Error CTaskFireAnt::Start(glm::vec3 impact)
|
|||
|
||||
Error CTaskFireAnt::IsEnded()
|
||||
{
|
||||
Math::Matrix* mat;
|
||||
glm::vec3 pos, speed;
|
||||
glm::vec2 dim;
|
||||
float angle, dist;
|
||||
|
@ -169,8 +168,8 @@ Error CTaskFireAnt::IsEnded()
|
|||
for ( i=0 ; i<20 ; i++ )
|
||||
{
|
||||
pos = glm::vec3(-2.5f, -0.7f, 0.0f);
|
||||
mat = m_object->GetWorldMatrix(2);
|
||||
pos = Math::Transform(*mat, pos);
|
||||
glm::mat4 mat = m_object->GetWorldMatrix(2);
|
||||
pos = Math::Transform(mat, pos);
|
||||
dist = glm::distance(pos, m_impact);
|
||||
speed = m_impact-pos;
|
||||
speed.x += (Math::Rand()-0.5f)*dist*1.2f;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "object/task/taskgungoal.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
|
|
|
@ -134,7 +134,6 @@ bool CTaskPen::EventProcess(const Event &event)
|
|||
Error CTaskPen::Start(bool bDown, TraceColor color)
|
||||
{
|
||||
glm::vec3 pos;
|
||||
Math::Matrix* mat;
|
||||
ObjectType type;
|
||||
int i;
|
||||
|
||||
|
@ -179,9 +178,9 @@ Error CTaskPen::Start(bool bDown, TraceColor color)
|
|||
m_timeDown = 0.0f;
|
||||
}
|
||||
|
||||
mat = m_object->GetWorldMatrix(0);
|
||||
glm::mat4 mat = m_object->GetWorldMatrix(0);
|
||||
pos = glm::vec3(-3.0f, 7.0f, 0.0f);
|
||||
pos = Math::Transform(*mat, pos); // position of carousel
|
||||
pos = Math::Transform(mat, pos); // position of carousel
|
||||
m_supportPos = pos;
|
||||
|
||||
m_phase = TPP_UP;
|
||||
|
|
|
@ -70,7 +70,6 @@ CTaskShield::~CTaskShield()
|
|||
|
||||
bool CTaskShield::EventProcess(const Event &event)
|
||||
{
|
||||
Math::Matrix matrix;
|
||||
glm::vec3 pos, speed, goal, angle;
|
||||
Gfx::Color color;
|
||||
glm::vec2 dim;
|
||||
|
@ -178,6 +177,7 @@ bool CTaskShield::EventProcess(const Event &event)
|
|||
angle.x = (Math::Rand()-0.5f)*Math::PI*1.2f;
|
||||
angle.y = 0.0f;
|
||||
angle.z = (Math::Rand()-0.5f)*Math::PI*1.2f;
|
||||
glm::mat4 matrix;
|
||||
Math::LoadRotationXZYMatrix(matrix, angle);
|
||||
goal = Math::Transform(matrix, glm::vec3(0.0f, GetRadius()-dim.x, 0.0f));
|
||||
goal += pos;
|
||||
|
|
|
@ -1441,7 +1441,7 @@ void CPhysics::UpdateMotionStruct(float rTime, Motion &motion)
|
|||
bool CPhysics::EventFrame(const Event &event)
|
||||
{
|
||||
ObjectType type;
|
||||
Math::Matrix objRotate, matRotate;
|
||||
glm::mat4 objRotate, matRotate;
|
||||
glm::vec3 iPos{ 0, 0, 0 }, iAngle{ 0, 0, 0 }, tAngle{ 0, 0, 0 }, pos{ 0, 0, 0 }, newpos{ 0, 0, 0 }, angle{ 0, 0, 0 }, newangle{ 0, 0, 0 }, n{ 0, 0, 0 };
|
||||
float h, w;
|
||||
int i;
|
||||
|
@ -2288,7 +2288,7 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
|
|||
Character* character;
|
||||
ObjectType type;
|
||||
glm::vec3 norm{ 0, 0, 0 };
|
||||
Math::Matrix matRotate;
|
||||
glm::mat4 matRotate;
|
||||
float level, h, f, a1, volume, freq, force;
|
||||
bool bSlopingTerrain;
|
||||
|
||||
|
@ -2498,7 +2498,7 @@ void CPhysics::FloorAngle(const glm::vec3 &pos, glm::vec3 &angle)
|
|||
|
||||
int CPhysics::ObjectAdapt(const glm::vec3 &pos, const glm::vec3 &angle)
|
||||
{
|
||||
Math::Matrix matRotate;
|
||||
glm::mat4 matRotate;
|
||||
glm::vec3 iPos{ 0, 0, 0 }, oAngle{ 0, 0, 0 }, oSpeed{ 0, 0, 0 };
|
||||
float distance, force, volume;
|
||||
int colType;
|
||||
|
|
|
@ -3739,7 +3739,7 @@ void CScriptFunctions::uObject(CBotVar* botThis, void* user)
|
|||
}
|
||||
else
|
||||
{
|
||||
Math::Matrix matRotate;
|
||||
glm::mat4 matRotate;
|
||||
Math::LoadRotationZXYMatrix(matRotate, object->GetRotation());
|
||||
pos = physics->GetLinMotion(MO_CURSPEED);
|
||||
pos = Math::Transform(matRotate, pos);
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "graphics/core/renderers.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
// Object's constructor.
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#include "level/parser/parser.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "script/script.h"
|
||||
|
||||
#include "ui/controls/scroll.h"
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "graphics/core/device.h"
|
||||
#include "graphics/engine/engine.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "graphics/engine/engine.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include "graphics/engine/engine.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace Ui
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "level/player_profile.h"
|
||||
#include "level/robotmain.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include "ui/controls/button.h"
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include "level/robotmain.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include "ui/maindialog.h"
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "graphics/engine/particle.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
namespace UI
|
||||
{
|
||||
CParticlesGenerator::CParticlesGenerator()
|
||||
|
|
|
@ -706,8 +706,8 @@ void CScreenApperance::SetCamera(float x, float y, float cameraDistance)
|
|||
|
||||
glm::vec3 p2D(x, y, cameraDistance);
|
||||
glm::vec3 p3D{};
|
||||
Math::Matrix matView;
|
||||
Math::Matrix matProj = engine->GetMatProj();
|
||||
glm::mat4 matView;
|
||||
glm::mat4 matProj = engine->GetMatProj();
|
||||
|
||||
Math::LoadViewMatrix(matView, glm::vec3(0.0f, 0.0f, -cameraDistance),
|
||||
glm::vec3(0.0f, 0.0f, 0.0f),
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include "graphics/engine/camera.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include "ui/controls/button.h"
|
||||
#include "ui/controls/check.h"
|
||||
#include "ui/controls/editvalue.h"
|
||||
|
|
Loading…
Reference in New Issue