[EMAIL PROTECTED] writes:

> To me the problem looks that (in xform_tmp.h notation) the from[*] array seems
> to be overwriten/not realy initialized in some parts, which causes "random"
> numbers to appear.

The problem seems to be with the bounding box culling.  The blue gear
gets too small of a box and gl_transform_vb() incorrectly skips the
clip test because of it.

Here is a new calculate_bounds3() (dlist.c) that seems to work better.
I've changed the starting vertex to obj->start instead of obj->data,
initialized both min and max with the first vertex, instead of
initializing max with the second vertex, and removed the else
statements (I'm not sure if they're safe or not).


static void calculate_bounds3( GLfloat (*bounds)[3],
                               const GLvector4f *obj )
{
   const GLfloat (*data)[4] = (GLfloat (*)[4])obj->start;
   GLfloat xmin = data[0][0];
   GLfloat ymin = data[0][1];
   GLfloat zmin = data[0][2];
   GLfloat xmax = data[0][0];
   GLfloat ymax = data[0][1];
   GLfloat zmax = data[0][2];
   GLuint i, count = obj->count;
   
   for (i = 1 ; i < count ; i++) {
      GLfloat t;
      t = data[i][0]; if (t > xmax) xmax = t; if (t < xmin) xmin = t;
      t = data[i][1]; if (t > ymax) ymax = t; if (t < ymin) ymin = t;
      t = data[i][2]; if (t > zmax) zmax = t; if (t < zmin) zmin = t;
   }
   
   bounds[0][0] = xmin;
   bounds[0][1] = ymin;
   bounds[0][2] = zmin;
   bounds[1][0] = xmax - xmin;
   bounds[1][1] = ymax - ymin;
   bounds[1][2] = zmax - zmin;
}


The calculate_bounds2() function needs the same changes.  I would want
to get Keith W's opinion before I check anything in though.


Josh

Reply via email to