Skip to content

Commit

Permalink
Refactor|Map Renderer: Restructured middle material coordinate calcul…
Browse files Browse the repository at this point in the history
…ations

This logic had become rather obfuscated and difficult to follow. This
new layout is much cleaner and easier to follow.
  • Loading branch information
danij-deng committed Sep 2, 2012
1 parent e346465 commit 03c4597
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 278 deletions.
74 changes: 14 additions & 60 deletions doomsday/engine/portable/include/linedef.h
Expand Up @@ -67,9 +67,22 @@ coord_t LineDef_PointXYOnSide(const LineDef* lineDef, coord_t x, coord_t y);
*/
void LineDef_SetDivline(const LineDef* lineDef, divline_t* divline);

/**
* Find the Z coordinate range of the opening on @a side. The open range is defined
* as the gap between foor and ceiling on @a side clipped by the floor and ceiling
* planes on the back side (if present).
*
* @param line LineDef instance.
* @param bottom Bottom Z height is written here. Can be @c NULL.
* @param top Top Z height is written here. Can be @c NULL.
*
* @return Height of the open range.
*/
coord_t LineDef_OpenRange(const LineDef* line, int side, coord_t* bottom, coord_t* top);

/**
* Configure the specified TraceOpening according to the opening defined by the
* inner-minimal planes heights which intercept this LineDef.
* inner-minimal plane heights which intercept this LineDef
*
* @param lineDef LineDef instance.
* @param opening TraceOpening instance to be configured.
Expand Down Expand Up @@ -102,38 +115,6 @@ void LineDef_UpdateSlope(LineDef* lineDef);
*/
void LineDef_UpdateAABox(LineDef* lineDef);

/**
* @param lineDef LineDef instance.
* @return Minimal floor Plane which interfaces with this LineDef.
* If both front and back floor Plane interfaces exist and are equal,
* the front plane is returned. May return @c NULL if no interfaces.
*/
Plane* LineDef_FloorMin(const LineDef* lineDef);

/**
* @param lineDef LineDef instance.
* @return Maximal floor Plane which interfaces with this LineDef.
* If both front and back floor Plane interfaces exist and are equal,
* the front plane is returned. May return @c NULL if no interfaces.
*/
Plane* LineDef_FloorMax(const LineDef* lineDef);

/**
* @param lineDef LineDef instance.
* @return Minimal ceiling Plane which interfaces with this LineDef.
* If both front and back ceiling Plane interfaces exist and are equal,
* the front plane is returned. May return @c NULL if no interfaces.
*/
Plane* LineDef_CeilingMin(const LineDef* lineDef);

/**
* @param lineDef LineDef instance.
* @return Maximal ceiling Plane which interfaces with this LineDef.
* If both front and back ceiling Plane interfaces exist and are equal,
* the front plane is returned. May return @c NULL if no interfaces.
*/
Plane* LineDef_CeilingMax(const LineDef* lineDef);

/**
* The DOOM lighting model applies a sector light level delta when drawing
* line segments based on their 2D world angle.
Expand All @@ -145,33 +126,6 @@ Plane* LineDef_CeilingMax(const LineDef* lineDef);
*/
void LineDef_LightLevelDelta(LineDef* lineDef, int side, float* deltaL, float* deltaR);

/**
* @param lineDef LineDef instance.
* @param side Side of LineDef to test. Non-zero value signifies the BACK side.
*
* @return @c true iff the SideDef on the referenced @a lineDef @a side has
* a "middle" Material which completely covers any opening (gap between
* floor and ceiling planes) on that side of the line.
*/
boolean LineDef_MiddleMaterialCoversOpening(LineDef* lineDef, int side, boolean ignoreAlpha);

/**
* Calculate coordinates for a "middle" Material if present.
*
* @param lineDef LineDef instance.
* @param side Side of the LineDef we are interested in.
* @param bottomLeft Z map space coordinate of the bottom left of the Material written here.
* @param bottomRight Z map space coordinate of the bottom right of the Material written here.
* @param topLeft Z map space coordinate of the top left of the Material written here.
* @param topRight Z map space coordinate of the top right of the Material written here.
* @param texOffY Offset to the top of the Material written here.
*
* @return @c true iff the middle Material is visible (in the opening).
*/
int LineDef_MiddleMaterialCoords(LineDef* lineDef, int side,
coord_t* bottomLeft, coord_t* bottomRight, coord_t* topLeft, coord_t* topRight, float* texOffY,
boolean lowerUnpeg, boolean clipBottom, boolean clipTop);

/**
* Get a property value, selected by DMU_* name.
*
Expand Down
13 changes: 11 additions & 2 deletions doomsday/engine/portable/include/r_world.h
Expand Up @@ -89,8 +89,7 @@ void R_UpdatePlanes(void);
void R_ClearSectorFlags(void);
void R_MapInitSurfaceLists(void);

void R_OrderVertices(const LineDef* line, const Sector* sector,
Vertex* verts[2]);
void R_OrderVertices(const LineDef* line, const Sector* sector, Vertex* verts[2]);

/**
* @param matOffset Can be @c NULL.
Expand All @@ -99,6 +98,16 @@ boolean R_FindBottomTop(LineDef* line, int side, SideDefSection section,
Sector* frontSec, Sector* backSec, SideDef* frontSideDef,
coord_t* low, coord_t* hi, float matOffset[2]);

/**
* @param lineDef LineDef instance.
* @param side Side of LineDef to test. Non-zero value signifies the BACK side.
*
* @return @c true iff the SideDef on the referenced @a lineDef @a side has
* a "middle" Material which completely covers any opening (gap between
* floor and ceiling planes) on that side of the line.
*/
boolean R_MiddleMaterialCoversOpening(LineDef* lineDef, int side, boolean ignoreAlpha);

Plane* R_NewPlaneForSector(Sector* sec);
void R_DestroyPlaneOfSector(uint id, Sector* sec);

Expand Down
4 changes: 4 additions & 0 deletions doomsday/engine/portable/include/render/rend_main.h
Expand Up @@ -33,6 +33,8 @@
#include "rend_list.h"
#include "r_things.h"

struct materialvariantspecification_s;

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -79,6 +81,8 @@ void Rend_ModelViewMatrix(boolean use_angles);

#define Rend_PointDist2D(c) (fabs((vOrigin[VZ]-c[VY])*viewsidex - (vOrigin[VX]-c[VX])*viewsidey))

const struct materialvariantspecification_s* Rend_MapSurfaceDiffuseMaterialSpec(void);

coord_t Rend_PointDist3D(coord_t const point[3]);
void Rend_ApplyTorchLight(float* color, float distance);

Expand Down

0 comments on commit 03c4597

Please sign in to comment.