Game Development Reference
In-Depth Information
if (edgecount > numedges){
//Not sure if we need this but I'll put it in for safety
AfxMessageBox(”Edge count exceeds memory limit”);
goto subdivabort;
}
ply++;
}
//Now we know the actual number of edges
delete [] edges;
delete [] oi.pts;
delete [] oi.plys;
delete [] con;
oi.pts = new POINT3D[pointcount];
memcpy(oi.pts, pts, sizeof(POINT3D) * pointcount);
delete [] pts;
pts = NULL;
oi.numpoints = pointcount;
oi.plys = plys;
oi.numpolygons = numpolygons;
}
CalcNormals();
return TRUE;
subdivabort:
if (pts) delete [] pts;
if (plys) delete [] plys;
if (con) delete [] con;
return FALSE;
}
Optimization
If you intend to use subdivision for character animation, then the vertex
placement must be calculated for every change in the base mesh.
Connectivity will not alter throughout the animation, however, so it will
improve the performance to calculate the connectivity values only once. If
the maximum subdivision is order three, then calculate and store three
connectivity arrays. You could also store the number edges and points in
the subdivision after the first call, thereby reducing the memory
Search Nedrilad ::




Custom Search