I was just having a look at these new problems and I notice that you change in your code the union by struct. Is there any reason for it? I was considering the same thing to be able to specialize the vec<half> which can't be union.

This union with no constructor has always been a pain in all my experiments to implement a good swizzle operator and I haven't found any answer yet. I'm afraid this will remain a critical issue :/

 I still didn't had time to really tackle the subject but if everything goes well, it will have been the case within a week.


On 28 May 2010 16:46, Christoph Schied <Christoph.Schied@uni-ulm.de> wrote:

I continued playing with the swizzle stuff and just encountered a major
problem which I wasn't aware of:
 vec3 v1, v2;
 v1.xy = v2.xy;

This calls the default assignment constructor for attrib_alias_vec2
which won't do anything as attrib_alias has no members. This cannot be
solved as C++ does not allow a member of a union to have a non-default
constructor. This also includes T & operator=(const T &t). The only
solution is to make the left and right side of the assignment different
types, but i don't know how one could create a template which has a
different type in each instantiation (and i don't think this would be a
nice thing). One solution is to make the different swizzle indizes of
different types, and as such make at least the following work:
 vec3 v1, v2;
 v1.rg = v2.xy;
The problem still is that one can't even declare the default-constructor
private, so one cannot create an error.

Any ideas how this could be solved?



ogl-math-devel mailing list