Commit 989cc96d authored by NY00123's avatar NY00123 Committed by Evan Ramos
Browse files

sw/src/jsector.cpp:JS_DrawMirrors: Make camera oscilation

less dependent on the frame rate.
It would probably be better to update this from the game loop side,
like in Duke3D, but it's still better than the preceding situation.
parent 9d6c8da0
......@@ -53,8 +53,7 @@ MIRRORTYPE mirror[MAXMIRRORS];
short mirrorcnt; //, floormirrorcnt;
//short floormirrorsector[MAXMIRRORS];
SWBOOL mirrorinview;
SWBOOL MirrorMoveSkip16 = 0;
uint32_t oscilationclock;
// Voxel stuff
//SWBOOL bVoxelsOn = TRUE; // Turn voxels on by default
......@@ -329,6 +328,7 @@ JS_InitMirrors(void)
mirrorcnt = 0;
tilesiz[MIRROR].x = 0;
tilesiz[MIRROR].y = 0;
oscilationclock = ototalclock;
for (i = 0; i < MAXMIRRORS; i++)
{
......@@ -646,8 +646,6 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq
// drift!
SWBOOL bIsWallMirror = FALSE;
MirrorMoveSkip16 = (MirrorMoveSkip16 + 1) & 15;
camloopcnt += (int32_t) (totalclock - ototalclock);
if (camloopcnt > (60 * 5)) // 5 seconds per player view
{
......@@ -661,6 +659,10 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq
longptr = (int *)&gotpic[MIRRORLABEL >> 3];
if (longptr && (longptr[0] || longptr[1]))
{
uint32_t oscilation_delta = ototalclock - oscilationclock;
oscilation_delta -= oscilation_delta % 4;
oscilationclock += oscilation_delta;
oscilation_delta *= 2;
for (cnt = MAXMIRRORS - 1; cnt >= 0; cnt--)
//if (TEST_GOTPIC(cnt + MIRRORLABEL) || TEST_GOTPIC(cnt + CAMSPRITE))
if (TEST_GOTPIC(cnt + MIRRORLABEL) || ((unsigned)mirror[cnt].campic < MAXTILES && TEST_GOTPIC(mirror[cnt].campic)))
......@@ -786,8 +788,6 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq
}
else
{
SWBOOL DoCam = FALSE;
if (mirror[cnt].campic == -1)
{
TerminateGame();
......@@ -797,17 +797,18 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq
}
// BOOL2 = Oscilate camera
if (TEST_BOOL2(sp) && MoveSkip2 == 0)
if (TEST_BOOL2(sp))
{
if (TEST_BOOL3(sp)) // If true add increment to
// angle else subtract
{
// Store current angle in TAG5
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + 4));
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta));
// TAG6 = Turn radius
if (klabs(GetDeltaAngle(SP_TAG5(sp), sp->ang)) >= SP_TAG6(sp))
{
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta));
RESET_BOOL3(sp); // Reverse turn
// direction.
}
......@@ -815,11 +816,12 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq
else
{
// Store current angle in TAG5
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - 4));
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta));
// TAG6 = Turn radius
if (klabs(GetDeltaAngle(SP_TAG5(sp), sp->ang)) >= SP_TAG6(sp))
{
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta));
SET_BOOL3(sp); // Reverse turn
// direction.
}
......@@ -844,29 +846,20 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq
else
camhoriz = 100; // Default
// If player is dead still then update at MoveSkip4
// rate.
if (pp->posx == pp->oposx && pp->posy == pp->oposy && pp->posz == pp->oposz)
DoCam = TRUE;
// Set up the tile for drawing
tilesiz[mirror[cnt].campic].x = tilesiz[mirror[cnt].campic].y = 128;
if (MirrorMoveSkip16 == 0 || (DoCam && (MoveSkip4 == 0)))
if (dist < MAXCAMDIST)
{
if (dist < MAXCAMDIST)
{
PLAYERp cp = Player + camplayerview;
PLAYERp cp = Player + camplayerview;
if (TEST_BOOL11(sp) && numplayers > 1)
{
drawroomstotile(cp->posx, cp->posy, cp->posz, cp->q16ang, cp->q16horiz, cp->cursectnum, mirror[cnt].campic);
}
else
{
drawroomstotile(sp->x, sp->y, sp->z, fix16_from_int(SP_TAG5(sp)), fix16_from_int(camhoriz), sp->sectnum, mirror[cnt].campic);
}
if (TEST_BOOL11(sp) && numplayers > 1)
{
drawroomstotile(cp->posx, cp->posy, cp->posz, cp->q16ang, cp->q16horiz, cp->cursectnum, mirror[cnt].campic);
}
else
{
drawroomstotile(sp->x, sp->y, sp->z, fix16_from_int(SP_TAG5(sp)), fix16_from_int(camhoriz), sp->sectnum, mirror[cnt].campic);
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment