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

Function make_trigger_face_list

physics/findintersection.cpp:2527–2594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2525}
2526
2527void make_trigger_face_list(int last_sim_faces) {
2528 int num_real_collisions;
2529 int x;
2530
2531 num_real_collisions = last_sim_faces;
2532
2533 ASSERT(Fvi_num_recorded_faces <= MAX_RECORDED_FACES);
2534
2535 for (x = last_sim_faces; x < Fvi_num_recorded_faces; x++) {
2536 vector face_normal;
2537 vector *vertex_ptr_list[MAX_VERTS_PER_FACE];
2538 int face_hit_type;
2539 vector wall_norm;
2540 vector colp;
2541 vector hit_point;
2542 int16_t count;
2543 room *cur_room = &Rooms[Fvi_recorded_faces[x].room_index];
2544 int i = Fvi_recorded_faces[x].face_index;
2545 float cur_dist;
2546
2547 for (count = 0; count < cur_room->faces[i].num_verts; count++)
2548 vertex_ptr_list[count] = &cur_room->verts[cur_room->faces[i].face_verts[count]];
2549 /*
2550 mprintf(0, "FVI:In trigger %f to %f crossed %f\n",
2551 fvi_query_ptr->p0->z,
2552 fvi_hit_data_ptr->hit_pnt.z,
2553 vertex_ptr_list[0]->z);
2554 */
2555
2556 face_normal = cur_room->faces[i].normal;
2557
2558 face_hit_type =
2559 check_line_to_face(&hit_point, &colp, &cur_dist, &wall_norm, fvi_query_ptr->p0, &fvi_hit_data_ptr->hit_pnt,
2560 &face_normal, vertex_ptr_list, cur_room->faces[i].num_verts, 0.0f);
2561
2562 if (face_hit_type) {
2563 // mprintf(0, "FVI:hit trigger\n");
2564 Fvi_recorded_faces[num_real_collisions].face_index = i;
2565 Fvi_recorded_faces[num_real_collisions++].room_index = Fvi_recorded_faces[x].room_index;
2566 }
2567 }
2568
2569 if (!ROOMNUM_OUTSIDE(fvi_query_ptr->startroom) && !ROOMNUM_OUTSIDE(fvi_hit_data_ptr->hit_room)) {
2570 int i;
2571
2572 for (i = 0; i < Rooms[fvi_query_ptr->startroom].num_portals; i++) {
2573 if (Rooms[fvi_query_ptr->startroom].portals[i].croom == fvi_hit_data_ptr->hit_room) {
2574 int j;
2575 bool f_found = false;
2576
2577 for (j = 0; j < num_real_collisions; j++) {
2578 if (Fvi_recorded_faces[j].face_index == Rooms[fvi_query_ptr->startroom].portals[i].portal_face &&
2579 Fvi_recorded_faces[j].room_index == fvi_query_ptr->startroom) {
2580 f_found = true;
2581 break;
2582 }
2583 }
2584

Callers 1

fvi_FindIntersectionFunction · 0.85

Calls 1

check_line_to_faceFunction · 0.85

Tested by

no test coverage detected