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

Function DeleteRoomFace

editor/Erooms.cpp:1697–1786  ·  view source on GitHub ↗

Delete a face from a room Parameters: rp - the room the face is in facenum - the face to be deleted

Source from the content-addressed store, hash-verified

1695// Parameters: rp - the room the face is in
1696// facenum - the face to be deleted
1697void DeleteRoomFace(room *rp, int facenum, bool delete_unused_verts) {
1698 int p, f, i, t;
1699 face *newfaces;
1700
1701 // Check for trigger on this face
1702 if (rp->faces[facenum].flags & FF_HAS_TRIGGER)
1703 DeleteTrigger(ROOMNUM(rp), facenum);
1704
1705 // Adjust face numbers in portals
1706 for (p = 0; p < rp->num_portals; p++) {
1707 portal *pp = &rp->portals[p];
1708 ASSERT(pp->portal_face != facenum);
1709 if (pp->portal_face > facenum)
1710 pp->portal_face--;
1711 }
1712
1713 // Adjust face numbers in triggers
1714 for (t = 0; t < Num_triggers; t++) {
1715 trigger *tp = &Triggers[t];
1716 if (tp->roomnum == ROOMNUM(rp)) {
1717 ASSERT(tp->facenum != facenum);
1718 if (tp->facenum > facenum)
1719 tp->facenum--;
1720 }
1721 }
1722
1723 // Allocate new face list
1724 newfaces = (face *)mem_malloc(sizeof(*newfaces) * (rp->num_faces - 1));
1725 ASSERT(newfaces != NULL);
1726
1727 // Copy faces over
1728 for (f = 0; f < facenum; f++)
1729 newfaces[f] = rp->faces[f];
1730 for (f++; f < rp->num_faces; f++)
1731 newfaces[f - 1] = rp->faces[f];
1732
1733#ifdef NEWEDITOR
1734 // Decrement texture usage
1735 if (ROOMNUM(rp) < MAX_ROOMS) {
1736 LevelTexDecrementTexture(rp->faces[facenum].tmap);
1737 //@@RoomTexDecrementTexture(rp->faces[facenum].tmap,m_Textures_in_use,false);
1738 } else {
1739 // TODO: for room tab, replace second line with first
1740 ned_MarkTextureInUse(rp->faces[facenum].tmap, false);
1741 //@@RoomTexDecrementTexture(rp->faces[facenum].tmap,m_Textures_in_use);
1742 }
1743#endif
1744
1745 // Free deleted face memeory
1746 FreeRoomFace(&rp->faces[facenum]);
1747
1748 // Free old face list
1749 mem_free(rp->faces);
1750
1751 // Use new face list
1752 rp->faces = newfaces;
1753 rp->num_faces--;
1754

Callers 14

RemoveDuplicateFacesFunction · 0.85
FixDegenerateFacesFunction · 0.85
AttachGroupFunction · 0.85
OnTrigDeleteMethod · 0.85
OnRoomDeleteFaceMethod · 0.85
OnClearVolumetricRoomMethod · 0.85
AttachRoomFunction · 0.85
CombineFacesFunction · 0.85
TriangulateFaceFunction · 0.85
CombineRoomsFunction · 0.85
SplitFaceFunction · 0.85

Calls 3

DeleteTriggerFunction · 0.85
FreeRoomFaceFunction · 0.85
DeleteUnusedRoomVertsFunction · 0.85

Tested by

no test coverage detected