From bf604ef1f7a21114108c4145da2bc630eeebba4a Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 27 Jan 2012 08:04:56 +0000 Subject: [PATCH] math: use the usual GLSL member names for vectors (xyzw, rgba, stpq). --- src/lol/math/matrix.h | 27 ++++++++++++++++++--------- src/tileset.cpp | 12 ++++++------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/lol/math/matrix.h b/src/lol/math/matrix.h index 810fe39e..66d2b563 100644 --- a/src/lol/math/matrix.h +++ b/src/lol/math/matrix.h @@ -277,8 +277,12 @@ template struct Vec2 friend std::ostream &operator<<(std::ostream &stream, Vec2 const &v); #endif - union { T x; T a; T i; }; - union { T y; T b; T j; }; + union + { + struct { T x, y; }; + struct { T r, g; }; + struct { T s, t; }; + }; }; /* @@ -351,9 +355,12 @@ template struct Vec3 friend std::ostream &operator<<(std::ostream &stream, Vec3 const &v); #endif - union { T x; T a; T i; }; - union { T y; T b; T j; }; - union { T z; T c; T k; }; + union + { + struct { T x, y, z; }; + struct { T r, g, b; }; + struct { T s, t, p; }; + }; }; /* @@ -386,10 +393,12 @@ template struct Vec4 friend std::ostream &operator<<(std::ostream &stream, Vec4 const &v); #endif - union { T x; T a; T i; }; - union { T y; T b; T j; }; - union { T z; T c; T k; }; - union { T w; T d; T l; }; + union + { + struct { T x, y, z, w; }; + struct { T r, g, b, a; }; + struct { T s, t, p, q; }; + }; }; /* diff --git a/src/tileset.cpp b/src/tileset.cpp index be7ac312..48935ab9 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -64,7 +64,7 @@ TileSet::TileSet(char const *path, ivec2 size, ivec2 count, float dilate) data->img = new Image(path); data->isize = data->img->GetSize(); - if (count.i > 0 && count.j > 0) + if (count.x > 0 && count.y > 0) { data->count = count; data->size = data->isize / count; @@ -73,8 +73,8 @@ TileSet::TileSet(char const *path, ivec2 size, ivec2 count, float dilate) { if (size.x <= 0 || size.y <= 0) size = ivec2(32, 32); - data->count.i = data->isize.x > size.i ? data->isize.x / size.i : 1; - data->count.j = data->isize.y > size.j ? data->isize.y / size.j : 1; + data->count.x = data->isize.x > size.x ? data->isize.x / size.x : 1; + data->count.y = data->isize.y > size.y ? data->isize.y / size.y : 1; data->size = size; } @@ -82,7 +82,7 @@ TileSet::TileSet(char const *path, ivec2 size, ivec2 count, float dilate) data->ty = (float)data->size.y / PotUp(data->isize.y); data->dilate = dilate; - data->ntiles = data->count.i * data->count.j; + data->ntiles = data->count.x * data->count.y; m_drawgroup = DRAWGROUP_BEFORE; } @@ -181,8 +181,8 @@ void TileSet::Bind() void TileSet::BlitTile(uint32_t id, vec3 pos, int o, float *vertex, float *texture) { - float tx = data->tx * ((id & 0xffff) % data->count.i); - float ty = data->ty * ((id & 0xffff) / data->count.i); + float tx = data->tx * ((id & 0xffff) % data->count.x); + float ty = data->ty * ((id & 0xffff) / data->count.x); float dilate = data->dilate; int dx = data->size.x;