# HG changeset patch # User sam # Date 1743951322 -25200 # Node ID 2cc8103a74187178d0a486be3d60fe3cab06fdad # Parent cfec585882ce6a6a44fcdea13b6c844998296d9b fix: make vector component assignment work diff -r cfec585882ce -r 2cc8103a7418 semicongine/core/vector.nim --- a/semicongine/core/vector.nim Wed Apr 02 22:41:48 2025 +0700 +++ b/semicongine/core/vector.nim Sun Apr 06 21:55:22 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: