From 12b0a90ad0ba524dc7e689895bde99a1b60a8977 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 4 Jan 2022 22:33:59 +0100 Subject: [PATCH] remove old transform and velocity components and replace with new decomposed components focus on 2D for now --- .../src/mm/components/position2d.hpp | 12 + .../src/mm/components/position2d_zoffset.hpp | 11 + .../src/mm/components/position3d.hpp | 12 + .../src/mm/components/rotation2d.hpp | 10 + .../src/mm/components/scale2d.hpp | 12 + .../src/mm/components/serialize/json_glm.hpp | 22 ++ ...son_velocity2d.hpp => json_position2d.hpp} | 4 +- ...form2d.hpp => json_position2d_zoffset.hpp} | 4 +- ...son_velocity3d.hpp => json_position3d.hpp} | 4 +- ...on_transform3d.hpp => json_rotation2d.hpp} | 4 +- .../mm/components/serialize/json_scale2d.hpp | 12 + .../serialize/json_transform4x4.hpp | 12 + .../serialize/json_velocity2d_position.hpp | 12 + .../json_velocity2d_position_intent.hpp | 12 + .../serialize/json_velocity2d_rotation.hpp | 12 + .../src/mm/components/transform2d.hpp | 55 ---- .../src/mm/components/transform3d.hpp | 37 --- .../src/mm/components/transform4x4.hpp | 15 ++ .../src/mm/components/velocity2d.hpp | 16 -- .../src/mm/components/velocity2d_position.hpp | 12 + .../components/velocity2d_position_intent.hpp | 12 + .../src/mm/components/velocity2d_rotation.hpp | 10 + .../src/mm/components/velocity3d.hpp | 13 - .../component_json_serialization_test.cpp | 236 ++++++++---------- framework/imgui/CMakeLists.txt | 20 +- .../imgui/src/mm/imgui/widgets/camera.cpp | 11 +- .../imgui/widgets/components/position2d.cpp | 21 ++ .../{velocity2d.hpp => position2d.hpp} | 8 +- .../widgets/components/position2d_zoffset.cpp | 21 ++ .../widgets/components/position2d_zoffset.hpp | 15 ++ .../imgui/widgets/components/position3d.cpp | 26 ++ .../{transform2d.hpp => position3d.hpp} | 8 +- .../imgui/widgets/components/rotation2d.cpp | 23 ++ .../{transform3d.hpp => rotation2d.hpp} | 8 +- .../mm/imgui/widgets/components/scale2d.cpp | 21 ++ .../mm/imgui/widgets/components/scale2d.hpp | 15 ++ .../widgets/components/tilemap_renderable.cpp | 4 +- .../imgui/widgets/components/transform2d.cpp | 25 -- .../imgui/widgets/components/transform3d.cpp | 25 -- .../imgui/widgets/components/velocity2d.cpp | 24 -- .../components/velocity2d_position.cpp | 21 ++ .../components/velocity2d_position.hpp | 15 ++ .../components/velocity2d_rotation.cpp | 21 ++ .../components/velocity2d_rotation.hpp | 15 ++ .../imgui/src/mm/services/scene_tools.cpp | 32 ++- .../render_tasks/batched_spritesheet.cpp | 34 ++- .../mm/opengl/render_tasks/simple_rect.cpp | 24 +- .../mm/opengl/render_tasks/simple_sprite.cpp | 17 +- .../render_tasks/simple_spritesheet.cpp | 18 +- .../render_tasks/spritesheet_renderable.hpp | 2 + .../src/mm/opengl/render_tasks/tilemap.cpp | 9 +- .../render_tasks/tilemap_renderable.hpp | 2 +- framework/opengl_renderer/test/CMakeLists.txt | 9 + .../batched_spritesheet_render_task_test.cpp | 47 +++- .../test/blur_render_task_test.cpp | 44 +++- .../test/simple_rect_render_task_test.cpp | 45 +++- .../test/simple_sprite_render_task_test.cpp | 58 +++-- .../simple_spritesheet_render_task_test.cpp | 46 +++- .../test/tilemap_render_task_test.cpp | 28 ++- framework/tilemap/src/mm/tilemap.cpp | 15 +- screens/mm_logo/CMakeLists.txt | 1 + .../mm_logo/src/mm/screens/mm_logo_screen.cpp | 39 ++- systems/CMakeLists.txt | 1 + .../mm/systems/player_velocity2d_system.cpp | 15 +- .../mm/systems/player_velocity2d_system.hpp | 7 +- .../mm/systems/simple_velocity_system2d.cpp | 59 ++++- .../mm/systems/simple_velocity_system2d.hpp | 44 +++- .../test/simple_velocity_test.cpp | 19 +- systems/transform/CMakeLists.txt | 23 ++ .../transform/src/mm/systems/transform.cpp | 43 ++++ .../transform/src/mm/systems/transform.hpp | 53 ++++ 71 files changed, 1114 insertions(+), 528 deletions(-) create mode 100644 framework/common_components/src/mm/components/position2d.hpp create mode 100644 framework/common_components/src/mm/components/position2d_zoffset.hpp create mode 100644 framework/common_components/src/mm/components/position3d.hpp create mode 100644 framework/common_components/src/mm/components/rotation2d.hpp create mode 100644 framework/common_components/src/mm/components/scale2d.hpp rename framework/common_components/src/mm/components/serialize/{json_velocity2d.hpp => json_position2d.hpp} (52%) rename framework/common_components/src/mm/components/serialize/{json_transform2d.hpp => json_position2d_zoffset.hpp} (50%) rename framework/common_components/src/mm/components/serialize/{json_velocity3d.hpp => json_position3d.hpp} (52%) rename framework/common_components/src/mm/components/serialize/{json_transform3d.hpp => json_rotation2d.hpp} (50%) create mode 100644 framework/common_components/src/mm/components/serialize/json_scale2d.hpp create mode 100644 framework/common_components/src/mm/components/serialize/json_transform4x4.hpp create mode 100644 framework/common_components/src/mm/components/serialize/json_velocity2d_position.hpp create mode 100644 framework/common_components/src/mm/components/serialize/json_velocity2d_position_intent.hpp create mode 100644 framework/common_components/src/mm/components/serialize/json_velocity2d_rotation.hpp delete mode 100644 framework/common_components/src/mm/components/transform2d.hpp delete mode 100644 framework/common_components/src/mm/components/transform3d.hpp create mode 100644 framework/common_components/src/mm/components/transform4x4.hpp delete mode 100644 framework/common_components/src/mm/components/velocity2d.hpp create mode 100644 framework/common_components/src/mm/components/velocity2d_position.hpp create mode 100644 framework/common_components/src/mm/components/velocity2d_position_intent.hpp create mode 100644 framework/common_components/src/mm/components/velocity2d_rotation.hpp delete mode 100644 framework/common_components/src/mm/components/velocity3d.hpp create mode 100644 framework/imgui/src/mm/imgui/widgets/components/position2d.cpp rename framework/imgui/src/mm/imgui/widgets/components/{velocity2d.hpp => position2d.hpp} (58%) create mode 100644 framework/imgui/src/mm/imgui/widgets/components/position2d_zoffset.cpp create mode 100644 framework/imgui/src/mm/imgui/widgets/components/position2d_zoffset.hpp create mode 100644 framework/imgui/src/mm/imgui/widgets/components/position3d.cpp rename framework/imgui/src/mm/imgui/widgets/components/{transform2d.hpp => position3d.hpp} (52%) create mode 100644 framework/imgui/src/mm/imgui/widgets/components/rotation2d.cpp rename framework/imgui/src/mm/imgui/widgets/components/{transform3d.hpp => rotation2d.hpp} (52%) create mode 100644 framework/imgui/src/mm/imgui/widgets/components/scale2d.cpp create mode 100644 framework/imgui/src/mm/imgui/widgets/components/scale2d.hpp delete mode 100644 framework/imgui/src/mm/imgui/widgets/components/transform2d.cpp delete mode 100644 framework/imgui/src/mm/imgui/widgets/components/transform3d.cpp delete mode 100644 framework/imgui/src/mm/imgui/widgets/components/velocity2d.cpp create mode 100644 framework/imgui/src/mm/imgui/widgets/components/velocity2d_position.cpp create mode 100644 framework/imgui/src/mm/imgui/widgets/components/velocity2d_position.hpp create mode 100644 framework/imgui/src/mm/imgui/widgets/components/velocity2d_rotation.cpp create mode 100644 framework/imgui/src/mm/imgui/widgets/components/velocity2d_rotation.hpp create mode 100644 systems/transform/CMakeLists.txt create mode 100644 systems/transform/src/mm/systems/transform.cpp create mode 100644 systems/transform/src/mm/systems/transform.hpp diff --git a/framework/common_components/src/mm/components/position2d.hpp b/framework/common_components/src/mm/components/position2d.hpp new file mode 100644 index 0000000..ddeda18 --- /dev/null +++ b/framework/common_components/src/mm/components/position2d.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace MM::Components { + + struct Position2D { + glm::vec2 pos {0.f, 0.f}; + }; + +} // MM::Components + diff --git a/framework/common_components/src/mm/components/position2d_zoffset.hpp b/framework/common_components/src/mm/components/position2d_zoffset.hpp new file mode 100644 index 0000000..7aad861 --- /dev/null +++ b/framework/common_components/src/mm/components/position2d_zoffset.hpp @@ -0,0 +1,11 @@ +#pragma once + +namespace MM::Components { + + // used to lift 2D into 3D space. like a z-index in css/svg + struct Position2D_ZOffset { + float z_offset = 500.f; // default camera allows values to be between 0 and 1000 + }; + +} // MM::Components + diff --git a/framework/common_components/src/mm/components/position3d.hpp b/framework/common_components/src/mm/components/position3d.hpp new file mode 100644 index 0000000..e9cb3bc --- /dev/null +++ b/framework/common_components/src/mm/components/position3d.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace MM::Components { + + struct Position3D { + glm::vec3 pos {0.f, 0.f, 0.f}; + }; + +} // MM::Components + diff --git a/framework/common_components/src/mm/components/rotation2d.hpp b/framework/common_components/src/mm/components/rotation2d.hpp new file mode 100644 index 0000000..3f85325 --- /dev/null +++ b/framework/common_components/src/mm/components/rotation2d.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace MM::Components { + + struct Rotation2D { + float rot {0.f}; + }; + +} // MM::Components + diff --git a/framework/common_components/src/mm/components/scale2d.hpp b/framework/common_components/src/mm/components/scale2d.hpp new file mode 100644 index 0000000..e2349df --- /dev/null +++ b/framework/common_components/src/mm/components/scale2d.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace MM::Components { + + struct Scale2D { + glm::vec2 scale {1.f, 1.f}; + }; + +} // MM::Components + diff --git a/framework/common_components/src/mm/components/serialize/json_glm.hpp b/framework/common_components/src/mm/components/serialize/json_glm.hpp index 3216d0f..0f5c05a 100644 --- a/framework/common_components/src/mm/components/serialize/json_glm.hpp +++ b/framework/common_components/src/mm/components/serialize/json_glm.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -12,5 +13,26 @@ namespace glm { NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec3, x, y, z) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec4, x, y, z, w) + //NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(mat4x4, [0], y, z, w) + inline void to_json(nlohmann::json& nlohmann_json_j, const mat4x4& nlohmann_json_t) { + // TODO: make 2d array? + nlohmann_json_j = nlohmann::json::array_t{}; + nlohmann_json_j[0] = nlohmann_json_t[0]; + nlohmann_json_j[1] = nlohmann_json_t[1]; + nlohmann_json_j[2] = nlohmann_json_t[2]; + nlohmann_json_j[3] = nlohmann_json_t[3]; + } + inline void from_json(const nlohmann::json& nlohmann_json_j, mat4x4& nlohmann_json_t) { + if (!nlohmann_json_j.is_array()) { + //throw nlohmann::json::type_error::create(0, "", nlohmann_json_j); + assert(false && "expected array"); + return; // TODO: dont fail silently + } + + nlohmann_json_j.at(0).get_to(nlohmann_json_t[0]); + nlohmann_json_j.at(1).get_to(nlohmann_json_t[1]); + nlohmann_json_j.at(2).get_to(nlohmann_json_t[2]); + nlohmann_json_j.at(3).get_to(nlohmann_json_t[3]); + } } diff --git a/framework/common_components/src/mm/components/serialize/json_velocity2d.hpp b/framework/common_components/src/mm/components/serialize/json_position2d.hpp similarity index 52% rename from framework/common_components/src/mm/components/serialize/json_velocity2d.hpp rename to framework/common_components/src/mm/components/serialize/json_position2d.hpp index 1bca822..7e7998f 100644 --- a/framework/common_components/src/mm/components/serialize/json_velocity2d.hpp +++ b/framework/common_components/src/mm/components/serialize/json_position2d.hpp @@ -2,11 +2,11 @@ #include -#include +#include #include "./json_glm.hpp" namespace MM::Components { - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2D, velocity, rotation) + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D, pos) } // MM::Components diff --git a/framework/common_components/src/mm/components/serialize/json_transform2d.hpp b/framework/common_components/src/mm/components/serialize/json_position2d_zoffset.hpp similarity index 50% rename from framework/common_components/src/mm/components/serialize/json_transform2d.hpp rename to framework/common_components/src/mm/components/serialize/json_position2d_zoffset.hpp index d8d1a1d..e22c1c0 100644 --- a/framework/common_components/src/mm/components/serialize/json_transform2d.hpp +++ b/framework/common_components/src/mm/components/serialize/json_position2d_zoffset.hpp @@ -2,11 +2,11 @@ #include -#include +#include #include "./json_glm.hpp" namespace MM::Components { - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform2D, position, scale, rotation) + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D_ZOffset, z_offset) } // MM::Components diff --git a/framework/common_components/src/mm/components/serialize/json_velocity3d.hpp b/framework/common_components/src/mm/components/serialize/json_position3d.hpp similarity index 52% rename from framework/common_components/src/mm/components/serialize/json_velocity3d.hpp rename to framework/common_components/src/mm/components/serialize/json_position3d.hpp index 3f60626..ce0eb78 100644 --- a/framework/common_components/src/mm/components/serialize/json_velocity3d.hpp +++ b/framework/common_components/src/mm/components/serialize/json_position3d.hpp @@ -2,11 +2,11 @@ #include -#include +#include #include "./json_glm.hpp" namespace MM::Components { - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity3D, velocity, rotation) + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position3D, pos) } // MM::Components diff --git a/framework/common_components/src/mm/components/serialize/json_transform3d.hpp b/framework/common_components/src/mm/components/serialize/json_rotation2d.hpp similarity index 50% rename from framework/common_components/src/mm/components/serialize/json_transform3d.hpp rename to framework/common_components/src/mm/components/serialize/json_rotation2d.hpp index e5eea67..8f3a4cb 100644 --- a/framework/common_components/src/mm/components/serialize/json_transform3d.hpp +++ b/framework/common_components/src/mm/components/serialize/json_rotation2d.hpp @@ -2,11 +2,11 @@ #include -#include +#include #include "./json_glm.hpp" namespace MM::Components { - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform3D, position, scale, rotation) + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Rotation2D, rot) } // MM::Components diff --git a/framework/common_components/src/mm/components/serialize/json_scale2d.hpp b/framework/common_components/src/mm/components/serialize/json_scale2d.hpp new file mode 100644 index 0000000..32a3662 --- /dev/null +++ b/framework/common_components/src/mm/components/serialize/json_scale2d.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +#include + +#include "./json_glm.hpp" + +namespace MM::Components { + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Scale2D, scale) +} // MM::Components + diff --git a/framework/common_components/src/mm/components/serialize/json_transform4x4.hpp b/framework/common_components/src/mm/components/serialize/json_transform4x4.hpp new file mode 100644 index 0000000..513836d --- /dev/null +++ b/framework/common_components/src/mm/components/serialize/json_transform4x4.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +#include + +#include "./json_glm.hpp" + +namespace MM::Components { + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform4x4, trans) +} // MM::Components + diff --git a/framework/common_components/src/mm/components/serialize/json_velocity2d_position.hpp b/framework/common_components/src/mm/components/serialize/json_velocity2d_position.hpp new file mode 100644 index 0000000..cd75b41 --- /dev/null +++ b/framework/common_components/src/mm/components/serialize/json_velocity2d_position.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +#include + +#include "./json_glm.hpp" + +namespace MM::Components { + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPosition, pos_vel) +} // MM::Components + diff --git a/framework/common_components/src/mm/components/serialize/json_velocity2d_position_intent.hpp b/framework/common_components/src/mm/components/serialize/json_velocity2d_position_intent.hpp new file mode 100644 index 0000000..356347b --- /dev/null +++ b/framework/common_components/src/mm/components/serialize/json_velocity2d_position_intent.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +#include + +#include "./json_glm.hpp" + +namespace MM::Components { + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPositionIntent, intent) +} // MM::Components + diff --git a/framework/common_components/src/mm/components/serialize/json_velocity2d_rotation.hpp b/framework/common_components/src/mm/components/serialize/json_velocity2d_rotation.hpp new file mode 100644 index 0000000..9a313e3 --- /dev/null +++ b/framework/common_components/src/mm/components/serialize/json_velocity2d_rotation.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +#include + +#include "./json_glm.hpp" + +namespace MM::Components { + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DRotation, rot_vel) +} // MM::Components + diff --git a/framework/common_components/src/mm/components/transform2d.hpp b/framework/common_components/src/mm/components/transform2d.hpp deleted file mode 100644 index 4a5e2bd..0000000 --- a/framework/common_components/src/mm/components/transform2d.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// -// Created by FlaXxy on 29.07.2018. -// -#pragma once - -#include -#include -#include -#include - -namespace MM::Components { - - struct Transform2D { - glm::vec2 position {0.0f,0.0f}; - glm::vec2 scale {1.0f,1.0f}; - float rotation {0.0f}; - - glm::mat3x3 getTransform3(void) const { - //return transformationMatrix(scale, rotation, position); - glm::mat3x3 res(1); - res[2][0] = position.x; - res[2][1] = position.y; - float const s = sinf(rotation); - float const c = cosf(rotation); - res[0][0] = scale.x * c; - res[0][1] = scale.x * s; - res[1][0] = scale.y * -s; - res[1][1] = scale.y * c; - return res; - } - - glm::mat4x4 getTransform4(float z = 500.f) const { - //return transformationMatrix(scale, rotation, position); - glm::mat4x4 res{1}; - - //res[2][0] = position.x; - //res[2][1] = position.y; - res = glm::translate(res, glm::vec3(position, z)); - - //float const s = sinf(rotation); - //float const c = cosf(rotation); - //res[0][0] = scale.x * c; - //res[0][1] = scale.x * s; - //res[1][0] = scale.y * -s; - //res[1][1] = scale.y * c; - res = glm::rotate(res, rotation, glm::vec3(0.f, 0.f, 1.f)); - - res = glm::scale(res, glm::vec3(scale, 1.f)); - - return res; - } - }; - -} // MM::Components - diff --git a/framework/common_components/src/mm/components/transform3d.hpp b/framework/common_components/src/mm/components/transform3d.hpp deleted file mode 100644 index 2d7846d..0000000 --- a/framework/common_components/src/mm/components/transform3d.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -//#include -#include -#include - -//#include - -namespace MM::Components { - struct Transform3D { - glm::vec3 position {0.0f,0.0f,0.0f}; - glm::vec3 scale {1.0f,1.0f,1.0f}; - float rotation {0.0f}; - - glm::mat4x4 getTransform4(void) const { - //return transformationMatrix(scale, rotation, position); - glm::mat4x4 res{1}; - - //res[2][0] = position.x; - //res[2][1] = position.y; - res = glm::translate(res, position); - - //float const s = sinf(rotation); - //float const c = cosf(rotation); - //res[0][0] = scale.x * c; - //res[0][1] = scale.x * s; - //res[1][0] = scale.y * -s; - //res[1][1] = scale.y * c; - res = glm::rotate(res, rotation, glm::vec3(0.f, 0.f, 1.f)); - - res = glm::scale(res, scale); - - return res; - } - }; -} // MM::Components - diff --git a/framework/common_components/src/mm/components/transform4x4.hpp b/framework/common_components/src/mm/components/transform4x4.hpp new file mode 100644 index 0000000..e87ea08 --- /dev/null +++ b/framework/common_components/src/mm/components/transform4x4.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace MM::Components { + + // tag/flag to track dirty positional data, to reduce computation. + struct DirtyTransformTag {}; + + struct Transform4x4 { + glm::mat4x4 trans {1.f}; + }; + +} // MM::Components + diff --git a/framework/common_components/src/mm/components/velocity2d.hpp b/framework/common_components/src/mm/components/velocity2d.hpp deleted file mode 100644 index 64df1c0..0000000 --- a/framework/common_components/src/mm/components/velocity2d.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// Created by FlaXxy on 29.07.2018. -// -#pragma once - -#include - -namespace MM::Components { - - struct Velocity2D { - glm::vec2 velocity; - float rotation {0.f}; - }; - -} // MM::Components - diff --git a/framework/common_components/src/mm/components/velocity2d_position.hpp b/framework/common_components/src/mm/components/velocity2d_position.hpp new file mode 100644 index 0000000..2f80601 --- /dev/null +++ b/framework/common_components/src/mm/components/velocity2d_position.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace MM::Components { + + struct Velocity2DPosition { + glm::vec2 pos_vel {0.f, 0.f}; + }; + +} // MM::Components + diff --git a/framework/common_components/src/mm/components/velocity2d_position_intent.hpp b/framework/common_components/src/mm/components/velocity2d_position_intent.hpp new file mode 100644 index 0000000..edb4d56 --- /dev/null +++ b/framework/common_components/src/mm/components/velocity2d_position_intent.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace MM::Components { + + struct Velocity2DPositionIntent { + glm::vec2 intent {0.f, 0.f}; + }; + +} // MM::Components + diff --git a/framework/common_components/src/mm/components/velocity2d_rotation.hpp b/framework/common_components/src/mm/components/velocity2d_rotation.hpp new file mode 100644 index 0000000..7a2115d --- /dev/null +++ b/framework/common_components/src/mm/components/velocity2d_rotation.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace MM::Components { + + struct Velocity2DRotation { + float rot_vel {0.f}; + }; + +} // MM::Components + diff --git a/framework/common_components/src/mm/components/velocity3d.hpp b/framework/common_components/src/mm/components/velocity3d.hpp deleted file mode 100644 index 3253ce2..0000000 --- a/framework/common_components/src/mm/components/velocity3d.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include - -namespace MM::Components { - - struct Velocity3D { - glm::vec3 velocity {0.f, 0.f, 0.f}; - glm::vec3 rotation {0.f, 0.f, 0.f}; - }; - -} // MM::Components - diff --git a/framework/common_components/test/component_json_serialization_test.cpp b/framework/common_components/test/component_json_serialization_test.cpp index cc1e837..026281f 100644 --- a/framework/common_components/test/component_json_serialization_test.cpp +++ b/framework/common_components/test/component_json_serialization_test.cpp @@ -1,33 +1,37 @@ +#include "mm/components/position2d.hpp" #include #include #include -#include -#include -#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -/*#define PARSE_TEST_MACRO(type, json_string, comp_val) \ -TEST(common_components_json_serialization, type) { \ - MM::Components::type comp; \ - { \ - auto j = nlohmann::json::parse(json_string); \ - EXPECT_NO_THROW({ comp = j; }); \ - ASSERT_EQ(comp, (comp_val)); \ +#define TEST_JSON_SERL_EXPAND(x) x +#define TEST_JSON_SERL_IN_OUT(TYPE, JSON_STR, TEST_CORPUS) \ +TEST(common_components_json_serialization, in_out_##TYPE) { \ + MM::Components::TYPE comp; \ + { /* in */ \ + auto j = nlohmann::json::parse(JSON_STR); \ + comp = j; \ + TEST_CORPUS \ } \ - { \ + { /* out */ \ nlohmann::json j; \ - [>EXPECT_NO_THROW({ j = comp; });<] \ - ASSERT_EQ(json_string, j.dump()); \ + j = comp; \ + ASSERT_EQ(JSON_STR, j.dump()); \ } \ } -PARSE_TEST_MACRO( - Name, - "{\"str\":\"test_name\"}", - MM::Components::Name{"test_name"} -); */ TEST(common_components_json_serialization, in_out_name) { MM::Components::Name comp; @@ -72,137 +76,113 @@ TEST(common_components_json_serialization, in_out_name_fail) { // ############################################################## -TEST(common_components_json_serialization, in_out_color) { - MM::Components::Color comp; - - const char* json_test_file = R"({"color":{"w":1337.0,"x":0.0,"y":1.0,"z":3.0}})"; - - { // in - auto j = nlohmann::json::parse(json_test_file); - - EXPECT_NO_THROW({ - comp = j; - }); - - glm::vec4 comp_val{0.f, 1.f, 3.f, 1337.f}; +TEST_JSON_SERL_IN_OUT( + Color, + R"({"color":{"w":1337.0,"x":0.0,"y":1.0,"z":3.0}})", + TEST_JSON_SERL_EXPAND({ + glm::vec4 comp_val(0.f, 1.f, 3.f, 1337.f); ASSERT_EQ(comp.color.x, comp_val.x); ASSERT_EQ(comp.color.y, comp_val.y); ASSERT_EQ(comp.color.z, comp_val.z); ASSERT_EQ(comp.color.w, comp_val.w); - } - - { // out - nlohmann::json j; - - EXPECT_NO_THROW({ - j = comp; - }); - - ASSERT_EQ(json_test_file, j.dump()); - } -} + }) +) // ############################################################## -TEST(common_components_json_serialization, in_out_transform2d) { - MM::Components::Transform2D comp; - - const char* json_test_file = R"({"position":{"x":42.0,"y":6.0},"rotation":99.0,"scale":{"x":1337.0,"y":68.0}})"; - - { // in - auto j = nlohmann::json::parse(json_test_file); - - EXPECT_NO_THROW({ - comp = j; - }); - - ASSERT_EQ(comp.position.x, 42.f); - ASSERT_EQ(comp.position.y, 6.f); - - ASSERT_EQ(comp.scale.x, 1337.f); - ASSERT_EQ(comp.scale.y, 68.f); - - ASSERT_EQ(comp.rotation, 99.f); - } - - { // out - nlohmann::json j; - - EXPECT_NO_THROW({ - j = comp; - }); - - ASSERT_EQ(json_test_file, j.dump()); - } -} +TEST_JSON_SERL_IN_OUT( + Position2D, + R"({"pos":{"x":42.0,"y":6.0}})", + TEST_JSON_SERL_EXPAND( + ASSERT_EQ(comp.pos.x, 42.f); + ASSERT_EQ(comp.pos.y, 6.f); + ) +) // ############################################################## -TEST(common_components_json_serialization, in_out_transform3d) { - MM::Components::Transform3D comp; - - const char* json_test_file = R"({"position":{"x":42.0,"y":6.0,"z":66.0},"rotation":99.0,"scale":{"x":1337.0,"y":68.0,"z":60.0}})"; - - { // in - auto j = nlohmann::json::parse(json_test_file); - - EXPECT_NO_THROW({ - comp = j; - }); - - ASSERT_EQ(comp.position.x, 42.f); - ASSERT_EQ(comp.position.y, 6.f); - ASSERT_EQ(comp.position.z, 66.f); - - ASSERT_EQ(comp.scale.x, 1337.f); - ASSERT_EQ(comp.scale.y, 68.f); - ASSERT_EQ(comp.scale.z, 60.f); - - // TODO: prob needs 3 rotations... - ASSERT_EQ(comp.rotation, 99.f); - } - - { // out - nlohmann::json j; - - EXPECT_NO_THROW({ - j = comp; - }); - - ASSERT_EQ(json_test_file, j.dump()); - } -} +TEST_JSON_SERL_IN_OUT( + Position2D_ZOffset, + R"({"z_offset":3.0})", + TEST_JSON_SERL_EXPAND( + ASSERT_EQ(comp.z_offset, 3.f); + ) +) // ############################################################## -TEST(common_components_json_serialization, in_out_velocity2d) { - MM::Components::Velocity2D comp; +TEST_JSON_SERL_IN_OUT( + Position3D, + R"({"pos":{"x":42.0,"y":6.0,"z":44.0}})", + TEST_JSON_SERL_EXPAND( + ASSERT_EQ(comp.pos.x, 42.f); + ASSERT_EQ(comp.pos.y, 6.f); + ASSERT_EQ(comp.pos.z, 44.f); + ) +) - const char* json_test_file = R"({"rotation":99.0,"velocity":{"x":42.0,"y":6.0}})"; +// ############################################################## - { // in - auto j = nlohmann::json::parse(json_test_file); +TEST_JSON_SERL_IN_OUT( + Rotation2D, + R"({"rot":42.0})", + TEST_JSON_SERL_EXPAND( + ASSERT_EQ(comp.rot, 42.f); + ) +) - EXPECT_NO_THROW({ - comp = j; - }); +// ############################################################## - ASSERT_EQ(comp.velocity.x, 42.f); - ASSERT_EQ(comp.velocity.y, 6.f); +TEST_JSON_SERL_IN_OUT( + Scale2D, + R"({"scale":{"x":42.0,"y":6.0}})", + TEST_JSON_SERL_EXPAND( + ASSERT_EQ(comp.scale.x, 42.f); + ASSERT_EQ(comp.scale.y, 6.f); + ) +) - ASSERT_EQ(comp.rotation, 99.f); - } +// ############################################################## - { // out - nlohmann::json j; +TEST_JSON_SERL_IN_OUT( + Transform4x4, + R"({"trans":[{"w":0.0,"x":1.0,"y":0.0,"z":0.0},{"w":0.0,"x":0.0,"y":1.0,"z":0.0},{"w":0.0,"x":0.0,"y":0.0,"z":1.0},{"w":1.0,"x":0.0,"y":0.0,"z":0.0}]})", + TEST_JSON_SERL_EXPAND( + ASSERT_EQ(comp.trans, glm::mat4x4{1.f}); + ) +) - EXPECT_NO_THROW({ - j = comp; - }); +// ############################################################## - ASSERT_EQ(json_test_file, j.dump()); - } -} +TEST_JSON_SERL_IN_OUT( + Velocity2DPosition, + R"({"pos_vel":{"x":42.0,"y":6.0}})", + TEST_JSON_SERL_EXPAND( + ASSERT_EQ(comp.pos_vel.x, 42.f); + ASSERT_EQ(comp.pos_vel.y, 6.f); + ) +) + +// ############################################################## + +TEST_JSON_SERL_IN_OUT( + Velocity2DPositionIntent, + R"({"intent":{"x":42.0,"y":6.0}})", + TEST_JSON_SERL_EXPAND( + ASSERT_EQ(comp.intent.x, 42.f); + ASSERT_EQ(comp.intent.y, 6.f); + ) +) + +// ############################################################## + +TEST_JSON_SERL_IN_OUT( + Velocity2DRotation, + R"({"rot_vel":42.0})", + TEST_JSON_SERL_EXPAND( + ASSERT_EQ(comp.rot_vel, 42.f); + ) +) // ############################################################## diff --git a/framework/imgui/CMakeLists.txt b/framework/imgui/CMakeLists.txt index be8aa7d..7280d45 100644 --- a/framework/imgui/CMakeLists.txt +++ b/framework/imgui/CMakeLists.txt @@ -36,9 +36,13 @@ add_library(imgui_widgets ./src/mm/imgui/widgets/auto_wrap.hpp ./src/mm/imgui/widgets/components/name.hpp - ./src/mm/imgui/widgets/components/transform2d.hpp - ./src/mm/imgui/widgets/components/transform3d.hpp - ./src/mm/imgui/widgets/components/velocity2d.hpp + ./src/mm/imgui/widgets/components/position2d.hpp + ./src/mm/imgui/widgets/components/position2d_zoffset.hpp + ./src/mm/imgui/widgets/components/position3d.hpp + ./src/mm/imgui/widgets/components/rotation2d.hpp + ./src/mm/imgui/widgets/components/scale2d.hpp + ./src/mm/imgui/widgets/components/velocity2d_position.hpp + ./src/mm/imgui/widgets/components/velocity2d_rotation.hpp ./src/mm/imgui/widgets/components/view_dir2d.hpp ./src/mm/imgui/widgets/components/view_dir3d.hpp ./src/mm/imgui/widgets/components/color.hpp @@ -57,9 +61,13 @@ add_library(imgui_widgets ./src/mm/imgui/widgets/texture_resource_manager.cpp ./src/mm/imgui/widgets/components/name.cpp - ./src/mm/imgui/widgets/components/transform2d.cpp - ./src/mm/imgui/widgets/components/transform3d.cpp - ./src/mm/imgui/widgets/components/velocity2d.cpp + ./src/mm/imgui/widgets/components/position2d.cpp + ./src/mm/imgui/widgets/components/position2d_zoffset.cpp + ./src/mm/imgui/widgets/components/position3d.cpp + ./src/mm/imgui/widgets/components/rotation2d.cpp + ./src/mm/imgui/widgets/components/scale2d.cpp + ./src/mm/imgui/widgets/components/velocity2d_position.cpp + ./src/mm/imgui/widgets/components/velocity2d_rotation.cpp ./src/mm/imgui/widgets/components/view_dir2d.cpp ./src/mm/imgui/widgets/components/view_dir3d.cpp ./src/mm/imgui/widgets/components/color.cpp diff --git a/framework/imgui/src/mm/imgui/widgets/camera.cpp b/framework/imgui/src/mm/imgui/widgets/camera.cpp index b242950..c5fec06 100644 --- a/framework/imgui/src/mm/imgui/widgets/camera.cpp +++ b/framework/imgui/src/mm/imgui/widgets/camera.cpp @@ -4,7 +4,8 @@ #include "./entity.hpp" -#include +#include +#include #include @@ -37,10 +38,12 @@ void Camera3D(MM::Scene& scene) { MM::ImGuiWidgets::Entity(tracking, scene); if (scene.valid(tracking)) { - if (scene.all_of(tracking)) { - camera->translation = {scene.get(tracking).position, 0.f}; + if (scene.all_of(tracking)) { + camera->translation = {scene.get(tracking).pos, 0.f}; + } else if (scene.all_of(tracking)) { // "3d" fallback + camera->translation = scene.get(tracking).pos; } else { - ImGui::TextUnformatted("error: Entity has no Transform"); + ImGui::TextUnformatted("error: Entity has neither Position2D nor Position3D"); } } } else { diff --git a/framework/imgui/src/mm/imgui/widgets/components/position2d.cpp b/framework/imgui/src/mm/imgui/widgets/components/position2d.cpp new file mode 100644 index 0000000..8ab5a7d --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/position2d.cpp @@ -0,0 +1,21 @@ +#include "./position2d.hpp" + +#include + +namespace MM::ImGuiWidgets::Components { + +void Position(MM::Components::Position2D& p) { + ImGui::DragFloat2("position (x,y)##Position2D", &p.pos.x, 0.1f); +} + +} // MM::ImGuiWidgets::Components + +namespace MM { + +template <> +void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { + ImGuiWidgets::Components::Position(reg.get(e)); +} + +} // MM + diff --git a/framework/imgui/src/mm/imgui/widgets/components/velocity2d.hpp b/framework/imgui/src/mm/imgui/widgets/components/position2d.hpp similarity index 58% rename from framework/imgui/src/mm/imgui/widgets/components/velocity2d.hpp rename to framework/imgui/src/mm/imgui/widgets/components/position2d.hpp index 0dba515..6efd56d 100644 --- a/framework/imgui/src/mm/imgui/widgets/components/velocity2d.hpp +++ b/framework/imgui/src/mm/imgui/widgets/components/position2d.hpp @@ -1,15 +1,15 @@ #pragma once -#include -#include +#include #include +#include namespace MM::ImGuiWidgets::Components { - void Velocity(MM::Components::Velocity2D& v); + void Position(MM::Components::Position2D& p); } namespace MM { template <> - void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); + void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); } diff --git a/framework/imgui/src/mm/imgui/widgets/components/position2d_zoffset.cpp b/framework/imgui/src/mm/imgui/widgets/components/position2d_zoffset.cpp new file mode 100644 index 0000000..f66bc93 --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/position2d_zoffset.cpp @@ -0,0 +1,21 @@ +#include "./position2d_zoffset.hpp" + +#include + +namespace MM::ImGuiWidgets::Components { + +void Position_ZOffset(MM::Components::Position2D_ZOffset& z) { + ImGui::SliderFloat("zoffset##Position2D_ZOffset", &z.z_offset, 0.f, 1000.f); // TODO: this depends on the camera far and near plane... somewhat +} + +} // MM::ImGuiWidgets::Components + +namespace MM { + +template <> +void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { + ImGuiWidgets::Components::Position_ZOffset(reg.get(e)); +} + +} // MM + diff --git a/framework/imgui/src/mm/imgui/widgets/components/position2d_zoffset.hpp b/framework/imgui/src/mm/imgui/widgets/components/position2d_zoffset.hpp new file mode 100644 index 0000000..55c9c65 --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/position2d_zoffset.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include +#include +#include + +namespace MM::ImGuiWidgets::Components { + void Position_ZOffset(MM::Components::Position2D_ZOffset& t); +} + +namespace MM { + template <> + void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); +} + diff --git a/framework/imgui/src/mm/imgui/widgets/components/position3d.cpp b/framework/imgui/src/mm/imgui/widgets/components/position3d.cpp new file mode 100644 index 0000000..67ef1bb --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/position3d.cpp @@ -0,0 +1,26 @@ +#include "./position3d.hpp" + +#include + +//#include + +namespace MM::ImGuiWidgets::Components { + +void Transform(MM::Components::Position3D& p) { + //ImGui::DragFloat3("position (x,y,z)##Transform3D", &t.position.x, 0.1f); + ImGui::DragFloat3("position (x,y,z)##Position3D", &p.pos.x, 0.1f); + //ImGui::SliderFloat("rotation##Transform3D", &t.rotation, 0.f, glm::pi() * 2.f); + //ImGui::DragFloat3("scale (x,y,z)##Transform3D", &t.scale.x, 1.f, 0.f); +} + +} // MM::ImGuiWidgets::Components + +namespace MM { + +template <> +void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { + ImGuiWidgets::Components::Transform(reg.get(e)); +} + +} // MM + diff --git a/framework/imgui/src/mm/imgui/widgets/components/transform2d.hpp b/framework/imgui/src/mm/imgui/widgets/components/position3d.hpp similarity index 52% rename from framework/imgui/src/mm/imgui/widgets/components/transform2d.hpp rename to framework/imgui/src/mm/imgui/widgets/components/position3d.hpp index c716129..c931288 100644 --- a/framework/imgui/src/mm/imgui/widgets/components/transform2d.hpp +++ b/framework/imgui/src/mm/imgui/widgets/components/position3d.hpp @@ -1,15 +1,15 @@ #pragma once -#include -#include +#include #include +#include namespace MM::ImGuiWidgets::Components { - void Transform(MM::Components::Transform2D& t); + void Transform(MM::Components::Position3D& p); } namespace MM { template <> - void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); + void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); } diff --git a/framework/imgui/src/mm/imgui/widgets/components/rotation2d.cpp b/framework/imgui/src/mm/imgui/widgets/components/rotation2d.cpp new file mode 100644 index 0000000..61804e7 --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/rotation2d.cpp @@ -0,0 +1,23 @@ +#include "./rotation2d.hpp" + +#include + +#include + +namespace MM::ImGuiWidgets::Components { + +void Rotation(MM::Components::Rotation2D& r) { + ImGui::SliderFloat("rotation##Rotation2D", &r.rot, 0.f, glm::two_pi()); +} + +} // MM::ImGuiWidgets::Components + +namespace MM { + +template <> +void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { + ImGuiWidgets::Components::Rotation(reg.get(e)); +} + +} // MM + diff --git a/framework/imgui/src/mm/imgui/widgets/components/transform3d.hpp b/framework/imgui/src/mm/imgui/widgets/components/rotation2d.hpp similarity index 52% rename from framework/imgui/src/mm/imgui/widgets/components/transform3d.hpp rename to framework/imgui/src/mm/imgui/widgets/components/rotation2d.hpp index 09428fc..18a454d 100644 --- a/framework/imgui/src/mm/imgui/widgets/components/transform3d.hpp +++ b/framework/imgui/src/mm/imgui/widgets/components/rotation2d.hpp @@ -1,15 +1,15 @@ #pragma once -#include -#include +#include #include +#include namespace MM::ImGuiWidgets::Components { - void Transform(MM::Components::Transform3D& t); + void Rotation(MM::Components::Rotation2D& r); } namespace MM { template <> - void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); + void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); } diff --git a/framework/imgui/src/mm/imgui/widgets/components/scale2d.cpp b/framework/imgui/src/mm/imgui/widgets/components/scale2d.cpp new file mode 100644 index 0000000..b60e8e4 --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/scale2d.cpp @@ -0,0 +1,21 @@ +#include "./scale2d.hpp" + +#include + +namespace MM::ImGuiWidgets::Components { + +void Scale(MM::Components::Scale2D& s) { + ImGui::DragFloat2("scale (x,y)##Scale2D", &s.scale.x, 0.01f); +} + +} // MM::ImGuiWidgets::Components + +namespace MM { + +template <> +void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { + ImGuiWidgets::Components::Scale(reg.get(e)); +} + +} // MM + diff --git a/framework/imgui/src/mm/imgui/widgets/components/scale2d.hpp b/framework/imgui/src/mm/imgui/widgets/components/scale2d.hpp new file mode 100644 index 0000000..510ed60 --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/scale2d.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include +#include +#include + +namespace MM::ImGuiWidgets::Components { + void Scale(MM::Components::Scale2D& s); +} + +namespace MM { + template <> + void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); +} + diff --git a/framework/imgui/src/mm/imgui/widgets/components/tilemap_renderable.cpp b/framework/imgui/src/mm/imgui/widgets/components/tilemap_renderable.cpp index 4497af0..a390e37 100644 --- a/framework/imgui/src/mm/imgui/widgets/components/tilemap_renderable.cpp +++ b/framework/imgui/src/mm/imgui/widgets/components/tilemap_renderable.cpp @@ -9,8 +9,6 @@ namespace MM::ImGuiWidgets::Components { void TilemapRenderable(MM::OpenGL::TilemapRenderable& tm_r) { - ImGui::InputFloat("z", &tm_r.z); - for (size_t i = 0; i < tm_r.sprite_layer.size(); i++) { ImGui::Separator(); std::string label = "sprite_sheet##"; @@ -19,7 +17,7 @@ void TilemapRenderable(MM::OpenGL::TilemapRenderable& tm_r) { } } -} +} // MM::ImGuiWidgets::Components namespace MM { diff --git a/framework/imgui/src/mm/imgui/widgets/components/transform2d.cpp b/framework/imgui/src/mm/imgui/widgets/components/transform2d.cpp deleted file mode 100644 index 0904be9..0000000 --- a/framework/imgui/src/mm/imgui/widgets/components/transform2d.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "./transform2d.hpp" - -#include - -#include - -namespace MM::ImGuiWidgets::Components { - -void Transform(MM::Components::Transform2D& t) { - ImGui::DragFloat2("position (x,y)##Transform", &t.position.x, 0.1f); - ImGui::SliderFloat("rotation##Transform", &t.rotation, 0.f, glm::pi() * 2.f); - ImGui::DragFloat2("scale (x,y)##Transform", &t.scale.x, 1.f, 0.f); -} - -} - -namespace MM { - -template <> -void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { - ImGuiWidgets::Components::Transform(reg.get(e)); -} - -} // MM - diff --git a/framework/imgui/src/mm/imgui/widgets/components/transform3d.cpp b/framework/imgui/src/mm/imgui/widgets/components/transform3d.cpp deleted file mode 100644 index 9c2251a..0000000 --- a/framework/imgui/src/mm/imgui/widgets/components/transform3d.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "./transform3d.hpp" - -#include - -#include - -namespace MM::ImGuiWidgets::Components { - -void Transform(MM::Components::Transform3D& t) { - ImGui::DragFloat3("position (x,y,z)##Transform3D", &t.position.x, 0.1f); - ImGui::SliderFloat("rotation##Transform3D", &t.rotation, 0.f, glm::pi() * 2.f); - ImGui::DragFloat3("scale (x,y,z)##Transform3D", &t.scale.x, 1.f, 0.f); -} - -} - -namespace MM { - -template <> -void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { - ImGuiWidgets::Components::Transform(reg.get(e)); -} - -} // MM - diff --git a/framework/imgui/src/mm/imgui/widgets/components/velocity2d.cpp b/framework/imgui/src/mm/imgui/widgets/components/velocity2d.cpp deleted file mode 100644 index c019864..0000000 --- a/framework/imgui/src/mm/imgui/widgets/components/velocity2d.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "./velocity2d.hpp" - -#include - -#include - -namespace MM::ImGuiWidgets::Components { - -void Velocity(MM::Components::Velocity2D& v) { - ImGui::DragFloat2("velocity (x,y)##Velocity", &v.velocity.x, 0.1f); - ImGui::SliderFloat("rotation##Velocity", &v.rotation, -glm::two_pi(), glm::two_pi()); -} - -} - -namespace MM { - -template <> -void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { - ImGuiWidgets::Components::Velocity(reg.get(e)); -} - -} // MM - diff --git a/framework/imgui/src/mm/imgui/widgets/components/velocity2d_position.cpp b/framework/imgui/src/mm/imgui/widgets/components/velocity2d_position.cpp new file mode 100644 index 0000000..8999b13 --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/velocity2d_position.cpp @@ -0,0 +1,21 @@ +#include "./velocity2d_position.hpp" + +#include + +namespace MM::ImGuiWidgets::Components { + +void VelocityPosition(MM::Components::Velocity2DPosition& v) { + ImGui::DragFloat2("velocity (x,y)##Velocity2DPosition", &v.pos_vel.x, 0.1f); +} + +} // MM::ImGuiWidgets::Components + +namespace MM { + +template <> +void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { + ImGuiWidgets::Components::VelocityPosition(reg.get(e)); +} + +} // MM + diff --git a/framework/imgui/src/mm/imgui/widgets/components/velocity2d_position.hpp b/framework/imgui/src/mm/imgui/widgets/components/velocity2d_position.hpp new file mode 100644 index 0000000..41dd878 --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/velocity2d_position.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include +#include +#include + +namespace MM::ImGuiWidgets::Components { + void VelocityPosition(MM::Components::Velocity2DPosition& v); +} + +namespace MM { + template <> + void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); +} + diff --git a/framework/imgui/src/mm/imgui/widgets/components/velocity2d_rotation.cpp b/framework/imgui/src/mm/imgui/widgets/components/velocity2d_rotation.cpp new file mode 100644 index 0000000..2c72de4 --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/velocity2d_rotation.cpp @@ -0,0 +1,21 @@ +#include "./velocity2d_rotation.hpp" + +#include + +namespace MM::ImGuiWidgets::Components { + +void VelocityRotation(MM::Components::Velocity2DRotation& v) { + ImGui::DragFloat("rotation##Velocity2DRotation", &v.rot_vel); +} + +} // MM::ImGuiWidgets::Components + +namespace MM { + +template <> +void ComponentEditorWidget(MM::Scene& reg, MM::Entity e) { + ImGuiWidgets::Components::VelocityRotation(reg.get(e)); +} + +} // MM + diff --git a/framework/imgui/src/mm/imgui/widgets/components/velocity2d_rotation.hpp b/framework/imgui/src/mm/imgui/widgets/components/velocity2d_rotation.hpp new file mode 100644 index 0000000..7966950 --- /dev/null +++ b/framework/imgui/src/mm/imgui/widgets/components/velocity2d_rotation.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include +#include +#include + +namespace MM::ImGuiWidgets::Components { + void VelocityRotation(MM::Components::Velocity2DRotation& v); +} + +namespace MM { + template <> + void ComponentEditorWidget(MM::Scene& reg, MM::Entity e); +} + diff --git a/framework/imgui/src/mm/services/scene_tools.cpp b/framework/imgui/src/mm/services/scene_tools.cpp index a6595b1..92b3314 100644 --- a/framework/imgui/src/mm/services/scene_tools.cpp +++ b/framework/imgui/src/mm/services/scene_tools.cpp @@ -1,8 +1,5 @@ #include "./scene_tools.hpp" - -//#include - -//#include +#include "mm/components/velocity2d_rotation.hpp" #include @@ -10,18 +7,18 @@ #include -#include -#include -#include #include -//#include #include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -29,9 +26,6 @@ #include -//#include -//#include - #include #define LOGIGS(x) LOG("ImGuiSceneToolsService", x) @@ -48,9 +42,13 @@ namespace MM::Services { _entity_editor.show_window = false; _entity_editor.registerComponent("Name"); - _entity_editor.registerComponent("Transform2D"); - _entity_editor.registerComponent("Transform3D"); - _entity_editor.registerComponent("Velocity2D"); + _entity_editor.registerComponent("Position2D"); + _entity_editor.registerComponent("Position2D_ZOffset"); + _entity_editor.registerComponent("Position3D"); + _entity_editor.registerComponent("Rotation2D"); + _entity_editor.registerComponent("Scale2D"); + _entity_editor.registerComponent("Velocity2DPosition"); + _entity_editor.registerComponent("Velocity2DRotation"); _entity_editor.registerComponent("ViewDir2D"); _entity_editor.registerComponent("ViewDir3D"); _entity_editor.registerComponent("Color"); diff --git a/framework/opengl_renderer/src/mm/opengl/render_tasks/batched_spritesheet.cpp b/framework/opengl_renderer/src/mm/opengl/render_tasks/batched_spritesheet.cpp index 786f825..fc1b742 100644 --- a/framework/opengl_renderer/src/mm/opengl/render_tasks/batched_spritesheet.cpp +++ b/framework/opengl_renderer/src/mm/opengl/render_tasks/batched_spritesheet.cpp @@ -1,7 +1,5 @@ #include "./batched_spritesheet.hpp" -#include - #include #include #include @@ -13,11 +11,9 @@ #include #include -#include +#include #include - #include "./spritesheet_renderable.hpp" -#include #include #ifndef MM_OPENGL_3_GLES @@ -67,18 +63,17 @@ BatchedSpriteSheet::~BatchedSpriteSheet(void) { void BatchedSpriteSheet::render(Services::OpenGLRenderer& rs, Engine& engine) { ZoneScopedN("MM::OpenGL::RenderTasks::BatchedSpriteSheet::render"); - auto* scene_ss = engine.tryService(); - // no scene - if (scene_ss == nullptr) { - return; + auto* ssi = engine.tryService(); + if (ssi == nullptr) { + return; // nothing to draw } - auto& scene = scene_ss->getScene(); + auto& scene = ssi->getScene(); struct sp_data { SpriteSheet sp; struct instance_data { - MM::Components::Transform2D* trans = nullptr; + const MM::Components::Transform4x4* trans = nullptr; glm::vec4* color = nullptr; uint32_t tile_index = 0; }; @@ -87,13 +82,11 @@ void BatchedSpriteSheet::render(Services::OpenGLRenderer& rs, Engine& engine) { // HACK: assume same sp for same texture std::unordered_map batch_map; - auto view = scene.view(); - - view.each([&](auto e, Components::Transform2D& t, SpriteSheetRenderable& spr) { - // if off screen, early out - if (false) { // TODO: - return; - } + scene.view().each([this, &scene, &batch_map](entt::entity e, const auto& t, auto& spr) { + //// if off screen, early out + //if (false) { // TODO: + //return; + //} assert(spr.sp.tex); // debug @@ -139,7 +132,8 @@ void BatchedSpriteSheet::render(Services::OpenGLRenderer& rs, Engine& engine) { auto* inst_memory = gl_inst_buffer->map(sp_ent.second.instances.size(), GL_DYNAMIC_DRAW); for (auto& inst : sp_ent.second.instances) { - inst_memory->pos_trans = inst.trans->getTransform4(inst.trans->position.y/10.f + 500.f); + //inst_memory->pos_trans = inst.trans->getTransform4(inst.trans->position.y/10.f + 500.f); + inst_memory->pos_trans = inst.trans->trans; // TODO: this is ugly inst_memory->color = *inst.color; inst_memory->tile_index = inst.tile_index; @@ -149,6 +143,8 @@ void BatchedSpriteSheet::render(Services::OpenGLRenderer& rs, Engine& engine) { static_assert(std::is_standard_layout::value); // check if offsetof() is usable + // TODO: optimize, dont call attrib pointer each draw + // mat4, oof // attptr 1-4 for (size_t i = 0; i < 4; i++) { diff --git a/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_rect.cpp b/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_rect.cpp index df1a15e..49c3750 100644 --- a/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_rect.cpp +++ b/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_rect.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -56,6 +56,13 @@ SimpleRect::~SimpleRect(void) { void SimpleRect::render(Services::OpenGLRenderer& rs, Engine& engine) { ZoneScopedN("MM::OpenGL::RenderTasks::SimpleRect::render"); + auto* ssi = engine.tryService(); + if (ssi == nullptr) { + return; // nothing to draw + } + + auto& scene = ssi->getScene(); + rs.targets[target_fbo]->bind(FrameBufferObject::RW); glEnable(GL_DEPTH_TEST); @@ -64,8 +71,6 @@ void SimpleRect::render(Services::OpenGLRenderer& rs, Engine& engine) { _shader->bind(); _vao->bind(); - auto& scene = engine.tryService()->getScene(); - Camera3D* cam = scene.try_ctx(); if (!cam) { cam = &default_cam; @@ -73,12 +78,8 @@ void SimpleRect::render(Services::OpenGLRenderer& rs, Engine& engine) { auto vp = cam->getViewProjection(); - auto view = scene.view(); - - for (auto& e : view) { - auto& t = view.get(e); - - _shader->setUniformMat4f("_WVP", vp * t.getTransform4(t.position.y/10.f + 500.f)); + scene.view().each([this, &scene, &vp](entt::entity e, const auto& t) { + _shader->setUniformMat4f("_WVP", vp * t.trans); if (scene.all_of(e)) { _shader->setUniform4f("_color", scene.get(e).color); @@ -86,9 +87,8 @@ void SimpleRect::render(Services::OpenGLRenderer& rs, Engine& engine) { _shader->setUniform4f("_color", default_color); } - glDrawArrays(GL_TRIANGLES, 0, 6); - } + }); _vao->unbind(); _shader->unbind(); @@ -106,7 +106,7 @@ in vec2 _vertexPosition; uniform mat4 _WVP; void main() { - gl_Position = _WVP * vec4(_vertexPosition, 0, 1); + gl_Position = _WVP * vec4(_vertexPosition, 0.0, 1.0); })") FS_CONST_MOUNT_FILE(fragmentPath, diff --git a/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_sprite.cpp b/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_sprite.cpp index 45c28d6..0234363 100644 --- a/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_sprite.cpp +++ b/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_sprite.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -62,6 +62,13 @@ SimpleSprite::~SimpleSprite(void) { void SimpleSprite::render(Services::OpenGLRenderer& rs, Engine& engine) { ZoneScopedN("MM::OpenGL::RenderTasks::SimpleSprite::render"); + auto* ssi = engine.tryService(); + if (ssi == nullptr) { + return; // nothing to draw + } + + auto& scene = ssi->getScene(); + rs.targets[target_fbo]->bind(FrameBufferObject::W); glEnable(GL_DEPTH_TEST); @@ -72,8 +79,6 @@ void SimpleSprite::render(Services::OpenGLRenderer& rs, Engine& engine) { _vao->bind(); - auto& scene = engine.tryService()->getScene(); - auto* cam = scene.try_ctx(); if (!cam) { cam = &default_cam; @@ -81,14 +86,12 @@ void SimpleSprite::render(Services::OpenGLRenderer& rs, Engine& engine) { auto vp = cam->getViewProjection(); - auto view = scene.view(); - - view.each([&](auto e, Components::Transform2D& t, Components::OpenGL::Texture& tex) { + scene.view().each([this, &scene, &vp](entt::entity e, const auto& t, auto& tex) { assert(tex.tex); // debug tex.tex->bind(0); - _shader->setUniformMat4f("_WVP", vp * t.getTransform4(t.position.y/10.f + 500.f)); + _shader->setUniformMat4f("_WVP", vp * t.trans); if (scene.all_of(e)) { _shader->setUniform4f("_color", scene.get(e).color); diff --git a/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_spritesheet.cpp b/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_spritesheet.cpp index 77541ce..d718986 100644 --- a/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_spritesheet.cpp +++ b/framework/opengl_renderer/src/mm/opengl/render_tasks/simple_spritesheet.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include "./spritesheet_renderable.hpp" @@ -69,6 +69,13 @@ SimpleSpriteSheet::~SimpleSpriteSheet(void) { void SimpleSpriteSheet::render(Services::OpenGLRenderer& rs, Engine& engine) { ZoneScopedN("MM::OpenGL::RenderTasks::SimpleSpriteSheet::render"); + auto* ssi = engine.tryService(); + if (ssi == nullptr) { + return; // nothing to draw + } + + auto& scene = ssi->getScene(); + rs.targets[target_fbo]->bind(FrameBufferObject::W); glEnable(GL_DEPTH_TEST); @@ -78,9 +85,6 @@ void SimpleSpriteSheet::render(Services::OpenGLRenderer& rs, Engine& engine) { _vertexBuffer->bind(GL_ARRAY_BUFFER); _vao->bind(); - - auto& scene = engine.tryService()->getScene(); - auto* cam = scene.try_ctx(); if (!cam) { cam = &default_cam; @@ -88,16 +92,14 @@ void SimpleSpriteSheet::render(Services::OpenGLRenderer& rs, Engine& engine) { auto vp = cam->getViewProjection(); - auto view = scene.view(); - - view.each([&](auto e, Components::Transform2D& t, SpriteSheetRenderable& spr) { + scene.view().each([this, &scene, &vp](entt::entity e, const auto& t, auto& spr) { assert(spr.sp.tex); // debug TracyGpuZone("MM::OpenGL::Renderers::SimpleSpriteSheetRenderer::render.each"); spr.sp.tex->bind(0); - _shader->setUniformMat4f("_WVP", vp * t.getTransform4(t.position.y/10.f + 500.f)); + _shader->setUniformMat4f("_WVP", vp * t.trans); _shader->setUniform2ui("_tileCount", spr.sp.tile_count.x, spr.sp.tile_count.y); _shader->setUniform1ui("_atlasIndex", spr.tile_index); diff --git a/framework/opengl_renderer/src/mm/opengl/render_tasks/spritesheet_renderable.hpp b/framework/opengl_renderer/src/mm/opengl/render_tasks/spritesheet_renderable.hpp index aea73dc..8e11b0e 100644 --- a/framework/opengl_renderer/src/mm/opengl/render_tasks/spritesheet_renderable.hpp +++ b/framework/opengl_renderer/src/mm/opengl/render_tasks/spritesheet_renderable.hpp @@ -1,3 +1,5 @@ +#pragma once + #include namespace MM::OpenGL { diff --git a/framework/opengl_renderer/src/mm/opengl/render_tasks/tilemap.cpp b/framework/opengl_renderer/src/mm/opengl/render_tasks/tilemap.cpp index c25510a..58f2ad5 100644 --- a/framework/opengl_renderer/src/mm/opengl/render_tasks/tilemap.cpp +++ b/framework/opengl_renderer/src/mm/opengl/render_tasks/tilemap.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -87,9 +87,10 @@ void Tilemap::render(MM::Services::OpenGLRenderer& rs, MM::Engine& engine) { _shader->setUniform3f("_ambient_color", ambient_color); - auto view = scene.view(); - view.each([&](auto, MM::Components::Transform2D& t, OpenGL::TilemapRenderable& tilemap) { - _shader->setUniformMat4f("_WVP", vp * t.getTransform4(tilemap.z + 500.f)); + scene.view() + .each([&](auto, MM::Components::Transform4x4& t, OpenGL::TilemapRenderable& tilemap) { + //_shader->setUniformMat4f("_WVP", vp * t.getTransform4(tilemap.z + 500.f)); + _shader->setUniformMat4f("_WVP", vp * t.trans); // for each sprite layer for (auto& sp_layer : tilemap.sprite_layer) { diff --git a/framework/opengl_renderer/src/mm/opengl/render_tasks/tilemap_renderable.hpp b/framework/opengl_renderer/src/mm/opengl/render_tasks/tilemap_renderable.hpp index 0e9bb8c..4ae988f 100644 --- a/framework/opengl_renderer/src/mm/opengl/render_tasks/tilemap_renderable.hpp +++ b/framework/opengl_renderer/src/mm/opengl/render_tasks/tilemap_renderable.hpp @@ -42,7 +42,7 @@ struct TilemapRenderable { }; std::vector sprite_layer; - float z = 0.f; + //float z = 0.f; // TODO: use Components::Position2D_ZOffset instead }; } // MM::OpenGL diff --git a/framework/opengl_renderer/test/CMakeLists.txt b/framework/opengl_renderer/test/CMakeLists.txt index 6d1e1bc..e3e0aef 100644 --- a/framework/opengl_renderer/test/CMakeLists.txt +++ b/framework/opengl_renderer/test/CMakeLists.txt @@ -30,6 +30,7 @@ target_link_libraries(simple_rect_render_task_test simple_rect_render_task simple_velocity_system + transform_system random @@ -48,6 +49,9 @@ target_link_libraries(simple_sprite_render_task_test simple_sprite_render_task simple_velocity_system + transform_system + + random gtest_main ) @@ -64,6 +68,7 @@ target_link_libraries(simple_spritesheet_render_task_test simple_spritesheet_render_task #simple_velocity_system + transform_system gtest_main ) @@ -80,6 +85,7 @@ target_link_libraries(batched_spritesheet_render_task_test batched_spritesheet_render_task #simple_velocity_system + transform_system gtest_main ) @@ -101,6 +107,7 @@ target_link_libraries(blur_render_task_test imgui_render_task simple_velocity_system + transform_system random @@ -119,6 +126,8 @@ target_link_libraries(tilemap_render_task_test imgui_service tilemap_render_task + transform_system + gtest_main ) diff --git a/framework/opengl_renderer/test/batched_spritesheet_render_task_test.cpp b/framework/opengl_renderer/test/batched_spritesheet_render_task_test.cpp index 3904a22..14ceb8e 100644 --- a/framework/opengl_renderer/test/batched_spritesheet_render_task_test.cpp +++ b/framework/opengl_renderer/test/batched_spritesheet_render_task_test.cpp @@ -14,11 +14,17 @@ #include -#include +#include +#include +#include +#include +#include #include #include #include +#include + #include #include "res/textures.zip.h" @@ -69,10 +75,27 @@ TEST(batched_spritesheet_render_task, it) { rs.addRenderTask(engine); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + + // setup systems scene.set(0.f); // accu auto& org = scene.set(); org.emplace<&update_spritesheet_animation>("update_spritesheet_animation"); + org.emplace("position3d_from_2d"); + org.emplace("transform3d_translate"); + org.emplace("transform3d_rotate2d"); + org.emplace("transform3d_scale2d"); + org.emplace("transform_clear_dirty"); + // HACK: instead you would switch to this scene engine.getService().updateOrganizerVertices(scene); @@ -83,10 +106,13 @@ TEST(batched_spritesheet_render_task, it) { { auto e = scene.create(); - auto& t = scene.emplace(e); - t.position.x = -1.f; - t.scale.x = 1.5f; - t.scale.y = 2.f; + auto& p = scene.emplace(e); + p.pos.x = -1.f; + + // zoffset is created by event + + auto& s = scene.emplace(e); + s.scale = {1.5f,2.f}; auto& spr = scene.emplace(e); spr.sp.tex = rm_t.get("anim_run"_hs); @@ -97,10 +123,13 @@ TEST(batched_spritesheet_render_task, it) { { auto e = scene.create(); - auto& t = scene.emplace(e); - t.position.x = 1.f; - t.scale.x = 1.5f; - t.scale.y = 2.f; + auto& p = scene.emplace(e); + p.pos.x = 1.f; + + // zoffset is created by event + + auto& s = scene.emplace(e); + s.scale = {1.5f,2.f}; auto& spr = scene.emplace(e); spr.sp.tex = rm_t.get("anim_idle"_hs); diff --git a/framework/opengl_renderer/test/blur_render_task_test.cpp b/framework/opengl_renderer/test/blur_render_task_test.cpp index 9e244a8..e0c8f5c 100644 --- a/framework/opengl_renderer/test/blur_render_task_test.cpp +++ b/framework/opengl_renderer/test/blur_render_task_test.cpp @@ -17,10 +17,17 @@ #include #include -#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include #include #include @@ -110,10 +117,27 @@ TEST(blur_render_task, it) { .finish(); } + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); // in this example only rotation is touched + // setup v system auto& org = scene.set(); - org.emplace<&MM::Systems::simple_velocity>("simple_velocity"); + org.emplace("simple_rotational_velocity_patching"); + org.emplace("position3d_from_2d"); + org.emplace("transform3d_translate"); + org.emplace("transform3d_rotate2d"); + org.emplace("transform3d_scale2d"); + org.emplace("transform_clear_dirty"); + // HACK: instead you would switch to this scene engine.getService().updateOrganizerVertices(scene); @@ -122,12 +146,18 @@ TEST(blur_render_task, it) { for (int i = 0; i < 10; i++) { auto e = scene.create(); - auto& t = scene.emplace(e); - t.position.x = float(i) * 9.f - 40.f; - t.scale = {5,5}; + auto& p = scene.emplace(e); + p.pos.x = i * 9.f - 40; - auto& v = scene.emplace(e); - v.rotation = float(i) * 0.3f; + // zoffset is created by event + + auto& s = scene.emplace(e); + s.scale = {5,5}; + + scene.emplace(e); + + auto& v = scene.emplace(e); + v.rot_vel = i * 0.3f; if (rng.roll(0.5f)) { auto& col = scene.emplace(e); diff --git a/framework/opengl_renderer/test/simple_rect_render_task_test.cpp b/framework/opengl_renderer/test/simple_rect_render_task_test.cpp index cbae391..68fe303 100644 --- a/framework/opengl_renderer/test/simple_rect_render_task_test.cpp +++ b/framework/opengl_renderer/test/simple_rect_render_task_test.cpp @@ -12,10 +12,17 @@ #include -#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include #include @@ -44,9 +51,25 @@ TEST(simple_rect_render_task, it) { rs.addRenderTask(engine); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); // in this example only rotation is touched + // setup v system auto& org = scene.set(); - org.emplace<&MM::Systems::simple_velocity>("simple_velocity"); + org.emplace("simple_rotational_velocity_patching"); + org.emplace("position3d_from_2d"); + org.emplace("transform3d_translate"); + org.emplace("transform3d_rotate2d"); + org.emplace("transform3d_scale2d"); + org.emplace("transform_clear_dirty"); // HACK: instead you would switch to this scene engine.getService().updateOrganizerVertices(scene); @@ -56,13 +79,19 @@ TEST(simple_rect_render_task, it) { for (int y = 0; y < 10; y++) { for (int i = 0; i < 10; i++) { auto e = scene.create(); - auto& t = scene.emplace(e); - t.position.x = i * 9.f - 40; - t.position.y = -y * 6.f + 25; - t.scale = {5,5}; + auto& p = scene.emplace(e); + p.pos.x = i * 9.f - 40; + p.pos.y = -y * 6.f + 25; - auto& v = scene.emplace(e); - v.rotation = i * 0.3f; + // zoffset is created by event + + auto& s = scene.emplace(e); + s.scale = {5,5}; + + scene.emplace(e); + + auto& v = scene.emplace(e); + v.rot_vel = i * 0.3f; if (rng.roll(0.5f)) { auto& col = scene.emplace(e); diff --git a/framework/opengl_renderer/test/simple_sprite_render_task_test.cpp b/framework/opengl_renderer/test/simple_sprite_render_task_test.cpp index 0d098b1..e8661e4 100644 --- a/framework/opengl_renderer/test/simple_sprite_render_task_test.cpp +++ b/framework/opengl_renderer/test/simple_sprite_render_task_test.cpp @@ -12,13 +12,20 @@ #include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include -#include +#include using namespace entt::literals; @@ -47,37 +54,58 @@ TEST(simple_sprite_render_task, it) { rs.addRenderTask(engine); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); // in this example only rotation is touched + + // setup v system auto& org = scene.set(); - org.emplace<&MM::Systems::simple_velocity>("simple_velocity"); + org.emplace("simple_rotational_velocity_patching"); + org.emplace("position3d_from_2d"); + org.emplace("transform3d_translate"); + org.emplace("transform3d_rotate2d"); + org.emplace("transform3d_scale2d"); + org.emplace("transform_clear_dirty"); + // HACK: instead you would switch to this scene engine.getService().updateOrganizerVertices(scene); auto& rm_t = MM::ResourceManager::ref(); - std::mt19937 mt(42); + MM::Random::SRNG rng{42}; for (int y = 0; y < 10; y++) { for (int i = 0; i < 10; i++) { auto e = scene.create(); - auto& t = scene.emplace(e); - t.position.x = i * 9.f - 40; - t.position.y = -y * 6.f + 25; - t.scale = {5,5}; + auto& p = scene.emplace(e); + p.pos.x = i * 9.f - 40; + p.pos.y = -y * 6.f + 25; - auto& v = scene.emplace(e); - v.rotation = i * 0.3f; + // zoffset is created by event + + auto& s = scene.emplace(e); + s.scale = {5,5}; + + scene.emplace(e); + + auto& v = scene.emplace(e); + v.rot_vel = i * 0.3f; auto& tex = scene.emplace(e); tex.tex = rm_t.get("errig"_hs); - if (mt() % 2) { + if (rng.roll(0.5f)) { auto& col = scene.emplace(e); - auto rc = [&mt]() -> float { - return (mt() % 1001) / 1000.f ; - }; - col.color = {rc(),rc(),rc(),1}; + col.color = {rng.zeroToOne(), rng.zeroToOne(), rng.zeroToOne(), 1.f}; } } } diff --git a/framework/opengl_renderer/test/simple_spritesheet_render_task_test.cpp b/framework/opengl_renderer/test/simple_spritesheet_render_task_test.cpp index e7c2dcf..f9a09da 100644 --- a/framework/opengl_renderer/test/simple_spritesheet_render_task_test.cpp +++ b/framework/opengl_renderer/test/simple_spritesheet_render_task_test.cpp @@ -14,11 +14,17 @@ #include -#include +#include +#include +#include +#include +#include #include #include #include +#include + #include #include "res/textures.zip.h" @@ -65,10 +71,26 @@ TEST(simple_spritesheet_render_task, it) { rs.addRenderTask(engine); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + // setup systems scene.set(0.f); // accu auto& org = scene.set(); org.emplace<&update_spritesheet_animation>("update_spritesheet_animation"); + org.emplace("position3d_from_2d"); + org.emplace("transform3d_translate"); + org.emplace("transform3d_rotate2d"); + org.emplace("transform3d_scale2d"); + org.emplace("transform_clear_dirty"); + // HACK: instead you would switch to this scene engine.getService().updateOrganizerVertices(scene); @@ -79,10 +101,13 @@ TEST(simple_spritesheet_render_task, it) { { auto e = scene.create(); - auto& t = scene.emplace(e); - t.position.x = -1.f; - t.scale.x = 1.5f; - t.scale.y = 2.f; + auto& p = scene.emplace(e); + p.pos.x = -1.f; + + // zoffset is created by event + + auto& s = scene.emplace(e); + s.scale = {1.5f,2.f}; auto& spr = scene.emplace(e); spr.sp.tex = rm_t.get("anim_run"_hs); @@ -93,10 +118,13 @@ TEST(simple_spritesheet_render_task, it) { { auto e = scene.create(); - auto& t = scene.emplace(e); - t.position.x = 1.f; - t.scale.x = 1.5f; - t.scale.y = 2.f; + auto& p = scene.emplace(e); + p.pos.x = 1.f; + + // zoffset is created by event + + auto& s = scene.emplace(e); + s.scale = {1.5f,2.f}; auto& spr = scene.emplace(e); spr.sp.tex = rm_t.get("anim_idle"_hs); diff --git a/framework/opengl_renderer/test/tilemap_render_task_test.cpp b/framework/opengl_renderer/test/tilemap_render_task_test.cpp index 7b7ccca..7639255 100644 --- a/framework/opengl_renderer/test/tilemap_render_task_test.cpp +++ b/framework/opengl_renderer/test/tilemap_render_task_test.cpp @@ -8,13 +8,18 @@ #include #include +#include #include #include #include -#include +#include +#include +#include +#include +#include #include using namespace entt::literals; @@ -48,11 +53,30 @@ TEST(tilemap_render_task_test, it) { rs.addRenderTask(engine); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); + scene.on_construct().connect<&entt::registry::emplace_or_replace>(); // fun + + // "useless" in this example + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + scene.on_update().connect<&entt::registry::emplace_or_replace>(); + + auto& org = scene.set(); + org.emplace("position3d_from_2d"); + org.emplace("transform3d_translate"); + org.emplace("transform_clear_dirty"); + + // HACK: instead you would switch to this scene + engine.getService().updateOrganizerVertices(scene); + + auto& rm_t = MM::ResourceManager::ref(); { auto e = scene.create(); - scene.emplace(e); + scene.emplace(e); auto& tm = scene.emplace(e); diff --git a/framework/tilemap/src/mm/tilemap.cpp b/framework/tilemap/src/mm/tilemap.cpp index 9923d07..b968c4f 100644 --- a/framework/tilemap/src/mm/tilemap.cpp +++ b/framework/tilemap/src/mm/tilemap.cpp @@ -8,7 +8,9 @@ #include #include -#include +#include +#include +#include #include #include @@ -95,9 +97,9 @@ bool Tilemap::parseTiled_LayerRenderable(MM::Engine&, MM::Scene& scene, nlohmann uint32_t layer_width = jlayer["width"]; uint32_t layer_height = jlayer["height"]; - auto& tilemap_rend = scene.emplace(e); + scene.get_or_emplace(e).z_offset = Tiled_get_z_prop(jlayer) + 500.f; // TODO: magic - tilemap_rend.z = Tiled_get_z_prop(jlayer); + auto& tilemap_rend = scene.emplace(e); // TODO: inefficient for (auto& it : _sprite_sheet_map) { @@ -165,10 +167,11 @@ bool Tilemap::parseTiled_Layer(MM::Engine& engine, MM::Scene& scene, nlohmann::j name.str = jlayer["name"]; } - auto& t = scene.emplace(e); - t.position = {0, 0}; - t.scale = {1, 1}; + scene.emplace(e); + // in case there is no auto system + scene.emplace_or_replace(e); + scene.emplace_or_replace(e); if (Tiled_is_collision_layer(jlayer)) { return parseTiled_LayerCollision(engine, scene, jlayer, e); diff --git a/screens/mm_logo/CMakeLists.txt b/screens/mm_logo/CMakeLists.txt index 898165f..6aea6ee 100644 --- a/screens/mm_logo/CMakeLists.txt +++ b/screens/mm_logo/CMakeLists.txt @@ -21,6 +21,7 @@ target_link_libraries(mm_logo_screen simple_sprite_render_task common_components + transform_system random ) diff --git a/screens/mm_logo/src/mm/screens/mm_logo_screen.cpp b/screens/mm_logo/src/mm/screens/mm_logo_screen.cpp index bb253a2..2f0eb92 100644 --- a/screens/mm_logo/src/mm/screens/mm_logo_screen.cpp +++ b/screens/mm_logo/src/mm/screens/mm_logo_screen.cpp @@ -1,6 +1,5 @@ #include "./mm_logo_screen.hpp" -#include #include #include @@ -13,14 +12,24 @@ #include #include -#include +#include +#include +#include +#include +#include #include #include #include +#include + +#include +#include + #include #include + namespace MM::Screens { namespace Components { @@ -51,8 +60,8 @@ namespace Systems { } // elastic scale easing - void elasic_scale_easing(entt::view> view, const MM::Components::TimeDelta& td) { - view.each([&td](auto& t, auto& easing_comp) { + void elasic_scale_easing(entt::view> view, const MM::Components::TimeDelta& td) { + view.each([&td](auto& s, auto& easing_comp) { easing_comp.accumulator += td.tickDelta; // taken from https://github.com/warrenm/AHEasing @@ -61,8 +70,8 @@ namespace Systems { return glm::sin(-13.f * glm::half_pi() * (x + 1.f)) * glm::pow(2.f, -10.f * x) + 1.f; }; - t.scale.x = glm::mix(easing_comp.start.x, easing_comp.end.x, elasticOut(easing_comp.accumulator / easing_comp.duration)); - t.scale.y = glm::mix(easing_comp.start.y, easing_comp.end.y, elasticOut(easing_comp.accumulator / easing_comp.duration)); + s.scale.x = glm::mix(easing_comp.start.x, easing_comp.end.x, elasticOut(easing_comp.accumulator / easing_comp.duration)); + s.scale.y = glm::mix(easing_comp.start.y, easing_comp.end.y, elasticOut(easing_comp.accumulator / easing_comp.duration)); }); } @@ -117,9 +126,14 @@ void create_mm_logo(MM::Engine& engine, MM::Services::ScreenDirector::Screen& sc scene.set(0.f, screen_duration, next_screen); - org.emplace<&Systems::screen_timer_system>("screen_timer_system"); + org.emplace("screen_timer_system"); - org.emplace<&Systems::elasic_scale_easing>("elasic_scale_easing"); + org.emplace("elasic_scale_easing"); + org.emplace("position3d_from_2d"); + org.emplace("transform3d_translate"); + //org.emplace("transform3d_rotate2d"); + org.emplace("transform3d_scale2d"); + //org.emplace("transform_clear_dirty"); auto& cam = scene.set(); cam.horizontalViewPortSize = 89.f; @@ -128,8 +142,12 @@ void create_mm_logo(MM::Engine& engine, MM::Services::ScreenDirector::Screen& sc { auto e_logo = scene.create(); - auto& t = scene.emplace(e_logo); - t.scale = {0,0}; + scene.emplace(e_logo); + scene.emplace(e_logo); + scene.emplace(e_logo); + scene.emplace(e_logo, glm::vec2{0.f, 0.f}); + scene.emplace(e_logo); + scene.emplace(e_logo); auto& easing_comp = scene.emplace(e_logo); easing_comp.start = {0.f, 0.f}; @@ -161,7 +179,6 @@ void create_mm_logo(MM::Engine& engine, MM::Services::ScreenDirector::Screen& sc 1.f, }; - //std::mt19937_64 mt{std::random_device{}()}; MM::Random::SRNG rng{std::random_device{}(), 0}; std::vector colors {color1, color2, color3}; diff --git a/systems/CMakeLists.txt b/systems/CMakeLists.txt index f1876a0..77735f7 100644 --- a/systems/CMakeLists.txt +++ b/systems/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.8) project(systems CXX) +add_subdirectory(transform) add_subdirectory(simple_velocity) if(NOT MM_HEADLESS) diff --git a/systems/player_velocity/src/mm/systems/player_velocity2d_system.cpp b/systems/player_velocity/src/mm/systems/player_velocity2d_system.cpp index 531088f..c70f5b2 100644 --- a/systems/player_velocity/src/mm/systems/player_velocity2d_system.cpp +++ b/systems/player_velocity/src/mm/systems/player_velocity2d_system.cpp @@ -6,22 +6,13 @@ namespace MM::Systems { -void player_velocity2d(entt::view> view, const MM::Engine* engine) { +void player_velocity2d(entt::view> view, const MM::Engine* engine) { ZoneScopedN("MM::Systems::PlayerVelocity2D"); auto& input_ss = engine->getService(); - view.each([&input_ss](const MM::Input::PlayerID p_id, MM::Components::Velocity2D& v) { - //const float movement_speed = 8.f; // apply via post processing - - auto vec_force = input_ss.getMoveForce(p_id); - - if (vec_force >= 0.01f) { - v.velocity = input_ss.getMoveVec(p_id); - //v.velocity *= vec_force; - } else { - v.velocity = {0.f, 0.f}; - } + view.each([&input_ss](const MM::Input::PlayerID p_id, MM::Components::Velocity2DPositionIntent& v) { + v.intent = input_ss.getMoveVec(p_id); }); } diff --git a/systems/player_velocity/src/mm/systems/player_velocity2d_system.hpp b/systems/player_velocity/src/mm/systems/player_velocity2d_system.hpp index bb0e5cd..e316aad 100644 --- a/systems/player_velocity/src/mm/systems/player_velocity2d_system.hpp +++ b/systems/player_velocity/src/mm/systems/player_velocity2d_system.hpp @@ -1,14 +1,13 @@ #pragma once #include -#include #include -#include +#include namespace MM::Systems { - // this system transforms the input from the input_service into velocity - void player_velocity2d(entt::view> view, const MM::Engine* engine); + // this system transforms the input from the input_service into velocity intent + void player_velocity2d(entt::view> view, const MM::Engine* engine); } // MM::Systems diff --git a/systems/simple_velocity/src/mm/systems/simple_velocity_system2d.cpp b/systems/simple_velocity/src/mm/systems/simple_velocity_system2d.cpp index a1a990d..01304cf 100644 --- a/systems/simple_velocity/src/mm/systems/simple_velocity_system2d.cpp +++ b/systems/simple_velocity/src/mm/systems/simple_velocity_system2d.cpp @@ -1,21 +1,66 @@ #include "./simple_velocity_system2d.hpp" +#include "mm/components/rotation2d.hpp" +#include "mm/components/velocity2d_position.hpp" +#include "mm/components/velocity2d_rotation.hpp" #include namespace MM::Systems { - void simple_velocity( + void simple_positional_velocity( entt::view> view, const Components::TimeDelta& td ) { - view.each([delta = td.tickDelta](auto, auto& t, auto& v) { - t.position += v.velocity * delta; - t.rotation += v.rotation * delta; + view.each([delta = td.tickDelta](auto& t, auto& v) { + t.pos += v.pos_vel * delta; + }); + } + + void simple_positional_velocity_patching( + entt::registry& scene, + entt::view> view, + const Components::TimeDelta& td + ) { + view.each([&scene, delta = td.tickDelta](const auto e, auto& t, auto& v) { + if (v.pos_vel.x != 0.f || v.pos_vel.y != 0.f) { + t.pos += v.pos_vel * delta; + scene.patch(e); } - ); + }); + } + + void simple_rotational_velocity( + entt::view> view, + const Components::TimeDelta& td + ) { + view.each([delta = td.tickDelta](auto& r, auto& v) { + r.rot += v.rot_vel * delta; + }); + } + + void simple_rotational_velocity_patching( + entt::registry& scene, + entt::view> view, + const Components::TimeDelta& td + ) { + view.each([&scene, delta = td.tickDelta](const auto e, auto& r, auto& v) { + if (v.rot_vel != 0.f) { + r.rot += v.rot_vel * delta; + scene.patch(e); + } + }); } } // MM::Systems diff --git a/systems/simple_velocity/src/mm/systems/simple_velocity_system2d.hpp b/systems/simple_velocity/src/mm/systems/simple_velocity_system2d.hpp index 59628ac..1e1a564 100644 --- a/systems/simple_velocity/src/mm/systems/simple_velocity_system2d.hpp +++ b/systems/simple_velocity/src/mm/systems/simple_velocity_system2d.hpp @@ -1,17 +1,49 @@ #pragma once -#include -#include +#include +#include +#include +#include #include -#include +#include namespace MM::Systems { - void simple_velocity( + // non patching (on_update()) + void simple_positional_velocity( entt::view> view, + const Components::TimeDelta& td + ); + + // patching (on_update()) + void simple_positional_velocity_patching( + entt::registry& scene, + entt::view> view, + const Components::TimeDelta& td + ); + + // non patching (on_update()) + void simple_rotational_velocity( + entt::view> view, + const Components::TimeDelta& td + ); + + // patching (on_update()) + void simple_rotational_velocity_patching( + entt::registry& scene, + entt::view> view, const Components::TimeDelta& td ); diff --git a/systems/simple_velocity/test/simple_velocity_test.cpp b/systems/simple_velocity/test/simple_velocity_test.cpp index 28d9586..a8b8550 100644 --- a/systems/simple_velocity/test/simple_velocity_test.cpp +++ b/systems/simple_velocity/test/simple_velocity_test.cpp @@ -12,7 +12,8 @@ TEST(simple_velocity_2d, basic_run) { // setup v system auto& org = scene.set(); - org.emplace<&MM::Systems::simple_velocity>("simple_velocity"); + org.emplace<&MM::Systems::simple_positional_velocity>("simple_positional_velocity"); + org.emplace<&MM::Systems::simple_rotational_velocity>("simple_rotational_velocity"); auto graph = org.graph(); // setup delta @@ -21,19 +22,21 @@ TEST(simple_velocity_2d, basic_run) { // setup test entity auto e = scene.create(); - auto& t = scene.emplace(e); - auto& v = scene.emplace(e); - t.position = { 0.f, 0.f }; - t.rotation = 0.f; + auto& p = scene.emplace(e); + auto& r = scene.emplace(e); + auto& vp = scene.emplace(e); + auto& vr = scene.emplace(e); + p.pos = { 0.f, 0.f }; + r.rot = 0.f; - v.velocity = { 1.f, 1.f }; - v.rotation = 0.f; + vp.pos_vel = { 1.f, 1.f }; + vr.rot_vel = 0.f; // run all systems for (auto&& vert : graph) { vert.callback()(vert.data(), scene); } - ASSERT_EQ(t.position.x, 1.f * 1.f/60.f); + ASSERT_EQ(p.pos.x, 1.f * 1.f/60.f); } diff --git a/systems/transform/CMakeLists.txt b/systems/transform/CMakeLists.txt new file mode 100644 index 0000000..918d4ef --- /dev/null +++ b/systems/transform/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.2) +project(transfrom_system CXX) + +add_library(transform_system + src/mm/systems/transform.hpp + src/mm/systems/transform.cpp +) + +target_include_directories(transform_system PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src") + +target_link_libraries(transform_system + entt + glm + engine + common_components + tracy_client +) + +#if (BUILD_TESTING) + #add_subdirectory(test) +#endif() + + diff --git a/systems/transform/src/mm/systems/transform.cpp b/systems/transform/src/mm/systems/transform.cpp new file mode 100644 index 0000000..3bd1549 --- /dev/null +++ b/systems/transform/src/mm/systems/transform.cpp @@ -0,0 +1,43 @@ +#include "./transform.hpp" + +#include + +#include + +namespace MM::Systems { + +void position3d_from_2d(entt::view> view) { + ZoneScoped; + view.each([](const Components::Position2D& pos2, const Components::Position2D_ZOffset& zoff, Components::Position3D& pos3) { + pos3.pos = glm::vec3(pos2.pos, zoff.z_offset + pos2.pos.y/10.f); + }); +} + +void transform3d_translate(entt::view> view) { + ZoneScoped; + view.each([](const Components::Position3D& pos, Components::Transform4x4& trans) { + trans.trans = glm::translate(glm::mat4x4{1.f}, pos.pos); + }); +} + +void transform3d_rotate2d(entt::view> view) { + ZoneScoped; + view.each([](const Components::Rotation2D& rot, Components::Transform4x4& trans) { + trans.trans = glm::rotate(trans.trans, rot.rot, glm::vec3(0.f, 0.f, 1.f)); + }); +} + +void transform3d_scale2d(entt::view> view) { + ZoneScoped; + view.each([](const Components::Scale2D& scale, Components::Transform4x4& trans) { + trans.trans = glm::scale(trans.trans, glm::vec3(scale.scale, 1.f)); + }); +} + +void transform_clear_dirty(entt::registry& scene, entt::view> view) { + ZoneScoped; + scene.remove(view.begin(), view.end()); +} + +} // MM::Systems + diff --git a/systems/transform/src/mm/systems/transform.hpp b/systems/transform/src/mm/systems/transform.hpp new file mode 100644 index 0000000..6ffb7da --- /dev/null +++ b/systems/transform/src/mm/systems/transform.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include +#include +#include + +#include +#include + +#include + +#include + +namespace MM::Systems { + +// 2D usage: +// +// auto create dependencies, eg: +// scene.on_construct().connect<&entt::registry::emplace_or_replace>(); +// scene.on_construct().connect<&entt::registry::emplace_or_replace>(); +// scene.on_construct().connect<&entt::registry::emplace_or_replace>(); +// +// mark as dirty on change, eg: +// scene.on_update().connect<&entt::registry::emplace_or_replace>(); +// scene.on_update().connect<&entt::registry::emplace_or_replace>(); +// scene.on_update().connect<&entt::registry::emplace_or_replace>(); +// scene.on_update().connect<&entt::registry::emplace_or_replace>(); +// scene.on_update().connect<&entt::registry::emplace_or_replace>(); +// +// optinally cleanup on destruction, eg: +// scene.on_destroy().connect<&entt::registry::remove< +// Components::DirtyTransformTag, +// Components::Position2D_ZOffset, +// Components::Position3D, +// Components::Scale2D, +// Components::Rotation2D, +// Components::Transform4x4 +// >>(); + + +// TODO: impl for no zoffset comp +void position3d_from_2d(entt::view> view); + +void transform3d_translate(entt::view> view); + +void transform3d_rotate2d(entt::view> view); + +void transform3d_scale2d(entt::view> view); + +void transform_clear_dirty(entt::registry& scene, entt::view> view); + +} // MM::Systems +