mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-29 12:40:58 +00:00
Make sure quakes are scaled for skyboxes
While I was at it I also refactored most of the skybox view scaling code so it isn't needlessly duplicated
This commit is contained in:
parent
63a16355da
commit
7629a0710e
1 changed files with 58 additions and 136 deletions
194
src/r_main.c
194
src/r_main.c
|
@ -806,153 +806,75 @@ void R_SkyboxFrame(player_t *player)
|
||||||
if (viewmobj->spawnpoint)
|
if (viewmobj->spawnpoint)
|
||||||
viewz = ((fixed_t)viewmobj->spawnpoint->angle)<<FRACBITS;
|
viewz = ((fixed_t)viewmobj->spawnpoint->angle)<<FRACBITS;
|
||||||
|
|
||||||
viewx += quake.x;
|
|
||||||
viewy += quake.y;
|
|
||||||
viewz += quake.z;
|
|
||||||
|
|
||||||
if (mapheaderinfo[gamemap-1])
|
if (mapheaderinfo[gamemap-1])
|
||||||
{
|
{
|
||||||
mapheader_t *mh = mapheaderinfo[gamemap-1];
|
mapheader_t *mh = mapheaderinfo[gamemap-1];
|
||||||
if (player->awayviewtics)
|
vector3_t campos = {0,0,0}; // Position of player's actual view point
|
||||||
{
|
|
||||||
if (skyboxmo[1])
|
|
||||||
{
|
|
||||||
fixed_t x = 0, y = 0;
|
|
||||||
if (mh->skybox_scalex > 0)
|
|
||||||
x = (player->awayviewmobj->x - skyboxmo[1]->x) / mh->skybox_scalex;
|
|
||||||
else if (mh->skybox_scalex < 0)
|
|
||||||
x = (player->awayviewmobj->x - skyboxmo[1]->x) * -mh->skybox_scalex;
|
|
||||||
|
|
||||||
if (mh->skybox_scaley > 0)
|
if (player->awayviewtics) {
|
||||||
y = (player->awayviewmobj->y - skyboxmo[1]->y) / mh->skybox_scaley;
|
campos.x = player->awayviewmobj->x;
|
||||||
else if (mh->skybox_scaley < 0)
|
campos.y = player->awayviewmobj->y;
|
||||||
y = (player->awayviewmobj->y - skyboxmo[1]->y) * -mh->skybox_scaley;
|
campos.z = player->awayviewmobj->z + 20*FRACUNIT;
|
||||||
|
} else if (thiscam->chase) {
|
||||||
if (viewmobj->angle == 0)
|
campos.x = thiscam->x;
|
||||||
{
|
campos.y = thiscam->y;
|
||||||
viewx += x;
|
campos.z = thiscam->z + (thiscam->height>>1);
|
||||||
viewy += y;
|
} else {
|
||||||
}
|
campos.x = player->mo->x;
|
||||||
else if (viewmobj->angle == ANGLE_90)
|
campos.y = player->mo->y;
|
||||||
{
|
campos.z = player->viewz;
|
||||||
viewx -= y;
|
|
||||||
viewy += x;
|
|
||||||
}
|
|
||||||
else if (viewmobj->angle == ANGLE_180)
|
|
||||||
{
|
|
||||||
viewx -= x;
|
|
||||||
viewy -= y;
|
|
||||||
}
|
|
||||||
else if (viewmobj->angle == ANGLE_270)
|
|
||||||
{
|
|
||||||
viewx += y;
|
|
||||||
viewy -= x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
|
|
||||||
viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
|
||||||
viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mh->skybox_scalez > 0)
|
|
||||||
viewz += (player->awayviewmobj->z + 20*FRACUNIT) / mh->skybox_scalez;
|
|
||||||
else if (mh->skybox_scalez < 0)
|
|
||||||
viewz += (player->awayviewmobj->z + 20*FRACUNIT) * -mh->skybox_scalez;
|
|
||||||
}
|
}
|
||||||
else if (thiscam->chase)
|
|
||||||
|
// Earthquake effects should be scaled in the skybox
|
||||||
|
// (if an axis isn't used, the skybox won't shake in that direction)
|
||||||
|
campos.x += quake.x;
|
||||||
|
campos.y += quake.y;
|
||||||
|
campos.z += quake.z;
|
||||||
|
|
||||||
|
if (skyboxmo[1]) // Is there a viewpoint?
|
||||||
{
|
{
|
||||||
if (skyboxmo[1])
|
fixed_t x = 0, y = 0;
|
||||||
|
if (mh->skybox_scalex > 0)
|
||||||
|
x = (campos.x - skyboxmo[1]->x) / mh->skybox_scalex;
|
||||||
|
else if (mh->skybox_scalex < 0)
|
||||||
|
x = (campos.x - skyboxmo[1]->x) * -mh->skybox_scalex;
|
||||||
|
|
||||||
|
if (mh->skybox_scaley > 0)
|
||||||
|
y = (campos.y - skyboxmo[1]->y) / mh->skybox_scaley;
|
||||||
|
else if (mh->skybox_scaley < 0)
|
||||||
|
y = (campos.y - skyboxmo[1]->y) * -mh->skybox_scaley;
|
||||||
|
|
||||||
|
if (viewmobj->angle == 0)
|
||||||
{
|
{
|
||||||
fixed_t x = 0, y = 0;
|
viewx += x;
|
||||||
if (mh->skybox_scalex > 0)
|
viewy += y;
|
||||||
x = (thiscam->x - skyboxmo[1]->x) / mh->skybox_scalex;
|
|
||||||
else if (mh->skybox_scalex < 0)
|
|
||||||
x = (thiscam->x - skyboxmo[1]->x) * -mh->skybox_scalex;
|
|
||||||
|
|
||||||
if (mh->skybox_scaley > 0)
|
|
||||||
y = (thiscam->y - skyboxmo[1]->y) / mh->skybox_scaley;
|
|
||||||
else if (mh->skybox_scaley < 0)
|
|
||||||
y = (thiscam->y - skyboxmo[1]->y) * -mh->skybox_scaley;
|
|
||||||
|
|
||||||
if (viewmobj->angle == 0)
|
|
||||||
{
|
|
||||||
viewx += x;
|
|
||||||
viewy += y;
|
|
||||||
}
|
|
||||||
else if (viewmobj->angle == ANGLE_90)
|
|
||||||
{
|
|
||||||
viewx -= y;
|
|
||||||
viewy += x;
|
|
||||||
}
|
|
||||||
else if (viewmobj->angle == ANGLE_180)
|
|
||||||
{
|
|
||||||
viewx -= x;
|
|
||||||
viewy -= y;
|
|
||||||
}
|
|
||||||
else if (viewmobj->angle == ANGLE_270)
|
|
||||||
{
|
|
||||||
viewx += y;
|
|
||||||
viewy -= x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
|
|
||||||
viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
|
||||||
viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (mh->skybox_scalez > 0)
|
else if (viewmobj->angle == ANGLE_90)
|
||||||
viewz += (thiscam->z + (thiscam->height>>1)) / mh->skybox_scalez;
|
|
||||||
else if (mh->skybox_scalez < 0)
|
|
||||||
viewz += (thiscam->z + (thiscam->height>>1)) * -mh->skybox_scalez;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (skyboxmo[1])
|
|
||||||
{
|
{
|
||||||
fixed_t x = 0, y = 0;
|
viewx -= y;
|
||||||
if (mh->skybox_scalex > 0)
|
viewy += x;
|
||||||
x = (player->mo->x - skyboxmo[1]->x) / mh->skybox_scalex;
|
}
|
||||||
else if (mh->skybox_scalex < 0)
|
else if (viewmobj->angle == ANGLE_180)
|
||||||
x = (player->mo->x - skyboxmo[1]->x) * -mh->skybox_scalex;
|
{
|
||||||
if (mh->skybox_scaley > 0)
|
viewx -= x;
|
||||||
y = (player->mo->y - skyboxmo[1]->y) / mh->skybox_scaley;
|
viewy -= y;
|
||||||
else if (mh->skybox_scaley < 0)
|
}
|
||||||
y = (player->mo->y - skyboxmo[1]->y) * -mh->skybox_scaley;
|
else if (viewmobj->angle == ANGLE_270)
|
||||||
|
{
|
||||||
if (viewmobj->angle == 0)
|
viewx += y;
|
||||||
{
|
viewy -= x;
|
||||||
viewx += x;
|
}
|
||||||
viewy += y;
|
else
|
||||||
}
|
{
|
||||||
else if (viewmobj->angle == ANGLE_90)
|
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
|
||||||
{
|
viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
||||||
viewx -= y;
|
viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
|
||||||
viewy += x;
|
|
||||||
}
|
|
||||||
else if (viewmobj->angle == ANGLE_180)
|
|
||||||
{
|
|
||||||
viewx -= x;
|
|
||||||
viewy -= y;
|
|
||||||
}
|
|
||||||
else if (viewmobj->angle == ANGLE_270)
|
|
||||||
{
|
|
||||||
viewx += y;
|
|
||||||
viewy -= x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
|
|
||||||
viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
|
||||||
viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (mh->skybox_scalez > 0)
|
|
||||||
viewz += player->viewz / mh->skybox_scalez;
|
|
||||||
else if (mh->skybox_scalez < 0)
|
|
||||||
viewz += player->viewz * -mh->skybox_scalez;
|
|
||||||
}
|
}
|
||||||
|
if (mh->skybox_scalez > 0)
|
||||||
|
viewz += campos.z / mh->skybox_scalez;
|
||||||
|
else if (mh->skybox_scalez < 0)
|
||||||
|
viewz += campos.z * -mh->skybox_scalez;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewmobj->subsector)
|
if (viewmobj->subsector)
|
||||||
|
|
Loading…
Reference in a new issue