Added Transform objects to love.math (resolves issue #1228).

- Added love.math.newTransform.
- Added love.graphics.applyTransform and love.graphics.replaceTransform.
- love.graphics.draw/print/printf, Text:add/addf, and SpriteBatch:add can accept a Transform argument.
- love.graphics.push can accept an optional Transform as a second argument, which will apply the Transform after pushing the matrix stack,
- Shader:send can accept Transform objects when sending to a mat4 uniform variable.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-11-24 21:30:45 -04:00
parent 9d2ee6d909
commit 14aa6965b3
19 changed files with 820 additions and 94 deletions
+29
View File
@@ -22,8 +22,10 @@
#include "wrap_RandomGenerator.h"
#include "wrap_BezierCurve.h"
#include "wrap_CompressedData.h"
#include "wrap_Transform.h"
#include "MathModule.h"
#include "BezierCurve.h"
#include "Transform.h"
#include "common/b64.h"
#include <cmath>
@@ -118,6 +120,31 @@ int w_newBezierCurve(lua_State *L)
return 1;
}
int w_newTransform(lua_State *L)
{
Transform *t = nullptr;
if (lua_isnoneornil(L, 1))
t = Math::instance.newTransform();
else
{
float x = (float) luaL_checknumber(L, 1);
float y = (float) luaL_checknumber(L, 2);
float a = (float) luaL_optnumber(L, 3, 0.0);
float sx = (float) luaL_optnumber(L, 4, 1.0);
float sy = (float) luaL_optnumber(L, 5, sx);
float ox = (float) luaL_optnumber(L, 6, 0.0);
float oy = (float) luaL_optnumber(L, 7, 0.0);
float kx = (float) luaL_optnumber(L, 8, 0.0);
float ky = (float) luaL_optnumber(L, 9, 0.0);
t = Math::instance.newTransform(x, y, a, sx, sy, ox, oy, kx, ky);
}
luax_pushtype(L, MATH_TRANSFORM_ID, t);
t->release();
return 1;
}
int w_triangulate(lua_State *L)
{
std::vector<love::Vector> vertices;
@@ -507,6 +534,7 @@ static const luaL_Reg functions[] =
{ "_getRandomGenerator", w__getRandomGenerator },
{ "newRandomGenerator", w_newRandomGenerator },
{ "newBezierCurve", w_newBezierCurve },
{ "newTransform", w_newTransform },
{ "triangulate", w_triangulate },
{ "isConvex", w_isConvex },
{ "gammaToLinear", w_gammaToLinear },
@@ -525,6 +553,7 @@ static const lua_CFunction types[] =
luaopen_randomgenerator,
luaopen_beziercurve,
luaopen_compresseddata,
luaopen_transform,
0
};