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

Function EBNode_MakeDefaultIntraRoomNodes

editor/ebnode.cpp:924–985  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

922}
923
924void EBNode_MakeDefaultIntraRoomNodes(int roomnum) {
925 int i, j;
926
927 room *rp = &Rooms[roomnum];
928
929 // Adds the nodes from portals
930 for (i = 0; i < rp->num_portals; i++) {
931 vector pos;
932 pos = rp->portals[i].path_pnt + rp->faces[rp->portals[i].portal_face].normal * 0.75f;
933 rp->portals[i].bnode_index = i;
934
935 EBNode_AddNode(roomnum, &pos, false, false);
936 }
937
938 // Adds a node for centerpoint of the room
939 EBNode_AddNode(roomnum, &rp->path_pnt, false, false);
940
941 // Add the edges
942 for (i = 0; i < rp->bn_info.num_nodes; i++) {
943 // Edges go both ways - always
944 for (j = i + 1; j < rp->bn_info.num_nodes; j++) {
945 // Check to see if the center is really close to this edge, if so - Dont make this edge
946 if (i < rp->bn_info.num_nodes - 1 && j < rp->bn_info.num_nodes - 1) {
947 vector vec = rp->portals[j].path_pnt - rp->portals[i].path_pnt;
948 vector cvec = rp->path_pnt - rp->portals[i].path_pnt;
949
950 float len = vm_NormalizeVector(&vec);
951 float cproj = cvec * vec;
952
953 if (len >= cproj && cproj >= 0.0f) {
954 vector cxline = cproj * vec;
955 vector dvec = rp->path_pnt - (rp->portals[i].path_pnt + cxline);
956
957 if (vm_GetMagnitude(&dvec) < 3.0f) {
958 continue;
959 }
960 }
961 }
962
963 fvi_info hit_info;
964 fvi_query fq;
965
966 // check to make sure it is still in the room and valid
967 fq.p0 = &Rooms[roomnum].bn_info.nodes[i].pos;
968 fq.p1 = &Rooms[roomnum].bn_info.nodes[j].pos;
969 fq.startroom = (roomnum > Highest_room_index && roomnum <= Highest_room_index + 8)
970 ? GetTerrainRoomFromPos(&Rooms[roomnum].bn_info.nodes[i].pos)
971 : roomnum;
972
973 fq.rad = 0.1f;
974 fq.flags = FQ_SOLID_PORTALS | FQ_NO_RELINK;
975 fq.thisobjnum = -1;
976 fq.ignore_obj_list = NULL;
977
978 if (fvi_FindIntersection(&fq, &hit_info) != HIT_NONE) {
979 continue;
980 }
981

Callers 1

EBNode_MakeFirstPassFunction · 0.85

Calls 6

EBNode_AddNodeFunction · 0.85
vm_NormalizeVectorFunction · 0.85
GetTerrainRoomFromPosFunction · 0.85
fvi_FindIntersectionFunction · 0.85
EBNode_AddEdgeFunction · 0.85
vm_GetMagnitudeFunction · 0.50

Tested by

no test coverage detected