Skip to content

Commit

Permalink
Refactor|Map Renderer|Client: Continued cleaning up halo and light de…
Browse files Browse the repository at this point in the history
…coration projection
  • Loading branch information
danij-deng committed Sep 8, 2013
1 parent 6866c6d commit d84d602
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 338 deletions.
22 changes: 11 additions & 11 deletions doomsday/client/include/render/rend_halo.h
Expand Up @@ -17,14 +17,16 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBDENG_RENDER_HALO_H
#define LIBDENG_RENDER_HALO_H
#ifndef DENG_CLIENT_RENDER_HALO_H
#define DENG_CLIENT_RENDER_HALO_H

#include <de/Vector>

#include "TextureVariantSpec"

DENG_EXTERN_C int haloOccludeSpeed;
DENG_EXTERN_C int haloMode, haloRealistic, haloBright, haloSize;
DENG_EXTERN_C float haloFadeMax, haloFadeMin, minHaloSize;
DENG_EXTERN_C int haloOccludeSpeed;
DENG_EXTERN_C int haloMode, haloRealistic, haloBright, haloSize;
DENG_EXTERN_C float haloFadeMax, haloFadeMin, minHaloSize;

void H_Register();

Expand All @@ -40,9 +42,7 @@ void H_SetupState(bool dosetup);
*
* The caller must check that @c sourcevis, really has a ->light! (? -jk)
*
* @param x X coordinate of the center of the halo.
* @param y Y coordinate of the center of the halo.
* @param z Z coordinate of the center of the halo.
* @param origin Origin of the halo in map space.
* @param size The precalculated radius of the primary halo.
* @param tex Texture to use for the halo.
* @param color Color for the halo.
Expand All @@ -59,13 +59,13 @@ void H_SetupState(bool dosetup);
*
* @return @c true, iff a halo was rendered.
*/
bool H_RenderHalo(coord_t x, coord_t y, coord_t z, float size,
DGLuint tex, float const color[3],
bool H_RenderHalo(de::Vector3d const &origin, float size,
DGLuint tex, de::Vector3f const &color,
coord_t distanceToViewer, float occlusionFactor,
float brightnessFactor, float viewXOffset,
bool primary, bool viewRelativeRotate);

// Console commands.
D_CMD(FlareConfig);

#endif /* LIBDENG_RENDER_HALO_H */
#endif // DENG_CLIENT_RENDER_HALO_H
10 changes: 4 additions & 6 deletions doomsday/client/include/render/vissprite.h
Expand Up @@ -18,11 +18,10 @@
* 02110-1301 USA</small>
*/

#ifdef __CLIENT__
#ifndef DENG_CLIENT_RENDER_VISSPRITE_H
#define DENG_CLIENT_RENDER_VISSPRITE_H

#ifdef __CLIENT__

#include <de/Vector>

#include "resource/r_data.h"
Expand Down Expand Up @@ -107,7 +106,7 @@ typedef struct vissprite_s {
struct vissprite_s *prev, *next;
visspritetype_t type; // VSPR_* type of vissprite.
coord_t distance; // Vissprites are sorted by distance.
coord_t origin[3];
de::Vector3d origin;

// An anonymous union for the data.
union vissprite_data_u {
Expand Down Expand Up @@ -187,10 +186,9 @@ DENG_EXTERN_C vispsprite_t visPSprites[DDMAXPSPRITES];
/// To be called at the start of the current render frame to clear the vissprite list.
void R_ClearVisSprites();

vissprite_t *R_NewVisSprite();
vissprite_t *R_NewVisSprite(visspritetype_t type);

void R_SortVisSprites();

#endif // __CLIENT__

#endif // DENG_CLIENT_RENDER_VISSPRITE_H
#endif // __CLIENT__
35 changes: 15 additions & 20 deletions doomsday/client/src/render/r_things.cpp
Expand Up @@ -136,12 +136,12 @@ static int findMobjZOriginWorker(Sector *sector, void *parameters)

if(p->floorAdjust && p->mo->origin[VZ] == sector->floor().height())
{
p->vis->origin[VZ] = sector->floor().visHeight();
p->vis->origin.z = sector->floor().visHeight();
}

if(p->mo->origin[VZ] + p->mo->height == sector->ceiling().height())
{
p->vis->origin[VZ] = sector->ceiling().visHeight() - p->mo->height;
p->vis->origin.z = sector->ceiling().visHeight() - p->mo->height;
}

return false; // Continue iteration.
Expand Down Expand Up @@ -261,12 +261,10 @@ void R_ProjectSprite(mobj_t *mo)
}

// Store information in a vissprite.
vissprite_t *vis = R_NewVisSprite();
vis->type = mf? VSPR_MODEL : VSPR_SPRITE;
vis->origin[VX] = moPos.x;
vis->origin[VY] = moPos.y;
vis->origin[VZ] = moPos.z;
vis->distance = distFromEye;
vissprite_t *vis = R_NewVisSprite(mf? VSPR_MODEL : VSPR_SPRITE);

vis->origin = moPos;
vis->distance = distFromEye;

/*
* The Z origin of the visual should match that of the mobj. When smoothing
Expand All @@ -281,7 +279,7 @@ void R_ProjectSprite(mobj_t *mo)
findMobjZOrigin(mo, floorAdjust, vis);
}

coord_t gzt = vis->origin[VZ] + -tex.origin().y;
coord_t gzt = vis->origin.z + -tex.origin().y;

// Determine floor clipping.
coord_t floorClip = mo->floorClip;
Expand Down Expand Up @@ -326,7 +324,7 @@ void R_ProjectSprite(mobj_t *mo)
if(mf->testSubFlag(0, MFF_ALIGN_PITCH))
{
viewdata_t const *viewData = R_ViewData(viewPlayer - ddPlayers);
Vector2d delta((vis->origin[VZ] + gzt) / 2 - viewData->current.origin[VZ], distFromEye);
Vector2d delta((vis->origin.z + gzt) / 2 - viewData->current.origin[VZ], distFromEye);

pitch = -BANG2DEG(bamsAtan2(delta.x * 10, delta.y * 10));
}
Expand Down Expand Up @@ -394,7 +392,7 @@ void R_ProjectSprite(mobj_t *mo)
// Adjust by the floor clip.
gzt -= floorClip;

Vector3d const origin(vis->origin[VX], vis->origin[VY], gzt - ms.height() / 2.0f);
Vector3d const origin(vis->origin.x, vis->origin.y, gzt - ms.height() / 2.0f);
Vector4f ambientColor;
uint vLightListIdx = 0;
evaluateLighting(origin, mo->bspLeaf, vis->distance, fullbright,
Expand All @@ -412,15 +410,14 @@ void R_ProjectSprite(mobj_t *mo)
}
else
{
Vector3d const origin(vis->origin);
Vector4f ambientColor;
uint vLightListIdx = 0;
evaluateLighting(origin, mo->bspLeaf, vis->distance, fullbright,
evaluateLighting(vis->origin, mo->bspLeaf, vis->distance, fullbright,
ambientColor, &vLightListIdx);

ambientColor.w = alpha;

VisSprite_SetupModel(vis->data.model, origin, vis->distance,
VisSprite_SetupModel(vis->data.model, vis->origin, vis->distance,
Vector3d(visOff.x, visOff.y, visOff.z - floorClip),
gzt, yaw, 0, pitch, 0,
mf, nextmf, interp,
Expand Down Expand Up @@ -450,15 +447,13 @@ void R_ProjectSprite(mobj_t *mo)

Lumobj const *lum = mo->bspLeaf->map().lumobj(mo->lumIdx);

vissprite_t *vis = R_NewVisSprite();
vis->type = VSPR_FLARE;
vissprite_t *vis = R_NewVisSprite(VSPR_FLARE);

vis->distance = distFromEye;

// Determine the exact center of the flare.
Vector3d center = moPos + visOff;
vis->origin[VX] = center.x;
vis->origin[VY] = center.y;
vis->origin[VZ] = center.z + lum->zOffset();
vis->origin = moPos + visOff;
vis->origin.z += lum->zOffset();

float flareSize = pl->brightMul;
// X offset to the flare position.
Expand Down

0 comments on commit d84d602

Please sign in to comment.