Fix slope collision detection for the camera

See http://mb.srb2.org/showthread.php?t=41494
This commit is contained in:
Monster Iestyn 2016-05-25 21:10:46 +01:00
parent 6466ed5afe
commit 8ceba95bfa
1 changed files with 28 additions and 18 deletions

View File

@ -8123,6 +8123,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
{ {
fixed_t myfloorz, myceilingz; fixed_t myfloorz, myceilingz;
fixed_t midz = thiscam->z + (thiscam->z - mo->z)/2; fixed_t midz = thiscam->z + (thiscam->z - mo->z)/2;
fixed_t midx = ((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1);
fixed_t midy = ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1);
// Cameras use the heightsec's heights rather then the actual sector heights. // Cameras use the heightsec's heights rather then the actual sector heights.
// If you can see through it, why not move the camera through it too? // If you can see through it, why not move the camera through it too?
@ -8138,8 +8140,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
} }
else else
{ {
myfloorz = newsubsec->sector->floorheight; myfloorz = P_CameraGetFloorZ(thiscam, newsubsec->sector, midx, midy, NULL);
myceilingz = newsubsec->sector->ceilingheight; myceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, midx, midy, NULL);
} }
// Check list of fake floors and see if floorz/ceilingz need to be altered. // Check list of fake floors and see if floorz/ceilingz need to be altered.
@ -8151,17 +8153,21 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) for (rover = newsubsec->sector->ffloors; rover; rover = rover->next)
{ {
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12)
continue; continue;
delta1 = midz - (*rover->bottomheight topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL);
+ ((*rover->topheight - *rover->bottomheight)/2)); bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL);
delta2 = thingtop - (*rover->bottomheight
+ ((*rover->topheight - *rover->bottomheight)/2)); delta1 = midz - (bottomheight
if (*rover->topheight > myfloorz && abs(delta1) < abs(delta2)) + ((topheight - bottomheight)/2));
myfloorz = *rover->topheight; delta2 = thingtop - (bottomheight
if (*rover->bottomheight < myceilingz && abs(delta1) >= abs(delta2)) + ((topheight - bottomheight)/2));
myceilingz = *rover->bottomheight; if (topheight > myfloorz && abs(delta1) < abs(delta2))
myfloorz = topheight;
if (bottomheight < myceilingz && abs(delta1) >= abs(delta2))
myceilingz = bottomheight;
} }
} }
@ -8275,18 +8281,22 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) for (rover = newsubsec->sector->ffloors; rover; rover = rover->next)
{ {
fixed_t topheight, bottomheight;
if ((rover->flags & FF_BLOCKOTHERS) && (rover->flags & FF_RENDERALL) && (rover->flags & FF_EXISTS) && GETSECSPECIAL(rover->master->frontsector->special, 4) != 12) if ((rover->flags & FF_BLOCKOTHERS) && (rover->flags & FF_RENDERALL) && (rover->flags & FF_EXISTS) && GETSECSPECIAL(rover->master->frontsector->special, 4) != 12)
{ {
if (*rover->bottomheight - thiscam->height < z topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL);
&& midz < *rover->bottomheight) bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL);
z = *rover->bottomheight - thiscam->height-FixedMul(11*FRACUNIT, mo->scale);
else if (*rover->topheight + thiscam->height > z if (bottomheight - thiscam->height < z
&& midz > *rover->topheight) && midz < bottomheight)
z = *rover->topheight; z = bottomheight - thiscam->height-FixedMul(11*FRACUNIT, mo->scale);
if ((mo->z >= *rover->topheight && midz < *rover->bottomheight) else if (topheight + thiscam->height > z
|| ((mo->z < *rover->bottomheight && mo->z+mo->height < *rover->topheight) && midz >= *rover->topheight)) && midz > topheight)
z = topheight;
if ((mo->z >= topheight && midz < bottomheight)
|| ((mo->z < bottomheight && mo->z+mo->height < topheight) && midz >= topheight))
{ {
// Can't see // Can't see
if (!resetcalled) if (!resetcalled)