MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / FindSharedEdgeAcrossRooms

Function FindSharedEdgeAcrossRooms

editor/Erooms.cpp:1587–1623  ·  view source on GitHub ↗

Finds a shared edge, if one exists, between two faces in different rooms Parameters: rp0,rp1 - pointers to the two rooms face0,face1 - the face numbers in rp0 & rp1, respectively vn0,vn1 - filled in with the vertex numbers of the edge. These vert numbers are relative to their own faces. The shared edge is verts on face 0, and on face 1 Returns: true if a shared

Source from the content-addressed store, hash-verified

1585//verts <vn0,vn0+1> on face 0, and <vn1+1,vn1> on face 1 Returns: true if a shared edge was found, else
1586// false
1587bool FindSharedEdgeAcrossRooms(room *rp0, int face0, room *rp1, int face1, int *vn0, int *vn1) {
1588 int i, j;
1589 vector *va0, *vb0, *va1, *vb1;
1590 face *fp0, *fp1;
1591
1592 // Get pointers to the two faces
1593 fp0 = &rp0->faces[face0];
1594 fp1 = &rp1->faces[face1];
1595
1596 // Go through each edge in first face
1597 for (i = 0; i < fp0->num_verts; i++) {
1598
1599 // Get edge verts - <va0,vb0> is edge on first face
1600 va0 = &rp0->verts[fp0->face_verts[i]];
1601 vb0 = &rp0->verts[fp0->face_verts[(i + 1) % fp0->num_verts]];
1602
1603 // Check against second face
1604 for (j = 0; j < fp1->num_verts; j++) {
1605
1606 // Get edge verts - <va1,vb1> is edge on second face
1607 va1 = &rp1->verts[fp1->face_verts[j]];
1608 vb1 = &rp1->verts[fp1->face_verts[(j + 1) % fp1->num_verts]];
1609
1610 if (PointsAreSame(va0, va1) && PointsAreSame(vb0, vb1)) // this shouldn't happen
1611 Int3();
1612
1613 if (PointsAreSame(va0, vb1) && PointsAreSame(vb0, va1)) { // found match!
1614 *vn0 = i;
1615 *vn1 = j;
1616 return 1;
1617 }
1618 }
1619 }
1620
1621 // Didn't find an edge, so return error
1622 return 0;
1623}
1624
1625// Delete a vertex from a room. Assumes the vertex is unused.
1626// Parameters: rp - pointer to room

Callers 1

HTexturePropagateToFaceFunction · 0.85

Calls 1

PointsAreSameFunction · 0.85

Tested by

no test coverage detected