| @@ -40,12 +40,12 @@ DebugFps::DebugFps(int x, int y) | |||||
| for (int i = 0; i < 5; i ++) | for (int i = 0; i < 5; i ++) | ||||
| { | { | ||||
| data->lines[i] = new Text(NULL, "gfx/font/ascii.png"); | data->lines[i] = new Text(NULL, "gfx/font/ascii.png"); | ||||
| data->lines[i]->SetPos(int3(x, y + (i ? 8 : 0) + 16 * i, 0)); | |||||
| data->lines[i]->SetPos(vec3i(x, y + (i ? 8 : 0) + 16 * i, 0)); | |||||
| Ticker::Ref(data->lines[i]); | Ticker::Ref(data->lines[i]); | ||||
| } | } | ||||
| #else | #else | ||||
| data->lines[0] = new Text(NULL, "gfx/font/ascii.png"); | data->lines[0] = new Text(NULL, "gfx/font/ascii.png"); | ||||
| data->lines[0]->SetPos(int3(x, y, 100)); | |||||
| data->lines[0]->SetPos(vec3i(x, y, 100)); | |||||
| Ticker::Ref(data->lines[0]); | Ticker::Ref(data->lines[0]); | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -29,10 +29,10 @@ class EmitterData | |||||
| private: | private: | ||||
| int tiler; | int tiler; | ||||
| float3 gravity; | |||||
| vec3 gravity; | |||||
| int particles[MAX_PARTICLES]; | int particles[MAX_PARTICLES]; | ||||
| float3 positions[MAX_PARTICLES]; | |||||
| float3 velocities[MAX_PARTICLES]; | |||||
| vec3 positions[MAX_PARTICLES]; | |||||
| vec3 velocities[MAX_PARTICLES]; | |||||
| int nparticles; | int nparticles; | ||||
| }; | }; | ||||
| @@ -40,7 +40,7 @@ private: | |||||
| * Public Emitter class | * Public Emitter class | ||||
| */ | */ | ||||
| Emitter::Emitter(int tiler, float3 gravity) | |||||
| Emitter::Emitter(int tiler, vec3 gravity) | |||||
| : data(new EmitterData()) | : data(new EmitterData()) | ||||
| { | { | ||||
| data->tiler = tiler; | data->tiler = tiler; | ||||
| @@ -77,7 +77,7 @@ void Emitter::TickDraw(float deltams) | |||||
| data->positions[i].z, 0); | data->positions[i].z, 0); | ||||
| } | } | ||||
| void Emitter::AddParticle(int id, float3 pos, float3 vel) | |||||
| void Emitter::AddParticle(int id, vec3 pos, vec3 vel) | |||||
| { | { | ||||
| if (data->nparticles >= EmitterData::MAX_PARTICLES) | if (data->nparticles >= EmitterData::MAX_PARTICLES) | ||||
| return; | return; | ||||
| @@ -23,10 +23,10 @@ class EmitterData; | |||||
| class Emitter : public Entity | class Emitter : public Entity | ||||
| { | { | ||||
| public: | public: | ||||
| Emitter(int tiler, float3 gravity); | |||||
| Emitter(int tiler, vec3 gravity); | |||||
| virtual ~Emitter(); | virtual ~Emitter(); | ||||
| void AddParticle(int id, float3 pos, float3 vel); | |||||
| void AddParticle(int id, vec3 pos, vec3 vel); | |||||
| protected: | protected: | ||||
| virtual void TickGame(float deltams); | virtual void TickGame(float deltams); | ||||
| @@ -28,7 +28,7 @@ class FontData | |||||
| private: | private: | ||||
| char *name; | char *name; | ||||
| int tiler; | int tiler; | ||||
| int2 size; | |||||
| vec2i size; | |||||
| }; | }; | ||||
| /* | /* | ||||
| @@ -64,7 +64,7 @@ char const *Font::GetName() | |||||
| return data->name; | return data->name; | ||||
| } | } | ||||
| void Font::Print(int3 pos, char const *str) | |||||
| void Font::Print(vec3i pos, char const *str) | |||||
| { | { | ||||
| Scene *scene = Scene::GetDefault(); | Scene *scene = Scene::GetDefault(); | ||||
| @@ -80,7 +80,7 @@ void Font::Print(int3 pos, char const *str) | |||||
| } | } | ||||
| } | } | ||||
| int2 Font::GetSize() const | |||||
| vec2i Font::GetSize() const | |||||
| { | { | ||||
| return data->size; | return data->size; | ||||
| } | } | ||||
| @@ -33,8 +33,8 @@ protected: | |||||
| public: | public: | ||||
| /* New methods */ | /* New methods */ | ||||
| void Print(int3 pos, char const *str); | |||||
| int2 GetSize() const; | |||||
| void Print(vec3i pos, char const *str); | |||||
| vec2i GetSize() const; | |||||
| private: | private: | ||||
| FontData *data; | FontData *data; | ||||
| @@ -37,8 +37,8 @@ public: | |||||
| { } | { } | ||||
| private: | private: | ||||
| int2 mouse; | |||||
| int3 buttons; | |||||
| vec2i mouse; | |||||
| vec3i buttons; | |||||
| static int const MAX_ENTITIES = 100; | static int const MAX_ENTITIES = 100; | ||||
| WorldEntity *entities[MAX_ENTITIES]; | WorldEntity *entities[MAX_ENTITIES]; | ||||
| @@ -53,10 +53,10 @@ static InputData * const data = &inputdata; | |||||
| * Public Input class | * Public Input class | ||||
| */ | */ | ||||
| float2 Input::GetAxis(int axis) | |||||
| vec2 Input::GetAxis(int axis) | |||||
| { | { | ||||
| float invsqrt2 = sqrtf(0.5f); | float invsqrt2 = sqrtf(0.5f); | ||||
| float2 f; | |||||
| vec2 f; | |||||
| /* Simulate a joystick using the keyboard. This SDL call is free. */ | /* Simulate a joystick using the keyboard. This SDL call is free. */ | ||||
| Uint8 *keystate = SDL_GetKeyState(NULL); | Uint8 *keystate = SDL_GetKeyState(NULL); | ||||
| @@ -70,12 +70,12 @@ float2 Input::GetAxis(int axis) | |||||
| return f; | return f; | ||||
| } | } | ||||
| int2 Input::GetMousePos() | |||||
| vec2i Input::GetMousePos() | |||||
| { | { | ||||
| return data->mouse; | return data->mouse; | ||||
| } | } | ||||
| int3 Input::GetMouseButtons() | |||||
| vec3i Input::GetMouseButtons() | |||||
| { | { | ||||
| return data->buttons; | return data->buttons; | ||||
| } | } | ||||
| @@ -101,7 +101,7 @@ void Input::UntrackMouse(WorldEntity *e) | |||||
| } | } | ||||
| } | } | ||||
| void Input::SetMousePos(int2 coord) | |||||
| void Input::SetMousePos(vec2i coord) | |||||
| { | { | ||||
| data->mouse = coord; | data->mouse = coord; | ||||
| @@ -123,7 +123,7 @@ void Input::SetMousePos(int2 coord) | |||||
| { | { | ||||
| if (data->entities[n] == best) | if (data->entities[n] == best) | ||||
| { | { | ||||
| data->entities[n]->mousepos = (int2)((int3)coord - best->bbox[0]); | |||||
| data->entities[n]->mousepos = (vec2i)((vec3i)coord - best->bbox[0]); | |||||
| if (best != data->lastfocus) | if (best != data->lastfocus) | ||||
| data->entities[n]->pressed = data->buttons; | data->entities[n]->pressed = data->buttons; | ||||
| else | else | ||||
| @@ -131,7 +131,7 @@ void Input::SetMousePos(int2 coord) | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| data->entities[n]->mousepos = int2(-1); | |||||
| data->entities[n]->mousepos = vec2i(-1); | |||||
| /* FIXME */ | /* FIXME */ | ||||
| data->entities[n]->released = 0; | data->entities[n]->released = 0; | ||||
| data->entities[n]->pressed = 0; | data->entities[n]->pressed = 0; | ||||
| @@ -24,16 +24,16 @@ class Input | |||||
| { | { | ||||
| public: | public: | ||||
| /* These methods are general queries */ | /* These methods are general queries */ | ||||
| static float2 GetAxis(int axis); | |||||
| static int2 GetMousePos(); | |||||
| static int3 GetMouseButtons(); | |||||
| static vec2 GetAxis(int axis); | |||||
| static vec2i GetMousePos(); | |||||
| static vec3i GetMouseButtons(); | |||||
| /* Entities can subscribe to events */ | /* Entities can subscribe to events */ | ||||
| static void TrackMouse(WorldEntity *e); | static void TrackMouse(WorldEntity *e); | ||||
| static void UntrackMouse(WorldEntity *e); | static void UntrackMouse(WorldEntity *e); | ||||
| /* These methods are called by the underlying input listeners */ | /* These methods are called by the underlying input listeners */ | ||||
| static void SetMousePos(int2 coord); | |||||
| static void SetMousePos(vec2i coord); | |||||
| static void SetMouseButton(int index); | static void SetMouseButton(int index); | ||||
| static void UnsetMouseButton(int index); | static void UnsetMouseButton(int index); | ||||
| }; | }; | ||||
| @@ -27,7 +27,7 @@ static inline float det3(float a, float b, float c, | |||||
| + c * (d * h - g * e); | + c * (d * h - g * e); | ||||
| } | } | ||||
| static inline float cofact3(float4x4 const &mat, int i, int j) | |||||
| static inline float cofact3(mat4 const &mat, int i, int j) | |||||
| { | { | ||||
| return det3(mat[(i + 1) & 3][(j + 1) & 3], | return det3(mat[(i + 1) & 3][(j + 1) & 3], | ||||
| mat[(i + 2) & 3][(j + 1) & 3], | mat[(i + 2) & 3][(j + 1) & 3], | ||||
| @@ -40,7 +40,7 @@ static inline float cofact3(float4x4 const &mat, int i, int j) | |||||
| mat[(i + 3) & 3][(j + 3) & 3]) * (((i + j) & 1) ? -1.0f : 1.0f); | mat[(i + 3) & 3][(j + 3) & 3]) * (((i + j) & 1) ? -1.0f : 1.0f); | ||||
| } | } | ||||
| template<> float float4x4::det() const | |||||
| template<> float mat4::det() const | |||||
| { | { | ||||
| float ret = 0; | float ret = 0; | ||||
| for (int n = 0; n < 4; n++) | for (int n = 0; n < 4; n++) | ||||
| @@ -48,9 +48,9 @@ template<> float float4x4::det() const | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| template<> float4x4 float4x4::invert() const | |||||
| template<> mat4 mat4::invert() const | |||||
| { | { | ||||
| float4x4 ret; | |||||
| mat4 ret; | |||||
| float d = det(); | float d = det(); | ||||
| if (d) | if (d) | ||||
| { | { | ||||
| @@ -62,14 +62,14 @@ template<> float4x4 float4x4::invert() const | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| template<> float4x4 float4x4::ortho(float left, float right, float bottom, | |||||
| float top, float near, float far) | |||||
| template<> mat4 mat4::ortho(float left, float right, float bottom, | |||||
| float top, float near, float far) | |||||
| { | { | ||||
| float invrl = (right != left) ? 1.0f / (right - left) : 0.0f; | float invrl = (right != left) ? 1.0f / (right - left) : 0.0f; | ||||
| float invtb = (top != bottom) ? 1.0f / (top - bottom) : 0.0f; | float invtb = (top != bottom) ? 1.0f / (top - bottom) : 0.0f; | ||||
| float invfn = (far != near) ? 1.0f / (far - near) : 0.0f; | float invfn = (far != near) ? 1.0f / (far - near) : 0.0f; | ||||
| float4x4 ret(0.0f); | |||||
| mat4 ret(0.0f); | |||||
| ret[0][0] = 2.0f * invrl; | ret[0][0] = 2.0f * invrl; | ||||
| ret[1][1] = 2.0f * invtb; | ret[1][1] = 2.0f * invtb; | ||||
| ret[2][2] = -2.0f * invfn; | ret[2][2] = -2.0f * invfn; | ||||
| @@ -80,14 +80,14 @@ template<> float4x4 float4x4::ortho(float left, float right, float bottom, | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| template<> float4x4 float4x4::frustum(float left, float right, float bottom, | |||||
| float top, float near, float far) | |||||
| template<> mat4 mat4::frustum(float left, float right, float bottom, | |||||
| float top, float near, float far) | |||||
| { | { | ||||
| float invrl = (right != left) ? 1.0f / (right - left) : 0.0f; | float invrl = (right != left) ? 1.0f / (right - left) : 0.0f; | ||||
| float invtb = (top != bottom) ? 1.0f / (top - bottom) : 0.0f; | float invtb = (top != bottom) ? 1.0f / (top - bottom) : 0.0f; | ||||
| float invfn = (far != near) ? 1.0f / (far - near) : 0.0f; | float invfn = (far != near) ? 1.0f / (far - near) : 0.0f; | ||||
| float4x4 ret(0.0f); | |||||
| mat4 ret(0.0f); | |||||
| ret[0][0] = 2.0f * near * invrl; | ret[0][0] = 2.0f * near * invrl; | ||||
| ret[1][1] = 2.0f * near * invtb; | ret[1][1] = 2.0f * near * invtb; | ||||
| ret[2][0] = (right + left) * invrl; | ret[2][0] = (right + left) * invrl; | ||||
| @@ -98,8 +98,8 @@ template<> float4x4 float4x4::frustum(float left, float right, float bottom, | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| template<> float4x4 float4x4::perspective(float theta, float width, | |||||
| float height, float near, float far) | |||||
| template<> mat4 mat4::perspective(float theta, float width, | |||||
| float height, float near, float far) | |||||
| { | { | ||||
| float t1 = tanf(theta / 2.0f); | float t1 = tanf(theta / 2.0f); | ||||
| float t2 = t1 * height / width; | float t2 = t1 * height / width; | ||||
| @@ -107,16 +107,16 @@ template<> float4x4 float4x4::perspective(float theta, float width, | |||||
| return frustum(-near * t1, near * t1, -near * t2, near * t2, near, far); | return frustum(-near * t1, near * t1, -near * t2, near * t2, near, far); | ||||
| } | } | ||||
| template<> float4x4 float4x4::translate(float x, float y, float z) | |||||
| template<> mat4 mat4::translate(float x, float y, float z) | |||||
| { | { | ||||
| float4x4 ret(1.0f); | |||||
| mat4 ret(1.0f); | |||||
| ret[3][0] = x; | ret[3][0] = x; | ||||
| ret[3][1] = y; | ret[3][1] = y; | ||||
| ret[3][2] = z; | ret[3][2] = z; | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| template<> float4x4 float4x4::rotate(float theta, float x, float y, float z) | |||||
| template<> mat4 mat4::rotate(float theta, float x, float y, float z) | |||||
| { | { | ||||
| float st = sinf(theta); | float st = sinf(theta); | ||||
| float ct = cosf(theta); | float ct = cosf(theta); | ||||
| @@ -131,7 +131,7 @@ template<> float4x4 float4x4::rotate(float theta, float x, float y, float z) | |||||
| float mty = (1.0f - ct) * y; | float mty = (1.0f - ct) * y; | ||||
| float mtz = (1.0f - ct) * z; | float mtz = (1.0f - ct) * z; | ||||
| float4x4 ret(1.0f); | |||||
| mat4 ret(1.0f); | |||||
| ret[0][0] = x * mtx + ct; | ret[0][0] = x * mtx + ct; | ||||
| ret[0][1] = x * mty + st * z; | ret[0][1] = x * mty + st * z; | ||||
| @@ -278,15 +278,5 @@ template <typename T> struct Mat4 | |||||
| typedef Mat4<float> mat4; | typedef Mat4<float> mat4; | ||||
| typedef Mat4<int> mat4i; | typedef Mat4<int> mat4i; | ||||
| /* Aliases for deprecated stuff */ | |||||
| typedef Vec2<float> float2; | |||||
| typedef Vec2<int> int2; | |||||
| typedef Vec3<float> float3; | |||||
| typedef Vec3<int> int3; | |||||
| typedef Vec4<float> float4; | |||||
| typedef Vec4<int> int4; | |||||
| typedef Mat4<float> float4x4; | |||||
| typedef Mat4<int> int4x4; | |||||
| #endif // __DH_MATRIX_H__ | #endif // __DH_MATRIX_H__ | ||||
| @@ -38,7 +38,7 @@ struct Tile | |||||
| #if LOL_EXPERIMENTAL | #if LOL_EXPERIMENTAL | ||||
| extern Shader *stdshader; | extern Shader *stdshader; | ||||
| #endif | #endif | ||||
| extern float4x4 projection_matrix, view_matrix, model_matrix; | |||||
| extern mat4 projection_matrix, view_matrix, model_matrix; | |||||
| /* | /* | ||||
| * Scene implementation class | * Scene implementation class | ||||
| @@ -136,15 +136,15 @@ void Scene::Render() // XXX: rename to Blit() | |||||
| qsort(data->tiles, data->ntiles, sizeof(Tile), SceneData::Compare); | qsort(data->tiles, data->ntiles, sizeof(Tile), SceneData::Compare); | ||||
| // XXX: debug stuff | // XXX: debug stuff | ||||
| model_matrix = float4x4::translate(320.0f, 240.0f, 0.0f); | |||||
| model_matrix *= float4x4::rotate(-data->angle, 1.0f, 0.0f, 0.0f); | |||||
| model_matrix = mat4::translate(320.0f, 240.0f, 0.0f); | |||||
| model_matrix *= mat4::rotate(-data->angle, 1.0f, 0.0f, 0.0f); | |||||
| #if 0 | #if 0 | ||||
| static float f = 0.0f; | static float f = 0.0f; | ||||
| f += 0.01f; | f += 0.01f; | ||||
| model_matrix *= float4x4::rotate(0.1f * sinf(f), 1.0f, 0.0f, 0.0f); | |||||
| model_matrix *= float4x4::rotate(0.3f * cosf(f), 0.0f, 0.0f, 1.0f); | |||||
| model_matrix *= mat4::rotate(0.1f * sinf(f), 1.0f, 0.0f, 0.0f); | |||||
| model_matrix *= mat4::rotate(0.3f * cosf(f), 0.0f, 0.0f, 1.0f); | |||||
| #endif | #endif | ||||
| model_matrix *= float4x4::translate(-320.0f, -240.0f, 0.0f); | |||||
| model_matrix *= mat4::translate(-320.0f, -240.0f, 0.0f); | |||||
| // XXX: end of debug stuff | // XXX: end of debug stuff | ||||
| #if LOL_EXPERIMENTAL | #if LOL_EXPERIMENTAL | ||||
| @@ -48,7 +48,7 @@ void SdlInput::TickGame(float deltams) | |||||
| Entity::TickGame(deltams); | Entity::TickGame(deltams); | ||||
| /* Handle mouse input */ | /* Handle mouse input */ | ||||
| int2 mouse; | |||||
| vec2i mouse; | |||||
| if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) | if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) | ||||
| { | { | ||||
| SDL_GetMouseState(&mouse.x, &mouse.y); | SDL_GetMouseState(&mouse.x, &mouse.y); | ||||
| @@ -29,7 +29,7 @@ class TextData | |||||
| private: | private: | ||||
| int font, align, length; | int font, align, length; | ||||
| char *text; | char *text; | ||||
| int3 pos; | |||||
| vec3i pos; | |||||
| }; | }; | ||||
| /* | /* | ||||
| @@ -42,7 +42,7 @@ Text::Text(char const *text, char const *font) | |||||
| data->font = Forge::Register(font); | data->font = Forge::Register(font); | ||||
| data->text = text ? strdup(text) : NULL; | data->text = text ? strdup(text) : NULL; | ||||
| data->length = text ? strlen(text) : 0; | data->length = text ? strlen(text) : 0; | ||||
| data->pos = int3(0, 0, 0); | |||||
| data->pos = vec3i(0, 0, 0); | |||||
| drawgroup = DRAWGROUP_HUD; | drawgroup = DRAWGROUP_HUD; | ||||
| } | } | ||||
| @@ -65,7 +65,7 @@ void Text::SetInt(int val) | |||||
| data->length = strlen(text); | data->length = strlen(text); | ||||
| } | } | ||||
| void Text::SetPos(int3 pos) | |||||
| void Text::SetPos(vec3i pos) | |||||
| { | { | ||||
| data->pos = pos; | data->pos = pos; | ||||
| } | } | ||||
| @@ -82,7 +82,7 @@ void Text::TickDraw(float deltams) | |||||
| if (data->text) | if (data->text) | ||||
| { | { | ||||
| Font *font = Forge::GetFont(data->font); | Font *font = Forge::GetFont(data->font); | ||||
| int3 delta = 0; | |||||
| vec3i delta = 0; | |||||
| if (data->align == ALIGN_RIGHT) | if (data->align == ALIGN_RIGHT) | ||||
| delta.x -= data->length * font->GetSize().x; | delta.x -= data->length * font->GetSize().x; | ||||
| else if (data->align == ALIGN_CENTER) | else if (data->align == ALIGN_CENTER) | ||||
| @@ -28,7 +28,7 @@ public: | |||||
| void SetText(char const *text); | void SetText(char const *text); | ||||
| void SetInt(int val); | void SetInt(int val); | ||||
| void SetPos(int3 pos); | |||||
| void SetPos(vec3i pos); | |||||
| void SetAlign(int align); | void SetAlign(int align); | ||||
| enum | enum | ||||
| @@ -45,7 +45,7 @@ static TilerData * const data = &tilerdata; | |||||
| * Public Tiler class | * Public Tiler class | ||||
| */ | */ | ||||
| int Tiler::Register(char const *path, int2 size, int2 count, float dilate) | |||||
| int Tiler::Register(char const *path, vec2i size, vec2i count, float dilate) | |||||
| { | { | ||||
| int id = data->tilesets.MakeSlot(path); | int id = data->tilesets.MakeSlot(path); | ||||
| @@ -67,7 +67,7 @@ void Tiler::Deregister(int id) | |||||
| data->tilesets.RemoveSlot(id - 1); /* ID 0 is for the empty tileset */ | data->tilesets.RemoveSlot(id - 1); /* ID 0 is for the empty tileset */ | ||||
| } | } | ||||
| int2 Tiler::GetSize(int id) | |||||
| vec2i Tiler::GetSize(int id) | |||||
| { | { | ||||
| TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1); | TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1); | ||||
| #if !LOL_RELEASE | #if !LOL_RELEASE | ||||
| @@ -80,7 +80,7 @@ int2 Tiler::GetSize(int id) | |||||
| return tileset->GetSize(); | return tileset->GetSize(); | ||||
| } | } | ||||
| int2 Tiler::GetCount(int id) | |||||
| vec2i Tiler::GetCount(int id) | |||||
| { | { | ||||
| TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1); | TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1); | ||||
| #if !LOL_RELEASE | #if !LOL_RELEASE | ||||
| @@ -22,11 +22,12 @@ | |||||
| class Tiler | class Tiler | ||||
| { | { | ||||
| public: | public: | ||||
| static int Register(char const *path, int2 size, int2 count, float dilate); | |||||
| static int Register(char const *path, vec2i size, vec2i count, | |||||
| float dilate); | |||||
| static void Deregister(int id); | static void Deregister(int id); | ||||
| static int2 GetSize(int id); | |||||
| static int2 GetCount(int id); | |||||
| static vec2i GetSize(int id); | |||||
| static vec2i GetCount(int id); | |||||
| static void Bind(uint32_t code); | static void Bind(uint32_t code); | ||||
| static void BlitTile(uint32_t code, int x, int y, int z, int o, | static void BlitTile(uint32_t code, int x, int y, int z, int o, | ||||
| float *vertex, float *texture); | float *vertex, float *texture); | ||||
| @@ -42,7 +42,7 @@ class TileSetData | |||||
| private: | private: | ||||
| char *name, *path; | char *name, *path; | ||||
| int *tiles, ntiles; | int *tiles, ntiles; | ||||
| int2 size, count; | |||||
| vec2i size, count; | |||||
| float dilate, tx, ty; | float dilate, tx, ty; | ||||
| SDL_Surface *img; | SDL_Surface *img; | ||||
| @@ -53,7 +53,7 @@ private: | |||||
| * Public TileSet class | * Public TileSet class | ||||
| */ | */ | ||||
| TileSet::TileSet(char const *path, int2 size, int2 count, float dilate) | |||||
| TileSet::TileSet(char const *path, vec2i size, vec2i count, float dilate) | |||||
| : data(new TileSetData()) | : data(new TileSetData()) | ||||
| { | { | ||||
| data->name = (char *)malloc(10 + strlen(path) + 1); | data->name = (char *)malloc(10 + strlen(path) + 1); | ||||
| @@ -80,7 +80,7 @@ TileSet::TileSet(char const *path, int2 size, int2 count, float dilate) | |||||
| if (count.i > 0 && count.j > 0) | if (count.i > 0 && count.j > 0) | ||||
| { | { | ||||
| data->count = count; | data->count = count; | ||||
| data->size = int2(data->img->w, data->img->h) / count; | |||||
| data->size = vec2i(data->img->w, data->img->h) / count; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -157,12 +157,12 @@ char const *TileSet::GetName() | |||||
| return data->name; | return data->name; | ||||
| } | } | ||||
| int2 TileSet::GetSize() const | |||||
| vec2i TileSet::GetSize() const | |||||
| { | { | ||||
| return data->size; | return data->size; | ||||
| } | } | ||||
| int2 TileSet::GetCount() const | |||||
| vec2i TileSet::GetCount() const | |||||
| { | { | ||||
| return data->count; | return data->count; | ||||
| } | } | ||||
| @@ -28,7 +28,7 @@ class TileSetData; | |||||
| class TileSet : public Entity | class TileSet : public Entity | ||||
| { | { | ||||
| public: | public: | ||||
| TileSet(char const *path, int2 size, int2 count, float dilate); | |||||
| TileSet(char const *path, vec2i size, vec2i count, float dilate); | |||||
| virtual ~TileSet(); | virtual ~TileSet(); | ||||
| protected: | protected: | ||||
| @@ -38,8 +38,8 @@ protected: | |||||
| public: | public: | ||||
| /* New methods */ | /* New methods */ | ||||
| int2 GetSize() const; | |||||
| int2 GetCount() const; | |||||
| vec2i GetSize() const; | |||||
| vec2i GetCount() const; | |||||
| void Bind(); | void Bind(); | ||||
| void BlitTile(uint32_t id, int x, int y, int z, int o, | void BlitTile(uint32_t id, int x, int y, int z, int o, | ||||
| float *vertex, float *texture); | float *vertex, float *texture); | ||||
| @@ -31,7 +31,7 @@ | |||||
| #if LOL_EXPERIMENTAL | #if LOL_EXPERIMENTAL | ||||
| Shader *stdshader; | Shader *stdshader; | ||||
| #endif | #endif | ||||
| float4x4 projection_matrix, view_matrix, model_matrix; | |||||
| mat4 projection_matrix, view_matrix, model_matrix; | |||||
| #if LOL_EXPERIMENTAL | #if LOL_EXPERIMENTAL | ||||
| static char const *vertexshader = | static char const *vertexshader = | ||||
| @@ -92,7 +92,7 @@ void Video::SetFov(float theta) | |||||
| { | { | ||||
| #undef near /* Fuck Microsoft */ | #undef near /* Fuck Microsoft */ | ||||
| #undef far /* Fuck Microsoft again */ | #undef far /* Fuck Microsoft again */ | ||||
| float4x4 proj; | |||||
| mat4 proj; | |||||
| float width = GetWidth(); | float width = GetWidth(); | ||||
| float height = GetHeight(); | float height = GetHeight(); | ||||
| @@ -103,7 +103,7 @@ void Video::SetFov(float theta) | |||||
| if (theta < 1e-4f) | if (theta < 1e-4f) | ||||
| { | { | ||||
| /* The easy way: purely orthogonal projection. */ | /* The easy way: purely orthogonal projection. */ | ||||
| proj = float4x4::ortho(0, width, 0, height, near, far); | |||||
| proj = mat4::ortho(0, width, 0, height, near, far); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -123,14 +123,14 @@ void Video::SetFov(float theta) | |||||
| near = 1.0f; | near = 1.0f; | ||||
| } | } | ||||
| proj = float4x4::frustum(-near * t1, near * t1, | |||||
| -near * t2, near * t2, near, far) | |||||
| * float4x4::translate(-0.5f * width, -0.5f * height, -dist); | |||||
| proj = mat4::frustum(-near * t1, near * t1, | |||||
| -near * t2, near * t2, near, far) | |||||
| * mat4::translate(-0.5f * width, -0.5f * height, -dist); | |||||
| } | } | ||||
| #if LOL_EXPERIMENTAL | #if LOL_EXPERIMENTAL | ||||
| projection_matrix = proj; | projection_matrix = proj; | ||||
| view_matrix = float4x4(1.0f); | |||||
| view_matrix = mat4(1.0f); | |||||
| #else | #else | ||||
| glMatrixMode(GL_PROJECTION); | glMatrixMode(GL_PROJECTION); | ||||
| glLoadIdentity(); | glLoadIdentity(); | ||||
| @@ -21,14 +21,14 @@ | |||||
| class WorldEntity : public Entity | class WorldEntity : public Entity | ||||
| { | { | ||||
| public: | public: | ||||
| float3 position; | |||||
| float3 rotation; | |||||
| float3 velocity; | |||||
| float3 bbox[2]; | |||||
| int2 mousepos; | |||||
| int3 mousebuttons; | |||||
| int3 pressed, clicked, released; | |||||
| vec3 position; | |||||
| vec3 rotation; | |||||
| vec3 velocity; | |||||
| vec3 bbox[2]; | |||||
| vec2i mousepos; | |||||
| vec3i mousebuttons; | |||||
| vec3i pressed, clicked, released; | |||||
| protected: | protected: | ||||
| WorldEntity(); | WorldEntity(); | ||||
| @@ -32,15 +32,15 @@ public: | |||||
| void setUp() | void setUp() | ||||
| { | { | ||||
| identity = float4x4(1.0f); | |||||
| triangular = float4x4(float4(1.0f, 0.0f, 0.0f, 0.0f), | |||||
| float4(7.0f, 2.0f, 0.0f, 0.0f), | |||||
| float4(1.0f, 5.0f, 3.0f, 0.0f), | |||||
| float4(8.0f, 9.0f, 2.0f, 4.0f)); | |||||
| invertible = float4x4(float4( 1.0f, 1.0f, 2.0f, -1.0f), | |||||
| float4(-2.0f, -1.0f, -2.0f, 2.0f), | |||||
| float4( 4.0f, 2.0f, 5.0f, -4.0f), | |||||
| float4( 5.0f, -3.0f, -7.0f, -6.0f)); | |||||
| identity = mat4(1.0f); | |||||
| triangular = mat4(vec4(1.0f, 0.0f, 0.0f, 0.0f), | |||||
| vec4(7.0f, 2.0f, 0.0f, 0.0f), | |||||
| vec4(1.0f, 5.0f, 3.0f, 0.0f), | |||||
| vec4(8.0f, 9.0f, 2.0f, 4.0f)); | |||||
| invertible = mat4(vec4( 1.0f, 1.0f, 2.0f, -1.0f), | |||||
| vec4(-2.0f, -1.0f, -2.0f, 2.0f), | |||||
| vec4( 4.0f, 2.0f, 5.0f, -4.0f), | |||||
| vec4( 5.0f, -3.0f, -7.0f, -6.0f)); | |||||
| } | } | ||||
| void tearDown() {} | void tearDown() {} | ||||
| @@ -55,9 +55,9 @@ public: | |||||
| void test_mat_mul() | void test_mat_mul() | ||||
| { | { | ||||
| float4x4 m0 = identity; | |||||
| float4x4 m1 = identity; | |||||
| float4x4 m2 = m0 * m1; | |||||
| mat4 m0 = identity; | |||||
| mat4 m1 = identity; | |||||
| mat4 m2 = m0 * m1; | |||||
| CPPUNIT_ASSERT(m2[0][0] == 1.0f); | CPPUNIT_ASSERT(m2[0][0] == 1.0f); | ||||
| CPPUNIT_ASSERT(m2[1][0] == 0.0f); | CPPUNIT_ASSERT(m2[1][0] == 0.0f); | ||||
| @@ -82,10 +82,10 @@ public: | |||||
| void test_mat_inv() | void test_mat_inv() | ||||
| { | { | ||||
| float4x4 m0 = invertible; | |||||
| float4x4 m1 = m0.invert(); | |||||
| mat4 m0 = invertible; | |||||
| mat4 m1 = m0.invert(); | |||||
| float4x4 m2 = m0 * m1; | |||||
| mat4 m2 = m0 * m1; | |||||
| CPPUNIT_ASSERT(m2[0][0] == 1.0f); | CPPUNIT_ASSERT(m2[0][0] == 1.0f); | ||||
| CPPUNIT_ASSERT(m2[1][0] == 0.0f); | CPPUNIT_ASSERT(m2[1][0] == 0.0f); | ||||
| @@ -109,7 +109,7 @@ public: | |||||
| } | } | ||||
| private: | private: | ||||
| float4x4 triangular, identity, invertible; | |||||
| mat4 triangular, identity, invertible; | |||||
| }; | }; | ||||
| CPPUNIT_TEST_SUITE_REGISTRATION(MatrixTest); | CPPUNIT_TEST_SUITE_REGISTRATION(MatrixTest); | ||||