mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 17:22:12 +00:00
Merge branch 'skybox-quake-fix' into 'master'
Skybox quake fix Fixes earthquake effects not being properly scaled for skyboxes. If a skybox is 16x larger than life, then the quake is only 16th as strong, for instance. Also some skybox scaling code cleanup was done I guess. Probably easier to see it in action than explain what I've done: I've put srb2win-skyboxquakefix.exe in my FTP folder for peeps to be able to test out this branch. Also there is luatest-startquake.lua, which produces a fairly strong (10*FRACUNIT intensity) 3-second quake on pressing the Custom 1 key. See merge request !82
This commit is contained in:
commit
a0179aa29b
1 changed files with 58 additions and 136 deletions
136
src/r_main.c
136
src/r_main.c
|
@ -806,27 +806,43 @@ void R_SkyboxFrame(player_t *player)
|
|||
if (viewmobj->spawnpoint)
|
||||
viewz = ((fixed_t)viewmobj->spawnpoint->angle)<<FRACBITS;
|
||||
|
||||
viewx += quake.x;
|
||||
viewy += quake.y;
|
||||
viewz += quake.z;
|
||||
|
||||
if (mapheaderinfo[gamemap-1])
|
||||
{
|
||||
mapheader_t *mh = mapheaderinfo[gamemap-1];
|
||||
if (player->awayviewtics)
|
||||
{
|
||||
if (skyboxmo[1])
|
||||
vector3_t campos = {0,0,0}; // Position of player's actual view point
|
||||
|
||||
if (player->awayviewtics) {
|
||||
campos.x = player->awayviewmobj->x;
|
||||
campos.y = player->awayviewmobj->y;
|
||||
campos.z = player->awayviewmobj->z + 20*FRACUNIT;
|
||||
} else if (thiscam->chase) {
|
||||
campos.x = thiscam->x;
|
||||
campos.y = thiscam->y;
|
||||
campos.z = thiscam->z + (thiscam->height>>1);
|
||||
} else {
|
||||
campos.x = player->mo->x;
|
||||
campos.y = player->mo->y;
|
||||
campos.z = player->viewz;
|
||||
}
|
||||
|
||||
// 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?
|
||||
{
|
||||
fixed_t x = 0, y = 0;
|
||||
if (mh->skybox_scalex > 0)
|
||||
x = (player->awayviewmobj->x - skyboxmo[1]->x) / mh->skybox_scalex;
|
||||
x = (campos.x - skyboxmo[1]->x) / mh->skybox_scalex;
|
||||
else if (mh->skybox_scalex < 0)
|
||||
x = (player->awayviewmobj->x - skyboxmo[1]->x) * -mh->skybox_scalex;
|
||||
x = (campos.x - skyboxmo[1]->x) * -mh->skybox_scalex;
|
||||
|
||||
if (mh->skybox_scaley > 0)
|
||||
y = (player->awayviewmobj->y - skyboxmo[1]->y) / mh->skybox_scaley;
|
||||
y = (campos.y - skyboxmo[1]->y) / mh->skybox_scaley;
|
||||
else if (mh->skybox_scaley < 0)
|
||||
y = (player->awayviewmobj->y - skyboxmo[1]->y) * -mh->skybox_scaley;
|
||||
y = (campos.y - skyboxmo[1]->y) * -mh->skybox_scaley;
|
||||
|
||||
if (viewmobj->angle == 0)
|
||||
{
|
||||
|
@ -856,103 +872,9 @@ void R_SkyboxFrame(player_t *player)
|
|||
}
|
||||
}
|
||||
if (mh->skybox_scalez > 0)
|
||||
viewz += (player->awayviewmobj->z + 20*FRACUNIT) / mh->skybox_scalez;
|
||||
viewz += campos.z / mh->skybox_scalez;
|
||||
else if (mh->skybox_scalez < 0)
|
||||
viewz += (player->awayviewmobj->z + 20*FRACUNIT) * -mh->skybox_scalez;
|
||||
}
|
||||
else if (thiscam->chase)
|
||||
{
|
||||
if (skyboxmo[1])
|
||||
{
|
||||
fixed_t x = 0, y = 0;
|
||||
if (mh->skybox_scalex > 0)
|
||||
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)
|
||||
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;
|
||||
if (mh->skybox_scalex > 0)
|
||||
x = (player->mo->x - skyboxmo[1]->x) / mh->skybox_scalex;
|
||||
else if (mh->skybox_scalex < 0)
|
||||
x = (player->mo->x - skyboxmo[1]->x) * -mh->skybox_scalex;
|
||||
if (mh->skybox_scaley > 0)
|
||||
y = (player->mo->y - skyboxmo[1]->y) / mh->skybox_scaley;
|
||||
else if (mh->skybox_scaley < 0)
|
||||
y = (player->mo->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)
|
||||
viewz += player->viewz / mh->skybox_scalez;
|
||||
else if (mh->skybox_scalez < 0)
|
||||
viewz += player->viewz * -mh->skybox_scalez;
|
||||
}
|
||||
viewz += campos.z * -mh->skybox_scalez;
|
||||
}
|
||||
|
||||
if (viewmobj->subsector)
|
||||
|
|
Loading…
Reference in a new issue