Carlos Pereira wrote:
>
> In matrix.c, in function gl_rotation_matrix,
> in the very beginning, Mesa 3.2.1 has this code:
> 
> mag = GL_SQRT( x*x + y*y + z*z );
>
> if (mag == 0.0) {
> /* generate an identity matrix and return */
> MEMCPY(m, Identity, sizeof(GLfloat)*16);
> return;
> }
> 
> Basically this checks whether the rotation axis
> is zero or not. Of course it is the user's responsability
> to define correctly the axis...
>
> Anyway, if the rotation axis is very close to zero
> the test fails and strange things start happening
> (this condition may happen when the axis is the vector
> formed by the external product of two vectors forming an
> angle of 0.01 degree or less).
>
> Perhaps the above could be rewritten as:
> _______________________________________
> mag = GL_SQRT( x*x + y*y + z*z );
>
> if (mag < MESA_SAFE_ZERO) {
> /* generate an identity matrix and return */
> MEMCPY(m, Identity, sizeof(GLfloat)*16);
> return;
> }
> _______________________________________
>
> with a #define MESA_SAFE_ZERO set for something as, say, 1.0E4?
OK, I'm about to check in this change for future versions of Mesa.
Thanks.
Brian
