Return vertex_array_list_t from create_abs_vertex_lists
This commit is contained in:
parent
601290e674
commit
1960a2ebad
|
@ -98,7 +98,14 @@ static inline std::pair<uint_fast32_t, vertex_array_list_t> create_all_vertex_li
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//like create_all_vertex_lists(), but generate absolute point numbers
|
//like create_all_vertex_lists(), but generate absolute point numbers
|
||||||
void create_abs_vertex_lists(int *num_faces, vertex_array_list_t &vertices, vcsegptr_t segnum, int sidenum);
|
uint_fast32_t create_abs_vertex_lists(vertex_array_list_t &vertices, vcsegptr_t segnum, int sidenum);
|
||||||
|
__attribute_warn_unused_result
|
||||||
|
static inline std::pair<uint_fast32_t, vertex_array_list_t> create_abs_vertex_lists(vcsegptr_t segnum, int sidenum)
|
||||||
|
{
|
||||||
|
vertex_array_list_t r;
|
||||||
|
auto n = create_abs_vertex_lists(r, segnum, sidenum);
|
||||||
|
return {n, r};
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
// Like create all vertex lists, but returns the vertnums (relative to
|
// Like create all vertex lists, but returns the vertnums (relative to
|
||||||
|
|
|
@ -238,14 +238,14 @@ static int check_line_to_face(vms_vector &newp,const vms_vector &p0,const vms_ve
|
||||||
{
|
{
|
||||||
int pli;
|
int pli;
|
||||||
const struct side *s=&seg->sides[side];
|
const struct side *s=&seg->sides[side];
|
||||||
vertex_array_list_t vertex_list;
|
|
||||||
int num_faces;
|
|
||||||
int vertnum;
|
int vertnum;
|
||||||
vms_vector norm;
|
vms_vector norm;
|
||||||
|
|
||||||
norm = seg->sides[side].normals[facenum];
|
norm = seg->sides[side].normals[facenum];
|
||||||
|
|
||||||
create_abs_vertex_lists(&num_faces, vertex_list, seg, side);
|
const auto v = create_abs_vertex_lists(seg, side);
|
||||||
|
const auto &num_faces = v.first;
|
||||||
|
const auto &vertex_list = v.second;
|
||||||
|
|
||||||
//use lowest point number
|
//use lowest point number
|
||||||
if (num_faces==2) {
|
if (num_faces==2) {
|
||||||
|
@ -314,14 +314,14 @@ static int special_check_line_to_face(vms_vector &newp,const vms_vector &p0,cons
|
||||||
{
|
{
|
||||||
fix edge_t=0,move_t=0,edge_t2=0,move_t2=0,closest_dist=0;
|
fix edge_t=0,move_t=0,edge_t2=0,move_t2=0,closest_dist=0;
|
||||||
fix edge_len=0,move_len=0;
|
fix edge_len=0,move_len=0;
|
||||||
vertex_array_list_t vertex_list;
|
int edgenum;
|
||||||
int num_faces,edgenum;
|
|
||||||
uint edgemask;
|
uint edgemask;
|
||||||
const struct side *s=&seg->sides[side];
|
const struct side *s=&seg->sides[side];
|
||||||
|
|
||||||
//calc some basic stuff
|
//calc some basic stuff
|
||||||
|
|
||||||
create_abs_vertex_lists(&num_faces, vertex_list, seg, side);
|
const auto v = create_abs_vertex_lists(seg, side);
|
||||||
|
const auto &vertex_list = v.second;
|
||||||
auto move_vec = vm_vec_sub(p1,p0);
|
auto move_vec = vm_vec_sub(p1,p0);
|
||||||
|
|
||||||
//figure out which edge(s) to check against
|
//figure out which edge(s) to check against
|
||||||
|
@ -1094,7 +1094,7 @@ void find_hitpoint_uv(fix *u,fix *v,const vms_vector &pnt,const vcsegptridx_t se
|
||||||
{
|
{
|
||||||
int num_faces;
|
int num_faces;
|
||||||
const side *side = &seg->sides[sidenum];
|
const side *side = &seg->sides[sidenum];
|
||||||
vertex_array_list_t vertex_list, vertnum_list;
|
vertex_array_list_t vertnum_list;
|
||||||
uvl uvls[3];
|
uvl uvls[3];
|
||||||
fix k0,k1;
|
fix k0,k1;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1109,7 +1109,8 @@ void find_hitpoint_uv(fix *u,fix *v,const vms_vector &pnt,const vcsegptridx_t se
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
create_abs_vertex_lists(&num_faces, vertex_list, seg, sidenum);
|
const auto vx = create_abs_vertex_lists(seg, sidenum);
|
||||||
|
const auto &vertex_list = vx.second;
|
||||||
create_all_vertnum_lists(&num_faces,vertnum_list,seg,sidenum);
|
create_all_vertnum_lists(&num_faces,vertnum_list,seg,sidenum);
|
||||||
|
|
||||||
//now the hard work.
|
//now the hard work.
|
||||||
|
@ -1218,12 +1219,11 @@ static int sphere_intersects_wall(const vms_vector &pnt,const vcsegptridx_t segn
|
||||||
|
|
||||||
if (facemask & bit) { //on the back of this face
|
if (facemask & bit) { //on the back of this face
|
||||||
int face_hit_type; //in what way did we hit the face?
|
int face_hit_type; //in what way did we hit the face?
|
||||||
int num_faces;
|
|
||||||
vertex_array_list_t vertex_list;
|
|
||||||
|
|
||||||
//did we go through this wall/door?
|
//did we go through this wall/door?
|
||||||
|
const auto v = create_abs_vertex_lists(seg, side);
|
||||||
create_abs_vertex_lists(&num_faces, vertex_list, seg, side);
|
const auto &num_faces = v.first;
|
||||||
|
const auto &vertex_list = v.second;
|
||||||
|
|
||||||
face_hit_type = check_sphere_to_face( pnt,&seg->sides[side],
|
face_hit_type = check_sphere_to_face( pnt,&seg->sides[side],
|
||||||
face,((num_faces==1)?4:3),rad,vertex_list);
|
face,((num_faces==1)?4:3),rad,vertex_list);
|
||||||
|
|
|
@ -239,53 +239,43 @@ void create_all_vertnum_lists(int *num_faces, vertex_array_list_t &vertnums, con
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// like create_all_vertex_lists(), but generate absolute point numbers
|
// like create_all_vertex_lists(), but generate absolute point numbers
|
||||||
void create_abs_vertex_lists(int *num_faces, vertex_array_list_t &vertices, const vcsegptr_t segp, int sidenum)
|
uint_fast32_t create_abs_vertex_lists(vertex_array_list_t &vertices, const vcsegptr_t segp, int sidenum)
|
||||||
{
|
{
|
||||||
auto &vp = segp->verts;
|
auto &vp = segp->verts;
|
||||||
auto sidep = &segp->sides[sidenum];
|
auto sidep = &segp->sides[sidenum];
|
||||||
const int *sv = Side_to_verts_int[sidenum];
|
const int *sv = Side_to_verts_int[sidenum];
|
||||||
switch (sidep->get_type()) {
|
switch (sidep->get_type()) {
|
||||||
case SIDE_IS_QUAD:
|
case SIDE_IS_QUAD:
|
||||||
|
|
||||||
vertices[0] = vp[sv[0]];
|
vertices[0] = vp[sv[0]];
|
||||||
vertices[1] = vp[sv[1]];
|
vertices[1] = vp[sv[1]];
|
||||||
vertices[2] = vp[sv[2]];
|
vertices[2] = vp[sv[2]];
|
||||||
vertices[3] = vp[sv[3]];
|
vertices[3] = vp[sv[3]];
|
||||||
|
return 1;
|
||||||
*num_faces = 1;
|
|
||||||
break;
|
|
||||||
case SIDE_IS_TRI_02:
|
case SIDE_IS_TRI_02:
|
||||||
*num_faces = 2;
|
|
||||||
|
|
||||||
vertices[0] = vp[sv[0]];
|
vertices[0] = vp[sv[0]];
|
||||||
vertices[1] = vp[sv[1]];
|
vertices[1] = vp[sv[1]];
|
||||||
vertices[2] = vp[sv[2]];
|
vertices[2] = vp[sv[2]];
|
||||||
|
|
||||||
vertices[3] = vp[sv[2]];
|
vertices[3] = vp[sv[2]];
|
||||||
vertices[4] = vp[sv[3]];
|
vertices[4] = vp[sv[3]];
|
||||||
vertices[5] = vp[sv[0]];
|
vertices[5] = vp[sv[0]];
|
||||||
|
|
||||||
//IMPORTANT: DON'T CHANGE THIS CODE WITHOUT CHANGING GET_SEG_MASKS(),
|
//IMPORTANT: DON'T CHANGE THIS CODE WITHOUT CHANGING GET_SEG_MASKS(),
|
||||||
//CREATE_ABS_VERTEX_LISTS(), CREATE_ALL_VERTEX_LISTS(), CREATE_ALL_VERTNUM_LISTS()
|
//CREATE_ABS_VERTEX_LISTS(), CREATE_ALL_VERTEX_LISTS(), CREATE_ALL_VERTNUM_LISTS()
|
||||||
break;
|
return 2;
|
||||||
case SIDE_IS_TRI_13:
|
case SIDE_IS_TRI_13:
|
||||||
*num_faces = 2;
|
|
||||||
|
|
||||||
vertices[0] = vp[sv[3]];
|
vertices[0] = vp[sv[3]];
|
||||||
vertices[1] = vp[sv[0]];
|
vertices[1] = vp[sv[0]];
|
||||||
vertices[2] = vp[sv[1]];
|
vertices[2] = vp[sv[1]];
|
||||||
|
|
||||||
vertices[3] = vp[sv[1]];
|
vertices[3] = vp[sv[1]];
|
||||||
vertices[4] = vp[sv[2]];
|
vertices[4] = vp[sv[2]];
|
||||||
vertices[5] = vp[sv[3]];
|
vertices[5] = vp[sv[3]];
|
||||||
|
|
||||||
//IMPORTANT: DON'T CHANGE THIS CODE WITHOUT CHANGING GET_SEG_MASKS()
|
//IMPORTANT: DON'T CHANGE THIS CODE WITHOUT CHANGING GET_SEG_MASKS()
|
||||||
//CREATE_ABS_VERTEX_LISTS(), CREATE_ALL_VERTEX_LISTS(), CREATE_ALL_VERTNUM_LISTS()
|
//CREATE_ABS_VERTEX_LISTS(), CREATE_ALL_VERTEX_LISTS(), CREATE_ALL_VERTNUM_LISTS()
|
||||||
break;
|
return 2;
|
||||||
default:
|
default:
|
||||||
throw side::illegal_type(segp, sidep);
|
throw side::illegal_type(segp, sidep);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,8 +285,6 @@ segmasks get_seg_masks(const vms_vector &checkp, const vcsegptridx_t segnum, fix
|
||||||
{
|
{
|
||||||
int sn,facebit,sidebit;
|
int sn,facebit,sidebit;
|
||||||
segmasks masks;
|
segmasks masks;
|
||||||
int num_faces;
|
|
||||||
vertex_array_list_t vertex_list;
|
|
||||||
|
|
||||||
if (segnum < 0 || segnum > Highest_segment_index)
|
if (segnum < 0 || segnum > Highest_segment_index)
|
||||||
Error("segnum == %hu (%i) in get_seg_masks() \ncheckp: %i, %i, %i, rad: %i \nfrom file: %s, line: %i \nMission: %s (%i) \nPlease report this bug.\n", static_cast<vcsegptridx_t::integral_type>(segnum), Highest_segment_index, checkp.x, checkp.y, checkp.z, rad, calling_file, calling_linenum, Current_mission_filename, Current_level_num);
|
Error("segnum == %hu (%i) in get_seg_masks() \ncheckp: %i, %i, %i, rad: %i \nfrom file: %s, line: %i \nMission: %s (%i) \nPlease report this bug.\n", static_cast<vcsegptridx_t::integral_type>(segnum), Highest_segment_index, checkp.x, checkp.y, checkp.z, rad, calling_file, calling_linenum, Current_mission_filename, Current_level_num);
|
||||||
|
@ -317,7 +305,9 @@ segmasks get_seg_masks(const vms_vector &checkp, const vcsegptridx_t segnum, fix
|
||||||
// Get number of faces on this side, and at vertex_list, store vertices.
|
// Get number of faces on this side, and at vertex_list, store vertices.
|
||||||
// If one face, then vertex_list indicates a quadrilateral.
|
// 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.
|
// If two faces, then 0,1,2 define one triangle, 3,4,5 define the second.
|
||||||
create_abs_vertex_lists(&num_faces, vertex_list, segnum, sn);
|
const auto v = create_abs_vertex_lists(segnum, sn);
|
||||||
|
const auto &num_faces = v.first;
|
||||||
|
const auto &vertex_list = v.second;
|
||||||
|
|
||||||
//ok...this is important. If a side has 2 faces, we need to know if
|
//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,
|
//those faces form a concave or convex side. If the side pokes out,
|
||||||
|
@ -407,8 +397,6 @@ static ubyte get_side_dists(const vms_vector &checkp,const vsegptridx_t segnum,f
|
||||||
{
|
{
|
||||||
int sn,facebit,sidebit;
|
int sn,facebit,sidebit;
|
||||||
ubyte mask;
|
ubyte mask;
|
||||||
int num_faces;
|
|
||||||
vertex_array_list_t vertex_list;
|
|
||||||
auto &seg = segnum;
|
auto &seg = segnum;
|
||||||
|
|
||||||
//check point against each side of segment. return bitmask
|
//check point against each side of segment. return bitmask
|
||||||
|
@ -423,7 +411,9 @@ static ubyte get_side_dists(const vms_vector &checkp,const vsegptridx_t segnum,f
|
||||||
// Get number of faces on this side, and at vertex_list, store vertices.
|
// Get number of faces on this side, and at vertex_list, store vertices.
|
||||||
// If one face, then vertex_list indicates a quadrilateral.
|
// 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.
|
// If two faces, then 0,1,2 define one triangle, 3,4,5 define the second.
|
||||||
create_abs_vertex_lists(&num_faces, vertex_list, segnum, sn);
|
const auto v = create_abs_vertex_lists(segnum, sn);
|
||||||
|
const auto &num_faces = v.first;
|
||||||
|
const auto &vertex_list = v.second;
|
||||||
|
|
||||||
//ok...this is important. If a side has 2 faces, we need to know if
|
//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,
|
//those faces form a concave or convex side. If the side pokes out,
|
||||||
|
@ -523,9 +513,9 @@ int check_segment_connections(void)
|
||||||
{
|
{
|
||||||
auto seg = vcsegptridx(segnum);
|
auto seg = vcsegptridx(segnum);
|
||||||
for (int sidenum=0;sidenum<6;sidenum++) {
|
for (int sidenum=0;sidenum<6;sidenum++) {
|
||||||
int num_faces,con_num_faces;
|
const auto v = create_abs_vertex_lists(seg, sidenum);
|
||||||
vertex_array_list_t vertex_list, con_vertex_list;
|
const auto &num_faces = v.first;
|
||||||
create_abs_vertex_lists(&num_faces, vertex_list, seg, sidenum);
|
const auto &vertex_list = v.second;
|
||||||
auto csegnum = seg->children[sidenum];
|
auto csegnum = seg->children[sidenum];
|
||||||
if (IS_CHILD(csegnum)) {
|
if (IS_CHILD(csegnum)) {
|
||||||
auto cseg = vcsegptr(csegnum);
|
auto cseg = vcsegptr(csegnum);
|
||||||
|
@ -536,7 +526,9 @@ int check_segment_connections(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
create_abs_vertex_lists(&con_num_faces, con_vertex_list, cseg, csidenum);
|
const auto cv = create_abs_vertex_lists(cseg, csidenum);
|
||||||
|
const auto &con_num_faces = cv.first;
|
||||||
|
const auto &con_vertex_list = cv.second;
|
||||||
|
|
||||||
if (con_num_faces != num_faces) {
|
if (con_num_faces != num_faces) {
|
||||||
errors = 1;
|
errors = 1;
|
||||||
|
@ -1433,16 +1425,15 @@ void create_walls_on_side(const vsegptridx_t sp, int sidenum)
|
||||||
//de-triangulates if we shouldn't be.
|
//de-triangulates if we shouldn't be.
|
||||||
|
|
||||||
{
|
{
|
||||||
int num_faces;
|
|
||||||
vertex_array_list_t vertex_list;
|
|
||||||
fix dist0,dist1;
|
fix dist0,dist1;
|
||||||
int s0,s1;
|
int s0,s1;
|
||||||
int vertnum;
|
int vertnum;
|
||||||
side *s;
|
side *s;
|
||||||
|
|
||||||
create_abs_vertex_lists(&num_faces, vertex_list, sp, sidenum);
|
const auto v = create_abs_vertex_lists(sp, sidenum);
|
||||||
|
const auto &vertex_list = v.second;
|
||||||
|
|
||||||
Assert(num_faces == 2);
|
Assert(v.first == 2);
|
||||||
|
|
||||||
s = &sp->sides[sidenum];
|
s = &sp->sides[sidenum];
|
||||||
|
|
||||||
|
|
|
@ -729,15 +729,14 @@ void do_physics_sim(const vobjptridx_t obj)
|
||||||
if (sidenum != -1) {
|
if (sidenum != -1) {
|
||||||
|
|
||||||
if (! (WALL_IS_DOORWAY(orig_segp,sidenum) & WID_FLY_FLAG)) {
|
if (! (WALL_IS_DOORWAY(orig_segp,sidenum) & WID_FLY_FLAG)) {
|
||||||
int num_faces;
|
|
||||||
fix dist;
|
fix dist;
|
||||||
vertex_array_list_t vertex_list;
|
|
||||||
|
|
||||||
//bump object back
|
//bump object back
|
||||||
|
|
||||||
auto s = &orig_segp->sides[sidenum];
|
auto s = &orig_segp->sides[sidenum];
|
||||||
|
|
||||||
create_abs_vertex_lists(&num_faces, vertex_list, orig_segp, sidenum);
|
const auto v = create_abs_vertex_lists(orig_segp, sidenum);
|
||||||
|
const auto &vertex_list = v.second;
|
||||||
|
|
||||||
//let's pretend this wall is not triangulated
|
//let's pretend this wall is not triangulated
|
||||||
auto b = begin(vertex_list);
|
auto b = begin(vertex_list);
|
||||||
|
|
Loading…
Reference in a new issue