From 987aedd7dc75c095a96cb20b21bbad2f71857776 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 12 Feb 2009 09:17:18 -0700 Subject: mesa: move _mesa_transform_vector() from m_xform.c to m_matrix.c m_xform.c is omitted from gallium builds but _mesa_transform_vector() is still needed. --- src/mesa/math/m_matrix.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/mesa/math/m_matrix.c') diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c index 84b4cae4ad..58cae88b08 100644 --- a/src/mesa/math/m_matrix.c +++ b/src/mesa/math/m_matrix.c @@ -1620,3 +1620,24 @@ _math_transposefd( GLfloat to[16], const GLdouble from[16] ) /*@}*/ + +/** + * Transform a 4-element row vector (1x4 matrix) by a 4x4 matrix. This + * function is used for transforming clipping plane equations and spotlight + * directions. + * Mathematically, u = v * m. + * Input: v - input vector + * m - transformation matrix + * Output: u - transformed vector + */ +void +_mesa_transform_vector( GLfloat u[4], const GLfloat v[4], const GLfloat m[16] ) +{ + const GLfloat v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3]; +#define M(row,col) m[row + col*4] + u[0] = v0 * M(0,0) + v1 * M(1,0) + v2 * M(2,0) + v3 * M(3,0); + u[1] = v0 * M(0,1) + v1 * M(1,1) + v2 * M(2,1) + v3 * M(3,1); + u[2] = v0 * M(0,2) + v1 * M(1,2) + v2 * M(2,2) + v3 * M(3,2); + u[3] = v0 * M(0,3) + v1 * M(1,3) + v2 * M(2,3) + v3 * M(3,3); +#undef M +} -- cgit v1.2.3 From ce461ffc5aa2ea6941d6722e8ed473cda8c17833 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 3 Apr 2009 12:49:03 -0600 Subject: mesa: only clear matrix MAT_DIRTY_INVERSE flag when we actually compute the inverse If _math_matrix_analyse() got called before we allocated the inverse matrix array we could lose the flag indicating that we needed to compute the inverse. This could happen with certain vertex shader cases. --- src/mesa/math/m_matrix.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/mesa/math/m_matrix.c') diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c index 58cae88b08..da6956efed 100644 --- a/src/mesa/math/m_matrix.c +++ b/src/mesa/math/m_matrix.c @@ -1379,11 +1379,10 @@ _math_matrix_analyse( GLmatrix *mat ) if (mat->inv && (mat->flags & MAT_DIRTY_INVERSE)) { matrix_invert( mat ); + mat->flags &= ~MAT_DIRTY_INVERSE; } - mat->flags &= ~(MAT_DIRTY_FLAGS| - MAT_DIRTY_TYPE| - MAT_DIRTY_INVERSE); + mat->flags &= ~(MAT_DIRTY_FLAGS | MAT_DIRTY_TYPE); } /*@}*/ -- cgit v1.2.3