Skip to content

Commit

Permalink
Major restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
broken-bytes committed Mar 8, 2024
1 parent 9131ccf commit b2f6a58
Show file tree
Hide file tree
Showing 263 changed files with 1,145 additions and 3,768 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ project(${PROJECT_NAME})

enable_testing()

add_subdirectory(editor)
add_subdirectory(engine)
add_subdirectory(core)
3 changes: 2 additions & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "c6294a0f487b97131f54202be1cb7d4b73dc771be2c3aa5a67c31f59acbb1824",
"pins" : [
{
"identity" : "swift-syntax",
Expand All @@ -10,5 +11,5 @@
}
}
],
"version" : 2
"version" : 3
}
32 changes: 21 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
],
dependencies: [
// Depend on the Swift 5.9 release of SwiftSyntax
.package(url: "https://github.com/apple/swift-syntax.git", from: "509.1.1"),
.package(url: "https://github.com/apple/swift-syntax.git", from: "509.1.1")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand All @@ -35,17 +35,33 @@ let package = Package(
],
path: "scripting/macros"
),
// The shared targets
.target(
name: "SceneManagement",
dependencies: [],
path: "scripting/shared/scenemanagement"
),

.target(
name: "KyaniteEngine",
dependencies: ["Macros", "Native"],
path: "scripting/engine"
dependencies: ["Macros", "Native", "SceneManagement"],
path: "scripting/engine",
swiftSettings: [
.unsafeFlags(["-enable-library-evolution"])
]
),

.target(
name: "KyaniteEditor",
dependencies: ["KyaniteEngine", "EditorNative", "Native"],
path: "scripting/editor"
dependencies: [
"KyaniteEngine",
"Native",
"SceneManagement"
],
path: "scripting/editor",
swiftSettings: [
.unsafeFlags(["-enable-library-evolution"])
]
),

.target(
Expand All @@ -57,12 +73,6 @@ let package = Package(
name: "Native",
dependencies: ["Bridge"],
path: "scripting/native"
),

.target(
name: "EditorNative",
dependencies: ["Bridge"],
path: "scripting/editornative"
)
]
)
2 changes: 2 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(engine)
add_subdirectory(editor)
2 changes: 2 additions & 0 deletions core/editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(assetpipeline)
add_subdirectory(app)
51 changes: 51 additions & 0 deletions core/editor/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FILE(GLOB_RECURSE HEADERS "include/*.h*")
FILE(GLOB_RECURSE SRC "src/*.c*")

find_package(SDL2 REQUIRED)
find_package(unofficial-sqlite3 REQUIRED)
find_package(assimp CONFIG REQUIRED)

add_executable(EditorApp ${SRC} ${HEADERS})

target_include_directories(EditorApp PRIVATE include)
target_include_directories(EditorApp PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/assetpackages/include)
target_include_directories(EditorApp PRIVATE ${CMAKE_SOURCE_DIR}/editor//core/include)
target_include_directories(EditorApp PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/audio/include)
target_include_directories(EditorApp PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/ecs/include)
target_include_directories(EditorApp PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/shared/include)
target_include_directories(EditorApp PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/logger/include)
target_include_directories(EditorApp PRIVATE ${CMAKE_SOURCE_DIR}/core/engine//core/include)
target_include_directories(EditorApp PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/rendering/include)

target_link_directories(EditorApp PRIVATE ${CMAKE_SOURCE_DIR}/.build/debug)

target_link_libraries(EditorApp PRIVATE SDL2::SDL2)

add_custom_command(TARGET EditorApp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:EditorApp> $<TARGET_RUNTIME_DLLS:EditorApp>
COMMAND_EXPAND_LISTS
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SRC} ${HEADERS})


add_custom_command(
TARGET EditorApp
POST_BUILD
COMMAND swift build -Xlinker ${CMAKE_BINARY_DIR}/engine/assetpackages/debug/AssetPackages.lib
-Xlinker ${CMAKE_BINARY_DIR}/engine/audio/debug/Audio.lib
-Xlinker ${CMAKE_BINARY_DIR}/engine/core/debug/Core.lib
-Xlinker ${CMAKE_BINARY_DIR}/engine/ecs/debug/EntityComponentSystem.lib
-Xlinker ${CMAKE_BINARY_DIR}/engine/input/debug/Input.lib
-Xlinker ${CMAKE_BINARY_DIR}/engine/rendering/debug/Rendering.lib
-Xlinker ${CMAKE_BINARY_DIR}/editor/core/debug/EditorCore.lib
-Xlinker ${CMAKE_BINARY_DIR}/editor/assetpipeline/debug/AssetPipeline.lib
--static-swift-stdlib
COMMENT "Running swift build with custom flags..."
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/.build/debug/KyaniteEditor.dll
$<TARGET_RUNTIME_DLLS:EditorApp>/KyaniteEditor.dll
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/.build/debug/KyaniteEngine.dll
$<TARGET_RUNTIME_DLLS:EditorApp>/KyaniteEngine.dll
)
File renamed without changes.
16 changes: 16 additions & 0 deletions core/editor/app/src/app/App.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "app/App.hxx"

#include <filesystem>
#include <memory>
#include <sstream>

#pragma comment(lib, "KyaniteEngine.lib")
#pragma comment(lib, "KyaniteEditor.lib")

// NOTE: These functions come from the Swift libraries. They are *not* unused
extern "C" void kyanitemain(bool);
extern "C" void kyaniteeditormain();

int main(int argc, char** argv) {
kyaniteeditormain();
}
28 changes: 28 additions & 0 deletions core/editor/assetpipeline/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FILE(GLOB_RECURSE HEADERS "include/*.h*")
FILE(GLOB_RECURSE SRC "src/*.c*")

find_package(unofficial-sqlite3 REQUIRED)
find_package(assimp CONFIG REQUIRED)
find_package(imgui CONFIG REQUIRED)

add_library(AssetPipeline SHARED ${SRC} ${HEADERS})

target_include_directories(AssetPipeline PRIVATE include)
target_include_directories(AssetPipeline PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/audio/include)
target_include_directories(AssetPipeline PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/ecs/include)
target_include_directories(AssetPipeline PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/shared/include)
target_include_directories(AssetPipeline PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/logger/include)
target_include_directories(AssetPipeline PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/io/include)
target_include_directories(AssetPipeline PRIVATE ${CMAKE_SOURCE_DIR}/core/engine/rendering/include)

target_link_libraries(AssetPipeline PRIVATE unofficial::sqlite3::sqlite3 assimp::assimp)

# Link all engine libraries
target_link_libraries(AssetPipeline PRIVATE Logger EntityComponentSystem Audio IO Rendering)

add_custom_command(TARGET AssetPipeline POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:AssetPipeline> $<TARGET_RUNTIME_DLLS:AssetPipeline>
COMMAND_EXPAND_LISTS
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SRC} ${HEADERS})
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#pragma once

#include <shared/Exported.hxx>
#include <shared/NativePointer.hxx>

#ifdef __cplusplus
extern "C" {
#endif
EXPORTED struct Vertex {
float position[3];
float normal[3];
float texCoord[2];
} typedef Vertex;

EXPORTED struct MeshData {
const char* name;
Vertex* vertices;
uint32_t vertexCount;
uint32_t* indices;
uint32_t indexCount;
} typedef MeshData;

/**
* @brief Initialize the asset pipeline
*/
EXPORTED void AssetPipeline_Init();

/**
* @brief Load a mesh from a file
* @param path The path to the file
* @param meshData The mesh data to load into
* @param len The length of the mesh data
*/
EXPORTED void AssetPipeline_LoadMeshes(const uint8_t* buffer, size_t bufferLen, MeshData* meshData, size_t* len);

/**
* @brief Free the mesh data
* @param meshData The mesh data to free
*/
EXPORTED void AssetPipeline_FreeMeshes(MeshData* meshData, size_t len);


#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#pragma once

#include "../meta/ModelMeta.hxx"
#include <rendering/Mesh.hxx>

#include <cstdint>
#include <tuple>
#include <vector>

namespace kyanite::editor::loaders {
namespace kyanite::editor::assetpipeline::loaders {
class FbxLoader {
public:
FbxLoader();
~FbxLoader();
auto LoadFromBuffer(std::vector<uint8_t> buffer) -> std::vector<engine::rendering::MeshData>;
auto LoadFromBuffer(std::vector<uint8_t> buffer) -> std::vector<kyanite::engine::rendering::MeshData>;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

namespace kyanite::editor::assetpipeline::mappers::AnimationMapper {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>
#include <vector>

namespace kyanite::editor::mappers {
namespace kyanite::editor::assetpipeline::mappers {
/**
* @brief Interface for asset mappers.
* @tparam T The type of the asset to convert to.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#pragma once

#include "editor/core/mappers/IMapper.hxx"
#include "editor/core/meta/ModelMeta.hxx"
#include "assetpipeline/mappers/IMapper.hxx"
#include "assetpipeline/Bridge_AssetPipeline.h"
#include <rendering/Mesh.hxx>

#include <cstdint>
#include <string>
#include <tuple>
#include <vector>

namespace kyanite::editor::mappers {
namespace kyanite::editor::assetpipeline::mappers {
class ModelMapper {
public:
ModelMapper() = default;

auto MapFbx(
std::vector<uint8_t> data
)-> std::vector<kyanite::engine::rendering::MeshData>;
) -> std::vector<kyanite::engine::rendering::MeshData>;
};
}
33 changes: 33 additions & 0 deletions core/editor/assetpipeline/src/Bridge_AssetPipeline.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "assetpipeline/Bridge_AssetPipeline.h"
#include "assetpipeline/loaders/FbxLoader.hxx"

namespace assetpipeline = kyanite::editor::assetpipeline;

EXPORTED void AssetPipeline_Init() {

}

EXPORTED void AssetPipeline_LoadMeshes(const uint8_t* buffer, size_t bufferLen, MeshData* meshData, size_t* len) {
auto vec = std::vector<uint8_t>(buffer, buffer + bufferLen);
auto meshes = assetpipeline::loaders::FbxLoader().LoadFromBuffer(vec);

*len = meshes.size();
meshData = new MeshData[*len];
for (size_t i = 0; i < *len; i++) {
meshData[i].vertexCount = meshes[i].vertices.size();
meshData[i].indexCount = meshes[i].indices.size();
meshData[i].vertices = new Vertex[meshData[i].vertexCount];
meshData[i].indices = new uint32_t[meshData[i].indexCount];

memcpy(meshData[i].vertices, meshes[i].vertices.data(), sizeof(Vertex) * meshData[i].vertexCount);
memcpy(meshData[i].indices, meshes[i].indices.data(), sizeof(uint32_t) * meshData[i].indexCount);
}
}

EXPORTED void AssetPipeline_FreeMeshes(MeshData* meshData, size_t len) {
for (size_t i = 0; i < len; i++) {
delete[] meshData[i].vertices;
delete[] meshData[i].indices;
}
delete[] meshData;
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "editor/core/loaders/FbxLoader.hxx"
#include "assetpipeline/loaders/FbxLoader.hxx"

#include <assimp/scene.h>
#include <assimp/Importer.hpp>

namespace kyanite::editor::loaders {
namespace kyanite::editor::assetpipeline::loaders {
FbxLoader::FbxLoader() {

}

FbxLoader::~FbxLoader() {
}

auto FbxLoader::LoadFromBuffer(std::vector<uint8_t> buffer) -> std::vector<engine::rendering::MeshData> {
auto FbxLoader::LoadFromBuffer(std::vector<uint8_t> buffer) -> std::vector<kyanite::engine::rendering::MeshData> {
std::vector<engine::rendering::MeshData> meshes = {};

Assimp::Importer importer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "editor/core/mappers/ModelMapper.hxx"
#include "editor/core/meta/ModelMeta.hxx"
#include "editor/core/loaders/FbxLoader.hxx"
#include "assetpipeline/mappers/ModelMapper.hxx"
#include "assetpipeline/loaders/FbxLoader.hxx"

#include <logger/Logger.hxx>
#include <rendering/Mesh.hxx>
Expand All @@ -10,10 +9,10 @@

namespace rendering = kyanite::engine::rendering;

auto kyanite::editor::mappers::ModelMapper::MapFbx(
auto kyanite::editor::assetpipeline::mappers::ModelMapper::MapFbx(
std::vector<uint8_t> data
) -> std::vector<kyanite::engine::rendering::MeshData> {
auto loader = kyanite::editor::loaders::FbxLoader();
auto loader = kyanite::editor::assetpipeline::loaders::FbxLoader();

try {
return loader.LoadFromBuffer(data);
Expand Down
3 changes: 1 addition & 2 deletions engine/CMakeLists.txt → core/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
add_subdirectory(logger)
add_subdirectory(shared)
add_subdirectory(core)
add_subdirectory(io)
add_subdirectory(imgui)
add_subdirectory(math)
add_subdirectory(audio)
add_subdirectory(input)
add_subdirectory(rendering)
add_subdirectory(assetpackages)
add_subdirectory(ecs)

Loading

0 comments on commit b2f6a58

Please sign in to comment.