/* ================= R_AddMarkFragments ================= */ void R_AddMarkFragments(int numClipPoints, vec3_t clipPoints[2][MAX_VERTS_ON_POLY], int numPlanes, vec3_t * normals, float *dists, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t * fragmentBuffer, int *returnedPoints, int *returnedFragments, vec3_t mins, vec3_t maxs) { int pingPong, i; markFragment_t *mf; // chop the surface by all the bounding planes of the to be projected polygon pingPong = 0; for(i = 0; i < numPlanes; i++) { R_ChopPolyBehindPlane(numClipPoints, clipPoints[pingPong], &numClipPoints, clipPoints[!pingPong], normals[i], dists[i], 0.5); pingPong ^= 1; if(numClipPoints == 0) { break; } } // completely clipped away? if(numClipPoints == 0) { return; } // add this fragment to the returned list if(numClipPoints + (*returnedPoints) > maxPoints) { return; // not enough space for this polygon } /* // all the clip points should be within the bounding box for ( i = 0 ; i < numClipPoints ; i++ ) { int j; for ( j = 0 ; j < 3 ; j++ ) { if (clipPoints[pingPong][i][j] < mins[j] - 0.5) break; if (clipPoints[pingPong][i][j] > maxs[j] + 0.5) break; } if (j < 3) break; } if (i < numClipPoints) return; */ mf = fragmentBuffer + (*returnedFragments); mf->firstPoint = (*returnedPoints); mf->numPoints = numClipPoints; #if defined(SSEVEC3_T) Com_Memcpy(pointBuffer + (*returnedPoints) * 4, clipPoints[pingPong], numClipPoints * sizeof(vec3_t)); #else Com_Memcpy(pointBuffer + (*returnedPoints) * 3, clipPoints[pingPong], numClipPoints * sizeof(vec3_t)); #endif (*returnedPoints) += numClipPoints; (*returnedFragments)++; }
/* ================= R_AddMarkFragments ================= */ void R_AddMarkFragments(int numClipPoints, vec3_t clipPoints[2][MAX_VERTS_ON_POLY], int numPlanes, vec3_t *normals, float *dists, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, int *returnedPoints, int *returnedFragments, vec3_t mins, vec3_t maxs) { int pingPong, i; markFragment_t *mf; // chop the surface by all the bounding planes of the to be projected polygon pingPong = 0; for (i = 0 ; i < numPlanes ; i++) { R_ChopPolyBehindPlane(numClipPoints, clipPoints[pingPong], &numClipPoints, clipPoints[!pingPong], normals[i], dists[i], 0.5); pingPong ^= 1; if (numClipPoints == 0) { break; } } // completely clipped away? if (numClipPoints == 0) { return; } // add this fragment to the returned list if (numClipPoints + (*returnedPoints) > maxPoints) { return; // not enough space for this polygon } mf = fragmentBuffer + (*returnedFragments); mf->firstPoint = (*returnedPoints); mf->numPoints = numClipPoints; //memcpy( pointBuffer + (*returnedPoints) * 3, clipPoints[pingPong], numClipPoints * sizeof(vec3_t) ); for (i = 0; i < numClipPoints; i++) { VectorCopy(clipPoints[pingPong][i], (float *)pointBuffer + 5 * (*returnedPoints + i)); } (*returnedPoints) += numClipPoints; (*returnedFragments)++; }