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

Function CM_SetBorderInward

code/qcommon/cm_patch.cpp:708–777  ·  view source on GitHub ↗

=================== CM_SetBorderInward =================== */

Source from the content-addressed store, hash-verified

706===================
707*/
708static void CM_SetBorderInward( facet_t *facet, cGrid_t *grid, int gridPlanes[CM_MAX_GRID_SIZE][CM_MAX_GRID_SIZE][2],
709 int i, int j, int which ) {
710 int k, l;
711 float *points[4];
712 int numPoints;
713
714 switch ( which ) {
715 case -1:
716 points[0] = grid->points[i][j];
717 points[1] = grid->points[i+1][j];
718 points[2] = grid->points[i+1][j+1];
719 points[3] = grid->points[i][j+1];
720 numPoints = 4;
721 break;
722 case 0:
723 points[0] = grid->points[i][j];
724 points[1] = grid->points[i+1][j];
725 points[2] = grid->points[i+1][j+1];
726 numPoints = 3;
727 break;
728 case 1:
729 points[0] = grid->points[i+1][j+1];
730 points[1] = grid->points[i][j+1];
731 points[2] = grid->points[i][j];
732 numPoints = 3;
733 break;
734 default:
735 Com_Error( ERR_FATAL, "CM_SetBorderInward: bad parameter" );
736 numPoints = 0;
737 break;
738 }
739
740 for ( k = 0 ; k < facet->numBorders ; k++ ) {
741 int front, back;
742
743 front = 0;
744 back = 0;
745
746 for ( l = 0 ; l < numPoints ; l++ ) {
747 int side;
748
749 side = CM_PointOnPlaneSide( points[l], facet->borderPlanes[k] );
750 if ( side == SIDE_FRONT ) {
751 front++;
752 } if ( side == SIDE_BACK ) {
753 back++;
754 }
755 }
756
757 if ( front && !back ) {
758 facet->borderInward[k] = qtrue;
759 } else if ( back && !front ) {
760 facet->borderInward[k] = qfalse;
761 } else if ( !front && !back ) {
762 // flat side border
763 facet->borderPlanes[k] = -1;
764 } else {
765 // bisecting side border

Callers 1

CM_PatchCollideFromGridFunction · 0.70

Calls 4

VectorCopyFunction · 0.85
Com_ErrorFunction · 0.70
CM_PointOnPlaneSideFunction · 0.70
Com_DPrintfFunction · 0.70

Tested by

no test coverage detected