- localNumSurfaceModels += n;
- }
- break;
-
- /* handle patches */
- case SURFACE_PATCH:
- /* subdivide the surface */
- src.width = ds->patchWidth;
- src.height = ds->patchHeight;
- src.verts = ds->verts;
- //% subdivided = SubdivideMesh( src, 8.0f, 512 );
- iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions );
- subdivided = SubdivideMesh2( src, iterations );
-
- /* fit it to the curve and remove colinear verts on rows/columns */
- PutMeshOnCurve( *subdivided );
- mesh = RemoveLinearMeshColumnsRows( subdivided );
- FreeMesh( subdivided );
-
- /* subdivide each quad to place the models */
- for( y = 0; y < (mesh->height - 1); y++ )
- {
- for( x = 0; x < (mesh->width - 1); x++ )
- {
- /* set indexes */
- pw[ 0 ] = x + (y * mesh->width);
- pw[ 1 ] = x + ((y + 1) * mesh->width);
- pw[ 2 ] = x + 1 + ((y + 1) * mesh->width);
- pw[ 3 ] = x + 1 + (y * mesh->width);
- pw[ 4 ] = x + (y * mesh->width); /* same as pw[ 0 ] */
-
- /* set radix */
- r = (x + y) & 1;
-
- /* triangle 1 */
- tri[ 0 ] = &mesh->verts[ pw[ r + 0 ] ];
- tri[ 1 ] = &mesh->verts[ pw[ r + 1 ] ];
- tri[ 2 ] = &mesh->verts[ pw[ r + 2 ] ];
- n = AddSurfaceModelsToTriangle_r( ds, model, tri );
- if( n < 0 )
- return n;
- localNumSurfaceModels += n;
-
- /* triangle 2 */
- tri[ 0 ] = &mesh->verts[ pw[ r + 0 ] ];
- tri[ 1 ] = &mesh->verts[ pw[ r + 2 ] ];
- tri[ 2 ] = &mesh->verts[ pw[ r + 3 ] ];
- n = AddSurfaceModelsToTriangle_r( ds, model, tri );
- if( n < 0 )
- return n;
- localNumSurfaceModels += n;