Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

mesh.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  mesh_t

Defines

#define MAX_EXPANDED_AXIS   128

Functions

mesh_tCopyMesh (mesh_t *mesh)
void FreeMesh (mesh_t *m)
void InvertMesh (mesh_t *m)
void MakeMeshNormals (mesh_t in)
void MakeNormalVectors (vec3_t forward, vec3_t right, vec3_t up)
void PrintMesh (mesh_t *m)
void PutMeshOnCurve (mesh_t in)
mesh_tRemoveLinearMeshColumnsRows (mesh_t *in)
mesh_tSubdivideMesh (mesh_t in, float maxError, float minLength)
mesh_tSubdivideMeshQuads (mesh_t *in, float minLength, int maxsize, int widthtable[], int heighttable[])
mesh_tTransposeMesh (mesh_t *in)

Variables

int originalHeights [MAX_EXPANDED_AXIS]
int originalWidths [MAX_EXPANDED_AXIS]


Define Documentation

#define MAX_EXPANDED_AXIS   128
 

Definition at line 31 of file mesh.h.


Function Documentation

mesh_t* CopyMesh mesh_t mesh  ) 
 

Definition at line 85 of file mesh.c.

References mesh_t::height, malloc(), memcpy(), mesh_t::verts, and mesh_t::width.

Referenced by DrawSurfaceForMesh(), RemoveLinearMeshColumnsRows(), SubdivideMesh(), and SubdivideMeshQuads().

00085                                  {
00086     mesh_t  *out;
00087     int     size;
00088 
00089     out = malloc( sizeof( *out ) );
00090     out->width = mesh->width;
00091     out->height = mesh->height;
00092 
00093     size = out->width * out->height * sizeof( *out->verts );
00094     out->verts = malloc( size );
00095     memcpy( out->verts, mesh->verts, size );
00096 
00097     return out;
00098 }

Here is the call graph for this function:

void FreeMesh mesh_t m  ) 
 

Definition at line 65 of file mesh.c.

References free(), m, and mesh_t::verts.

Referenced by AllocateLightmapForPatch(), ChopPatchByBrush(), DrawSurfaceForMesh(), FacetsForPatch(), LinearSubdivideMesh(), SplitMeshByPlane(), TraceLtm(), TransposeMesh(), VL_FacetsForPatch(), and VS_FacetsForPatch().

00065                            {
00066     free( m->verts );
00067     free( m );
00068 }

Here is the call graph for this function:

void InvertMesh mesh_t m  ) 
 

Definition at line 128 of file mesh.c.

References h(), mesh_t::height, in, mesh_t::verts, w, and mesh_t::width.

Referenced by SplitMeshByPlane().

00128                               {
00129     int         w, h;
00130     drawVert_t  temp;
00131 
00132     for ( h = 0 ; h < in->height ; h++ ) {
00133         for ( w = 0 ; w < in->width / 2 ; w++ ) {
00134             temp = in->verts[ h * in->width + w ];
00135             in->verts[ h * in->width + w ] = in->verts[ h * in->width + in->width - 1 - w ];
00136             in->verts[ h * in->width + in->width - 1 - w ] = temp;
00137         }
00138     }
00139 }

Here is the call graph for this function:

void MakeMeshNormals mesh_t  in  ) 
 

Definition at line 147 of file mesh.c.

References count, CrossProduct(), mesh_t::height, i, in, j, k, neighbors, drawVert_t::normal, qboolean, vec3_t, VectorAdd, VectorClear, VectorCopy, VectorLength(), VectorNormalize(), VectorSubtract, mesh_t::verts, mesh_t::width, x, drawVert_t::xyz, and y.

Referenced by DrawSurfaceForMesh(), FacetsForPatch(), R_GridInsertColumn(), R_GridInsertRow(), R_SubdividePatchToGrid(), TraceLtm(), VL_FacetsForPatch(), and VS_FacetsForPatch().

00147                                   {
00148     int     i, j, k, dist;
00149     vec3_t  normal;
00150     vec3_t  sum;
00151     int     count;
00152     vec3_t  base;
00153     vec3_t  delta;
00154     int     x, y;
00155     drawVert_t  *dv;
00156     vec3_t      around[8], temp;
00157     qboolean    good[8];
00158     qboolean    wrapWidth, wrapHeight;
00159     float       len;
00160 
00161     wrapWidth = qfalse;
00162     for ( i = 0 ; i < in.height ; i++ ) {
00163         VectorSubtract( in.verts[i*in.width].xyz, 
00164             in.verts[i*in.width+in.width-1].xyz, delta );
00165         len = VectorLength( delta );
00166         if ( len > 1.0 ) {
00167             break;
00168         }
00169     }
00170     if ( i == in.height ) {
00171         wrapWidth = qtrue;
00172     }
00173 
00174     wrapHeight = qfalse;
00175     for ( i = 0 ; i < in.width ; i++ ) {
00176         VectorSubtract( in.verts[i].xyz, 
00177             in.verts[i + (in.height-1)*in.width].xyz, delta );
00178         len = VectorLength( delta );
00179         if ( len > 1.0 ) {
00180             break;
00181         }
00182     }
00183     if ( i == in.width) {
00184         wrapHeight = qtrue;
00185     }
00186 
00187 
00188     for ( i = 0 ; i < in.width ; i++ ) {
00189         for ( j = 0 ; j < in.height ; j++ ) {
00190             count = 0;
00191             dv = &in.verts[j*in.width+i];
00192             VectorCopy( dv->xyz, base );
00193             for ( k = 0 ; k < 8 ; k++ ) {
00194                 VectorClear( around[k] );
00195                 good[k] = qfalse;
00196 
00197                 for ( dist = 1 ; dist <= 3 ; dist++ ) {
00198                     x = i + neighbors[k][0] * dist;
00199                     y = j + neighbors[k][1] * dist;
00200                     if ( wrapWidth ) {
00201                         if ( x < 0 ) {
00202                             x = in.width - 1 + x;
00203                         } else if ( x >= in.width ) {
00204                             x = 1 + x - in.width;
00205                         }
00206                     }
00207                     if ( wrapHeight ) {
00208                         if ( y < 0 ) {
00209                             y = in.height - 1 + y;
00210                         } else if ( y >= in.height ) {
00211                             y = 1 + y - in.height;
00212                         }
00213                     }
00214 
00215                     if ( x < 0 || x >= in.width || y < 0 || y >= in.height ) {
00216                         break;                  // edge of patch
00217                     }
00218                     VectorSubtract( in.verts[y*in.width+x].xyz, base, temp );
00219                     if ( VectorNormalize( temp, temp ) == 0 ) {
00220                         continue;               // degenerate edge, get more dist
00221                     } else {
00222                         good[k] = qtrue;
00223                         VectorCopy( temp, around[k] );
00224                         break;                  // good edge
00225                     }
00226                 }
00227             }
00228 
00229             VectorClear( sum );
00230             for ( k = 0 ; k < 8 ; k++ ) {
00231                 if ( !good[k] || !good[(k+1)&7] ) {
00232                     continue;   // didn't get two points
00233                 }
00234                 CrossProduct( around[(k+1)&7], around[k], normal );
00235                 if ( VectorNormalize( normal, normal ) == 0 ) {
00236                     continue;
00237                 }
00238                 VectorAdd( normal, sum, sum );
00239                 count++;
00240             }
00241             if ( count == 0 ) {
00242 //_printf("bad normal\n");
00243                 count = 1;
00244             }
00245             VectorNormalize( sum, dv->normal );
00246         }
00247     }
00248 }

Here is the call graph for this function:

void MakeNormalVectors vec3_t  forward,
vec3_t  right,
vec3_t  up
 

Definition at line 523 of file q_math.c.

References CrossProduct(), d, DotProduct, right, up, VectorMA, and VectorNormalize().

Referenced by AddEdge(), RB_SurfaceRailRings(), and TraceLtm().

00523                                                                        {
00524     float       d;
00525 
00526     // this rotate and negate guarantees a vector
00527     // not colinear with the original
00528     right[1] = -forward[0];
00529     right[2] = forward[1];
00530     right[0] = forward[2];
00531 
00532     d = DotProduct (right, forward);
00533     VectorMA (right, -d, forward, right);
00534     VectorNormalize (right);
00535     CrossProduct (right, forward, up);
00536 }

Here is the call graph for this function:

void PrintMesh mesh_t m  ) 
 

Definition at line 70 of file mesh.c.

References _printf(), mesh_t::height, i, j, m, mesh_t::verts, and mesh_t::width.

00070                             {
00071     int     i, j;
00072 
00073     for ( i = 0 ; i < m->height ; i++ ) {
00074         for ( j = 0 ; j < m->width ; j++ ) {
00075             _printf("(%5.2f %5.2f %5.2f) "
00076                 , m->verts[i*m->width+j].xyz[0]
00077                 , m->verts[i*m->width+j].xyz[1]
00078                 , m->verts[i*m->width+j].xyz[2] );
00079         }
00080         _printf("\n");
00081     }
00082 }

Here is the call graph for this function:

void PutMeshOnCurve mesh_t  in  ) 
 

Definition at line 257 of file mesh.c.

References mesh_t::height, i, in, j, l, next, mesh_t::verts, mesh_t::width, and drawVert_t::xyz.

Referenced by AllocateLightmapForPatch(), DrawSurfaceForMesh(), FacetsForPatch(), TraceLtm(), VL_FacetsForPatch(), and VS_FacetsForPatch().

00257                                  {
00258     int     i, j, l;
00259     float   prev, next;
00260 
00261     // put all the aproximating points on the curve
00262     for ( i = 0 ; i < in.width ; i++ ) {
00263         for ( j = 1 ; j < in.height ; j += 2 ) {
00264             for ( l = 0 ; l < 3 ; l++ ) {
00265                 prev = ( in.verts[j*in.width+i].xyz[l] + in.verts[(j+1)*in.width+i].xyz[l] ) * 0.5;
00266                 next = ( in.verts[j*in.width+i].xyz[l] + in.verts[(j-1)*in.width+i].xyz[l] ) * 0.5;
00267                 in.verts[j*in.width+i].xyz[l] = ( prev + next ) * 0.5;
00268             }
00269         }
00270     }
00271 
00272     for ( j = 0 ; j < in.height ; j++ ) {
00273         for ( i = 1 ; i < in.width ; i += 2 ) {
00274             for ( l = 0 ; l < 3 ; l++ ) {
00275                 prev = ( in.verts[j*in.width+i].xyz[l] + in.verts[j*in.width+i+1].xyz[l] ) * 0.5;
00276                 next = ( in.verts[j*in.width+i].xyz[l] + in.verts[j*in.width+i-1].xyz[l] ) * 0.5;
00277                 in.verts[j*in.width+i].xyz[l] = ( prev + next ) * 0.5;
00278             }
00279         }
00280     }
00281 }

mesh_t* RemoveLinearMeshColumnsRows mesh_t in  ) 
 

Definition at line 467 of file mesh.c.

References CopyMesh(), expand(), mesh_t::height, i, in, j, k, memmove(), originalHeights, originalWidths, ProjectPointOntoVector(), vec3_t, VectorLength(), VectorSubtract, mesh_t::verts, and mesh_t::width.

Referenced by AllocateLightmapForPatch(), FacetsForPatch(), TraceLtm(), VL_FacetsForPatch(), and VS_FacetsForPatch().

00467                                                   {
00468     int i, j, k;
00469     float len, maxLength;
00470     vec3_t proj, dir;
00471     mesh_t out;
00472     drawVert_t  expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS];
00473 
00474     out.width = in->width;
00475     out.height = in->height;
00476 
00477     for ( i = 0 ; i < in->width ; i++ ) {
00478         for ( j = 0 ; j < in->height ; j++ ) {
00479             expand[j][i] = in->verts[j*in->width+i];
00480         }
00481     }
00482 
00483     for ( j = 1 ; j < out.width - 1; j++ ) {
00484         maxLength = 0;
00485         for ( i = 0 ; i < out.height ; i++ ) {
00486             ProjectPointOntoVector(expand[i][j].xyz, expand[i][j-1].xyz, expand[i][j+1].xyz, proj);
00487             VectorSubtract(expand[i][j].xyz, proj, dir);
00488             len = VectorLength(dir);
00489             if (len > maxLength) {
00490                 maxLength = len;
00491             }
00492         }
00493         if (maxLength < 0.1)
00494         {
00495             out.width--;
00496             for ( i = 0 ; i < out.height ; i++ ) {
00497                 for (k = j; k < out.width; k++) {
00498                     expand[i][k] = expand[i][k+1];
00499                 }
00500             }
00501             for (k = j; k < out.width; k++) {
00502                 originalWidths[k] = originalWidths[k+1];
00503             }
00504             j--;
00505         }
00506     }
00507     for ( j = 1 ; j < out.height - 1; j++ ) {
00508         maxLength = 0;
00509         for ( i = 0 ; i < out.width ; i++ ) {
00510             ProjectPointOntoVector(expand[j][i].xyz, expand[j-1][i].xyz, expand[j+1][i].xyz, proj);
00511             VectorSubtract(expand[j][i].xyz, proj, dir);
00512             len = VectorLength(dir);
00513             if (len > maxLength) {
00514                 maxLength = len;
00515             }
00516         }
00517         if (maxLength < 0.1)
00518         {
00519             out.height--;
00520             for ( i = 0 ; i < out.width ; i++ ) {
00521                 for (k = j; k < out.height; k++) {
00522                     expand[k][i] = expand[k+1][i];
00523                 }
00524             }
00525             for (k = j; k < out.height; k++) {
00526                 originalHeights[k] = originalHeights[k+1];
00527             }
00528             j--;
00529         }
00530     }
00531     // collapse the verts
00532     out.verts = &expand[0][0];
00533     for ( i = 1 ; i < out.height ; i++ ) {
00534         memmove( &out.verts[i*out.width], expand[i], out.width * sizeof(drawVert_t) );
00535     }
00536 
00537     return CopyMesh(&out);
00538 }

Here is the call graph for this function:

mesh_t* SubdivideMesh mesh_t  in,
float  maxError,
float  minLength
 

Definition at line 290 of file mesh.c.

00290                                                                     {
00291     int         i, j, k, l;
00292     drawVert_t  prev, next, mid;
00293     vec3_t      prevxyz, nextxyz, midxyz;
00294     vec3_t      delta;
00295     float       len;
00296     mesh_t      out;
00297     drawVert_t  expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS];
00298 
00299     out.width = in.width;
00300     out.height = in.height;
00301 
00302     for ( i = 0 ; i < in.width ; i++ ) {
00303         for ( j = 0 ; j < in.height ; j++ ) {
00304             expand[j][i] = in.verts[j*in.width+i];
00305         }
00306     }
00307 
00308     for ( i = 0 ; i < in.height ; i++ ) {
00309         originalHeights[i] = i;
00310     }
00311     for ( i = 0 ; i < in.width ; i++ ) {
00312         originalWidths[i] = i;
00313     }
00314 
00315     // horizontal subdivisions
00316     for ( j = 0 ; j + 2 < out.width ; j += 2 ) {
00317         // check subdivided midpoints against control points
00318         for ( i = 0 ; i < out.height ; i++ ) {
00319             for ( l = 0 ; l < 3 ; l++ ) {
00320                 prevxyz[l] = expand[i][j+1].xyz[l] - expand[i][j].xyz[l]; 
00321                 nextxyz[l] = expand[i][j+2].xyz[l] - expand[i][j+1].xyz[l]; 
00322                 midxyz[l] = (expand[i][j].xyz[l] + expand[i][j+1].xyz[l] * 2
00323                         + expand[i][j+2].xyz[l] ) * 0.25;
00324             }
00325 
00326             // if the span length is too long, force a subdivision
00327             if ( VectorLength( prevxyz ) > minLength 
00328                 || VectorLength( nextxyz ) > minLength ) {
00329                 break;
00330             }
00331 
00332             // see if this midpoint is off far enough to subdivide
00333             VectorSubtract( expand[i][j+1].xyz, midxyz, delta );
00334             len = VectorLength( delta );
00335             if ( len > maxError ) {
00336                 break;
00337             }
00338         }
00339 
00340         if ( out.width + 2 >= MAX_EXPANDED_AXIS ) {
00341             break;  // can't subdivide any more
00342         }
00343 
00344         if ( i == out.height ) {
00345             continue;   // didn't need subdivision
00346         }
00347 
00348         // insert two columns and replace the peak
00349         out.width += 2;
00350 
00351         for ( k = out.width - 1 ; k > j + 3 ; k-- ) {
00352             originalWidths[k] = originalWidths[k-2];
00353         }
00354         originalWidths[j+3] = originalWidths[j+1];
00355         originalWidths[j+2] = originalWidths[j+1];
00356         originalWidths[j+1] = originalWidths[j];
00357 
00358         for ( i = 0 ; i < out.height ; i++ ) {
00359             LerpDrawVert( &expand[i][j], &expand[i][j+1], &prev );
00360             LerpDrawVert( &expand[i][j+1], &expand[i][j+2], &next );
00361             LerpDrawVert( &prev, &next, &mid );
00362 
00363             for ( k = out.width - 1 ; k > j + 3 ; k-- ) {
00364                 expand[i][k] = expand[i][k-2];
00365             }
00366             expand[i][j + 1] = prev;
00367             expand[i][j + 2] = mid;
00368             expand[i][j + 3] = next;
00369         }
00370 
00371         // back up and recheck this set again, it may need more subdivision
00372         j -= 2;
00373 
00374     }
00375 
00376     // vertical subdivisions
00377     for ( j = 0 ; j + 2 < out.height ; j += 2 ) {
00378         // check subdivided midpoints against control points
00379         for ( i = 0 ; i < out.width ; i++ ) {
00380             for ( l = 0 ; l < 3 ; l++ ) {
00381                 prevxyz[l] = expand[j+1][i].xyz[l] - expand[j][i].xyz[l]; 
00382                 nextxyz[l] = expand[j+2][i].xyz[l] - expand[j+1][i].xyz[l]; 
00383                 midxyz[l] = (expand[j][i].xyz[l] + expand[j+1][i].xyz[l] * 2
00384                         + expand[j+2][i].xyz[l] ) * 0.25;
00385             }
00386 
00387             // if the span length is too long, force a subdivision
00388             if ( VectorLength( prevxyz ) > minLength 
00389                 || VectorLength( nextxyz ) > minLength ) {
00390                 break;
00391             }
00392             // see if this midpoint is off far enough to subdivide
00393             VectorSubtract( expand[j+1][i].xyz, midxyz, delta );
00394             len = VectorLength( delta );
00395             if ( len > maxError ) {
00396                 break;
00397             }
00398         }
00399 
00400         if ( out.height + 2 >= MAX_EXPANDED_AXIS ) {
00401             break;  // can't subdivide any more
00402         }
00403 
00404         if ( i == out.width ) {
00405             continue;   // didn't need subdivision
00406         }
00407 
00408         // insert two columns and replace the peak
00409         out.height += 2;
00410 
00411         for ( k = out.height - 1 ; k > j + 3 ; k-- ) {
00412             originalHeights[k] = originalHeights[k-2];
00413         }
00414         originalHeights[j+3] = originalHeights[j+1];
00415         originalHeights[j+2] = originalHeights[j+1];
00416         originalHeights[j+1] = originalHeights[j];
00417 
00418         for ( i = 0 ; i < out.width ; i++ ) {
00419             LerpDrawVert( &expand[j][i], &expand[j+1][i], &prev );
00420             LerpDrawVert( &expand[j+1][i], &expand[j+2][i], &next );
00421             LerpDrawVert( &prev, &next, &mid );
00422 
00423             for ( k = out.height - 1 ; k > j + 3 ; k-- ) {
00424                 expand[k][i] = expand[k-2][i];
00425             }
00426             expand[j+1][i] = prev;
00427             expand[j+2][i] = mid;
00428             expand[j+3][i] = next;
00429         }
00430 
00431         // back up and recheck this set again, it may need more subdivision
00432         j -= 2;
00433 
00434     }
00435 
00436     // collapse the verts
00437 
00438     out.verts = &expand[0][0];
00439     for ( i = 1 ; i < out.height ; i++ ) {
00440         memmove( &out.verts[i*out.width], expand[i], out.width * sizeof(drawVert_t) );
00441     }
00442 
00443     return CopyMesh(&out);
00444 }

mesh_t* SubdivideMeshQuads mesh_t in,
float  minLength,
int  maxsize,
int  widthtable[],
int  heighttable[]
 

Definition at line 572 of file mesh.c.

References CopyMesh(), Error(), expand(), h(), mesh_t::height, i, in, j, k, length(), LerpDrawVertAmount(), memmove(), originalHeights, originalWidths, vec3_t, VectorLength(), VectorSubtract, mesh_t::verts, w, and mesh_t::width.

Referenced by AllocateLightmapForPatch(), TraceLtm(), VL_FacetsForPatch(), and VS_FacetsForPatch().

00572                                                                                                            {
00573     int         i, j, k, w, h, maxsubdivisions, subdivisions;
00574     vec3_t      dir;
00575     float       length, maxLength, amount;
00576     mesh_t      out;
00577     drawVert_t  expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS];
00578 
00579     out.width = in->width;
00580     out.height = in->height;
00581 
00582     for ( i = 0 ; i < in->width ; i++ ) {
00583         for ( j = 0 ; j < in->height ; j++ ) {
00584             expand[j][i] = in->verts[j*in->width+i];
00585         }
00586     }
00587 
00588     if (maxsize > MAX_EXPANDED_AXIS)
00589         Error("SubdivideMeshQuads: maxsize > MAX_EXPANDED_AXIS");
00590 
00591     // horizontal subdivisions
00592 
00593     maxsubdivisions = (maxsize - in->width) / (in->width - 1);
00594 
00595     for ( w = 0, j = 0 ; w < in->width - 1; w++, j += subdivisions + 1) {
00596         maxLength = 0;
00597         for ( i = 0 ; i < out.height ; i++ ) {
00598             VectorSubtract(expand[i][j+1].xyz, expand[i][j].xyz, dir);
00599             length = VectorLength( dir );
00600             if (length > maxLength) {
00601                 maxLength = length;
00602             }
00603         }
00604         
00605         subdivisions = (int) (maxLength / minLength);
00606         if (subdivisions > maxsubdivisions)
00607             subdivisions = maxsubdivisions;
00608 
00609         widthtable[w] = subdivisions + 1;
00610         if (subdivisions <= 0)
00611             continue;
00612 
00613         out.width += subdivisions;
00614 
00615         for ( k = out.width - 1; k >= j + subdivisions; k-- ) {
00616             originalWidths[k] = originalWidths[k-subdivisions];
00617         }
00618         for (k = 1; k <= subdivisions; k++) {
00619             originalWidths[j+k] = originalWidths[j];
00620         }
00621 
00622         for ( i = 0 ; i < out.height ; i++ ) {
00623             for ( k = out.width - 1 ; k > j + subdivisions; k-- ) {
00624                 expand[i][k] = expand[i][k-subdivisions];
00625             }
00626             for (k = 1; k <= subdivisions; k++)
00627             {
00628                 amount = (float) k / (subdivisions + 1);
00629                 LerpDrawVertAmount(&expand[i][j], &expand[i][j+subdivisions+1], amount, &expand[i][j+k]);
00630             }
00631         }
00632     }
00633 
00634     maxsubdivisions = (maxsize - in->height) / (in->height - 1);
00635 
00636     for ( h = 0, j = 0 ; h < in->height - 1; h++, j += subdivisions + 1) {
00637         maxLength = 0;
00638         for ( i = 0 ; i < out.width ; i++ ) {
00639             VectorSubtract(expand[j+1][i].xyz, expand[j][i].xyz, dir);
00640             length = VectorLength( dir );
00641             if (length  > maxLength) {
00642                 maxLength = length;
00643             }
00644         }
00645         
00646         subdivisions = (int) (maxLength / minLength);
00647         if (subdivisions > maxsubdivisions)
00648             subdivisions = maxsubdivisions;
00649 
00650         heighttable[h] = subdivisions + 1;
00651         if (subdivisions <= 0)
00652             continue;
00653 
00654         out.height += subdivisions;
00655 
00656         for ( k = out.height - 1; k >= j + subdivisions; k-- ) {
00657             originalHeights[k] = originalHeights[k-subdivisions];
00658         }
00659         for (k = 1; k <= subdivisions; k++) {
00660             originalHeights[j+k] = originalHeights[j];
00661         }
00662 
00663         for ( i = 0 ; i < out.width ; i++ ) {
00664             for ( k = out.height - 1 ; k > j + subdivisions; k-- ) {
00665                 expand[k][i] = expand[k-subdivisions][i];
00666             }
00667             for (k = 1; k <= subdivisions; k++)
00668             {
00669                 amount = (float) k / (subdivisions + 1);
00670                 LerpDrawVertAmount(&expand[j][i], &expand[j+subdivisions+1][i], amount, &expand[j+k][i]);
00671             }
00672         }
00673     }
00674 
00675     // collapse the verts
00676     out.verts = &expand[0][0];
00677     for ( i = 1 ; i < out.height ; i++ ) {
00678         memmove( &out.verts[i*out.width], expand[i], out.width * sizeof(drawVert_t) );
00679     }
00680 
00681     return CopyMesh(&out);
00682 }

Here is the call graph for this function:

mesh_t* TransposeMesh mesh_t in  ) 
 

Definition at line 108 of file mesh.c.

References FreeMesh(), h(), mesh_t::height, in, malloc(), mesh_t::verts, w, and mesh_t::width.

Referenced by SplitMeshByPlane(), and TraceLtm().

00108                                     {
00109     int         w, h;
00110     mesh_t      *out;
00111 
00112     out = malloc( sizeof( *out ) );
00113     out->width = in->height;
00114     out->height = in->width;
00115     out->verts = malloc( out->width * out->height * sizeof( drawVert_t ) );
00116 
00117     for ( h = 0 ; h < in->height ; h++ ) {
00118         for ( w = 0 ; w < in->width ; w++ ) {
00119             out->verts[ w * in->height + h ] = in->verts[ h * in->width + w ];
00120         }
00121     }
00122 
00123     FreeMesh( in );
00124 
00125     return out;
00126 }

Here is the call graph for this function:


Variable Documentation

int originalHeights[MAX_EXPANDED_AXIS]
 

Definition at line 36 of file mesh.c.

Referenced by AllocateLightmapForPatch(), RemoveLinearMeshColumnsRows(), SubdivideMesh(), and SubdivideMeshQuads().

int originalWidths[MAX_EXPANDED_AXIS]
 

Definition at line 35 of file mesh.c.

Referenced by AllocateLightmapForPatch(), RemoveLinearMeshColumnsRows(), SubdivideMesh(), and SubdivideMeshQuads().


Generated on Thu Aug 25 16:57:10 2005 for Quake III Arena by  doxygen 1.3.9.1