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

Function AddRoom

editor/HRoom.cpp:443–536  ·  view source on GitHub ↗

Adds a room at the current room/face. The room is created by extuding out from the current face

Source from the content-addressed store, hash-verified

441
442// Adds a room at the current room/face. The room is created by extuding out from the current face
443void AddRoom() {
444 room *rp;
445 face *cfp;
446 int cnv, nfaces;
447 vector room_delta;
448 int i;
449
450 // Get values from current room & face
451 cfp = &Curroomp->faces[Curface]; // pointer to current face
452 cnv = cfp->num_verts; // number of verts in current face
453
454 // Check for portal already here
455 if (cfp->portal_num != -1) {
456 OutrageMessageBox("Can't add room: There is already a connection at the current room:face.");
457 return;
458 }
459
460 // Get values for new room
461 nfaces = cnv + 2;
462
463 // Get a pointer to our room
464 rp = CreateNewRoom(cnv * 2, nfaces, 0);
465 if (rp == NULL) {
466 OutrageMessageBox("Cannot add room: No free rooms.");
467 return;
468 }
469
470 // Compute delta vector
471 room_delta = cfp->normal * -DEFAULT_ROOM_LENGTH;
472
473 // Set the vertices for the room
474 for (i = 0; i < cnv; i++) {
475 rp->verts[i] = Curroomp->verts[cfp->face_verts[cnv - 1 - i]];
476 rp->verts[cnv + i] = rp->verts[i] + room_delta;
477 }
478
479 // Set the faces for the room
480 InitRoomFace(&rp->faces[0], cnv);
481 for (i = 0; i < cnv; i++)
482 rp->faces[0].face_verts[i] = i;
483
484 InitRoomFace(&rp->faces[1], cnv);
485 for (i = 0; i < cnv; i++)
486 rp->faces[1].face_verts[i] = cnv * 2 - 1 - i;
487
488 for (i = 0; i < nfaces - 2; i++) {
489 InitRoomFace(&rp->faces[i + 2], 4);
490 rp->faces[i + 2].face_verts[0] = i;
491 rp->faces[i + 2].face_verts[1] = i + cnv;
492 rp->faces[i + 2].face_verts[2] = ((i + 1) % cnv) + cnv;
493 rp->faces[i + 2].face_verts[3] = (i + 1) % cnv;
494 }
495
496#ifndef NEWEDITOR
497 // Set normals & textures for each face
498 for (i = 0; i < nfaces; i++) {
499 if (!ComputeFaceNormal(rp, i))
500 Int3(); // Bad! Get Matt!

Callers 1

OnRoomAddMethod · 0.85

Calls 6

OutrageMessageBoxFunction · 0.85
CreateNewRoomFunction · 0.85
InitRoomFaceFunction · 0.85
ComputeFaceNormalFunction · 0.85
HTextureApplyToRoomFaceFunction · 0.85
AssignDefaultUVsToRoomFunction · 0.85

Tested by

no test coverage detected