Use structured bindings for create_abs_vertex_lists

This commit is contained in:
Kp 2021-11-01 03:37:20 +00:00
parent 6fefeadf09
commit 0044c010ad
3 changed files with 11 additions and 26 deletions

View file

@ -247,9 +247,7 @@ static int check_line_to_face(vms_vector &newp, const vms_vector &p0, const vms_
auto &s = seg.sides[side];
const vms_vector &norm = s.normals[facenum];
const auto v = create_abs_vertex_lists(seg, s, side);
const auto &num_faces = v.first;
const auto &vertex_list = v.second;
const auto &&[num_faces, vertex_list] = create_abs_vertex_lists(seg, s, side);
//use lowest point number
vertnum_t vertnum;
@ -327,8 +325,7 @@ static int special_check_line_to_face(vms_vector &newp, const vms_vector &p0, co
//calc some basic stuff
const auto v = create_abs_vertex_lists(seg, s, side);
const auto &vertex_list = v.second;
const auto &&vertex_list = create_abs_vertex_lists(seg, s, side).second;
auto move_vec = vm_vec_sub(p1,p0);
//figure out which edge(s) to check against
@ -1260,9 +1257,7 @@ static sphere_intersects_wall_result sphere_intersects_wall(fvcsegptridx &vcsegp
//did we go through this wall/door?
auto &sidep = sseg.sides[side];
const auto v = create_abs_vertex_lists(sseg, sidep, side);
const auto &num_faces = v.first;
const auto &vertex_list = v.second;
const auto &&[num_faces, vertex_list] = create_abs_vertex_lists(sseg, sidep, side);
face_hit_type = check_sphere_to_face(pnt, sidep.normals[face],
face,((num_faces==1)?4:3),rad,vertex_list);

View file

@ -301,9 +301,7 @@ segmasks get_seg_masks(fvcvertptr &vcvertptr, const vms_vector &checkp, const sh
// Get number of faces on this side, and at vertex_list, store vertices.
// If one face, then vertex_list indicates a quadrilateral.
// If two faces, then 0,1,2 define one triangle, 3,4,5 define the second.
const auto v = create_abs_vertex_lists(seg, s, sn);
const auto &num_faces = v.first;
const auto &vertex_list = v.second;
const auto &&[num_faces, vertex_list] = create_abs_vertex_lists(seg, s, sn);
//ok...this is important. If a side has 2 faces, we need to know if
//those faces form a concave or convex side. If the side pokes out,
@ -400,9 +398,7 @@ static uint8_t get_side_dists(fvcvertptr &vcvertptr, const vms_vector &checkp, c
// Get number of faces on this side, and at vertex_list, store vertices.
// If one face, then vertex_list indicates a quadrilateral.
// If two faces, then 0,1,2 define one triangle, 3,4,5 define the second.
const auto v = create_abs_vertex_lists(segnum, s, sn);
const auto &num_faces = v.first;
const auto &vertex_list = v.second;
const auto &&[num_faces, vertex_list] = create_abs_vertex_lists(segnum, s, sn);
//ok...this is important. If a side has 2 faces, we need to know if
//those faces form a concave or convex side. If the side pokes out,
@ -517,9 +513,7 @@ int check_segment_connections(void)
{
range_for (const int sidenum, xrange(6u)) {
#ifndef NDEBUG
const auto v = create_abs_vertex_lists(seg, sidenum);
const auto &num_faces = v.first;
const auto &vertex_list = v.second;
const auto &&[num_faces, vertex_list] = create_abs_vertex_lists(seg, sidenum);
#endif
const auto csegnum = seg->shared_segment::children[sidenum];
if (!IS_CHILD(csegnum))
@ -540,9 +534,7 @@ int check_segment_connections(void)
}
#ifndef NDEBUG
const auto cv = create_abs_vertex_lists(cseg, csidenum);
const auto &con_num_faces = cv.first;
const auto &con_vertex_list = cv.second;
const auto &&[con_num_faces, con_vertex_list] = create_abs_vertex_lists(cseg, csidenum);
if (con_num_faces != num_faces) {
LevelError("Segment #%u side %u: wrong faces: con_num_faces=%" PRIuFAST32 " num_faces=%" PRIuFAST32 ".", seg.get_unchecked_index(), sidenum, con_num_faces, num_faces);
@ -1456,10 +1448,9 @@ void create_walls_on_side(fvcvertptr &vcvertptr, shared_segment &sp, const unsig
int s0,s1;
const auto v = create_abs_vertex_lists(sp, s, sidenum);
const auto &vertex_list = v.second;
Assert(v.first == 2);
const auto &&[num_faces, vertex_list] = create_abs_vertex_lists(sp, s, sidenum);
assert(num_faces == 2);
(void)num_faces;
auto &vvn = *vcvertptr(min(vertex_list[0],vertex_list[2]));

View file

@ -760,8 +760,7 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
auto &s = orig_segp.s.sides[sidenum];
const auto v = create_abs_vertex_lists(orig_segp, s, sidenum);
const auto &vertex_list = v.second;
const auto &&vertex_list = create_abs_vertex_lists(orig_segp, s, sidenum).second;
//let's pretend this wall is not triangulated
const auto b = begin(vertex_list);