Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed (All Games): Upon spawning into the map the player's viewheight…
… would be set at zero resulting.

Fixed (Engine/All Games): When the player teleports the current view was not instantly updated due to smoothing, resulting in the player momentarily looking in the wrong direction.
Changed (All Games): When starting a new map there is nolonger a momentary wait where the game is running but the player's view is not drawn.
Fixed (DOOM): When starting a new map if the statusbar is visible the counters would be momentarily hidden.
  • Loading branch information
danij-deng committed Nov 28, 2009
1 parent a8f2d18 commit 82872ea
Show file tree
Hide file tree
Showing 54 changed files with 531 additions and 547 deletions.
16 changes: 5 additions & 11 deletions doomsday/engine/api/dd_share.h
Expand Up @@ -282,14 +282,11 @@ enum {
DD_OPENTOP,
DD_OPENBOTTOM,
DD_LOWFLOOR,
DD_VIEWX,
DD_VIEWY,
DD_VIEWZ,
DD_VIEWX_OFFSET,
DD_VIEWY_OFFSET,
DD_VIEWZ_OFFSET,
DD_VIEWANGLE,
DD_VIEWANGLE_OFFSET,
DD_VIEW_X,
DD_VIEW_Y,
DD_VIEW_Z,
DD_VIEW_ANGLE,
DD_VIEW_PITCH,
DD_CPLAYER_THRUST_MUL,
DD_GRAVITY,
DD_PSPRITE_OFFSET_X, // 10x
Expand Down Expand Up @@ -1331,9 +1328,6 @@ typedef struct ticcmd_s {
typedef struct ddplayer_s {
ticcmd_t cmd;
struct mobj_s* mo; // Pointer to a (game specific) mobj.
float viewZ; // Focal origin above r.z.
float viewHeight; // Base height above floor for viewZ.
float viewHeightDelta;
float lookDir; // For mouse look.
int fixedColorMap; // Can be set to REDCOLORMAP, etc.
int extraLight; // So gun flashes light up areas.
Expand Down
35 changes: 24 additions & 11 deletions doomsday/engine/portable/include/r_main.h
Expand Up @@ -34,27 +34,37 @@ typedef struct viewport_s {
int x, y, width, height;
} viewport_t;

extern float viewX, viewY, viewZ;
extern float viewFrontVec[3], viewUpVec[3], viewSideVec[3];
extern float viewXOffset, viewYOffset, viewZOffset;
extern angle_t viewAngle;
extern float viewPitch;
extern angle_t clipAngle;
extern fixed_t fineTangent[FINEANGLES / 2];
typedef struct viewer_s {
float pos[3];
angle_t angle;
float pitch;
} viewer_t;

typedef struct viewdata_s {
viewer_t current; // Current view paramaters.
viewer_t lastSharp[2]; // For smoothing.
float frontVec[3], upVec[3], sideVec[3];
float viewCos, viewSin;

// These are used when camera smoothing is disabled.
angle_t frozenAngle;
float frozenPitch;
} viewdata_t;

extern float viewX, viewY, viewZ, viewPitch;
extern int viewAngle;

extern float frameTimePos; // 0...1: fractional part for sharp game tics
extern boolean resyncFrameTimePos;
extern int loadInStartupMode;
extern int validCount;
extern int viewwidth, viewheight, viewwindowx, viewwindowy;
extern boolean setSizeNeeded;
extern int frameCount;
extern int viewAngleOffset;
extern int extraLight;
extern float extraLightDelta;
extern float viewCos, viewSin;
extern int rendInfoTris;

extern fixed_t fineTangent[FINEANGLES / 2];

void R_Register(void);
void R_Init(void);
void R_Update(void);
Expand All @@ -64,7 +74,10 @@ void R_EndWorldFrame(void);
void R_RenderPlayerView(int num);
void R_RenderPlayerViewBorder(void);
void R_RenderViewPorts(void);

const viewdata_t* R_ViewData(int localPlayerNum);
void R_ResetViewer(void);

void R_SetViewWindow(int x, int y, int w, int h);
void R_NewSharpWorld(void);

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/include/r_util.h
Expand Up @@ -32,8 +32,8 @@
int R_PointOnSide(const float x, const float y,
const partition_t* par);
angle_t R_PointToAngle(float x, float y);
angle_t R_PointToAngle2(const float x1, const float y1,
const float x2, const float y2);
angle_t R_PointToAngle2(float x1, float y1,
float x2, float y2);
float R_PointToDist(const float x, const float y);
linedef_t* R_GetLineForSide(const uint sideIDX);
subsector_t* R_PointInSubsector(const float x, const float y);
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/portable/src/cl_player.c
Expand Up @@ -582,12 +582,10 @@ void Cl_MoveLocalPlayer(float dx, float dy, float z, boolean onground)
if(onground)
{
mo->pos[VZ] = z - 1;
ddpl->viewHeight = 1;
}
else
{
mo->pos[VZ] = z;
ddpl->viewHeight = 0;
}

Cl_UpdatePlayerPos(consolePlayer);
Expand Down
45 changes: 12 additions & 33 deletions doomsday/engine/portable/src/dd_main.c
Expand Up @@ -960,29 +960,20 @@ void* DD_GetVariable(int ddvalue)
case DD_GAME_EXPORTS:
return &gx;

case DD_VIEWX:
case DD_VIEW_X:
return &viewX;

case DD_VIEWY:
case DD_VIEW_Y:
return &viewY;

case DD_VIEWZ:
case DD_VIEW_Z:
return &viewZ;

case DD_VIEWX_OFFSET:
return &viewXOffset;

case DD_VIEWY_OFFSET:
return &viewYOffset;

case DD_VIEWZ_OFFSET:
return &viewZOffset;

case DD_VIEWANGLE:
case DD_VIEW_ANGLE:
return &viewAngle;

case DD_VIEWANGLE_OFFSET:
return &viewAngleOffset;
case DD_VIEW_PITCH:
return &viewPitch;

case DD_SECTOR_COUNT:
return &numSectors;
Expand Down Expand Up @@ -1149,36 +1140,24 @@ void DD_SetVariable(int ddvalue, void *parm)
{
switch(ddvalue)
{
case DD_VIEWX:
case DD_VIEW_X:
viewX = *(float*) parm;
return;

case DD_VIEWY:
case DD_VIEW_Y:
viewY = *(float*) parm;
return;

case DD_VIEWZ:
case DD_VIEW_Z:
viewZ = *(float*) parm;
return;

case DD_VIEWX_OFFSET:
viewXOffset = *(float*) parm;
return;

case DD_VIEWY_OFFSET:
viewYOffset = *(float*) parm;
return;

case DD_VIEWZ_OFFSET:
viewZOffset = *(float*) parm;
return;

case DD_VIEWANGLE:
case DD_VIEW_ANGLE:
viewAngle = *(angle_t*) parm;
return;

case DD_VIEWANGLE_OFFSET:
viewAngleOffset = *(int*) parm;
case DD_VIEW_PITCH:
viewPitch = *(float*) parm;
return;

case DD_CPLAYER_THRUST_MUL:
Expand Down
36 changes: 20 additions & 16 deletions doomsday/engine/portable/src/edit_bias.c
Expand Up @@ -145,9 +145,10 @@ void SBE_Register(void)

static void SBE_GetHand(float pos[3])
{
pos[0] = vx + viewFrontVec[VX] * editDistance;
pos[1] = vz + viewFrontVec[VZ] * editDistance;
pos[2] = vy + viewFrontVec[VY] * editDistance;
const viewdata_t* viewData = R_ViewData(viewPlayer - ddPlayers);
pos[0] = vx + viewData->frontVec[VX] * editDistance;
pos[1] = vz + viewData->frontVec[VZ] * editDistance;
pos[2] = vy + viewData->frontVec[VY] * editDistance;
}

static source_t *SBE_GrabSource(int index)
Expand Down Expand Up @@ -200,13 +201,14 @@ static source_t *SBE_GetNearest(void)

static void SBE_GetHueColor(float *color, float *angle, float *sat)
{
int i;
float dot;
float saturation, hue, scale;
float minAngle = 0.1f, range = 0.19f;
vec3_t h, proj;

dot = M_DotProduct(viewFrontVec, hueOrigin);
int i;
float dot;
float saturation, hue, scale;
float minAngle = 0.1f, range = 0.19f;
vec3_t h, proj;
const viewdata_t* viewData = R_ViewData(viewPlayer - ddPlayers);

dot = M_DotProduct(viewData->frontVec, hueOrigin);
saturation = (acos(dot) - minAngle) / range;

if(saturation < 0)
Expand All @@ -229,12 +231,12 @@ static void SBE_GetHueColor(float *color, float *angle, float *sat)

// Calculate hue angle by projecting the current viewfront to the
// hue circle plane. Project onto the normal and subtract.
scale = M_DotProduct(viewFrontVec, hueOrigin) /
scale = M_DotProduct(viewData->frontVec, hueOrigin) /
M_DotProduct(hueOrigin, hueOrigin);
M_Scale(h, hueOrigin, scale);

for(i = 0; i < 3; ++i)
proj[i] = viewFrontVec[i] - h[i];
proj[i] = viewData->frontVec[i] - h[i];

// Now we have the projected view vector on the circle's plane.
// Normalize the projected vector.
Expand Down Expand Up @@ -439,7 +441,7 @@ void SBE_MenuSave(ui_object_t *ob)

void SBE_SetHueCircle(boolean activate)
{
int i;
int i;

if((signed) activate == editHueCircle)
return; // No change in state.
Expand All @@ -451,12 +453,14 @@ void SBE_SetHueCircle(boolean activate)

if(activate)
{
const viewdata_t* viewData = R_ViewData(viewPlayer - ddPlayers);

// Determine the orientation of the hue circle.
for(i = 0; i < 3; ++i)
{
hueOrigin[i] = viewFrontVec[i];
hueSide[i] = viewSideVec[i];
hueUp[i] = viewUpVec[i];
hueOrigin[i] = viewData->frontVec[i];
hueSide[i] = viewData->sideVec[i];
hueUp[i] = viewData->upVec[i];
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions doomsday/engine/portable/src/m_misc.c
Expand Up @@ -54,6 +54,8 @@
#include "de_graphics.h"
#include "de_refresh.h"
#include "de_misc.h"
#include "de_play.h"

#include "lzss.h"

// MACROS ------------------------------------------------------------------
Expand Down Expand Up @@ -709,20 +711,21 @@ void M_ProjectViewRelativeLine2D(const float center[2],
float width, float offset,
float start[2], float end[2])
{
float sinrv, cosrv;
const viewdata_t* viewData = R_ViewData(viewPlayer - ddPlayers);
float sinrv, cosrv;

if(alignToViewPlane)
{ // Should be fully aligned to view plane.
sinrv = -viewCos;
cosrv = viewSin;
sinrv = -viewData->viewCos;
cosrv = viewData->viewSin;
}
else
{
float trx, try, thangle;
float trx, try, thangle;

// Transform the origin point.
trx = center[VX] - viewX;
try = center[VY] - viewY;
trx = center[VX] - viewData->current.pos[VX];
try = center[VY] - viewData->current.pos[VY];

thangle = BANG2RAD(bamsAtan2(try * 10, trx * 10)) - PI / 2;
sinrv = sin(thangle);
Expand Down
17 changes: 8 additions & 9 deletions doomsday/engine/portable/src/net_demo.c
Expand Up @@ -445,12 +445,13 @@ Con_Printf("RDP: pt=%i ang=%i ld=%i len=%i type=%i\n", ptime,
*/
void Demo_WriteLocalCamera(int plrNum)
{
player_t *plr = &ddPlayers[plrNum];
ddplayer_t *ddpl = &plr->shared;
mobj_t *mo = ddpl->mo;
fixed_t x, y, z;
byte flags;
boolean incfov = (writeInfo[plrNum].fov != fieldOfView);
player_t* plr = &ddPlayers[plrNum];
ddplayer_t* ddpl = &plr->shared;
mobj_t* mo = ddpl->mo;
fixed_t x, y, z;
byte flags;
boolean incfov = (writeInfo[plrNum].fov != fieldOfView);
const viewdata_t* viewData = R_ViewData(plrNum);

if(!mo)
return;
Expand All @@ -474,8 +475,7 @@ void Demo_WriteLocalCamera(int plrNum)
Msg_WriteShort(y >> 16);
Msg_WriteByte(y >> 8);

//z = mo->pos[VZ] + ddpl->viewheight;
z = FLT2FIX(ddpl->viewZ);
z = FLT2FIX(mo->pos[VZ] + viewData->current.pos[VZ]);
Msg_WriteShort(z >> 16);
Msg_WriteByte(z >> 8);

Expand Down Expand Up @@ -577,7 +577,6 @@ void Demo_ReadLocalCamera(void)
R_ResetViewer();
demoFrameZ = z;
Cl_MoveLocalPlayer(posDelta[VX], posDelta[VY], z, demoOnGround);
pl->viewZ = z; // Might get an unsynced frame is not set right now.
posDelta[VX] = posDelta[VY] = posDelta[VZ] = 0;
}
}
Expand Down
26 changes: 0 additions & 26 deletions doomsday/engine/portable/src/p_mobj.c
Expand Up @@ -924,14 +924,6 @@ void P_MobjZMovement(mobj_t *mo)
{
float gravity = FIX2FLT(mapGravity);

// check for smooth step up
if(mo->dPlayer && mo->pos[VZ] < mo->floorZ)
{
mo->dPlayer->viewHeight -= mo->floorZ - mo->pos[VZ];
mo->dPlayer->viewHeightDelta =
(41 - mo->dPlayer->viewHeight) / 8;
}

// Adjust height.
mo->pos[VZ] += mo->mom[MZ];

Expand All @@ -940,15 +932,6 @@ void P_MobjZMovement(mobj_t *mo)
{
if(mo->mom[MZ] < 0)
{
if(mo->dPlayer && mo->mom[MZ] < -gravity * 8)
{
/**
* Decrease viewheight for a moment after hitting the ground
* (hard), and utter appropriate sound.
*/
mo->dPlayer->viewHeightDelta = mo->mom[MZ] / 8;
}

mo->mom[MZ] = 0;
}

Expand All @@ -962,15 +945,6 @@ void P_MobjZMovement(mobj_t *mo)
// Hit the floor.
if(mo->mom[MZ] < 0)
{
if(mo->dPlayer && mo->mom[MZ] < -gravity * 8)
{
/**
* Decrease viewheight for a moment after hitting the ground
* (hard), and utter appropriate sound.
*/
mo->dPlayer->viewHeightDelta = mo->mom[MZ] / 8;
}

mo->mom[MZ] = 0;
}

Expand Down

0 comments on commit 82872ea

Please sign in to comment.