Skip to content

Commit

Permalink
Revised method for texturing planes. Rather than aligning to the worl…
Browse files Browse the repository at this point in the history
…d grid, subsector planes are now textured using the bbox of the subsector to derive the s, t tex coords. This allows for all world surfaces to be textured using the same algorithms by using an conceptual quad for mapping.

Rewrote dynlight projection to use a unified, 3D dimensional method which is used on all world surfaces. Also improved memory management for dynlight link lists to reduce per-frame overhead somewhat.
Rewrote the surface decoration plotting to use a unified method which is used on all world surfaces.
Added world surface normal drawer for debug purposes.
Added lumobj_t drawer for debug purposes.
Fixed logic bug in RL_AddPoly which was resulted in dynlights for a lit poly not being drawn rarely.
Fixed bug in the surface decoration plotting which used the surface normal incorrectly when applying the decoration elevation offset.
Fixed bug in GL_PrepareMaterial2 which meant that all types of particle generator were cross-referenced with the surface material name, even if not a surface generator. 
Renamed P_PointOnLineSide to P_PointOnLinedefSide and added a new P_PointOnLineSide whose input is a point on the line, line x/y deltas and the point to be tested.
cvar rend-glow-fog-bright replaced with rend-light-fog-bright which is used universally on all lights when fog is enabled.
  • Loading branch information
danij committed Jul 21, 2008
1 parent 87dde8e commit eff6b3e
Show file tree
Hide file tree
Showing 28 changed files with 1,357 additions and 1,100 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/doomsday.def
Expand Up @@ -153,7 +153,7 @@ EXPORTS
P_AccurateDistance @57 NONAME
P_ApproxDistance @58 NONAME
P_ApproxDistance3 @243 NONAME
P_PointOnLineSide @59 NONAME
P_PointOnLinedefSide @59 NONAME
P_BoxOnLineSide @60 NONAME
P_MakeDivline @61 NONAME
P_PointOnDivlineSide @62 NONAME
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -143,7 +143,7 @@ extern "C" {
void B_FormEventString(char *buff, evtype_t type, evstate_t state,
int data1);
int B_BindingsForCommand(const char *cmd, char *buf, int bufSize);
int B_BindingsForControl(int localPlayer, const char *controlName, char *buf,
int B_BindingsForControl(int localPlayer, const char *controlName, char *buf,
int bufSize);
void DD_AddBindClass(struct bindclass_s *);
boolean DD_SetBindClass(unsigned int classID, int type);
Expand Down Expand Up @@ -209,7 +209,7 @@ extern "C" {
float P_AccurateDistance(float dx, float dy);
float P_ApproxDistance(float dx, float dy);
float P_ApproxDistance3(float dx, float dy, float dz);
int P_PointOnLineSide(float x, float y,
int P_PointOnLinedefSide(float x, float y,
struct linedef_s *line);
int P_BoxOnLineSide(float *tmbox, struct linedef_s *ld);
void P_MakeDivline(struct linedef_s *li, divline_t *dl);
Expand Down
5 changes: 3 additions & 2 deletions doomsday/engine/data/cphelp.txt
Expand Up @@ -642,6 +642,9 @@ desc = Dynamic lights color blending mode: 0=normal, 1=additive, 2=no blending.
[rend-light-bright]
desc = Intensity factor for dynamic lights.

[rend-light-fog-bright]
desc = Brightness of dynamic lights when fog is enabled.

[rend-light-num]
desc = The maximum number of dynamic lights. 0=no limit.

Expand Down Expand Up @@ -687,8 +690,6 @@ desc = Max height of wall glow (default: 100).
[rend-glow-scale]
desc = A multiplier for glow height (default: 1).

[rend-glow-fog-bright]
desc = Brightness of wall glow when fog is enabled.

[rend-halo]
desc = Number of flares to draw per light.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/defs/flags.ded
Expand Up @@ -31,8 +31,8 @@ Flag { # Allow using decoration with external resources.
}

# Lights
Flag { ID = "lgf_nohalo"; Value = 0x100; }
Flag { ID = "lgf_dontturnhalo"; Value = 0x200; }
Flag { ID = "lgf_nohalo"; Value = 0x1; }
Flag { ID = "lgf_dontturnhalo"; Value = 0x2; }

# Map Info
Flag { ID = "mif_fog"; Value = 0x1; }
Expand Down
19 changes: 10 additions & 9 deletions doomsday/engine/portable/include/m_vector.h
Expand Up @@ -4,7 +4,7 @@
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2004-2008 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2007 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006-2008 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*/

/*
/**
* m_vector.h: Vector Math
*/

Expand All @@ -48,22 +48,22 @@ void V2_Scale(pvec2_t vector, float scalar);
void V2_Rotate(pvec2_t vec, float radians);
void V2_Sum(pvec2_t dest, const pvec2_t src1, const pvec2_t src2);
void V2_Subtract(pvec2_t dest, const pvec2_t src1,
const pvec2_t src2);
const pvec2_t src2);
float V2_DotProduct(const pvec2_t a, const pvec2_t b);
float V2_ScalarProject(const pvec2_t a, const pvec2_t b);
void V2_Project(pvec2_t dest, const pvec2_t a, const pvec2_t b);
boolean V2_IsParallel(const pvec2_t a, const pvec2_t b);
boolean V2_IsZero(const pvec2_t vec);
float V2_Intersection(const pvec2_t p1, const pvec2_t delta1,
const pvec2_t p2, const pvec2_t delta2,
pvec2_t point);
const pvec2_t p2, const pvec2_t delta2,
pvec2_t point);
float V2_Intercept(const pvec2_t a, const pvec2_t b, const pvec2_t c,
const pvec2_t d, pvec2_t point);
const pvec2_t d, pvec2_t point);
boolean V2_Intercept2(const pvec2_t a, const pvec2_t b,
const pvec2_t c, const pvec2_t d, pvec2_t point,
float *abFrac, float *cdFrac);
const pvec2_t c, const pvec2_t d, pvec2_t point,
float *abFrac, float *cdFrac);
void V2_Lerp(pvec2_t dest, const pvec2_t a, const pvec2_t b,
float c);
float c);
void V2_InitBox(arvec2_t box, const pvec2_t point);
void V2_AddToBox(arvec2_t box, const pvec2_t point);

Expand All @@ -88,6 +88,7 @@ float V3_ClosestPointOnPlane(pvec3_t dest,
const pvec3_t planeNormal,
const pvec3_t planePoint,
const pvec3_t arbPoint);
int V3_MajorAxis(const pvec3_t vec);
boolean V3_IsZero(const pvec3_t vec);
void V3_Lerp(pvec3_t dest, const pvec3_t a, const pvec3_t b,
float c);
Expand Down
12 changes: 7 additions & 5 deletions doomsday/engine/portable/include/mapdata.hs
Expand Up @@ -107,19 +107,21 @@ end

struct subsector
UINT uint segCount
PTR seg_s** segs // [segcount] size.
PTR polyobj_s* polyObj // NULL, if there is no polyobj.
PTR seg_s** segs // [segcount] size.
PTR polyobj_s* polyObj // NULL, if there is no polyobj.
PTR sector_s* sector
- uint inSectorID
- int flags
- int validCount
- uint group
- uint[NUM_REVERB_DATA] reverb
- fvertex_t bBox[2] // Min and max points.
- fvertex_t midPoint // Center of vertices.
- fvertex_t bBox[2] // Min and max points.
- float[2] worldGridOffset // Offset to align the top left of the bBox to the world grid.
- fvertex_t midPoint // Center of vertices.
- ushort numVertices
- fvertex_s** vertices // [numvertices] size
- fvertex_s** vertices // [numvertices] size
- shadowlink_s* shadows

end

public
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/p_maptypes.h
Expand Up @@ -109,6 +109,7 @@ typedef struct subsector_s {
unsigned int group;
unsigned int reverb[NUM_REVERB_DATA];
fvertex_t bBox[2]; // Min and max points.
float worldGridOffset[2]; // Offset to align the top left of the bBox to the world grid.
fvertex_t midPoint; // Center of vertices.
unsigned short numVertices;
struct fvertex_s** vertices; // [numvertices] size
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/portable/include/p_maputil.h
Expand Up @@ -47,8 +47,8 @@ float P_ApproxDistance3(float dx, float dy, float dz);
void P_LineUnitVector(linedef_t *line, float *unitvec);
float P_MobjPointDistancef(mobj_t *start, mobj_t *end,
float *fixpoint);
int P_PointOnLineSide(float x, float y, linedef_t *line);
int P_PointOnLineSide2(double pointX, double pointY,
int P_PointOnLinedefSide(float x, float y, linedef_t *line);
int P_PointOnLinedefSide2(double pointX, double pointY,
double lineDX, double lineDY,
double linePerp, double lineLength,
double epsilon);
Expand All @@ -62,7 +62,7 @@ int P_BoxOnLineSide3(const int bbox[4], double lineSX,
void P_MakeDivline(linedef_t *li, divline_t *dl);
int P_PointOnDivlineSide(float x, float y, divline_t *line);
float P_InterceptVector(divline_t *v2, divline_t *v1);
int P_FloatPointOnLineSide(fvertex_t *pnt, fdivline_t *dline);
int P_PointOnDivLineSidef(fvertex_t *pnt, fdivline_t *dline);
float P_FloatInterceptVertex(fvertex_t *start, fvertex_t *end,
fdivline_t *fdiv, fvertex_t *inter);
void P_LineOpening(linedef_t *linedef);
Expand Down
17 changes: 9 additions & 8 deletions doomsday/engine/portable/include/r_data.h
Expand Up @@ -91,23 +91,24 @@ typedef struct walldiv_s {

typedef struct rendpoly_wall_s {
float length;
walldiv_t divs[2]; // For wall segments (two vertices).
walldiv_t divs[2]; // For wall segments (two vertices).
} rendpoly_wall_t;

// rendpoly_params_t is only for convenience; the data written in the rendering
// list data buffer is taken from this struct.
typedef struct rendpoly_params_s {
boolean isWall;
rendpolytype_t type;
short flags; // RPF_*.
float texOffset[2]; // Texture coordinates for left/top
// (in real texcoords).
short flags; // RPF_*.
float texOrigin[2][3]; // Used in texture coordinate calculation.
float texOffset[2]; // Texture coordinates for left/top
// (in real texcoords).
gltexture_t tex;
gltexture_t interTex;
float interPos; // Blending strength (0..1).
uint lightListIdx; // List of lights that affect this poly.
blendmode_t blendMode; // Primitive-specific blending mode.
rendpoly_wall_t* wall; // Wall specific data if any.
float interPos; // Blending strength (0..1).
uint lightListIdx; // List of lights that affect this poly.
blendmode_t blendMode; // Primitive-specific blending mode.
rendpoly_wall_t* wall; // Wall specific data if any.
} rendpoly_params_t;

// This is the dummy mobj_t used for blockring roots.
Expand Down
40 changes: 23 additions & 17 deletions doomsday/engine/portable/include/r_lumobjs.h
Expand Up @@ -32,45 +32,49 @@
// Lumobj Flags.
#define LUMF_USED 0x1
#define LUMF_RENDERED 0x2
#define LUMF_CLIPPED 0x4 // Hidden by world geometry.
#define LUMF_NOHALO 0x100
#define LUMF_DONTTURNHALO 0x200
#define LUMF_CLIPPED 0x4 // Hidden by world geometry.

// lumobj, omni flags
#define LUMOF_NOHALO 0x1
#define LUMOF_DONTTURNHALO 0x2

// Lumobject types.
typedef enum {
LT_OMNI, // Omni (spherical) light.
LT_PLANE // Planar light.
LT_OMNI, // Omni (spherical) light.
LT_PLANE, // Planar light.
} lumtype_t;

// Helper macros for accessing lum data.
#define LUM_OMNI(x) (&((x)->data.omni))
#define LUM_PLANE(x) (&((x)->data.plane))

typedef struct lumobj_s { // For dynamic lighting.
typedef struct lumobj_s {
lumtype_t type;
int flags; // LUMF_* flags.
float pos[3]; // Center of the light.
float color[3];
int flags; // LUMF_* flags.
float pos[3]; // Center of the obj.
float distanceToViewer;
subsector_t *subsector;

union lumobj_data_u {
struct lumobj_omni_s {
int radius; // Radius for this omnilight source.
float zOff; // Offset to center from pos[VZ].
DGLuint tex; // Lightmap texture.
DGLuint floorTex, ceilTex; // Lightmaps for floor/ceil.
int flags; // LUMOF_* flags.
float color[3];
int radius; // Radius for this omnilight source.
float zOff; // Offset to center from pos[VZ].
DGLuint tex; // Lightmap texture.
DGLuint floorTex, ceilTex; // Lightmaps for floor/ceil.

// For flares (halos).
int flareSize;
byte haloFactor;
float xOff;
DGLuint flareTex; // Flaremap if flareCustom ELSE (flaretexName id.
// Zero = automatical)
boolean flareCustom; // True id flareTex is a custom flare graphic
float flareMul; // Flare brightness factor.
DGLuint flareTex; // Flaremap if flareCustom ELSE (flaretexName id.
// Zero = automatical)
boolean flareCustom; // True id flareTex is a custom flare graphic
float flareMul; // Flare brightness factor.
} omni;
struct lumobj_plane_s {
float color[3];
float intensity;
DGLuint tex;
float normal[3];
Expand Down Expand Up @@ -117,5 +121,7 @@ boolean LO_LumobjsRadiusIterator(subsector_t *subsector, float x, float
void LO_ClipInSubsector(uint ssecidx);
void LO_ClipBySight(uint ssecidx);

#if _DEBUG
void LO_DrawLumobjs(void);
#endif
#endif
23 changes: 11 additions & 12 deletions doomsday/engine/portable/include/rend_dyn.h
Expand Up @@ -4,7 +4,7 @@
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2008 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2007 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006-2008 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -32,9 +32,9 @@
#include "p_object.h"
#include "rend_list.h"

#define DYN_ASPECT 1.1f // 1.2f is just too round for Doom.
#define DYN_ASPECT (1.1f) // 1.2f is just too round for Doom.

#define MAX_GLOWHEIGHT 1024.0f // Absolute max glow height
#define MAX_GLOWHEIGHT (1024.0f) // Absolute max glow height.

/**
* The data of a projected dynamic light is stored in this structure.
Expand All @@ -47,11 +47,10 @@ typedef struct dynlight_s {
DGLuint texture;
} dynlight_t;

extern int useDynLights, dlBlend;
extern float dlFactor;
extern int useWallGlow, glowHeightMax;
extern float glowHeightFactor;
extern float glowFogBright;
extern int useDynLights, dlBlend;
extern float dlFactor, dlFogBright;
extern int useWallGlow, glowHeightMax;
extern float glowHeightFactor;

// Initialization
void DL_Register(void);
Expand All @@ -61,12 +60,12 @@ void DL_InitForMap(void);
void DL_InitForNewFrame(void);

// Action.
uint DL_ProcessSegSection(seg_t *seg, float bottom, float top,
uint DL_ProcessSegSection(seg_t* seg, float bottom, float top,
boolean sortBrightestFirst);
uint DL_ProcessSubSectorPlane(subsector_t *subsector, uint plane);
uint DL_ProcessSubSectorPlane(subsector_t* ssec, uint plane);

// Helpers.
boolean DL_ListIterator(uint listIdx, void *data,
boolean (*func) (const dynlight_t *, void *data));
boolean DL_ListIterator(uint listIdx, void* data,
boolean (*func) (const dynlight_t*, void*));

#endif
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/bsp_node.c
Expand Up @@ -80,7 +80,7 @@ static hedge_t **hEdgeSortBuf;

static __inline int pointOnHEdgeSide(double x, double y, const hedge_t *part)
{
return P_PointOnLineSide2(x, y, part->pDX, part->pDY, part->pPerp,
return P_PointOnLinedefSide2(x, y, part->pDX, part->pDY, part->pPerp,
part->pLength, DIST_EPSILON);
}

Expand Down
6 changes: 6 additions & 0 deletions doomsday/engine/portable/src/edit_map.c
Expand Up @@ -27,6 +27,8 @@

// HEADER FILES ------------------------------------------------------------

#include <math.h>

#include "de_base.h"
#include "de_play.h"
#include "de_bsp.h"
Expand Down Expand Up @@ -965,6 +967,10 @@ static void updateSSecMidPoint(subsector_t *sub)

sub->midPoint.pos[VX] /= sub->segCount; // num vertices.
sub->midPoint.pos[VY] /= sub->segCount;

// Calculate the worldwide grid offset.
sub->worldGridOffset[VX] = fmod(sub->bBox[0].pos[VX], 64);
sub->worldGridOffset[VY] = fmod(sub->bBox[1].pos[VY], 64);
}

static void prepareSubSectors(gamemap_t *map)
Expand Down

0 comments on commit eff6b3e

Please sign in to comment.