remove old transform and velocity components and replace with new decomposed components

focus on 2D for now
This commit is contained in:
2022-01-04 22:33:59 +01:00
parent c36fa30cbc
commit 12b0a90ad0
71 changed files with 1114 additions and 528 deletions

View File

@@ -17,10 +17,17 @@
#include <mm/opengl/render_tasks/blur.hpp>
#include <mm/opengl/render_tasks/imgui.hpp>
#include <mm/components/transform2d.hpp>
#include <mm/components/position2d.hpp>
#include <mm/components/position2d_zoffset.hpp>
#include <mm/components/scale2d.hpp>
#include <mm/components/rotation2d.hpp>
#include <mm/components/velocity2d_rotation.hpp>
#include <mm/components/position3d.hpp>
#include <mm/components/transform4x4.hpp>
#include <mm/components/color.hpp>
#include <mm/systems/simple_velocity_system2d.hpp>
#include <mm/systems/transform.hpp>
#include <mm/opengl/fbo_builder.hpp>
#include <mm/opengl/texture_loader.hpp>
@@ -110,10 +117,27 @@ TEST(blur_render_task, it) {
.finish();
}
scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::Position2D_ZOffset>>();
scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::Position3D>>();
scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::Transform4x4>>();
scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::DirtyTransformTag>>();
scene.on_update<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::DirtyTransformTag>>();
scene.on_update<MM::Components::Position2D_ZOffset>().connect<&entt::registry::emplace_or_replace<MM::Components::DirtyTransformTag>>();
scene.on_update<MM::Components::Position3D>().connect<&entt::registry::emplace_or_replace<MM::Components::DirtyTransformTag>>();
scene.on_update<MM::Components::Scale2D>().connect<&entt::registry::emplace_or_replace<MM::Components::DirtyTransformTag>>();
scene.on_update<MM::Components::Rotation2D>().connect<&entt::registry::emplace_or_replace<MM::Components::DirtyTransformTag>>(); // in this example only rotation is touched
// setup v system
auto& org = scene.set<entt::organizer>();
org.emplace<&MM::Systems::simple_velocity>("simple_velocity");
org.emplace<MM::Systems::simple_rotational_velocity_patching>("simple_rotational_velocity_patching");
org.emplace<MM::Systems::position3d_from_2d>("position3d_from_2d");
org.emplace<MM::Systems::transform3d_translate>("transform3d_translate");
org.emplace<MM::Systems::transform3d_rotate2d>("transform3d_rotate2d");
org.emplace<MM::Systems::transform3d_scale2d>("transform3d_scale2d");
org.emplace<MM::Systems::transform_clear_dirty>("transform_clear_dirty");
// HACK: instead you would switch to this scene
engine.getService<MM::Services::OrganizerSceneService>().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<MM::Components::Transform2D>(e);
t.position.x = float(i) * 9.f - 40.f;
t.scale = {5,5};
auto& p = scene.emplace<MM::Components::Position2D>(e);
p.pos.x = i * 9.f - 40;
auto& v = scene.emplace<MM::Components::Velocity2D>(e);
v.rotation = float(i) * 0.3f;
// zoffset is created by event
auto& s = scene.emplace<MM::Components::Scale2D>(e);
s.scale = {5,5};
scene.emplace<MM::Components::Rotation2D>(e);
auto& v = scene.emplace<MM::Components::Velocity2DRotation>(e);
v.rot_vel = i * 0.3f;
if (rng.roll(0.5f)) {
auto& col = scene.emplace<MM::Components::Color>(e);