| 698 | } |
| 699 | |
| 700 | void RenderSubmodelFacesSorted(poly_model *pm, bsp_info *sm) { |
| 701 | int i, t; |
| 702 | |
| 703 | int rcount; |
| 704 | int model_render_order[MAX_POLYGON_VECS]; |
| 705 | int modelnum = sm - pm->submodel; |
| 706 | |
| 707 | ASSERT(sm->nverts < MAX_POLYGON_VECS); |
| 708 | |
| 709 | // Build list of visible (non-backfacing) faces, & compute average face depths |
| 710 | for (i = rcount = 0; i < sm->num_faces; i++) { |
| 711 | polyface *fp = &sm->faces[i]; |
| 712 | |
| 713 | // check for visible face |
| 714 | if (g3_CheckNormalFacing(&sm->verts[fp->vertnums[0]], &fp->normal)) { |
| 715 | face_depth[i] = 0; |
| 716 | for (t = 0; t < fp->nverts; t++) |
| 717 | face_depth[i] += Robot_points[fp->vertnums[t]].p3_z; |
| 718 | |
| 719 | face_depth[i] /= fp->nverts; |
| 720 | |
| 721 | // initialize order list |
| 722 | model_render_order[rcount] = i; |
| 723 | |
| 724 | rcount++; |
| 725 | |
| 726 | ASSERT(rcount < MAX_POLYGON_VECS); |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | // Sort the faces |
| 731 | qsort(model_render_order, rcount, sizeof(*model_render_order), |
| 732 | (int (*)(const void *, const void *))ModelFaceSortFunc); |
| 733 | |
| 734 | for (i = rcount - 1; i >= 0; i--) { |
| 735 | int facenum = model_render_order[i]; |
| 736 | |
| 737 | RenderSubmodelFace(pm, sm, facenum); |
| 738 | } |
| 739 | } |
| 740 | void RenderSubmodelFacesUnsorted(poly_model *pm, bsp_info *sm) { |
| 741 | int i; |
| 742 | int modelnum = sm - pm->submodel; |
no test coverage detected