Implementing vector swizzle.
evilrat
evilrat666 at gmail.com
Thu Dec 12 21:02:31 PST 2013
On Friday, 13 December 2013 at 00:53:17 UTC, TheFlyingFiddle
wrote:
> I would like to be able to do this.
>
> auto vector = vec4(1,2,3,4);
> vector.zxy += vec3(4,4,4);
>
>
>
> I'm currently able to do this:
>
> vector.zxy = vec3(4,4,4);
>
> Assigns 4 to the x,y and z components.
>
> and this
>
> auto other = vector.zxy;
> other is a vector3 with
> other.x == vector.z
> other.y == vector.x
> other.z == vector.y
>
> However implementing the
> +=, -=, *=, /= operators is tricky.
>
> How would i go about doing that?
i think gl3n[1] have implemented full GLSL-like swizzle. i
haven't much used it, but you can look how it's done here.
[1] https://github.com/Dav1dde/gl3n
More information about the Digitalmars-d-learn
mailing list