Clips a polygon Parameters: pointlist - pointer to a list of pointers to points nv - the number of points in the polygon cc - the clip codes for this polygon Returns: a pointer to a list of pointer of points in the clipped polygon NOTE: You MUST call g3_FreeTempPoints() when you're done with the clipped polygon
| 342 | // Returns: a pointer to a list of pointer of points in the clipped polygon |
| 343 | // NOTE: You MUST call g3_FreeTempPoints() when you're done with the clipped polygon |
| 344 | g3Point **g3_ClipPolygon(g3Point **pointlist, int *nv, g3Codes *cc) { |
| 345 | int plane_flag; |
| 346 | g3Point **dest; |
| 347 | |
| 348 | dest = Vbuf0; |
| 349 | |
| 350 | //& ASSERT(free_point_num == 0); //DAJ UTB CMO |
| 351 | if (free_point_num != 0) { |
| 352 | mprintf(1, "clipper: leftover temp point\n"); |
| 353 | free_point_num = 0; |
| 354 | Int3(); |
| 355 | } |
| 356 | |
| 357 | for (plane_flag = 1; plane_flag <= 32; plane_flag <<= 1) { |
| 358 | if (cc->cc_or & plane_flag) { |
| 359 | |
| 360 | *nv = ClipPlane(plane_flag, pointlist, dest, nv, cc); |
| 361 | |
| 362 | if (cc->cc_and) // clipped away |
| 363 | return dest; |
| 364 | |
| 365 | pointlist = dest; |
| 366 | dest = (pointlist == Vbuf0) ? Vbuf1 : Vbuf0; |
| 367 | } |
| 368 | } |
| 369 | return pointlist; // we swapped after we copied |
| 370 | } |
| 371 | |
| 372 | // sets the z distance of the far clipping plane |
| 373 | void g3_SetFarClipZ(float z) { Far_clip_z = z; } |
no test coverage detected