Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[submodule "Engine/cpp/thirdparty/bx"]
path = Engine/cpp/thirdparty/bx
path = Engine/cpp/ThirdParty/bx
url = https://github.com/bkaradzic/bx
[submodule "Engine/cpp/thirdparty/bimg"]
path = Engine/cpp/thirdparty/bimg
path = Engine/cpp/ThirdParty/bimg
url = https://github.com/bkaradzic/bimg
[submodule "Engine/cpp/thirdparty/bgfx"]
path = Engine/cpp/thirdparty/bgfx
path = Engine/cpp/ThirdParty/bgfx
url = https://github.com/bkaradzic/bgfx
[submodule "Engine/cpp/thirdparty/sdl"]
path = Engine/cpp/thirdparty/sdl
path = Engine/cpp/ThirdParty/sdl
url = https://github.com/libsdl-org/SDL
6 changes: 3 additions & 3 deletions Engine/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_subdirectory(thirdparty SYSTEM)
add_subdirectory(ThirdParty SYSTEM)

add_modules_library(runtime)
target_link_libraries(runtime PUBLIC platform core input scene rendering)
add_modules_library(Runtime SHARED)
target_link_libraries(Runtime PUBLIC Platform Core Input Scene Rendering)

# TODO: binding library
11 changes: 11 additions & 0 deletions Engine/cpp/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
add_modules_library(Platform)
add_modules_library(Core PIC)
add_modules_library(Input)
add_modules_library(Rendering PIC)
add_modules_library(Scene)

target_link_libraries(Platform PUBLIC Platform_impl)
target_link_libraries(Core PUBLIC Definitions Math IO Memory)
target_link_libraries(Input PRIVATE SDL3::SDL3-static Platform Core)
target_link_libraries(Rendering PUBLIC RHI RenderGraph Mesh Material QuadRenderer Renderer)
target_link_libraries(Scene PUBLIC Renderable TransformComponent Camera)
8 changes: 8 additions & 0 deletions Engine/cpp/Runtime/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
add_modules_library(Definitions)
add_modules_library(Math)
add_modules_library(IO)
add_modules_library(Memory)

target_link_libraries(Math PUBLIC Definitions bx)
target_link_libraries(IO PUBLIC Definitions stb_image)
target_link_libraries(Memory PUBLIC Definitions Math)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export module core;
export import core.defs;
export import core.version;
export import core.math;
export import core.memory;
export import core.io;
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module;
#include <type_traits>

export module core.defs;
export import core.version;
export import core.stdtypes;

static_assert(__cplusplus >= 202207L, "Minimum of C++23 required. Consider upgrading your compiler.");
static_assert(__cplusplus >= 202207L, "Minimum of C++23 required.");

export namespace draco {
template<typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import core.stdtypes;

namespace draco::core::io::filesystem
{
std::vector<u8> load_binary(const std::string& path)
std::vector<u8> loadBinary(const std::string& path)
{
// Open at the end (ate) to get size and in binary mode
std::ifstream file(path, std::ios::binary | std::ios::ate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ import core.stdtypes;
export namespace draco::core::io::filesystem
{
// Returns a buffer of the file data
std::vector<u8> load_binary(const std::string& path);
std::vector<u8> loadBinary(const std::string& path);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export module core.io;

export import core.io.filesystem;
export import core.io.image_loader;
export import core.io.loader.image;
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ module;
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>

module core.io.image_loader;
module core.io.loader.image;

import core.stdtypes;

// TODO: I'm too lazy to write code so we need somethin' better

namespace draco::core::io::image_loader
namespace draco::core::io::loader::image
{
ImageData load_image(const std::filesystem::path& path)
ImageData loadImage(const std::filesystem::path& path)
{
ImageData result;

Expand Down Expand Up @@ -53,7 +53,7 @@ namespace draco::core::io::image_loader
result.width = static_cast<u16>(width);
result.height = static_cast<u16>(height);
result.channels = 4;
result.is_valid = true;
result.isValid = true;

// Free the memory allocated by stb
stbi_image_free(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ module;
#include <vector>
#include <filesystem>

export module core.io.image_loader;
export module core.io.loader.image;

import core.stdtypes;

export namespace draco::core::io::image_loader
export namespace draco::core::io::loader::image
{
struct ImageData
{
std::vector<u8> pixels;
std::vector<u8> pixels{};
u32 width = 0;
u32 height = 0;
u8 channels = 0;
bool is_valid = false;
bool isValid = false;
};

// Load an image file (PNG, JPG, etc.) & decode it to raw RGBA8
ImageData load_image(const std::filesystem::path& path);
ImageData loadImage(const std::filesystem::path& path);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ export namespace draco::math {
constexpr T sqr(T x) noexcept { return x*x; }

template <std::floating_point T>
[[nodiscard]] constexpr bool is_nan(T val) noexcept {
[[nodiscard]] constexpr bool isNan(T val) noexcept {
// Only NaN does not equal itself.
return val != val;
}

template <std::floating_point T>
[[nodiscard]] constexpr bool is_inf(T val) noexcept {
[[nodiscard]] constexpr bool isInf(T val) noexcept {
return std::isinf(val);
}

template <std::floating_point T>
[[nodiscard]] constexpr bool is_finite(T val) noexcept {
[[nodiscard]] constexpr bool isFinite(T val) noexcept {
return std::isfinite(val);
}

Expand Down Expand Up @@ -91,12 +91,12 @@ export namespace draco::math {
}

template <std::floating_point T>
constexpr T deg_to_rad(T y) noexcept {
constexpr T degToRad(T y) noexcept {
return y * (T{PI} / T{180.});
}

template <std::floating_point T>
constexpr T rad_to_deg(T y) noexcept {
constexpr T radToDeg(T y) noexcept {
return y * (T{180.} / T{PI});
}

Expand All @@ -111,7 +111,7 @@ export namespace draco::math {
}

template <std::floating_point T>
constexpr T cubic_interpolate(T from, T to, T before, T after, T weight) noexcept {
constexpr T cubicInterpolate(T from, T to, T before, T after, T weight) noexcept {
// weight squared.
T w2 = weight * weight;
// weight cubed.
Expand All @@ -135,7 +135,7 @@ export namespace draco::math {
}

template <std::floating_point T>
constexpr T cubic_interpolate_in_time(
constexpr T cubicInterpolateInTime(
T from, T to,
T before, T after, T weight,
T to_t, T before_t, T after_t) noexcept {
Expand Down Expand Up @@ -169,7 +169,7 @@ export namespace draco::math {
}

template <std::floating_point T>
constexpr T bezier_interpolate(T start, T control_1, T control_2, T end, T t) noexcept {
constexpr T bezierInterpolate(T start, T control_1, T control_2, T end, T t) noexcept {
/* Formula from Wikipedia article on Bezier curves. */
// one minus t.
T omt = T{1.} - t;
Expand All @@ -184,7 +184,7 @@ export namespace draco::math {
}

template <std::floating_point T>
constexpr T bezier_derivative(T start, T control_1, T control_2, T end, T t) noexcept {
constexpr T bezierDerivative(T start, T control_1, T control_2, T end, T t) noexcept {
/* Formula from Wikipedia article on Bezier curves. */
T omt = T{1.} - t;
T omt2 = omt * omt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ TEST_SUITE("vector2") {
using math::CMP_EPSILON;

static constexpr Vector2 v{1.0f, 2.0f};
static constexpr Vector2 offset = Vector2::x_axis(CMP_EPSILON);
static constexpr Vector2 offset = Vector2::xAxis(CMP_EPSILON);

BASIC_R_SUBCASE("distance < epsilon",
( approx_eq(v, v + offset * 0.5f) ),
Expand Down Expand Up @@ -910,7 +910,7 @@ TEST_SUITE("vector3") {
using math::CMP_EPSILON;

static constexpr Vector3 v{1.0f, 2.0f, 3.0f};
static constexpr Vector3 offset = Vector3::x_axis(CMP_EPSILON);
static constexpr Vector3 offset = Vector3::xAxis(CMP_EPSILON);

BASIC_R_SUBCASE("distance < epsilon",
( approx_eq(v, v + offset * 0.5f) ),
Expand All @@ -933,8 +933,8 @@ TEST_SUITE("vector3") {
using math::cross;

RAC_CHECK_EQ(
( cross(Vector3::x_axis(), Vector3::y_axis()) ),
( Vector3::z_axis() )
( cross(Vector3::xAxis(), Vector3::yAxis()) ),
( Vector3::zAxis() )
)
}
}
Expand Down Expand Up @@ -1401,7 +1401,7 @@ TEST_SUITE("vector4") {
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);
static constexpr Vector4 offset = Vector4::xAxis(CMP_EPSILON);

BASIC_R_SUBCASE("distance < epsilon",
( approx_eq(v, v + offset * 0.5f) ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import core.stdtypes;

namespace draco::math
{
void Transform::to_matrix(f32 out[16]) const
void Transform::toMatrix(f32 out[16]) const
{
f32 translation[16];
f32 rx[16];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,59 @@ export namespace draco::math
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 {
constexpr void setPosition(f32 x, f32 y, f32 z) noexcept {
position[0] = x;
position[1] = y;
position[2] = z;
}

constexpr void set_position(const Vector3& v) noexcept {
constexpr void setPosition(const Vector3& v) noexcept {
position[0] = v.x;
position[1] = v.y;
position[2] = v.z;
}

[[nodiscard]] constexpr Vector3 get_position() const noexcept {
[[nodiscard]] constexpr Vector3 getPosition() const noexcept {
return Vector3{position[0], position[1], position[2]};
}

constexpr void set_rotation(f32 x, f32 y, f32 z) noexcept
constexpr void setRotation(const f32 x, const f32 y, const f32 z) noexcept
{
rotation[0] = x;
rotation[1] = y;
rotation[2] = z;
}

constexpr void set_rotation(const Vector3& v) noexcept
constexpr void setRotation(const Vector3& v) noexcept
{
rotation[0] = v.x;
rotation[1] = v.y;
rotation[2] = v.z;
}

[[nodiscard]] constexpr Vector3 get_rotation() const noexcept {
[[nodiscard]] constexpr Vector3 getRotation() const noexcept {
return Vector3{rotation[0], rotation[1], rotation[2]};
}

constexpr void set_scale(f32 x, f32 y, f32 z) noexcept
constexpr void setScale(const f32 x, const f32 y, const f32 z) noexcept
{
scale[0] = x;
scale[1] = y;
scale[2] = z;
}

constexpr void set_scale(const Vector3& v) noexcept
constexpr void setScale(const Vector3& v) noexcept
{
scale[0] = v.x;
scale[1] = v.y;
scale[2] = v.z;
}

[[nodiscard]] constexpr Vector3 get_scale() const noexcept {
[[nodiscard]] constexpr Vector3 getScale() const noexcept {
return Vector3{scale[0], scale[1], scale[2]};
}

// Compute column-major matrix from transform
void to_matrix(f32 out[16]) const;
void toMatrix(f32 out[16]) const;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export namespace draco::math {
[[nodiscard]] constexpr explicit Vector2(const Vector4& xy) noexcept;

// static
[[nodiscard]] static constexpr Vector2 x_axis(f32 x = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector2 y_axis(f32 y = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector2 xAxis(f32 x = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector2 yAxis(f32 y = 1.0f) noexcept;
[[nodiscard]] static Vector2 polar(f32 angle, f32 radius = 1.0f) noexcept;

// element access
Expand Down Expand Up @@ -57,9 +57,9 @@ export namespace draco::math {
[[nodiscard]] constexpr explicit Vector3(const Vector4& xyz) noexcept;

// static
[[nodiscard]] static constexpr Vector3 x_axis(f32 x = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector3 y_axis(f32 y = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector3 z_axis(f32 z = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector3 xAxis(f32 x = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector3 yAxis(f32 y = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector3 zAxis(f32 z = 1.0f) noexcept;
[[nodiscard]] static Vector3 spherical(f32 azimuth, f32 inclination, f32 radius = 1.0f) noexcept;
[[nodiscard]] static Vector3 cylindrical(f32 angle, f32 radius = 1.0f, f32 height = 0.0f) noexcept;

Expand Down Expand Up @@ -103,10 +103,10 @@ export namespace draco::math {
[[nodiscard]] constexpr Vector4(f32 x, const Vector3& yzw) noexcept;

// static
[[nodiscard]] static constexpr Vector4 x_axis(f32 x = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector4 y_axis(f32 y = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector4 z_axis(f32 z = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector4 w_axis(f32 w = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector4 xAxis(f32 x = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector4 yAxis(f32 y = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector4 zAxis(f32 z = 1.0f) noexcept;
[[nodiscard]] static constexpr Vector4 wAxis(f32 w = 1.0f) noexcept;

// element access
[[nodiscard]] constexpr f32& operator[](i32 i) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export namespace draco::math {
: x{xy.x}, y{xy.y} { }

// static
[[nodiscard]] constexpr Vector2 Vector2::x_axis(const f32 x) noexcept {
[[nodiscard]] constexpr Vector2 Vector2::xAxis(const f32 x) noexcept {
return { x, 0.0f };
}

[[nodiscard]] constexpr Vector2 Vector2::y_axis(const f32 y) noexcept {
[[nodiscard]] constexpr Vector2 Vector2::yAxis(const f32 y) noexcept {
return { 0.0f, y };
}

Expand Down
Loading
Loading