From 2942cc096882fdaca0a2a6783906dd611d506bd1 Mon Sep 17 00:00:00 2001 From: dandistine <34634876+dandistine@users.noreply.github.com> Date: Sun, 20 Sep 2026 11:13:57 -0500 Subject: [PATCH 1/4] Only copy the header if it is different --- dev/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/CMakeLists.txt b/dev/CMakeLists.txt index 4895ce0..51a9c6d 100644 --- a/dev/CMakeLists.txt +++ b/dev/CMakeLists.txt @@ -45,7 +45,8 @@ else() endif() add_custom_target(CopyHeader - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/olcPixelGameEngine3.h ${REPO_ROOT_DIR}/olcPixelGameEngine3.h + BYPRODUCTS ${REPO_ROOT_DIR}/olcPixelGameEngine3.h + COMMAND ${CMAKE_COMMAND} -E copy_if_newer ${CMAKE_BINARY_DIR}/olcPixelGameEngine3.h ${REPO_ROOT_DIR}/olcPixelGameEngine3.h DEPENDS olcPixelGameEngine3.h ) From e8082f0c28fb254c871a2f66fcf8ab648d4fdd2b Mon Sep 17 00:00:00 2001 From: dandistine <34634876+dandistine@users.noreply.github.com> Date: Sun, 20 Sep 2026 11:27:46 -0500 Subject: [PATCH 2/4] Change to copy_if_different since the github runner is out-of-date. --- dev/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/CMakeLists.txt b/dev/CMakeLists.txt index 51a9c6d..61704c9 100644 --- a/dev/CMakeLists.txt +++ b/dev/CMakeLists.txt @@ -46,7 +46,7 @@ endif() add_custom_target(CopyHeader BYPRODUCTS ${REPO_ROOT_DIR}/olcPixelGameEngine3.h - COMMAND ${CMAKE_COMMAND} -E copy_if_newer ${CMAKE_BINARY_DIR}/olcPixelGameEngine3.h ${REPO_ROOT_DIR}/olcPixelGameEngine3.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/olcPixelGameEngine3.h ${REPO_ROOT_DIR}/olcPixelGameEngine3.h DEPENDS olcPixelGameEngine3.h ) From d74c771797e2c769c831e1d3f793d953c6b12166 Mon Sep 17 00:00:00 2001 From: dandistine <34634876+dandistine@users.noreply.github.com> Date: Sun, 20 Sep 2026 21:49:24 -0500 Subject: [PATCH 3/4] Allow unpacking of v_2d and v_4d via structured bindings. --- dev/src/vector2d.h | 30 +++++++++++++++ dev/src/vector4d.h | 30 +++++++++++++++ examples/olcPGE3_WorldTransform.cpp | 6 +++ olcPixelGameEngine3.h | 60 +++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) diff --git a/dev/src/vector2d.h b/dev/src/vector2d.h index 5b6a88b..90d71cc 100644 --- a/dev/src/vector2d.h +++ b/dev/src/vector2d.h @@ -195,6 +195,26 @@ namespace olc { return { static_cast(this->x), static_cast(this->y) }; } + + template + auto& get() & { + return std::get(xy); + } + + template + const auto& get() const & { + return std::get(xy); + } + + template + auto&& get() && { + return std::get(xy); + } + + template + const auto& get() const && { + return std::get(xy); + } }; // Multiplication operator overloads between vectors and scalars, and vectors and vectors @@ -356,6 +376,16 @@ namespace olc typedef v_2d vf2d; typedef v_2d vd2d; } + +namespace std { + template + struct tuple_size> : std::integral_constant {}; + + + template + struct tuple_element> : tuple_element> {}; +} + #define PGE_VECTOR2D_DECLARED 1 #endif //! END DECLARATION \ No newline at end of file diff --git a/dev/src/vector4d.h b/dev/src/vector4d.h index 3661b50..5e65cb9 100644 --- a/dev/src/vector4d.h +++ b/dev/src/vector4d.h @@ -183,6 +183,26 @@ namespace olc { return { static_cast(this->x), static_cast(this->y), static_cast(this->z), static_cast(this->w) }; } + + template + auto& get() & { + return std::get(xyzw); + } + + template + const auto& get() const & { + return std::get(xyzw); + } + + template + auto&& get() && { + return std::get(xyzw); + } + + template + const auto& get() const && { + return std::get(xyzw); + } }; // Multiplication operator overloads between vectors and scalars, and vectors and vectors @@ -343,6 +363,16 @@ namespace olc typedef v_4d vf4d; typedef v_4d vd4d; } + +namespace std { + template + struct tuple_size> : std::integral_constant {}; + + + template + struct tuple_element> : tuple_element> {}; +} + #define PGE_VECTOR4D_DECLARED 1 #endif //! END DECLARATION \ No newline at end of file diff --git a/examples/olcPGE3_WorldTransform.cpp b/examples/olcPGE3_WorldTransform.cpp index 699b6bc..bdf4748 100644 --- a/examples/olcPGE3_WorldTransform.cpp +++ b/examples/olcPGE3_WorldTransform.cpp @@ -132,6 +132,12 @@ class Example_WorldTransform: public olc::PixelGameEngine // Get Mouse in "transformed world" space olc::vf2d vMouseWorld = draw.ScreenToWorld(vMouseScreen); + // Unpack the mouse coordinate to x and y just for fun and to serve as a compilation test for unpacking v_2d objects + const auto& [x1, y1] = vMouseWorld; + auto& [x2, y2] = vMouseWorld; + auto [x3, y3] = vMouseWorld; + auto&& [x4, y4] = vMouseWorld; + // Draw Status draw.WorldReset(); draw.StringProp({ 8, 300 }, "Offset: Arrow Keys, Scale: Shift & Arrow Keys, Rotate: Q/A, SPACE: Reset"); diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index 2b919d7..0265b4a 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -849,6 +849,26 @@ namespace olc { return { static_cast(this->x), static_cast(this->y) }; } + + template + auto& get() & { + return std::get(xy); + } + + template + const auto& get() const & { + return std::get(xy); + } + + template + auto&& get() && { + return std::get(xy); + } + + template + const auto& get() const && { + return std::get(xy); + } }; // Multiplication operator overloads between vectors and scalars, and vectors and vectors @@ -1010,6 +1030,16 @@ namespace olc typedef v_2d vf2d; typedef v_2d vd2d; } + +namespace std { + template + struct tuple_size> : std::integral_constant {}; + + + template + struct tuple_element> : tuple_element> {}; +} + #define PGE_VECTOR2D_DECLARED 1 #endif @@ -1182,6 +1212,26 @@ namespace olc { return { static_cast(this->x), static_cast(this->y), static_cast(this->z), static_cast(this->w) }; } + + template + auto& get() & { + return std::get(xyzw); + } + + template + const auto& get() const & { + return std::get(xyzw); + } + + template + auto&& get() && { + return std::get(xyzw); + } + + template + const auto& get() const && { + return std::get(xyzw); + } }; // Multiplication operator overloads between vectors and scalars, and vectors and vectors @@ -1342,6 +1392,16 @@ namespace olc typedef v_4d vf4d; typedef v_4d vd4d; } + +namespace std { + template + struct tuple_size> : std::integral_constant {}; + + + template + struct tuple_element> : tuple_element> {}; +} + #define PGE_VECTOR4D_DECLARED 1 #endif From ebdff87cb24c6eba6bb970377f7743d4529f825b Mon Sep 17 00:00:00 2001 From: dandistine <34634876+dandistine@users.noreply.github.com> Date: Sun, 20 Sep 2026 22:00:36 -0500 Subject: [PATCH 4/4] Implement a test / demo for v_4d --- dev/src/vector4d.h | 2 +- examples/olcPGE3_3DCube.cpp | 10 ++++++++-- olcPixelGameEngine3.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dev/src/vector4d.h b/dev/src/vector4d.h index 5e65cb9..618d69e 100644 --- a/dev/src/vector4d.h +++ b/dev/src/vector4d.h @@ -370,7 +370,7 @@ namespace std { template - struct tuple_element> : tuple_element> {}; + struct tuple_element> : tuple_element> {}; } #define PGE_VECTOR4D_DECLARED 1 diff --git a/examples/olcPGE3_3DCube.cpp b/examples/olcPGE3_3DCube.cpp index 1839d6d..ce127eb 100644 --- a/examples/olcPGE3_3DCube.cpp +++ b/examples/olcPGE3_3DCube.cpp @@ -1,7 +1,7 @@ /* olc::PixelGameEngine3 Example - olc::SanityCube!!! - Draws teh infamous olc::SanityCube using the hardware 3D rendering capabilities. + Draws the infamous olc::SanityCube using the hardware 3D rendering capabilities. Licenced under the OLC-3 License */ @@ -12,6 +12,8 @@ #define OLC_PGE3_APPLICATION #include "../olcPixelGameEngine3.h" +#include + // Example application demonstrating basic 3D rendering. This class // overrides the olc::PixelGameEngine base class by implementing // the OnUserCreate() and OnUserUpdate() functions @@ -123,7 +125,11 @@ class Example_3DCube : public olc::PixelGameEngine draw.Line({ 0,0,0 }, { 0, 1, 0 }, olc::Colour::GREEN); draw.Line({ 0,0,0 }, { 0, 0, 1 }, olc::Colour::BLUE); - draw.StringProp({ 4, 4 }, "+X: Right\n-X: Left\n+Y: Up\n-Y: Down\n+Z: Q\n-Z: A\nSPIN: Space", olc::Colour::BLACK); + // Decompose the quaternion to demonstrate the structured binding support + const auto [x, y, z, w] = vViewTranslate; + draw.String({ 4, 4 }, std::format("X:{: 4.1f} Y:{: 4.1f} Z:{: 4.1f} W:{: 4.1f}", x, y, z, w), olc::Colour::BLACK); + draw.StringProp({ 4, 14 }, "+X: Right\n-X: Left\n+Y: Up\n-Y: Down\n+Z: Q\n-Z: A\nSPIN: Space", olc::Colour::BLACK); + // Successful frame return true; diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index 0265b4a..e92f859 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -1399,7 +1399,7 @@ namespace std { template - struct tuple_element> : tuple_element> {}; + struct tuple_element> : tuple_element> {}; } #define PGE_VECTOR4D_DECLARED 1