Skip to content

Commit

Permalink
Add some sector and linedef udmf properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillyWillyGuru committed Feb 8, 2017
1 parent 4f4abd6 commit 8360f56
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 57 deletions.
146 changes: 139 additions & 7 deletions src/p_setup.cc
Expand Up @@ -80,6 +80,7 @@ extern void TinyBSP(void); /// Add #IFDEF DREAMCAST TO REMOVE GLBSP LINKAGE
//
int numvertexes;
vec2_t *vertexes;
vec2_t *zvertexes;

int num_gl_vertexes;
vec2_t *gl_vertexes;
Expand Down Expand Up @@ -1949,6 +1950,7 @@ static void LoadUDMFVertexes(parser_t *psr)
}

vertexes = new vec2_t[numvertexes];
zvertexes = new vec2_t[numvertexes];

psr->next = 0; // restart from start of lump
while (1)
Expand Down Expand Up @@ -2057,7 +2059,11 @@ static void LoadUDMFSectors(parser_t *psr)
if (strcasecmp(ident, "sector") == 0)
{
float cz = 0.0f, fz = 0.0f;
int light = 160, type = 0, tag = 0;
float rc = 0.0f, rf = 0.0f;
float xpf = 0.0f, ypf = 0.0f, xpc = 0.0f, ypc = 0.0f;
float xsf = 1.0f, ysf = 1.0f, xsc = 1.0f, ysc = 1.0f;
float grav = 1.0f;
int light = 160, lc = 0x00FFFFFF, fc = 0, type = 0, tag = 0;
char floor_tex[10];
char ceil_tex[10];
strcpy(floor_tex, "-");
Expand Down Expand Up @@ -2092,6 +2098,50 @@ static void LoadUDMFSectors(parser_t *psr)
{
cz = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "xpanningfloor") == 0)
{
xpf = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "ypanningfloor") == 0)
{
ypf = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "xpanningceiling") == 0)
{
xpc = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "ypanningceiling") == 0)
{
ypc = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "xscalefloor") == 0)
{
xsf = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "yscalefloor") == 0)
{
ysf = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "xscaleceiling") == 0)
{
xsc = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "yscaleceiling") == 0)
{
ysc = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "rotationfloor") == 0)
{
rf = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "rotationceiling") == 0)
{
rc = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "gravity") == 0)
{
grav = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "texturefloor") == 0)
{
Z_StrNCpy(floor_tex, val, 8);
Expand All @@ -2104,6 +2154,14 @@ static void LoadUDMFSectors(parser_t *psr)
{
light = str2int(val, 160);
}
else if (strcasecmp(ident, "lightcolor") == 0)
{
lc = str2int(val, 0x00FFFFFF);
}
else if (strcasecmp(ident, "fadecolor") == 0)
{
fc = str2int(val, 0);
}
else if (strcasecmp(ident, "special") == 0)
{
type = str2int(val, 0);
Expand All @@ -2130,10 +2188,16 @@ static void LoadUDMFSectors(parser_t *psr)
}

ss->floor.translucency = VISIBLE;
ss->floor.x_mat.x = 1; ss->floor.x_mat.y = 0;
ss->floor.y_mat.x = 0; ss->floor.y_mat.y = 1;
ss->floor.x_mat.x = xsf * cosf(rf * 0.0174533f); ss->floor.x_mat.y = -ysf * sinf(rf * 0.0174533f);
ss->floor.y_mat.x = xsf * sinf(rf * 0.0174533f); ss->floor.y_mat.y = ysf * cosf(rf * 0.0174533f);
ss->floor.offset.x = xpf;
ss->floor.offset.y = ypf;

ss->ceil = ss->floor;
ss->ceil.translucency = VISIBLE;
ss->ceil.x_mat.x = xsc * cosf(rc * 0.0174533f); ss->ceil.x_mat.y = -ysc * sinf(rc * 0.0174533f);
ss->ceil.y_mat.x = xsc * sinf(rc * 0.0174533f); ss->ceil.y_mat.y = ysc * cosf(rc * 0.0174533f);
ss->ceil.offset.x = xpc;
ss->ceil.offset.y = ypc;

ss->floor.image = W_ImageLookup(floor_tex, INS_Flat);
ss->ceil.image = W_ImageLookup(ceil_tex, INS_Flat);
Expand Down Expand Up @@ -2162,13 +2226,16 @@ static void LoadUDMFSectors(parser_t *psr)

ss->props.colourmap = NULL;

ss->props.gravity = GRAVITY;
ss->props.gravity = grav * GRAVITY;
ss->props.friction = FRICTION;
ss->props.viscosity = VISCOSITY;
ss->props.drag = DRAG;

ss->p = &ss->props;

ss->lightcolor = lc;
ss->fadecolor = fc;

ss->sound_player = -1;

// -AJA- 1999/07/29: Keep sectors with same tag in a list.
Expand Down Expand Up @@ -2204,6 +2271,8 @@ static void LoadUDMFSideDefs(parser_t *psr)
if (strcasecmp(ident, "sidedef") == 0)
{
int x = 0, y = 0, sec_num = 0;
float bx = 0.0f, by = 0.0f, mx = 0.0f, my = 0.0f, tx = 0.0f, ty = 0.0f;
float bxs = 1.0f, bys = 1.0f, mxs = 1.0f, mys = 1.0f, txs = 1.0f, tys = 1.0f;
char top_tex[10];
char bottom_tex[10];
char middle_tex[10];
Expand Down Expand Up @@ -2242,6 +2311,54 @@ static void LoadUDMFSideDefs(parser_t *psr)
{
y = str2int(val, 0);
}
else if (strcasecmp(ident, "offsetx_bottom") == 0)
{
bx = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "offsety_bottom") == 0)
{
by = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "offsetx_mid") == 0)
{
mx = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "offsety_mid") == 0)
{
my = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "offsetx_top") == 0)
{
tx = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "offsety_top") == 0)
{
ty = str2float(val, 0.0f);
}
else if (strcasecmp(ident, "scalex_bottom") == 0)
{
bxs = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "scaley_bottom") == 0)
{
bys = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "scalex_mid") == 0)
{
mxs = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "scaley_mid") == 0)
{
mys = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "scalex_top") == 0)
{
txs = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "scaley_top") == 0)
{
tys = str2float(val, 1.0f);
}
else if (strcasecmp(ident, "texturetop") == 0)
{
Z_StrNCpy(top_tex, val, 8);
Expand All @@ -2268,12 +2385,24 @@ static void LoadUDMFSideDefs(parser_t *psr)
sd->top.translucency = VISIBLE;
sd->top.offset.x = x;
sd->top.offset.y = y;
sd->top.x_mat.x = 1; sd->top.x_mat.y = 0;
sd->top.y_mat.x = 0; sd->top.y_mat.y = 1;

sd->middle = sd->top;
sd->bottom = sd->top;

sd->top.offset.x += tx;
sd->top.offset.y += ty;
sd->middle.offset.x += mx;
sd->middle.offset.y += my;
sd->bottom.offset.x += bx;
sd->bottom.offset.y += by;

sd->top.x_mat.x = txs; sd->top.x_mat.y = 0;
sd->top.y_mat.x = 0; sd->top.y_mat.y = tys;
sd->middle.x_mat.x = mxs; sd->middle.x_mat.y = 0;
sd->middle.y_mat.x = 0; sd->middle.y_mat.y = mys;
sd->bottom.x_mat.x = bxs; sd->bottom.x_mat.y = 0;
sd->bottom.y_mat.x = 0; sd->bottom.y_mat.y = bys;

sd->sector = &sectors[sec_num];

sd->top.image = W_ImageLookup(top_tex, INS_Texture, ILF_Null);
Expand Down Expand Up @@ -3559,6 +3688,9 @@ void P_ShutdownLevel(void)
delete[] vertexes;
vertexes = NULL;

delete[] zvertexes;
zvertexes = NULL;

delete[] sides;
sides = NULL;

Expand Down
38 changes: 21 additions & 17 deletions src/r_defs.h
@@ -1,9 +1,9 @@
//----------------------------------------------------------------------------
// EDGE2 Rendering Definitions Header
//----------------------------------------------------------------------------
//
//
// Copyright (c) 1999-2009 The EDGE2 Team.
//
//
// 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 the Free Software Foundation; either version 2
Expand Down Expand Up @@ -75,7 +75,7 @@ struct region_properties_s;
// part is that we only need to unlink the node from the sector list
// (and relink) if the sector in that node is different. Thus saving
// work for the common case where the sector(s) don't change.
//
//
// CAVEAT: this means that very little should be done in between
// P_UnsetThingPos and P_SetThingPos calls, ideally just load some new
// x/y position. Avoid especially anything that scans the sector
Expand Down Expand Up @@ -134,7 +134,7 @@ region_properties_t;
//
// tx = wx * x_mat.x + wy * x_mat.y
// ty = wx * y_mat.x + wy * y_mat.y
//
//
typedef struct surface_s
{
const image_c *image;
Expand Down Expand Up @@ -167,7 +167,7 @@ typedef struct extrafloor_s
// bottom_h as the reference. This is important, especially when a
// liquid extrafloor overlaps a solid one: using this rule, the
// liquid region will be higher than the solid one.
//
//
struct extrafloor_s *higher;
struct extrafloor_s *lower;

Expand All @@ -179,7 +179,7 @@ typedef struct extrafloor_s
// extrafloor.
//
float top_h, bottom_h;

//Last gametic top and bottom of floor, for interpolation
float last_top_h, last_bottom_h;

Expand All @@ -206,7 +206,7 @@ typedef struct extrafloor_s
extrafloor_t;

// Vertical gap between a floor & a ceiling.
// -AJA- 1999/07/19.
// -AJA- 1999/07/19.
//
typedef struct
{
Expand Down Expand Up @@ -269,9 +269,9 @@ typedef struct sector_s
// properties that are active for this sector (top-most extrafloor).
// This may be different than the sector's actual properties (the
// "props" field) due to flooders.
//
//
region_properties_t *p;

// slope information, normally NULL
slope_plane_t *f_slope;
slope_plane_t *c_slope;
Expand All @@ -280,7 +280,7 @@ typedef struct sector_s
// that this sector is not a controller.
//
extrafloor_t *control_floors;

// movement thinkers, for quick look-up
struct plane_move_s *floor_move;
struct plane_move_s *ceil_move;
Expand All @@ -299,17 +299,17 @@ typedef struct sector_s

// touch list: objects in or touching this sector
touch_node_t *touch_things;

// list of sector glow things (linked via dlnext/dlprev)
mobj_t *glow_things;

// sky height for GL renderer
float sky_h;

// keep track of vertical sight gaps within the sector. This is
// just a much more convenient form of the info in the extrafloor
// list.
//
//
short max_gaps;
short sight_gap_num;

Expand All @@ -324,6 +324,10 @@ typedef struct sector_s

// -AJA- 2000/03/30: Keep a list of child subsectors.
struct subsector_s *subsectors;

// -CW- 2017/02/07: light and fade vars for UDMF
int lightcolor;
int fadecolor;
}
sector_t;

Expand Down Expand Up @@ -445,7 +449,7 @@ typedef struct subsector_s
{
// link in sector list
struct subsector_s *sec_next;

sector_t *sector;
struct seg_s *segs;

Expand Down Expand Up @@ -480,7 +484,7 @@ typedef struct seg_s
// link in subsector list.
// (NOTE: sorted in clockwise order)
struct seg_s *sub_next;

// -AJA- 1999/12/20: Reference to partner seg, or NULL if the seg
// lies along a one-sided line.
struct seg_s *partner;
Expand All @@ -490,7 +494,7 @@ typedef struct seg_s
// (Addendum: back_sub is obsolete with new `partner' field)
subsector_t *front_sub;
subsector_t *back_sub;

// -AJA- 1999/09/23: For "True BSP rendering", we keep track of the
// `minisegs' which define all the non-wall borders of the
// subsector. Thus all the segs (normal + mini) define a
Expand Down

0 comments on commit 8360f56

Please sign in to comment.