Skip to content

Commit

Permalink
Fixed mobj Z coordinate when sector's real floor is not visible
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jun 27, 2004
1 parent 281cd67 commit 964af78
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions doomsday/Include/r_things.h
Expand Up @@ -72,6 +72,7 @@ typedef struct vissprite_s {
float yaw, pitch; // For models.
float inter; // Frame interpolation, 0..1
struct lumobj_s *light; // For the halo (NULL if no halo).
boolean flooradjust; // Allow moving sprite to match visible floor.
} mo;
struct vissprite_wall_s {
int texture;
Expand Down
12 changes: 11 additions & 1 deletion doomsday/Src/r_things.c
Expand Up @@ -583,14 +583,20 @@ float R_MovementPitch(fixed_t momx, fixed_t momy, fixed_t momz)
(100 * FIX2FLT(momz), 100 * P_AccurateDistance(momx, momy)));
}

/*
* Determine the correct Z coordinate for the mobj. The visible Z
* coordinate may be slightly different than the actual Z coordinate
* due to smoothed plane movement.
*/
boolean RIT_VisMobjZ(sector_t *sector, void *data)
{
vissprite_t *vis = data;

assert(sector != NULL);
assert(data != NULL);

if(projectedThing->z == sector->floorheight)
if(vis->data.mo.flooradjust &&
projectedThing->z == sector->floorheight)
{
vis->data.mo.gz = FRACUNIT * SECT_FLOOR(sector);
}
Expand Down Expand Up @@ -772,6 +778,9 @@ void R_ProjectSprite(mobj_t *thing)
vis->data.mo.gy = thing->y;
vis->data.mo.gz = thing->z;

vis->data.mo.flooradjust =
(fabs(SECT_FLOOR(sect) - FIX2FLT(sect->floorheight)) < 8);

// The thing's Z coordinate must match the actual visible
// floor/ceiling height. When using smoothing, this requires
// iterating through the sectors (planes) in the vicinity.
Expand All @@ -787,6 +796,7 @@ void R_ProjectSprite(mobj_t *thing)
vis->data.mo.viewaligned = align;

vis->data.mo.secfloor = SECT_FLOOR(thing->subsector->sector);

vis->data.mo.secceil = SECT_CEIL(thing->subsector->sector);

if(thing->ddflags & DDMF_TRANSLATION)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/Src/rend_main.c
Expand Up @@ -55,7 +55,7 @@ extern int dlMaxRad;

boolean useFog = false; // Is the fog in use?
byte fogColor[4];
float fieldOfView = 90.0f;
float fieldOfView = 95.0f;
float maxLightDist = 1024;
boolean smoothTexAnim = true;

Expand Down
3 changes: 2 additions & 1 deletion doomsday/Src/rend_sprite.c
Expand Up @@ -638,7 +638,8 @@ void Rend_RenderSprite(vissprite_t * spr)
if(spr->data.mo.flags & DDMF_FITTOP && top > spr->data.mo.secceil)
top = spr->data.mo.secceil;
// Check bottom.
if(!(spr->data.mo.flags & DDMF_NOFITBOTTOM) &&
if(spr->data.mo.flooradjust &&
!(spr->data.mo.flags & DDMF_NOFITBOTTOM) &&
top - sprh < spr->data.mo.secfloor)
top = spr->data.mo.secfloor + sprh;
}
Expand Down

0 comments on commit 964af78

Please sign in to comment.