[Mesa-dev] [PATCH v1] mesa: rotation of 0-vector

Sergii Romantsov sergii.romantsov at gmail.com
Wed Sep 12 13:30:35 UTC 2018


Specification doesn't define behaviour for rotation of 0-vector.
But khronos.org says that vector has to be normalized.
As workaround assumed that for 0-vector x-position will be
defined as 1.0f.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100960
Signed-off-by: Sergii Romantsov <sergii.romantsov at globallogic.com>
---
 src/mesa/main/matrix.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 8065a83..631b203 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -415,6 +415,11 @@ _mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
 
    FLUSH_VERTICES(ctx, 0);
    if (angle != 0.0F) {
+      /* khronos.org says that ||( x,y,z )|| = 1 (if not, the GL will normalize this vector)
+      * So that is kind of workaround for empty-vectors.
+      * */
+      if (x == 0 && y == 0 && z == 0)
+         x = 1.0f;
       _math_matrix_rotate( ctx->CurrentStack->Top, angle, x, y, z);
       ctx->NewState |= ctx->CurrentStack->DirtyFlag;
    }
-- 
2.7.4



More information about the mesa-dev mailing list