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

Function CM_EdgePlaneNum

code/qcommon/cm_patch.cpp:631–701  ·  view source on GitHub ↗

================== CM_EdgePlaneNum ================== */

Source from the content-addressed store, hash-verified

629==================
630*/
631static int CM_EdgePlaneNum( cGrid_t *grid, int gridPlanes[CM_MAX_GRID_SIZE][CM_MAX_GRID_SIZE][2], int i, int j, int k ) {
632 float *p1, *p2;
633 vec3_t up;
634 int p;
635
636 switch ( k ) {
637 case 0: // top border
638 p1 = grid->points[i][j];
639 p2 = grid->points[i+1][j];
640 p = CM_GridPlane( gridPlanes, i, j, 0 );
641 if ( p == -1 ) {
642 return -1;
643 }
644 VectorMA( p1, 4, planes[ p ].plane, up );
645 return CM_FindPlane( p1, p2, up );
646
647 case 2: // bottom border
648 p1 = grid->points[i][j+1];
649 p2 = grid->points[i+1][j+1];
650 p = CM_GridPlane( gridPlanes, i, j, 1 );
651 if ( p == -1 ) {
652 return -1;
653 }
654 VectorMA( p1, 4, planes[ p ].plane, up );
655 return CM_FindPlane( p2, p1, up );
656
657 case 3: // left border
658 p1 = grid->points[i][j];
659 p2 = grid->points[i][j+1];
660 p = CM_GridPlane( gridPlanes, i, j, 1 );
661 if ( p == -1 ) {
662 return -1;
663 }
664 VectorMA( p1, 4, planes[ p ].plane, up );
665 return CM_FindPlane( p2, p1, up );
666
667 case 1: // right border
668 p1 = grid->points[i+1][j];
669 p2 = grid->points[i+1][j+1];
670 p = CM_GridPlane( gridPlanes, i, j, 0 );
671 if ( p == -1 ) {
672 return -1;
673 }
674 VectorMA( p1, 4, planes[ p ].plane, up );
675 return CM_FindPlane( p1, p2, up );
676
677 case 4: // diagonal out of triangle 0
678 p1 = grid->points[i+1][j+1];
679 p2 = grid->points[i][j];
680 p = CM_GridPlane( gridPlanes, i, j, 0 );
681 if ( p == -1 ) {
682 return -1;
683 }
684 VectorMA( p1, 4, planes[ p ].plane, up );
685 return CM_FindPlane( p1, p2, up );
686
687 case 5: // diagonal out of triangle 1
688 p1 = grid->points[i][j];

Callers 1

CM_PatchCollideFromGridFunction · 0.70

Calls 4

CM_GridPlaneFunction · 0.70
CM_FindPlaneFunction · 0.70
Com_ErrorFunction · 0.70
VectorMAFunction · 0.50

Tested by

no test coverage detected