summaryrefslogtreecommitdiffstats
path: root/src/mesa/math
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2000-12-26 05:09:27 +0000
committerKeith Whitwell <[email protected]>2000-12-26 05:09:27 +0000
commitcab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290 (patch)
tree45385bd755d8e3876c54b2b0113636f5ceb7976a /src/mesa/math
parentd1ff1f6798b003a820f5de9fad835ff352f31afe (diff)
Major rework of tnl module
New array_cache module Support 8 texture units in core mesa (now support 8 everywhere) Rework core mesa statechange operations to avoid flushing on many noop statechanges.
Diffstat (limited to 'src/mesa/math')
-rw-r--r--src/mesa/math/m_clip_tmp.h12
-rw-r--r--src/mesa/math/m_copy_tmp.h37
-rw-r--r--src/mesa/math/m_dotprod_tmp.h42
-rw-r--r--src/mesa/math/m_eval.c501
-rw-r--r--src/mesa/math/m_eval.h79
-rw-r--r--src/mesa/math/m_translate.c130
-rw-r--r--src/mesa/math/m_translate.h106
-rw-r--r--src/mesa/math/m_vector.c26
-rw-r--r--src/mesa/math/m_vector.h13
-rw-r--r--src/mesa/math/m_xform.c4
-rw-r--r--src/mesa/math/m_xform.h68
-rw-r--r--src/mesa/math/m_xform_tmp.h7
12 files changed, 821 insertions, 204 deletions
diff --git a/src/mesa/math/m_clip_tmp.h b/src/mesa/math/m_clip_tmp.h
index 321d3a9e616..d977698da57 100644
--- a/src/mesa/math/m_clip_tmp.h
+++ b/src/mesa/math/m_clip_tmp.h
@@ -1,4 +1,4 @@
-/* $Id: m_clip_tmp.h,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
+/* $Id: m_clip_tmp.h,v 1.2 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -78,16 +78,16 @@ static GLvector4f * _XFORMAPI TAG(cliptest_points4)( GLvector4f *clip_vec,
c++;
tmpAndMask &= mask;
tmpOrMask |= mask;
- vProj[i][0] = 0; /* no longer required? */
+ vProj[i][0] = 0;
vProj[i][1] = 0;
vProj[i][2] = 0;
vProj[i][3] = 1;
} else {
GLfloat oow = 1.0F / cw;
- vProj[i][3] = oow;
vProj[i][0] = cx * oow;
vProj[i][1] = cy * oow;
vProj[i][2] = cz * oow;
+ vProj[i][3] = oow;
}
}
@@ -95,7 +95,7 @@ static GLvector4f * _XFORMAPI TAG(cliptest_points4)( GLvector4f *clip_vec,
*andMask = (GLubyte) (c < count ? 0 : tmpAndMask);
proj_vec->flags |= VEC_SIZE_4;
- proj_vec->size = 3;
+ proj_vec->size = 4;
proj_vec->count = clip_vec->count;
return proj_vec;
}
@@ -127,8 +127,6 @@ static GLvector4f * _XFORMAPI TAG(cliptest_points3)( GLvector4f *clip_vec,
tmpAndMask &= mask;
}
- gl_vector4f_clean_elem(proj_vec, count, 3);
-
*orMask = tmpOrMask;
*andMask = tmpAndMask;
return clip_vec;
@@ -159,8 +157,6 @@ static GLvector4f * _XFORMAPI TAG(cliptest_points2)( GLvector4f *clip_vec,
tmpAndMask &= mask;
}
- gl_vector4f_clean_elem(proj_vec, count, 3);
-
*orMask = tmpOrMask;
*andMask = tmpAndMask;
return clip_vec;
diff --git a/src/mesa/math/m_copy_tmp.h b/src/mesa/math/m_copy_tmp.h
index b328537fafa..3119b95589b 100644
--- a/src/mesa/math/m_copy_tmp.h
+++ b/src/mesa/math/m_copy_tmp.h
@@ -1,4 +1,4 @@
-/* $Id: m_copy_tmp.h,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
+/* $Id: m_copy_tmp.h,v 1.2 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -51,24 +51,6 @@ static void TAG2(copy, BITS)(GLvector4f *to, const GLvector4f *f, \
} \
}
-
-
-/* static void TAG2(clean, BITS)(GLvector4f *to ) */
-/* { */
-/* GLfloat (*t)[4] = to->data; */
-/* GLuint i; */
-
-/* if (BITS) */
-/* for (i = 0 ; i < VB_SIZE ; i++) { */
-/* if (BITS&1) t[i][0] = 0; */
-/* if (BITS&2) t[i][1] = 0; */
-/* if (BITS&4) t[i][2] = 0; */
-/* if (BITS&8) t[i][3] = 1; */
-/* } */
-/* to->flags &= ~BITS; */
-/* } */
-
-
/* We got them all here:
*/
COPY_FUNC( 0x0 ) /* noop */
@@ -106,21 +88,4 @@ static void TAG2(init_copy, 0 ) ( void )
gl_copy_tab[IDX][0xd] = TAG2(copy, 0xd);
gl_copy_tab[IDX][0xe] = TAG2(copy, 0xe);
gl_copy_tab[IDX][0xf] = TAG2(copy, 0xf);
-
-/* gl_clean_tab[IDX][0x0] = TAG2(clean, 0x0); */
-/* gl_clean_tab[IDX][0x1] = TAG2(clean, 0x1); */
-/* gl_clean_tab[IDX][0x2] = TAG2(clean, 0x2); */
-/* gl_clean_tab[IDX][0x3] = TAG2(clean, 0x3); */
-/* gl_clean_tab[IDX][0x4] = TAG2(clean, 0x4); */
-/* gl_clean_tab[IDX][0x5] = TAG2(clean, 0x5); */
-/* gl_clean_tab[IDX][0x6] = TAG2(clean, 0x6); */
-/* gl_clean_tab[IDX][0x7] = TAG2(clean, 0x7); */
-/* gl_clean_tab[IDX][0x8] = TAG2(clean, 0x8); */
-/* gl_clean_tab[IDX][0x9] = TAG2(clean, 0x9); */
-/* gl_clean_tab[IDX][0xa] = TAG2(clean, 0xa); */
-/* gl_clean_tab[IDX][0xb] = TAG2(clean, 0xb); */
-/* gl_clean_tab[IDX][0xc] = TAG2(clean, 0xc); */
-/* gl_clean_tab[IDX][0xd] = TAG2(clean, 0xd); */
-/* gl_clean_tab[IDX][0xe] = TAG2(clean, 0xe); */
-/* gl_clean_tab[IDX][0xf] = TAG2(clean, 0xf); */
}
diff --git a/src/mesa/math/m_dotprod_tmp.h b/src/mesa/math/m_dotprod_tmp.h
index 637e35fd587..4bd875c6813 100644
--- a/src/mesa/math/m_dotprod_tmp.h
+++ b/src/mesa/math/m_dotprod_tmp.h
@@ -1,4 +1,4 @@
-/* $Id: m_dotprod_tmp.h,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
+/* $Id: m_dotprod_tmp.h,v 1.2 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,18 +31,16 @@
/* Note - respects the stride of the output vector.
*/
-static void TAG(dotprod_vec2)( GLvector4f *out_vec,
- GLuint elt,
- const GLvector4f *coord_vec,
- const GLfloat plane[4],
- const GLubyte mask[])
+static void TAG(dotprod_vec2)( GLfloat *out,
+ GLuint outstride,
+ const GLvector4f *coord_vec,
+ const GLfloat plane[4],
+ const GLubyte mask[])
{
GLuint stride = coord_vec->stride;
GLfloat *coord = coord_vec->start;
GLuint count = coord_vec->count;
- GLuint outstride = out_vec->stride;
- GLfloat *out = out_vec->start + elt;
GLuint i;
const GLfloat plane0 = plane[0], plane1 = plane[1], plane3 = plane[3];
@@ -56,21 +54,18 @@ static void TAG(dotprod_vec2)( GLvector4f *out_vec,
plane3);
}
}
- out_vec->count = coord_vec->count;
}
-static void TAG(dotprod_vec3)( GLvector4f *out_vec,
- GLuint elt,
- const GLvector4f *coord_vec,
- const GLfloat plane[4],
- const GLubyte mask[])
+static void TAG(dotprod_vec3)( GLfloat *out,
+ GLuint outstride,
+ const GLvector4f *coord_vec,
+ const GLfloat plane[4],
+ const GLubyte mask[])
{
GLuint stride = coord_vec->stride;
GLfloat *coord = coord_vec->start;
GLuint count = coord_vec->count;
- GLuint outstride = out_vec->stride;
- GLfloat *out = out_vec->start + elt;
GLuint i;
const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2];
@@ -86,21 +81,17 @@ static void TAG(dotprod_vec3)( GLvector4f *out_vec,
plane3);
}
}
- out_vec->count = coord_vec->count;
}
-static void TAG(dotprod_vec4)( GLvector4f *out_vec,
- GLuint elt,
- const GLvector4f *coord_vec,
- const GLfloat plane[4],
- const GLubyte mask[])
+static void TAG(dotprod_vec4)( GLfloat *out,
+ GLuint outstride,
+ const GLvector4f *coord_vec,
+ const GLfloat plane[4],
+ const GLubyte mask[])
{
GLuint stride = coord_vec->stride;
GLfloat *coord = coord_vec->start;
GLuint count = coord_vec->count;
-
- GLuint outstride = out_vec->stride;
- GLfloat *out = out_vec->start + elt;
GLuint i;
const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2];
@@ -116,7 +107,6 @@ static void TAG(dotprod_vec4)( GLvector4f *out_vec,
coord[3] * plane3);
}
}
- out_vec->count = coord_vec->count;
}
diff --git a/src/mesa/math/m_eval.c b/src/mesa/math/m_eval.c
new file mode 100644
index 00000000000..a4ae0395cad
--- /dev/null
+++ b/src/mesa/math/m_eval.c
@@ -0,0 +1,501 @@
+/* $Id: m_eval.c,v 1.1 2000/12/26 05:09:31 keithw Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2000 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * eval.c was written by
+ * Bernd Barsuhn ([email protected]) and
+ * Volker Weiss ([email protected]).
+ *
+ * My original implementation of evaluators was simplistic and didn't
+ * compute surface normal vectors properly. Bernd and Volker applied
+ * used more sophisticated methods to get better results.
+ *
+ * Thanks guys!
+ */
+
+
+#include "glheader.h"
+#include "config.h"
+#include "m_eval.h"
+
+static GLfloat inv_tab[MAX_EVAL_ORDER];
+
+
+
+/*
+ * Horner scheme for Bezier curves
+ *
+ * Bezier curves can be computed via a Horner scheme.
+ * Horner is numerically less stable than the de Casteljau
+ * algorithm, but it is faster. For curves of degree n
+ * the complexity of Horner is O(n) and de Casteljau is O(n^2).
+ * Since stability is not important for displaying curve
+ * points I decided to use the Horner scheme.
+ *
+ * A cubic Bezier curve with control points b0, b1, b2, b3 can be
+ * written as
+ *
+ * (([3] [3] ) [3] ) [3]
+ * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3
+ *
+ * [n]
+ * where s=1-t and the binomial coefficients [i]. These can
+ * be computed iteratively using the identity:
+ *
+ * [n] [n ] [n]
+ * [i] = (n-i+1)/i * [i-1] and [0] = 1
+ */
+
+
+void
+_math_horner_bezier_curve(const GLfloat *cp, GLfloat *out, GLfloat t,
+ GLuint dim, GLuint order)
+{
+ GLfloat s, powert;
+ GLuint i, k, bincoeff;
+
+ if(order >= 2)
+ {
+ bincoeff = order-1;
+ s = 1.0-t;
+
+ for(k=0; k<dim; k++)
+ out[k] = s*cp[k] + bincoeff*t*cp[dim+k];
+
+ for(i=2, cp+=2*dim, powert=t*t; i<order; i++, powert*=t, cp +=dim)
+ {
+ bincoeff *= order-i;
+ bincoeff *= inv_tab[i];
+
+ for(k=0; k<dim; k++)
+ out[k] = s*out[k] + bincoeff*powert*cp[k];
+ }
+ }
+ else /* order=1 -> constant curve */
+ {
+ for(k=0; k<dim; k++)
+ out[k] = cp[k];
+ }
+}
+
+/*
+ * Tensor product Bezier surfaces
+ *
+ * Again the Horner scheme is used to compute a point on a
+ * TP Bezier surface. First a control polygon for a curve
+ * on the surface in one parameter direction is computed,
+ * then the point on the curve for the other parameter
+ * direction is evaluated.
+ *
+ * To store the curve control polygon additional storage
+ * for max(uorder,vorder) points is needed in the
+ * control net cn.
+ */
+
+void
+_math_horner_bezier_surf(GLfloat *cn, GLfloat *out, GLfloat u, GLfloat v,
+ GLuint dim, GLuint uorder, GLuint vorder)
+{
+ GLfloat *cp = cn + uorder*vorder*dim;
+ GLuint i, uinc = vorder*dim;
+
+ if(vorder > uorder)
+ {
+ if(uorder >= 2)
+ {
+ GLfloat s, poweru;
+ GLuint j, k, bincoeff;
+
+ /* Compute the control polygon for the surface-curve in u-direction */
+ for(j=0; j<vorder; j++)
+ {
+ GLfloat *ucp = &cn[j*dim];
+
+ /* Each control point is the point for parameter u on a */
+ /* curve defined by the control polygons in u-direction */
+ bincoeff = uorder-1;
+ s = 1.0-u;
+
+ for(k=0; k<dim; k++)
+ cp[j*dim+k] = s*ucp[k] + bincoeff*u*ucp[uinc+k];
+
+ for(i=2, ucp+=2*uinc, poweru=u*u; i<uorder;
+ i++, poweru*=u, ucp +=uinc)
+ {
+ bincoeff *= uorder-i;
+ bincoeff *= inv_tab[i];
+
+ for(k=0; k<dim; k++)
+ cp[j*dim+k] = s*cp[j*dim+k] + bincoeff*poweru*ucp[k];
+ }
+ }
+
+ /* Evaluate curve point in v */
+ _math_horner_bezier_curve(cp, out, v, dim, vorder);
+ }
+ else /* uorder=1 -> cn defines a curve in v */
+ _math_horner_bezier_curve(cn, out, v, dim, vorder);
+ }
+ else /* vorder <= uorder */
+ {
+ if(vorder > 1)
+ {
+ GLuint i;
+
+ /* Compute the control polygon for the surface-curve in u-direction */
+ for(i=0; i<uorder; i++, cn += uinc)
+ {
+ /* For constant i all cn[i][j] (j=0..vorder) are located */
+ /* on consecutive memory locations, so we can use */
+ /* horner_bezier_curve to compute the control points */
+
+ _math_horner_bezier_curve(cn, &cp[i*dim], v, dim, vorder);
+ }
+
+ /* Evaluate curve point in u */
+ _math_horner_bezier_curve(cp, out, u, dim, uorder);
+ }
+ else /* vorder=1 -> cn defines a curve in u */
+ _math_horner_bezier_curve(cn, out, u, dim, uorder);
+ }
+}
+
+/*
+ * The direct de Casteljau algorithm is used when a point on the
+ * surface and the tangent directions spanning the tangent plane
+ * should be computed (this is needed to compute normals to the
+ * surface). In this case the de Casteljau algorithm approach is
+ * nicer because a point and the partial derivatives can be computed
+ * at the same time. To get the correct tangent length du and dv
+ * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1.
+ * Since only the directions are needed, this scaling step is omitted.
+ *
+ * De Casteljau needs additional storage for uorder*vorder
+ * values in the control net cn.
+ */
+
+void
+_math_de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv,
+ GLfloat u, GLfloat v, GLuint dim,
+ GLuint uorder, GLuint vorder)
+{
+ GLfloat *dcn = cn + uorder*vorder*dim;
+ GLfloat us = 1.0-u, vs = 1.0-v;
+ GLuint h, i, j, k;
+ GLuint minorder = uorder < vorder ? uorder : vorder;
+ GLuint uinc = vorder*dim;
+ GLuint dcuinc = vorder;
+
+ /* Each component is evaluated separately to save buffer space */
+ /* This does not drasticaly decrease the performance of the */
+ /* algorithm. If additional storage for (uorder-1)*(vorder-1) */
+ /* points would be available, the components could be accessed */
+ /* in the innermost loop which could lead to less cache misses. */
+
+#define CN(I,J,K) cn[(I)*uinc+(J)*dim+(K)]
+#define DCN(I, J) dcn[(I)*dcuinc+(J)]
+ if(minorder < 3)
+ {
+ if(uorder==vorder)
+ {
+ for(k=0; k<dim; k++)
+ {
+ /* Derivative direction in u */
+ du[k] = vs*(CN(1,0,k) - CN(0,0,k)) +
+ v*(CN(1,1,k) - CN(0,1,k));
+
+ /* Derivative direction in v */
+ dv[k] = us*(CN(0,1,k) - CN(0,0,k)) +
+ u*(CN(1,1,k) - CN(1,0,k));
+
+ /* bilinear de Casteljau step */
+ out[k] = us*(vs*CN(0,0,k) + v*CN(0,1,k)) +
+ u*(vs*CN(1,0,k) + v*CN(1,1,k));
+ }
+ }
+ else if(minorder == uorder)
+ {
+ for(k=0; k<dim; k++)
+ {
+ /* bilinear de Casteljau step */
+ DCN(1,0) = CN(1,0,k) - CN(0,0,k);
+ DCN(0,0) = us*CN(0,0,k) + u*CN(1,0,k);
+
+ for(j=0; j<vorder-1; j++)
+ {
+ /* for the derivative in u */
+ DCN(1,j+1) = CN(1,j+1,k) - CN(0,j+1,k);
+ DCN(1,j) = vs*DCN(1,j) + v*DCN(1,j+1);
+
+ /* for the `point' */
+ DCN(0,j+1) = us*CN(0,j+1,k) + u*CN(1,j+1,k);
+ DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
+ }
+
+ /* remaining linear de Casteljau steps until the second last step */
+ for(h=minorder; h<vorder-1; h++)
+ for(j=0; j<vorder-h; j++)
+ {
+ /* for the derivative in u */
+ DCN(1,j) = vs*DCN(1,j) + v*DCN(1,j+1);
+
+ /* for the `point' */
+ DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
+ }
+
+ /* derivative direction in v */
+ dv[k] = DCN(0,1) - DCN(0,0);
+
+ /* derivative direction in u */
+ du[k] = vs*DCN(1,0) + v*DCN(1,1);
+
+ /* last linear de Casteljau step */
+ out[k] = vs*DCN(0,0) + v*DCN(0,1);
+ }
+ }
+ else /* minorder == vorder */
+ {
+ for(k=0; k<dim; k++)
+ {
+ /* bilinear de Casteljau step */
+ DCN(0,1) = CN(0,1,k) - CN(0,0,k);
+ DCN(0,0) = vs*CN(0,0,k) + v*CN(0,1,k);
+ for(i=0; i<uorder-1; i++)
+ {
+ /* for the derivative in v */
+ DCN(i+1,1) = CN(i+1,1,k) - CN(i+1,0,k);
+ DCN(i,1) = us*DCN(i,1) + u*DCN(i+1,1);
+
+ /* for the `point' */
+ DCN(i+1,0) = vs*CN(i+1,0,k) + v*CN(i+1,1,k);
+ DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
+ }
+
+ /* remaining linear de Casteljau steps until the second last step */
+ for(h=minorder; h<uorder-1; h++)
+ for(i=0; i<uorder-h; i++)
+ {
+ /* for the derivative in v */
+ DCN(i,1) = us*DCN(i,1) + u*DCN(i+1,1);
+
+ /* for the `point' */
+ DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
+ }
+
+ /* derivative direction in u */
+ du[k] = DCN(1,0) - DCN(0,0);
+
+ /* derivative direction in v */
+ dv[k] = us*DCN(0,1) + u*DCN(1,1);
+
+ /* last linear de Casteljau step */
+ out[k] = us*DCN(0,0) + u*DCN(1,0);
+ }
+ }
+ }
+ else if(uorder == vorder)
+ {
+ for(k=0; k<dim; k++)
+ {
+ /* first bilinear de Casteljau step */
+ for(i=0; i<uorder-1; i++)
+ {
+ DCN(i,0) = us*CN(i,0,k) + u*CN(i+1,0,k);
+ for(j=0; j<vorder-1; j++)
+ {
+ DCN(i,j+1) = us*CN(i,j+1,k) + u*CN(i+1,j+1,k);
+ DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
+ }
+ }
+
+ /* remaining bilinear de Casteljau steps until the second last step */
+ for(h=2; h<minorder-1; h++)
+ for(i=0; i<uorder-h; i++)
+ {
+ DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
+ for(j=0; j<vorder-h; j++)
+ {
+ DCN(i,j+1) = us*DCN(i,j+1) + u*DCN(i+1,j+1);
+ DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
+ }
+ }
+
+ /* derivative direction in u */
+ du[k] = vs*(DCN(1,0) - DCN(0,0)) +
+ v*(DCN(1,1) - DCN(0,1));
+
+ /* derivative direction in v */
+ dv[k] = us*(DCN(0,1) - DCN(0,0)) +
+ u*(DCN(1,1) - DCN(1,0));
+
+ /* last bilinear de Casteljau step */
+ out[k] = us*(vs*DCN(0,0) + v*DCN(0,1)) +
+ u*(vs*DCN(1,0) + v*DCN(1,1));
+ }
+ }
+ else if(minorder == uorder)
+ {
+ for(k=0; k<dim; k++)
+ {
+ /* first bilinear de Casteljau step */
+ for(i=0; i<uorder-1; i++)
+ {
+ DCN(i,0) = us*CN(i,0,k) + u*CN(i+1,0,k);
+ for(j=0; j<vorder-1; j++)
+ {
+ DCN(i,j+1) = us*CN(i,j+1,k) + u*CN(i+1,j+1,k);
+ DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
+ }
+ }
+
+ /* remaining bilinear de Casteljau steps until the second last step */
+ for(h=2; h<minorder-1; h++)
+ for(i=0; i<uorder-h; i++)
+ {
+ DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
+ for(j=0; j<vorder-h; j++)
+ {
+ DCN(i,j+1) = us*DCN(i,j+1) + u*DCN(i+1,j+1);
+ DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
+ }
+ }
+
+ /* last bilinear de Casteljau step */
+ DCN(2,0) = DCN(1,0) - DCN(0,0);
+ DCN(0,0) = us*DCN(0,0) + u*DCN(1,0);
+ for(j=0; j<vorder-1; j++)
+ {
+ /* for the derivative in u */
+ DCN(2,j+1) = DCN(1,j+1) - DCN(0,j+1);
+ DCN(2,j) = vs*DCN(2,j) + v*DCN(2,j+1);
+
+ /* for the `point' */
+ DCN(0,j+1) = us*DCN(0,j+1 ) + u*DCN(1,j+1);
+ DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
+ }
+
+ /* remaining linear de Casteljau steps until the second last step */
+ for(h=minorder; h<vorder-1; h++)
+ for(j=0; j<vorder-h; j++)
+ {
+ /* for the derivative in u */
+ DCN(2,j) = vs*DCN(2,j) + v*DCN(2,j+1);
+
+ /* for the `point' */
+ DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
+ }
+
+ /* derivative direction in v */
+ dv[k] = DCN(0,1) - DCN(0,0);
+
+ /* derivative direction in u */
+ du[k] = vs*DCN(2,0) + v*DCN(2,1);
+
+ /* last linear de Casteljau step */
+ out[k] = vs*DCN(0,0) + v*DCN(0,1);
+ }
+ }
+ else /* minorder == vorder */
+ {
+ for(k=0; k<dim; k++)
+ {
+ /* first bilinear de Casteljau step */
+ for(i=0; i<uorder-1; i++)
+ {
+ DCN(i,0) = us*CN(i,0,k) + u*CN(i+1,0,k);
+ for(j=0; j<vorder-1; j++)
+ {
+ DCN(i,j+1) = us*CN(i,j+1,k) + u*CN(i+1,j+1,k);
+ DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
+ }
+ }
+
+ /* remaining bilinear de Casteljau steps until the second last step */
+ for(h=2; h<minorder-1; h++)
+ for(i=0; i<uorder-h; i++)
+ {
+ DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
+ for(j=0; j<vorder-h; j++)
+ {
+ DCN(i,j+1) = us*DCN(i,j+1) + u*DCN(i+1,j+1);
+ DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
+ }
+ }
+
+ /* last bilinear de Casteljau step */
+ DCN(0,2) = DCN(0,1) - DCN(0,0);
+ DCN(0,0) = vs*DCN(0,0) + v*DCN(0,1);
+ for(i=0; i<uorder-1; i++)
+ {
+ /* for the derivative in v */
+ DCN(i+1,2) = DCN(i+1,1) - DCN(i+1,0);
+ DCN(i,2) = us*DCN(i,2) + u*DCN(i+1,2);
+
+ /* for the `point' */
+ DCN(i+1,0) = vs*DCN(i+1,0) + v*DCN(i+1,1);
+ DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
+ }
+
+ /* remaining linear de Casteljau steps until the second last step */
+ for(h=minorder; h<uorder-1; h++)
+ for(i=0; i<uorder-h; i++)
+ {
+ /* for the derivative in v */
+ DCN(i,2) = us*DCN(i,2) + u*DCN(i+1,2);
+
+ /* for the `point' */
+ DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
+ }
+
+ /* derivative direction in u */
+ du[k] = DCN(1,0) - DCN(0,0);
+
+ /* derivative direction in v */
+ dv[k] = us*DCN(0,2) + u*DCN(1,2);
+
+ /* last linear de Casteljau step */
+ out[k] = us*DCN(0,0) + u*DCN(1,0);
+ }
+ }
+#undef DCN
+#undef CN
+}
+
+
+/*
+ * Do one-time initialization for evaluators.
+ */
+void _math_init_eval( void )
+{
+ GLuint i;
+
+ /* KW: precompute 1/x for useful x.
+ */
+ for (i = 1 ; i < MAX_EVAL_ORDER ; i++)
+ inv_tab[i] = 1.0 / i;
+}
+
diff --git a/src/mesa/math/m_eval.h b/src/mesa/math/m_eval.h
new file mode 100644
index 00000000000..b478b39351e
--- /dev/null
+++ b/src/mesa/math/m_eval.h
@@ -0,0 +1,79 @@
+
+#ifndef _M_EVAL_H
+#define _M_EVAL_H
+
+#include "glheader.h"
+
+void _math_init_eval( void );
+
+
+/*
+ * Horner scheme for Bezier curves
+ *
+ * Bezier curves can be computed via a Horner scheme.
+ * Horner is numerically less stable than the de Casteljau
+ * algorithm, but it is faster. For curves of degree n
+ * the complexity of Horner is O(n) and de Casteljau is O(n^2).
+ * Since stability is not important for displaying curve
+ * points I decided to use the Horner scheme.
+ *
+ * A cubic Bezier curve with control points b0, b1, b2, b3 can be
+ * written as
+ *
+ * (([3] [3] ) [3] ) [3]
+ * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3
+ *
+ * [n]
+ * where s=1-t and the binomial coefficients [i]. These can
+ * be computed iteratively using the identity:
+ *
+ * [n] [n ] [n]
+ * [i] = (n-i+1)/i * [i-1] and [0] = 1
+ */
+
+
+void
+_math_horner_bezier_curve(const GLfloat *cp, GLfloat *out, GLfloat t,
+ GLuint dim, GLuint order);
+
+
+/*
+ * Tensor product Bezier surfaces
+ *
+ * Again the Horner scheme is used to compute a point on a
+ * TP Bezier surface. First a control polygon for a curve
+ * on the surface in one parameter direction is computed,
+ * then the point on the curve for the other parameter
+ * direction is evaluated.
+ *
+ * To store the curve control polygon additional storage
+ * for max(uorder,vorder) points is needed in the
+ * control net cn.
+ */
+
+void
+_math_horner_bezier_surf(GLfloat *cn, GLfloat *out, GLfloat u, GLfloat v,
+ GLuint dim, GLuint uorder, GLuint vorder);
+
+
+/*
+ * The direct de Casteljau algorithm is used when a point on the
+ * surface and the tangent directions spanning the tangent plane
+ * should be computed (this is needed to compute normals to the
+ * surface). In this case the de Casteljau algorithm approach is
+ * nicer because a point and the partial derivatives can be computed
+ * at the same time. To get the correct tangent length du and dv
+ * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1.
+ * Since only the directions are needed, this scaling step is omitted.
+ *
+ * De Casteljau needs additional storage for uorder*vorder
+ * values in the control net cn.
+ */
+
+void
+_math_de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv,
+ GLfloat u, GLfloat v, GLuint dim,
+ GLuint uorder, GLuint vorder);
+
+
+#endif
diff --git a/src/mesa/math/m_translate.c b/src/mesa/math/m_translate.c
index 945e35706c4..1a0804ab60a 100644
--- a/src/mesa/math/m_translate.c
+++ b/src/mesa/math/m_translate.c
@@ -1,4 +1,4 @@
-/* $Id: m_translate.c,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
+/* $Id: m_translate.c,v 1.2 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -36,22 +36,67 @@
#include "m_translate.h"
+
+
+typedef void (*trans_1f_func)(GLfloat *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_1ui_func)(GLuint *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_1ub_func)(GLubyte *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_4ub_func)(GLubyte (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_4f_func)(GLfloat (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_3f_func)(GLfloat (*to)[3],
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+
+
+
+#define TYPE_IDX(t) ((t) & 0xf)
+#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
+
+
/* This macro is used on other systems, so undefine it for this module */
#undef CHECK
-trans_1f_func gl_trans_1f_tab[MAX_TYPES];
-trans_1ui_func gl_trans_1ui_tab[MAX_TYPES];
-trans_1ub_func gl_trans_1ub_tab[MAX_TYPES];
-trans_3f_func gl_trans_3f_tab[MAX_TYPES];
-trans_4ub_func gl_trans_4ub_tab[5][MAX_TYPES];
-trans_4f_func gl_trans_4f_tab[5][MAX_TYPES];
+static trans_1f_func _math_trans_1f_tab[MAX_TYPES];
+static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES];
+static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES];
+static trans_3f_func _math_trans_3f_tab[MAX_TYPES];
+static trans_4ub_func _math_trans_4ub_tab[5][MAX_TYPES];
+static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES];
#define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt])
-#define TAB(x) gl_trans##x##_tab
+#define TAB(x) _math_trans##x##_tab
#define ARGS GLuint start, GLuint n
#define SRC_START start
#define DST_START 0
@@ -471,8 +516,73 @@ static void init_translate_raw(void)
-void
-_math_init_translate( void )
+void _math_init_translate( void )
{
init_translate_raw();
}
+
+
+
+void _math_trans_1f(GLfloat *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_1f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_1ui(GLuint *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_1ui_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_1ub(GLubyte *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_1ub_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+
+void _math_trans_4ub(GLubyte (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_4f(GLfloat (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_4f_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_3f(GLfloat (*to)[3],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_3f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
diff --git a/src/mesa/math/m_translate.h b/src/mesa/math/m_translate.h
index a109dfa721b..b6db1f60480 100644
--- a/src/mesa/math/m_translate.h
+++ b/src/mesa/math/m_translate.h
@@ -1,4 +1,4 @@
-/* $Id: m_translate.h,v 1.2 2000/11/17 21:01:49 brianp Exp $ */
+/* $Id: m_translate.h,v 1.3 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,66 +31,52 @@
#include "config.h"
-typedef void (*trans_1f_func)(GLfloat *to,
- CONST void *ptr,
- GLuint stride,
- GLuint start,
- GLuint n );
-typedef void (*trans_1ui_func)(GLuint *to,
- CONST void *ptr,
- GLuint stride,
- GLuint start,
- GLuint n );
-
-typedef void (*trans_1ub_func)(GLubyte *to,
- CONST void *ptr,
- GLuint stride,
- GLuint start,
- GLuint n );
-
-typedef void (*trans_4ub_func)(GLubyte (*to)[4],
- CONST void *ptr,
- GLuint stride,
- GLuint start,
- GLuint n );
-
-typedef void (*trans_4f_func)(GLfloat (*to)[4],
- CONST void *ptr,
- GLuint stride,
- GLuint start,
- GLuint n );
-
-typedef void (*trans_3f_func)(GLfloat (*to)[3],
- CONST void *ptr,
- GLuint stride,
- GLuint start,
- GLuint n );
-
-
-
-
-/* Translate GL_UNSIGNED_BYTE, etc to the indexes used in the arrays
- * below.
- */
-#define TYPE_IDX(t) ((t) & 0xf)
-
-#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
-
-/* Only useful combinations are defined, thus there is no function to
- * translate eg, ubyte->float or ubyte->ubyte, which are never used.
- */
-extern trans_1f_func gl_trans_1f_tab[MAX_TYPES];
-extern trans_1ui_func gl_trans_1ui_tab[MAX_TYPES];
-extern trans_1ub_func gl_trans_1ub_tab[MAX_TYPES];
-extern trans_3f_func gl_trans_3f_tab[MAX_TYPES];
-extern trans_4ub_func gl_trans_4ub_tab[5][MAX_TYPES];
-extern trans_4f_func gl_trans_4f_tab[5][MAX_TYPES];
-
-
-
-extern void
-_math_init_translate( void );
+extern void _math_trans_1f(GLfloat *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_1ui(GLuint *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_1ub(GLubyte *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_4ub(GLubyte (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_4f(GLfloat (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_3f(GLfloat (*to)[3],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n );
+
+extern void _math_init_translate( void );
#endif
diff --git a/src/mesa/math/m_vector.c b/src/mesa/math/m_vector.c
index 4dbf68f8e0f..e582ccce37e 100644
--- a/src/mesa/math/m_vector.c
+++ b/src/mesa/math/m_vector.c
@@ -1,4 +1,4 @@
-/* $Id: m_vector.c,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
+/* $Id: m_vector.c,v 1.2 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -85,7 +85,7 @@ void gl_vector4f_init( GLvector4f *v, GLuint flags, GLfloat (*storage)[4] )
v->data = storage;
v->start = (GLfloat *) storage;
v->count = 0;
- v->flags = size_bits[4] | flags | VEC_GOOD_STRIDE;
+ v->flags = size_bits[4] | flags ;
}
void gl_vector3f_init( GLvector3f *v, GLuint flags, GLfloat (*storage)[3] )
@@ -94,7 +94,7 @@ void gl_vector3f_init( GLvector3f *v, GLuint flags, GLfloat (*storage)[3] )
v->data = storage;
v->start = (GLfloat *) storage;
v->count = 0;
- v->flags = flags | VEC_GOOD_STRIDE;
+ v->flags = flags ;
}
void gl_vector1f_init( GLvector1f *v, GLuint flags, GLfloat *storage )
@@ -103,7 +103,7 @@ void gl_vector1f_init( GLvector1f *v, GLuint flags, GLfloat *storage )
v->data = storage;
v->start = (GLfloat *)storage;
v->count = 0;
- v->flags = flags | VEC_GOOD_STRIDE;
+ v->flags = flags ;
}
void gl_vector4ub_init( GLvector4ub *v, GLuint flags, GLubyte (*storage)[4] )
@@ -112,7 +112,7 @@ void gl_vector4ub_init( GLvector4ub *v, GLuint flags, GLubyte (*storage)[4] )
v->data = storage;
v->start = (GLubyte *) storage;
v->count = 0;
- v->flags = flags | VEC_GOOD_STRIDE;
+ v->flags = flags ;
}
void gl_vector1ub_init( GLvector1ub *v, GLuint flags, GLubyte *storage )
@@ -121,7 +121,7 @@ void gl_vector1ub_init( GLvector1ub *v, GLuint flags, GLubyte *storage )
v->data = storage;
v->start = (GLubyte *) storage;
v->count = 0;
- v->flags = flags | VEC_GOOD_STRIDE;
+ v->flags = flags ;
}
void gl_vector1ui_init( GLvector1ui *v, GLuint flags, GLuint *storage )
@@ -130,7 +130,7 @@ void gl_vector1ui_init( GLvector1ui *v, GLuint flags, GLuint *storage )
v->data = storage;
v->start = (GLuint *) storage;
v->count = 0;
- v->flags = flags | VEC_GOOD_STRIDE;
+ v->flags = flags ;
}
@@ -153,7 +153,7 @@ void gl_vector4f_alloc( GLvector4f *v, GLuint flags, GLuint count,
v->start = (GLfloat *) v->storage;
v->data = (GLfloat (*)[4]) v->storage;
v->count = 0;
- v->flags = size_bits[4] | flags | VEC_MALLOC | VEC_GOOD_STRIDE;
+ v->flags = size_bits[4] | flags | VEC_MALLOC ;
}
void gl_vector3f_alloc( GLvector3f *v, GLuint flags, GLuint count,
@@ -164,7 +164,7 @@ void gl_vector3f_alloc( GLvector3f *v, GLuint flags, GLuint count,
v->start = (GLfloat *) v->storage;
v->data = (GLfloat (*)[3]) v->storage;
v->count = 0;
- v->flags = flags | VEC_MALLOC | VEC_GOOD_STRIDE;
+ v->flags = flags | VEC_MALLOC ;
}
void gl_vector1f_alloc( GLvector1f *v, GLuint flags, GLuint count,
@@ -175,7 +175,7 @@ void gl_vector1f_alloc( GLvector1f *v, GLuint flags, GLuint count,
ALIGN_MALLOC( count * sizeof(GLfloat), alignment );
v->data = v->start;
v->count = 0;
- v->flags = flags | VEC_MALLOC | VEC_GOOD_STRIDE;
+ v->flags = flags | VEC_MALLOC ;
}
void gl_vector4ub_alloc( GLvector4ub *v, GLuint flags, GLuint count,
@@ -186,7 +186,7 @@ void gl_vector4ub_alloc( GLvector4ub *v, GLuint flags, GLuint count,
v->start = (GLubyte *) v->storage;
v->data = (GLubyte (*)[4]) v->storage;
v->count = 0;
- v->flags = flags | VEC_MALLOC | VEC_GOOD_STRIDE;
+ v->flags = flags | VEC_MALLOC ;
}
void gl_vector1ub_alloc( GLvector1ub *v, GLuint flags, GLuint count,
@@ -197,7 +197,7 @@ void gl_vector1ub_alloc( GLvector1ub *v, GLuint flags, GLuint count,
v->start = (GLubyte *) v->storage;
v->data = (GLubyte *) v->storage;
v->count = 0;
- v->flags = flags | VEC_MALLOC | VEC_GOOD_STRIDE;
+ v->flags = flags | VEC_MALLOC ;
}
void gl_vector1ui_alloc( GLvector1ui *v, GLuint flags, GLuint count,
@@ -208,7 +208,7 @@ void gl_vector1ui_alloc( GLvector1ui *v, GLuint flags, GLuint count,
v->start = (GLuint *) v->storage;
v->data = (GLuint *) v->storage;
v->count = 0;
- v->flags = flags | VEC_MALLOC | VEC_GOOD_STRIDE;
+ v->flags = flags | VEC_MALLOC ;
}
diff --git a/src/mesa/math/m_vector.h b/src/mesa/math/m_vector.h
index c4af1eaade5..24a392a12b4 100644
--- a/src/mesa/math/m_vector.h
+++ b/src/mesa/math/m_vector.h
@@ -1,4 +1,4 @@
-/* $Id: m_vector.h,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
+/* $Id: m_vector.h,v 1.2 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,18 +35,13 @@
#include "glheader.h"
-#define VEC_DIRTY_0 0x1 /* dirty flags not really used any more */
+#define VEC_DIRTY_0 0x1
#define VEC_DIRTY_1 0x2
#define VEC_DIRTY_2 0x4
#define VEC_DIRTY_3 0x8
#define VEC_MALLOC 0x10 /* storage field points to self-allocated mem*/
-#define VEC_WRITABLE 0x20 /* keep both + and - bits for easy testing */
-#define VEC_NOT_WRITABLE 0x40
-#define VEC_GOOD_STRIDE 0x80
-#define VEC_BAD_STRIDE 0x100
-
-#define VEC_WRITABLE_FLAGS (VEC_WRITABLE|VEC_NOT_WRITABLE)
-#define VEC_STRIDE_FLAGS (VEC_GOOD_STRIDE|VEC_BAD_STRIDE)
+#define VEC_NOT_WRITEABLE 0x40 /* writable elements to hold clipped data */
+#define VEC_BAD_STRIDE 0x100 /* matches tnl's prefered stride */
#define VEC_SIZE_1 VEC_DIRTY_0
diff --git a/src/mesa/math/m_xform.c b/src/mesa/math/m_xform.c
index a6e34e9eb2b..72aec3a06ad 100644
--- a/src/mesa/math/m_xform.c
+++ b/src/mesa/math/m_xform.c
@@ -1,4 +1,4 @@
-/* $Id: m_xform.c,v 1.4 2000/11/24 10:25:11 keithw Exp $ */
+/* $Id: m_xform.c,v 1.5 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -41,6 +41,7 @@
#include "macros.h"
#include "mmath.h"
+#include "m_eval.h"
#include "m_matrix.h"
#include "m_translate.h"
#include "m_xform.h"
@@ -250,4 +251,5 @@ _math_init( void )
_math_init_transformation();
_math_init_translate();
_math_init_vertices();
+ _math_init_eval();
}
diff --git a/src/mesa/math/m_xform.h b/src/mesa/math/m_xform.h
index 7fc5be3ab15..046fc3d9371 100644
--- a/src/mesa/math/m_xform.h
+++ b/src/mesa/math/m_xform.h
@@ -1,4 +1,4 @@
-/* $Id: m_xform.h,v 1.2 2000/11/17 21:01:49 brianp Exp $ */
+/* $Id: m_xform.h,v 1.3 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -75,8 +75,8 @@ do { \
extern void gl_transform_vector( GLfloat u[4],
- const GLfloat v[4],
- const GLfloat m[16] );
+ CONST GLfloat v[4],
+ CONST GLfloat m[16] );
extern void
@@ -132,37 +132,36 @@ _math_init_transformation( void );
#define CLIP_NEAR_BIT 0x10
#define CLIP_FAR_BIT 0x20
#define CLIP_USER_BIT 0x40
-#define CLIP_CULLED_BIT 0x80 /* Vertex has been culled */
#define CLIP_ALL_BITS 0x3f
typedef GLvector4f * (_XFORMAPIP clip_func)( GLvector4f *vClip,
- GLvector4f *vProj,
- GLubyte clipMask[],
- GLubyte *orMask,
- GLubyte *andMask );
+ GLvector4f *vProj,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask );
-typedef void (*dotprod_func)( GLvector4f *out_vec,
- GLuint elt,
- const GLvector4f *coord_vec,
- const GLfloat plane[4],
- const GLubyte mask[]);
+typedef void (*dotprod_func)( GLfloat *out,
+ GLuint out_stride,
+ CONST GLvector4f *coord_vec,
+ CONST GLfloat plane[4],
+ CONST GLubyte mask[]);
typedef void (*vec_copy_func)( GLvector4f *to,
- const GLvector4f *from,
- const GLubyte mask[]);
+ CONST GLvector4f *from,
+ CONST GLubyte mask[]);
/*
* Functions for transformation of normals in the VB.
*/
-typedef void (_NORMAPIP normal_func)( const GLmatrix *mat,
- GLfloat scale,
- const GLvector3f *in,
- const GLfloat lengths[],
- const GLubyte mask[],
- GLvector3f *dest );
+typedef void (_NORMAPIP normal_func)( CONST GLmatrix *mat,
+ GLfloat scale,
+ CONST GLvector3f *in,
+ CONST GLfloat lengths[],
+ CONST GLubyte mask[],
+ GLvector3f *dest );
/* Flags for selecting a normal transformation function.
@@ -181,26 +180,27 @@ typedef void (_NORMAPIP normal_func)( const GLmatrix *mat,
* parameter, to allow a unified interface.
*/
typedef void (_XFORMAPIP transform_func)( GLvector4f *to_vec,
- const GLfloat m[16],
- const GLvector4f *from_vec,
- const GLubyte *clipmask,
- const GLubyte flag );
+ CONST GLfloat m[16],
+ CONST GLvector4f *from_vec,
+ CONST GLubyte *clipmask,
+ CONST GLubyte flag );
extern GLvector4f *gl_project_points( GLvector4f *to,
- const GLvector4f *from );
+ CONST GLvector4f *from );
extern void gl_transform_bounds3( GLubyte *orMask, GLubyte *andMask,
- const GLfloat m[16],
- CONST GLfloat src[][3] );
+ CONST GLfloat m[16],
+ CONST GLfloat src[][3] );
extern void gl_transform_bounds2( GLubyte *orMask, GLubyte *andMask,
- const GLfloat m[16],
- CONST GLfloat src[][3] );
+ CONST GLfloat m[16],
+ CONST GLfloat src[][3] );
extern dotprod_func gl_dotprod_tab[2][5];
extern vec_copy_func gl_copy_tab[2][0x10];
+extern vec_copy_func gl_copy_clean_tab[2][5];
extern clip_func gl_clip_tab[5];
extern normal_func gl_normal_tab[0xf][0x4];
@@ -210,17 +210,13 @@ extern normal_func gl_normal_tab[0xf][0x4];
extern transform_func **(gl_transform_tab[2]);
-extern void gl_transform_point_sz( GLfloat Q[4], const GLfloat M[16],
- const GLfloat P[4], GLuint sz );
+extern void gl_transform_point_sz( GLfloat Q[4], CONST GLfloat M[16],
+ CONST GLfloat P[4], GLuint sz );
#define TransformRaw( to, mat, from ) \
( (*gl_transform_tab[0][(from)->size][(mat)->type])( to, (mat)->m, from, 0, 0 ), \
(to) )
-#define Transform( to, mat, from, mask, cull ) \
- ( (*gl_transform_tab[cull!=0][(from)->size][(mat)->type])( to, (mat)->m, from, mask, cull ), \
- (to) )
-
#endif
diff --git a/src/mesa/math/m_xform_tmp.h b/src/mesa/math/m_xform_tmp.h
index 289255a9cf5..cb94f88ed1e 100644
--- a/src/mesa/math/m_xform_tmp.h
+++ b/src/mesa/math/m_xform_tmp.h
@@ -1,4 +1,4 @@
-/* $Id: m_xform_tmp.h,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
+/* $Id: m_xform_tmp.h,v 1.2 2000/12/26 05:09:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -457,10 +457,7 @@ TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-/* This may not be called too often, but I wouldn't say it was dead
- * code. It's also hard to remove any of these functions if you are
- * attached to the assertions that have appeared in them.
- */
+
static void _XFORMAPI
TAG(transform_points2_perspective)( GLvector4f *to_vec,
const GLfloat m[16],