Compare commits
10 Commits
14f3339eee
...
65a42f0904
Author | SHA1 | Date | |
---|---|---|---|
![]() |
65a42f0904 | ||
![]() |
b90b562557 | ||
![]() |
61189bdc73 | ||
![]() |
53dac3537e | ||
![]() |
d00448a422 | ||
![]() |
0da9755ae6 | ||
![]() |
1fbbdf5f0a | ||
![]() |
d6362a62df | ||
![]() |
defa41b42a | ||
![]() |
606eb5a657 |
49
.gitignore
vendored
49
.gitignore
vendored
@ -1,21 +1,54 @@
|
||||
# vscode
|
||||
.premake/
|
||||
|
||||
# Exclude folders
|
||||
bin/
|
||||
bin-int/
|
||||
int/
|
||||
external/
|
||||
|
||||
# Frequently edited tests
|
||||
Tests/TestProject/
|
||||
|
||||
# Exclude files
|
||||
# Premake Build Files
|
||||
build/
|
||||
Makefile
|
||||
|
||||
# C++
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# Temporary excludes
|
||||
|
||||
Core/private/Math/
|
||||
|
||||
Matrix4.h
|
||||
IntVector4.h
|
||||
Vector4.h
|
||||
|
||||
############################################################################################
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
|
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -1,3 +1,6 @@
|
||||
[submodule "Engine/Source/ThirdParty/spdlog"]
|
||||
path = Engine/Source/ThirdParty/spdlog
|
||||
url = https://github.com/gabime/spdlog.git
|
||||
url = git@github.com:gabime/spdlog.git
|
||||
[submodule "Engine/Source/ThirdParty/googletest"]
|
||||
path = Engine/Source/ThirdParty/googletest
|
||||
url = https://github.com/google/googletest.git
|
||||
|
32
.vscode/launch.json
vendored
Normal file
32
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug MathTestFPU (gdb)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/bin/1.0.0/Debug/MathTestFPU/MathTestFPU",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${fileDirname}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "Set Disassembly Flavor to Intel",
|
||||
"text": "-gdb-set disassembly-flavor intel",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
136
.vscode/settings.json
vendored
136
.vscode/settings.json
vendored
@ -3,8 +3,8 @@
|
||||
"C_Cpp.loggingLevel": "Error",
|
||||
"C_Cpp.default.cppStandard": "c++20",
|
||||
"C_Cpp.default.includePath": [
|
||||
"${workspaceFolder}/Engine/Source/Runtime",
|
||||
"${workspaceFolder}/Engine/Source/ThirdParty"
|
||||
"${workspaceFolder}/Engine/Source/Runtime/",
|
||||
"${workspaceFolder}/Engine/Source/ThirdParty/"
|
||||
],
|
||||
|
||||
"C_Cpp.default.browse.path": [
|
||||
@ -13,10 +13,140 @@
|
||||
],
|
||||
"C_Cpp.default.browse.databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db",
|
||||
"files.associations": {
|
||||
"cstdint": "cpp"
|
||||
"cstdint": "cpp",
|
||||
"chrono": "cpp",
|
||||
"string": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"any": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"charconv": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"compare": "cpp",
|
||||
"complex": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"deque": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"expected": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"regex": "cpp",
|
||||
"source_location": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"hash_map": "cpp",
|
||||
"hash_set": "cpp",
|
||||
"format": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"semaphore": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"span": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stdfloat": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"text_encoding": "cpp",
|
||||
"thread": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"valarray": "cpp",
|
||||
"variant": "cpp"
|
||||
},
|
||||
"C_Cpp.default.defines": [
|
||||
"P_LINUX_BUILD",
|
||||
"__SSE__",
|
||||
],
|
||||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
|
||||
"editor.tokenColorCustomizations": {
|
||||
"[*Light*]": {
|
||||
"textMateRules": [
|
||||
{
|
||||
"scope": "ref.matchtext",
|
||||
"settings": {
|
||||
"foreground": "#000"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"[*Dark*]": {
|
||||
"textMateRules": [
|
||||
{
|
||||
"scope": "ref.matchtext",
|
||||
"settings": {
|
||||
"foreground": "#fff"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"textMateRules": [
|
||||
{
|
||||
"scope": "googletest.failed",
|
||||
"settings": {
|
||||
"foreground": "#f00"
|
||||
}
|
||||
},
|
||||
{
|
||||
"scope": "googletest.passed",
|
||||
"settings": {
|
||||
"foreground": "#0f0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"scope": "googletest.run",
|
||||
"settings": {
|
||||
"foreground": "#0f0"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"gtest-adapter.debugConfig": [
|
||||
"Debug MathTestFPU (gdb)"
|
||||
],
|
||||
"gtest-adapter.supportLocation": true,
|
||||
"premake.version": "Premake 5.0-beta5",
|
||||
}
|
28
.vscode/tasks.json
vendored
Normal file
28
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++ build active file",
|
||||
"command": "/sbin/g++",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.15...3.30)
|
||||
|
||||
project(DevPlayground)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../Engine/Source/Runtime ${CMAKE_BINARY_DIR}/Engine)
|
||||
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}../Engine/Source/Runtime)
|
||||
|
||||
add_executable(DevPlayground
|
||||
DevPlayground.cpp
|
||||
)
|
||||
|
||||
|
||||
add_compile_definitions(P_LINUX_BUILD)
|
||||
add_compile_definitions(P_DEBUG)
|
||||
|
||||
target_link_libraries(DevPlayground PRIVATE PhanesCore)
|
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 }
|
@ -1,5 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.15...3.30)
|
||||
|
||||
project(PhanesRuntime)
|
||||
|
||||
add_subdirectory(Core)
|
@ -1,26 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.15...3.30)
|
||||
|
||||
project(PhanesCore)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
include(Logging/CMakeLists.txt)
|
||||
include(StartingPoint/CMakeLists.txt)
|
||||
|
||||
add_library(PhanesCore STATIC
|
||||
Core.h
|
||||
${Logging}
|
||||
${StartingPoint}
|
||||
)
|
||||
|
||||
target_precompile_headers(PhanesCore PUBLIC
|
||||
${LoggingPCH}
|
||||
${StartingPointPCH}
|
||||
)
|
||||
|
||||
add_compile_definitions(P_LINUX_BUILD)
|
||||
add_compile_definitions(P_DEBUG)
|
||||
|
||||
|
||||
target_include_directories(PhanesCore PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
|
@ -38,6 +38,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
#define FORCEINLINE inline
|
||||
|
||||
#elif defined(P_ARM_BUILD)
|
||||
|
||||
#error Only Windows is supported at the moment.
|
||||
|
@ -1,12 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.15...3.30)
|
||||
|
||||
project(PhanesLogging)
|
||||
|
||||
set(Logging
|
||||
Logging/Logging.h
|
||||
Logging/private/Logging.cpp
|
||||
)
|
||||
|
||||
set(LoggingPCH
|
||||
Logging/LoggingPCH.h
|
||||
)
|
@ -6,13 +6,19 @@
|
||||
|
||||
namespace Phanes::Core::Logging
|
||||
{
|
||||
static Phanes::Ref<spdlog::logger> _PEngineLogger;
|
||||
static Phanes::Ref<spdlog::logger> _PAppLogger;
|
||||
class Logger {
|
||||
|
||||
void Init();
|
||||
public:
|
||||
|
||||
inline std::shared_ptr<spdlog::logger>& PEngineLogger() { return _PEngineLogger; };
|
||||
inline std::shared_ptr<spdlog::logger>& PAppLogger() { return _PAppLogger; };
|
||||
static void Init();
|
||||
|
||||
static std::shared_ptr<spdlog::logger>& PEngineLogger() { return _PEngineLogger; }
|
||||
static std::shared_ptr<spdlog::logger>& PAppLogger() { return _PAppLogger; }
|
||||
|
||||
private:
|
||||
static std::shared_ptr<spdlog::logger> _PEngineLogger;
|
||||
static std::shared_ptr<spdlog::logger> _PAppLogger;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -22,18 +28,18 @@ namespace PLog = Phanes::Core::Logging; // User Macros
|
||||
|
||||
// Default logger
|
||||
|
||||
#define PENGINE_LOG_TRACE(...) ::Phanes::Core::Logging::PEngineLogger()->trace(__VA_ARGS__)
|
||||
#define PENGINE_LOG_INFO(...) ::Phanes::Core::Logging::PEngineLogger()->info(__VA_ARGS__)
|
||||
#define PENGINE_LOG_WARN(...) ::Phanes::Core::Logging::PEngineLogger()->warn(__VA_ARGS__)
|
||||
#define PENGINE_LOG_ERROR(...) ::Phanes::Core::Logging::PEngineLogger()->error(__VA_ARGS__)
|
||||
#define PENGINE_LOG_FATAL(...) ::Phanes::Core::Logging::PEngineLogger()->critical(__VA_ARGS__)
|
||||
#define PENGINE_LOG_TRACE(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->trace(__VA_ARGS__)
|
||||
#define PENGINE_LOG_INFO(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->info(__VA_ARGS__)
|
||||
#define PENGINE_LOG_WARN(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->warn(__VA_ARGS__)
|
||||
#define PENGINE_LOG_ERROR(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->error(__VA_ARGS__)
|
||||
#define PENGINE_LOG_FATAL(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->critical(__VA_ARGS__)
|
||||
|
||||
|
||||
#define PAPP_LOG_TRACE(...) ::Phanes::Core::Logging::PAppLogger()->trace(__VA_ARGS__)
|
||||
#define PAPP_LOG_INFO(...) ::Phanes::Core::Logging::PAppLogger()->info(__VA_ARGS__)
|
||||
#define PAPP_LOG_WARN(...) ::Phanes::Core::Logging::PAppLogger()->warn(__VA_ARGS__)
|
||||
#define PAPP_LOG_ERROR(...) ::Phanes::Core::Logging::PAppLogger()->error(__VA_ARGS__)
|
||||
#define PAPP_LOG_FATAL(...) ::Phanes::Core::Logging::PAppLogger()->critical(__VA_ARGS__)
|
||||
#define PAPP_LOG_TRACE(...) ::Phanes::Core::Logging::Logger::PAppLogger()->trace(__VA_ARGS__)
|
||||
#define PAPP_LOG_INFO(...) ::Phanes::Core::Logging::Logger::PAppLogger()->info(__VA_ARGS__)
|
||||
#define PAPP_LOG_WARN(...) ::Phanes::Core::Logging::Logger::PAppLogger()->warn(__VA_ARGS__)
|
||||
#define PAPP_LOG_ERROR(...) ::Phanes::Core::Logging::Logger::PAppLogger()->error(__VA_ARGS__)
|
||||
#define PAPP_LOG_FATAL(...) ::Phanes::Core::Logging::Logger::PAppLogger()->critical(__VA_ARGS__)
|
||||
|
||||
#else
|
||||
|
||||
|
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
|
@ -1,6 +1,13 @@
|
||||
#include "Core/Logging/Logging.h"
|
||||
|
||||
void Phanes::Core::Logging::Init()
|
||||
namespace Phanes::Core::Logging
|
||||
{
|
||||
std::shared_ptr<spdlog::logger> Logger::_PEngineLogger;
|
||||
std::shared_ptr<spdlog::logger> Logger::_PAppLogger;
|
||||
} // namespace Phanes::Core::Logging
|
||||
|
||||
|
||||
void Phanes::Core::Logging::Logger::Init()
|
||||
{
|
||||
spdlog::set_pattern("%^[%n][%T][%l]:%$ %v");
|
||||
|
||||
|
@ -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)...);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
|
||||
namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
|
||||
namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
@ -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,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
|
@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
@ -177,8 +175,8 @@ namespace Phanes::Core::Math::Detail
|
||||
|
||||
static constexpr bool map(const Phanes::Core::Math::TVector2<T, S>& v1, const Phanes::Core::Math::TVector2<T, S>& v2)
|
||||
{
|
||||
return (Phanes::Core::Math::Abs(v1.x - v2.x) < P_FLT_INAC &&
|
||||
Phanes::Core::Math::Abs(v1.y - v2.y) < P_FLT_INAC);
|
||||
return (Phanes::Core::Math::Abs(v1.x - v2.x) <= P_FLT_INAC &&
|
||||
Phanes::Core::Math::Abs(v1.y - v2.y) <= P_FLT_INAC);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#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,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
namespace Phanes::Core::Math::Detail
|
||||
{
|
||||
|
@ -1,39 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
|
||||
// --- Vectors ------------------------
|
||||
|
||||
#include "Core/public/Math/Vector2.hpp"
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
#include "Core/public/Math/Vector4.hpp"
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
#include "Core/Math/Vector4.hpp"
|
||||
|
||||
#include "Core/public/Math/IntVector2.hpp"
|
||||
#include "Core/public/Math/IntVector3.hpp"
|
||||
#include "Core/public/Math/IntVector4.hpp"
|
||||
#include "Core/Math/IntVector2.hpp"
|
||||
#include "Core/Math/IntVector3.hpp"
|
||||
#include "Core/Math/IntVector4.hpp"
|
||||
|
||||
#include "Core/public/Math/Point.hpp"
|
||||
#include "Core/public/Math/IntPoint.hpp"
|
||||
#include "Core/Math/Point.hpp"
|
||||
#include "Core/Math/IntPoint.hpp"
|
||||
|
||||
|
||||
// --- Matrices ------------------------
|
||||
|
||||
#include "Core/public/Math/Matrix2.hpp"
|
||||
#include "Core/public/Math/Matrix3.hpp"
|
||||
#include "Core/public/Math/Matrix4.hpp"
|
||||
#include "Core/Math/Matrix2.hpp"
|
||||
#include "Core/Math/Matrix3.hpp"
|
||||
#include "Core/Math/Matrix4.hpp"
|
||||
|
||||
// --- Other Math ----------------------
|
||||
|
||||
#include "Core/public/Math/Plane.hpp"
|
||||
#include "Core/public/Math/Line.hpp"
|
||||
#include "Core/Math/Plane.hpp"
|
||||
#include "Core/Math/Line.hpp"
|
||||
|
||||
|
||||
// --- Misc -----------------
|
||||
|
||||
#include "Core/public/Math/MathTypeConversion.hpp"
|
||||
#include "Core/public/Math/MathUnitConversion.hpp"
|
||||
#include "Core/Math/MathTypeConversion.hpp"
|
||||
#include "Core/Math/MathUnitConversion.hpp"
|
||||
|
@ -1,19 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/public/Math/MathAbstractTypes.h"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/IntVector2.hpp"
|
||||
#include "Core/public/Math/IntVector3.hpp"
|
||||
#include "Core/public/Math/IntVector4.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathAbstractTypes.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/Math/IntVector2.hpp"
|
||||
#include "Core/Math/IntVector3.hpp"
|
||||
#include "Core/Math/IntVector4.hpp"
|
||||
/**
|
||||
* General annonation: The Point is the same as a vector. The type exists, to ensure a
|
||||
* easy differentiation between the two.
|
||||
|
@ -1,15 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/Storage.h"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
#include "Core/Math/SIMD/Storage.h"
|
||||
|
||||
/**
|
||||
* Note: Some function are deleted, because, their unusable with int types, except very specific cases.
|
||||
@ -627,4 +623,4 @@ namespace Phanes::Core::Math {
|
||||
|
||||
#endif // !INTVECTOR2_H
|
||||
|
||||
#include "Core/public/Math/IntVector2.inl"
|
||||
#include "Core/Math/IntVector2.inl"
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/Detail/IntVector2Decl.inl"
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/Detail/IntVector2Decl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
{
|
||||
|
@ -1,18 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/Storage.h"
|
||||
|
||||
#include "Core/public/Math/IntVector4.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
#include "Core/Math/SIMD/Storage.h"
|
||||
|
||||
#include "Core/Math/IntVector4.hpp"
|
||||
|
||||
#ifndef INTVECTOR3_H
|
||||
#define INTVECTOR3_H
|
||||
@ -686,4 +681,4 @@ namespace Phanes::Core::Math {
|
||||
|
||||
#endif // !INTVECTOR3_H
|
||||
|
||||
#include "Core/public/Math/IntVector3.inl"
|
||||
#include "Core/Math/IntVector3.inl"
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/Detail/IntVector3Decl.inl"
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/Detail/IntVector3Decl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
|
@ -1,17 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/Storage.h"
|
||||
#include "Core/Math/SIMD/Storage.h"
|
||||
|
||||
#include "Core/public/Math/IntVector2.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
#include "Core/Math/IntVector2.hpp"
|
||||
|
||||
|
||||
#ifndef INTVECTOR4_H
|
||||
@ -640,4 +636,4 @@ namespace Phanes::Core::Math {
|
||||
#endif // !INTVECTOR3_H
|
||||
|
||||
|
||||
#include "Core/public/Math/IntVector4.inl"
|
||||
#include "Core/Math/IntVector4.inl"
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/Detail/IntVector4Decl.inl"
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/Detail/IntVector4Decl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
{
|
||||
|
@ -1,12 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
|
||||
#include <any>
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
@ -49,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);
|
||||
@ -126,34 +128,16 @@ namespace Phanes::Core::Math {
|
||||
|
||||
|
||||
template<typename T>
|
||||
FORCEINLINE T Abs(T s)
|
||||
inline T Abs(T s)
|
||||
{
|
||||
return abs(s);
|
||||
}
|
||||
|
||||
template<>
|
||||
FORCEINLINE float Abs<float>(float s)
|
||||
template<typename T>
|
||||
inline T Sqrt(T s)
|
||||
{
|
||||
return (float)fabs(s);
|
||||
};
|
||||
|
||||
template<>
|
||||
FORCEINLINE long long Abs<long long>(long long s)
|
||||
{
|
||||
return llabs(s);
|
||||
};
|
||||
|
||||
template<>
|
||||
FORCEINLINE long Abs<long>(long s)
|
||||
{
|
||||
return labs(s);
|
||||
};
|
||||
|
||||
template<>
|
||||
FORCEINLINE double Abs<double>(double s)
|
||||
{
|
||||
return fabsl(s);
|
||||
};
|
||||
return sqrt(s);
|
||||
}
|
||||
|
||||
|
||||
} // phanes
|
||||
|
@ -9,8 +9,8 @@
|
||||
#ifndef MATH_FWD_H
|
||||
#define MATH_FWD_H
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
/**
|
||||
* Includes forward declarations, as well as certain useful typedefs.
|
||||
|
@ -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/public/Math/Point.hpp"
|
||||
#include "Core/public/Math/Plane.hpp"
|
||||
#include "Core/public/Math/Line.hpp"
|
||||
#include "Core/public/Math/Ray.hpp"
|
||||
|
||||
|
||||
#include "Core/public/Math/Vector2.hpp"
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
#include "Core/public/Math/Vector4.hpp"
|
||||
|
||||
#include "Core/public/Math/IntPoint.hpp"
|
||||
#include "Core/public/Math/IntVector2.hpp"
|
||||
#include "Core/public/Math/IntVector3.hpp"
|
||||
#include "Core/public/Math/IntVector4.hpp"
|
||||
|
||||
#include "Core/public/Math/Matrix2.hpp"
|
||||
#include "Core/public/Math/Matrix3.hpp"
|
||||
#include "Core/public/Math/Matrix4.hpp"
|
||||
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/public/Math/MathTypeConversion.hpp"
|
||||
#include "Core/public/Math/MathUnitConversion.hpp"
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
@ -6,24 +6,20 @@
|
||||
// @ref [FILE]MathUnitConversion //
|
||||
// ============================================= //
|
||||
|
||||
#ifdef P_BUILD_LIB
|
||||
#include "PhanesEnginePCH.h"
|
||||
#else
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathPCH.h"
|
||||
|
||||
#include "Core/public/Math/MathAbstractTypes.h"
|
||||
#include "Core/public/Math/Vector2.hpp"
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
#include "Core/public/Math/Vector4.hpp"
|
||||
#include "Core/public/Math/Matrix2.hpp"
|
||||
#include "Core/public/Math/Matrix3.hpp"
|
||||
#include "Core/public/Math/Matrix4.hpp"
|
||||
#include "Core/public/Math/IntVector2.hpp"
|
||||
#include "Core/public/Math/IntVector3.hpp"
|
||||
#include "Core/public/Math/IntVector4.hpp"
|
||||
#include "Core/Math/MathAbstractTypes.h"
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
#include "Core/Math/Vector4.hpp"
|
||||
#include "Core/Math/Matrix2.hpp"
|
||||
#include "Core/Math/Matrix3.hpp"
|
||||
#include "Core/Math/Matrix4.hpp"
|
||||
#include "Core/Math/IntVector2.hpp"
|
||||
#include "Core/Math/IntVector3.hpp"
|
||||
#include "Core/Math/IntVector4.hpp"
|
||||
|
||||
#ifndef MATH_TYPE_CONVERSION_H
|
||||
#define MATH_TYPE_CONVERSION_H
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
// Contains functions to convert units //
|
||||
// ======================================= //
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
|
||||
namespace Phanes::Core::Math::UnitConversion
|
||||
{
|
||||
@ -14,7 +14,7 @@ namespace Phanes::Core::Math::UnitConversion
|
||||
/**
|
||||
* Converts degrees to radians.
|
||||
*
|
||||
* @param(deg) Angle in degress (°)
|
||||
* @param(deg) Angle in degress (<EFBFBD>)
|
||||
*
|
||||
* @return Angle in radians
|
||||
*/
|
||||
@ -42,7 +42,7 @@ namespace Phanes::Core::Math::UnitConversion
|
||||
/**
|
||||
* Converts degrees to gradian.
|
||||
*
|
||||
* @param(deg) Angle in degress (°)
|
||||
* @param(deg) Angle in degress (<EFBFBD>)
|
||||
*
|
||||
* @return Angle in gradian
|
||||
*/
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/Vector2.hpp"
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
|
||||
#ifndef MATRIX2_H
|
||||
#define MATRIX2_H
|
||||
@ -355,4 +355,4 @@ namespace Phanes::Core::Math {
|
||||
#endif // !MATRIX2_H
|
||||
|
||||
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathAbstractTypes.h"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
#include "Core/Math/MathAbstractTypes.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
|
||||
#ifndef MATRIX3_H
|
||||
#define MATRIX3_H
|
||||
@ -547,4 +547,4 @@ namespace Phanes::Core::Math {
|
||||
|
||||
#endif // !MATRIX3_H
|
||||
|
||||
#include "Core/public/Math/Matrix3.inl"
|
||||
#include "Core/Math/Matrix3.inl"
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/Detail/Matrix3Decl.inl"
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/Detail/Matrix3Decl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathAbstractTypes.h"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/public/Math/Vector4.hpp"
|
||||
#include "Core/Math/MathAbstractTypes.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
#include "Core/Math/Vector4.hpp"
|
||||
|
||||
#ifndef MATRIX4_H
|
||||
#define MATRIX4_H
|
||||
@ -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
|
||||
@ -331,4 +331,4 @@ namespace Phanes::Core::Math {
|
||||
|
||||
#endif // !MATRIX4_H
|
||||
|
||||
#include "Core/public/Math/Matrix4.inl"
|
||||
#include "Core/Math/Matrix4.inl"
|
@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/Detail/Matrix4Decl.inl"
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/Detail/Matrix4Decl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#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"
|
@ -3,12 +3,12 @@
|
||||
|
||||
// TODO: Transform
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/Line.hpp"
|
||||
#include "Core/public/Math/Ray.hpp"
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
#include "Core/Math/Line.hpp"
|
||||
#include "Core/Math/Ray.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
|
||||
namespace Phanes::Core::Math {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -953,4 +953,4 @@ namespace Phanes::Core::Math {
|
||||
} // Phanes::Core::Math
|
||||
|
||||
// Include operator impl.
|
||||
#include "Core/public/Math/Plane.inl"
|
||||
#include "Core/Math/Plane.inl"
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/Detail/PlaneDecl.inl"
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/Detail/PlaneDecl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
|
||||
|
||||
|
@ -1,17 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/public/Math/MathAbstractTypes.h"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathAbstractTypes.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/Vector2.hpp"
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
|
||||
/**
|
||||
* The Point is the same as a vector. The type exists, to ensure
|
||||
@ -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.
|
||||
*
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
|
||||
namespace Phanes::Core::Math::SIMD
|
||||
|
@ -4,8 +4,8 @@
|
||||
//
|
||||
// ARM is not supported.
|
||||
|
||||
#include "Core/public/Math/SIMD/Platform.h"
|
||||
#include "Core/public/Math/MathTypes.h"
|
||||
#include "Core/Math/SIMD/Platform.h"
|
||||
#include "Core/Math/MathTypes.h"
|
||||
|
||||
#if P_INTRINSICS == P_INTRINSICS_AVX2
|
||||
# include <immintrin.h>
|
||||
|
@ -2,23 +2,23 @@
|
||||
|
||||
#include <nmmintrin.h>
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
|
||||
|
||||
#include "Core/public/Math/Vector2.hpp"
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
#include "Core/public/Math/Vector4.hpp"
|
||||
#include "Core/Math/Vector2.hpp"
|
||||
#include "Core/Math/Vector3.hpp"
|
||||
#include "Core/Math/Vector4.hpp"
|
||||
|
||||
#include "Core/public/Math/Plane.hpp"
|
||||
#include "Core/Math/Plane.hpp"
|
||||
|
||||
#include "Core/public/Math/IntVector2.hpp"
|
||||
#include "Core/public/Math/IntVector3.hpp"
|
||||
#include "Core/public/Math/IntVector4.hpp"
|
||||
#include "Core/Math/IntVector2.hpp"
|
||||
#include "Core/Math/IntVector3.hpp"
|
||||
#include "Core/Math/IntVector4.hpp"
|
||||
|
||||
#include "Core/public/Math/Matrix3.hpp"
|
||||
#include "Core/public/Math/Matrix4.hpp"
|
||||
#include "Core/Math/Matrix3.hpp"
|
||||
#include "Core/Math/Matrix4.hpp"
|
||||
|
||||
|
||||
|
||||
@ -26,6 +26,9 @@
|
||||
// Common //
|
||||
// ========== //
|
||||
|
||||
#ifndef PHANES_VECTOR_MATH_SSE_HPP
|
||||
#define PHANES_VECTOR_MATH_SSE_HPP
|
||||
|
||||
namespace Phanes::Core::Math::SIMD
|
||||
{
|
||||
Phanes::Core::Types::Vec4f32Reg vec4_cross_p(const Phanes::Core::Types::Vec4f32Reg v1, const Phanes::Core::Types::Vec4f32Reg v2)
|
||||
@ -48,10 +51,10 @@ namespace Phanes::Core::Math::SIMD
|
||||
/// <returns>Sum stored in v[0:31].</returns>
|
||||
Phanes::Core::Types::Vec4f32Reg vec4_hadd(const Phanes::Core::Types::Vec4f32Reg v)
|
||||
{
|
||||
__m128 shufl = _mm_movehdup_ps(v);
|
||||
__m128 sum = _mm_add_ps(v, shufl);
|
||||
shufl = _mm_movehl_ps(sum, sum);
|
||||
return _mm_add_ss(sum, shufl);
|
||||
__m128 t = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 3, 0, 1));
|
||||
t = _mm_add_ps(t, v);
|
||||
t = _mm_shuffle_ps(t, t, _MM_SHUFFLE(1, 0, 3, 2));
|
||||
return _mm_add_ps(t, v);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -61,12 +64,11 @@ namespace Phanes::Core::Math::SIMD
|
||||
/// <returns>Sum of components.</returns>
|
||||
float vec4_hadd_cvtf32(const Phanes::Core::Types::Vec4f32Reg v)
|
||||
{
|
||||
__m128 shufl = _mm_movehdup_ps(v);
|
||||
__m128 sum = _mm_add_ps(v, shufl);
|
||||
shufl = _mm_movehl_ps(sum, sum);
|
||||
sum = _mm_add_ss(sum, shufl);
|
||||
|
||||
return _mm_cvtss_f32(sum);
|
||||
__m128 t = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 3, 0, 1));
|
||||
t = _mm_add_ps(t, v);
|
||||
t = _mm_shuffle_ps(t, t, _MM_SHUFFLE(1, 0, 3, 2));
|
||||
t = _mm_add_ps(t, v);
|
||||
return _mm_cvtss_f32(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -586,12 +588,7 @@ namespace Phanes::Core::Math::Detail
|
||||
pl.comp.data = _mm_set_ps(x, y, z, d);
|
||||
}
|
||||
|
||||
static FORCEINLINE void map(Phanes::Core::Math::TPlane<float, true>& pl, const TVector3<float, true>& v1, const TVector3<float, true>& v2, const TVector3<float, true>& v3)
|
||||
{
|
||||
TVector4<float, false> tmp;
|
||||
|
||||
}
|
||||
|
||||
// TODO: Create SSE constructor with 3 Points
|
||||
|
||||
};
|
||||
|
||||
@ -1281,7 +1278,7 @@ namespace Phanes::Core::Math::Detail
|
||||
|
||||
|
||||
template<>
|
||||
struct compute_mat4_inv<float, false>
|
||||
struct compute_mat4_inv<float, true>
|
||||
{
|
||||
// From: GLM: https://github.com/g-truc/glm/blob/master/glm/simd/matrix.h (MIT License)
|
||||
static FORCEINLINE bool map(Phanes::Core::Math::TMatrix4<float, true>& r, const Phanes::Core::Math::TMatrix4<float, true>& m1)
|
||||
@ -1503,6 +1500,10 @@ namespace Phanes::Core::Math::Detail
|
||||
r.c1.data = _mm_mul_ps(Inv1, Rcp0);
|
||||
r.c2.data = _mm_mul_ps(Inv2, Rcp0);
|
||||
r.c3.data = _mm_mul_ps(Inv3, Rcp0);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -23,9 +23,9 @@
|
||||
// User defines build platform
|
||||
#ifdef P_WIN_BUILD
|
||||
# define P_PLATFORM P_PLATFORM_WIN
|
||||
# error Windows system is not yet supported.
|
||||
#elif P_LINUX_BUILD
|
||||
# define P_PLATFORM P_PLATFORM_LIN
|
||||
# error Linux / Unix system is not yet supported.
|
||||
#elif P_MAC_BUILD
|
||||
# define P_PLATFORM P_PLATFORM_MAC
|
||||
# error Mac target system is not yet supported.
|
||||
@ -142,7 +142,6 @@
|
||||
// Clang
|
||||
|
||||
#elif (defined(__clang__))
|
||||
# error PhanesEngine only supports MSVC -> Visual Studio
|
||||
# if defined(__apple_build_version__)
|
||||
#
|
||||
# if (__clang_major__ < 6)
|
||||
@ -208,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
|
||||
@ -313,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
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "Core/public/Math/SIMD/Platform.h"
|
||||
#include "Core/Math/SIMD/Platform.h"
|
||||
|
||||
#if P_INTRINSICS == P_INTRINSICS_AVX2
|
||||
# include "PhanesVectorMathAVX2.hpp"
|
||||
# include "Core/Math/SIMD/PhanesVectorMathAVX2.hpp"
|
||||
#elif P_INTRINSICS == P_INTRINSICS_AVX
|
||||
# include "PhanesVectorMathAVX.hpp"
|
||||
# include "Core/Math/SIMD/PhanesVectorMathAVX.hpp"
|
||||
#elif P_INTRINSICS == P_INTRINSICS_SSE
|
||||
# include "PhanesVectorMathSSE.hpp"
|
||||
# include "Core/Math/SIMD/PhanesVectorMathSSE.hpp"
|
||||
#elif P_INTRINSICS == P_INTRINSICS_NEON
|
||||
# include "PhanesVectorMathNeon.hpp"
|
||||
# include "Core/Math/SIMD/PhanesVectorMathNeon.hpp"
|
||||
#endif
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Defines on compile time, whether a xmm register or an array should be used.
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
#include "Core/public/Math/MathTypes.h"
|
||||
#include "Core/Math/MathTypes.h"
|
||||
|
||||
namespace Phanes::Core::Math::SIMD
|
||||
{
|
||||
|
@ -1,27 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/Storage.h"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
#pragma warning(disable: 4661)
|
||||
#include "Core/Math/SIMD/Storage.h"
|
||||
|
||||
#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
|
||||
*
|
||||
@ -1016,4 +1016,4 @@ namespace Phanes::Core::Math {
|
||||
#endif // !VECTOR2_H
|
||||
|
||||
// Include operator impl.
|
||||
#include "Core/public/Math/Vector2.inl"
|
||||
#include "Core/Math/Vector2.inl"
|
@ -4,12 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/Detail/Vector2Decl.inl"
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/Detail/Vector2Decl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
|
||||
|
||||
|
@ -3,28 +3,24 @@
|
||||
// TODO: Slerp (using Quaternions)
|
||||
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/public/Math/SIMD/Storage.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
#include "Core/Math/SIMD/Storage.h"
|
||||
|
||||
#include "Core/public/Math/Vector4.hpp"
|
||||
|
||||
#ifndef P_DEBUG
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
#include "Core/Math/Vector4.hpp"
|
||||
|
||||
#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
|
||||
*
|
||||
@ -671,7 +707,7 @@ namespace Phanes::Core::Math {
|
||||
*/
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector3<T, S>& ClampToCubeV(TVector3<T, S> v1, T cubeRadius);
|
||||
TVector3<T, S>& ClampToCubeV(TVector3<T, S>& v1, T cubeRadius);
|
||||
|
||||
/**
|
||||
* Rotates vector around axis
|
||||
@ -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.
|
||||
@ -1179,4 +1240,4 @@ namespace Phanes::Core::Math {
|
||||
#endif // !VECTOR3_H
|
||||
|
||||
|
||||
#include "Core/public/Math/Vector3.inl"
|
||||
#include "Core/Math/Vector3.inl"
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/Detail/Vector3Decl.inl"
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/Detail/Vector3Decl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.h"
|
||||
#include "Core/Math/SIMD/PhanesSIMDTypes.h"
|
||||
|
||||
|
||||
|
||||
@ -292,7 +292,7 @@ namespace Phanes::Core::Math
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector3<T, S>& ClampToCubeV(TVector3<T, S> v1, T cubeRadius)
|
||||
TVector3<T, S>& ClampToCubeV(TVector3<T, S>& v1, T cubeRadius)
|
||||
{
|
||||
Detail::compute_vec3_clamp<T, S>::map(v1, v1, cubeRadius);
|
||||
return v1;
|
||||
|
@ -1,16 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/public/Math/MathCommon.hpp"
|
||||
#include "Core/public/Math/SIMD/Storage.h"
|
||||
#include "Core/public/Math/MathFwd.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
#include "Core/Math/MathCommon.hpp"
|
||||
#include "Core/Math/SIMD/Storage.h"
|
||||
#include "Core/Math/MathFwd.h"
|
||||
|
||||
|
||||
#include "Core/public/Math/Vector2.hpp"
|
||||
#include "Core/public/Math/Vector3.hpp"
|
||||
#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/public/Math/Vector4.inl"
|
||||
#include "Core/Math/Vector4.inl"
|
||||
|
@ -1,12 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/public/Math/Boilerplate.h"
|
||||
#include "Core/Math/Boilerplate.h"
|
||||
|
||||
#include "Core/public/Math/Detail/Vector4Decl.inl"
|
||||
#include "Core/public/Math/SIMD/SIMDIntrinsics.h"
|
||||
#include "Core/Math/Detail/Vector4Decl.inl"
|
||||
#include "Core/Math/SIMD/SIMDIntrinsics.h"
|
||||
|
||||
|
||||
#include "Core/public/Math/SIMD/PhanesSIMDTypes.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"
|
@ -1,13 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.15...3.30)
|
||||
|
||||
project(StartingPoint)
|
||||
|
||||
set(StartingPoint
|
||||
StartingPoint/EntryPoint.h
|
||||
StartingPoint/StartingPoint.h
|
||||
StartingPoint/private/StartingPoint.cpp
|
||||
)
|
||||
|
||||
set(StartingPointPCH
|
||||
StartingPoint/StartingPointPCH.h
|
||||
)
|
@ -3,24 +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::Init();
|
||||
PENGINE_LOG_INFO("Logger initialized!");
|
||||
PENGINE_LOG_INFO("Welcome to PhanesEngine!");
|
||||
|
||||
|
||||
auto phanes_game = Phanes::Core::Application::CreatePhanesGame();
|
||||
|
||||
PENGINE_LOG_INFO("Loading project {0}...", phanes_game->GetName());
|
||||
|
||||
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
|
@ -1,37 +1,38 @@
|
||||
#include "Core/StartingPoint/StartingPoint.h"
|
||||
#include "Core/Logging/Logging.h"
|
||||
|
||||
static void IdleMsg()
|
||||
{
|
||||
std::cout << "\n\nWelcome to PhanesEngine!" << std::endl << std::endl;
|
||||
std::cout << "\nWelcome to PhanesEngine!\n";
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
|
||||
std::cout << "It's silent..." << std::endl << std::endl;
|
||||
std::cout << "It's silent...\n";
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
|
||||
std::cout << "To silent." << std::endl;
|
||||
std::cout << "To silent.\n";
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
|
||||
std::cout << "\nI will go now" << std::endl;
|
||||
std::cout << "I will go now\n";
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(4));
|
||||
|
||||
std::cout << "\nGood by!" << std::endl;
|
||||
std::cout << "Good by!\n\n";
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Phanes::Core::Application::PhanesProject::PhanesProject(std::string _ProjectName)
|
||||
: projectName(_ProjectName)
|
||||
{};
|
||||
{
|
||||
PAPP_LOG_INFO("Loading project: {0}", this->GetName());
|
||||
};
|
||||
|
||||
Phanes::Core::Application::PhanesProject::~PhanesProject()
|
||||
{
|
||||
this->projectName = "Unnamed Project";
|
||||
PAPP_LOG_INFO("Unloading project: {0}", this->GetName());
|
||||
};
|
||||
|
||||
std::string Phanes::Core::Application::PhanesProject::GetName()
|
||||
|
@ -0,0 +1 @@
|
||||
#include "Core/StartingPoint/StartingPointPCH.h"
|
21
Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/main.cpp
Normal file
21
Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/main.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
#include "Core/Math/Include.h"
|
||||
|
||||
namespace PMath = Phanes::Core::Math;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
PMath::Matrix4 m2;
|
||||
|
||||
std::cout << std::to_string(PMath::InverseV<float, false>(m0)) << std::endl;
|
||||
|
||||
std::cout << PMath::ToString(m0) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
#include "pch.h"
|
||||
|
7
Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/pch.h
Normal file
7
Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/pch.h
Normal file
@ -0,0 +1,7 @@
|
||||
//
|
||||
// pch.h
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "googletest/googletest/include/gtest/gtest.h"
|
@ -0,0 +1,39 @@
|
||||
project "gtest"
|
||||
language "C++"
|
||||
kind "StaticLib"
|
||||
third_party_boilerplate()
|
||||
|
||||
includedirs {
|
||||
|
||||
PhanesThirdParty .. "/googletest/googletest/include",
|
||||
PhanesThirdParty .. "/googletest/googletest/include/gtest",
|
||||
PhanesThirdParty .. "/googletest/googletest"
|
||||
|
||||
}
|
||||
files {
|
||||
PhanesThirdParty .. "/googletest/googletest/src/**.cc",
|
||||
PhanesThirdParty .. "/googletest/googletest/include/gtest/**.h"
|
||||
}
|
||||
|
||||
project "MathTestFPU"
|
||||
kind "ConsoleApp"
|
||||
boilerplate()
|
||||
|
||||
files {
|
||||
PhanesRuntime .. "/Core/Tests/Math/MathTestFPU/test.cpp"
|
||||
}
|
||||
|
||||
buildoptions {"-Wno-unused-variable", "-w", "-fpermissive"}
|
||||
|
||||
pchheader (PhanesRuntime .. "/Core/Tests/Math/MathTestFPU/pch.h")
|
||||
pchsource (PhanesRuntime .. "/Core/Tests/Math/MathTestFPU/pch.cpp")
|
||||
|
||||
links { "gtest" }
|
||||
dependson { "gtest" }
|
||||
|
||||
includedirs {
|
||||
PhanesRuntime .. "/Core/Tests/Math/MathTestFPU",
|
||||
PhanesThirdParty .. "/googletest/googletest/include",
|
||||
PhanesThirdParty,
|
||||
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;
|
||||
|
||||
@ -737,7 +740,8 @@ namespace VectorTests
|
||||
EXPECT_TRUE(PMath::CompInverseV(v0) == PMath::Vector3(1.0f / 2.4f, 1.0f / 3.1f, 1.0f / 5.6f));
|
||||
|
||||
v0 = PMath::Vector3(2.4f, 3.1f, 5.6f);
|
||||
EXPECT_TRUE(PMath::ClampToCubeV(v0, 3.2f) == PMath::Vector3(2.4f, 3.1f, 3.2f));
|
||||
PMath::Vector3 test = PMath::ClampToCubeV(v0, 3.2f);
|
||||
EXPECT_TRUE(test == PMath::Vector3(2.4f, 3.1f, 3.2f));
|
||||
|
||||
v0 = PMath::Vector3(2.4f, 3.1f, 5.6f);
|
||||
EXPECT_TRUE(PMath::RotateAroundAxisV(v0, PMath::Vector3(0.0f, 0.0f, 1.0f), (float)30.0_deg) == PMath::Vector3(3.628461f, 1.484679f, 5.600000f)) << PMath::ToString(PMath::RotateAroundAxisV(v0, PMath::Vector3(0.0f, 0.0f, 1.0f), (float)30.0_deg));
|
||||
@ -930,16 +934,16 @@ namespace MatrixTests
|
||||
PMath::Matrix2 m0 = PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f);
|
||||
|
||||
m0 += 2.0f;
|
||||
EXPECT_TRUE(m0 == PMath::Matrix2(3.0f, 7.0f, 5.0f, 4.0f));
|
||||
EXPECT_TRUE(m0 == PMath::Matrix2(3.0f, 7.0f, 5.0f, 4.0f)) << PMath::ToString(m0);
|
||||
|
||||
m0 -= 2.0f;
|
||||
EXPECT_TRUE(m0 == PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f));
|
||||
EXPECT_TRUE(m0 == PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f)) << PMath::ToString(m0);
|
||||
|
||||
m0 *= 2.0f;
|
||||
EXPECT_TRUE(m0 == PMath::Matrix2(2.0f, 10.0f, 6.0f, 4.0f));
|
||||
EXPECT_TRUE(m0 == PMath::Matrix2(2.0f, 10.0f, 6.0f, 4.0f)) << PMath::ToString(m0);
|
||||
|
||||
m0 /= 2.0f;
|
||||
EXPECT_TRUE(m0 == PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f));
|
||||
EXPECT_TRUE(m0 == PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f)) << PMath::ToString(m0);
|
||||
|
||||
|
||||
m0 = m0 + 2.0f;
|
||||
@ -995,7 +999,7 @@ namespace MatrixTests
|
||||
|
||||
EXPECT_FLOAT_EQ(PMath::Determinant(m0), -13.0f);
|
||||
|
||||
EXPECT_TRUE(PMath::InverseV(m0) == PMath::Matrix2(-2.0f / 13.0f, 5.0f / 13.0f, 3.0f / 13.0f, -1.0f / 13.0f));
|
||||
EXPECT_TRUE(PMath::InverseV(m0) == PMath::Matrix2(-2.0f / 13.0f, 5.0f / 13.0f, 3.0f / 13.0f, -1.0f / 13.0f)) << PMath::ToString(m0);
|
||||
|
||||
m0 = PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f);
|
||||
EXPECT_TRUE(PMath::TransposeV(m0) == PMath::Matrix2(1.0f, 3.0f, 5.0f, 2.0f));
|
||||
@ -1263,7 +1267,14 @@ 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
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()
|
@ -2,6 +2,5 @@
|
||||
|
||||
// --- Core -------------------
|
||||
|
||||
#include "PhanesEnginePCH.h"
|
||||
#include "Core/Include.h"
|
||||
|
||||
|
1
Engine/Source/ThirdParty/googletest
vendored
Submodule
1
Engine/Source/ThirdParty/googletest
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit a6ce08abf746c0aaa577520d6d1f6ea2abeeb61d
|
2
Engine/Source/ThirdParty/spdlog
vendored
2
Engine/Source/ThirdParty/spdlog
vendored
@ -1 +1 @@
|
||||
Subproject commit bdd1dff3788ebfe520f48f9ad216c60da6dd8f00
|
||||
Subproject commit 3335c380a08c5e0f5117a66622df6afdb3d74959
|
@ -1,7 +0,0 @@
|
||||
//
|
||||
// pch.cpp
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
@ -1,7 +0,0 @@
|
||||
//
|
||||
// pch.h
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gtest/gtest.h"
|
131
premake5.lua
Normal file
131
premake5.lua
Normal file
@ -0,0 +1,131 @@
|
||||
-- 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"
|
||||
cppdialect "C++20"
|
||||
architecture (ARCH)
|
||||
toolset "gcc"
|
||||
flags { "MultiProcessorCompile" }
|
||||
clangtidy "On"
|
||||
debugger "gdb"
|
||||
startproject "MathTestFPU"
|
||||
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" }
|
||||
buildoptions {"-Wall", "-Wextra", "-Werror"}
|
||||
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
|
||||
|
||||
function third_party_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
|
||||
buildoptions {"-Wall", "-Wextra", "-Werror"}
|
||||
linux_sse()
|
||||
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 (phanesRoot .. "/Engine/Source/Runtime/Core/premake5.lua")
|
||||
include (phanesRoot .. "/DevPlayground/premake5.lua")
|
||||
include (PhanesRuntime .. "/Core/Tests/Math/MathTestFPU/premake5.lua")
|
Loading…
x
Reference in New Issue
Block a user