From 199a08a3b0f2b349ebcc53989b6ce11dcfaff910 Mon Sep 17 00:00:00 2001 From: Jaby Date: Fri, 5 Jan 2024 23:02:14 -0600 Subject: [PATCH] More CleanUp of JabyEngine/PoolBox --- .../ControllerTest/controller_state.cpp | 21 +------------------ .../PSX/GPU/Primitives/linked_elements.hpp | 18 ++++++++++++++++ .../GPU/Primitives/primitive_line_types.hpp | 1 + 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/PoolBox/application/src/Overlay/ControllerTest/controller_state.cpp b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_state.cpp index c6aada62..cda13cab 100644 --- a/examples/PoolBox/application/src/Overlay/ControllerTest/controller_state.cpp +++ b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_state.cpp @@ -5,25 +5,6 @@ namespace ControllerTest { using DigitalButton = Periphery::AnalogeController::Button; using namespace JabyEngine; - // This should go to JabyEngine eventually - template - static GPU::Link* link_array(GPU::Link* last_prim, T* elements, size_t length) { - for(size_t n = 0; n < length; n++) { - last_prim->concat(elements[n]); - last_prim = &elements[n]; - } - - last_prim->terminate(); - return last_prim; - } - - template - static GPU::Link* link_array(GPU::Link* last_prim, T(&elements)[N]) { - return link_array(last_prim, elements, N); - } - - // -------------------------------------------------------------------------------------------------------------------------- - static void set_active(GPU::SPRT_16::Linked& sprt, bool is_active) { sprt->tex_offset.y = is_active ? 16 : 0; } @@ -71,7 +52,7 @@ namespace ControllerTest { void ControllerState :: setup() { for(size_t n = 0; n < 2; n++) { - link_array(link_array(&this->tex_page[n], this->buttons[n]), this->arrows[n]); + GPU::LinkHelper::link_array(GPU::LinkHelper::link_array(&this->tex_page[n], this->buttons[n]), this->arrows[n]); } } diff --git a/include/PSX/GPU/Primitives/linked_elements.hpp b/include/PSX/GPU/Primitives/linked_elements.hpp index d2cfeb1d..360f9df9 100644 --- a/include/PSX/GPU/Primitives/linked_elements.hpp +++ b/include/PSX/GPU/Primitives/linked_elements.hpp @@ -88,5 +88,23 @@ namespace JabyEngine { } }; } + + namespace LinkHelper { + template + static Link* link_array(Link* last_prim, T* elements, size_t length) { + for(size_t n = 0; n < length; n++) { + last_prim->concat(elements[n]); + last_prim = &elements[n]; + } + + last_prim->terminate(); + return last_prim; + } + + template + static Link* link_array(Link* last_prim, T(&elements)[N]) { + return link_array(last_prim, elements, N); + } + } } } \ No newline at end of file diff --git a/include/PSX/GPU/Primitives/primitive_line_types.hpp b/include/PSX/GPU/Primitives/primitive_line_types.hpp index 96d337b2..3ff8704b 100644 --- a/include/PSX/GPU/Primitives/primitive_line_types.hpp +++ b/include/PSX/GPU/Primitives/primitive_line_types.hpp @@ -70,6 +70,7 @@ namespace JabyEngine { Body points[N]; Termination end; + // Could also be none const in the future template constexpr typename enable_if::value, Vertex>::type operator[](size_t idx) const { if(idx == 0) {