Make utils.h self-contained.
[mesa.git] / src / mesa / math / m_norm_tmp.h
index c0d6fac96b36b9e9d9e6e936ba79476521310348..a20cb05017dac337a11e3733910df2b2736702e5 100644 (file)
@@ -1,10 +1,9 @@
-/* $Id: m_norm_tmp.h,v 1.9 2002/01/05 14:12:24 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  4.1
+ * Version:  5.1
  *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * the transformation matrix, rescaling and normalization.
  */
 
-#include <math.h>
-#include "m_vertices.h"
-
-
 /*
  * mat - the 4x4 transformation matrix
  * scale - uniform scale factor of the transformation matrix (not always used)
 static void _XFORMAPI
 TAG(transform_normalize_normals)( const GLmatrix *mat,
                                   GLfloat scale,
-                                  const GLvector3f *in,
+                                  const GLvector4f *in,
                                   const GLfloat *lengths,
-                                  GLvector3f *dest )
+                                  GLvector4f *dest )
 {
-   GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+   GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
    const GLfloat *from = in->start;
    const GLuint stride = in->stride;
    const GLuint count = in->count;
@@ -73,10 +68,10 @@ TAG(transform_normalize_normals)( const GLmatrix *mat,
         {
            GLdouble len = tx*tx + ty*ty + tz*tz;
            if (len > 1e-20) {
-              GLdouble scale = 1.0 / GL_SQRT(len);
-              out[i][0] = (GLfloat) (tx * scale);
-              out[i][1] = (GLfloat) (ty * scale);
-              out[i][2] = (GLfloat) (tz * scale);
+              GLfloat scale = INV_SQRTF(len);
+              out[i][0] = tx * scale;
+              out[i][1] = ty * scale;
+              out[i][2] = tz * scale;
            }
            else {
               out[i][0] = out[i][1] = out[i][2] = 0;
@@ -114,11 +109,11 @@ TAG(transform_normalize_normals)( const GLmatrix *mat,
 static void _XFORMAPI
 TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat,
                                          GLfloat scale,
-                                         const GLvector3f *in,
+                                         const GLvector4f *in,
                                          const GLfloat *lengths,
-                                         GLvector3f *dest )
+                                         GLvector4f *dest )
 {
-   GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+   GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
    const GLfloat *from = in->start;
    const GLuint stride = in->stride;
    const GLuint count = in->count;
@@ -140,10 +135,10 @@ TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat,
         {
            GLdouble len = tx*tx + ty*ty + tz*tz;
            if (len > 1e-20) {
-              GLdouble scale = 1.0 / GL_SQRT(len);
-              out[i][0] = (GLfloat) (tx * scale);
-              out[i][1] = (GLfloat) (ty * scale);
-              out[i][2] = (GLfloat) (tz * scale);
+              GLfloat scale = INV_SQRTF(len);
+              out[i][0] = tx * scale;
+              out[i][1] = ty * scale;
+              out[i][2] = tz * scale;
            }
            else {
               out[i][0] = out[i][1] = out[i][2] = 0;
@@ -179,11 +174,11 @@ TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat,
 static void _XFORMAPI
 TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat,
                                        GLfloat scale,
-                                       const GLvector3f *in,
+                                       const GLvector4f *in,
                                        const GLfloat *lengths,
-                                       GLvector3f *dest )
+                                       GLvector4f *dest )
 {
-   GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+   GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
    const GLfloat *from = in->start;
    const GLuint stride = in->stride;
    const GLuint count = in->count;
@@ -208,11 +203,11 @@ TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat,
 static void _XFORMAPI
 TAG(transform_rescale_normals)( const GLmatrix *mat,
                                 GLfloat scale,
-                                const GLvector3f *in,
+                                const GLvector4f *in,
                                 const GLfloat *lengths,
-                                GLvector3f *dest )
+                                GLvector4f *dest )
 {
-   GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+   GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
    const GLfloat *from = in->start;
    const GLuint stride = in->stride;
    const GLuint count = in->count;
@@ -240,11 +235,11 @@ TAG(transform_rescale_normals)( const GLmatrix *mat,
 static void _XFORMAPI
 TAG(transform_normals_no_rot)( const GLmatrix *mat,
                               GLfloat scale,
-                              const GLvector3f *in,
+                              const GLvector4f *in,
                               const GLfloat *lengths,
-                              GLvector3f *dest )
+                              GLvector4f *dest )
 {
-   GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+   GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
    const GLfloat *from = in->start;
    const GLuint stride = in->stride;
    const GLuint count = in->count;
@@ -270,11 +265,11 @@ TAG(transform_normals_no_rot)( const GLmatrix *mat,
 static void _XFORMAPI
 TAG(transform_normals)( const GLmatrix *mat,
                         GLfloat scale,
-                        const GLvector3f *in,
+                        const GLvector4f *in,
                         const GLfloat *lengths,
-                        GLvector3f *dest )
+                        GLvector4f *dest )
 {
-   GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+   GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
    const GLfloat *from = in->start;
    const GLuint stride = in->stride;
    const GLuint count = in->count;
@@ -300,11 +295,11 @@ TAG(transform_normals)( const GLmatrix *mat,
 static void _XFORMAPI
 TAG(normalize_normals)( const GLmatrix *mat,
                         GLfloat scale,
-                        const GLvector3f *in,
+                        const GLvector4f *in,
                         const GLfloat *lengths,
-                        GLvector3f *dest )
+                        GLvector4f *dest )
 {
-   GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+   GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
    const GLfloat *from = in->start;
    const GLuint stride = in->stride;
    const GLuint count = in->count;
@@ -327,10 +322,10 @@ TAG(normalize_normals)( const GLmatrix *mat,
         const GLfloat x = from[0], y = from[1], z = from[2];
         GLdouble len = x * x + y * y + z * z;
         if (len > 1e-50) {
-           len = 1.0 / GL_SQRT(len);
-           out[i][0] = (GLfloat) (x * len);
-           out[i][1] = (GLfloat) (y * len);
-           out[i][2] = (GLfloat) (z * len);
+           len = INV_SQRTF(len);
+           out[i][0] = (GLfloat)(x * len);
+           out[i][1] = (GLfloat)(y * len);
+           out[i][2] = (GLfloat)(z * len);
         }
         else {
            out[i][0] = x;
@@ -346,11 +341,11 @@ TAG(normalize_normals)( const GLmatrix *mat,
 static void _XFORMAPI
 TAG(rescale_normals)( const GLmatrix *mat,
                       GLfloat scale,
-                      const GLvector3f *in,
+                      const GLvector4f *in,
                       const GLfloat *lengths,
-                      GLvector3f *dest )
+                      GLvector4f *dest )
 {
-   GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+   GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
    const GLfloat *from = in->start;
    const GLuint stride = in->stride;
    const GLuint count = in->count;