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

Function BuildBridge

editor/HRoom.cpp:1241–1369  ·  view source on GitHub ↗

Creates a new bridge room connecting two rooms Parameters: attroomp,attface - one end of the new room baseroom,baseface - the other end of the new room The new room is created by extruding from attroom/attface

Source from the content-addressed store, hash-verified

1239// baseroom,baseface - the other end of the new room
1240// The new room is created by extruding from attroom/attface
1241void BuildBridge(room *attroomp, int attface, room *baseroomp, int baseface) {
1242 room *newroomp;
1243 face *afp, *bfp;
1244 int nv, nfaces;
1245 vector delta_vec, bc, ac;
1246 vector *basevert; // a vertex on the base face
1247 int i;
1248 float cos, dist;
1249
1250 // Check that the two faces don't already have portals
1251 if (attroomp->faces[attface].portal_num != -1) {
1252 OutrageMessageBox("Cannot build bridge: There is already a portal at %d:%d", ROOMNUM(attroomp), attface);
1253 return;
1254 }
1255 if (baseroomp->faces[baseface].portal_num != -1) {
1256 OutrageMessageBox("Cannot build bridge: There is already a portal at %d:%d", ROOMNUM(baseroomp), baseface);
1257 return;
1258 }
1259
1260 // Get values from current room & face
1261 afp = &attroomp->faces[attface]; // pointer to attach face
1262 bfp = &baseroomp->faces[baseface]; // pointer to base face
1263 nv = afp->num_verts; // number of verts in attach face
1264 nfaces = nv + 2; // number of faces in new room
1265
1266 // Make sure all points on each face are on the front of the other face
1267 vector tnorm = -afp->normal;
1268 int t = CheckFaceToPlane(baseroomp, baseface, &attroomp->verts[afp->face_verts[0]], &tnorm);
1269 if (t != -1) {
1270 OutrageMessageBox("Can't build bridge: Vertex %d on %d:%d is behind %d:%d", t, ROOMNUM(baseroomp), baseface,
1271 ROOMNUM(attroomp), attface);
1272 return;
1273 }
1274 tnorm = -bfp->normal;
1275 t = CheckFaceToPlane(attroomp, attface, &baseroomp->verts[bfp->face_verts[0]], &tnorm);
1276 if (t != -1) {
1277 OutrageMessageBox("Can't build bridge: Vertex %d on %d:%d is behind %d:%d", t, ROOMNUM(attroomp), attface,
1278 ROOMNUM(baseroomp), baseface);
1279 return;
1280 }
1281
1282 // Compute normalized vector from attach face to base face
1283#ifndef NEWEDITOR
1284 ComputeCenterPointOnFace(&bc, baseroomp, baseface);
1285 ComputeCenterPointOnFace(&ac, attroomp, attface);
1286#else
1287 ComputeFaceBoundingCircle(&bc, baseroomp, baseface);
1288 ComputeFaceBoundingCircle(&ac, attroomp, attface);
1289#endif
1290 dist = vm_GetNormalizedDir(&delta_vec, &bc, &ac);
1291
1292 // Compute the cosine of the angle between our vector and the normal of the base face
1293 cos = delta_vec * bfp->normal;
1294
1295 // Get a pointer to a vertex on the base face
1296 basevert = &baseroomp->verts[bfp->face_verts[0]];
1297
1298 // Get a pointer to our room

Callers 1

OnRoomBuildBridgeMethod · 0.85

Calls 11

OutrageMessageBoxFunction · 0.85
CheckFaceToPlaneFunction · 0.85
ComputeCenterPointOnFaceFunction · 0.85
CreateNewRoomFunction · 0.85
InitRoomFaceFunction · 0.85
ResetRoomFaceNormalsFunction · 0.85
HTextureApplyToRoomFaceFunction · 0.85
AssignDefaultUVsToRoomFunction · 0.85
ClipFacePairFunction · 0.85
MatchPortalFacesFunction · 0.85
vm_GetNormalizedDirFunction · 0.50

Tested by

no test coverage detected