From 642a84925b703fb45996bc28bdb1c327ea7bfd24 Mon Sep 17 00:00:00 2001 From: Borealis Date: Wed, 8 Jan 2025 18:41:06 +0000 Subject: [PATCH] Auto-update from libvoxelstorm: latest improvements from webgpu demo3 for the Armchair engine (f235ae1) --- vectorstorm/vector/vector2.h | 21 +++++++++++++++++++-- vectorstorm/vector/vector3.h | 20 ++++++++++++++++++-- vectorstorm/vector/vector4.h | 20 ++++++++++++++++++-- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/vectorstorm/vector/vector2.h b/vectorstorm/vector/vector2.h index acaffbb..99b1443 100644 --- a/vectorstorm/vector/vector2.h +++ b/vectorstorm/vector/vector2.h @@ -564,15 +564,32 @@ class vector2 { return vector2(-x, -y); } - //-------------[ size operations ]--------------------------- + //-------------[ data operations ]--------------------------- + /** + * Data access + * @return pointer to the first element in the vector + */ + inline T constexpr *data() noexcept __attribute__((__always_inline__)) { + return &x; + } + /** + * Data access + * @return pointer to the first element in the vector, const version + */ + inline T constexpr const *data() const noexcept __attribute__((__always_inline__)) { + return &x; + } + /** * Get number of elements in the vector. * @return number of elements (will always return 2) */ - static inline size_t consteval size() noexcept __attribute__((__always_inline__)) __attribute__((__const__)) { + static inline unsigned int constexpr size() noexcept __attribute__((__always_inline__)) __attribute__((__const__)) { return 2u; } + //-------------[ size operations ]--------------------------- + /** * Return square of length. * @return length ^ 2 diff --git a/vectorstorm/vector/vector3.h b/vectorstorm/vector/vector3.h index b4a26ab..14a4f9c 100644 --- a/vectorstorm/vector/vector3.h +++ b/vectorstorm/vector/vector3.h @@ -779,15 +779,31 @@ class vector3 { return vector3(-x, -y, -z); } - //-------------[ size operations ]--------------------------- + //-------------[ data operations ]--------------------------- + /** + * Data access + * @return pointer to the first element in the vector + */ + inline T constexpr *data() noexcept __attribute__((__always_inline__)) { + return &x; + } + /** + * Data access + * @return pointer to the first element in the vector, const version + */ + inline T constexpr const *data() const noexcept __attribute__((__always_inline__)) { + return &x; + } + /** * Get number of elements in the vector. * @return number of elements (will always return 3) */ - static inline size_t consteval size() noexcept __attribute__((__always_inline__)) __attribute__((__const__)) { + static inline unsigned int constexpr size() noexcept __attribute__((__always_inline__)) __attribute__((__const__)) { return 3u; } + //-------------[ size operations ]--------------------------- /** * Return square of length. * @return length ^ 2 diff --git a/vectorstorm/vector/vector4.h b/vectorstorm/vector/vector4.h index 41dc908..e6ef1b0 100644 --- a/vectorstorm/vector/vector4.h +++ b/vectorstorm/vector/vector4.h @@ -903,15 +903,31 @@ class vector4 { return *this; } - //-------------[ size operations ]--------------------------- + //-------------[ data operations ]--------------------------- + /** + * Data access + * @return pointer to the first element in the vector + */ + inline T constexpr *data() noexcept __attribute__((__always_inline__)) { + return &x; + } + /** + * Data access + * @return pointer to the first element in the vector, const version + */ + inline T constexpr const *data() const noexcept __attribute__((__always_inline__)) { + return &x; + } + /** * Get number of elements in the vector. * @return number of elements (will always return 4) */ - static inline size_t consteval size() noexcept __attribute__((__always_inline__)) __attribute__((__const__)) { + static inline unsigned int constexpr size() noexcept __attribute__((__always_inline__)) __attribute__((__const__)) { return 4u; } + //-------------[ size operations ]--------------------------- /** * Return square of length. * @return length ^ 2