changeset 1474:bb7bbe2fee78 default tip

merge
author sam <sam@basx.dev>
date Sun, 06 Apr 2025 21:56:10 +0700
parents 2cc8103a7418 (diff) 0972bf98c883 (current diff)
children
files semicongine/core/vector.nim
diffstat 1 files changed, 48 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/core/vector.nim	Sat Apr 05 18:32:18 2025 +0700
+++ b/semicongine/core/vector.nim	Sun Apr 06 21:56:10 2025 +0700
@@ -782,13 +782,60 @@
     setterCode,
   )
 
+template x*[T: TVec](v: T): untyped =
+  v[0]
+
+template y*[T: TVec](v: T): untyped =
+  v[1]
+
+template z*[T: TVec](v: T): untyped =
+  v[2]
+
+template w*[T: TVec](v: T): untyped =
+  v[3]
+
+template r*[T: TVec](v: T): untyped =
+  v[0]
+
+template g*[T: TVec](v: T): untyped =
+  v[1]
+
+template b*[T: TVec](v: T): untyped =
+  v[2]
+
+template a*[T: TVec](v: T): untyped =
+  v[3]
+
+template `x=`*[T: TVec, S](v: T, a: S): untyped =
+  v[0] = a
+
+template `y=`*[T: TVec, S](v: T, a: S): untyped =
+  v[1] = a
+
+template `z=`*[T: TVec, S](v: T, a: S): untyped =
+  v[2] = a
+
+template `w=`*[T: TVec, S](v: T, a: S): untyped =
+  v[3] = a
+
+template `r=`*[T: TVec, S](v: T, a: S): untyped =
+  v[0] = a
+
+template `g=`*[T: TVec, S](v: T, a: S): untyped =
+  v[1] = a
+
+template `b=`*[T: TVec, S](v: T, a: S): untyped =
+  v[2] = a
+
+template `a=`*[T: TVec, S](v: T, a: S): untyped =
+  v[3] = a
+
 macro createVectorAttribAccessorFuncs() =
   const COORD_ATTRS = ["x", "y", "z", "w"]
   const COLOR_ATTRS = ["r", "g", "b", "a"]
   result = nnkStmtList.newTree()
   for attlist in [COORD_ATTRS, COLOR_ATTRS]:
     for i in attlist:
-      result.add(vectorAttributeAccessor(i))
       for j in attlist:
         result.add(vectorAttributeAccessor(i & j))
         for k in attlist: