MCPcopy Create free account
hub / github.com/JACoders/OpenJK / CM_AddFacetBevels

Function CM_AddFacetBevels

code/qcommon/cm_patch.cpp:838–1001  ·  view source on GitHub ↗

================== CM_AddFacetBevels ================== */

Source from the content-addressed store, hash-verified

836==================
837*/
838void 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");

Callers 1

CM_PatchCollideFromGridFunction · 0.70

Calls 15

VectorCopy4Function · 0.85
VectorSubtractFunction · 0.85
VectorClearFunction · 0.85
VectorNormalizeFunction · 0.85
CrossProductFunction · 0.85
DotProductFunction · 0.85
BaseWindingForPlaneFunction · 0.70
ChopWindingInPlaceFunction · 0.70
WindingBoundsFunction · 0.70
CM_PlaneEqualFunction · 0.70
Com_PrintfFunction · 0.70
CM_FindPlane2Function · 0.70

Tested by

no test coverage detected