Explorar el Código

math: use the usual GLSL member names for vectors (xyzw, rgba, stpq).

legacy
Sam Hocevar sam hace 13 años
padre
commit
bf604ef1f7
Se han modificado 2 ficheros con 24 adiciones y 15 borrados
  1. +18
    -9
      src/lol/math/matrix.h
  2. +6
    -6
      src/tileset.cpp

+ 18
- 9
src/lol/math/matrix.h Ver fichero

@@ -277,8 +277,12 @@ template <typename T> struct Vec2
friend std::ostream &operator<<(std::ostream &stream, Vec2<U> 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 <typename T> struct Vec3
friend std::ostream &operator<<(std::ostream &stream, Vec3<U> 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 <typename T> struct Vec4
friend std::ostream &operator<<(std::ostream &stream, Vec4<U> 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; };
};
};

/*


+ 6
- 6
src/tileset.cpp Ver fichero

@@ -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;


Cargando…
Cancelar
Guardar