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

Method OnTrigAddFloating

editor/TriggerDialog.cpp:501–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499#define TRIG_DEFAULT_SIZE 10.0
500
501void CTriggerDialog::OnTrigAddFloating() {
502 int facenum, vertnum;
503 room *rp;
504 face *fp;
505 vector center;
506 fvi_query fq;
507 fvi_info hit_info;
508 int fate;
509
510 if (OBJECT_OUTSIDE(Viewer_object)) {
511 OutrageMessageBox("Sorry, this operation does not yet work in the terrain.");
512 return;
513 }
514
515 char name[TRIG_NAME_LEN + 1] = "";
516
517 if (!InputString(name, sizeof(name), "Trigger Name", "Enter a name for this trigger"))
518 return;
519
520 // Get center point of new face
521 center = Viewer_object->pos + (Viewer_object->orient.fvec * TRIG_PLACE_DIST);
522
523 // Make sure the viewer in in the mine
524 if (Viewer_object->flags & OF_OUTSIDE_MINE)
525 goto bad_place;
526
527 // Check if position ok
528 fq.p0 = &Viewer_object->pos;
529 fq.startroom = Viewer_object->roomnum;
530 fq.p1 = &center;
531 fq.rad = 0;
532 fq.thisobjnum = -1;
533 fq.ignore_obj_list = NULL;
534 fq.flags = 0;
535 fate = fvi_FindIntersection(&fq, &hit_info);
536
537 // Bail if there's something in the way, or if the center point is outside
538 if ((fate != HIT_NONE) || ROOMNUM_OUTSIDE(hit_info.hit_room)) {
539
540 bad_place:;
541 OutrageMessageBox("You cannot place a floating trigger here.");
542 return;
543 }
544
545 // Get pointer to room the trigger is in
546 rp = &Rooms[hit_info.hit_room];
547
548 // Create a new face & new verts
549 facenum = RoomAddFaces(rp, 1);
550 vertnum = RoomAddVertices(rp, 4);
551 fp = &rp->faces[facenum];
552 InitRoomFace(fp, 4);
553
554 // Set the vertices for the new face
555 rp->verts[vertnum] =
556 center - (Viewer_object->orient.rvec * TRIG_DEFAULT_SIZE) + (Viewer_object->orient.uvec * TRIG_DEFAULT_SIZE);
557 rp->verts[vertnum + 1] =
558 center + (Viewer_object->orient.rvec * TRIG_DEFAULT_SIZE) + (Viewer_object->orient.uvec * TRIG_DEFAULT_SIZE);

Callers

nothing calls this directly

Calls 10

OutrageMessageBoxFunction · 0.85
InputStringFunction · 0.85
fvi_FindIntersectionFunction · 0.85
RoomAddFacesFunction · 0.85
RoomAddVerticesFunction · 0.85
InitRoomFaceFunction · 0.85
ComputeFaceNormalFunction · 0.85
AddTriggerFunction · 0.85
SetCurroomFromTriggerFunction · 0.85

Tested by

no test coverage detected