Skip to content

Commit

Permalink
UPBGE: Optimization in SetViewMatrix about negative scale.
Browse files Browse the repository at this point in the history
  • Loading branch information
panzergame committed Jul 19, 2016
1 parent b585b4a commit 399ffc4
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,16 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
}
}

bool negX = (scale[0] < 0.0f);
bool negY = (scale[1] < 0.0f);
bool negZ = (scale[2] < 0.0f);
if (negX || negY || negZ) {
m_viewmatrix.tscale((negX)?-1.0f:1.0f, (negY)?-1.0f:1.0f, (negZ)?-1.0f:1.0f, 1.0);
// Don't making variable negX/negY/negZ allow drastic time saving.
if (scale[0] < 0.0f || scale[1] < 0.0f || scale[2] < 0.0f) {
const bool negX = (scale[0] < 0.0f);
const bool negY = (scale[1] < 0.0f);
const bool negZ = (scale[2] < 0.0f);
m_viewmatrix.tscale((negX) ? -1.0f : 1.0f, (negY) ? -1.0f : 1.0f, (negZ) ? -1.0f : 1.0f, 1.0f);
m_camnegscale = negX ^ negY ^ negZ;
}
else {
m_camnegscale = false;
}
m_viewinvmatrix = m_viewmatrix;
m_viewinvmatrix.invert();
Expand All @@ -1226,7 +1231,6 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
SetMatrixMode(RAS_MODELVIEW);
LoadMatrix(glviewmat);
m_campos = pos;
m_camnegscale = negX ^ negY ^ negZ;
}

void RAS_OpenGLRasterizer::SetViewport(int x, int y, int width, int height)
Expand Down

0 comments on commit 399ffc4

Please sign in to comment.