Преглед изворни кода

LibGfx: Add `::xyz()` swizzle operator to `Vector4`

Jesse Buhagiar пре 3 година
родитељ
комит
38fc7361ca
1 измењених фајлова са 8 додато и 0 уклоњено
  1. 8 0
      Userland/Libraries/LibGfx/Vector4.h

+ 8 - 0
Userland/Libraries/LibGfx/Vector4.h

@@ -10,6 +10,9 @@
 #include <AK/String.h>
 
 namespace Gfx {
+template<typename T>
+class Vector3;
+
 template<typename T>
 class Vector4 final {
 public:
@@ -131,6 +134,11 @@ public:
         return AK::sqrt(m_x * m_x + m_y * m_y + m_z * m_z + m_w * m_w);
     }
 
+    constexpr Vector3<T> xyz() const
+    {
+        return Vector3<T>(m_x, m_y, m_z);
+    }
+
     String to_string() const
     {
         return String::formatted("[{},{},{},{}]", x(), y(), z(), w());