================== CM_EdgePlaneNum ================== */
| 629 | ================== |
| 630 | */ |
| 631 | static 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]; |
no test coverage detected