# HG changeset patch # User sam # Date 1743951370 -25200 # Node ID bb7bbe2fee7898c12016c8a270d7c2c69865a937 # Parent 2cc8103a74187178d0a486be3d60fe3cab06fdad# Parent 0972bf98c88307b8f47c6eca5fbd8c93a2c5520b merge diff -r 0972bf98c883 -r bb7bbe2fee78 semicongine/core/vector.nim --- 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: