On 24/02/15 23:30, Brian Paul wrote:
---
src/mesa/main/imports.h | 8 --------
src/mesa/main/light.c | 2 +-
src/mesa/math/m_matrix.c | 4 ++--
3 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 356f0e1..d886427 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -79,14 +79,6 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
-/**********************************************************************
- * Math macros
- */
-
-/* Degrees to radians conversion: */
-#define DEG2RAD (M_PI/180.0)
-
-
#if defined(_MSC_VER)
#if _MSC_VER < 1800 /* Not req'd on VS2013 and above */
#define strtoll(p, e, b) _strtoi64(p, e, b)
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index c4d3a53..4021dbe 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -156,7 +156,7 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum
pname, const GLfloat *pa
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
light->SpotCutoff = params[0];
- light->_CosCutoff = (GLfloat) (cos(light->SpotCutoff * DEG2RAD));
+ light->_CosCutoff = (GLfloat) (cos(light->SpotCutoff * M_PI / 180.0));
It might be worthwhile to add parenthesis around M_PI / 180.0.
I'm not sure the compiler will fold, due to C operator precedence, and
the fact that floating point operations when not being associative:
$ cat deg2rad.c
#include <math.h>
double deg2rad(double angle) {
return angle * M_PI / 180.0;
}
$ gcc -O3 -s -S -o - deg2rad.c
.file "deg2rad.c"
.section .text.unlikely,"ax",@progbits
.LCOLDB2:
.text
.LHOTB2:
.p2align 4,,15
.globl deg2rad
.type deg2rad, @function
deg2rad:
.LFB3:
.cfi_startproc
mulsd .LC0(%rip), %xmm0
divsd .LC1(%rip), %xmm0 <===================================
ret
.cfi_endproc
.LFE3:
.size deg2rad, .-deg2rad
.section .text.unlikely
.LCOLDE2:
.text
.LHOTE2:
.section .rodata.cst8,"aM",@progbits,8
.align 8
.LC0:
.long 1413754136
.long 1074340347
.align 8
.LC1:
.long 0
.long 1080459264
.ident "GCC: (Debian 4.9.1-19) 4.9.1"
.section .note.GNU-stack,"",@progbits
Otherwise series looks good to me.
Jose
if (light->_CosCutoff < 0)
light->_CosCutoff = 0;
if (light->SpotCutoff != 180.0F)
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index 9d51021..0475a7a 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -799,8 +799,8 @@ _math_matrix_rotate( GLmatrix *mat,
GLfloat m[16];
GLboolean optimized;
- s = (GLfloat) sin( angle * DEG2RAD );
- c = (GLfloat) cos( angle * DEG2RAD );
+ s = (GLfloat) sin( angle * M_PI / 180.0 );
+ c = (GLfloat) cos( angle * M_PI / 180.0 );
memcpy(m, Identity, sizeof(GLfloat)*16);
optimized = GL_FALSE;
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev