From accb70ad5f141244a9ebc6f8f840e5501ec23d14 Mon Sep 17 00:00:00 2001 From: David Allemang Date: Sun, 12 Feb 2023 10:10:25 -0500 Subject: [PATCH] WIP: remove points, hull from Structure<> --- vis/src/components.hpp | 15 ++++----------- vis/src/main.cpp | 23 +++++++++-------------- vis/src/systems.hpp | 13 ++++++++++--- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/vis/src/components.hpp b/vis/src/components.hpp index d9fa7b0..323fdfc 100644 --- a/vis/src/components.hpp +++ b/vis/src/components.hpp @@ -47,25 +47,18 @@ namespace vis { tc::Group group; VectorRf root; - Points points; - Hull hull; - - std::vector enabled; - std::vector colors; + std::vector::Tiling> tilings{}; + std::vector enabled{}; + std::vector colors{}; Affine transform = Affine::Identity(); explicit Structure( tc::Group group, - VectorRf root, - Color color_ = Color::Ones() + VectorRf root ) : group(group), root(root), - points(group, root), // todo separate system - hull(group), // todo separate system - enabled(hull.tilings.size(), true), - colors(hull.tilings.size(), color_), transform(Affine::Identity()) { } }; diff --git a/vis/src/main.cpp b/vis/src/main.cpp index f78546b..980c65d 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -115,8 +115,8 @@ void show_options(entt::registry ®istry) { for (auto [entity, structure]: view.each()) { ImGui::Begin("Structure View Options"); - for (int i = 0; i < structure.hull.tilings.size(); ++i) { - std::string label = fmt::format("{}", structure.hull.subgroups[i]); + for (int i = 0; i < structure.tilings.size(); ++i) { + std::string label = fmt::format("{}", i); ImGui::Checkbox(label.c_str(), (bool*) (&(structure.enabled[i]))); ImGui::ColorEdit3(label.c_str(), structure.colors[i].data(), ImGuiColorEditFlags_NoLabel); @@ -156,20 +156,15 @@ int run(GLFWwindow* window, ImGuiContext* ctx) { state.dimension = 4; auto entity = registry.create(); - { - tc::Group group = tc::schlafli({5, 3, 3, 2}); - - auto &structure = registry.emplace( - entity, - group, - vec5{0.80, 0.09, 0.09, 0.09, 0.09} - ); - registry.emplace>(entity); - - structure.enabled[0] = false; // disable {0,1,2} cells - } + registry.emplace( + entity, + tc::schlafli({5, 3, 3, 2}), + vec5{0.80, 0.09, 0.09, 0.09, 0.09} + ); + registry.emplace>(entity); vis::upload_structure(registry); + registry.get(entity).enabled[0] = false; // disable {0,1,2} cells auto ubo = cgl::Buffer(); glBindBufferBase(GL_UNIFORM_BUFFER, 1, ubo); diff --git a/vis/src/systems.hpp b/vis/src/systems.hpp index b7616c1..99c4f1d 100644 --- a/vis/src/systems.hpp +++ b/vis/src/systems.hpp @@ -24,8 +24,15 @@ namespace vis { auto view = registry.view>(); for (auto [entity, structure, vbos]: view.each()) { - auto vertices = structure.points.verts.colwise(); - auto indices = structure.hull.inds.colwise(); + Points points(structure.group, structure.root); + Hull hull(structure.group); + + auto vertices = points.verts.colwise(); + auto indices = hull.inds.colwise(); + + structure.tilings = hull.tilings; + structure.enabled.resize(hull.tilings.size(), true); + structure.colors.resize(hull.tilings.size(), vec3::Ones()); vbos.vertices.put(vertices.begin(), vertices.end()); vbos.indices.put(indices.begin(), indices.end()); @@ -53,7 +60,7 @@ namespace vis { auto view = registry.view>(); for (auto [entity, structure, vbos]: view.each()) { - const auto &tilings = structure.hull.tilings; + const auto &tilings = structure.tilings; std::vector::Command> commands;