On Sunday, 20 September 2020 at 15:52:49 UTC, realhet wrote:
On Sunday, 20 September 2020 at 14:54:09 UTC, Steven Schveighoffer wrote:
On 9/20/20 9:30 AM, realhet wrote:

I managed to do the constant swizzles and it seems so elegant:

  auto opDispatch(string def)() const
if(validRvalueSwizzle(def)) //making sure that only the few thousand valid swizzles can pass through here
  {
static if(def.startsWith('_')){ //if the swizzle definition starts with a number
      return opDispatch!(def[1..$]);
    }else{
      Vec!(CT, mixin(def.length)) res;
      static foreach(i, ch; def)
res[i] = mixin(ch); // ch can be one of xyzw or rgba or stpq or 0 or 1. // just mix it in using the already created lvalue swizzles of (integer consts 01)
      return res;
    }
  }

I also have an idea that if I use capital letters, it shoud mean negative components. This way importing a 3d vertex could be so easy in compile time: rotated = original.xZy -> this is rotated 90 degrees around the x axis. Just need to add an uppercase check.

Never dared to go that far in compile time dlang stuff, and I love it. :D Amazing language!

Reply via email to