Use enum class for find_vector_intersection result

This commit is contained in:
Kp 2022-05-24 02:32:58 +00:00
parent d8ab3c9bd3
commit a8e7f6ad59
13 changed files with 102 additions and 113 deletions

View file

@ -34,10 +34,13 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "countarray.h"
//return values for find_vector_intersection() - what did we hit?
#define HIT_NONE 0 //we hit nothing
#define HIT_WALL 1 //we hit - guess - a wall
#define HIT_OBJECT 2 //we hit an object - which one? no way to tell...
#define HIT_BAD_P0 3 //start point not is specified segment
enum class fvi_hit_type : uint8_t
{
None, //we hit nothing
Wall, //we hit a wall
Object, //we hit an object - which one? no way to tell...
BadP0, //start point not is specified segment
};
#define MAX_FVI_SEGS 100
@ -45,9 +48,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
struct fvi_info : prohibit_void_ptr<fvi_info>
{
struct segment_array_t : public count_array_t<segnum_t, MAX_FVI_SEGS> {};
int hit_type; //what sort of intersection
vms_vector hit_pnt; //where we hit
segnum_t hit_seg; //what segment hit_pnt is in
fvi_hit_type hit_type; //what sort of intersection
sidenum_t hit_side; //if hit wall, which side
segnum_t hit_side_seg; //what segment the hit side is in
objnum_t hit_object; //if object hit, which object
@ -98,7 +101,7 @@ struct fvi_query : prohibit_void_ptr<fvi_query>
// ingore_obj_list NULL, or ptr to a list of objnums to ignore, terminated with -1
// check_obj_flag determines whether collisions with objects are checked
//Returns the hit_data->hit_type
int find_vector_intersection(const fvi_query &fq, fvi_info &hit_data);
fvi_hit_type find_vector_intersection(const fvi_query &fq, fvi_info &hit_data);
//finds the uv coords of the given point on the given seg & side
//fills in u & v. if l is non-NULL fills it in also

View file

@ -472,7 +472,6 @@ static int move_object_within_mine(fvmobjptr &vmobjptr, segment_array &Segments,
{
if (get_seg_masks(vcvertptr, obj->pos, segp, 0).centermask == sidemask_t{})
{
int fate;
fvi_info hit_info;
fvi_query fq;
@ -485,9 +484,9 @@ static int move_object_within_mine(fvmobjptr &vmobjptr, segment_array &Segments,
fq.ignore_obj_list.first = nullptr;
fq.flags = 0;
fate = find_vector_intersection(fq, hit_info);
if (fate != HIT_WALL) {
const auto fate = find_vector_intersection(fq, hit_info);
if (fate != fvi_hit_type::Wall)
{
if (segp != obj->segnum)
obj_relink(vmobjptr, Segments.vmptr, obj, segp);
obj->pos = newpos;
@ -752,7 +751,6 @@ static void move_object_to_position(const vmobjptridx_t objp, const vms_vector &
objp->pos = newpos;
} else {
if (verify_object_seg(vmobjptr, Segments, vcvertptr, objp, newpos)) {
int fate;
object temp_viewer_obj;
fvi_query fq;
fvi_info hit_info;
@ -813,9 +811,9 @@ static void move_object_to_position(const vmobjptridx_t objp, const vms_vector &
fq.ignore_obj_list.first = nullptr;
fq.flags = 0;
fate = find_vector_intersection(fq, hit_info);
if (fate == HIT_WALL) {
const auto fate = find_vector_intersection(fq, hit_info);
if (fate == fvi_hit_type::Wall)
{
objp->pos = hit_info.hit_pnt;
const auto &&segp = find_object_seg(LevelSharedSegmentState, LevelUniqueSegmentState, objp);
if (segp != segment_none)

View file

@ -897,7 +897,8 @@ fix Magical_light_constant = (F1_0*16);
namespace {
struct hash_info {
sbyte flag, hit_type;
sbyte flag;
fvi_hit_type hit_type;
vms_vector vector;
};
@ -990,7 +991,7 @@ static void cast_light_from_side(const vmsegptridx_t segp, const sidenum_t light
light_at_point = fixmul(light_at_point, Magical_light_constant);
if (light_at_point >= 0) {
fvi_info hit_data;
int hit_type;
fvi_hit_type hit_type;
const auto r_vector_to_center = vm_vec_sub(r_segment_center, vert_location);
const auto inverse_segment_magnitude = fixdiv(F1_0/3, vm_vec_mag(r_vector_to_center));
@ -1033,20 +1034,20 @@ static void cast_light_from_side(const vmsegptridx_t segp, const sidenum_t light
}
}
} else
hit_type = HIT_NONE;
hit_type = fvi_hit_type::None;
switch (hit_type) {
case HIT_NONE:
case fvi_hit_type::None:
light_at_point = fixmul(light_at_point, light_intensity);
urside.uvls[vertnum].l += light_at_point;
if (urside.uvls[vertnum].l > F1_0)
urside.uvls[vertnum].l = F1_0;
break;
case HIT_WALL:
case fvi_hit_type::Wall:
break;
case HIT_OBJECT:
case fvi_hit_type::Object:
Int3(); // Hit object, should be ignoring objects!
break;
case HIT_BAD_P0:
case fvi_hit_type::BadP0:
Int3(); // Ugh, this thing again, what happened, what does it mean?
break;
}
@ -1112,7 +1113,7 @@ static void cast_light_from_side_to_center(const vmsegptridx_t segp, const siden
light_at_point = Magical_light_constant;
if (light_at_point >= 0) {
int hit_type;
fvi_hit_type hit_type;
if (!quick_light) {
fvi_query fq;
@ -1129,10 +1130,10 @@ static void cast_light_from_side_to_center(const vmsegptridx_t segp, const siden
hit_type = find_vector_intersection(fq, hit_data);
}
else
hit_type = HIT_NONE;
hit_type = fvi_hit_type::None;
switch (hit_type) {
case HIT_NONE:
case fvi_hit_type::None:
light_at_point = fixmul(light_at_point, light_intensity);
if (light_at_point >= F1_0)
light_at_point = F1_0-1;
@ -1143,12 +1144,12 @@ static void cast_light_from_side_to_center(const vmsegptridx_t segp, const siden
static_light = 0;
}
break;
case HIT_WALL:
case fvi_hit_type::Wall:
break;
case HIT_OBJECT:
case fvi_hit_type::Object:
Int3(); // Hit object, should be ignoring objects!
break;
case HIT_BAD_P0:
case fvi_hit_type::BadP0:
Int3(); // Ugh, this thing again, what happened, what does it mean?
break;
}

View file

@ -265,7 +265,6 @@ static int ai_evaded;
// These globals are set by a call to find_vector_intersection, which is a slow routine,
// so we don't want to call it again (for this object) unless we have to.
static vms_vector Hit_pos;
static int Hit_type;
static fvi_info Hit_data;
namespace dcx {
@ -795,11 +794,11 @@ player_visibility_state player_is_visible_from_object(const vmobjptridx_t objp,
fq.ignore_obj_list.first = nullptr;
fq.flags = FQ_TRANSWALL; // -- Why were we checking objects? | FQ_CHECK_OBJS; //what about trans walls???
Hit_type = find_vector_intersection(fq, Hit_data);
const auto Hit_type = find_vector_intersection(fq, Hit_data);
Hit_pos = Hit_data.hit_pnt;
if (Hit_type == HIT_NONE)
if (Hit_type == fvi_hit_type::None)
{
dot = vm_vec_dot(vec_to_player, obj.orient.fvec);
if (dot > field_of_view - (Overall_agitation << 9)) {
@ -1200,7 +1199,6 @@ static void ai_fire_laser_at_player(const d_level_shared_segment_state &LevelSha
// Well, they are not directly connected, so use find_vector_intersection to see if they are unobstructed.
fvi_query fq;
fvi_info hit_data;
int fate;
fq.startseg = obj->segnum;
fq.p0 = &obj->pos;
@ -1210,8 +1208,9 @@ static void ai_fire_laser_at_player(const d_level_shared_segment_state &LevelSha
fq.ignore_obj_list.first = nullptr;
fq.flags = FQ_TRANSWALL;
fate = find_vector_intersection(fq, hit_data);
if (fate != HIT_NONE) {
const auto fate = find_vector_intersection(fq, hit_data);
if (fate != fvi_hit_type::None)
{
Int3(); // This bot's gun is poking through a wall, so don't fire.
move_towards_segment_center(LevelSharedSegmentState, obj); // And decrease chances it will happen again.
return;
@ -1820,7 +1819,7 @@ static void compute_buddy_vis_vec(const vmobjptridx_t buddy_obj, const vms_vecto
const auto hit_type = find_vector_intersection(fq, hit_data);
auto &ailp = buddy_obj->ctype.ai_info.ail;
player_visibility.visibility = (hit_type == HIT_NONE)
player_visibility.visibility = (hit_type == fvi_hit_type::None)
? ((ailp.time_player_seen = GameTime64, vm_vec_dot(player_visibility.vec_to_player, buddy_obj->orient.fvec) > robptr.field_of_view[GameUniqueState.Difficulty_level])
? player_visibility_state::visible_and_in_field_of_view
: player_visibility_state::visible_not_in_field_of_view

View file

@ -209,7 +209,6 @@ static void move_towards_outside(const d_level_shared_segment_state &LevelShared
while (count) {
fvi_query fq;
fvi_info hit_data;
int hit_type;
fq.p0 = &psegs[i].point;
fq.startseg = psegs[i].segnum;
@ -219,12 +218,12 @@ static void move_towards_outside(const d_level_shared_segment_state &LevelShared
fq.ignore_obj_list.first = nullptr;
fq.flags = 0;
hit_type = find_vector_intersection(fq, hit_data);
const auto hit_type = find_vector_intersection(fq, hit_data);
if (hit_type == HIT_NONE)
if (hit_type == fvi_hit_type::None)
count = 0;
else {
if ((count == 3) && (hit_type == HIT_BAD_P0))
if (count == 3 && hit_type == fvi_hit_type::BadP0)
Int3();
goal_pos.x = (fq.p0->x + hit_data.hit_pnt.x)/2;
goal_pos.y = (fq.p0->y + hit_data.hit_pnt.y)/2;
@ -377,7 +376,6 @@ std::pair<create_path_result, unsigned> create_path_points(const vmobjptridx_t o
if (((cur_seg == avoid_seg) || (this_seg == avoid_seg)) && (ConsoleObject->segnum == avoid_seg)) {
fvi_query fq;
fvi_info hit_data;
int hit_type;
const auto &&center_point = compute_center_point_on_side(vcvertptr, segp, snum);
@ -389,8 +387,9 @@ std::pair<create_path_result, unsigned> create_path_points(const vmobjptridx_t o
fq.ignore_obj_list.first = nullptr;
fq.flags = 0;
hit_type = find_vector_intersection(fq, hit_data);
if (hit_type != HIT_NONE) {
const auto hit_type = find_vector_intersection(fq, hit_data);
if (hit_type != fvi_hit_type::None)
{
goto dont_add;
}
}
@ -553,7 +552,6 @@ int polish_path(const vmobjptridx_t objp, point_seg *psegs, int num_points)
for (i=0; i<2; i++) {
fvi_query fq;
fvi_info hit_data;
int hit_type;
fq.p0 = &obj.pos;
fq.startseg = obj.segnum;
@ -563,9 +561,9 @@ int polish_path(const vmobjptridx_t objp, point_seg *psegs, int num_points)
fq.ignore_obj_list.first = nullptr;
fq.flags = 0;
hit_type = find_vector_intersection(fq, hit_data);
const auto hit_type = find_vector_intersection(fq, hit_data);
if (hit_type == HIT_NONE)
if (hit_type == fvi_hit_type::None)
first_point = i+1;
else
break;
@ -1197,7 +1195,6 @@ void ai_follow_path(const vmobjptridx_t objp, const player_visibility_state play
int opposite_end_index;
vms_vector *opposite_end_point;
fvi_info hit_data;
int fate;
fvi_query fq;
// See which end we're nearer and look at the opposite end point.
@ -1219,9 +1216,9 @@ void ai_follow_path(const vmobjptridx_t objp, const player_visibility_state play
fq.ignore_obj_list.first = nullptr;
fq.flags = 0; //what about trans walls???
fate = find_vector_intersection(fq, hit_data);
if (fate != HIT_WALL) {
const auto fate = find_vector_intersection(fq, hit_data);
if (fate != fvi_hit_type::Wall)
{
// We can be circular! Do it!
// Path direction is unchanged.
aip->cur_path_index = opposite_end_index;

View file

@ -917,7 +917,7 @@ window_event_result do_endlevel_frame()
find_vector_intersection(fq, hit_data);
if (hit_data.hit_type==HIT_WALL && hit_data.hit_seg!=segment_none)
if (hit_data.hit_type == fvi_hit_type::Wall && hit_data.hit_seg != segment_none)
object_create_explosion(vmsegptridx(hit_data.hit_seg), hit_data.hit_pnt, i2f(3) + d_rand() * 6, VCLIP_SMALL_EXPLOSION);
explosion_wait2 = (0xa00 + d_rand()/8)/2;

View file

@ -611,7 +611,7 @@ struct fvi_segments_visited_t : public fvi_segment_visit_count_t, public visited
namespace dsx {
namespace {
static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const vcsegptridx_t startseg, const vms_vector &p1, fix rad, const icobjptridx_t thisobjnum, const std::pair<const vcobjidx_t *, const vcobjidx_t *> ignore_obj_list, int flags, fvi_info::segment_array_t &seglist, segnum_t entry_seg, fvi_segments_visited_t &visited, sidenum_t &fvi_hit_side, icsegidx_t &fvi_hit_side_seg, unsigned &fvi_nest_count, icsegidx_t &fvi_hit_pt_seg, const vms_vector *&wall_norm, icobjidx_t &fvi_hit_object);
static fvi_hit_type fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const vcsegptridx_t startseg, const vms_vector &p1, fix rad, const icobjptridx_t thisobjnum, const std::pair<const vcobjidx_t *, const vcobjidx_t *> ignore_obj_list, int flags, fvi_info::segment_array_t &seglist, segnum_t entry_seg, fvi_segments_visited_t &visited, sidenum_t &fvi_hit_side, icsegidx_t &fvi_hit_side_seg, unsigned &fvi_nest_count, icsegidx_t &fvi_hit_pt_seg, const vms_vector *&wall_norm, icobjidx_t &fvi_hit_object);
}
//What the hell is fvi_hit_seg for???
@ -626,13 +626,12 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
// ingore_obj ignore collisions with this object
// check_obj_flag determines whether collisions with objects are checked
//Returns the hit_data->hit_type
int find_vector_intersection(const fvi_query &fq, fvi_info &hit_data)
fvi_hit_type find_vector_intersection(const fvi_query &fq, fvi_info &hit_data)
{
auto &LevelSharedVertexState = LevelSharedSegmentState.get_vertex_state();
auto &Objects = LevelUniqueObjectState.Objects;
auto &Vertices = LevelSharedVertexState.get_vertices();
auto &imobjptridx = Objects.imptridx;
int hit_type;
segnum_t hit_seg2;
vms_vector hit_pnt;
@ -645,7 +644,7 @@ int find_vector_intersection(const fvi_query &fq, fvi_info &hit_data)
if(fq.startseg > Highest_segment_index)
{
Assert(fq.startseg <= Highest_segment_index);
hit_data.hit_type = HIT_BAD_P0;
hit_data.hit_type = fvi_hit_type::BadP0;
hit_data.hit_pnt = *fq.p0;
hit_data.hit_seg = hit_data.hit_object = 0;
hit_data.hit_side = side_none;
@ -659,7 +658,7 @@ int find_vector_intersection(const fvi_query &fq, fvi_info &hit_data)
if (get_seg_masks(vcvertptr, *fq.p0, vcsegptr(fq.startseg), 0).centermask != sidemask_t{})
{
hit_data.hit_type = HIT_BAD_P0;
hit_data.hit_type = fvi_hit_type::BadP0;
hit_data.hit_pnt = *fq.p0;
hit_data.hit_seg = fq.startseg;
hit_data.hit_side = side_none;
@ -680,7 +679,7 @@ int find_vector_intersection(const fvi_query &fq, fvi_info &hit_data)
hit_seg2 = segment_none;
const vms_vector *wall_norm = nullptr; //surface normal of hit wall
hit_type = fvi_sub(hit_pnt, hit_seg2, *fq.p0, vcsegptridx(fq.startseg), *fq.p1, fq.rad, imobjptridx(fq.thisobjnum), fq.ignore_obj_list, fq.flags, hit_data.seglist, segment_exit, visited, fvi_hit_side, fvi_hit_side_seg, fvi_nest_count, fvi_hit_pt_seg, wall_norm, fvi_hit_object);
const auto hit_type = fvi_sub(hit_pnt, hit_seg2, *fq.p0, vcsegptridx(fq.startseg), *fq.p1, fq.rad, imobjptridx(fq.thisobjnum), fq.ignore_obj_list, fq.flags, hit_data.seglist, segment_exit, visited, fvi_hit_side, fvi_hit_side_seg, fvi_nest_count, fvi_hit_pt_seg, wall_norm, fvi_hit_object);
segnum_t hit_seg;
if (hit_seg2 != segment_none && get_seg_masks(vcvertptr, hit_pnt, vcsegptr(hit_seg2), 0).centermask == sidemask_t{})
hit_seg = hit_seg2;
@ -688,19 +687,18 @@ int find_vector_intersection(const fvi_query &fq, fvi_info &hit_data)
hit_seg = find_point_seg(LevelSharedSegmentState, LevelUniqueSegmentState, hit_pnt, imsegptridx(fq.startseg));
//MATT: TAKE OUT THIS HACK AND FIX THE BUGS!
if (hit_type == HIT_WALL && hit_seg==segment_none)
if (hit_type == fvi_hit_type::Wall && hit_seg == segment_none)
if (fvi_hit_pt_seg != segment_none && get_seg_masks(vcvertptr, hit_pnt, vcsegptr(fvi_hit_pt_seg), 0).centermask == sidemask_t{})
hit_seg = fvi_hit_pt_seg;
if (hit_seg == segment_none) {
int new_hit_type;
segnum_t new_hit_seg2=segment_none;
vms_vector new_hit_pnt;
//because of code that deal with object with non-zero radius has
//problems, try using zero radius and see if we hit a wall
new_hit_type = fvi_sub(new_hit_pnt, new_hit_seg2, *fq.p0, vcsegptridx(fq.startseg), *fq.p1, 0, imobjptridx(fq.thisobjnum), fq.ignore_obj_list, fq.flags, hit_data.seglist, segment_exit, visited, fvi_hit_side, fvi_hit_side_seg, fvi_nest_count, fvi_hit_pt_seg, wall_norm, fvi_hit_object);
const auto new_hit_type = fvi_sub(new_hit_pnt, new_hit_seg2, *fq.p0, vcsegptridx(fq.startseg), *fq.p1, 0, imobjptridx(fq.thisobjnum), fq.ignore_obj_list, fq.flags, hit_data.seglist, segment_exit, visited, fvi_hit_side, fvi_hit_side_seg, fvi_nest_count, fvi_hit_pt_seg, wall_norm, fvi_hit_object);
(void)new_hit_type; // FIXME! This should become hit_type, right?
if (new_hit_seg2 != segment_none) {
@ -749,7 +747,7 @@ int find_vector_intersection(const fvi_query &fq, fvi_info &hit_data)
// Assert(fvi_hit_seg==-1 || fvi_hit_seg == hit_seg);
Assert(!(hit_type==HIT_OBJECT && fvi_hit_object==object_none));
assert(!(hit_type == fvi_hit_type::Object && fvi_hit_object == object_none));
hit_data.hit_type = hit_type;
hit_data.hit_pnt = hit_pnt;
@ -799,7 +797,7 @@ static void append_segments(fvi_info::segment_array_t &dst, const fvi_info::segm
namespace dsx {
namespace {
static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const vcsegptridx_t startseg, const vms_vector &p1, fix rad, icobjptridx_t thisobjnum, const std::pair<const vcobjidx_t *, const vcobjidx_t *> ignore_obj_list, int flags, fvi_info::segment_array_t &seglist, segnum_t entry_seg, fvi_segments_visited_t &visited, sidenum_t &fvi_hit_side, icsegidx_t &fvi_hit_side_seg, unsigned &fvi_nest_count, icsegidx_t &fvi_hit_pt_seg, const vms_vector *&wall_norm, icobjidx_t &fvi_hit_object)
static fvi_hit_type fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const vcsegptridx_t startseg, const vms_vector &p1, fix rad, icobjptridx_t thisobjnum, const std::pair<const vcobjidx_t *, const vcobjidx_t *> ignore_obj_list, int flags, fvi_info::segment_array_t &seglist, segnum_t entry_seg, fvi_segments_visited_t &visited, sidenum_t &fvi_hit_side, icsegidx_t &fvi_hit_side_seg, unsigned &fvi_nest_count, icsegidx_t &fvi_hit_pt_seg, const vms_vector *&wall_norm, icobjidx_t &fvi_hit_object)
{
auto &LevelSharedVertexState = LevelSharedSegmentState.get_vertex_state();
auto &Objects = LevelUniqueObjectState.Objects;
@ -809,7 +807,7 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
//@@int sidemask; //mask of sides - can be on back of face but not side
vms_vector closest_hit_point{}; //where we hit
auto closest_d = vm_distance_squared::maximum_value(); //distance to hit point
int hit_type=HIT_NONE; //what sort of hit
auto hit_type = fvi_hit_type::None; //what sort of hit
segnum_t hit_seg=segment_none;
segnum_t hit_none_seg=segment_none;
fvi_info::segment_array_t hit_none_seglist;
@ -877,7 +875,7 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
Assert(fvi_hit_object!=object_none);
closest_d = d;
closest_hit_point = hit_point;
hit_type=HIT_OBJECT;
hit_type = fvi_hit_type::Object;
}
}
}
@ -961,7 +959,6 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
segnum_t newsegnum,sub_hit_seg;
vms_vector sub_hit_point;
int sub_hit_type;
const auto save_wall_norm = wall_norm;
auto save_hit_objnum = fvi_hit_object;
@ -977,10 +974,10 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
goto quit_looking; //we've looked a long time, so give up
fvi_info::segment_array_t temp_seglist;
sub_hit_type = fvi_sub(sub_hit_point, sub_hit_seg, p0, startseg.absolute_sibling(newsegnum), p1, rad, thisobjnum, ignore_obj_list, flags, temp_seglist, startseg, visited, fvi_hit_side, fvi_hit_side_seg, fvi_nest_count, fvi_hit_pt_seg, wall_norm, fvi_hit_object);
if (sub_hit_type != HIT_NONE) {
const auto sub_hit_type = fvi_sub(sub_hit_point, sub_hit_seg, p0, startseg.absolute_sibling(newsegnum), p1, rad, thisobjnum, ignore_obj_list, flags, temp_seglist, startseg, visited, fvi_hit_side, fvi_hit_side_seg, fvi_nest_count, fvi_hit_pt_seg, wall_norm, fvi_hit_object);
if (sub_hit_type != fvi_hit_type::None)
{
const auto d = vm_vec_dist2(sub_hit_point,p0);
if (d < closest_d) {
@ -999,7 +996,6 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
wall_norm = save_wall_norm; //global could be trashed
fvi_hit_object = save_hit_objnum;
}
}
else {
wall_norm = save_wall_norm; //global could be trashed
@ -1020,7 +1016,7 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
if (d < closest_d) {
closest_d = d;
closest_hit_point = hit_point;
hit_type = HIT_WALL;
hit_type = fvi_hit_type::Wall;
wall_norm = &startseg->shared_segment::sides[side].normals[face];
if (get_seg_masks(vcvertptr, hit_point, startseg, rad).centermask == sidemask_t{})
hit_seg = startseg; //hit in this segment
@ -1045,7 +1041,8 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
quit_looking:
;
if (hit_type == HIT_NONE) { //didn't hit anything, return end point
if (hit_type == fvi_hit_type::None)
{ //didn't hit anything, return end point
intp = p1;
ints = hit_none_seg;
//MATT: MUST FIX THIS!!!!
@ -1072,10 +1069,8 @@ quit_looking:
ints = hit_seg;
}
Assert(!(hit_type==HIT_OBJECT && fvi_hit_object==object_none));
assert(!(hit_type == fvi_hit_type::Object && fvi_hit_object == object_none));
return hit_type;
}
}
}

View file

@ -3491,7 +3491,6 @@ static void hud_show_kill_list(fvcobjptr &vcobjptr, grs_canvas &canvas, const ga
static int see_object(fvcobjptridx &vcobjptridx, const vcobjptridx_t objnum)
{
fvi_query fq;
int hit_type;
fvi_info hit_data;
//see if we can see this player
@ -3504,9 +3503,8 @@ static int see_object(fvcobjptridx &vcobjptridx, const vcobjptridx_t objnum)
fq.startseg = Viewer->segnum;
fq.ignore_obj_list.first = nullptr;
hit_type = find_vector_intersection(fq, hit_data);
return (hit_type == HIT_OBJECT && hit_data.hit_object == objnum);
const auto hit_type = find_vector_intersection(fq, hit_data);
return hit_type == fvi_hit_type::Object && hit_data.hit_object == objnum;
}
}

View file

@ -55,6 +55,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "compiler-range_for.h"
#include "d_levelstate.h"
#include "d_underlying_value.h"
#include "partial_range.h"
#ifdef NEWHOMER
@ -608,7 +609,6 @@ static void do_omega_stuff(fvmsegptridx &vmsegptridx, const vmobjptridx_t parent
if (lock_objnum == object_none) {
fvi_query fq;
fvi_info hit_data;
int fate;
const auto &&perturbed_fvec = vm_vec_scale_add(parent_objp->orient.fvec, make_random_vector(), F1_0/16);
vm_vec_scale_add(goal_pos, firing_pos, perturbed_fvec, MAX_OMEGA_DIST);
fq.startseg = firing_segnum;
@ -622,8 +622,9 @@ static void do_omega_stuff(fvmsegptridx &vmsegptridx, const vmobjptridx_t parent
fq.ignore_obj_list.first = nullptr;
fq.flags = FQ_IGNORE_POWERUPS | FQ_TRANSPOINT | FQ_CHECK_OBJS; //what about trans walls???
fate = find_vector_intersection(fq, hit_data);
if (fate != HIT_NONE) {
const auto fate = find_vector_intersection(fq, hit_data);
if (fate != fvi_hit_type::None)
{
Assert(hit_data.hit_seg != segment_none); // How can this be? We went from inside the mine to outside without hitting anything?
goal_pos = hit_data.hit_pnt;
}
@ -884,7 +885,6 @@ imobjptridx_t Laser_create_new_easy(const vms_vector &direction, const vms_vecto
{
fvi_query fq;
fvi_info hit_data;
int fate;
// Find segment containing laser fire position. If the robot is straddling a segment, the position from
// which it fires may be in a different segment, which is bad news for find_vector_intersection. So, cast
@ -901,8 +901,9 @@ imobjptridx_t Laser_create_new_easy(const vms_vector &direction, const vms_vecto
fq.ignore_obj_list.first = nullptr;
fq.flags = FQ_TRANSWALL | FQ_CHECK_OBJS; //what about trans walls???
fate = find_vector_intersection(fq, hit_data);
if (fate != HIT_NONE || hit_data.hit_seg==segment_none) {
const auto fate = find_vector_intersection(fq, hit_data);
if (fate != fvi_hit_type::None || hit_data.hit_seg == segment_none)
{
return object_none;
}
@ -960,12 +961,12 @@ int object_to_object_visibility(const vcobjptridx_t obj1, const object_base &obj
switch(const auto fate = find_vector_intersection(fq, hit_data))
{
case HIT_NONE:
case fvi_hit_type::None:
return 1;
case HIT_WALL:
case fvi_hit_type::Wall:
return 0;
default:
con_printf(CON_VERBOSE, "object_to_object_visibility: fate=%u for object %hu{%hu/%i,%i,%i} to {%i,%i,%i}", fate, static_cast<vcobjptridx_t::integral_type>(obj1), obj1->segnum, obj1->pos.x, obj1->pos.y, obj1->pos.z, obj2.pos.x, obj2.pos.y, obj2.pos.z);
con_printf(CON_VERBOSE, "object_to_object_visibility: fate=%u for object %hu{%hu/%i,%i,%i} to {%i,%i,%i}", underlying_value(fate), static_cast<vcobjptridx_t::integral_type>(obj1), obj1->segnum, obj1->pos.x, obj1->pos.y, obj1->pos.z, obj2.pos.x, obj2.pos.y, obj2.pos.z);
// Int3(); // Contact Mike: Oops, what happened? What is fate?
// 2 = hit object (impossible), 3 = bad starting point (bad)
break;
@ -1293,7 +1294,6 @@ static imobjptridx_t track_track_goal(fvcobjptr &vcobjptr, const imobjptridx_t t
static imobjptridx_t Laser_player_fire_spread_delay(fvmsegptridx &vmsegptridx, const vmobjptridx_t obj, const weapon_id_type laser_type, const int gun_num, const fix spreadr, const fix spreadu, const fix delay_time, const weapon_sound_flag make_sound, const vms_vector &shot_orientation, const icobjidx_t Network_laser_track)
{
int Fate;
vms_vector LaserDir;
fvi_query fq;
fvi_info hit_data;
@ -1326,7 +1326,7 @@ static imobjptridx_t Laser_player_fire_spread_delay(fvmsegptridx &vmsegptridx, c
fq.flags = FQ_CHECK_OBJS | FQ_IGNORE_POWERUPS;
#endif
Fate = find_vector_intersection(fq, hit_data);
const auto Fate = find_vector_intersection(fq, hit_data);
auto LaserSeg = hit_data.hit_seg;
@ -1337,11 +1337,11 @@ static imobjptridx_t Laser_player_fire_spread_delay(fvmsegptridx &vmsegptridx, c
if ( vm_vec_dist_quick(LaserPos, obj->pos) > 0x50000 )
return object_none;
if (Fate==HIT_WALL) {
if (Fate == fvi_hit_type::Wall)
return object_none;
}
if (Fate==HIT_OBJECT) {
if (Fate == fvi_hit_type::Object)
{
// if ( Objects[hit_data.hit_object].type == OBJ_ROBOT )
// Objects[hit_data.hit_object].flags |= OF_SHOULD_BE_DEAD;
// if ( Objects[hit_data.hit_object].type != OBJ_POWERUP )

View file

@ -165,7 +165,6 @@ static void apply_light(fvmsegptridx &vmsegptridx, const g3s_lrgb obj_light_emis
{
fvi_query fq;
fvi_info hit_data;
int fate;
const auto tvec = vm_vec_scale_add(obj.pos, obj.orient.fvec, F1_0*200);
@ -177,8 +176,8 @@ static void apply_light(fvmsegptridx &vmsegptridx, const g3s_lrgb obj_light_emis
fq.ignore_obj_list.first = nullptr;
fq.flags = FQ_TRANSWALL;
fate = find_vector_intersection(fq, hit_data);
if (fate != HIT_NONE)
const auto fate = find_vector_intersection(fq, hit_data);
if (fate != fvi_hit_type::None)
max_headlight_dist = vm_vec_mag_quick(vm_vec_sub(hit_data.hit_pnt, obj.pos)) + F1_0*4;
}
}

View file

@ -1385,10 +1385,11 @@ static void set_camera_pos(vms_vector &camera_pos, const vcobjptridx_t objp)
if ((player_camera_vec.x == 0) && (player_camera_vec.y == 0) && (player_camera_vec.z == 0))
player_camera_vec.x += F1_0/16;
hit_data.hit_type = HIT_WALL;
hit_data.hit_type = fvi_hit_type::Wall;
far_scale = F1_0;
while ((hit_data.hit_type != HIT_NONE) && (count++ < 6)) {
while (hit_data.hit_type != fvi_hit_type::None && count++ < 6)
{
vm_vec_normalize_quick(player_camera_vec);
vm_vec_scale(player_camera_vec, Camera_to_player_dist_goal);
@ -1405,7 +1406,8 @@ static void set_camera_pos(vms_vector &camera_pos, const vcobjptridx_t objp)
fq.flags = 0;
find_vector_intersection(fq, hit_data);
if (hit_data.hit_type == HIT_NONE) {
if (hit_data.hit_type == fvi_hit_type::None)
{
camera_pos = closer_p1;
} else {
make_random_vector(player_camera_vec);

View file

@ -320,7 +320,6 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
auto &vmobjptr = Objects.vmptr;
ignore_objects_array_t ignore_obj_list;
int try_again;
int fate=0;
vms_vector ipos; //position after this frame
segnum_t WallHitSeg;
sidenum_t WallHitSide;
@ -410,6 +409,7 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
auto &vcvertptr = Vertices.vcptr;
auto &Walls = LevelUniqueWallSubsystemState.Walls;
auto &vcwallptr = Walls.vcptr;
auto fate = fvi_hit_type::None;
do {
try_again = 0;
@ -441,7 +441,8 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
fate = find_vector_intersection(fq, hit_info);
// Matt: Mike's hack.
if (fate == HIT_OBJECT) {
if (fate == fvi_hit_type::Object)
{
auto &objp = *vcobjptr(hit_info.hit_object);
if ((objp.type == OBJ_WEAPON && is_proximity_bomb_or_player_smart_mine(get_weapon_id(objp))) ||
@ -450,9 +451,8 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
}
#ifndef NDEBUG
if (fate == HIT_BAD_P0) {
if (fate == fvi_hit_type::BadP0)
Int3();
}
#endif
if (phys_segs && !hit_info.seglist.empty())
@ -480,7 +480,7 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
break;
}
Assert(!((fate==HIT_WALL) && ((WallHitSeg == segment_none) || (WallHitSeg > Highest_segment_index))));
assert(!(fate == fvi_hit_type::Wall && (WallHitSeg == segment_none || WallHitSeg > Highest_segment_index)));
save_pos = obj->pos; //save the object's position
auto save_seg = obj->segnum;
@ -520,7 +520,8 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
vms_vector moved_vec_n;
const auto actual_dist = vm_vec_normalized_dir(moved_vec_n,obj->pos,save_pos);
if (fate==HIT_WALL && vm_vec_dot(moved_vec_n,frame_vec) < 0) { //moved backwards
if (fate == fvi_hit_type::Wall && vm_vec_dot(moved_vec_n,frame_vec) < 0)
{ //moved backwards
//don't change position or sim_time
@ -551,7 +552,7 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
switch( fate ) {
case HIT_WALL: {
case fvi_hit_type::Wall: {
fix hit_speed=0,wall_part=0;
// Find hit speed
@ -656,7 +657,7 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
break;
}
case HIT_OBJECT: {
case fvi_hit_type::Object: {
vms_vector old_vel;
// Mark the hit object so that on a retry the fvi code
@ -696,18 +697,14 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
break;
}
case HIT_NONE:
case fvi_hit_type::None:
break;
case fvi_hit_type::BadP0:
#ifndef NDEBUG
case HIT_BAD_P0:
Int3(); // Unexpected collision type: start point not in specified segment.
break;
default:
// Unknown collision type returned from find_vector_intersection!!
Int3();
break;
#endif
break;
}
} while ( try_again );
@ -726,7 +723,7 @@ window_event_result do_physics_sim(const vmobjptridx_t obj, const vms_vector &ob
// After collision with objects and walls, set velocity from actual movement
if (!obj_stopped && !bounced
&& ((obj->type == OBJ_PLAYER) || (obj->type == OBJ_ROBOT) || (obj->type == OBJ_DEBRIS))
&& ((fate == HIT_WALL) || (fate == HIT_OBJECT) || (fate == HIT_BAD_P0))
&& (fate == fvi_hit_type::Wall || fate == fvi_hit_type::Object || fate == fvi_hit_type::BadP0)
)
{
const auto moved_vec = vm_vec_sub(obj->pos,start_pos);

View file

@ -1374,7 +1374,7 @@ static bool immediate_detonate_smart_mine(const vcobjptridx_t smart_mine, const
fq.p1 = &target->pos;
fq.thisobjnum = smart_mine;
auto fate = find_vector_intersection(fq, hit_data);
return fate != HIT_WALL;
return fate != fvi_hit_type::Wall;
}
}