================== CM_AddFacetBevels ================== */
| 836 | ================== |
| 837 | */ |
| 838 | void CM_AddFacetBevels( facet_t *facet ) { |
| 839 | |
| 840 | int i, j, k, l; |
| 841 | int axis, dir, order, flipped; |
| 842 | float plane[4], d, newplane[4]; |
| 843 | winding_t *w, *w2; |
| 844 | vec3_t mins, maxs, vec, vec2; |
| 845 | |
| 846 | #ifndef ADDBEVELS |
| 847 | return; |
| 848 | #endif |
| 849 | |
| 850 | VectorCopy4( planes[ facet->surfacePlane ].plane, plane ); |
| 851 | |
| 852 | w = BaseWindingForPlane( plane, plane[3] ); |
| 853 | for ( j = 0 ; j < facet->numBorders && w ; j++ ) { |
| 854 | if (facet->borderPlanes[j] == facet->surfacePlane) continue; |
| 855 | VectorCopy4( planes[ facet->borderPlanes[j] ].plane, plane ); |
| 856 | |
| 857 | if ( !facet->borderInward[j] ) { |
| 858 | VectorSubtract( vec3_origin, plane, plane ); |
| 859 | plane[3] = -plane[3]; |
| 860 | } |
| 861 | |
| 862 | ChopWindingInPlace( &w, plane, plane[3], 0.1f ); |
| 863 | } |
| 864 | if ( !w ) { |
| 865 | return; |
| 866 | } |
| 867 | |
| 868 | WindingBounds(w, mins, maxs); |
| 869 | |
| 870 | // add the axial planes |
| 871 | order = 0; |
| 872 | for ( axis = 0 ; axis < 3 ; axis++ ) |
| 873 | { |
| 874 | for ( dir = -1 ; dir <= 1 ; dir += 2, order++ ) |
| 875 | { |
| 876 | VectorClear(plane); |
| 877 | plane[axis] = dir; |
| 878 | if (dir == 1) { |
| 879 | plane[3] = maxs[axis]; |
| 880 | } |
| 881 | else { |
| 882 | plane[3] = -mins[axis]; |
| 883 | } |
| 884 | //if it's the surface plane |
| 885 | if (CM_PlaneEqual(&planes[facet->surfacePlane], plane, &flipped)) { |
| 886 | continue; |
| 887 | } |
| 888 | // see if the plane is allready present |
| 889 | for ( i = 0 ; i < facet->numBorders ; i++ ) { |
| 890 | if (CM_PlaneEqual(&planes[facet->borderPlanes[i]], plane, &flipped)) |
| 891 | break; |
| 892 | } |
| 893 | |
| 894 | if ( i == facet->numBorders ) { |
| 895 | if (facet->numBorders > 4 + 6 + 16) Com_Printf(S_COLOR_RED"ERROR: too many bevels\n"); |
no test coverage detected