Skip to content

Commit

Permalink
COMMON: Be explicit about memset()ing the Matrix elements
Browse files Browse the repository at this point in the history
Technically, the matrices to be created are non-trivial objects, so
they shouldn't be memset(). We can operate directly on the elements,
though.
  • Loading branch information
DrMcCoy committed May 3, 2018
1 parent 0c883b0 commit c10c42b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/matrix4x4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ void Matrix4x4::lookAt(const Vector3 &v) {
void Matrix4x4::perspective(float fovy, float aspectRatio, float znear, float zfar) {
float xmin, xmax, ymin, ymax;
Matrix4x4 pMatrix(false);
std::memset(&pMatrix, 0, 16 * sizeof(float));
std::memset(pMatrix._elements, 0, 16 * sizeof(float));

ymax = znear * tan(deg2rad(0.5f * fovy));
ymin = -ymax;
Expand All @@ -622,7 +622,7 @@ void Matrix4x4::perspective(float fovy, float aspectRatio, float znear, float zf
void Matrix4x4::ortho(float l, float r, float b, float t, float n, float f)
{
Matrix4x4 mMatrix(false);
std::memset(&mMatrix, 0, 16*sizeof(float));
std::memset(mMatrix._elements, 0, 16*sizeof(float));

mMatrix[0] = 2.0f / (r - l);
mMatrix[5] = 2.0f / (t - b);
Expand Down

0 comments on commit c10c42b

Please sign in to comment.