Porting to linux
This commit is contained in:
parent
0da9755ae6
commit
d00448a422
20
.gitignore
vendored
20
.gitignore
vendored
@ -1,28 +1,14 @@
|
||||
# Exclude folders
|
||||
bin/
|
||||
bin-int/
|
||||
int/
|
||||
external/
|
||||
|
||||
# Frequently edited tests
|
||||
Tests/TestProject/
|
||||
|
||||
# CMake Build Files
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
CMakeScripts/
|
||||
Testing/
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps/
|
||||
CMakeUserPresets.json
|
||||
# Premake Build Files
|
||||
build/
|
||||
|
||||
|
||||
# Exclude files
|
||||
Makefile
|
||||
|
||||
# C++
|
||||
# Prerequisites
|
||||
|
18
DevPlayground/premake5.lua
Normal file
18
DevPlayground/premake5.lua
Normal file
@ -0,0 +1,18 @@
|
||||
project "DevPlayground"
|
||||
kind "ConsoleApp"
|
||||
|
||||
boilerplate()
|
||||
|
||||
files {
|
||||
phanesRoot .. "/DevPlayground/**.h",
|
||||
phanesRoot .. "/DevPlayground/**.cpp",
|
||||
}
|
||||
|
||||
-- Linking PhanesCore
|
||||
links { "PhanesCore" }
|
||||
dependson { "PhanesCore" }
|
||||
|
||||
links{"fmt"}
|
||||
dependson {"fmt"}
|
||||
|
||||
includedirs { PhanesRuntime }
|
@ -38,7 +38,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#define FORCEINLINE __attribute__((always_inline))
|
||||
#define FORCEINLINE inline
|
||||
|
||||
#elif defined(P_ARM_BUILD)
|
||||
|
||||
|
11
Engine/Source/Runtime/Core/Logging/premake5.lua
Normal file
11
Engine/Source/Runtime/Core/Logging/premake5.lua
Normal file
@ -0,0 +1,11 @@
|
||||
function includeLogging()
|
||||
files {
|
||||
PhanesRuntime .. "/Core/Logging/**.h",
|
||||
PhanesRuntime .. "/Core/Logging/**.cpp",
|
||||
}
|
||||
|
||||
-- includedirs { PhanesThirdParty .. "/spdlog/include" }
|
||||
|
||||
pchheader (PhanesRuntime .. "/Core/Logging/LoggingPCH.h")
|
||||
pchsource (PhanesRuntime .. "/Core/Logging/private/LoggingPCH.cpp")
|
||||
end
|
@ -0,0 +1 @@
|
||||
#include "Core/Logging/LoggingPCH.h"
|
@ -2,62 +2,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Core/Math/MathPCH.h"
|
||||
|
||||
|
||||
|
||||
#ifdef P_BUILD_LIB
|
||||
#include "PhanesEnginePCH.h"
|
||||
|
||||
#else
|
||||
#include <type_traits>
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef P_WIN_BUILD
|
||||
|
||||
#ifdef P_DEBUG
|
||||
|
||||
#define P_DEBUGBREAK DebugBreak();
|
||||
|
||||
#else
|
||||
|
||||
#define P_DEBUGBREAK
|
||||
|
||||
#endif // P_DEBUG
|
||||
|
||||
#define FORCEINLINE __forceinline
|
||||
|
||||
#elif defined(P_LINUX_BUILD)
|
||||
|
||||
#ifdef P_DEBUG
|
||||
|
||||
#define P_DEBUGBREAK __builtin_trap();
|
||||
|
||||
#else
|
||||
|
||||
#define P_DEBUGBREAK
|
||||
|
||||
#endif // P_DEBUG
|
||||
|
||||
#define FORCEINLINE inline __attribute__((always_inline))
|
||||
|
||||
#elif defined(P_ARM_BUILD)
|
||||
|
||||
#error Only Windows is supported at the moment.
|
||||
|
||||
#else
|
||||
|
||||
#error The target system must be defined. (See https://github.com/scorpioblood/PhanesEngine for more information)
|
||||
|
||||
#endif // P_WIN_BUILD
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "Core/Core.h"
|
||||
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
@ -74,28 +21,4 @@ namespace Phanes::Core::Math
|
||||
// Typenames with Arithmethic constrain have to be number.
|
||||
template<typename T>
|
||||
concept Arithmethic = std::is_arithmetic_v<T>;
|
||||
|
||||
|
||||
|
||||
// Alias for shared_ptr
|
||||
template<typename T>
|
||||
using Ref = std::shared_ptr<T>;
|
||||
|
||||
// Alias for make_shared
|
||||
template<typename T, typename ...Args>
|
||||
constexpr Ref<T> MakeRef(Args&& ...args)
|
||||
{
|
||||
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// Alias for unique ptr
|
||||
template<typename T>
|
||||
using Scope = std::unique_ptr<T>;
|
||||
|
||||
// Alias for make_unique
|
||||
template<typename T, typename ...Args>
|
||||
constexpr Scope<T> MakeScope(Args&& ...args)
|
||||
{
|
||||
return std::make_unique<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
@ -46,6 +46,7 @@ namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
static constexpr bool map(Phanes::Core::Math::TMatrix4<T, false>& r, const Phanes::Core::Math::TMatrix4<T, false>& m)
|
||||
{
|
||||
|
||||
const TVector3<T, false>& a = reinterpret_cast<const TVector3<T, false>&>(m[0]);
|
||||
const TVector3<T, false>& b = reinterpret_cast<const TVector3<T, false>&>(m[1]);
|
||||
const TVector3<T, false>& c = reinterpret_cast<const TVector3<T, false>&>(m[2]);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
|
||||
namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
@ -259,7 +260,7 @@ namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
static constexpr T map(const Phanes::Core::Math::TVector3<T, false>& v1)
|
||||
{
|
||||
return sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
|
||||
return Phanes::Core::Math::Sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
|
||||
|
@ -9,11 +9,6 @@
|
||||
#include "Core/Math/IntVector2.hpp"
|
||||
#include "Core/Math/IntVector3.hpp"
|
||||
#include "Core/Math/IntVector4.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* General annonation: The Point is the same as a vector. The type exists, to ensure a
|
||||
* easy differentiation between the two.
|
||||
|
@ -7,10 +7,6 @@
|
||||
|
||||
#include "Core/Math/SIMD/Storage.h"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Note: Some function are deleted, because, their unusable with int types, except very specific cases.
|
||||
* To keep the library verbose, these functions are explicitly marked as deleted.
|
||||
|
@ -9,11 +9,6 @@
|
||||
|
||||
#include "Core/Math/IntVector4.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef INTVECTOR3_H
|
||||
#define INTVECTOR3_H
|
||||
|
||||
|
@ -9,10 +9,6 @@
|
||||
|
||||
#include "Core/Math/IntVector2.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef INTVECTOR4_H
|
||||
#define INTVECTOR4_H
|
||||
|
@ -47,8 +47,6 @@ namespace Phanes::Core::Math
|
||||
template<RealType T>
|
||||
TLine<T>& NormalizeV(TLine<T>& l1)
|
||||
{
|
||||
std::any
|
||||
|
||||
NormalizeV(l1.direction);
|
||||
return l1;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/Math/MathPCH.h"
|
||||
|
||||
#define P_FLT_INAC_LARGE 0.0001f // large float inaccuracy (1*10^-4);
|
||||
#define P_FLT_INAC 0.00001f // float inaccuracy (1*10^-5);
|
||||
#define P_FLT_INAC_SMALL 0.000001f // small float inaccuracy (1*10^-6);
|
||||
@ -131,6 +133,12 @@ namespace Phanes::Core::Math {
|
||||
return abs(s);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T Sqrt(T s)
|
||||
{
|
||||
return sqrt(s);
|
||||
}
|
||||
|
||||
|
||||
} // phanes
|
||||
|
||||
|
@ -1,27 +1,10 @@
|
||||
// Header file containing all files to be compiled to use core math.
|
||||
// Should be included in PCH file of project to use.
|
||||
// PCH for STL. This is a precompiled header file for the Standard Template Library used in math.
|
||||
// For a PCH for this submodule see PhanesMathPCH.h
|
||||
|
||||
#pragma once
|
||||
#define NOMINMAX
|
||||
|
||||
#include "Core/Math/Point.hpp"
|
||||
#include "Core/Math/Plane.hpp"
|
||||
#include "Core/Math/Line.hpp"
|
||||
#include "Core/Math/Ray.hpp"
|
||||
|
||||
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
#include "Core/Math/Vector4.hpp"
|
||||
|
||||
#include "Core/Math/IntPoint.hpp"
|
||||
#include "Core/Math/IntVector2.hpp"
|
||||
#include "Core/Math/IntVector3.hpp"
|
||||
#include "Core/Math/IntVector4.hpp"
|
||||
|
||||
#include "Core/Math/Matrix2.hpp"
|
||||
#include "Core/Math/Matrix3.hpp"
|
||||
#include "Core/Math/Matrix4.hpp"
|
||||
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathTypeConversion.hpp"
|
||||
#include "Core/Math/MathUnitConversion.hpp"
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
@ -6,13 +6,9 @@
|
||||
// @ref [FILE]MathUnitConversion //
|
||||
// ============================================= //
|
||||
|
||||
#ifdef P_BUILD_LIB
|
||||
#include "PhanesEnginePCH.h"
|
||||
#else
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathPCH.h"
|
||||
|
||||
#include "Core/Math/MathAbstractTypes.h"
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
|
@ -1,11 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef P_BUILD_LIB
|
||||
# include "PhanesEnginePCH.h"
|
||||
#else
|
||||
# define NOMINMAX
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#include "Core/Math/MathPCH.h"
|
||||
|
||||
// ============================================= //
|
||||
// Turn os specific types into global types. //
|
||||
@ -23,6 +18,12 @@ namespace Phanes::Core::Types
|
||||
|
||||
typedef _FLOAT128 float128;
|
||||
|
||||
#elif defined(P_LINUX_BUILD)
|
||||
|
||||
// Linux specific types
|
||||
|
||||
typedef __float128 float128;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -123,7 +123,7 @@ namespace Phanes::Core::Math {
|
||||
}
|
||||
FORCEINLINE TVector4<T, S>& operator[] (int m)
|
||||
{
|
||||
return (*reinterpret_cast<TVector4<T, S>*>(this->m[m]));
|
||||
return (*reinterpret_cast<TVector4<T, S>*>(this->data[m]));
|
||||
}
|
||||
|
||||
FORCEINLINE const T& operator() (int n, int m) const
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
{
|
||||
|
27
Engine/Source/Runtime/Core/Math/PhanesMathPCH.h
Normal file
27
Engine/Source/Runtime/Core/Math/PhanesMathPCH.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Header file containing all files to be compiled to use core math.
|
||||
// Should be included in PCH file of project to use.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Core/Math/Point.hpp"
|
||||
#include "Core/Math/Plane.hpp"
|
||||
#include "Core/Math/Line.hpp"
|
||||
#include "Core/Math/Ray.hpp"
|
||||
|
||||
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
#include "Core/Math/Vector4.hpp"
|
||||
|
||||
#include "Core/Math/IntPoint.hpp"
|
||||
#include "Core/Math/IntVector2.hpp"
|
||||
#include "Core/Math/IntVector3.hpp"
|
||||
#include "Core/Math/IntVector4.hpp"
|
||||
|
||||
#include "Core/Math/Matrix2.hpp"
|
||||
#include "Core/Math/Matrix3.hpp"
|
||||
#include "Core/Math/Matrix4.hpp"
|
||||
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathTypeConversion.hpp"
|
||||
#include "Core/Math/MathUnitConversion.hpp"
|
@ -624,7 +624,7 @@ namespace Phanes::Core::Math {
|
||||
TPlane<T, false> TranslateV(TPlane<T, false>& pl1, const TVector3<T, false>& v1)
|
||||
{
|
||||
|
||||
pl1.d = DotP(this->normal, GetOrigin(pl1) + v1);
|
||||
pl1.d = DotP(pl1.normal, GetOrigin(pl1) + v1);
|
||||
|
||||
return pl1;
|
||||
}
|
||||
|
@ -9,10 +9,6 @@
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The Point is the same as a vector. The type exists, to ensure
|
||||
* differentiation between the two types.
|
||||
@ -46,6 +42,14 @@ namespace Phanes::Core::Math {
|
||||
this->y = p.y;
|
||||
}
|
||||
|
||||
/// @brief Creates Point2 from Vector2
|
||||
/// @param v
|
||||
TPoint2(const TVector2<T, false>& v)
|
||||
{
|
||||
this->x = v.x;
|
||||
this->y = v.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Point2 from Point4's xy
|
||||
*
|
||||
@ -102,6 +106,15 @@ namespace Phanes::Core::Math {
|
||||
this->z = 0;
|
||||
}
|
||||
|
||||
/// @brief Creates Point3 from Vector3
|
||||
/// @param v
|
||||
TPoint3(const TVector3<T, false>& v)
|
||||
{
|
||||
this->x = v.x;
|
||||
this->y = v.y;
|
||||
this->z = v.z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Point3 from Point4's xyz
|
||||
*
|
||||
@ -171,8 +184,17 @@ namespace Phanes::Core::Math {
|
||||
this->z = p.z;
|
||||
this->w = 0;
|
||||
}
|
||||
|
||||
TPoint4(const TVector4<T, false>& v)
|
||||
{
|
||||
this->x = v.x;
|
||||
this->y = v.y;
|
||||
this->z = v.z;
|
||||
this->w = v.w;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Calculates distance between two points.
|
||||
*
|
||||
|
@ -207,7 +207,6 @@
|
||||
|
||||
// G++
|
||||
#elif defined(__GNUC__) || defined(__MINGW32__)
|
||||
# error PhanesEngine only supports MSVC -> Visual Studio
|
||||
# if __GNUC__ >= 14
|
||||
# define P_COMPILER P_COMPILER_GCC14
|
||||
# elif __GNUC__ >= 13
|
||||
@ -312,7 +311,6 @@
|
||||
# define P_AVX2__ 0
|
||||
# define P_AVX__ 0
|
||||
# define P_SSE__ 0
|
||||
# define P_SSE__ 0
|
||||
#else
|
||||
# if (P_AVX__ == 1) && (P_AVX2__ == 0)
|
||||
# define P_INTRINSICS P_INTRINSICS_AVX
|
||||
|
@ -7,21 +7,15 @@
|
||||
|
||||
#include "Core/Math/SIMD/Storage.h"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
#pragma warning(disable: 4661)
|
||||
|
||||
#ifndef VECTOR2_H
|
||||
#define VECTOR2_H
|
||||
|
||||
|
||||
#define PZeroVector2(type, aligned) Phanes::Core::Math::TVector2<##type, ##aligned>(0,0)
|
||||
#define PVectorSouth2(type, aligned) Phanes::Core::Math::TVector2<##type, ##aligned>(0,-1)
|
||||
#define PVectorNorth2(type, aligned) Phanes::Core::Math::TVector2<##type, ##aligned>(0,1)
|
||||
#define PVectorEast2(type, aligned) Phanes::Core::Math::TVector2<##type, ##aligned>(1,0)
|
||||
#define PVectorWest2(type, aligned) Phanes::Core::Math::TVector2<##type, ##aligned>(-1,0)
|
||||
#define PZeroVector2(type, aligned) Phanes::Core::Math::TVector2<type, aligned>(0,0)
|
||||
#define PVectorSouth2(type, aligned) Phanes::Core::Math::TVector2<type, aligned>(0,-1)
|
||||
#define PVectorNorth2(type, aligned) Phanes::Core::Math::TVector2<type, aligned>(0,1)
|
||||
#define PVectorEast2(type, aligned) Phanes::Core::Math::TVector2<type, aligned>(1,0)
|
||||
#define PVectorWest2(type, aligned) Phanes::Core::Math::TVector2<type, aligned>(-1,0)
|
||||
|
||||
namespace Phanes::Core::Math {
|
||||
|
||||
@ -466,6 +460,12 @@ namespace Phanes::Core::Math {
|
||||
return v1;
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
T Distance(const TVector2<T, S>& v1, const TVector2<T, S>& v2)
|
||||
{
|
||||
return Magnitude(v2 - v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds a vector to a square with a radius
|
||||
*
|
||||
|
@ -11,20 +11,16 @@
|
||||
|
||||
#include "Core/Math/Vector4.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
#ifndef VECTOR3_H
|
||||
#define VECTOR3_H
|
||||
|
||||
#define PZeroVector3(type, aligned) Phanes::Core::Math::TVector3<##type, ##aligned>(0,0,0)
|
||||
#define PVectorForward3(type, aligned) Phanes::Core::Math::TVector3<##type, ##aligned>(1,0,0)
|
||||
#define PVectorBackward3(type, aligned) Phanes::Core::Math::TVector3<##type, ##aligned>(-1,0,0)
|
||||
#define PVectorEast3(type, aligned) Phanes::Core::Math::TVector3<##type, ##aligned>(0,1,0)
|
||||
#define PVectorWest3(type, aligned) Phanes::Core::Math::TVector3<##type, ##aligned>(0,-1,0)
|
||||
#define PVectorUp3(type, aligned) Phanes::Core::Math::TVector3<##type, ##aligned>(0,0,1)
|
||||
#define PVectorDown3(type, aligned) Phanes::Core::Math::TVector3<##type, ##aligned>(0,0,-1)
|
||||
#define PZeroVector3(type, aligned) Phanes::Core::Math::TVector3<type, aligned>(0,0,0)
|
||||
#define PVectorForward3(type, aligned) Phanes::Core::Math::TVector3<type, aligned>(1,0,0)
|
||||
#define PVectorBackward3(type, aligned) Phanes::Core::Math::TVector3<type, aligned>(-1,0,0)
|
||||
#define PVectorEast3(type, aligned) Phanes::Core::Math::TVector3<type, aligned>(0,1,0)
|
||||
#define PVectorWest3(type, aligned) Phanes::Core::Math::TVector3<type, aligned>(0,-1,0)
|
||||
#define PVectorUp3(type, aligned) Phanes::Core::Math::TVector3<type, aligned>(0,0,1)
|
||||
#define PVectorDown3(type, aligned) Phanes::Core::Math::TVector3<type, aligned>(0,0,-1)
|
||||
|
||||
namespace Phanes::Core::Math {
|
||||
|
||||
@ -413,6 +409,46 @@ namespace Phanes::Core::Math {
|
||||
return v1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Refracts a vector
|
||||
*
|
||||
* @param(v1) Vector one
|
||||
* @param(normal) Normal of surface
|
||||
* @param(eta) Refraction index
|
||||
*/
|
||||
template<RealType T, bool S>
|
||||
TVector3<T, S>& RefractV(TVector3<T, S>& v1, const TVector3<T, S>& normal, T eta)
|
||||
{
|
||||
T dot = DotP(v1, normal);
|
||||
T k = 1.0f - eta * eta * (1.0f - dot * dot);
|
||||
|
||||
if (k < 0.0f)
|
||||
{
|
||||
v1 = PZeroVector3(T, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
v1 = eta * v1 - (eta * dot + sqrt(k)) * normal;
|
||||
}
|
||||
|
||||
return v1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets distance between two vectors
|
||||
*
|
||||
* @param(v1) Vector one
|
||||
* @param(v2) Vector two
|
||||
*
|
||||
* @return Distance between vectors
|
||||
*/
|
||||
template<RealType T, bool S>
|
||||
T Distance(const TVector3<T, S>& v1, const TVector3<T, S>& v2)
|
||||
{
|
||||
return Magnitude(v2 - v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets angle between two vectors
|
||||
*
|
||||
@ -920,6 +956,31 @@ namespace Phanes::Core::Math {
|
||||
return (2 * DotP(v1, normal) * normal) - v1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refracts a vector
|
||||
*
|
||||
* @param (v1) Vector one
|
||||
* @param (normal) Normal of surface
|
||||
* @param (eta) Refraction index
|
||||
*
|
||||
* @return Refracted vector
|
||||
*/
|
||||
template<RealType T, bool S>
|
||||
TVector3<T, S> Refract(const TVector3<T, S>& v1, const TVector3<T, S>& normal, T eta)
|
||||
{
|
||||
T dot = DotP(v1, normal);
|
||||
T k = 1.0f - eta * eta * (1.0f - dot * dot);
|
||||
|
||||
if (k < 0.0f)
|
||||
{
|
||||
return PZeroVector3(T, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return eta * v1 - (eta * dot + sqrt(k)) * normal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performes perspective divide on vector.
|
||||
|
@ -10,7 +10,9 @@
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
|
||||
#define PZeroVector4(type, aligned) Phanes::Core::Math::TVector4<##type, ##aligned>(0,0,0,0)
|
||||
|
||||
|
||||
#define PZeroVector4(type, aligned) Phanes::Core::Math::TVector4<type, aligned>(0,0,0,0)
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
{
|
||||
@ -741,6 +743,12 @@ namespace Phanes::Core::Math
|
||||
return v1;
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
T Distance(const TVector4<T, S>& v1, const TVector4<T, S>& v2)
|
||||
{
|
||||
return Magnitude(v1 - v2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project vector v1 onto v2.
|
||||
/// </summary>
|
||||
@ -863,5 +871,4 @@ namespace Phanes::Core::Math
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "Core/Math/Vector4.inl"
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "Core/Math/Detail/Vector4Decl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
|
1
Engine/Source/Runtime/Core/Math/private/MathPCH.cpp
Normal file
1
Engine/Source/Runtime/Core/Math/private/MathPCH.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "Core/Math/MathPCH.h"
|
@ -0,0 +1 @@
|
||||
#include "Core/Math/PhanesMathPCH.h"
|
@ -3,21 +3,6 @@
|
||||
|
||||
#if defined(P_LINUX_BUILD)
|
||||
|
||||
extern Phanes::Core::Application::PhanesProject* Phanes::Core::Application::CreatePhanesGame();
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Phanes::Core::Logging::Logger::Init();
|
||||
PENGINE_LOG_INFO("Logger initialized!");
|
||||
PENGINE_LOG_INFO("Welcome to PhanesEngine!");
|
||||
|
||||
auto phanes_game = Phanes::Core::Application::CreatePhanesGame();
|
||||
|
||||
phanes_game->Run();
|
||||
|
||||
delete phanes_game;
|
||||
|
||||
return 0;
|
||||
}
|
||||
int main();
|
||||
|
||||
#endif
|
9
Engine/Source/Runtime/Core/StartingPoint/premake5.lua
Normal file
9
Engine/Source/Runtime/Core/StartingPoint/premake5.lua
Normal file
@ -0,0 +1,9 @@
|
||||
function includeStartingPoint()
|
||||
files {
|
||||
PhanesRuntime .. "/Core/StartingPoint/**.h",
|
||||
PhanesRuntime .. "/Core/StartingPoint/**.cpp",
|
||||
}
|
||||
|
||||
pchheader (PhanesRuntime .. "/Core/StartingPoint/StartingPointPCH.h")
|
||||
pchsource (PhanesRuntime .. "/Core/StartingPoint/private/StartingPointPCH.cpp")
|
||||
end
|
@ -0,0 +1,22 @@
|
||||
#include "Core/Include.h"
|
||||
|
||||
#if defined(P_LINUX_BUILD)
|
||||
|
||||
extern Phanes::Core::Application::PhanesProject* Phanes::Core::Application::CreatePhanesGame();
|
||||
|
||||
int main()
|
||||
{
|
||||
Phanes::Core::Logging::Logger::Init();
|
||||
PENGINE_LOG_INFO("Logger initialized!");
|
||||
PENGINE_LOG_INFO("Welcome to PhanesEngine!");
|
||||
|
||||
auto phanes_game = Phanes::Core::Application::CreatePhanesGame();
|
||||
|
||||
phanes_game->Run();
|
||||
|
||||
delete phanes_game;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1 @@
|
||||
#include "Core/StartingPoint/StartingPointPCH.h"
|
17
Engine/Source/Runtime/Core/premake5.lua
Normal file
17
Engine/Source/Runtime/Core/premake5.lua
Normal file
@ -0,0 +1,17 @@
|
||||
include (PhanesRuntime .. "/Core/StartingPoint/premake5.lua")
|
||||
include (PhanesRuntime .. "/Core/Logging/premake5.lua")
|
||||
|
||||
|
||||
project "PhanesCore"
|
||||
kind "StaticLib"
|
||||
|
||||
boilerplate()
|
||||
|
||||
files {
|
||||
PhanesRuntime .. "/Core/Core.h"
|
||||
}
|
||||
|
||||
includedirs { PhanesRuntime }
|
||||
|
||||
includeStartingPoint()
|
||||
includeLogging()
|
@ -1,12 +1,21 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "Core/Math/Include.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Phanes::Core::Math::Vector3 v1(1.0f, 2.0f, 3.0f);
|
||||
Phanes::Core::Math::Vector3 v2(1.0f, 2.0f, 3.0f);
|
||||
namespace PMath = Phanes::Core::Math;
|
||||
|
||||
Phanes::Core::Math::Vector3 v3 = v1 + v2;
|
||||
int main()
|
||||
{
|
||||
PMath::Matrix4 m0 = PMath::Matrix4(1.0f, 5.0f, 3.0f, 4.0f,
|
||||
2.0f, 6.0f, 4.0f, 1.0f,
|
||||
2.0f, -3.0f, 5.0f, 3.0f,
|
||||
8.0f, -4.0f, 6.0f, -2.0f);
|
||||
|
||||
std::cout << "v3: " << Phanes::Core::Math::ToString(v3) << std::endl;
|
||||
|
||||
PMath::Matrix4 m2;
|
||||
|
||||
std::cout << std::to_string(PMath::InverseV<float, false>(m0)) << std::endl;
|
||||
|
||||
std::cout << PMath::ToString(m0) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
2
MathTestFPU/pch.cpp
Normal file
2
MathTestFPU/pch.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include "pch.h"
|
||||
|
29
MathTestFPU/premake5.lua
Normal file
29
MathTestFPU/premake5.lua
Normal file
@ -0,0 +1,29 @@
|
||||
project "MathTestFPU"
|
||||
kind "ConsoleApp"
|
||||
boilerplate()
|
||||
|
||||
files {
|
||||
phanesRoot .. "/MathTestFPU/test.cpp"
|
||||
}
|
||||
|
||||
buildoptions {"-Wno-unused-variable", "-w", "-fpermissive"}
|
||||
|
||||
pchheader "pch.h"
|
||||
pchsource "pch.cpp"
|
||||
|
||||
includedirs {
|
||||
phanesRoot .. "/MathTestFPU",
|
||||
PhanesRuntime
|
||||
}
|
||||
|
||||
project "Test"
|
||||
kind "ConsoleApp"
|
||||
boilerplate()
|
||||
|
||||
files {
|
||||
phanesRoot .. "/MathTestFPU/main.cpp"
|
||||
}
|
||||
|
||||
includedirs {
|
||||
PhanesRuntime
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "Core/public/Math/Include.h"
|
||||
#include "Core/Math/Include.h"
|
||||
|
||||
#include "Core/Core.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-fpermissive"
|
||||
|
||||
namespace PMath = Phanes::Core::Math;
|
||||
using namespace Phanes::Core::Math::UnitLiterals;
|
||||
|
||||
@ -1263,7 +1266,7 @@ namespace Plane
|
||||
TEST(Plane, OperatorTests)
|
||||
{
|
||||
PMath::Plane pl1(3.0f / 5.4772255750f, -2.0f / 5.4772255750f, -3.0f / 5.4772255750f, 4.0f);
|
||||
PMath::Plane pl2(-0.526316f, -0.442105f, -0.726316f, 6.0f);
|
||||
PMath::Plane pl2 = PMath::Plane(-0.526316f, -0.442105f, -0.726316f, 6.0f);
|
||||
|
||||
}
|
||||
}
|
102
premake5.lua
102
premake5.lua
@ -1,2 +1,102 @@
|
||||
-- Phanes build configuration
|
||||
VERSION = "1.0.0"
|
||||
|
||||
-- Override with specific platform if necessary
|
||||
PLATFORM = os.target()
|
||||
|
||||
-- architecture.
|
||||
ARCH = "x86_64"
|
||||
|
||||
-- SSE options:
|
||||
-- SSE4: SSE
|
||||
-- AVX: AVX
|
||||
-- AVX2: AVX2
|
||||
-- No SSE: FPU
|
||||
-- None: Automatically detect SSE during build
|
||||
SSE = "None"
|
||||
|
||||
|
||||
phanesRoot = path.getabsolute(".")
|
||||
phanesBin = path.join(phanesRoot, "bin")
|
||||
phanesInt = path.join(phanesRoot, ".int")
|
||||
phanesBuildFiles = path.join(phanesRoot, "build")
|
||||
|
||||
PhanesEngine = path.join(phanesRoot, "Engine")
|
||||
PhanesRuntime = path.join(PhanesEngine, "Source/Runtime")
|
||||
PhanesThirdParty = path.join(PhanesEngine, "Source/ThirdParty")
|
||||
|
||||
|
||||
|
||||
workspace "PhanesEngine"
|
||||
configurations { "Debug", "Release" }
|
||||
cppdialect "C++20"
|
||||
architecture (ARCH)
|
||||
toolset "gcc"
|
||||
flags { "MultiProcessorCompile" }
|
||||
clangtidy "On"
|
||||
llvmversion "19.0"
|
||||
configurations { "Debug", "Release" }
|
||||
|
||||
|
||||
function linux_sse()
|
||||
if SSE == "SSE" then
|
||||
defines {"P_SSE__"}
|
||||
buildoptions {"-msse4", "-msse2", "-msse3"}
|
||||
elseif SSE == "AVX" then
|
||||
defines { "P_AVX__" }
|
||||
buildoptions {"-mavx", "-msse4", "-msse2", "-msse3"}
|
||||
elseif SSE == "AVX2" then
|
||||
defines { "P_AVX2__" }
|
||||
buildoptions {"-mavx2", "-mavx", "-msse4", "-msse2", "-msse3"}
|
||||
elseif SSE == "FPU" then
|
||||
defines { "P_FORCE_FPU" }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function boilerplate()
|
||||
language "C++"
|
||||
|
||||
location (phanesBuildFiles .. "/%{prj.name}")
|
||||
targetdir (phanesBin .. "/" .. VERSION .. "/%{cfg.buildcfg}/%{prj.name}")
|
||||
objdir (phanesInt .. "/" .. VERSION .. "/%{cfg.buildcfg}/%{prj.name}")
|
||||
|
||||
if PLATFORM == "linux" then
|
||||
defines { "P_LINUX_BUILD" }
|
||||
linux_sse()
|
||||
buildoptions { "-Wno-unused-parameter" , "-fms-extensions" }
|
||||
end
|
||||
|
||||
filter "configurations:Debug"
|
||||
defines { "DEBUG", "TRACE", "P_DEBUG"}
|
||||
symbols "On"
|
||||
buildmessage("Building %{prj.name} in debug mode")
|
||||
|
||||
filter "configurations:Release"
|
||||
defines { "NDEBUG", "P_RELEASE" }
|
||||
linktimeoptimization "On"
|
||||
optimize "On"
|
||||
intrinsics "On"
|
||||
buildmessage("Building %{prj.name} in release mode")
|
||||
|
||||
filter{}
|
||||
end
|
||||
|
||||
-- actions
|
||||
|
||||
function action_clean()
|
||||
os.rmdir(phanesBin)
|
||||
os.rmdir(phanesInt)
|
||||
os.rmdir(phanesBuildFiles)
|
||||
os.remove(phanesRoot .. "/Makefile")
|
||||
end
|
||||
|
||||
newaction {
|
||||
trigger = "clean",
|
||||
description = "Clean the build",
|
||||
execute = action_clean,
|
||||
}
|
||||
|
||||
-- includeProjects here
|
||||
include "Engine/Source/Runtime/Core/premake5.lua"
|
||||
include "DevPlayground/premake5.lua"
|
||||
include "MathTestFPU/premake5.lua"
|
Loading…
x
Reference in New Issue
Block a user