returns the index in the face_verts array for the topmost point on this face
| 631 | |
| 632 | // returns the index in the face_verts array for the topmost point on this face |
| 633 | int HTextureGetTopVertexForFace(int roomnum, int facenum) { |
| 634 | matrix face_matrix, trans_matrix; |
| 635 | vector fvec; |
| 636 | vector avg_vert; |
| 637 | vector verts[MAX_VERTS_PER_FACE]; |
| 638 | |
| 639 | ASSERT(Rooms[roomnum].used); |
| 640 | ASSERT(Rooms[roomnum].faces[facenum].num_verts >= 3); |
| 641 | |
| 642 | // find the center point of this face |
| 643 | vm_MakeZero(&avg_vert); |
| 644 | for (int i = 0; i < Rooms[roomnum].faces[facenum].num_verts; i++) |
| 645 | avg_vert += Rooms[roomnum].verts[Rooms[roomnum].faces[facenum].face_verts[i]]; |
| 646 | |
| 647 | avg_vert /= i; |
| 648 | |
| 649 | // Make the orientation matrix |
| 650 | fvec = Rooms[roomnum].faces[facenum].normal; |
| 651 | |
| 652 | vm_VectorToMatrix(&face_matrix, &fvec, NULL, NULL); |
| 653 | // Make the transformation matrix |
| 654 | |
| 655 | angvec avec; |
| 656 | vm_ExtractAnglesFromMatrix(&avec, &face_matrix); |
| 657 | vm_AnglesToMatrix(&trans_matrix, avec.p, avec.h, avec.b); |
| 658 | |
| 659 | // Rotate all the points |
| 660 | for (i = 0; i < Rooms[roomnum].faces[facenum].num_verts; i++) { |
| 661 | vector vert = Rooms[roomnum].verts[Rooms[roomnum].faces[facenum].face_verts[i]]; |
| 662 | vector rot_vert; |
| 663 | |
| 664 | vert -= avg_vert; |
| 665 | vm_MatrixMulVector(&rot_vert, &vert, &trans_matrix); |
| 666 | |
| 667 | verts[i] = rot_vert; |
| 668 | } |
| 669 | |
| 670 | // Find top most point |
| 671 | int topmost_point = -1; |
| 672 | float topmost_y = -900000.0f; // a big number |
| 673 | |
| 674 | for (i = 0; i < Rooms[roomnum].faces[facenum].num_verts; i++) { |
| 675 | if (verts[i].y > topmost_y) { |
| 676 | topmost_point = i; |
| 677 | topmost_y = verts[i].y; |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | ASSERT(topmost_point != -1); |
| 682 | |
| 683 | return topmost_point; |
| 684 | } |
| 685 | |
| 686 | // returns the index in the face_verts array for the rightmost point on this face |
| 687 | int HTextureGetRightVertexForFace(int roomnum, int facenum) { |
nothing calls this directly
no test coverage detected