returns the index in the face_verts array for the leftmost point on this face
| 578 | |
| 579 | // returns the index in the face_verts array for the leftmost point on this face |
| 580 | int HTextureGetLeftVertexForFace(int roomnum, int facenum) { |
| 581 | matrix face_matrix, trans_matrix; |
| 582 | vector fvec; |
| 583 | vector avg_vert; |
| 584 | vector verts[MAX_VERTS_PER_FACE]; |
| 585 | |
| 586 | ASSERT(Rooms[roomnum].used); |
| 587 | ASSERT(Rooms[roomnum].faces[facenum].num_verts >= 3); |
| 588 | |
| 589 | // find the center point of this face |
| 590 | vm_MakeZero(&avg_vert); |
| 591 | for (int i = 0; i < Rooms[roomnum].faces[facenum].num_verts; i++) |
| 592 | avg_vert += Rooms[roomnum].verts[Rooms[roomnum].faces[facenum].face_verts[i]]; |
| 593 | |
| 594 | avg_vert /= i; |
| 595 | |
| 596 | // Make the orientation matrix |
| 597 | fvec = Rooms[roomnum].faces[facenum].normal; |
| 598 | |
| 599 | vm_VectorToMatrix(&face_matrix, &fvec, NULL, NULL); |
| 600 | // Make the transformation matrix |
| 601 | |
| 602 | angvec avec; |
| 603 | vm_ExtractAnglesFromMatrix(&avec, &face_matrix); |
| 604 | vm_AnglesToMatrix(&trans_matrix, avec.p, avec.h, avec.b); |
| 605 | |
| 606 | // Rotate all the points |
| 607 | for (i = 0; i < Rooms[roomnum].faces[facenum].num_verts; i++) { |
| 608 | vector vert = Rooms[roomnum].verts[Rooms[roomnum].faces[facenum].face_verts[i]]; |
| 609 | vector rot_vert; |
| 610 | |
| 611 | vert -= avg_vert; |
| 612 | vm_MatrixMulVector(&rot_vert, &vert, &trans_matrix); |
| 613 | |
| 614 | verts[i] = rot_vert; |
| 615 | } |
| 616 | |
| 617 | // Find left most point |
| 618 | int leftmost_point = -1; |
| 619 | float leftmost_x = 900000.00f; // a big number |
| 620 | |
| 621 | for (i = 0; i < Rooms[roomnum].faces[facenum].num_verts; i++) { |
| 622 | if (verts[i].x < leftmost_x) { |
| 623 | leftmost_point = i; |
| 624 | leftmost_x = verts[i].x; |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | ASSERT(leftmost_point != -1); |
| 629 | return leftmost_point; |
| 630 | } |
| 631 | |
| 632 | // returns the index in the face_verts array for the topmost point on this face |
| 633 | int HTextureGetTopVertexForFace(int roomnum, int facenum) { |
nothing calls this directly
no test coverage detected