diff --git a/.gitmodules b/.gitmodules index 88865010..38b83926 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,12 @@ -[submodule "engine/native/thirdparty/bx"] - path = engine/native/thirdparty/bx +[submodule "Engine/cpp/thirdparty/bx"] + path = Engine/cpp/thirdparty/bx url = https://github.com/bkaradzic/bx -[submodule "engine/native/thirdparty/bimg"] - path = engine/native/thirdparty/bimg +[submodule "Engine/cpp/thirdparty/bimg"] + path = Engine/cpp/thirdparty/bimg url = https://github.com/bkaradzic/bimg -[submodule "engine/native/thirdparty/bgfx"] - path = engine/native/thirdparty/bgfx +[submodule "Engine/cpp/thirdparty/bgfx"] + path = Engine/cpp/thirdparty/bgfx url = https://github.com/bkaradzic/bgfx -[submodule "engine/native/thirdparty/sdl"] - path = engine/native/thirdparty/sdl +[submodule "Engine/cpp/thirdparty/sdl"] + path = Engine/cpp/thirdparty/sdl url = https://github.com/libsdl-org/SDL diff --git a/CMakeLists.txt b/CMakeLists.txt index 99a70261..d99bedff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,42 +25,8 @@ include(Compiler) include(Modules) include(Shaders) -# Subdirectories for engine libs -add_subdirectory(engine) +# Engine runtime (C++) +add_subdirectory(Engine/cpp) -# Main Executable -add_executable(draconic engine/native/main/main.cpp) - -target_link_libraries(draconic - PRIVATE - native - bgfx - bx - bimg -) - -if(UNIX AND NOT APPLE) - target_link_libraries(draconic PRIVATE SDL3::SDL3-static Threads::Threads dl) - target_link_options(draconic PRIVATE -Wl,--whole-archive $ -Wl,--no-whole-archive) -elseif(APPLE) - target_link_libraries(draconic PRIVATE SDL3::SDL3-static) - target_link_options(draconic PRIVATE -Wl,-force_load,$) -else() - target_link_libraries(draconic PRIVATE SDL3::SDL3-static) -endif() - -compile_shaders(draconic) - -set(TEST_IMAGE - "${CMAKE_SOURCE_DIR}/assets/draconic_logo_no_text.png" -) - -add_custom_command( - TARGET draconic POST_BUILD - - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${TEST_IMAGE} - $/test.png - - COMMENT "Copying test texture..." -) +# Samples (C++) +add_subdirectory(Samples/cpp) diff --git a/assets/draconic_logo_no_text.png b/Docs/assets/draconic_logo_no_text.png similarity index 100% rename from assets/draconic_logo_no_text.png rename to Docs/assets/draconic_logo_no_text.png diff --git a/assets/draconic_logo_no_text.svg b/Docs/assets/draconic_logo_no_text.svg similarity index 100% rename from assets/draconic_logo_no_text.svg rename to Docs/assets/draconic_logo_no_text.svg diff --git a/assets/draconic_logo_text.png b/Docs/assets/draconic_logo_text.png similarity index 100% rename from assets/draconic_logo_text.png rename to Docs/assets/draconic_logo_text.png diff --git a/docs/cxxmodules.md b/Docs/cxxmodules.md similarity index 100% rename from docs/cxxmodules.md rename to Docs/cxxmodules.md diff --git a/docs/index.md b/Docs/index.md similarity index 100% rename from docs/index.md rename to Docs/index.md diff --git a/Editor/Editor.cs b/Editor/Editor.cs new file mode 100644 index 00000000..f80babfe --- /dev/null +++ b/Editor/Editor.cs @@ -0,0 +1 @@ +// Placeholder for Editor UI code \ No newline at end of file diff --git a/Engine/cpp/CMakeLists.txt b/Engine/cpp/CMakeLists.txt new file mode 100644 index 00000000..3e594b1a --- /dev/null +++ b/Engine/cpp/CMakeLists.txt @@ -0,0 +1,6 @@ +add_subdirectory(thirdparty SYSTEM) + +add_modules_library(runtime) +target_link_libraries(runtime PUBLIC platform core input scene rendering) + +# TODO: binding library \ No newline at end of file diff --git a/Engine/cpp/DraconicAPI.h b/Engine/cpp/DraconicAPI.h new file mode 100644 index 00000000..ef55fbe4 --- /dev/null +++ b/Engine/cpp/DraconicAPI.h @@ -0,0 +1,15 @@ +#ifndef DRACONICENGINE_API_H +#define DRACONICENGINE_API_H + +/* + * Placeholder for C binding header. + * It will be a C facade to the Draconic C++ runtime. + */ + +extern "C" { + + + +} + +#endif //DRACONICENGINE_API_H \ No newline at end of file diff --git a/engine/native/CMakeLists.txt b/Engine/cpp/runtime/CMakeLists.txt similarity index 93% rename from engine/native/CMakeLists.txt rename to Engine/cpp/runtime/CMakeLists.txt index a8974d19..c9f083ed 100644 --- a/engine/native/CMakeLists.txt +++ b/Engine/cpp/runtime/CMakeLists.txt @@ -1,5 +1,3 @@ -add_subdirectory(thirdparty SYSTEM) - add_modules_library(platform) add_modules_library(core SHARED) add_modules_library(input) diff --git a/engine/native/core/CMakeLists.txt b/Engine/cpp/runtime/core/CMakeLists.txt similarity index 100% rename from engine/native/core/CMakeLists.txt rename to Engine/cpp/runtime/core/CMakeLists.txt diff --git a/engine/native/core/core.cppm b/Engine/cpp/runtime/core/core.cppm similarity index 100% rename from engine/native/core/core.cppm rename to Engine/cpp/runtime/core/core.cppm diff --git a/engine/native/core/definitions/definitions.cppm b/Engine/cpp/runtime/core/definitions/definitions.cppm similarity index 100% rename from engine/native/core/definitions/definitions.cppm rename to Engine/cpp/runtime/core/definitions/definitions.cppm diff --git a/engine/native/core/definitions/stdtypes.cppm b/Engine/cpp/runtime/core/definitions/stdtypes.cppm similarity index 100% rename from engine/native/core/definitions/stdtypes.cppm rename to Engine/cpp/runtime/core/definitions/stdtypes.cppm diff --git a/engine/native/core/definitions/version.cppm b/Engine/cpp/runtime/core/definitions/version.cppm similarity index 100% rename from engine/native/core/definitions/version.cppm rename to Engine/cpp/runtime/core/definitions/version.cppm diff --git a/engine/native/core/io/filesystem.cpp b/Engine/cpp/runtime/core/io/filesystem.cpp similarity index 100% rename from engine/native/core/io/filesystem.cpp rename to Engine/cpp/runtime/core/io/filesystem.cpp diff --git a/engine/native/core/io/filesystem.cppm b/Engine/cpp/runtime/core/io/filesystem.cppm similarity index 100% rename from engine/native/core/io/filesystem.cppm rename to Engine/cpp/runtime/core/io/filesystem.cppm diff --git a/engine/native/core/io/image_loader.cpp b/Engine/cpp/runtime/core/io/image_loader.cpp similarity index 100% rename from engine/native/core/io/image_loader.cpp rename to Engine/cpp/runtime/core/io/image_loader.cpp diff --git a/engine/native/core/io/image_loader.cppm b/Engine/cpp/runtime/core/io/image_loader.cppm similarity index 81% rename from engine/native/core/io/image_loader.cppm rename to Engine/cpp/runtime/core/io/image_loader.cppm index facced31..a1dd61f6 100644 --- a/engine/native/core/io/image_loader.cppm +++ b/Engine/cpp/runtime/core/io/image_loader.cppm @@ -1,7 +1,6 @@ module; #include -#include #include export module core.io.image_loader; @@ -19,6 +18,6 @@ export namespace draco::core::io::image_loader bool is_valid = false; }; - // Load an image file (PNG, JPG, etc) & decode it to raw RGBA8 + // Load an image file (PNG, JPG, etc.) & decode it to raw RGBA8 ImageData load_image(const std::filesystem::path& path); } \ No newline at end of file diff --git a/engine/native/core/io/io.cppm b/Engine/cpp/runtime/core/io/io.cppm similarity index 100% rename from engine/native/core/io/io.cppm rename to Engine/cpp/runtime/core/io/io.cppm diff --git a/engine/native/core/math/constants.cppm b/Engine/cpp/runtime/core/math/constants.cppm similarity index 100% rename from engine/native/core/math/constants.cppm rename to Engine/cpp/runtime/core/math/constants.cppm diff --git a/engine/native/core/math/functions.cppm b/Engine/cpp/runtime/core/math/functions.cppm similarity index 100% rename from engine/native/core/math/functions.cppm rename to Engine/cpp/runtime/core/math/functions.cppm diff --git a/engine/native/core/math/math.cppm b/Engine/cpp/runtime/core/math/math.cppm similarity index 86% rename from engine/native/core/math/math.cppm rename to Engine/cpp/runtime/core/math/math.cppm index 9aedc64b..bf983a28 100644 --- a/engine/native/core/math/math.cppm +++ b/Engine/cpp/runtime/core/math/math.cppm @@ -1,8 +1,7 @@ export module core.math; +export import core.defs; export import core.math.constants; export import core.math.functions; export import core.math.types; -export import core.defs; -export import core.stdtypes; export import core.math.transform; diff --git a/engine/native/core/math/math.test.cpp b/Engine/cpp/runtime/core/math/math.test.cpp similarity index 79% rename from engine/native/core/math/math.test.cpp rename to Engine/cpp/runtime/core/math/math.test.cpp index 2424f921..55452830 100644 --- a/engine/native/core/math/math.test.cpp +++ b/Engine/cpp/runtime/core/math/math.test.cpp @@ -1,33 +1,4 @@ -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include -#include - -#define R_CHECK_EQ(L_expr, R_expr) { \ - const auto L_run = (L_expr); \ - const auto R_run = (R_expr); \ - static_assert(std::is_same_v); \ - CHECK_EQ(L_run, R_run); \ -} - -#define RAC_CHECK_EQ(L_expr, R_expr) { \ - static constexpr auto L_comp = (L_expr); \ - static constexpr auto R_comp = (R_expr); \ - static_assert(std::is_same_v); \ - static_assert(L_comp == R_comp); \ - R_CHECK_EQ(L_expr, R_expr); \ -} - -#define BASIC_R_SUBCASE(name, L_expr, R_expr) \ - SUBCASE(name) { R_CHECK_EQ(L_expr, R_expr); } - -#define BASIC_R_SUBCASE_2(name, L_expr1, R_expr1, L_expr2, R_expr2) \ - SUBCASE(name) { R_CHECK_EQ(L_expr1, R_expr1); R_CHECK_EQ(L_expr2, R_expr2); } - -#define BASIC_RAC_SUBCASE(name, L_expr, R_expr) \ - SUBCASE(name) { RAC_CHECK_EQ(L_expr, R_expr); } - -#define BASIC_RAC_SUBCASE_2(name, L_expr1, R_expr1, L_expr2, R_expr2) \ - SUBCASE(name) { RAC_CHECK_EQ(L_expr1, R_expr1); RAC_CHECK_EQ(L_expr2, R_expr2); } +#include import core.math; @@ -35,13 +6,13 @@ using namespace draco; TEST_SUITE("math") { TEST_CASE("pow") { - f32 result = draco::math::pow(2.0f, 0.5f); - constexpr f32 expected = draco::math::SQRT2; + f32 result = math::pow(2.0f, 0.5f); + constexpr f32 expected = math::SQRT2; CHECK_EQ(result, expected); } TEST_CASE("abs") { - using draco::math::abs; + using math::abs; RAC_CHECK_EQ(abs(-1.f), 1.f); RAC_CHECK_EQ(abs(4.56f), 4.56f); @@ -56,9 +27,9 @@ TEST_SUITE("math") { TEST_SUITE("vector2") { TEST_CASE("constructors") { - using draco::math::Vector2; - using draco::math::Vector3; - using draco::math::Vector4; + using math::Vector2; + using math::Vector3; + using math::Vector4; static constexpr Vector3 a{1.0f, 2.0f, 3.0f}; static constexpr Vector4 b{4.0f, 5.0f, 6.0f, 7.0f}; @@ -80,7 +51,7 @@ TEST_SUITE("vector2") { } TEST_CASE("access") { - using draco::math::Vector2; + using math::Vector2; static constexpr Vector2 v(1.0f, 2.0f); @@ -89,9 +60,9 @@ TEST_SUITE("vector2") { } TEST_CASE("swizzle") { - using draco::math::Vector2; - using draco::math::Vector3; - using draco::math::Vector4; + using math::Vector2; + using math::Vector3; + using math::Vector4; static constexpr Vector2 v{1.0f, 2.0f}; @@ -112,7 +83,7 @@ TEST_SUITE("vector2") { } TEST_CASE("swap") { - using draco::math::Vector2; + using math::Vector2; Vector2 a{1.f, 2.f}; Vector2 b{2.f, 1.f}; @@ -124,8 +95,8 @@ TEST_SUITE("vector2") { } TEST_CASE("dot") { - using draco::math::Vector2; - using draco::math::dot; + using math::Vector2; + using math::dot; static constexpr Vector2 a{1.0f, 2.0f}; static constexpr Vector2 b{3.0f, 4.0f}; @@ -147,9 +118,9 @@ TEST_SUITE("vector2") { } TEST_CASE("length") { - using draco::math::Vector2; - using draco::math::length; - using draco::math::length_sq; + using math::Vector2; + using math::length; + using math::length_sq; static constexpr Vector2 v{3.0f, 4.0f}; @@ -165,9 +136,9 @@ TEST_SUITE("vector2") { } TEST_CASE("distance") { - using draco::math::Vector2; - using draco::math::distance; - using draco::math::distance_sq; + using math::Vector2; + using math::distance; + using math::distance_sq; static constexpr Vector2 a{3.0f, 4.0f}; static constexpr Vector2 b{-3.0f, 12.0f}; @@ -184,10 +155,10 @@ TEST_SUITE("vector2") { } TEST_CASE("normalize") { - using draco::math::Vector2; - using draco::math::length; - using draco::math::normalize; - using draco::math::normalize_fast; + using math::Vector2; + using math::length; + using math::normalize; + using math::normalize_fast; static constexpr Vector2 a{3.0f, 4.0f}; static constexpr Vector2 b(1e-99); @@ -202,8 +173,8 @@ TEST_SUITE("vector2") { } TEST_CASE("project") { - using draco::math::Vector2; - using draco::math::project; + using math::Vector2; + using math::project; static constexpr Vector2 a{4.0f, 6.0f}; static constexpr Vector2 b{2.0f, 2.0f}; @@ -215,8 +186,8 @@ TEST_SUITE("vector2") { } TEST_CASE("reflect") { - using draco::math::Vector2; - using draco::math::reflect; + using math::Vector2; + using math::reflect; static constexpr Vector2 a{1.0f, 2.0f}; static constexpr Vector2 b{3.0f, 4.0f}; @@ -228,9 +199,9 @@ TEST_SUITE("vector2") { } TEST_CASE("angle") { - using draco::math::Vector2; - using draco::math::angle; - using draco::math::PI2; + using math::Vector2; + using math::angle; + using math::PI2; static constexpr Vector2 a{2.0f, 1.0f}; static constexpr Vector2 b{-2.0f, 4.0f}; @@ -242,8 +213,8 @@ TEST_SUITE("vector2") { } TEST_CASE("lerp") { - using draco::math::Vector2; - using draco::math::lerp; + using math::Vector2; + using math::lerp; static constexpr Vector2 a{1.0f, 2.0f}; static constexpr Vector2 b{3.0f, 4.0f}; @@ -275,8 +246,8 @@ TEST_SUITE("vector2") { } TEST_CASE("min") { - using draco::math::Vector2; - using draco::math::min; + using math::Vector2; + using math::min; static constexpr Vector2 a{5.0f, 3.0f}; static constexpr Vector2 b{1.0f, 7.0f}; @@ -297,9 +268,9 @@ TEST_SUITE("vector2") { } TEST_CASE("min_length") { - using draco::math::Vector2; - using draco::math::length; - using draco::math::min_length; + using math::Vector2; + using math::length; + using math::min_length; static constexpr Vector2 a{3.0f, 4.0f}; // len: 5 static constexpr Vector2 b{5.0f, 12.0f}; // len: 13 @@ -324,8 +295,8 @@ TEST_SUITE("vector2") { } TEST_CASE("max") { - using draco::math::Vector2; - using draco::math::max; + using math::Vector2; + using math::max; static constexpr Vector2 a{5.0f, 3.0f}; static constexpr Vector2 b{1.0f, 7.0f}; @@ -346,9 +317,9 @@ TEST_SUITE("vector2") { } TEST_CASE("max_length") { - using draco::math::Vector2; - using draco::math::length; - using draco::math::max_length; + using math::Vector2; + using math::length; + using math::max_length; static constexpr Vector2 a{3.0f, 4.0f}; // len: 5 static constexpr Vector2 b{5.0f, 12.0f}; // len: 13 @@ -373,8 +344,8 @@ TEST_SUITE("vector2") { } TEST_CASE("clamp") { - using draco::math::Vector2; - using draco::math::clamp; + using math::Vector2; + using math::clamp; static constexpr Vector2 a{5.0f, 3.0f}; static constexpr Vector2 b{1.0f, 7.0f}; @@ -392,9 +363,9 @@ TEST_SUITE("vector2") { } TEST_CASE("clamp_length") { - using draco::math::Vector2; - using draco::math::length; - using draco::math::clamp_length; + using math::Vector2; + using math::length; + using math::clamp_length; static constexpr Vector2 v{3.0f, 4.0f}; // len: 5 @@ -420,8 +391,8 @@ TEST_SUITE("vector2") { } TEST_CASE("abs") { - using draco::math::Vector2; - using draco::math::abs; + using math::Vector2; + using math::abs; RAC_CHECK_EQ( ( abs(Vector2{1.0f, -2.0f}) ), @@ -430,11 +401,11 @@ TEST_SUITE("vector2") { } TEST_CASE("rounding") { - using draco::math::Vector2; - using draco::math::floor; - using draco::math::ceil; - using draco::math::trunc; - using draco::math::round; + using math::Vector2; + using math::floor; + using math::ceil; + using math::trunc; + using math::round; static constexpr Vector2 a{0.5f, 1.4f}; static constexpr Vector2 b{-1.0f, 1.0f}; @@ -469,8 +440,8 @@ TEST_SUITE("vector2") { } TEST_CASE("sign") { - using draco::math::Vector2; - using draco::math::sign; + using math::Vector2; + using math::sign; RAC_CHECK_EQ( ( sign(Vector2{1.0f, -1.0f}) ), @@ -479,9 +450,9 @@ TEST_SUITE("vector2") { } TEST_CASE("approx_eq") { - using draco::math::Vector2; - using draco::math::approx_eq; - using draco::math::CMP_EPSILON; + using math::Vector2; + using math::approx_eq; + using math::CMP_EPSILON; static constexpr Vector2 v{1.0f, 2.0f}; static constexpr Vector2 offset = Vector2::x_axis(CMP_EPSILON); @@ -505,9 +476,9 @@ TEST_SUITE("vector2") { TEST_SUITE("vector3") { TEST_CASE("constructors") { - using draco::math::Vector2; - using draco::math::Vector3; - using draco::math::Vector4; + using math::Vector2; + using math::Vector3; + using math::Vector4; static constexpr Vector2 a{1.0f, 2.0f}; static constexpr Vector4 b{3.0f, 4.0f, 5.0f, 6.0f}; @@ -534,7 +505,7 @@ TEST_SUITE("vector3") { } TEST_CASE("access") { - using draco::math::Vector3; + using math::Vector3; static constexpr Vector3 v(1.0f, 2.0f, 3.0f); @@ -544,9 +515,9 @@ TEST_SUITE("vector3") { } TEST_CASE("swizzle") { - using draco::math::Vector2; - using draco::math::Vector3; - using draco::math::Vector4; + using math::Vector2; + using math::Vector3; + using math::Vector4; static constexpr Vector3 v{1.0f, 2.0f, 3.0f}; @@ -567,7 +538,7 @@ TEST_SUITE("vector3") { } TEST_CASE("swap") { - using draco::math::Vector3; + using math::Vector3; Vector3 a{1.f, 2.f, 3.f}; Vector3 b{3.f, 2.f, 1.f}; @@ -579,8 +550,8 @@ TEST_SUITE("vector3") { } TEST_CASE("dot") { - using draco::math::Vector3; - using draco::math::dot; + using math::Vector3; + using math::dot; static constexpr Vector3 a{1.0f, 2.0f, 3.0f}; static constexpr Vector3 b{4.0f, 5.0f, 6.0f}; @@ -602,9 +573,9 @@ TEST_SUITE("vector3") { } TEST_CASE("length") { - using draco::math::Vector3; - using draco::math::length; - using draco::math::length_sq; + using math::Vector3; + using math::length; + using math::length_sq; static constexpr Vector3 v{2.0f, 4.0f, 4.0f}; @@ -620,9 +591,9 @@ TEST_SUITE("vector3") { } TEST_CASE("distance") { - using draco::math::Vector3; - using draco::math::distance; - using draco::math::distance_sq; + using math::Vector3; + using math::distance; + using math::distance_sq; static constexpr Vector3 a{2.0f, 4.0f, 4.0f}; static constexpr Vector3 b{-1.0f, -2.0f, -2.0f}; @@ -639,10 +610,10 @@ TEST_SUITE("vector3") { } TEST_CASE("normalize") { - using draco::math::Vector3; - using draco::math::length; - using draco::math::normalize; - using draco::math::normalize_fast; + using math::Vector3; + using math::length; + using math::normalize; + using math::normalize_fast; static constexpr Vector3 a{0.0f, 6.4f, 4.8f}; static constexpr Vector3 b(1e-99); @@ -657,8 +628,8 @@ TEST_SUITE("vector3") { } TEST_CASE("project") { - using draco::math::Vector3; - using draco::math::project; + using math::Vector3; + using math::project; static constexpr Vector3 a{2.0f, 8.0f, 4.0f}; static constexpr Vector3 b{1.0f, 1.0f, 2.0f}; @@ -670,8 +641,8 @@ TEST_SUITE("vector3") { } TEST_CASE("reflect") { - using draco::math::Vector3; - using draco::math::reflect; + using math::Vector3; + using math::reflect; static constexpr Vector3 a{1.0f, 2.0f, 3.0f}; static constexpr Vector3 b{4.0f, 5.0f, 6.0f}; @@ -683,9 +654,9 @@ TEST_SUITE("vector3") { } TEST_CASE("angle") { - using draco::math::Vector3; - using draco::math::angle; - using draco::math::PI; + using math::Vector3; + using math::angle; + using math::PI; static constexpr Vector3 a{2.0f, 4.0f, 4.0f}; static constexpr Vector3 b{-4.0f, -8.0f, -8.0f}; @@ -697,8 +668,8 @@ TEST_SUITE("vector3") { } TEST_CASE("lerp") { - using draco::math::Vector3; - using draco::math::lerp; + using math::Vector3; + using math::lerp; static constexpr Vector3 a{1.0f, 2.0f, 3.0f}; static constexpr Vector3 b{4.0f, 5.0f, 6.0f}; @@ -730,8 +701,8 @@ TEST_SUITE("vector3") { } TEST_CASE("min") { - using draco::math::Vector3; - using draco::math::min; + using math::Vector3; + using math::min; static constexpr Vector3 a{5.0f, 8.0f, 3.0f}; static constexpr Vector3 b{1.0f, 6.0f, 7.0f}; @@ -752,9 +723,9 @@ TEST_SUITE("vector3") { } TEST_CASE("min_length") { - using draco::math::Vector3; - using draco::math::length; - using draco::math::min_length; + using math::Vector3; + using math::length; + using math::min_length; static constexpr Vector3 a{2.0f, 4.0f, 4.0f}; // len: 6 static constexpr Vector3 b{5.0f, 10.0f, 10.0f}; // len: 15 @@ -779,8 +750,8 @@ TEST_SUITE("vector3") { } TEST_CASE("max") { - using draco::math::Vector3; - using draco::math::max; + using math::Vector3; + using math::max; static constexpr Vector3 a{5.0f, 8.0f, 3.0f}; static constexpr Vector3 b{1.0f, 6.0f, 7.0f}; @@ -801,9 +772,9 @@ TEST_SUITE("vector3") { } TEST_CASE("max_length") { - using draco::math::Vector3; - using draco::math::length; - using draco::math::max_length; + using math::Vector3; + using math::length; + using math::max_length; static constexpr Vector3 a{2.0f, 4.0f, 4.0f}; // len: 6 static constexpr Vector3 b{5.0f, 10.0f, 10.0f}; // len: 15 @@ -828,8 +799,8 @@ TEST_SUITE("vector3") { } TEST_CASE("clamp") { - using draco::math::Vector3; - using draco::math::clamp; + using math::Vector3; + using math::clamp; static constexpr Vector3 a{5.0f, 8.0f, 3.0f}; static constexpr Vector3 b{1.0f, 6.0f, 7.0f}; @@ -847,9 +818,9 @@ TEST_SUITE("vector3") { } TEST_CASE("clamp_length") { - using draco::math::Vector3; - using draco::math::length; - using draco::math::clamp_length; + using math::Vector3; + using math::length; + using math::clamp_length; static constexpr Vector3 v{2.0f, 4.0f, 4.0f}; // len: 6 @@ -875,8 +846,8 @@ TEST_SUITE("vector3") { } TEST_CASE("abs") { - using draco::math::Vector3; - using draco::math::abs; + using math::Vector3; + using math::abs; RAC_CHECK_EQ( ( abs(Vector3{1.0f, -2.0f, 0.0f}) ), @@ -885,11 +856,11 @@ TEST_SUITE("vector3") { } TEST_CASE("rounding") { - using draco::math::Vector3; - using draco::math::floor; - using draco::math::ceil; - using draco::math::trunc; - using draco::math::round; + using math::Vector3; + using math::floor; + using math::ceil; + using math::trunc; + using math::round; static constexpr Vector3 a{0.5f, -0.5f, 1.4f}; static constexpr Vector3 b{-1.0f, 0.0f, 1.0f}; @@ -924,8 +895,8 @@ TEST_SUITE("vector3") { } TEST_CASE("sign") { - using draco::math::Vector3; - using draco::math::sign; + using math::Vector3; + using math::sign; RAC_CHECK_EQ( ( sign(Vector3{1.0f, -1.0f, 0.0f}) ), @@ -934,9 +905,9 @@ TEST_SUITE("vector3") { } TEST_CASE("approx_eq") { - using draco::math::Vector3; - using draco::math::approx_eq; - using draco::math::CMP_EPSILON; + using math::Vector3; + using math::approx_eq; + using math::CMP_EPSILON; static constexpr Vector3 v{1.0f, 2.0f, 3.0f}; static constexpr Vector3 offset = Vector3::x_axis(CMP_EPSILON); @@ -958,8 +929,8 @@ TEST_SUITE("vector3") { } TEST_CASE("cross") { - using draco::math::Vector3; - using draco::math::cross; + using math::Vector3; + using math::cross; RAC_CHECK_EQ( ( cross(Vector3::x_axis(), Vector3::y_axis()) ), @@ -970,9 +941,9 @@ TEST_SUITE("vector3") { TEST_SUITE("vector4") { TEST_CASE("constructors") { - using draco::math::Vector2; - using draco::math::Vector3; - using draco::math::Vector4; + using math::Vector2; + using math::Vector3; + using math::Vector4; static constexpr Vector2 a{1.0f, 2.0f}; static constexpr Vector3 b{3.0f, 4.0f, 5.0f}; @@ -1024,7 +995,7 @@ TEST_SUITE("vector4") { } TEST_CASE("access") { - using draco::math::Vector4; + using math::Vector4; static constexpr Vector4 v(1.0f, 2.0f, 3.0f, 4.0f); @@ -1035,9 +1006,9 @@ TEST_SUITE("vector4") { } TEST_CASE("swizzle") { - using draco::math::Vector2; - using draco::math::Vector3; - using draco::math::Vector4; + using math::Vector2; + using math::Vector3; + using math::Vector4; static constexpr Vector4 v{1.0f, 2.0f, 3.0f, 4.0f}; @@ -1058,7 +1029,7 @@ TEST_SUITE("vector4") { } TEST_CASE("swap") { - using draco::math::Vector4; + using math::Vector4; Vector4 a{1.f, 2.f, 3.f, 4.f}; Vector4 b{4.f, 3.f, 2.f, 1.f}; @@ -1070,8 +1041,8 @@ TEST_SUITE("vector4") { } TEST_CASE("dot") { - using draco::math::Vector4; - using draco::math::dot; + using math::Vector4; + using math::dot; static constexpr Vector4 a{1.0f, 2.0f, 3.0f, 4.0f}; static constexpr Vector4 b{5.0f, 6.0f, 7.0f, 8.0f}; @@ -1093,9 +1064,9 @@ TEST_SUITE("vector4") { } TEST_CASE("length") { - using draco::math::Vector4; - using draco::math::length; - using draco::math::length_sq; + using math::Vector4; + using math::length; + using math::length_sq; static constexpr Vector4 v{1.0f, 2.0f, 2.0f, 4.0f}; @@ -1111,9 +1082,9 @@ TEST_SUITE("vector4") { } TEST_CASE("distance") { - using draco::math::Vector4; - using draco::math::distance; - using draco::math::distance_sq; + using math::Vector4; + using math::distance; + using math::distance_sq; static constexpr Vector4 a{1.0f, 2.0f, 2.0f, 4.0f}; static constexpr Vector4 b{3.0f, 6.0f, 7.0f, 10.0f}; @@ -1130,10 +1101,10 @@ TEST_SUITE("vector4") { } TEST_CASE("normalize") { - using draco::math::Vector4; - using draco::math::length; - using draco::math::normalize; - using draco::math::normalize_fast; + using math::Vector4; + using math::length; + using math::normalize; + using math::normalize_fast; static constexpr Vector4 a{2.0f, 4.0f, 5.0f, 6.0f}; static constexpr Vector4 b(1e-99); @@ -1148,8 +1119,8 @@ TEST_SUITE("vector4") { } TEST_CASE("project") { - using draco::math::Vector4; - using draco::math::project; + using math::Vector4; + using math::project; static constexpr Vector4 a{8.0f, 2.0f, 6.0f, 8.0f}; static constexpr Vector4 b{12.0f, 14.0f, 8.0f, 6.0f}; @@ -1161,8 +1132,8 @@ TEST_SUITE("vector4") { } TEST_CASE("reflect") { - using draco::math::Vector4; - using draco::math::reflect; + using math::Vector4; + using math::reflect; static constexpr Vector4 a{1.0f, 2.0f, 3.0f, 4.0f}; static constexpr Vector4 b{5.0f, 6.0f, 7.0f, 8.0f}; @@ -1174,9 +1145,9 @@ TEST_SUITE("vector4") { } TEST_CASE("angle") { - using draco::math::Vector4; - using draco::math::angle; - using draco::math::PI2; + using math::Vector4; + using math::angle; + using math::PI2; static constexpr Vector4 a{1.0f, 5.0f, 1.0f, 3.0f}; static constexpr Vector4 b{2.0f, -6.0f, -2.0f, 10.0f}; @@ -1188,8 +1159,8 @@ TEST_SUITE("vector4") { } TEST_CASE("lerp") { - using draco::math::Vector4; - using draco::math::lerp; + using math::Vector4; + using math::lerp; static constexpr Vector4 a{1.0f, 2.0f, 3.0f, 4.0f}; static constexpr Vector4 b{5.0f, 6.0f, 7.0f, 8.0f}; @@ -1221,8 +1192,8 @@ TEST_SUITE("vector4") { } TEST_CASE("min") { - using draco::math::Vector4; - using draco::math::min; + using math::Vector4; + using math::min; static constexpr Vector4 a{5.0f, 8.0f, 3.0f, 4.0f}; static constexpr Vector4 b{1.0f, 6.0f, 7.0f, 2.0f}; @@ -1243,9 +1214,9 @@ TEST_SUITE("vector4") { } TEST_CASE("min_length") { - using draco::math::Vector4; - using draco::math::length; - using draco::math::min_length; + using math::Vector4; + using math::length; + using math::min_length; static constexpr Vector4 a{1.0f, 2.0f, 2.0f, 4.0f}; // len: 5 static constexpr Vector4 b{1.0f, -3.0f, -1.0f, 5.0f}; // len: 6 @@ -1270,8 +1241,8 @@ TEST_SUITE("vector4") { } TEST_CASE("max") { - using draco::math::Vector4; - using draco::math::max; + using math::Vector4; + using math::max; static constexpr Vector4 a{5.0f, 8.0f, 3.0f, 4.0f}; static constexpr Vector4 b{1.0f, 6.0f, 7.0f, 2.0f}; @@ -1292,9 +1263,9 @@ TEST_SUITE("vector4") { } TEST_CASE("max_length") { - using draco::math::Vector4; - using draco::math::length; - using draco::math::max_length; + using math::Vector4; + using math::length; + using math::max_length; static constexpr Vector4 a{1.0f, 2.0f, 2.0f, 4.0f}; // len: 5 static constexpr Vector4 b{1.0f, -3.0f, -1.0f, 5.0f}; // len: 6 @@ -1319,8 +1290,8 @@ TEST_SUITE("vector4") { } TEST_CASE("clamp") { - using draco::math::Vector4; - using draco::math::clamp; + using math::Vector4; + using math::clamp; static constexpr Vector4 a{5.0f, 8.0f, 3.0f, 4.0f}; static constexpr Vector4 b{1.0f, 6.0f, 7.0f, 2.0f}; @@ -1338,9 +1309,9 @@ TEST_SUITE("vector4") { } TEST_CASE("clamp_length") { - using draco::math::Vector4; - using draco::math::length; - using draco::math::clamp_length; + using math::Vector4; + using math::length; + using math::clamp_length; static constexpr Vector4 v{1.0f, -3.0f, -1.0f, 5.0f}; // len: 6 @@ -1366,8 +1337,8 @@ TEST_SUITE("vector4") { } TEST_CASE("abs") { - using draco::math::Vector4; - using draco::math::abs; + using math::Vector4; + using math::abs; RAC_CHECK_EQ( ( abs(Vector4{1.0f, -2.0f, -3.0f, 0.0f}) ), @@ -1376,11 +1347,11 @@ TEST_SUITE("vector4") { } TEST_CASE("rounding") { - using draco::math::Vector4; - using draco::math::floor; - using draco::math::ceil; - using draco::math::trunc; - using draco::math::round; + using math::Vector4; + using math::floor; + using math::ceil; + using math::trunc; + using math::round; static constexpr Vector4 a{0.5f, -0.5f, 1.4f, 1.6f}; static constexpr Vector4 b{-1.0f, 0.0f, 1.0f, 2.0f}; @@ -1415,8 +1386,8 @@ TEST_SUITE("vector4") { } TEST_CASE("sign") { - using draco::math::Vector4; - using draco::math::sign; + using math::Vector4; + using math::sign; RAC_CHECK_EQ( ( sign(Vector4{1.0f, -1.0f, 0.0f, -0.0f}) ), @@ -1425,9 +1396,9 @@ TEST_SUITE("vector4") { } TEST_CASE("approx_eq") { - using draco::math::Vector4; - using draco::math::approx_eq; - using draco::math::CMP_EPSILON; + using math::Vector4; + using math::approx_eq; + using math::CMP_EPSILON; static constexpr Vector4 v{1.0f, 2.0f, 3.0f, 4.0f}; static constexpr Vector4 offset = Vector4::x_axis(CMP_EPSILON); @@ -1447,4 +1418,20 @@ TEST_SUITE("vector4") { ( false ) ); } + + TEST_CASE("Transform") { + using math::Transform; + + static constexpr Transform transform; + STATIC_REQUIRE(transform.position[0] == 0.f); + STATIC_REQUIRE(transform.position[1] == 0.f); + STATIC_REQUIRE(transform.position[2] == 0.f); + STATIC_REQUIRE(transform.rotation[0] == 0.f); + STATIC_REQUIRE(transform.rotation[1] == 0.f); + STATIC_REQUIRE(transform.rotation[2] == 0.f); + STATIC_REQUIRE(transform.scale[0] == 1.f); + STATIC_REQUIRE(transform.scale[1] == 1.f); + STATIC_REQUIRE(transform.scale[2] == 1.f); + + } } \ No newline at end of file diff --git a/Engine/cpp/runtime/core/math/transform.cpp b/Engine/cpp/runtime/core/math/transform.cpp new file mode 100644 index 00000000..b1238927 --- /dev/null +++ b/Engine/cpp/runtime/core/math/transform.cpp @@ -0,0 +1,38 @@ +module; + +#include + +#include + +module core.math.transform; + +import core.stdtypes; + +namespace draco::math +{ + void Transform::to_matrix(f32 out[16]) const + { + f32 translation[16]; + f32 rx[16]; + f32 ry[16]; + f32 rz[16]; + f32 scale[16]; + f32 temp[16]; + + bx::mtxIdentity(out); + + bx::mtxScale(scale, scale[0], scale[1], scale[2]); + + bx::mtxRotateX(rx, rotation[0]); + bx::mtxRotateY(ry, rotation[1]); + bx::mtxRotateZ(rz, rotation[2]); + + bx::mtxTranslate(translation, position[0], position[1], position[2]); + + // scale * rotation * translation + bx::mtxMul(temp, scale, rx); + bx::mtxMul(temp, temp, ry); + bx::mtxMul(temp, temp, rz); + bx::mtxMul(out, temp, translation); + } +} diff --git a/Engine/cpp/runtime/core/math/transform.cppm b/Engine/cpp/runtime/core/math/transform.cppm new file mode 100644 index 00000000..06f85d5d --- /dev/null +++ b/Engine/cpp/runtime/core/math/transform.cppm @@ -0,0 +1,70 @@ +module; + +export module core.math.transform; +import core.math.types; +import core.stdtypes; + +export namespace draco::math +{ + struct Transform + { + f32 position[3] = { 0.0f, 0.0f, 0.0f }; + f32 rotation[3] = { 0.0f, 0.0f, 0.0f }; // Euler (radians) + f32 scale[3] = { 1.0f, 1.0f, 1.0f }; + + constexpr void set_position(f32 x, f32 y, f32 z) noexcept { + position[0] = x; + position[1] = y; + position[2] = z; + } + + constexpr void set_position(const Vector3& v) noexcept { + position[0] = v.x; + position[1] = v.y; + position[2] = v.z; + } + + [[nodiscard]] constexpr Vector3 get_position() const noexcept { + return Vector3{position[0], position[1], position[2]}; + } + + constexpr void set_rotation(f32 x, f32 y, f32 z) noexcept + { + rotation[0] = x; + rotation[1] = y; + rotation[2] = z; + } + + constexpr void set_rotation(const Vector3& v) noexcept + { + rotation[0] = v.x; + rotation[1] = v.y; + rotation[2] = v.z; + } + + [[nodiscard]] constexpr Vector3 get_rotation() const noexcept { + return Vector3{rotation[0], rotation[1], rotation[2]}; + } + + constexpr void set_scale(f32 x, f32 y, f32 z) noexcept + { + scale[0] = x; + scale[1] = y; + scale[2] = z; + } + + constexpr void set_scale(const Vector3& v) noexcept + { + scale[0] = v.x; + scale[1] = v.y; + scale[2] = v.z; + } + + [[nodiscard]] constexpr Vector3 get_scale() const noexcept { + return Vector3{scale[0], scale[1], scale[2]}; + } + + // Compute column-major matrix from transform + void to_matrix(f32 out[16]) const; + }; +} diff --git a/engine/native/core/math/types.cppm b/Engine/cpp/runtime/core/math/types.cppm similarity index 100% rename from engine/native/core/math/types.cppm rename to Engine/cpp/runtime/core/math/types.cppm diff --git a/engine/native/core/math/types_common.cppm b/Engine/cpp/runtime/core/math/types_common.cppm similarity index 87% rename from engine/native/core/math/types_common.cppm rename to Engine/cpp/runtime/core/math/types_common.cppm index 089faa2a..4de2e55e 100644 --- a/engine/native/core/math/types_common.cppm +++ b/Engine/cpp/runtime/core/math/types_common.cppm @@ -1,6 +1,5 @@ export module core.math.types:common; import core.defs; -import core.stdtypes; export namespace draco::math { struct Vector2; @@ -27,11 +26,8 @@ export namespace draco::math { [[nodiscard]] constexpr const f32& operator[](i32 i) const noexcept; // swizzle - [[nodiscard]] constexpr Vector2 operator[](i32 i0, i32 i1) noexcept; [[nodiscard]] constexpr Vector2 operator[](i32 i0, i32 i1) const noexcept; - [[nodiscard]] constexpr Vector3 operator[](i32 i0, i32 i1, i32 i2) noexcept; [[nodiscard]] constexpr Vector3 operator[](i32 i0, i32 i1, i32 i2) const noexcept; - [[nodiscard]] constexpr Vector4 operator[](i32 i0, i32 i1, i32 i2, i32 i3) noexcept; [[nodiscard]] constexpr Vector4 operator[](i32 i0, i32 i1, i32 i2, i32 i3) const noexcept; // operators @@ -72,11 +68,8 @@ export namespace draco::math { [[nodiscard]] constexpr const f32& operator[](i32 i) const noexcept; // swizzle - [[nodiscard]] constexpr Vector2 operator[](i32 i0, i32 i1) noexcept; [[nodiscard]] constexpr Vector2 operator[](i32 i0, i32 i1) const noexcept; - [[nodiscard]] constexpr Vector3 operator[](i32 i0, i32 i1, i32 i2) noexcept; [[nodiscard]] constexpr Vector3 operator[](i32 i0, i32 i1, i32 i2) const noexcept; - [[nodiscard]] constexpr Vector4 operator[](i32 i0, i32 i1, i32 i2, i32 i3) noexcept; [[nodiscard]] constexpr Vector4 operator[](i32 i0, i32 i1, i32 i2, i32 i3) const noexcept; // operators @@ -120,11 +113,8 @@ export namespace draco::math { [[nodiscard]] constexpr const f32& operator[](i32 i) const noexcept; // swizzle - [[nodiscard]] constexpr Vector2 operator[](i32 i0, i32 i1) noexcept; [[nodiscard]] constexpr Vector2 operator[](i32 i0, i32 i1) const noexcept; - [[nodiscard]] constexpr Vector3 operator[](i32 i0, i32 i1, i32 i2) noexcept; [[nodiscard]] constexpr Vector3 operator[](i32 i0, i32 i1, i32 i2) const noexcept; - [[nodiscard]] constexpr Vector4 operator[](i32 i0, i32 i1, i32 i2, i32 i3) noexcept; [[nodiscard]] constexpr Vector4 operator[](i32 i0, i32 i1, i32 i2, i32 i3) const noexcept; // member operators @@ -143,7 +133,8 @@ export namespace draco::math { }; } -template consteval T select(const draco::i32 i, const T v1, const T v2) { +template +consteval const T& select(const draco::i32 i, const T& v1, const T& v2) { switch (i) { case 0: return v1; case 1: return v2; @@ -151,16 +142,48 @@ template consteval T select(const draco::i32 i, const T v1, const T } } -template consteval T select(const draco::i32 i, const T v1, const T v2, const T v3) { +template +consteval T& select(const draco::i32 i, T& v1, T& v2) { + switch (i) { + case 0: return v1; + case 1: return v2; + default: throw "Index out of range"; + } +} + +template +consteval const T& select(const draco::i32 i, const T& v1, const T& v2, const T& v3) { + switch (i) { + case 0: return v1; + case 1: return v2; + case 2: return v3; + default: throw "Index out of range"; + } +} + +template +consteval T& select(const draco::i32 i, T& v1, T& v2, T& v3) { + switch (i) { + case 0: return v1; + case 1: return v2; + case 2: return v3; + default: throw "Index out of range"; + } +} + +template +consteval const T& select(const draco::i32 i, const T& v1, const T& v2, const T& v3, const T& v4) { switch (i) { case 0: return v1; case 1: return v2; case 2: return v3; + case 3: return v4; default: throw "Index out of range"; } } -template consteval T select(const draco::i32 i, const T v1, const T v2, const T v3, const T v4) { +template +consteval T& select(const draco::i32 i, T& v1, T& v2, T& v3, T& v4) { switch (i) { case 0: return v1; case 1: return v2; diff --git a/engine/native/core/math/vector2.cppm b/Engine/cpp/runtime/core/math/vector2.cppm similarity index 92% rename from engine/native/core/math/vector2.cppm rename to Engine/cpp/runtime/core/math/vector2.cppm index a20b6e3a..fd0e1e31 100644 --- a/engine/native/core/math/vector2.cppm +++ b/Engine/cpp/runtime/core/math/vector2.cppm @@ -1,15 +1,7 @@ module; #include -#include #include -#include "platform/simd.h" - -#if ARCH_X64 - #include -#elif ARCH_ARM64 - #include -#endif export module core.math.types:vector2; export import :common; @@ -55,7 +47,7 @@ export namespace draco::math { // element access [[nodiscard]] constexpr f32& Vector2::operator[](const i32 i) noexcept { if consteval { - return i ? y : x; + return select(i, x, y); } else { return (&x)[i]; } @@ -63,21 +55,13 @@ export namespace draco::math { [[nodiscard]] constexpr const f32& Vector2::operator[](const i32 i) const noexcept { if consteval { - return i ? y : x; + return select(i, x, y); } else { return (&x)[i]; } } // swizzle - [[nodiscard]] constexpr Vector2 Vector2::operator[](const i32 i0, const i32 i1) noexcept { - if consteval { - return { select(i0, x, y), select(i1, x, y) }; - } else { - return { (&x)[i0], (&x)[i1] }; - } - } - [[nodiscard]] constexpr Vector2 Vector2::operator[](const i32 i0, const i32 i1) const noexcept { if consteval { return { select(i0, x, y), select(i1, x, y) }; @@ -86,14 +70,6 @@ export namespace draco::math { } } - [[nodiscard]] constexpr Vector3 Vector2::operator[](const i32 i0, const i32 i1, const i32 i2) noexcept { - if consteval { - return { select(i0, x, y), select(i1, x, y), select(i2, x, y) }; - } else { - return { (&x)[i0], (&x)[i1], (&x)[i2] }; - } - } - [[nodiscard]] constexpr Vector3 Vector2::operator[](const i32 i0, const i32 i1, const i32 i2) const noexcept { if consteval { return { select(i0, x, y), select(i1, x, y), select(i2, x, y) }; @@ -102,14 +78,6 @@ export namespace draco::math { } } - [[nodiscard]] constexpr Vector4 Vector2::operator[](const i32 i0, const i32 i1, const i32 i2, const i32 i3) noexcept { - if consteval { - return { select(i0, x, y), select(i1, x, y), select(i2, x, y), select(i3, x, y) }; - } else { - return { (&x)[i0], (&x)[i1], (&x)[i2], (&x)[i3] }; - } - } - [[nodiscard]] constexpr Vector4 Vector2::operator[](const i32 i0, const i32 i1, const i32 i2, const i32 i3) const noexcept { if consteval { return { select(i0, x, y), select(i1, x, y), select(i2, x, y), select(i3, x, y) }; diff --git a/engine/native/core/math/vector3.cppm b/Engine/cpp/runtime/core/math/vector3.cppm similarity index 91% rename from engine/native/core/math/vector3.cppm rename to Engine/cpp/runtime/core/math/vector3.cppm index 05240c01..fe8e8a2f 100644 --- a/engine/native/core/math/vector3.cppm +++ b/Engine/cpp/runtime/core/math/vector3.cppm @@ -1,15 +1,7 @@ module; #include -#include #include -#include "platform/simd.h" - -#if ARCH_X64 - #include -#elif ARCH_ARM64 - #include -#endif export module core.math.types:vector3; export import :common; @@ -67,35 +59,17 @@ export namespace draco::math { // element access [[nodiscard]] constexpr f32& Vector3::operator[](const i32 i) noexcept { if consteval { - switch (i) { - case 0: return x; - case 1: return y; - default: - case 2: return z; - } + return select(i, x, y, z); } else { return (&x)[i]; } } [[nodiscard]] constexpr const f32& Vector3::operator[](const i32 i) const noexcept { if consteval { - switch (i) { - case 0: return x; - case 1: return y; - default: - case 2: return z; - } + return select(i, x, y, z); } else { return (&x)[i]; } } // swizzle - [[nodiscard]] constexpr Vector2 Vector3::operator[](const i32 i0, const i32 i1) noexcept { - if consteval { - return { select(i0, x, y, z), select(i1, x, y, z) }; - } else { - return { (&x)[i0], (&x)[i1] }; - } - } - [[nodiscard]] constexpr Vector2 Vector3::operator[](const i32 i0, const i32 i1) const noexcept { if consteval { return { select(i0, x, y, z), select(i1, x, y, z) }; @@ -104,14 +78,6 @@ export namespace draco::math { } } - [[nodiscard]] constexpr Vector3 Vector3::operator[](const i32 i0, const i32 i1, const i32 i2) noexcept { - if consteval { - return { select(i0, x, y, z), select(i1, x, y, z), select(i2, x, y, z) }; - } else { - return { (&x)[i0], (&x)[i1], (&x)[i2] }; - } - } - [[nodiscard]] constexpr Vector3 Vector3::operator[](const i32 i0, const i32 i1, const i32 i2) const noexcept { if consteval { return { select(i0, x, y, z), select(i1, x, y, z), select(i2, x, y, z) }; @@ -120,14 +86,6 @@ export namespace draco::math { } } - [[nodiscard]] constexpr Vector4 Vector3::operator[](const i32 i0, const i32 i1, const i32 i2, const i32 i3) noexcept { - if consteval { - return { select(i0, x, y, z), select(i1, x, y, z), select(i2, x, y, z), select(i3, x, y, z) }; - } else { - return { (&x)[i0], (&x)[i1], (&x)[i2], (&x)[i3] }; - } - } - [[nodiscard]] constexpr Vector4 Vector3::operator[](const i32 i0, const i32 i1, const i32 i2, const i32 i3) const noexcept { if consteval { return { select(i0, x, y, z), select(i1, x, y, z), select(i2, x, y, z), select(i3, x, y, z) }; diff --git a/engine/native/core/math/vector4.cppm b/Engine/cpp/runtime/core/math/vector4.cppm similarity index 91% rename from engine/native/core/math/vector4.cppm rename to Engine/cpp/runtime/core/math/vector4.cppm index d2ddcd40..850daef1 100644 --- a/engine/native/core/math/vector4.cppm +++ b/Engine/cpp/runtime/core/math/vector4.cppm @@ -1,15 +1,7 @@ module; #include -#include #include -#include "platform/simd.h" - -#if ARCH_X64 - #include -#elif ARCH_ARM64 - #include -#endif export module core.math.types:vector4; export import :common; @@ -74,37 +66,17 @@ export namespace draco::math { // element access [[nodiscard]] constexpr f32& Vector4::operator[](const i32 i) noexcept { if consteval { - switch (i) { - case 0: return x; - case 1: return y; - case 2: return z; - default: - case 3: return w; - } + return select(i, x, y, z, w); } else { return (&x)[i]; } } [[nodiscard]] constexpr const f32& Vector4::operator[](const i32 i) const noexcept { if consteval { - switch (i) { - case 0: return x; - case 1: return y; - case 2: return z; - default: - case 3: return w; - } + return select(i, x, y, z, w); } else { return (&x)[i]; } } // swizzle - [[nodiscard]] constexpr Vector2 Vector4::operator[](const i32 i0, const i32 i1) noexcept { - if consteval { - return { select(i0, x, y, z, w), select(i1, x, y, z, w) }; - } else { - return { (&x)[i0], (&x)[i1] }; - } - } - [[nodiscard]] constexpr Vector2 Vector4::operator[](const i32 i0, const i32 i1) const noexcept { if consteval { return { select(i0, x, y, z, w), select(i1, x, y, z, w) }; @@ -113,14 +85,6 @@ export namespace draco::math { } } - [[nodiscard]] constexpr Vector3 Vector4::operator[](const i32 i0, const i32 i1, const i32 i2) noexcept { - if consteval { - return { select(i0, x, y, z, w), select(i1, x, y, z, w), select(i2, x, y, z, w) }; - } else { - return { (&x)[i0], (&x)[i1], (&x)[i2] }; - } - } - [[nodiscard]] constexpr Vector3 Vector4::operator[](const i32 i0, const i32 i1, const i32 i2) const noexcept { if consteval { return { select(i0, x, y, z, w), select(i1, x, y, z, w), select(i2, x, y, z, w) }; @@ -129,14 +93,6 @@ export namespace draco::math { } } - [[nodiscard]] constexpr Vector4 Vector4::operator[](const i32 i0, const i32 i1, const i32 i2, const i32 i3) noexcept { - if consteval { - return { select(i0, x, y, z, w), select(i1, x, y, z, w), select(i2, x, y, z, w), select(i3, x, y, z, w) }; - } else { - return { (&x)[i0], (&x)[i1], (&x)[i2], (&x)[i3] }; - } - } - [[nodiscard]] constexpr Vector4 Vector4::operator[](const i32 i0, const i32 i1, const i32 i2, const i32 i3) const noexcept { if consteval { return { select(i0, x, y, z, w), select(i1, x, y, z, w), select(i2, x, y, z, w), select(i3, x, y, z, w) }; diff --git a/engine/native/core/memory/allocator.cpp b/Engine/cpp/runtime/core/memory/allocator.cpp similarity index 100% rename from engine/native/core/memory/allocator.cpp rename to Engine/cpp/runtime/core/memory/allocator.cpp diff --git a/engine/native/core/memory/allocator.cppm b/Engine/cpp/runtime/core/memory/allocator.cppm similarity index 100% rename from engine/native/core/memory/allocator.cppm rename to Engine/cpp/runtime/core/memory/allocator.cppm diff --git a/engine/native/core/memory/bumpAllocator.cpp b/Engine/cpp/runtime/core/memory/bumpAllocator.cpp similarity index 100% rename from engine/native/core/memory/bumpAllocator.cpp rename to Engine/cpp/runtime/core/memory/bumpAllocator.cpp diff --git a/engine/native/core/memory/bumpAllocator.cppm b/Engine/cpp/runtime/core/memory/bumpAllocator.cppm similarity index 100% rename from engine/native/core/memory/bumpAllocator.cppm rename to Engine/cpp/runtime/core/memory/bumpAllocator.cppm diff --git a/engine/native/core/memory/bumpAllocator.test.cpp b/Engine/cpp/runtime/core/memory/bumpAllocator.test.cpp similarity index 98% rename from engine/native/core/memory/bumpAllocator.test.cpp rename to Engine/cpp/runtime/core/memory/bumpAllocator.test.cpp index fded289d..60c434d9 100644 --- a/engine/native/core/memory/bumpAllocator.test.cpp +++ b/Engine/cpp/runtime/core/memory/bumpAllocator.test.cpp @@ -1,5 +1,4 @@ -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include +#include import core.memory; import core.stdtypes; diff --git a/engine/native/core/memory/fixedAllocator.cpp b/Engine/cpp/runtime/core/memory/fixedAllocator.cpp similarity index 100% rename from engine/native/core/memory/fixedAllocator.cpp rename to Engine/cpp/runtime/core/memory/fixedAllocator.cpp diff --git a/engine/native/core/memory/fixedAllocator.cppm b/Engine/cpp/runtime/core/memory/fixedAllocator.cppm similarity index 100% rename from engine/native/core/memory/fixedAllocator.cppm rename to Engine/cpp/runtime/core/memory/fixedAllocator.cppm diff --git a/engine/native/core/memory/fixedAllocator.test.cpp b/Engine/cpp/runtime/core/memory/fixedAllocator.test.cpp similarity index 86% rename from engine/native/core/memory/fixedAllocator.test.cpp rename to Engine/cpp/runtime/core/memory/fixedAllocator.test.cpp index 83766123..6a7cc3bf 100644 --- a/engine/native/core/memory/fixedAllocator.test.cpp +++ b/Engine/cpp/runtime/core/memory/fixedAllocator.test.cpp @@ -1,5 +1,4 @@ -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include +#include import core.memory; import core.stdtypes; diff --git a/engine/native/core/memory/handle.cppm b/Engine/cpp/runtime/core/memory/handle.cppm similarity index 100% rename from engine/native/core/memory/handle.cppm rename to Engine/cpp/runtime/core/memory/handle.cppm diff --git a/engine/native/core/memory/handle_registry.cppm b/Engine/cpp/runtime/core/memory/handle_registry.cppm similarity index 100% rename from engine/native/core/memory/handle_registry.cppm rename to Engine/cpp/runtime/core/memory/handle_registry.cppm diff --git a/engine/native/core/memory/pageAllocator.cpp b/Engine/cpp/runtime/core/memory/pageAllocator.cpp similarity index 100% rename from engine/native/core/memory/pageAllocator.cpp rename to Engine/cpp/runtime/core/memory/pageAllocator.cpp diff --git a/engine/native/core/memory/pageAllocator.cppm b/Engine/cpp/runtime/core/memory/pageAllocator.cppm similarity index 100% rename from engine/native/core/memory/pageAllocator.cppm rename to Engine/cpp/runtime/core/memory/pageAllocator.cppm diff --git a/engine/native/core/memory/root.cppm b/Engine/cpp/runtime/core/memory/root.cppm similarity index 100% rename from engine/native/core/memory/root.cppm rename to Engine/cpp/runtime/core/memory/root.cppm diff --git a/engine/native/core/memory/slice.cppm b/Engine/cpp/runtime/core/memory/slice.cppm similarity index 100% rename from engine/native/core/memory/slice.cppm rename to Engine/cpp/runtime/core/memory/slice.cppm diff --git a/engine/native/core/memory/slot_array.cppm b/Engine/cpp/runtime/core/memory/slot_array.cppm similarity index 100% rename from engine/native/core/memory/slot_array.cppm rename to Engine/cpp/runtime/core/memory/slot_array.cppm diff --git a/engine/native/core/memory/trackingAllocator.cpp b/Engine/cpp/runtime/core/memory/trackingAllocator.cpp similarity index 100% rename from engine/native/core/memory/trackingAllocator.cpp rename to Engine/cpp/runtime/core/memory/trackingAllocator.cpp diff --git a/engine/native/core/memory/trackingAllocator.cppm b/Engine/cpp/runtime/core/memory/trackingAllocator.cppm similarity index 100% rename from engine/native/core/memory/trackingAllocator.cppm rename to Engine/cpp/runtime/core/memory/trackingAllocator.cppm diff --git a/engine/native/core/memory/trackingAllocator.test.cpp b/Engine/cpp/runtime/core/memory/trackingAllocator.test.cpp similarity index 95% rename from engine/native/core/memory/trackingAllocator.test.cpp rename to Engine/cpp/runtime/core/memory/trackingAllocator.test.cpp index 2a1ece42..ef10f7be 100644 --- a/engine/native/core/memory/trackingAllocator.test.cpp +++ b/Engine/cpp/runtime/core/memory/trackingAllocator.test.cpp @@ -1,5 +1,4 @@ -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include +#include import core.memory; import core.memory.slice; diff --git a/engine/native/draconic.cppm b/Engine/cpp/runtime/draconic.cppm similarity index 100% rename from engine/native/draconic.cppm rename to Engine/cpp/runtime/draconic.cppm diff --git a/engine/native/input/input.cpp b/Engine/cpp/runtime/input/input.cpp similarity index 100% rename from engine/native/input/input.cpp rename to Engine/cpp/runtime/input/input.cpp diff --git a/engine/native/input/input.cppm b/Engine/cpp/runtime/input/input.cppm similarity index 100% rename from engine/native/input/input.cppm rename to Engine/cpp/runtime/input/input.cppm diff --git a/engine/native/platform/CMakeLists.txt b/Engine/cpp/runtime/platform/CMakeLists.txt similarity index 100% rename from engine/native/platform/CMakeLists.txt rename to Engine/cpp/runtime/platform/CMakeLists.txt diff --git a/engine/native/platform/cpu/cpu_info.h b/Engine/cpp/runtime/platform/cpu/cpu_info.h similarity index 100% rename from engine/native/platform/cpu/cpu_info.h rename to Engine/cpp/runtime/platform/cpu/cpu_info.h diff --git a/engine/native/platform/cpu/cpu_info_neon.cpp b/Engine/cpp/runtime/platform/cpu/cpu_info_neon.cpp similarity index 100% rename from engine/native/platform/cpu/cpu_info_neon.cpp rename to Engine/cpp/runtime/platform/cpu/cpu_info_neon.cpp diff --git a/engine/native/platform/cpu/cpu_info_x64.cpp b/Engine/cpp/runtime/platform/cpu/cpu_info_x64.cpp similarity index 100% rename from engine/native/platform/cpu/cpu_info_x64.cpp rename to Engine/cpp/runtime/platform/cpu/cpu_info_x64.cpp diff --git a/engine/native/platform/impl/CMakeLists.txt b/Engine/cpp/runtime/platform/impl/CMakeLists.txt similarity index 100% rename from engine/native/platform/impl/CMakeLists.txt rename to Engine/cpp/runtime/platform/impl/CMakeLists.txt diff --git a/engine/native/platform/impl/linux/linux.cpp b/Engine/cpp/runtime/platform/impl/linux/linux.cpp similarity index 100% rename from engine/native/platform/impl/linux/linux.cpp rename to Engine/cpp/runtime/platform/impl/linux/linux.cpp diff --git a/engine/native/platform/impl/mac/mac.mm b/Engine/cpp/runtime/platform/impl/mac/mac.mm similarity index 100% rename from engine/native/platform/impl/mac/mac.mm rename to Engine/cpp/runtime/platform/impl/mac/mac.mm diff --git a/engine/native/platform/impl/platform_impl.h b/Engine/cpp/runtime/platform/impl/platform_impl.h similarity index 100% rename from engine/native/platform/impl/platform_impl.h rename to Engine/cpp/runtime/platform/impl/platform_impl.h diff --git a/engine/native/platform/impl/win32/win32.cpp b/Engine/cpp/runtime/platform/impl/win32/win32.cpp similarity index 100% rename from engine/native/platform/impl/win32/win32.cpp rename to Engine/cpp/runtime/platform/impl/win32/win32.cpp diff --git a/engine/native/platform/platform.cppm b/Engine/cpp/runtime/platform/platform.cppm similarity index 100% rename from engine/native/platform/platform.cppm rename to Engine/cpp/runtime/platform/platform.cppm diff --git a/engine/native/platform/simd.h b/Engine/cpp/runtime/platform/simd.h similarity index 100% rename from engine/native/platform/simd.h rename to Engine/cpp/runtime/platform/simd.h diff --git a/engine/native/rendering/CMakeLists.txt b/Engine/cpp/runtime/rendering/CMakeLists.txt similarity index 100% rename from engine/native/rendering/CMakeLists.txt rename to Engine/cpp/runtime/rendering/CMakeLists.txt diff --git a/engine/native/rendering/material/material.cppm b/Engine/cpp/runtime/rendering/material/material.cppm similarity index 100% rename from engine/native/rendering/material/material.cppm rename to Engine/cpp/runtime/rendering/material/material.cppm diff --git a/engine/native/rendering/mesh/mesh.cpp b/Engine/cpp/runtime/rendering/mesh/mesh.cpp similarity index 100% rename from engine/native/rendering/mesh/mesh.cpp rename to Engine/cpp/runtime/rendering/mesh/mesh.cpp diff --git a/engine/native/rendering/mesh/mesh.cppm b/Engine/cpp/runtime/rendering/mesh/mesh.cppm similarity index 100% rename from engine/native/rendering/mesh/mesh.cppm rename to Engine/cpp/runtime/rendering/mesh/mesh.cppm diff --git a/engine/native/rendering/quad_renderer/quad_renderer.cpp b/Engine/cpp/runtime/rendering/quad_renderer/quad_renderer.cpp similarity index 100% rename from engine/native/rendering/quad_renderer/quad_renderer.cpp rename to Engine/cpp/runtime/rendering/quad_renderer/quad_renderer.cpp diff --git a/engine/native/rendering/quad_renderer/quad_renderer.cppm b/Engine/cpp/runtime/rendering/quad_renderer/quad_renderer.cppm similarity index 100% rename from engine/native/rendering/quad_renderer/quad_renderer.cppm rename to Engine/cpp/runtime/rendering/quad_renderer/quad_renderer.cppm diff --git a/engine/native/rendering/renderer/renderer.cpp b/Engine/cpp/runtime/rendering/renderer/renderer.cpp similarity index 96% rename from engine/native/rendering/renderer/renderer.cpp rename to Engine/cpp/runtime/rendering/renderer/renderer.cpp index 0859b5ed..e6506a8c 100644 --- a/engine/native/rendering/renderer/renderer.cpp +++ b/Engine/cpp/runtime/rendering/renderer/renderer.cpp @@ -117,10 +117,7 @@ namespace draco::rendering::renderer build_uniforms(material, p.uniforms); - f32 model[16]; - draco::math::compute_matrix(transform, model); - - std::memcpy(p.model, model, sizeof(model)); + transform.to_matrix(p.model); submit_entity(p); } diff --git a/engine/native/rendering/renderer/renderer.cppm b/Engine/cpp/runtime/rendering/renderer/renderer.cppm similarity index 100% rename from engine/native/rendering/renderer/renderer.cppm rename to Engine/cpp/runtime/rendering/renderer/renderer.cppm diff --git a/engine/native/rendering/rendergraph/rendergraph.cpp b/Engine/cpp/runtime/rendering/rendergraph/rendergraph.cpp similarity index 100% rename from engine/native/rendering/rendergraph/rendergraph.cpp rename to Engine/cpp/runtime/rendering/rendergraph/rendergraph.cpp diff --git a/engine/native/rendering/rendergraph/rendergraph.cppm b/Engine/cpp/runtime/rendering/rendergraph/rendergraph.cppm similarity index 100% rename from engine/native/rendering/rendergraph/rendergraph.cppm rename to Engine/cpp/runtime/rendering/rendergraph/rendergraph.cppm diff --git a/engine/native/rendering/rendering.cppm b/Engine/cpp/runtime/rendering/rendering.cppm similarity index 100% rename from engine/native/rendering/rendering.cppm rename to Engine/cpp/runtime/rendering/rendering.cppm diff --git a/engine/native/rendering/rhi/buffers.cpp b/Engine/cpp/runtime/rendering/rhi/buffers.cpp similarity index 100% rename from engine/native/rendering/rhi/buffers.cpp rename to Engine/cpp/runtime/rendering/rhi/buffers.cpp diff --git a/engine/native/rendering/rhi/commands.cpp b/Engine/cpp/runtime/rendering/rhi/commands.cpp similarity index 100% rename from engine/native/rendering/rhi/commands.cpp rename to Engine/cpp/runtime/rendering/rhi/commands.cpp diff --git a/engine/native/rendering/rhi/core.cpp b/Engine/cpp/runtime/rendering/rhi/core.cpp similarity index 100% rename from engine/native/rendering/rhi/core.cpp rename to Engine/cpp/runtime/rendering/rhi/core.cpp diff --git a/engine/native/rendering/rhi/macros.h b/Engine/cpp/runtime/rendering/rhi/macros.h similarity index 100% rename from engine/native/rendering/rhi/macros.h rename to Engine/cpp/runtime/rendering/rhi/macros.h diff --git a/engine/native/rendering/rhi/pipelines.cpp b/Engine/cpp/runtime/rendering/rhi/pipelines.cpp similarity index 100% rename from engine/native/rendering/rhi/pipelines.cpp rename to Engine/cpp/runtime/rendering/rhi/pipelines.cpp diff --git a/engine/native/rendering/rhi/rhi.cppm b/Engine/cpp/runtime/rendering/rhi/rhi.cppm similarity index 100% rename from engine/native/rendering/rhi/rhi.cppm rename to Engine/cpp/runtime/rendering/rhi/rhi.cppm diff --git a/engine/native/rendering/rhi/texture.cpp b/Engine/cpp/runtime/rendering/rhi/texture.cpp similarity index 100% rename from engine/native/rendering/rhi/texture.cpp rename to Engine/cpp/runtime/rendering/rhi/texture.cpp diff --git a/engine/native/rendering/rhi/uniform_registry.cppm b/Engine/cpp/runtime/rendering/rhi/uniform_registry.cppm similarity index 100% rename from engine/native/rendering/rhi/uniform_registry.cppm rename to Engine/cpp/runtime/rendering/rhi/uniform_registry.cppm diff --git a/engine/native/rendering/rhi/vertex.cppm b/Engine/cpp/runtime/rendering/rhi/vertex.cppm similarity index 100% rename from engine/native/rendering/rhi/vertex.cppm rename to Engine/cpp/runtime/rendering/rhi/vertex.cppm diff --git a/engine/native/rendering/shaders/fs.sc b/Engine/cpp/runtime/rendering/shaders/fs.sc similarity index 100% rename from engine/native/rendering/shaders/fs.sc rename to Engine/cpp/runtime/rendering/shaders/fs.sc diff --git a/engine/native/rendering/shaders/fs_quad.sc b/Engine/cpp/runtime/rendering/shaders/fs_quad.sc similarity index 100% rename from engine/native/rendering/shaders/fs_quad.sc rename to Engine/cpp/runtime/rendering/shaders/fs_quad.sc diff --git a/engine/native/rendering/shaders/varying.def.sc b/Engine/cpp/runtime/rendering/shaders/varying.def.sc similarity index 100% rename from engine/native/rendering/shaders/varying.def.sc rename to Engine/cpp/runtime/rendering/shaders/varying.def.sc diff --git a/engine/native/rendering/shaders/varying_quad.def.sc b/Engine/cpp/runtime/rendering/shaders/varying_quad.def.sc similarity index 100% rename from engine/native/rendering/shaders/varying_quad.def.sc rename to Engine/cpp/runtime/rendering/shaders/varying_quad.def.sc diff --git a/engine/native/rendering/shaders/vs.sc b/Engine/cpp/runtime/rendering/shaders/vs.sc similarity index 100% rename from engine/native/rendering/shaders/vs.sc rename to Engine/cpp/runtime/rendering/shaders/vs.sc diff --git a/engine/native/rendering/shaders/vs_quad.sc b/Engine/cpp/runtime/rendering/shaders/vs_quad.sc similarity index 100% rename from engine/native/rendering/shaders/vs_quad.sc rename to Engine/cpp/runtime/rendering/shaders/vs_quad.sc diff --git a/engine/native/scene/CMakeLists.txt b/Engine/cpp/runtime/scene/CMakeLists.txt similarity index 100% rename from engine/native/scene/CMakeLists.txt rename to Engine/cpp/runtime/scene/CMakeLists.txt diff --git a/engine/native/scene/camera/camera_controller.cpp b/Engine/cpp/runtime/scene/camera/camera_controller.cpp similarity index 100% rename from engine/native/scene/camera/camera_controller.cpp rename to Engine/cpp/runtime/scene/camera/camera_controller.cpp diff --git a/engine/native/scene/camera/camera_controller.cppm b/Engine/cpp/runtime/scene/camera/camera_controller.cppm similarity index 100% rename from engine/native/scene/camera/camera_controller.cppm rename to Engine/cpp/runtime/scene/camera/camera_controller.cppm diff --git a/engine/native/scene/renderable/renderable.cppm b/Engine/cpp/runtime/scene/renderable/renderable.cppm similarity index 100% rename from engine/native/scene/renderable/renderable.cppm rename to Engine/cpp/runtime/scene/renderable/renderable.cppm diff --git a/engine/native/scene/scene.cppm b/Engine/cpp/runtime/scene/scene.cppm similarity index 100% rename from engine/native/scene/scene.cppm rename to Engine/cpp/runtime/scene/scene.cppm diff --git a/engine/native/scene/transform_component/transform_component.cpp b/Engine/cpp/runtime/scene/transform_component/transform_component.cpp similarity index 100% rename from engine/native/scene/transform_component/transform_component.cpp rename to Engine/cpp/runtime/scene/transform_component/transform_component.cpp diff --git a/engine/native/scene/transform_component/transform_component.cppm b/Engine/cpp/runtime/scene/transform_component/transform_component.cppm similarity index 100% rename from engine/native/scene/transform_component/transform_component.cppm rename to Engine/cpp/runtime/scene/transform_component/transform_component.cppm diff --git a/engine/native/thirdparty/CMakeLists.txt b/Engine/cpp/thirdparty/CMakeLists.txt similarity index 100% rename from engine/native/thirdparty/CMakeLists.txt rename to Engine/cpp/thirdparty/CMakeLists.txt diff --git a/engine/native/thirdparty/bgfx b/Engine/cpp/thirdparty/bgfx similarity index 100% rename from engine/native/thirdparty/bgfx rename to Engine/cpp/thirdparty/bgfx diff --git a/engine/native/thirdparty/bimg b/Engine/cpp/thirdparty/bimg similarity index 100% rename from engine/native/thirdparty/bimg rename to Engine/cpp/thirdparty/bimg diff --git a/engine/native/thirdparty/bx b/Engine/cpp/thirdparty/bx similarity index 100% rename from engine/native/thirdparty/bx rename to Engine/cpp/thirdparty/bx diff --git a/engine/native/thirdparty/cmake/Config.cmake.in b/Engine/cpp/thirdparty/cmake/Config.cmake.in similarity index 100% rename from engine/native/thirdparty/cmake/Config.cmake.in rename to Engine/cpp/thirdparty/cmake/Config.cmake.in diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/dear-imgui.cmake b/Engine/cpp/thirdparty/cmake/bgfx/3rdparty/dear-imgui.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/3rdparty/dear-imgui.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/3rdparty/dear-imgui.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/fcpp.cmake b/Engine/cpp/thirdparty/cmake/bgfx/3rdparty/fcpp.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/3rdparty/fcpp.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/3rdparty/fcpp.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/glsl-optimizer.cmake b/Engine/cpp/thirdparty/cmake/bgfx/3rdparty/glsl-optimizer.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/3rdparty/glsl-optimizer.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/3rdparty/glsl-optimizer.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/glslang.cmake b/Engine/cpp/thirdparty/cmake/bgfx/3rdparty/glslang.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/3rdparty/glslang.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/3rdparty/glslang.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/meshoptimizer.cmake b/Engine/cpp/thirdparty/cmake/bgfx/3rdparty/meshoptimizer.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/3rdparty/meshoptimizer.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/3rdparty/meshoptimizer.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-cross.cmake b/Engine/cpp/thirdparty/cmake/bgfx/3rdparty/spirv-cross.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-cross.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/3rdparty/spirv-cross.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-opt.cmake b/Engine/cpp/thirdparty/cmake/bgfx/3rdparty/spirv-opt.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-opt.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/3rdparty/spirv-opt.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/tint.cmake b/Engine/cpp/thirdparty/cmake/bgfx/3rdparty/tint.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/3rdparty/tint.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/3rdparty/tint.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/webgpu.cmake b/Engine/cpp/thirdparty/cmake/bgfx/3rdparty/webgpu.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/3rdparty/webgpu.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/3rdparty/webgpu.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/CMakeLists.txt b/Engine/cpp/thirdparty/cmake/bgfx/CMakeLists.txt similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/CMakeLists.txt rename to Engine/cpp/thirdparty/cmake/bgfx/CMakeLists.txt diff --git a/engine/native/thirdparty/cmake/bgfx/bgfx.cmake b/Engine/cpp/thirdparty/cmake/bgfx/bgfx.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/bgfx.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/bgfx.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/examples.cmake b/Engine/cpp/thirdparty/cmake/bgfx/examples.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/examples.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/examples.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/generated/bounds.cpp.in b/Engine/cpp/thirdparty/cmake/bgfx/generated/bounds.cpp.in similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/generated/bounds.cpp.in rename to Engine/cpp/thirdparty/cmake/bgfx/generated/bounds.cpp.in diff --git a/engine/native/thirdparty/cmake/bgfx/generated/shader.cpp.in b/Engine/cpp/thirdparty/cmake/bgfx/generated/shader.cpp.in similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/generated/shader.cpp.in rename to Engine/cpp/thirdparty/cmake/bgfx/generated/shader.cpp.in diff --git a/engine/native/thirdparty/cmake/bgfx/generated/vertexlayout.cpp.in b/Engine/cpp/thirdparty/cmake/bgfx/generated/vertexlayout.cpp.in similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/generated/vertexlayout.cpp.in rename to Engine/cpp/thirdparty/cmake/bgfx/generated/vertexlayout.cpp.in diff --git a/engine/native/thirdparty/cmake/bgfx/geometryc.cmake b/Engine/cpp/thirdparty/cmake/bgfx/geometryc.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/geometryc.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/geometryc.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/geometryv.cmake b/Engine/cpp/thirdparty/cmake/bgfx/geometryv.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/geometryv.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/geometryv.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/shaderc.cmake b/Engine/cpp/thirdparty/cmake/bgfx/shaderc.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/shaderc.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/shaderc.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/shared.cmake b/Engine/cpp/thirdparty/cmake/bgfx/shared.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/shared.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/shared.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/texturev.cmake b/Engine/cpp/thirdparty/cmake/bgfx/texturev.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/texturev.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/texturev.cmake diff --git a/engine/native/thirdparty/cmake/bgfx/util/ConfigureDebugging.cmake b/Engine/cpp/thirdparty/cmake/bgfx/util/ConfigureDebugging.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfx/util/ConfigureDebugging.cmake rename to Engine/cpp/thirdparty/cmake/bgfx/util/ConfigureDebugging.cmake diff --git a/engine/native/thirdparty/cmake/bgfxToolUtils.cmake b/Engine/cpp/thirdparty/cmake/bgfxToolUtils.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bgfxToolUtils.cmake rename to Engine/cpp/thirdparty/cmake/bgfxToolUtils.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/astc_encoder.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/astc_encoder.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/astc_encoder.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/astc_encoder.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/edtaa3.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/edtaa3.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/edtaa3.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/edtaa3.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/etc1.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/etc1.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/etc1.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/etc1.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/etc2.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/etc2.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/etc2.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/etc2.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/iqa.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/iqa.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/iqa.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/iqa.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/libsquish.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/libsquish.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/libsquish.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/libsquish.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/loadpng.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/loadpng.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/loadpng.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/loadpng.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/miniz.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/miniz.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/miniz.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/miniz.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/nvtt.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/nvtt.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/nvtt.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/nvtt.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/pvrtc.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/pvrtc.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/pvrtc.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/pvrtc.cmake diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/tinyexr.cmake b/Engine/cpp/thirdparty/cmake/bimg/3rdparty/tinyexr.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/3rdparty/tinyexr.cmake rename to Engine/cpp/thirdparty/cmake/bimg/3rdparty/tinyexr.cmake diff --git a/engine/native/thirdparty/cmake/bimg/CMakeLists.txt b/Engine/cpp/thirdparty/cmake/bimg/CMakeLists.txt similarity index 100% rename from engine/native/thirdparty/cmake/bimg/CMakeLists.txt rename to Engine/cpp/thirdparty/cmake/bimg/CMakeLists.txt diff --git a/engine/native/thirdparty/cmake/bimg/bimg.cmake b/Engine/cpp/thirdparty/cmake/bimg/bimg.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/bimg.cmake rename to Engine/cpp/thirdparty/cmake/bimg/bimg.cmake diff --git a/engine/native/thirdparty/cmake/bimg/bimg_decode.cmake b/Engine/cpp/thirdparty/cmake/bimg/bimg_decode.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/bimg_decode.cmake rename to Engine/cpp/thirdparty/cmake/bimg/bimg_decode.cmake diff --git a/engine/native/thirdparty/cmake/bimg/bimg_encode.cmake b/Engine/cpp/thirdparty/cmake/bimg/bimg_encode.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/bimg_encode.cmake rename to Engine/cpp/thirdparty/cmake/bimg/bimg_encode.cmake diff --git a/engine/native/thirdparty/cmake/bimg/texturec.cmake b/Engine/cpp/thirdparty/cmake/bimg/texturec.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bimg/texturec.cmake rename to Engine/cpp/thirdparty/cmake/bimg/texturec.cmake diff --git a/engine/native/thirdparty/cmake/bx/CMakeLists.txt b/Engine/cpp/thirdparty/cmake/bx/CMakeLists.txt similarity index 100% rename from engine/native/thirdparty/cmake/bx/CMakeLists.txt rename to Engine/cpp/thirdparty/cmake/bx/CMakeLists.txt diff --git a/engine/native/thirdparty/cmake/bx/bin2c.cmake b/Engine/cpp/thirdparty/cmake/bx/bin2c.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bx/bin2c.cmake rename to Engine/cpp/thirdparty/cmake/bx/bin2c.cmake diff --git a/engine/native/thirdparty/cmake/bx/bx.cmake b/Engine/cpp/thirdparty/cmake/bx/bx.cmake similarity index 100% rename from engine/native/thirdparty/cmake/bx/bx.cmake rename to Engine/cpp/thirdparty/cmake/bx/bx.cmake diff --git a/engine/native/thirdparty/cmake/version.cmake b/Engine/cpp/thirdparty/cmake/version.cmake similarity index 100% rename from engine/native/thirdparty/cmake/version.cmake rename to Engine/cpp/thirdparty/cmake/version.cmake diff --git a/engine/native/thirdparty/doctest/doctest.h b/Engine/cpp/thirdparty/doctest/doctest.h similarity index 100% rename from engine/native/thirdparty/doctest/doctest.h rename to Engine/cpp/thirdparty/doctest/doctest.h diff --git a/Engine/cpp/thirdparty/doctest/doctest_with_main.h b/Engine/cpp/thirdparty/doctest/doctest_with_main.h new file mode 100644 index 00000000..5c27df32 --- /dev/null +++ b/Engine/cpp/thirdparty/doctest/doctest_with_main.h @@ -0,0 +1,42 @@ +#pragma once + +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include +#include + +#define STATIC_REQUIRE(expr) { \ +static_assert(expr); \ +REQUIRE(expr); \ +} + +#define STATIC_REQUIRE_FALSE(expr) { \ +static_assert(!(expr)); \ +REQUIRE_FALSE(expr); \ +} + +#define R_CHECK_EQ(L_expr, R_expr) { \ +const auto L_run = (L_expr); \ +const auto R_run = (R_expr); \ +static_assert(std::is_same_v); \ +CHECK_EQ(L_run, R_run); \ +} + +#define RAC_CHECK_EQ(L_expr, R_expr) { \ +static constexpr auto L_comp = (L_expr); \ +static constexpr auto R_comp = (R_expr); \ +static_assert(std::is_same_v); \ +static_assert(L_comp == R_comp); \ +R_CHECK_EQ(L_expr, R_expr); \ +} + +#define BASIC_R_SUBCASE(name, L_expr, R_expr) \ +SUBCASE(name) { R_CHECK_EQ(L_expr, R_expr); } + +#define BASIC_R_SUBCASE_2(name, L_expr1, R_expr1, L_expr2, R_expr2) \ +SUBCASE(name) { R_CHECK_EQ(L_expr1, R_expr1); R_CHECK_EQ(L_expr2, R_expr2); } + +#define BASIC_RAC_SUBCASE(name, L_expr, R_expr) \ +SUBCASE(name) { RAC_CHECK_EQ(L_expr, R_expr); } + +#define BASIC_RAC_SUBCASE_2(name, L_expr1, R_expr1, L_expr2, R_expr2) \ +SUBCASE(name) { RAC_CHECK_EQ(L_expr1, R_expr1); RAC_CHECK_EQ(L_expr2, R_expr2); } diff --git a/engine/native/thirdparty/sdl b/Engine/cpp/thirdparty/sdl similarity index 100% rename from engine/native/thirdparty/sdl rename to Engine/cpp/thirdparty/sdl diff --git a/engine/native/thirdparty/stb/CMakeLists.txt b/Engine/cpp/thirdparty/stb/CMakeLists.txt similarity index 100% rename from engine/native/thirdparty/stb/CMakeLists.txt rename to Engine/cpp/thirdparty/stb/CMakeLists.txt diff --git a/engine/native/thirdparty/stb/stb_image.h b/Engine/cpp/thirdparty/stb/stb_image.h similarity index 100% rename from engine/native/thirdparty/stb/stb_image.h rename to Engine/cpp/thirdparty/stb/stb_image.h diff --git a/README.md b/README.md index 56182ccc..6cbe427e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

- Draconic Engine Logo + Draconic Engine Logo

@@ -43,4 +43,4 @@ Draconic Engine is a two-tiered project, with an inner core written in C++ and a public interface and editor in C#. Regarding the native layer, it is written in C++, according to the C++23 standard and using modules. -Documentation regarding how C++ modules are used can be read [here](docs/cxxmodules.md). +Documentation regarding how C++ modules are used can be read [here](Docs/cxxmodules.md). diff --git a/Samples/cpp/CMakeLists.txt b/Samples/cpp/CMakeLists.txt new file mode 100644 index 00000000..5ed5dfae --- /dev/null +++ b/Samples/cpp/CMakeLists.txt @@ -0,0 +1,38 @@ +# +# Rendering Sample +# +add_executable(Render rendering.cpp) + +target_link_libraries(Render + PRIVATE + runtime + bgfx + bx + bimg +) + +if(UNIX AND NOT APPLE) + target_link_libraries(Render PRIVATE SDL3::SDL3-static Threads::Threads dl) + target_link_options(Render PRIVATE -Wl,--whole-archive $ -Wl,--no-whole-archive) +elseif(APPLE) + target_link_libraries(Render PRIVATE SDL3::SDL3-static) + target_link_options(Render PRIVATE -Wl,-force_load,$) +else() + target_link_libraries(Render PRIVATE SDL3::SDL3-static) +endif() + +compile_shaders(Render) + +set(TEST_IMAGE + "${CMAKE_SOURCE_DIR}/Docs/assets/draconic_logo_no_text.png" +) + +add_custom_command( + TARGET Render POST_BUILD + + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${TEST_IMAGE} + $/test.png + + COMMENT "Copying test texture..." +) diff --git a/engine/native/main/main.cpp b/Samples/cpp/rendering.cpp similarity index 86% rename from engine/native/main/main.cpp rename to Samples/cpp/rendering.cpp index 726ea8e1..6dd2da9a 100644 --- a/engine/native/main/main.cpp +++ b/Samples/cpp/rendering.cpp @@ -16,7 +16,7 @@ int main(int argc, char* argv[]) } SDL_Window* window = SDL_CreateWindow( - "Draconic Engine", + "Draconic Engine Rendering Sample", 1280, 720, SDL_WINDOW_RESIZABLE ); @@ -112,30 +112,31 @@ int main(int argc, char* argv[]) mat.sampler = s_texColor; mat.uniforms.push_back({.name_hash = draco::rendering::rhi::hash_uniform("u_tint"), .data = tint, .count = 1}); - mat.uniforms.push_back({.name_hash = draco::rendering::rhi::hash_uniform("u_offset"), .data = offset, .count = 1}); draco::scene::Scene scene; - scene.renderables.push_back({cube_mesh, draco::math::make_transform(), mat}); - scene.renderables.push_back({plane_mesh, draco::math::make_transform(), mat}); - scene.renderables.push_back({sphere_mesh, draco::math::make_transform(), mat}); - scene.renderables.push_back({cylinder_mesh, draco::math::make_transform(), mat}); - scene.renderables.push_back({capsule_mesh, draco::math::make_transform(), mat}); + static constexpr draco::math::Transform tr; + + scene.renderables.push_back({cube_mesh, tr, mat}); + scene.renderables.push_back({plane_mesh, tr, mat}); + scene.renderables.push_back({sphere_mesh, tr, mat}); + scene.renderables.push_back({cylinder_mesh, tr, mat}); + scene.renderables.push_back({capsule_mesh, tr, mat}); - draco::math::set_position(scene.renderables[0].transform, -12.0f, 0.0f, 0.0f); - draco::math::set_position(scene.renderables[1].transform, -6.0f, 0.0f, 0.0f); - draco::math::set_position(scene.renderables[2].transform, 0.0f, 0.0f, 0.0f); - draco::math::set_position(scene.renderables[3].transform, 6.0f, 0.0f, 0.0f); - draco::math::set_position(scene.renderables[4].transform, 12.0f, 0.0f, 0.0f); + scene.renderables[0].transform.set_position(-12.0f, 0.0f, 0.0f); + scene.renderables[1].transform.set_position(-6.0f, 0.0f, 0.0f); + scene.renderables[2].transform.set_position(0.0f, 0.0f, 0.0f); + scene.renderables[3].transform.set_position(6.0f, 0.0f, 0.0f); + scene.renderables[4].transform.set_position(12.0f, 0.0f, 0.0f); - draco::math::set_rotation(scene.renderables[1].transform, -bx::kPiHalf, 0.0f, 0.0f); + scene.renderables[1].transform.set_rotation(-bx::kPiHalf, 0.0f, 0.0f); while (running) { static draco::u64 last = SDL_GetTicks(); draco::u64 now = SDL_GetTicks(); - draco::f32 dt = (now - last) / 1000.0f; + draco::f32 dt = static_cast(now - last) / 1000.0f; last = now; SDL_Event e; diff --git a/cmake/Modules.cmake b/cmake/Modules.cmake index 45a14f3c..f29d7615 100644 --- a/cmake/Modules.cmake +++ b/cmake/Modules.cmake @@ -1,6 +1,6 @@ include_guard(GLOBAL) -set(NATIVE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/engine/native") +set(NATIVE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/Engine/cpp") set(NATIVE_THIRD_PARTY_DIR "${NATIVE_SOURCE_DIR}/thirdparty") diff --git a/cmake/Shaders.cmake b/cmake/Shaders.cmake index 2eab7355..5085555b 100644 --- a/cmake/Shaders.cmake +++ b/cmake/Shaders.cmake @@ -1,8 +1,8 @@ include_guard(GLOBAL) -set(SHADER_SRC_DIR "${CMAKE_SOURCE_DIR}/engine/native/rendering/shaders") +set(SHADER_SRC_DIR "${CMAKE_SOURCE_DIR}/Engine/cpp/runtime/rendering/shaders") set(SHADER_BIN_DIR "${CMAKE_BINARY_DIR}") -set(BGFX_INCLUDE "${CMAKE_SOURCE_DIR}/engine/native/thirdparty/bgfx/src") +set(BGFX_INCLUDE "${CMAKE_SOURCE_DIR}/Engine/cpp/thirdparty/bgfx/src") function(compile_shaders TARGET_NAME) file(MAKE_DIRECTORY ${SHADER_BIN_DIR}) @@ -37,7 +37,7 @@ function(compile_shaders TARGET_NAME) set(QUAD_VARYING_DEF "${SHADER_SRC_DIR}/varying_quad.def.sc") add_custom_command( - TARGET draconic POST_BUILD + TARGET ${TARGET_NAME} POST_BUILD COMMENT "Compiling asset pipelines and core engine shaders via native tools..." COMMAND $ @@ -76,9 +76,9 @@ function(compile_shaders TARGET_NAME) --varyingdef ${QUAD_VARYING_DEF} -i ${BGFX_INCLUDE} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VERTEX_OUTPUT} $ - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FRAGMENT_OUTPUT} $ - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QUAD_VERTEX_OUTPUT} $ - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QUAD_FRAGMENT_OUTPUT} $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VERTEX_OUTPUT} $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FRAGMENT_OUTPUT} $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QUAD_VERTEX_OUTPUT} $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QUAD_FRAGMENT_OUTPUT} $ ) endfunction() diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt deleted file mode 100644 index b2417e14..00000000 --- a/engine/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_modules_library(native) -target_link_libraries(native PUBLIC platform core input scene rendering) \ No newline at end of file diff --git a/engine/native/core/math/transform.cpp b/engine/native/core/math/transform.cpp deleted file mode 100644 index 2538a51c..00000000 --- a/engine/native/core/math/transform.cpp +++ /dev/null @@ -1,78 +0,0 @@ -module; - -#include - -#include - -module core.math.transform; - -import core.stdtypes; - -namespace draco::math -{ - Transform make_transform() - { - Transform t; - - t.position[0] = 0.0f; - t.position[1] = 0.0f; - t.position[2] = 0.0f; - - t.rotation[0] = 0.0f; - t.rotation[1] = 0.0f; - t.rotation[2] = 0.0f; - - t.scale[0] = 1.0f; - t.scale[1] = 1.0f; - t.scale[2] = 1.0f; - - return t; - } - - void set_position(Transform& t, f32 x, f32 y, f32 z) - { - t.position[0] = x; - t.position[1] = y; - t.position[2] = z; - } - - void set_rotation(Transform& t, f32 x, f32 y, f32 z) - { - t.rotation[0] = x; - t.rotation[1] = y; - t.rotation[2] = z; - } - - void set_scale(Transform& t, f32 x, f32 y, f32 z) - { - t.scale[0] = x; - t.scale[1] = y; - t.scale[2] = z; - } - - void compute_matrix(const Transform& t, f32 out[16]) - { - f32 translation[16]; - f32 rx[16]; - f32 ry[16]; - f32 rz[16]; - f32 scale[16]; - f32 temp[16]; - - bx::mtxIdentity(out); - - bx::mtxScale(scale, t.scale[0], t.scale[1], t.scale[2]); - - bx::mtxRotateX(rx, t.rotation[0]); - bx::mtxRotateY(ry, t.rotation[1]); - bx::mtxRotateZ(rz, t.rotation[2]); - - bx::mtxTranslate(translation, t.position[0], t.position[1], t.position[2]); - - // scale * rotation * translation - bx::mtxMul(temp, scale, rx); - bx::mtxMul(temp, temp, ry); - bx::mtxMul(temp, temp, rz); - bx::mtxMul(out, temp, translation); - } -} diff --git a/engine/native/core/math/transform.cppm b/engine/native/core/math/transform.cppm deleted file mode 100644 index fc1a5893..00000000 --- a/engine/native/core/math/transform.cppm +++ /dev/null @@ -1,32 +0,0 @@ -module; - -#include - -#include - -export module core.math.transform; - -import core.stdtypes; - -export namespace draco::math -{ - struct Transform - { - f32 position[3] = { 0.0f, 0.0f, 0.0f }; - f32 rotation[3] = { 0.0f, 0.0f, 0.0f }; // Euler (radians) - f32 scale[3] = { 1.0f, 1.0f, 1.0f }; - }; - - // TODO: Besides compute_matrix, we should make rest of the funcs constexpr funcs - - // Creates a default identity transform - Transform make_transform(); - - // Recompute matrix from transform (column-major) - void compute_matrix(const Transform& t, f32 out[16]); - - // Helpers - void set_position(Transform& t, f32 x, f32 y, f32 z); - void set_rotation(Transform& t, f32 x, f32 y, f32 z); - void set_scale(Transform& t, f32 x, f32 y, f32 z); -}