ICB: Avoid casting BarrierCollision class to memory. Cleanup names.

This commit is contained in:
Paweł Kołodziejski 2022-07-31 10:41:26 +02:00
parent a71891824d
commit dcd54c8821
No known key found for this signature in database
GPG Key ID: 0BDADC9E74440FF7
16 changed files with 199 additions and 263 deletions

View File

@ -78,7 +78,7 @@ __barrier_result _game_session::Check_barrier_bump_and_bounce(PXreal newx, PXrea
// returns 0 no barrier found thats too near
// 1 a barrier was too close
_route_barrier *bar;
RouteBarrier *bar;
PXreal pdist, dist;
uint32 j;
PXfloat barrier_tolerance = BARRIER_TOLERANCE; // 1/8 of a turn = 45 degress
@ -105,20 +105,20 @@ __barrier_result _game_session::Check_barrier_bump_and_bounce(PXreal newx, PXrea
if (!stairs[j].live)
continue;
if (newy != bar->bottom())
if (newy != bar->m_bottom)
continue; // not on our floor so continue with next
pdist = ((newx * bar->bcm().lpx()) + (newz * bar->bcm().lpz())) - bar->bcm().linedist();
pdist = ((newx * bar->m_bcm.m_lpx) + (newz * bar->m_bcm.m_lpz)) - bar->m_bcm.m_linedist;
if (((PXfloat)PXfabs(pdist) < STAIR_CLOSE) || // stair
((!stairs[j].is_stair) && (!stairs[j].up) && ((PXfloat)PXfabs(pdist) < LADDER_TOP_CLOSE))) { // top of stairs
// we are near the plane so now we must check the end points
// check the left end of the line
dist = ((newx * bar->bcm().alpx()) + (newz * bar->bcm().alpz())) - bar->bcm().alinedist();
dist = ((newx * BarrierCollisionMathsObject::alpx(&bar->m_bcm)) + (newz * BarrierCollisionMathsObject::alpz(&bar->m_bcm))) - bar->m_bcm.m_alinedist;
// check the right end
if (dist >= 0) {
dist = ((newx * bar->bcm().blpx()) + (newz * bar->bcm().blpz())) - bar->bcm().blinedist();
dist = ((newx * BarrierCollisionMathsObject::blpx(&bar->m_bcm)) + (newz * BarrierCollisionMathsObject::blpz(&bar->m_bcm))) - bar->m_bcm.m_blinedist;
if (dist >= 0) {
// ok, its a hit
@ -194,20 +194,20 @@ __barrier_result _game_session::Check_barrier_bump_and_bounce(PXreal newx, PXrea
int32 b = Fetch_megas_nudge_barrier_number(j);
bar = session_barriers->Fetch_barrier(b);
pdist = ((newx * bar->bcm().lpx()) + (newz * bar->bcm().lpz())) - bar->bcm().linedist();
pdist = ((newx * bar->m_bcm.m_lpx) + (newz * bar->m_bcm.m_lpz)) - bar->m_bcm.m_linedist;
if ((PXfloat)PXfabs(pdist) < BARRIER_CLOSE) {
// we are near the plane so now we must check the end points
// check the left end of the line
dist = ((newx * bar->bcm().alpx()) + (newz * bar->bcm().alpz())) - bar->bcm().alinedist();
dist = ((newx * BarrierCollisionMathsObject::alpx(&bar->m_bcm)) + (newz * BarrierCollisionMathsObject::alpz(&bar->m_bcm))) - bar->m_bcm.m_alinedist;
// check the right end
// Make barrier a bit longer to nudge player through the doorway nicely
if (dist > -bar_close) {
dist = ((newx * bar->bcm().blpx()) + (newz * bar->bcm().blpz())) - bar->bcm().blinedist();
dist = ((newx * BarrierCollisionMathsObject::blpx(&bar->m_bcm)) + (newz * BarrierCollisionMathsObject::blpz(&bar->m_bcm))) - bar->m_bcm.m_blinedist;
// Make barrier a bit longer to nudge player through the doorway nicely
if (dist > -bar_close) {
// check angle - narrow ones are ignored
PXfloat delta = remainder(L->pan - bar->pan(), FULL_TURN, HALF_TURN);
PXfloat delta = remainder(L->pan - bar->m_pan, FULL_TURN, HALF_TURN);
PXfloat delta2 = delta;
if (delta < -QUARTER_TURN)
@ -220,7 +220,7 @@ __barrier_result _game_session::Check_barrier_bump_and_bounce(PXreal newx, PXrea
// work out pan of barrier
// we have our coordinate and a direction to shift in
PXfloat ang = bar->pan() * TWO_PI;
PXfloat ang = bar->m_pan * TWO_PI;
PXfloat cang = (PXfloat)PXcos(ang);
PXfloat sang = (PXfloat)PXsin(ang);
@ -248,7 +248,7 @@ __barrier_result _game_session::Check_barrier_bump_and_bounce(PXreal newx, PXrea
bar = session_barriers->Fetch_barrier(b);
ignoreBarrier[j] = 1;
if ((PXfloat)PXfabs(newy - bar->bottom()) > BARRIER_TOO_HIGH)
if ((PXfloat)PXfabs(newy - bar->m_bottom) > BARRIER_TOO_HIGH)
continue; // ignore abars that are now too high
__barrier_result result = Check_this_barrier(bar, newx, newz, oldx, oldz, bar_close, &ignoreThis);
@ -270,7 +270,7 @@ __barrier_result _game_session::Check_barrier_bump_and_bounce(PXreal newx, PXrea
for (j = 0; j < num_stairs; j++) {
bar = &stairs[j].bar;
if (newy != bar->bottom())
if (newy != bar->m_bottom)
continue; // not on our floor so continue with next
__barrier_result result = Check_this_barrier(bar, newx, newz, oldx, oldz, bar_close, &ignoreThis);
@ -321,11 +321,11 @@ __barrier_result _game_session::Check_barrier_bump_and_bounce(PXreal newx, PXrea
if (ignoreBarrier[j] == 1)
continue;
hit = troute.Get_intersect(oldx, oldz, destx, destz, bar->x1(), bar->z1(), bar->x2(), bar->z2());
hit = troute.Get_intersect(oldx, oldz, destx, destz, bar->m_x1, bar->m_z1, bar->m_x2, bar->m_z2);
if (hit == 1) {
warning("Player crossed the line nBars %d nFortKnox %d : player %f %f -> %f %f bar: %f %f -> %f %f", nBarriers, nFortKnox, oldx, oldz, destx, destz,
bar->x1(), bar->z1(), bar->x2(), bar->z2());
bar->m_x1, bar->m_z1, bar->m_x2, bar->m_z2);
break;
}
}
@ -419,7 +419,7 @@ __barrier_result _game_session::Check_barrier_bump_and_bounce(PXreal newx, PXrea
return (__OK);
}
__barrier_result _game_session::Check_this_barrier(_route_barrier *bar, PXreal newx, PXreal newz, PXreal /* oldx */, PXreal /* oldz */, PXreal bar_close, int32 *ignoreThis) {
__barrier_result _game_session::Check_this_barrier(RouteBarrier *bar, PXreal newx, PXreal newz, PXreal /* oldx */, PXreal /* oldz */, PXreal bar_close, int32 *ignoreThis) {
PXfloat delta;
PXfloat delta2;
PXfloat barrier_tolerance = BARRIER_TOLERANCE; // 1/8 of a turn = 45 degress
@ -428,24 +428,24 @@ __barrier_result _game_session::Check_this_barrier(_route_barrier *bar, PXreal n
*ignoreThis = 1;
pdist = ((newx * bar->bcm().lpx()) + (newz * bar->bcm().lpz())) - bar->bcm().linedist();
pdist = ((newx * bar->m_bcm.m_lpx) + (newz * bar->m_bcm.m_lpz)) - bar->m_bcm.m_linedist;
if ((PXfloat)PXfabs(pdist) < bar_close) {
// we are near the plane so now we must check the end points
// check the left end of the line
dist = ((newx * bar->bcm().alpx()) + (newz * bar->bcm().alpz())) - bar->bcm().alinedist();
dist = ((newx * BarrierCollisionMathsObject::alpx(&bar->m_bcm)) + (newz * BarrierCollisionMathsObject::alpz(&bar->m_bcm))) - bar->m_bcm.m_alinedist;
// check the right end
if (dist >= 0) {
dist = ((newx * bar->bcm().blpx()) + (newz * bar->bcm().blpz())) - bar->bcm().blinedist();
dist = ((newx * BarrierCollisionMathsObject::blpx(&bar->m_bcm)) + (newz * BarrierCollisionMathsObject::blpz(&bar->m_bcm))) - bar->m_bcm.m_blinedist;
if (dist >= 0) {
*ignoreThis = 0;
// we are going to hit this barrier
// but, if the angle is narrow we can aquire the barriers pan and continue unmolested
delta = remainder(L->pan - bar->pan(), FULL_TURN, HALF_TURN);
delta = remainder(L->pan - bar->m_pan, FULL_TURN, HALF_TURN);
delta2 = delta;
if (delta < -QUARTER_TURN)
@ -457,9 +457,9 @@ __barrier_result _game_session::Check_this_barrier(_route_barrier *bar, PXreal n
return (__BLOCKED); // conflict, so finish
if ((delta > QUARTER_TURN) || (delta < -QUARTER_TURN)) {
adjusted_pan = remainder(bar->pan() + HALF_TURN, FULL_TURN, HALF_TURN);
adjusted_pan = remainder(bar->m_pan + HALF_TURN, FULL_TURN, HALF_TURN);
} else {
adjusted_pan = bar->pan();
adjusted_pan = bar->m_pan;
}
made_adjust = TRUE8;
if (adjusted_pan > L->pan) {
@ -468,9 +468,9 @@ __barrier_result _game_session::Check_this_barrier(_route_barrier *bar, PXreal n
adjusted_pan -= REPEL_TURN;
}
if (pdist > 0)
normalAngle = bar->pan() + QUARTER_TURN;
normalAngle = bar->m_pan + QUARTER_TURN;
else if (pdist < 0)
normalAngle = bar->pan() - QUARTER_TURN;
normalAngle = bar->m_pan - QUARTER_TURN;
} else {
// cant adjust
return (__BLOCKED);
@ -487,7 +487,7 @@ __barrier_result _game_session::Check_this_barrier(_route_barrier *bar, PXreal n
}
void _barrier_handler::___init() {
_routing_slice *slice;
RoutingSlice *slice;
uint32 *num_bars;
uint32 len;
@ -507,7 +507,7 @@ void _barrier_handler::___init() {
num_bars = (uint32 *)LinkedDataObject::Fetch_item_by_name(raw_barriers, "Count");
total_barriers = *(num_bars);
total_barriers = READ_LE_U32(num_bars);
Tdebug("barriers.txt", "%d raw barriers", total_barriers);
@ -535,9 +535,9 @@ void _barrier_handler::___init() {
uint32 j;
for (j = 0; j < total_slices; j++) {
slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, j);
Tdebug("slice.txt", "bottom %3.1f top %3.1f", slice->bottom, slice->top);
Tdebug("slice.txt", "%d parents", slice->num_parent_boxes);
slice = (RoutingSlice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, j);
Tdebug("slice.txt", "bottom %3.1f top %3.1f", FROM_LE_FLOAT32(slice->bottom), FROM_LE_FLOAT32(slice->top));
Tdebug("slice.txt", "%d parents", FROM_LE_32(slice->num_parent_boxes));
}
// reset prop list for each
@ -566,9 +566,9 @@ void _barrier_handler::___init() {
if (clist[j]->num_barriers) \
for (k = 0; k < clist[j]->num_barriers; k++) { \
bar = Fetch_barrier(clist[j]->barriers[k]); \
if (bar->bottom() == y) { \
if (bar->m_bottom == y) { \
if (barrier_mask) { \
if (MS->troute.LineIntersectsRect(mask, (int32)bar->x1(), (int32)bar->z1(), (int32)bar->x2(), (int32)bar->z2())) \
if (MS->troute.LineIntersectsRect(mask, (int32)bar->m_x1, (int32)bar->m_z1, (int32)bar->m_x2, (int32)bar->m_z2)) \
MS->troute.Add_barrier(bar); \
} else \
MS->troute.Add_barrier(bar); \
@ -597,9 +597,9 @@ void _barrier_handler::___init() {
void _barrier_handler::Form_parent_barrier_list(PXreal x, PXreal y, PXreal z) {
// we are routing into a room - just get the parent barriers
_parent_box *endb;
ParentBox *endb;
uint32 parent_a, slice_a, k;
_route_barrier *bar;
RouteBarrier *bar;
uint32 *array;
endb = Fetch_parent_box_for_xyz(x, y, z, parent_a, slice_a);
@ -624,14 +624,14 @@ void _barrier_handler::Form_route_barrier_list(PXreal x, PXreal y, PXreal z, PXr
// it is a higher level job to divide long routes up into rect to rect chunks before calling here
// but this is quite sensible anyway as we only want to be auto-routing across tiny areas at a time
_parent_box *startb;
_parent_box *endb;
ParentBox *startb;
ParentBox *endb;
_rect rb; // rb meaning 'Route-Box'
uint32 j;
_child_group *clist[MAX_child_groups_per_parent * 2];
ChildGroup *clist[MAX_child_groups_per_parent * 2];
uint32 total_childs = 0; // separate total for safety
int32 expanded_this_go;
_route_barrier *bar;
RouteBarrier *bar;
uint32 k;
uint32 parent_a, parent_b;
uint32 slice_a, slice_b;
@ -778,50 +778,50 @@ void _barrier_handler::Form_route_barrier_list(PXreal x, PXreal y, PXreal z, PXr
}
}
} else { // route lies within a single floor - so draw a box around it
_route_barrier newbar;
RouteBarrier newbar;
// left hand barrier
newbar.x1(startb->left);
newbar.z1(startb->back);
newbar.x2(startb->left);
newbar.z2(startb->front);
newbar.m_x1 = startb->left;
newbar.m_z1 = startb->back;
newbar.m_x2 = startb->left;
newbar.m_z2 = startb->front;
MS->troute.Add_barrier(&newbar);
// right hand barrier
newbar.x1(startb->right);
newbar.z1(startb->back);
newbar.x2(startb->right);
newbar.z2(startb->front);
newbar.m_x1 = startb->right;
newbar.m_z1 = startb->back;
newbar.m_x2 = startb->right;
newbar.m_z2 = startb->front;
MS->troute.Add_barrier(&newbar);
// top barrier
newbar.x1(startb->left);
newbar.z1(startb->back);
newbar.x2(startb->right);
newbar.z2(startb->back);
newbar.m_x1 = startb->left;
newbar.m_z1 = startb->back;
newbar.m_x2 = startb->right;
newbar.m_z2 = startb->back;
MS->troute.Add_barrier(&newbar);
// bottom barrier
newbar.x1(startb->left);
newbar.z1(startb->front);
newbar.x2(startb->right);
newbar.z2(startb->front);
newbar.m_x1 = startb->left;
newbar.m_z1 = startb->front;
newbar.m_x2 = startb->right;
newbar.m_z2 = startb->front;
MS->troute.Add_barrier(&newbar);
}
}
_parent_box *_barrier_handler::Fetch_parent_num_on_slice_y(uint32 requested_parent, PXreal y) {
ParentBox *_barrier_handler::Fetch_parent_num_on_slice_y(uint32 requested_parent, PXreal y) {
// fetch the parent of the number passed for a given y level
// ie 0 means first, 1 means second, etc
// this is called by the plan-viewer which just keeps asking for the next one until we say there are no more
// by passing back a 0 instead of a pointer to a parent
static _routing_slice *slice;
static RoutingSlice *slice;
uint32 cur_slice = 0;
// first time in so compute the slice
if (!requested_parent) {
while (1) {
slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, cur_slice);
slice = (RoutingSlice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, cur_slice);
if ((y >= slice->bottom) && (y < slice->top))
break;
@ -845,29 +845,29 @@ _parent_box *_barrier_handler::Fetch_parent_num_on_slice_y(uint32 requested_pare
// simply return the pointer
return ((_parent_box *)(((uint8 *)slice) + slice->parent_boxes[requested_parent]));
return ((ParentBox *)(((uint8 *)slice) + slice->parent_boxes[requested_parent]));
}
_route_barrier *_barrier_handler::Fetch_barrier(uint32 num) {
RouteBarrier *_barrier_handler::Fetch_barrier(uint32 num) {
// return a pointer to numbered barrier
_route_barrier *bar;
RouteBarrier *bar;
assert(num < total_barriers);
if (num >= total_barriers)
Fatal_error("illegal barrier request %d", num);
bar = (_route_barrier *)LinkedDataObject::Fetch_item_by_name(raw_barriers, "Data");
bar = (RouteBarrier *)LinkedDataObject::Fetch_item_by_name(raw_barriers, "Data");
return &bar[num];
}
_parent_box *_barrier_handler::Fetch_parent_box_for_xyz(PXreal x, PXreal y, PXreal z, uint32 &par_num, uint32 &slice_num) {
ParentBox *_barrier_handler::Fetch_parent_box_for_xyz(PXreal x, PXreal y, PXreal z, uint32 &par_num, uint32 &slice_num) {
// return a pointer to the parent box of a point in world space
// returns 0 if the point does not lie within a parent box
_routing_slice *slice = nullptr;
_parent_box *parent = nullptr;
RoutingSlice *slice = nullptr;
ParentBox *parent = nullptr;
// find correct slice according to height
// fetch first
@ -875,7 +875,7 @@ _parent_box *_barrier_handler::Fetch_parent_box_for_xyz(PXreal x, PXreal y, PXre
slice_num = 0;
while (1) {
slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, slice_num);
slice = (RoutingSlice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, slice_num);
if ((y >= slice->bottom) && (y < slice->top))
break;
@ -897,7 +897,7 @@ _parent_box *_barrier_handler::Fetch_parent_box_for_xyz(PXreal x, PXreal y, PXre
Fatal_error("_barrier_handler::Fetch_parent_box_for_xyz slice has no parent boxes");
for (par_num = 0; par_num < slice->num_parent_boxes; par_num++) {
parent = (_parent_box *)(((uint8 *)slice) + slice->parent_boxes[par_num]);
parent = (ParentBox *)(((uint8 *)slice) + slice->parent_boxes[par_num]);
// do we lie within the box?
if ((x > parent->left) && (x < parent->right) && (z > parent->back) && (z < parent->front)) {
@ -914,14 +914,14 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
// this system is custom for the player object - routing megas use their own system
// this routine fecthes the 'special' player only line-of-sight barriers too
_parent_box *par = nullptr;
_child_group *pchild;
ParentBox *par = nullptr;
ChildGroup *pchild;
uint32 total_childs;
uint32 j, k;
uint32 *list;
_route_barrier *bar;
RouteBarrier *bar;
uint32 parent_number;
_routing_slice *slice;
RoutingSlice *slice;
PXreal x, y, z;
x = M->actor_xyz.x;
@ -929,7 +929,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
z = M->actor_xyz.z;
// on previous slice?
slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(session_barriers->route_wrapper, M->cur_slice);
slice = (RoutingSlice *)LinkedDataObject::Fetch_item_by_number(session_barriers->route_wrapper, M->cur_slice);
if ((y >= slice->bottom) && (y < slice->top) && (M->cur_parent))
if ((x > M->cur_parent->left) && (x < M->cur_parent->right) && (z > M->cur_parent->back) && (z < M->cur_parent->front)) {
// nothing has changed
@ -944,7 +944,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
M->cur_slice = 0;
while (1) {
slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(session_barriers->route_wrapper, M->cur_slice);
slice = (RoutingSlice *)LinkedDataObject::Fetch_item_by_number(session_barriers->route_wrapper, M->cur_slice);
if ((y >= slice->bottom) && (y < slice->top))
break;
@ -952,7 +952,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
M->cur_slice++;
if (M->cur_slice == session_barriers->total_slices) { // if so then must be last slice :O
M->cur_slice--;
slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(session_barriers->route_wrapper, M->cur_slice);
slice = (RoutingSlice *)LinkedDataObject::Fetch_item_by_number(session_barriers->route_wrapper, M->cur_slice);
break;
}
}
@ -962,7 +962,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
Fatal_error("Prepare_megas_route_barriers slice has no parent boxes");
for (parent_number = 0; parent_number < slice->num_parent_boxes; parent_number++) {
par = (_parent_box *)(((uint8 *)slice) + slice->parent_boxes[parent_number]);
par = (ParentBox *)(((uint8 *)slice) + slice->parent_boxes[parent_number]);
// do we lie within the box?
if ((x > par->left) && (x < par->right) && (z > par->back) && (z < par->front)) {
@ -996,7 +996,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
for (j = 0; j < par->num_barriers; j++) {
// fetch each barrier and check that its bottom edge is on the floor - otherwise we ignore it
bar = session_barriers->Fetch_barrier(*(list));
if (bar->bottom() == slice->bottom) { // M->actor_xyz.y)
if (bar->m_bottom == slice->bottom) { // M->actor_xyz.y)
// ok, this barrier is on the floor so we add it to our list
M->barrier_list[M->number_of_barriers++] = *(list++);
}
@ -1018,19 +1018,19 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
// fetch each barrier and check that its bottom edge is on the floor - otherwise we ignore it
bar = session_barriers->Fetch_barrier(*(list));
if (bar->material() == VIEW_FIELD) {
if (bar->bottom() == slice->bottom) { // M->actor_xyz.y)
if (bar->m_material == VIEW_FIELD) {
if (bar->m_bottom == slice->bottom) { // M->actor_xyz.y)
// ok, this barrier is on the floor so we add it to our list
M->barrier_list[M->number_of_barriers++] = *(list++);
}
} else if (bar->material() >= LEFT_NUDGE) {
if (bar->bottom() == slice->bottom) { // M->actor_xyz.y)
} else if (bar->m_material >= LEFT_NUDGE) {
if (bar->m_bottom == slice->bottom) { // M->actor_xyz.y)
// ok, this barrier is on the floor so we add it to our list
M->nudge_list[M->number_of_nudge++] = *(list++);
}
} else {
Fatal_error("illegal barrier [%d], special list - type %d, x1 %3.2f, x2 %3.2f, z1 %3.2f, z2 %3.2f", *(list), bar->material(), bar->x1(),
bar->x2(), bar->z1(), bar->z2());
Fatal_error("illegal barrier [%d], special list - type %d, x1 %3.2f, x2 %3.2f, z1 %3.2f, z2 %3.2f", *(list), bar->m_material, bar->m_x1,
bar->m_x2, bar->m_z1, bar->m_z2);
}
}
}
@ -1043,7 +1043,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
for (k = 0; k < pchild->num_barriers; k++) {
bar = session_barriers->Fetch_barrier(pchild->barriers[k]);
if (bar->bottom() == slice->bottom) { // M->actor_xyz.y)
if (bar->m_bottom == slice->bottom) { // M->actor_xyz.y)
M->barrier_list[M->number_of_barriers++] = pchild->barriers[k];
}
}
@ -1068,9 +1068,9 @@ void _barrier_handler::Prepare_animating_barriers() {
uint32 j;
uint16 barrier_table[MAX_anim_barriers];
uint32 total_anim_bars = 0;
_route_barrier *bar;
_routing_slice *slice;
_parent_box *parent;
RouteBarrier *bar;
RoutingSlice *slice;
ParentBox *parent;
uint32 cur_slice = 0;
uint32 l, f, pbar_num;
uint32 abar_index = 0;
@ -1114,8 +1114,8 @@ void _barrier_handler::Prepare_animating_barriers() {
bar = Fetch_barrier(bars[i]);
if (l == total_anim_bars) { // didnt find in list
Tdebug("anim_barriers.txt", " new barrier %d x%3.2f y%3.2f z%3.2f", bars[i], bar->x1(), bar->bottom(),
bar->z1());
Tdebug("anim_barriers.txt", " new barrier %d x%3.2f y%3.2f z%3.2f", bars[i], bar->m_x1, bar->m_bottom,
bar->m_z1);
barrier_table[total_anim_bars++] = (uint16)bars[i]; // write the bar down
@ -1126,9 +1126,9 @@ void _barrier_handler::Prepare_animating_barriers() {
cur_slice = 0;
do {
slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, cur_slice);
slice = (RoutingSlice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, cur_slice);
if ((bar->bottom() >= slice->bottom) && (bar->bottom() < slice->top))
if ((bar->m_bottom >= slice->bottom) && (bar->m_bottom < slice->top))
break;
cur_slice++;
@ -1155,11 +1155,11 @@ void _barrier_handler::Prepare_animating_barriers() {
for (f = 0; f < slice->num_parent_boxes; f++) {
Tdebug("anim_barriers.txt", " check parent %d", f);
parent = (_parent_box *)(((uint8 *)slice) + slice->parent_boxes[f]);
parent = (ParentBox *)(((uint8 *)slice) + slice->parent_boxes[f]);
// do we lie within the box?
if ((bar->x1() > parent->left) && (bar->x1() < parent->right) && (bar->z1() > parent->back) &&
(bar->z1() < parent->front)) {
if ((bar->m_x1 > parent->left) && (bar->m_x1 < parent->right) && (bar->m_z1 > parent->back) &&
(bar->m_z1 < parent->front)) {
char *props_name = (char *)LinkedDataObject::Fetch_items_name_by_number(MS->prop_anims, j);
uint32 props_number = LinkedDataObject::Fetch_item_number_by_name(MS->objects, props_name);
@ -1271,8 +1271,8 @@ void _barrier_handler::Prepare_animating_barriers() {
// now compute slice for sample barrier
cur_slice = 0;
do {
slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, cur_slice);
if ((bar->bottom() >= slice->bottom) && (bar->bottom() < slice->top))
slice = (RoutingSlice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, cur_slice);
if ((bar->m_bottom >= slice->bottom) && (bar->m_bottom < slice->top))
break;
cur_slice++;
} while (cur_slice != total_slices);

View File

@ -87,11 +87,11 @@ public:
void Form_route_barrier_list(PXreal x, PXreal y, PXreal z, PXreal x2, PXreal z2);
void Form_parent_barrier_list(PXreal x, PXreal y, PXreal z);
_parent_box *Fetch_parent_box_for_xyz(PXreal x, PXreal y, PXreal z, uint32 &par_num, uint32 &slice_num);
_parent_box *Fetch_parent_num_on_slice_y(uint32 requested_parent, PXreal y);
uint32 Fetch_number_of_child_boxes(_parent_box *parent);
_child_group *Fetch_child_box(_parent_box *parent, uint32 child);
_route_barrier *Fetch_barrier(uint32 num);
ParentBox *Fetch_parent_box_for_xyz(PXreal x, PXreal y, PXreal z, uint32 &par_num, uint32 &slice_num);
ParentBox *Fetch_parent_num_on_slice_y(uint32 requested_parent, PXreal y);
uint32 Fetch_number_of_child_boxes(ParentBox *parent);
ChildGroup *Fetch_child_box(ParentBox *parent, uint32 child);
RouteBarrier *Fetch_barrier(uint32 num);
uint32 Fetch_total_barriers();
LinkedDataFile *Get_barrier_pointer() const { return raw_barriers; }
void Prepare_animating_barriers();
@ -139,9 +139,9 @@ inline void _barrier_handler::Clear_route_barrier_mask() {
barrier_mask = FALSE8;
}
inline uint32 _barrier_handler::Fetch_number_of_child_boxes(_parent_box *parent) { return (parent->num_childgroups); }
inline uint32 _barrier_handler::Fetch_number_of_child_boxes(ParentBox *parent) { return (parent->num_childgroups); }
inline _child_group *_barrier_handler::Fetch_child_box(_parent_box *parent, uint32 child) { return ((_child_group *)(((uint8 *)parent) + parent->childgroups[child])); }
inline ChildGroup *_barrier_handler::Fetch_child_box(ParentBox *parent, uint32 child) { return ((ChildGroup *)(((uint8 *)parent) + parent->childgroups[child])); }
inline uint32 _barrier_handler::Fetch_total_barriers() { return (total_barriers); }

View File

@ -72,88 +72,58 @@ namespace ICB {
// VIEW_FIELD - stops characters walking out of camera field-of-view.
// LEFT_NUDGE - use to assist player control going through doors.
// RIGHT_NUDGE - ditto last one.
enum _barrier_type { BRICK = 0, GLASS, BULLET_PROOF_GLASS, THIN_STEEL, WIRE_FENCE, UNIT_HEIGHT, VIEW_FIELD, LEFT_NUDGE, RIGHT_NUDGE };
enum eBarrierType { BRICK = 0, GLASS, BULLET_PROOF_GLASS, THIN_STEEL, WIRE_FENCE, UNIT_HEIGHT, VIEW_FIELD, LEFT_NUDGE, RIGHT_NUDGE };
#define BARRIER_TYPE_CARDINALITY 9 // Must match number of enums in previous type (because C++
// doesn't provide a way to get this).
// This is an enumerated type for the things that might try to pass through a barrier. Note: the TEST_RAY
// is blocked by all types of barrier.
enum _barrier_ray_type { TEST_RAY, LIGHT, BULLET };
enum eBarrierRayType { TEST_RAY, LIGHT, BULLET };
#define RAY_TYPE_CARDINALITY 3
// Defines a multi-state logic value for use with the barriers.
enum _barrier_logic_value { NO_IMPACT = 0, BLOCKS, ALLOWS, MAYBE, SPECIAL };
enum eBarrierLogicValue { NO_IMPACT = 0, BLOCKS, ALLOWS, MAYBE, SPECIAL };
// This is the truth table that states what kind of ray passes through what
// type of barrier.
static enum _barrier_logic_value _barrier_logic_table[BARRIER_TYPE_CARDINALITY][RAY_TYPE_CARDINALITY] = {
static enum eBarrierLogicValue barrierLogicTable[BARRIER_TYPE_CARDINALITY][RAY_TYPE_CARDINALITY] = {
{BLOCKS, BLOCKS, BLOCKS}, {BLOCKS, ALLOWS, SPECIAL}, {BLOCKS, ALLOWS, BLOCKS}, {BLOCKS, BLOCKS, ALLOWS}, {BLOCKS, ALLOWS, MAYBE},
{BLOCKS, ALLOWS, ALLOWS}, {BLOCKS, ALLOWS, ALLOWS}, {BLOCKS, ALLOWS, ALLOWS}, {BLOCKS, ALLOWS, ALLOWS}};
// simple, this is just for the converters
// Some extra figures to speed up barrier collision detection.
typedef struct {
PXfloat linedist, alinedist, blinedist;
PXfloat lpx, lpz; // Main barrier
PXfloat alpx, alpz; // End A.
PXfloat blpx, blpz; // End B.
} _simple_barrier_collision_maths;
// simple, this is just for the converters
// This holds one single barrier.
typedef struct {
PXreal x1, z1; // Looking down on the model, the position of the first vertical edge of the barrier.
PXreal x2, z2; // Looking down on the model, the position of the second vertical edge.
PXreal bottom; // The bottom of the barrier.
PXreal top; // The top of the barrier.
_barrier_type material; // The material the barrier is made of.
PXfloat pan; // The barrier's pan value.
_simple_barrier_collision_maths bcm; // Some extra figures to speed up barrier collision detection.
} _simple_route_barrier;
class _barrier_collision_maths {
private:
// these are in both versions
PXfloat m_linedist, m_alinedist, m_blinedist;
PXfloat m_lpx, m_lpz; // Main barrier
PXfloat m_alpx, m_alpz; // End A.
PXfloat m_blpx, m_blpz; // End B.
} BarrierCollisionMaths;
class BarrierCollisionMathsObject {
public:
inline PXfloat linedist() { return m_linedist; }
inline PXfloat alinedist() { return m_alinedist; }
inline PXfloat blinedist() { return m_blinedist; }
// on pc these are pxfloats
inline PXfloat lpx() { return m_lpx; }
inline PXfloat lpz() { return m_lpz; }
inline PXfloat alpx() {
static inline PXfloat alpx(BarrierCollisionMaths *bmath) {
// return m_alpx;
return -lpz();
return -bmath->m_lpz;
}
inline PXfloat alpz() {
static inline PXfloat alpz(BarrierCollisionMaths *bmath) {
// return m_alpz;
return lpx();
return bmath->m_lpx;
}
inline PXfloat blpx() {
static inline PXfloat blpx(BarrierCollisionMaths *bmath) {
// return m_blpx;
return lpz();
return bmath->m_lpz;
}
inline PXfloat blpz() {
static inline PXfloat blpz(BarrierCollisionMaths *bmath) {
// return m_blpz;
return -lpx();
return -bmath->m_lpx;
}
void Generate(PXreal x1, PXreal z1, PXreal x2, PXreal z2) {
static void Generate(BarrierCollisionMaths *bmath, PXreal x1, PXreal z1, PXreal x2, PXreal z2) {
PXreal dx = x1 - x2;
PXreal dz = z1 - z2;
@ -162,75 +132,35 @@ public:
PXfloat xunit = PXreal2PXfloat(dx) / nLength;
PXfloat zunit = PXreal2PXfloat(dz) / nLength;
m_lpx = -zunit;
m_lpz = xunit;
bmath->m_lpx = -zunit;
bmath->m_lpz = xunit;
m_linedist = (x1 * lpx()) + (z1 * lpz());
bmath->m_linedist = (x1 * bmath->m_lpx) + (z1 * bmath->m_lpz);
m_alinedist = (x1 * alpx()) + (z1 * alpz());
bmath->m_alinedist = (x1 * alpx(bmath)) + (z1 * alpz(bmath));
m_blinedist = (x2 * blpx()) + (z2 * blpz());
}
_barrier_collision_maths() {
(void)m_alpx; // shutup warning
(void)m_alpz; // shutup warning
(void)m_blpx; // shutup warning
(void)m_blpz; // shutup warning
bmath->m_blinedist = (x2 * blpx(bmath)) + (z2 * blpz(bmath));
}
};
class _route_barrier {
typedef struct {
PXreal m_x1, m_z1; // Looking down on the model, the position of the first vertical edge of the barrier.
PXreal m_x2, m_z2; // Looking down on the model, the position of the second vertical edge.
PXreal m_bottom; // The bottom of the barrier.
PXreal m_top; // The top of the barrier.
_barrier_type m_material; // The material the barrier is made of.
eBarrierType m_material; // The material the barrier is made of.
PXfloat m_pan; // The barrier's pan value.
_barrier_collision_maths m_bcm; // Some extra figures to speed up barrier collision detection.
BarrierCollisionMaths m_bcm; // Some extra figures to speed up barrier collision detection.
} RouteBarrier;
public:
void Create_pan() { m_pan = PXAngleOfVector(m_z1 - m_z2, m_x1 - m_x2); }
void x1(PXreal x) { m_x1 = x; }
void z1(PXreal z) { m_z1 = z; }
inline PXreal x1() const { return m_x1; }
inline PXreal z1() const { return m_z1; }
void x2(PXreal x) { m_x2 = x; }
void z2(PXreal z) { m_z2 = z; }
inline PXreal x2() const { return m_x2; }
inline PXreal z2() const { return m_z2; }
inline PXreal bottom() const { return m_bottom; }
inline PXreal top() const { return m_top; }
inline _barrier_type material() const { return m_material; }
inline PXfloat pan() const { return m_pan; }
inline _barrier_collision_maths &bcm() { return m_bcm; }
_route_barrier() {}
_route_barrier(PXreal inX1, PXreal inZ1, PXreal inX2, PXreal inZ2, PXreal inBottom, PXreal inTop, _barrier_type inMaterial) {
m_x1 = inX1;
m_z1 = inZ1;
m_x2 = inX2;
m_z2 = inZ2;
m_bottom = inBottom;
m_top = inTop;
m_material = inMaterial;
}
};
inline void routeBarrierCreatePan(RouteBarrier *barrier) { barrier->m_pan = PXAngleOfVector(barrier->m_z1 - barrier->m_z2, barrier->m_x1 - barrier->m_x2); }
// This holds several barriers. These barriers all at least partly occupy a given cube in space. If one barrier passes
// through more than one cube, it will have a duplicate entry in each cube.
typedef struct {
int32 num_barriers; // The number of barriers referenced in this cube.
uint32 barriers; // Offset to an array of barrier indices.
} _barrier_cube;
} BarrierCube;
// This is a horizontal slice through the Max model, containing all the route barriers that pass through this level. The
// extremeties of the whole cuboid are given first so that a quick initial check can be done to see if there might be
@ -245,7 +175,7 @@ typedef struct {
uint32 num_cubes; // Number of _route_cubes in this floor (could be calculated by dividing overall cube size by FLOOR_CUBE_SIZE).
uint32 row_length; // Size of the rows in the array (eg. 6 cubes could be 1X6, 2X3, 3X2 or 6X1).
uint32 offset_cubes[1]; // An array of offsets to cubes (2D array of size row_length * (num_cubes / row_length) ).
} _barrier_slice;
} BarrierSlice;
// This is used in the following definition of _parent_box, and holds one group of barriers.
typedef struct {
@ -254,7 +184,7 @@ typedef struct {
uint32 num_barriers; // Number of barriers in this group.
uint32 barriers[1]; // Array of barrier indices.
} _child_group;
} ChildGroup;
// This holds one parent box entry.
typedef struct {
@ -267,7 +197,7 @@ typedef struct {
uint32 num_childgroups; // Number of child groups owned by this parent box.
uint32 childgroups[1]; // Array of offsets to the child groups.
} _parent_box;
} ParentBox;
// This is also a slice through the model, but the data is grouped in a different way which is more suited to routing.
typedef struct {
@ -276,9 +206,9 @@ typedef struct {
uint32 num_parent_boxes; // The number of parent boxes in this slice (same as the number of floor rectangles at this height).
uint32 parent_boxes[1]; // An array of offsets to parent boxes.
} _routing_slice;
} RoutingSlice;
__inline _barrier_logic_value IsBarrierTo(_barrier_type eMaterial, _barrier_ray_type eRay) { return _barrier_logic_table[eMaterial][eRay]; }
inline eBarrierLogicValue IsBarrierTo(eBarrierType eMaterial, eBarrierRayType eRay) { return barrierLogicTable[eMaterial][eRay]; }
} // End of namespace ICB

View File

@ -2989,18 +2989,24 @@ uint32 _game_session::Register_stair_or_ladder(const char *target, bool8 top, ui
z3 = z1 - dz;
// new constructor for barrier...
stairs[num_stairs].bar = _route_barrier(x2, z2, x3, z3, stair->floor_y, (PXreal)0 /* dont care */, BRICK /* dont care */);
stairs[num_stairs].bar.m_x1 = x2;
stairs[num_stairs].bar.m_z1 = z2;
stairs[num_stairs].bar.m_x2 = x3;
stairs[num_stairs].bar.m_z2 = z3;
stairs[num_stairs].bar.m_bottom = stair->floor_y;
stairs[num_stairs].bar.m_top = (PXreal)0;
stairs[num_stairs].bar.m_material = BRICK;
// create the BCM maths----------------------------------------------
// The barrier has coordinates x2, z2 to x3, z3.
// Fill in the structure that holds the extra collision maths.
stairs[num_stairs].bar.bcm().Generate(x2, z2, x3, z3);
stairs[num_stairs].bar.Create_pan();
BarrierCollisionMathsObject::Generate(&stairs[num_stairs].bar.m_bcm, x2, z2, x3, z3);
routeBarrierCreatePan(&stairs[num_stairs].bar);
Tdebug("stairs.txt", "try this: %.4f, %g,%g,%g %g,%g %g,%g %g,%g\n", stairs[num_stairs].bar.pan(), stairs[num_stairs].bar.bcm().linedist(),
stairs[num_stairs].bar.bcm().alinedist(), stairs[num_stairs].bar.bcm().blinedist(), stairs[num_stairs].bar.bcm().lpx(), stairs[num_stairs].bar.bcm().lpz(),
stairs[num_stairs].bar.bcm().alpx(), stairs[num_stairs].bar.bcm().alpz(), stairs[num_stairs].bar.bcm().blpx(), stairs[num_stairs].bar.bcm().blpz());
Tdebug("stairs.txt", "try this: %.4f, %g,%g,%g %g,%g %g,%g %g,%g\n", stairs[num_stairs].bar.m_pan, stairs[num_stairs].bar.m_bcm.m_linedist,
stairs[num_stairs].bar.m_bcm.m_alinedist, stairs[num_stairs].bar.m_bcm.m_blinedist, stairs[num_stairs].bar.m_bcm.m_lpx, stairs[num_stairs].bar.m_bcm.m_lpz,
BarrierCollisionMathsObject::alpx(&stairs[num_stairs].bar.m_bcm), BarrierCollisionMathsObject::alpz(&stairs[num_stairs].bar.m_bcm), BarrierCollisionMathsObject::blpx( &stairs[num_stairs].bar.m_bcm), BarrierCollisionMathsObject::blpz(&stairs[num_stairs].bar.m_bcm));
// create the BCM maths----------------------------------------------

View File

@ -31,7 +31,7 @@ namespace ICB {
void _game_volume::SetUpParameters(LinkedDataFile *pyLOSData) {
uint32 i;
_barrier_slice *pSlice;
BarrierSlice *pSlice;
_slice_limit sSliceLimit;
// Store the pointer to the data file.
@ -39,7 +39,7 @@ void _game_volume::SetUpParameters(LinkedDataFile *pyLOSData) {
// Get the first slice and use this to set the horizontal sizes, since they all share the
// same horizontal sizes.
pSlice = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pyLOSData, 0);
pSlice = (BarrierSlice *)LinkedDataObject::Fetch_item_by_number(pyLOSData, 0);
m_fLeftEdge = pSlice->left_edge;
m_fRightEdge = pSlice->right_edge;
m_fBackEdge = pSlice->back_edge;
@ -57,7 +57,7 @@ void _game_volume::SetUpParameters(LinkedDataFile *pyLOSData) {
m_nNumSlices = LinkedDataObject::Fetch_number_of_items(pyLOSData);
for (i = 0; i < m_nNumSlices; ++i) {
pSlice = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pyLOSData, i);
pSlice = (BarrierSlice *)LinkedDataObject::Fetch_item_by_number(pyLOSData, i);
sSliceLimit.fTop = pSlice->top;
sSliceLimit.fBottom = pSlice->bottom;
m_oSliceLimits[i] = sSliceLimit;

View File

@ -157,7 +157,7 @@ void _line_of_sight::UnSubscribe(uint32 nObserverID, uint32 nTargetID) {
}
}
bool8 _line_of_sight::ObjectToObject(uint32 nObserverID, uint32 nTargetID, _barrier_ray_type eRayType, bool8 bCanSeeUs, ActorEyeMode eEyeMode, bool8 bOverrideHeightLimit) {
bool8 _line_of_sight::ObjectToObject(uint32 nObserverID, uint32 nTargetID, eBarrierRayType eRayType, bool8 bCanSeeUs, ActorEyeMode eEyeMode, bool8 bOverrideHeightLimit) {
_logic *pObserver;
_logic *pTarget;
bool8 bObserverIsActor, bTargetIsActor;

View File

@ -115,14 +115,14 @@ public:
inline void ShadowsOnOff(bool8 bState) { m_bHandleShadows = bState; }
// This checks line-of-sight between two objects, accounting for field-of-view if observer is an actor,
bool8 ObjectToObject(uint32 nObserverID, uint32 nTargetID, _barrier_ray_type eRayType, bool8 bCanSeeUs, ActorEyeMode eEyeMode, bool8 bOverrideHeightLimit = FALSE8);
bool8 ObjectToObject(uint32 nObserverID, uint32 nTargetID, eBarrierRayType eRayType, bool8 bCanSeeUs, ActorEyeMode eEyeMode, bool8 bOverrideHeightLimit = FALSE8);
// This checks line-of-sight using the current truth table values and so is fast.
inline bool8 LineOfSight(uint32 nObserverID, uint32 nTargetID);
// And these two return extra information after a call to ObjectToObject().
const px3DRealPoint GetLastImpactPoint() const { return (m_oImpactPoint); }
_barrier_logic_value GetLastImpactType() const { return (m_eImpactType); }
eBarrierLogicValue GetLastImpactType() const { return (m_eImpactType); }
// This allows other classes to get at the barrier slices (the Remora needs this).
LinkedDataFile *GetSlicesPointer() const { return (m_pyLOSData); }
@ -145,7 +145,7 @@ private:
bool8 m_pbCanSeeInDark[LOS_1D_SIZE]; // Housekeeping table of objects that should ignore shadows.
bool8 m_pbIgnoreShadows[LOS_1D_SIZE]; // Table of megas that are always seen regardless of shadows.
px3DRealPoint m_oImpactPoint; // Holds impact point from last call to ObjectToObject().
_barrier_logic_value m_eImpactType; // Holds type of impact from last call to ObjectToObject().
eBarrierLogicValue m_eImpactType; // Holds type of impact from last call to ObjectToObject().
bool8 m_bSwitchedOn; // Flag that allows LOS processing to be suspended.
bool8 m_bFailingOnHeight; // Debug flag that gets set when a barrier height check fails.
bool8 m_bHandleShadows; // Turns shadow handling on/off.

View File

@ -202,7 +202,7 @@ enum CameraStateEnum { OFF_CAMERA = 0x0, ON_CAMERA = 0x1 };
class _mega { // mega logic specific
public:
_parent_box *cur_parent; // our owner parent box
ParentBox *cur_parent; // our owner parent box
uint32 par_number; // for players abar list update
uint32 cur_slice; // for speedups

View File

@ -47,14 +47,14 @@ void _prim_route_builder::Reset_barrier_list() {
total_points = 0;
}
void _prim_route_builder::Add_barrier(_route_barrier *new_barrier) {
barrier_list[total_points].x = new_barrier->x1();
barrier_list[total_points++].z = new_barrier->z1();
barrier_list[total_points].x = new_barrier->x2();
barrier_list[total_points++].z = new_barrier->z2();
void _prim_route_builder::Add_barrier(RouteBarrier *new_barrier) {
barrier_list[total_points].x = new_barrier->m_x1;
barrier_list[total_points++].z = new_barrier->m_z1;
barrier_list[total_points].x = new_barrier->m_x2;
barrier_list[total_points++].z = new_barrier->m_z2;
if (!ExtrapolateLine(&barrier_list[total_points - 2], &barrier_list[total_points - 1], &barrier_list[total_points - 2], &barrier_list[total_points - 1], extrap_size))
Fatal_error("extrapolate line failed on line %3.2f %3.2f %3.2f %3.2f", new_barrier->x1(), new_barrier->z1(), new_barrier->x2(), new_barrier->z2());
Fatal_error("extrapolate line failed on line %3.2f %3.2f %3.2f %3.2f", new_barrier->m_x1, new_barrier->m_z1, new_barrier->m_x2, new_barrier->m_z2);
assert(total_points < MAX_barriers);
}

View File

@ -47,7 +47,7 @@ class _prim_route_builder {
public:
void Reset_barrier_list();
void Add_barrier(_route_barrier *new_barrier);
void Add_barrier(RouteBarrier *new_barrier);
_route_stat Calc_route(PXreal startx, PXreal startz, PXreal endx, PXreal endz); // does extraping

View File

@ -899,7 +899,7 @@ void _remora::SetCommonActivateInfo(RemoraMode eMode) {
uint32 i, j;
_logic *pPlayerObject;
LinkedDataFile *pSlices;
_barrier_slice *pSlice;
BarrierSlice *pSlice;
int32 nSlice;
uint32 nNumSlices;
bool8 bInFloorRange;
@ -936,7 +936,7 @@ void _remora::SetCommonActivateInfo(RemoraMode eMode) {
for (i = 0; i < nNumSlices; ++i) {
// Get the slice.
pSlice = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pSlices, i);
pSlice = (BarrierSlice *)LinkedDataObject::Fetch_item_by_number(pSlices, i);
// See if the player's feet are in this slice.
if ((m_nPlayerY >= pSlice->bottom) && (m_nPlayerY < pSlice->top))
@ -954,7 +954,7 @@ void _remora::SetCommonActivateInfo(RemoraMode eMode) {
bInFloorRange = TRUE8;
for (j = m_pFloorRanges[i].s_nLower; j <= m_pFloorRanges[i].s_nUpper; ++j) {
m_pSlices[m_nNumCurrentFloorRanges] = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pSlices, j);
m_pSlices[m_nNumCurrentFloorRanges] = (BarrierSlice *)LinkedDataObject::Fetch_item_by_number(pSlices, j);
m_pnSlices[m_nNumCurrentFloorRanges] = j;
++m_nNumCurrentFloorRanges;
}
@ -966,7 +966,7 @@ void _remora::SetCommonActivateInfo(RemoraMode eMode) {
// If we didn't set a floor range then we must set a single floor slice.
if (!bInFloorRange) {
// Only one slice required to be displayed.
m_pSlices[0] = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pSlices, nSlice);
m_pSlices[0] = (BarrierSlice *)LinkedDataObject::Fetch_item_by_number(pSlices, nSlice);
m_pnSlices[0] = nSlice;
m_nNumCurrentFloorRanges = 1;
}

View File

@ -326,7 +326,7 @@ private:
uint32 m_nCurrentZoom; // 128 = scale of 1.0, 1 = x(1/128), 512 = scale of x4
uint32 m_nMinZoom; // Minimum zoom level allowed for the Remora.
uint32 m_nMaxZoom; // Maximum zoom level allowed for the Remora.
_barrier_slice *m_pSlices[REMORA_MAX_INCLUDED_SLICES]; // Slices of barriers for player's current height.
BarrierSlice *m_pSlices[REMORA_MAX_INCLUDED_SLICES]; // Slices of barriers for player's current height.
uint32 m_pnSlices[REMORA_MAX_INCLUDED_SLICES]; // Index of slice player is on.
int32 m_nIncludedCeiling; // Top coordinate of things to include in scan modes.
int32 m_nIncludedFloor; // Bottom coordinate of things to include in scan modes.

View File

@ -570,12 +570,12 @@ void _remora::DrawStaticBarriers(_rgb oLineColour) const {
uint32 i, j, k;
float fX1, fZ1, fX2, fZ2;
int32 nX1, nZ1, nX2, nZ2;
_barrier_cube *pBarrierCube;
_barrier_slice *pSlice;
BarrierCube *pBarrierCube;
BarrierSlice *pSlice;
uint32 *pBarrierArray;
uint32 nBarrierCubeOffset;
uint32 nBarrierIndex;
_route_barrier *pBarrier;
RouteBarrier *pBarrier;
PXTRY
@ -588,7 +588,7 @@ void _remora::DrawStaticBarriers(_rgb oLineColour) const {
for (j = 0; j < pSlice->num_cubes; ++j) {
// Get to the barriers for this cube.
nBarrierCubeOffset = pSlice->offset_cubes[j];
pBarrierCube = (_barrier_cube *)((uint8 *)pSlice + nBarrierCubeOffset);
pBarrierCube = (BarrierCube *)((uint8 *)pSlice + nBarrierCubeOffset);
pBarrierArray = (uint32 *)((uint8 *)pSlice + pBarrierCube->barriers);
// Draw the barriers for this cube.
@ -600,10 +600,10 @@ void _remora::DrawStaticBarriers(_rgb oLineColour) const {
pBarrier = MS->session_barriers->Fetch_barrier(nBarrierIndex);
// Set up the vector, the player relative bit has been done in the translation_matrix setting up
fX1 = pBarrier->x1();
fZ1 = pBarrier->z1();
fX2 = pBarrier->x2();
fZ2 = pBarrier->z2();
fX1 = pBarrier->m_x1;
fZ1 = pBarrier->m_z1;
fX2 = pBarrier->m_x2;
fZ2 = pBarrier->m_z2;
GameToRemora(fX1, fZ1);
GameToRemora(fX2, fZ2);
@ -631,7 +631,7 @@ void _remora::DrawAnimatingBarriers(_rgb oLineColour) const {
float fX1, fZ1, fX2, fZ2;
int32 nX1, nZ1, nX2, nZ2;
uint32 nBarrierIndex;
_route_barrier *pBarrier;
RouteBarrier *pBarrier;
uint32 nPropID;
uint32 nPropState;
uint32 nBarriersPerState;
@ -672,10 +672,10 @@ void _remora::DrawAnimatingBarriers(_rgb oLineColour) const {
pBarrier = MS->session_barriers->Fetch_barrier(*(pnBarriers++));
// Set up the vector, the player relative bit has been done in the translation_matrix setting up
fX1 = pBarrier->x1();
fZ1 = pBarrier->z1();
fX2 = pBarrier->x2();
fZ2 = pBarrier->z2();
fX1 = pBarrier->m_x1;
fZ1 = pBarrier->m_z1;
fX2 = pBarrier->m_x2;
fZ2 = pBarrier->m_z2;
GameToRemora(fX1, fZ1);
GameToRemora(fX2, fZ2);

View File

@ -152,7 +152,7 @@ typedef struct {
#define MAX_stairs 32
typedef struct {
_route_barrier bar;
RouteBarrier bar;
PXfloat pan, pan_ref, x, z;
uint8 units;
@ -772,7 +772,7 @@ public:
PXfloat normalAngle;
__barrier_result Check_barrier_bump_and_bounce(PXreal newx, PXreal newy, PXreal newz, PXreal oldx, PXreal oldy, PXreal oldz, bool8 player);
__barrier_result Check_this_barrier(_route_barrier *bar, PXreal newx, PXreal newz, PXreal oldx, PXreal oldz, PXreal bar_close, int32 *ignore);
__barrier_result Check_this_barrier(RouteBarrier *bar, PXreal newx, PXreal newz, PXreal oldx, PXreal oldz, PXreal bar_close, int32 *ignore);
void Prepare_megas_route_barriers(bool8 player);
void Prepare_megas_abarriers(uint32 slice_number, uint32 parent_number);

View File

@ -40,9 +40,9 @@ _tracer *g_oTracer;
bool8 _tracer::Trace(const px3DRealPoint &oFrom, // IN: Point to plot from.
const px3DRealPoint &oTo, // IN: Point to plot to.
_barrier_ray_type eRayType, // IN: The type of the ray being plotted.
eBarrierRayType eRayType, // IN: The type of the ray being plotted.
px3DRealPoint &oPointOfImpact, // OUT: The first point of impact.
_barrier_logic_value /*eImpactType*/ // OUT: For interpretation by high-level logic.
eBarrierLogicValue /*eImpactType*/ // OUT: For interpretation by high-level logic.
) {
uint32 i;
uint32 nLoopCount;
@ -55,8 +55,8 @@ bool8 _tracer::Trace(const px3DRealPoint &oFrom, // IN: Point to plot from
px2DRealLine oPlanRay, oPlanBarrier;
_bullet_cube oThisCube;
_XYZ_index oThisIndex;
_barrier_logic_value eTempImpactType;
const _route_barrier *pBarrier;
eBarrierLogicValue eTempImpactType;
const RouteBarrier *pBarrier;
bool8 bFinishInThisCube;
FaceID eCubeLeavingFace;
_floor *psFloor;
@ -130,14 +130,14 @@ bool8 _tracer::Trace(const px3DRealPoint &oFrom, // IN: Point to plot from
// The intersection test is relatively expensive, so do the barrier type check
// first (eg. if we're firing light at a glass barrier, we know it can go through).
eTempImpactType = IsBarrierTo(pBarrier->material(), eRayType);
eTempImpactType = IsBarrierTo(pBarrier->m_material, eRayType);
if (eTempImpactType != ALLOWS) {
// Right, this barrier doesn't allow this ray to pass, so we must check if it
// is actually in the path of the ray.
oPlanBarrier.SetX1(pBarrier->x1());
oPlanBarrier.SetY1(pBarrier->z1());
oPlanBarrier.SetX2(pBarrier->x2());
oPlanBarrier.SetY2(pBarrier->z2());
oPlanBarrier.SetX1(pBarrier->m_x1);
oPlanBarrier.SetY1(pBarrier->m_z1);
oPlanBarrier.SetX2(pBarrier->m_x2);
oPlanBarrier.SetY2(pBarrier->m_z2);
if (oPlanRay.Intersects(oPlanBarrier, o2DImpactPoint) == px2DRealLine::DO_INTERSECT) {
// We've found a barrier that the ray intersects with in the horizontal plane;
@ -212,19 +212,19 @@ bool8 _tracer::Trace(const px3DRealPoint &oFrom, // IN: Point to plot from
void _tracer::GetBarriersForCube(const _XYZ_index &oCubeIndices, uint32 *oThisCubesBarriers, int32 &nNumBarriers, int32 nExtraSliceIndex) const {
int32 i;
_barrier_slice *pSlice;
_barrier_cube *pBarrierCube;
BarrierSlice *pSlice;
BarrierCube *pBarrierCube;
uint32 nBarrierCubeOffset;
uint32 nActualIndex;
uint32 *pBarrierArray;
// Get to the right slice.
pSlice = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(m_pyLOSMemFile, oCubeIndices.nY);
pSlice = (BarrierSlice *)LinkedDataObject::Fetch_item_by_number(m_pyLOSMemFile, oCubeIndices.nY);
// Get to the right cube entry.
nActualIndex = oCubeIndices.nZ * pSlice->row_length + oCubeIndices.nX;
nBarrierCubeOffset = pSlice->offset_cubes[nActualIndex];
pBarrierCube = (_barrier_cube *)((uint8 *)pSlice + nBarrierCubeOffset);
pBarrierCube = (BarrierCube *)((uint8 *)pSlice + nBarrierCubeOffset);
pBarrierArray = (uint32 *)((uint8 *)pSlice + pBarrierCube->barriers);
// Add the barriers to the array we're returning.
@ -418,7 +418,7 @@ px3DRealPoint _tracer::CalculateRayIntersectionWithCubeWall(const px3DRealPoint
return (oNewPoint);
}
bool8 _tracer::CheckRayHeightAgainstBarrier(const px3DRealPoint &oFrom, const px3DRealPoint &oTo, const _route_barrier *pBarrier, px3DRealPoint &o3DImpactPoint) const {
bool8 _tracer::CheckRayHeightAgainstBarrier(const px3DRealPoint &oFrom, const px3DRealPoint &oTo, const RouteBarrier *pBarrier, px3DRealPoint &o3DImpactPoint) const {
PXreal l_fXDiff, l_fZDiff, l_fYDiff;
PXfloat fImpactDistance;
PXreal fTotalDistance;
@ -440,7 +440,7 @@ bool8 _tracer::CheckRayHeightAgainstBarrier(const px3DRealPoint &oFrom, const px
fImpactY = oFrom.GetY() + (fImpactDistance * l_fYDiff) / fTotalDistance;
// Check this z against the barrier to see if we have impact.
if ((fImpactY >= pBarrier->bottom()) && (fImpactY <= pBarrier->top())) {
if ((fImpactY >= pBarrier->m_bottom) && (fImpactY <= pBarrier->m_top)) {
o3DImpactPoint.SetY(fImpactY);
return (TRUE8);
} else {

View File

@ -48,7 +48,7 @@ public:
virtual inline ~_tracer() { ; }
// This checks a line through game-world space and returns the point of its first impact.
bool8 Trace(const px3DRealPoint &oFrom, const px3DRealPoint &oTo, _barrier_ray_type eRayType, px3DRealPoint &oImpact, _barrier_logic_value eImpactType);
bool8 Trace(const px3DRealPoint &oFrom, const px3DRealPoint &oTo, eBarrierRayType eRayType, px3DRealPoint &oImpact, eBarrierLogicValue eImpactType);
// Call this before using the tracer, to point it at its barriers.
void SetBarrierPointer(LinkedDataFile *pyBarriers) { m_pyBarrierMemFile = pyBarriers; }
@ -75,22 +75,22 @@ private:
px3DRealPoint CalculateEntryToNextCube(const px3DRealPoint &oCurrentPoint, const px3DRealPoint &oTo, const _bullet_cube &oThisCube, FaceID &eCubeLeavingFace) const;
bool8 CheckRayHeightAgainstBarrier(const px3DRealPoint &oFrom, const px3DRealPoint &oTo, const _route_barrier *pBarrier, px3DRealPoint &o3DImpactPoint) const;
bool8 CheckRayHeightAgainstBarrier(const px3DRealPoint &oFrom, const px3DRealPoint &oTo, const RouteBarrier *pBarrier, px3DRealPoint &o3DImpactPoint) const;
uint32 FindClosest(const px3DRealPoint &oFrom, px3DRealPoint *oImpactList, uint32 nNumImpacts) const;
px3DRealPoint CalculateRayIntersectionWithCubeWall(const px3DRealPoint &oCurrentPoint, const px3DRealPoint &oTo, const _bullet_cube &oThisCube, FaceID eLeavingFace) const;
inline const _route_barrier *GetBarrier(uint32 i) const;
inline const RouteBarrier *GetBarrier(uint32 i) const;
};
inline const _route_barrier *_tracer::GetBarrier(uint32 i) const {
_route_barrier *pBarriers;
inline const RouteBarrier *_tracer::GetBarrier(uint32 i) const {
RouteBarrier *pBarriers;
if (!m_pyBarrierMemFile)
Fatal_error("No barrier file in _tracer::GetBarrier()");
pBarriers = (_route_barrier *)LinkedDataObject::Fetch_item_by_name(m_pyBarrierMemFile, "Data");
pBarriers = (RouteBarrier *)LinkedDataObject::Fetch_item_by_name(m_pyBarrierMemFile, "Data");
return &(pBarriers[i]);
}