Skip to content

Commit

Permalink
Weapon offset Y scale, bob offset, fixed HUD sprite texcoords
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jun 27, 2003
1 parent e0b7779 commit 2604326
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 10 deletions.
8 changes: 4 additions & 4 deletions doomsday/Include/r_things.h
Expand Up @@ -91,11 +91,9 @@ typedef struct
float flarex; // Offset to flare.
float flarey;
float lumsize;
float tc[2]; // Texture coordinates.
float tc[2][2]; // Prepared texture coordinates.
DGLuint tex; // Name of the associated DGL texture.
DGLuint hudtex;
short hudwidth;
short hudheight;
DGLuint hudtex; // Name of the HUD sprite texture.
rgbcol_t color; // Average color, for lighting.
} spritelump_t;

Expand All @@ -106,6 +104,7 @@ extern int numspritelumps;
extern int pspOffX, pspOffY;
extern int alwaysAlign;
extern float weaponOffsetScale, weaponFOVShift;
extern int weaponOffsetScaleY;
extern int r_maxmodelz, r_nospritez;
extern int r_use_srvo, r_use_srvo_angle;
extern vissprite_t vissprites[MAXVISSPRITES], *vissprite_p;
Expand All @@ -114,6 +113,7 @@ extern vissprite_t vsprsortedhead;

void R_GetSpriteInfo(int sprite, int frame, spriteinfo_t *sprinfo);
int R_VisualRadius(mobj_t *mo);
fixed_t R_GetBobOffset(mobj_t *mo);
void R_ProjectSprite(mobj_t *thing);
void R_ProjectPlayerSprites(void);
void R_ProjectDecoration(mobj_t *source);
Expand Down
52 changes: 46 additions & 6 deletions doomsday/Src/r_things.c
Expand Up @@ -34,11 +34,10 @@

// EXTERNAL DATA DECLARATIONS ----------------------------------------------

extern int gametic;

// PUBLIC DATA DEFINITIONS -------------------------------------------------

float weaponOffsetScale = 0.3183f; // 1/Pi
int weaponOffsetScaleY = 1000;
float weaponFOVShift = 45;
int alwaysAlign = 0;
int r_nospritez = false;
Expand Down Expand Up @@ -68,6 +67,27 @@ int r_maxmodelz = 1500;

// PRIVATE DATA DEFINITIONS ------------------------------------------------

// The floatbob offsets from Hexen.
static fixed_t bobOffsets[64] =
{
0, 51389, 102283, 152192,
200636, 247147, 291278, 332604,
370727, 405280, 435929, 462380,
484378, 501712, 514213, 521763,
524287, 521763, 514213, 501712,
484378, 462380, 435929, 405280,
370727, 332604, 291278, 247147,
200636, 152192, 102283, 51389,
-1, -51390, -102284, -152193,
-200637, -247148, -291279, -332605,
-370728, -405281, -435930, -462381,
-484380, -501713, -514215, -521764,
-524288, -521764, -514214, -501713,
-484379, -462381, -435930, -405280,
-370728, -332605, -291279, -247148,
-200637, -152193, -102284, -51389
};

// CODE --------------------------------------------------------------------

/*
Expand Down Expand Up @@ -474,7 +494,7 @@ void R_ProjectPlayerSprites(void)
vis->mo.inter = R_CheckModelFor(&dummy, &mf, &nextmf);
if(!mf)
{
// No, draw a 2D sprite instead (in R_DrawPlayerSprites).
// No, draw a 2D sprite instead (in Rend_DrawPlayerSprites).
continue;
}
// Mark this sprite rendered.
Expand All @@ -501,7 +521,8 @@ void R_ProjectPlayerSprites(void)
vis->mo.floorclip = 0;
// Offsets to rotation angles.
vis->mo.v2[VX] = psp->x * weaponOffsetScale - 90;
vis->mo.v2[VY] = (32-psp->y) * weaponOffsetScale;
vis->mo.v2[VY] = (32 - psp->y) * weaponOffsetScale
* weaponOffsetScaleY/1000.0f;
// Is the FOV shift in effect?
if(weaponFOVShift > 0 && fieldOfView > 90)
vis->mo.v2[VY] -= weaponFOVShift * (fieldOfView - 90)/90;
Expand Down Expand Up @@ -682,6 +703,11 @@ void R_ProjectSprite (mobj_t *thing)

// Foot clipping.
vis->mo.floorclip = thing->floorclip;
if(thing->ddflags & DDMF_BOB)
{
// Bobbing is applied to the floorclip.
vis->mo.floorclip += R_GetBobOffset(thing);
}

// The start and end vertices.
vis->mo.v1[VX] = v1[VX];
Expand All @@ -700,7 +726,7 @@ void R_ProjectSprite (mobj_t *thing)
}
else if(mf->sub[0].flags & MFF_SPIN)
{
vis->mo.yaw = 70 * gametic/35.0f + (int)thing % 360;
vis->mo.yaw = 70 * leveltic/35.0f + (int)thing % 360;
}
else if(mf->sub[0].flags & MFF_MOVEMENT_YAW)
{
Expand All @@ -718,7 +744,8 @@ void R_ProjectSprite (mobj_t *thing)
if(mf->sub[0].flags & MFF_IDANGLE)
{
// Multiply with an arbitrary factor.
vis->mo.yaw += (thing->thinker.id * 27) % 360;
vis->mo.yaw += (thing->thinker.id * 26
+ ((unsigned)thing>>8)) % 360;
}

if(mf->sub[0].flags & MFF_ALIGN_PITCH)
Expand Down Expand Up @@ -908,3 +935,16 @@ void R_SortVisSprites (void)
}
}

/*
* Returns the current floatbob offset for the mobj, if the mobj is flagged
* for bobbing.
*/
fixed_t R_GetBobOffset(mobj_t *mo)
{
if(mo->ddflags & DDMF_BOB)
{
return bobOffsets[(mo->thinker.id * 26 + ((unsigned)mo >> 8)
+ leveltic) & 63];
}
return 0;
}

0 comments on commit 2604326

Please sign in to comment.