Skip to content

Commit

Permalink
gh-1: big engine rework
Browse files Browse the repository at this point in the history
- add IoC & dependency injection to manage singleton systems
- rewrite application and engine core loop exectuion and init
- refactor mesh resoruce (gh-57)
- add io macro to autogen serialization code for structs (gh-46)
- refactor scene nodes structure (gh-36)
  • Loading branch information
EgorOrachyov committed Feb 25, 2024
1 parent ce75ddd commit 443014b
Show file tree
Hide file tree
Showing 327 changed files with 7,191 additions and 6,492 deletions.
82 changes: 40 additions & 42 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,26 @@ add_library(wmoge STATIC
core/crc32.hpp
core/data.cpp
core/data.hpp
core/engine.cpp
core/engine.hpp
core/fast_map.hpp
core/fast_set.hpp
core/fast_vector.hpp
core/hook.cpp
core/hook.hpp
core/ioc_container.cpp
core/ioc_container.hpp
core/layer.cpp
core/layer.hpp
core/log.cpp
core/log.hpp
core/mask.hpp
core/object.cpp
core/object.hpp
core/pool_vector.hpp
core/random.cpp
core/random.hpp
core/ref.cpp
core/ref.hpp
core/signal.hpp
core/status.hpp
core/string_id.cpp
core/string_id.hpp
Expand All @@ -67,11 +69,12 @@ add_library(wmoge STATIC
core/timer.hpp
core/typed_array.hpp
core/typed_map.hpp
core/unrolled_list.hpp
core/uuid.cpp
core/uuid.hpp
core/var.cpp
core/var.hpp
core/weak_ref.cpp
core/weak_ref.hpp
ecs/ecs_component.hpp
ecs/ecs_core.cpp
ecs/ecs_core.hpp
Expand Down Expand Up @@ -110,6 +113,7 @@ add_library(wmoge STATIC
gameplay/action_map.hpp
gameplay/game_token_manager.cpp
gameplay/game_token_manager.hpp
gfx/gfx_buffers.cpp
gfx/gfx_buffers.hpp
gfx/gfx_defs.hpp
gfx/gfx_desc_set.cpp
Expand All @@ -119,10 +123,12 @@ add_library(wmoge STATIC
gfx/gfx_driver.hpp
gfx/gfx_dynamic_buffers.cpp
gfx/gfx_dynamic_buffers.hpp
gfx/gfx_pipeline.cpp
gfx/gfx_pipeline.hpp
gfx/gfx_pass.hpp
gfx/gfx_pass.cpp
gfx/gfx_pipeline_cache.cpp
gfx/gfx_pipeline_cache.hpp
gfx/gfx_pipeline.cpp
gfx/gfx_pipeline.hpp
gfx/gfx_render_pass.cpp
gfx/gfx_render_pass.hpp
gfx/gfx_resource.hpp
Expand Down Expand Up @@ -185,6 +191,7 @@ add_library(wmoge STATIC
hgfx/hgfx_pass_text.hpp
hooks/hook_config.hpp
hooks/hook_logs.hpp
hooks/hook_profiler.hpp
hooks/hook_root_remap.hpp
hooks/hook_uuid_gen.hpp
io/archive.cpp
Expand All @@ -198,6 +205,7 @@ add_library(wmoge STATIC
io/compression.cpp
io/compression.hpp
io/enum.hpp
io/serialization.hpp
io/yaml.cpp
io/yaml.hpp
math/aabb.hpp
Expand Down Expand Up @@ -249,6 +257,8 @@ add_library(wmoge STATIC
platform/input.hpp
platform/input_defs.hpp
platform/input_devices.hpp
platform/time.cpp
platform/time.hpp
platform/window.hpp
platform/window_manager.hpp
platform/glfw/glfw_input.cpp
Expand All @@ -262,22 +272,20 @@ add_library(wmoge STATIC
platform/glfw/glfw_window_manager.hpp
render/aux_draw_manager.cpp
render/aux_draw_manager.hpp
render/camera.cpp
render/camera.hpp
render/canvas.cpp
render/canvas.hpp
render/deferred_pipeline.cpp
render/deferred_pipeline.hpp
render/graphics_pipeline.cpp
render/graphics_pipeline.hpp
render/render_camera.cpp
render/render_camera.hpp
render/light.cpp
render/light.hpp
render/model_instance.cpp
render/model_instance.hpp
render/render_engine.cpp
render/render_engine.hpp
render/render_mesh_skinned.cpp
render/render_mesh_skinned.hpp
render/render_mesh_static.cpp
render/render_mesh_static.hpp
render/render_object.cpp
render/render_object.hpp
render/render_queue.cpp
render/render_queue.hpp
render/render_scene.cpp
Expand All @@ -292,22 +300,14 @@ add_library(wmoge STATIC
render/texture_compression.hpp
render/texture_manager.cpp
render/texture_manager.hpp
render/vertex_factories.cpp
render/vertex_factories.hpp
render/vertex_factory.cpp
render/vertex_factory.hpp
render/view.cpp
render/view.hpp
render/view_manager.cpp
render/view_manager.hpp
render/visibility.cpp
render/visibility.hpp
render/geometry/pass_gbuffer.cpp
render/geometry/pass_gbuffer.hpp
render/post_process/pass_autoexposure.cpp
render/post_process/pass_autoexposure.hpp
render/post_process/pass_bloom.cpp
render/post_process/pass_bloom.hpp
render/post_process/pass_composition.cpp
render/post_process/pass_composition.hpp
render/post_process/pass_tonemap.cpp
render/post_process/pass_tonemap.hpp
resource/array_mesh.cpp
resource/array_mesh.hpp
resource/audio_stream.cpp
resource/audio_stream.hpp
resource/audio_stream_wav.cpp
Expand Down Expand Up @@ -363,24 +363,24 @@ add_library(wmoge STATIC
resource/loaders/resource_loader_wav.hpp
resource/paks/resource_pak_fs.cpp
resource/paks/resource_pak_fs.hpp
scene/scene.cpp
scene/scene.hpp
scene/scene_camera.cpp
scene/scene_camera.hpp
scene/scene_components.cpp
scene/scene_components.hpp
scene/scene_data.cpp
scene/scene_data.hpp
scene/scene_entity.cpp
scene/scene_entity.hpp
scene/scene_manager.cpp
scene/scene_manager.hpp
scene/scene_node_props.cpp
scene/scene_node_props.hpp
scene/scene_node.cpp
scene/scene_node.hpp
scene/scene_properties.cpp
scene/scene_properties.hpp
scene/scene_property.cpp
scene/scene_property.hpp
scene/scene_transform.cpp
scene/scene_transform.hpp
scene/scene_systems.cpp
scene/scene_systems.hpp
scene/scene_tree.cpp
scene/scene_tree.hpp
scene/scene.cpp
scene/scene.hpp
scene/register_classes_scene.cpp
scene/register_classes_scene.hpp
scripting/script_instance.hpp
Expand Down Expand Up @@ -414,16 +414,14 @@ add_library(wmoge STATIC
scripting/lua_bindings/lua_bindings_resource.hpp
scripting/lua_bindings/lua_bindings_scene.cpp
scripting/lua_bindings/lua_bindings_scene.hpp
systems/system_render.hpp
systems/system_transform.hpp
system/engine.cpp
system/engine.hpp
debug/console.cpp
debug/console.hpp
debug/profiler.cpp
debug/profiler.hpp
debug/debug_layer.cpp
debug/debug_layer.hpp
main/main.cpp
main/main.hpp)
debug/debug_layer.hpp)

# specify public include path, so user can reference engine files by modules names
target_include_directories(wmoge PUBLIC ${CMAKE_CURRENT_LIST_DIR}/)
Expand Down
7 changes: 2 additions & 5 deletions engine/core/array_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
/* SOFTWARE. */
/**********************************************************************************/

#ifndef WMOGE_ARRAY_VIEW_HPP
#define WMOGE_ARRAY_VIEW_HPP
#pragma once

#include "svector.hpp"

Expand Down Expand Up @@ -81,6 +80,4 @@ namespace wmoge {
std::size_t m_size = 0;
};

}// namespace wmoge

#endif//WMOGE_ARRAY_VIEW_HPP
}// namespace wmoge
7 changes: 2 additions & 5 deletions engine/core/async.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
/* SOFTWARE. */
/**********************************************************************************/

#ifndef WMOGE_ASYNC_HPP
#define WMOGE_ASYNC_HPP
#pragma once

#include "core/array_view.hpp"
#include "core/fast_vector.hpp"
Expand Down Expand Up @@ -286,6 +285,4 @@ namespace wmoge {
}
};

}// namespace wmoge

#endif//WMOGE_ASYNC_HPP
}// namespace wmoge
7 changes: 2 additions & 5 deletions engine/core/callback_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
/* SOFTWARE. */
/**********************************************************************************/

#ifndef WMOGE_CALLBACK_QUEUE_HPP
#define WMOGE_CALLBACK_QUEUE_HPP
#pragma once

#include "core/synchronization.hpp"

Expand Down Expand Up @@ -74,6 +73,4 @@ namespace wmoge {
m_queue.emplace_back(std::forward<Callable>(callback));
}

}// namespace wmoge

#endif//WMOGE_CALLBACK_QUEUE_HPP
}// namespace wmoge
7 changes: 2 additions & 5 deletions engine/core/callback_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
/* SOFTWARE. */
/**********************************************************************************/

#ifndef WMOGE_CALLBACK_STREAM_HPP
#define WMOGE_CALLBACK_STREAM_HPP
#pragma once

#include "core/synchronization.hpp"

Expand Down Expand Up @@ -92,6 +91,4 @@ namespace wmoge {
wait();
}

}// namespace wmoge

#endif//WMOGE_CALLBACK_STREAM_HPP
}// namespace wmoge
48 changes: 25 additions & 23 deletions engine/core/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@

#include "core/object.hpp"

#include "event/register_classes_event.hpp"
#include "pfx/register_classes_pfx.hpp"
#include "resource/register_classes_resource.hpp"
#include "scene/register_classes_scene.hpp"

namespace wmoge {

ClassMember::ClassMember(StringId name)
Expand All @@ -55,6 +50,24 @@ namespace wmoge {
return m_callable(*this, object, argc, argv, ret);
}

Class* ClassDB::class_emplace(StringId name) {
Class* ptr = class_ptr(name);
if (!ptr) {
auto& storage = m_db[name];
storage = std::make_unique<Class>();
ptr = storage.get();
}
return ptr;
}
Class* ClassDB::class_ptr(StringId name) {
auto query = m_db.find(name);
return query != m_db.end() ? query->second.get() : nullptr;
}
ClassDB* ClassDB::instance() {
static ClassDB g_class_db;
return &g_class_db;
}

const Class* Class::super() const {
return class_ptr(super_name());
}
Expand Down Expand Up @@ -95,9 +108,8 @@ namespace wmoge {
}

Class* Class::class_ptr(StringId name) {
ClassDB* db = class_db();
auto query = db->find(name);
return query != db->end() ? query->second.get() : nullptr;
ClassDB* db = class_db();
return db->class_ptr(name);
}
Class* Class::register_class(const StringId& name, const StringId& super, std::size_t size, std::function<Object*()> instantiate) {
if (!class_ptr(super)) {
Expand All @@ -108,10 +120,9 @@ namespace wmoge {
WG_LOG_ERROR("class: " << name << " already registered");
return cls;
}
ClassDB& db = *class_db();
db[name] = std::make_unique<Class>();
Class* cls = db[name].get();
Class* super_cls = db[super].get();
ClassDB* db = class_db();
Class* cls = db->class_emplace(name);
Class* super_cls = db->class_ptr(super);
cls->m_name = name;
cls->m_super_name = super;
cls->m_size = size;
Expand All @@ -125,8 +136,7 @@ namespace wmoge {
return cls;
}
ClassDB* Class::class_db() {
static ClassDB classDb;
return &classDb;
return ClassDB::instance();
}

Class* Class::add_property(ClassProperty property) {
Expand All @@ -137,21 +147,13 @@ namespace wmoge {
}

void Class::register_types() {
ClassDB& db = *class_db();
db[Object::class_name_static()] = std::make_unique<Class>();
Class* cls = db[Object::class_name_static()].get();

Class* cls = class_db()->class_emplace(Object::class_name_static());
cls->m_name = SID("Object");
cls->m_size = sizeof(Object);
cls->m_instantiate = []() { return new Object(); };
cls->m_supers.emplace(Object::class_name_static());
cls->add_method(ClassMethod(VarType::Int, SID("hash"), {}), &Object::hash, {});
cls->add_method(ClassMethod(VarType::String, SID("to_string"), {}), &Object::to_string, {});

register_classes_event();
register_classes_resource();
register_classes_pfx();
register_classes_scene();
}

}// namespace wmoge
Loading

0 comments on commit 443014b

Please sign in to comment.