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

Function EBNode_InsertNodeOnEdge

editor/ebnode.cpp:724–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

722}
723
724int EBNode_InsertNodeOnEdge(int spnt, int sroom, int epnt, int eroom) {
725 int i;
726
727 BNode_verified = false;
728
729 bn_list *snlist;
730 snlist = BNode_GetBNListPtr(sroom);
731 bn_list *enlist;
732 enlist = BNode_GetBNListPtr(eroom);
733
734 bool f_exists = false;
735 int e_index;
736
737 // Check to see if this edge already exists
738 for (i = 0; i < snlist->nodes[spnt].num_edges; i++) {
739 if (snlist->nodes[spnt].edges[i].end_index == epnt && snlist->nodes[spnt].edges[i].end_room == eroom) {
740 e_index = i;
741 f_exists = true;
742 break;
743 }
744 }
745
746 ASSERT(f_exists);
747
748 vector new_pos = (snlist->nodes[spnt].pos + enlist->nodes[epnt].pos) / 2.0f;
749 fvi_info hit_info;
750 hit_info.hit_room = sroom;
751
752 if (sroom != eroom) {
753 fvi_query fq;
754 int fate;
755
756 // shoot a ray from the light position to the current vertex
757 fq.p0 = &snlist->nodes[spnt].pos;
758 fq.p1 = &enlist->nodes[epnt].pos;
759 fq.startroom = (sroom > Highest_room_index && sroom <= Highest_room_index + 8)
760 ? GetTerrainRoomFromPos(&snlist->nodes[spnt].pos)
761 : sroom;
762
763 fq.rad = 0.0f;
764 fq.flags = FQ_IGNORE_RENDER_THROUGH_PORTALS;
765 fq.thisobjnum = -1;
766 fq.ignore_obj_list = NULL;
767
768 fate = fvi_FindIntersection(&fq, &hit_info);
769
770 if (fate != HIT_NONE) {
771 OutrageMessageBox("You can only do this function if the 2 nodes can\nsee each other or are in the same room.\n");
772 return -1;
773 }
774 }
775
776 int n_index = EBNode_AddNode(hit_info.hit_room, &new_pos, false, false);
777 EBNode_AddEdge(n_index, hit_info.hit_room, spnt, sroom);
778 EBNode_AddEdge(n_index, hit_info.hit_room, epnt, eroom);
779
780 EBNode_RemoveEdge(epnt, eroom, spnt, sroom);
781

Callers 2

OnAinInsertNodeOnEdgeMethod · 0.85
OnIenavButtonMethod · 0.85

Calls 7

BNode_GetBNListPtrFunction · 0.85
GetTerrainRoomFromPosFunction · 0.85
fvi_FindIntersectionFunction · 0.85
OutrageMessageBoxFunction · 0.85
EBNode_AddNodeFunction · 0.85
EBNode_AddEdgeFunction · 0.85
EBNode_RemoveEdgeFunction · 0.85

Tested by

no test coverage detected