/* ================== SelectPartition Selects a surface from a linked list of surfaces to split the group on returns NULL if the surface list can not be divided any more (a leaf) ================== */ surface_t *SelectPartition (surface_t *surfaces, node_t *node, qboolean usemidsplit) { int i,j; surface_t *p, *bestsurface; // // count surface choices // i = 0; bestsurface = NULL; for (p=surfaces ; p ; p=p->next) if (!p->onnode) { i++; bestsurface = p; } if (i==0) return NULL; // this is a leafnode if (i==1) return bestsurface; // this is a final split if (usemidsplit) // do fast way for clipping hull return ChooseMidPlaneFromList (surfaces, node->mins, node->maxs); // do slow way to save poly splits for drawing hull return ChoosePlaneFromList (surfaces, node->mins, node->maxs); }
/* ================== SelectPartition Selects a surface from a linked list of surfaces to split the group on returns NULL if the surface list can not be divided any more (a leaf) ================== */ surface_t *SelectPartition (surface_t *surfaces) { int i,j; vec3_t mins, maxs; surface_t *p, *bestsurface; // // count onnode surfaces // i = 0; bestsurface = NULL; for (p=surfaces ; p ; p=p->next) if (!p->onnode) { i++; bestsurface = p; } if (i==0) return NULL; if (i==1) return bestsurface; // this is a final split // // calculate a bounding box of the entire surfaceset // for (i=0 ; i<3 ; i++) { mins[i] = BOGUS_RANGE; maxs[i] = -BOGUS_RANGE; } for (p=surfaces ; p ; p=p->next) for (j=0 ; j<3 ; j++) { if (p->mins[j] < mins[j]) mins[j] = p->mins[j]; if (p->maxs[j] > maxs[j]) maxs[j] = p->maxs[j]; } if (usemidsplit) // do fast way for clipping hull return ChooseMidPlaneFromList (surfaces, mins, maxs); // do slow way to save poly splits for drawing hull #if 0 bestsurface = ChoosePlaneFromList (surfaces, mins, maxs, false); if (bestsurface) return bestsurface; #endif return ChoosePlaneFromList (surfaces, mins, maxs, true); }