Skip to content

Commit

Permalink
fix sprite rotation in 3d;fix sky when looking up
Browse files Browse the repository at this point in the history
  • Loading branch information
elhobbs committed Aug 26, 2016
1 parent 7046ae5 commit 3e512be
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 20 deletions.
4 changes: 1 addition & 3 deletions source/H2_MAIN.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,7 @@ static void DrawAndBlit(void)
MN_Drawer();

// Send out any new accumulation
if ((screen_side & 1) != 0) {
NetUpdate();
}
NetUpdate();

// Flush buffered stuff to screen
I_Update();
Expand Down
71 changes: 56 additions & 15 deletions source/R_MAIN.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "r_local.h"

int viewangleoffset;
int _viewx, _viewy;

#ifdef __WATCOMC__
int newViewAngleOff;
Expand Down Expand Up @@ -276,6 +277,53 @@ angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2)
return R_PointToAngle (x2, y2);
}

angle_t R_PointToAngle3(fixed_t x, fixed_t y)
{
x -= _viewx;
y -= _viewy;
if ((!x) && (!y))
return 0;
if (x >= 0)
{ // x >=0
if (y >= 0)
{ // y>= 0
if (x>y)
return tantoangle[SlopeDiv(y, x)]; // octant 0
else
return ANG90 - 1 - tantoangle[SlopeDiv(x, y)]; // octant 1
}
else
{ // y<0
y = -y;
if (x>y)
return -tantoangle[SlopeDiv(y, x)]; // octant 8
else
return ANG270 + tantoangle[SlopeDiv(x, y)]; // octant 7
}
}
else
{ // x<0
x = -x;
if (y >= 0)
{ // y>= 0
if (x>y)
return ANG180 - 1 - tantoangle[SlopeDiv(y, x)]; // octant 3
else
return ANG90 + tantoangle[SlopeDiv(x, y)]; // octant 2
}
else
{ // y<0
y = -y;
if (x>y)
return ANG180 + tantoangle[SlopeDiv(y, x)]; // octant 4
else
return ANG270 - 1 - tantoangle[SlopeDiv(x, y)]; // octant 5
}
}

return 0;
}


fixed_t R_PointToDist (fixed_t x, fixed_t y)
{
Expand Down Expand Up @@ -845,15 +893,16 @@ void R_RenderPlayerView (player_t *player)
int sep = (slideamt*5.0f);
angle_t ang = (slideamt*ANG5);
fixed_t vsin, vcos;
boolean run_netupdate = false;

R_SetupFrame (player);

_viewx = viewx;
_viewy = viewy;

if (*slider > 0.0f && !MenuActive) {
if (screen_side == 1) {
ang = -ang;
sep = -sep;
run_netupdate = true;
}

vsin = finesine[(viewangle - ANG90) >> ANGLETOFINESHIFT];
Expand All @@ -864,15 +913,13 @@ void R_RenderPlayerView (player_t *player)
viewy -= sep * vsin;
viewangleoffset = -sep;
}
else {
run_netupdate = true;
}


R_ClearClipSegs ();
R_ClearDrawSegs ();
R_ClearPlanes ();
R_ClearSprites ();
NetUpdate (); // check for new console commands
NetUpdate(); // check for new console commands

// Make displayed player invisible locally
if (localQuakeHappening[displayplayer] && gamestate == GS_LEVEL)
Expand All @@ -886,15 +933,9 @@ void R_RenderPlayerView (player_t *player)
R_RenderBSPNode (numnodes-1); // head node is the last node output
}

if (run_netupdate) {
NetUpdate(); // check for new console commands
}
NetUpdate(); // check for new console commands
R_DrawPlanes ();
if (run_netupdate) {
NetUpdate(); // check for new console commands
}
NetUpdate(); // check for new console commands
R_DrawMasked ();
if (run_netupdate) {
NetUpdate(); // check for new console commands
}
NetUpdate(); // check for new console commands
}
2 changes: 1 addition & 1 deletion source/R_PLANE.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void R_MakeSpans(int x, int t1, int b1, int t2, int b2)
//
//==========================================================================

#define SKYTEXTUREMIDSHIFTED 200
#define SKYTEXTUREMIDSHIFTED 240

void R_DrawPlanes(void)
{
Expand Down
4 changes: 3 additions & 1 deletion source/R_THINGS.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ void R_DrawVisSprite (vissprite_t *vis, int x1, int x2)
===================
*/

angle_t R_PointToAngle3(fixed_t x, fixed_t y);

void R_ProjectSprite (mobj_t *thing)
{
fixed_t trx,try;
Expand Down Expand Up @@ -519,7 +521,7 @@ void R_ProjectSprite (mobj_t *thing)

if (sprframe->rotate)
{ // choose a different rotation based on player view
ang = R_PointToAngle (thing->x, thing->y);
ang = R_PointToAngle3 (thing->x, thing->y);
rot = (ang-thing->angle+(unsigned)(ANG45/2)*9)>>29;
lump = sprframe->lump[rot];
flip = (boolean)sprframe->flip[rot];
Expand Down

0 comments on commit 3e512be

Please sign in to comment.