mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Slightly reduced the CPU usage of SpriteBatch:add, Text:add, and love.graphics.draw(ParticleSystem).
This commit is contained in:
@@ -221,6 +221,11 @@ Matrix3::Matrix3(const Matrix4 &mat4)
|
||||
e[8] = mat4elems[10];
|
||||
}
|
||||
|
||||
Matrix3::Matrix3(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
}
|
||||
|
||||
Matrix3::~Matrix3()
|
||||
{
|
||||
}
|
||||
@@ -288,4 +293,23 @@ Matrix3 Matrix3::transposedInverse() const
|
||||
return m;
|
||||
}
|
||||
|
||||
void Matrix3::setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
float c = cosf(angle), s = sinf(angle);
|
||||
// matrix multiplication carried out on paper:
|
||||
// |1 x| |c -s | |sx | | 1 ky | |1 -ox|
|
||||
// | 1 y| |s c | | sy | |kx 1 | | 1 -oy|
|
||||
// | 1| | 1| | 1| | 1| | 1 |
|
||||
// move rotate scale skew origin
|
||||
e[0] = c * sx - ky * s * sy; // = a
|
||||
e[1] = s * sx + ky * c * sy; // = b
|
||||
e[3] = kx * c * sx - s * sy; // = c
|
||||
e[4] = kx * s * sx + c * sy; // = d
|
||||
e[6] = x - ox * e[0] - oy * e[3];
|
||||
e[7] = y - ox * e[1] - oy * e[4];
|
||||
|
||||
e[2] = e[5] = 0.0f;
|
||||
e[8] = 1.0f;
|
||||
}
|
||||
|
||||
} // love
|
||||
|
||||
@@ -185,6 +185,11 @@ public:
|
||||
**/
|
||||
Matrix3(const Matrix4 &mat4);
|
||||
|
||||
/**
|
||||
* Creates a new matrix set to a transformation.
|
||||
**/
|
||||
Matrix3(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||
|
||||
~Matrix3();
|
||||
|
||||
/**
|
||||
@@ -205,6 +210,22 @@ public:
|
||||
**/
|
||||
Matrix3 transposedInverse() const;
|
||||
|
||||
/**
|
||||
* Creates a transformation with a certain position, orientation, scale
|
||||
* and offset.
|
||||
*
|
||||
* @param x The translation along the x-axis.
|
||||
* @param y The translation along the y-axis.
|
||||
* @param angle The rotation (rad) around the center with offset (ox,oy).
|
||||
* @param sx Scale along x-axis.
|
||||
* @param sy Scale along y-axis.
|
||||
* @param ox The offset for rotation along the x-axis.
|
||||
* @param oy The offset for rotation along the y-axis.
|
||||
* @param kx Shear along x-axis
|
||||
* @param ky Shear along y-axis
|
||||
**/
|
||||
void setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||
|
||||
/**
|
||||
* Transforms an array of vertices by this matrix.
|
||||
**/
|
||||
|
||||
Reference in New Issue
Block a user