Merge branch 'next' into slope-fixes

This commit is contained in:
Alam Ed Arias 2016-03-31 21:43:51 -04:00
commit b45b9801d6
13 changed files with 88 additions and 46 deletions

View file

@ -139,7 +139,6 @@ set(SRB2_CORE_RENDER_SOURCES
set(SRB2_CORE_GAME_SOURCES set(SRB2_CORE_GAME_SOURCES
p_ceilng.c p_ceilng.c
p_enemy.c p_enemy.c
p_fab.c
p_floor.c p_floor.c
p_inter.c p_inter.c
p_lights.c p_lights.c

View file

@ -437,7 +437,6 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/info.o \ $(OBJDIR)/info.o \
$(OBJDIR)/p_ceilng.o \ $(OBJDIR)/p_ceilng.o \
$(OBJDIR)/p_enemy.o \ $(OBJDIR)/p_enemy.o \
$(OBJDIR)/p_fab.o \
$(OBJDIR)/p_floor.o \ $(OBJDIR)/p_floor.o \
$(OBJDIR)/p_inter.o \ $(OBJDIR)/p_inter.o \
$(OBJDIR)/p_lights.o \ $(OBJDIR)/p_lights.o \

View file

@ -148,14 +148,38 @@ static int lib_pAproxDistance(lua_State *L)
static int lib_pClosestPointOnLine(lua_State *L) static int lib_pClosestPointOnLine(lua_State *L)
{ {
int n = lua_gettop(L);
fixed_t x = luaL_checkfixed(L, 1); fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2); fixed_t y = luaL_checkfixed(L, 2);
line_t *line = *((line_t **)luaL_checkudata(L, 3, META_LINE));
vertex_t result; vertex_t result;
//HUDSAFE //HUDSAFE
if (lua_isuserdata(L, 3)) // use a real linedef to get our points
{
line_t *line = *((line_t **)luaL_checkudata(L, 3, META_LINE));
if (!line) if (!line)
return LUA_ErrInvalid(L, "line_t"); return LUA_ErrInvalid(L, "line_t");
P_ClosestPointOnLine(x, y, line, &result); P_ClosestPointOnLine(x, y, line, &result);
}
else // use custom coordinates of our own!
{
vertex_t v1, v2; // fake vertexes
line_t junk; // fake linedef
if (n < 6)
return luaL_error(L, "arguments 3 to 6 not all given (expected 4 fixed-point integers)");
v1.x = luaL_checkfixed(L, 3);
v1.y = luaL_checkfixed(L, 4);
v2.x = luaL_checkfixed(L, 5);
v2.y = luaL_checkfixed(L, 6);
junk.v1 = &v1;
junk.v2 = &v2;
junk.dx = v2.x - v1.x;
junk.dy = v2.y - v1.y;
P_ClosestPointOnLine(x, y, &junk, &result);
}
lua_pushfixed(L, result.x); lua_pushfixed(L, result.x);
lua_pushfixed(L, result.y); lua_pushfixed(L, result.y);
return 2; return 2;

View file

@ -1,15 +0,0 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2014 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file p_fab.c
/// \brief some new action routines, separated from the original doom
/// sources, so that you can include it or remove it easy.
/// \todo
/// This file is now unused, please remove at some point

View file

@ -1616,7 +1616,7 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
po->validcount = validcount; po->validcount = validcount;
if (!P_PointInsidePolyobj(po, x, y)) if (!P_PointInsidePolyobj(po, x, y) || !(po->flags & POF_SOLID))
{ {
plink = (polymaplink_t *)(plink->link.next); plink = (polymaplink_t *)(plink->link.next);
continue; continue;
@ -3717,6 +3717,9 @@ static inline boolean PIT_GetSectors(line_t *ld)
if (P_BoxOnLineSide(tmbbox, ld) != -1) if (P_BoxOnLineSide(tmbbox, ld) != -1)
return true; return true;
if (ld->polyobj) // line belongs to a polyobject, don't add it
return true;
// This line crosses through the object. // This line crosses through the object.
// Collect the sector(s) from the line and add to the // Collect the sector(s) from the line and add to the
@ -3749,6 +3752,9 @@ static inline boolean PIT_GetPrecipSectors(line_t *ld)
if (P_BoxOnLineSide(preciptmbbox, ld) != -1) if (P_BoxOnLineSide(preciptmbbox, ld) != -1)
return true; return true;
if (ld->polyobj) // line belongs to a polyobject, don't add it
return true;
// This line crosses through the object. // This line crosses through the object.
// Collect the sector(s) from the line and add to the // Collect the sector(s) from the line and add to the

View file

@ -3087,7 +3087,7 @@ static void P_DoTeeter(player_t *player)
} }
if (polybottom > player->mo->z + player->mo->height + tiptop if (polybottom > player->mo->z + player->mo->height + tiptop
|| (polybottom < player->mo->z || (polytop < player->mo->z
&& player->mo->z + player->mo->height < player->mo->ceilingz - tiptop)) && player->mo->z + player->mo->height < player->mo->ceilingz - tiptop))
teeter = true; teeter = true;
else else
@ -3105,7 +3105,7 @@ static void P_DoTeeter(player_t *player)
} }
if (polytop < player->mo->z - tiptop if (polytop < player->mo->z - tiptop
|| (polytop > player->mo->z + player->mo->height || (polybottom > player->mo->z + player->mo->height
&& player->mo->z > player->mo->floorz + tiptop)) && player->mo->z > player->mo->floorz + tiptop))
teeter = true; teeter = true;
else else
@ -8171,7 +8171,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
po->validcount = validcount; po->validcount = validcount;
if (!P_PointInsidePolyobj(po, x, y)) if (!P_PointInsidePolyobj(po, x, y) || !(po->flags & POF_SOLID))
{ {
plink = (polymaplink_t *)(plink->link.next); plink = (polymaplink_t *)(plink->link.next);
continue; continue;

View file

@ -26,6 +26,7 @@ side_t *sidedef;
line_t *linedef; line_t *linedef;
sector_t *frontsector; sector_t *frontsector;
sector_t *backsector; sector_t *backsector;
boolean portalline; // is curline a portal seg?
// very ugly realloc() of drawsegs at run-time, I upped it to 512 // very ugly realloc() of drawsegs at run-time, I upped it to 512
// instead of 256.. and someone managed to send me a level with // instead of 256.. and someone managed to send me a level with
@ -378,6 +379,7 @@ static void R_AddLine(seg_t *line)
return; return;
curline = line; curline = line;
portalline = false;
// OPTIMIZE: quickly reject orthogonal back sides. // OPTIMIZE: quickly reject orthogonal back sides.
angle1 = R_PointToAngle(line->v1->x, line->v1->y); angle1 = R_PointToAngle(line->v1->x, line->v1->y);
@ -431,7 +433,7 @@ static void R_AddLine(seg_t *line)
backsector = line->backsector; backsector = line->backsector;
// Portal line // Portal line
if (line->linedef->special == 40 && P_PointOnLineSide(viewx, viewy, line->linedef) == 0) if (line->linedef->special == 40 && line->side == 0)
{ {
if (portalrender < cv_maxportals.value) if (portalrender < cv_maxportals.value)
{ {

View file

@ -23,6 +23,7 @@ extern side_t *sidedef;
extern line_t *linedef; extern line_t *linedef;
extern sector_t *frontsector; extern sector_t *frontsector;
extern sector_t *backsector; extern sector_t *backsector;
extern boolean portalline; // is curline a portal seg?
// drawsegs are allocated on the fly... see r_segs.c // drawsegs are allocated on the fly... see r_segs.c

View file

@ -667,6 +667,8 @@ typedef struct drawseg_s
INT32 numthicksides; INT32 numthicksides;
fixed_t frontscale[MAXVIDWIDTH]; fixed_t frontscale[MAXVIDWIDTH];
UINT8 portalpass; // if > 0 and <= portalrender, do not affect sprite clipping
#ifdef ESLOPE #ifdef ESLOPE
fixed_t maskedtextureheight[MAXVIDWIDTH]; // For handling sloped midtextures fixed_t maskedtextureheight[MAXVIDWIDTH]; // For handling sloped midtextures

View file

@ -91,7 +91,6 @@ typedef struct portal_pair
INT16 *ceilingclip; INT16 *ceilingclip;
INT16 *floorclip; INT16 *floorclip;
fixed_t *frontscale; fixed_t *frontscale;
size_t seg;
} portal_pair; } portal_pair;
portal_pair *portal_base, *portal_cap; portal_pair *portal_base, *portal_cap;
line_t *portalclipline; line_t *portalclipline;
@ -1230,7 +1229,7 @@ void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2)
portal->start = x1; portal->start = x1;
portal->end = x2; portal->end = x2;
portal->seg = ds_p-drawsegs; portalline = true; // this tells R_StoreWallRange that curline is a portal seg
portal->viewx = viewx; portal->viewx = viewx;
portal->viewy = viewy; portal->viewy = viewy;
@ -1344,14 +1343,6 @@ void R_RenderPlayerView(player_t *player)
validcount++; validcount++;
if (portal->seg)
{
// Push the portal's old drawseg out of the way so it isn't interfering with sprite clipping. -Red
drawseg_t *seg = drawsegs+portal->seg;
seg->scale1 = 0;
seg->scale2 = 0;
}
R_RenderBSPNode((INT32)numnodes - 1); R_RenderBSPNode((INT32)numnodes - 1);
R_ClipSprites(); R_ClipSprites();
//R_DrawPlanes(); //R_DrawPlanes();
@ -1360,6 +1351,9 @@ void R_RenderPlayerView(player_t *player)
// okay done. free it. // okay done. free it.
portalcullsector = NULL; // Just in case... portalcullsector = NULL; // Just in case...
portal_base = portal->next; portal_base = portal->next;
Z_Free(portal->ceilingclip);
Z_Free(portal->floorclip);
Z_Free(portal->frontscale);
Z_Free(portal); Z_Free(portal);
} }
// END PORTAL RENDERING // END PORTAL RENDERING

View file

@ -2999,6 +2999,11 @@ void R_StoreWallRange(INT32 start, INT32 stop)
R_RenderSegLoop(); R_RenderSegLoop();
colfunc = wallcolfunc; colfunc = wallcolfunc;
if (portalline) // if curline is a portal, set portalrender for drawseg
ds_p->portalpass = portalrender+1;
else
ds_p->portalpass = 0;
// save sprite clipping info // save sprite clipping info
if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip)
{ {

View file

@ -834,10 +834,10 @@ static void R_DrawVisSprite(vissprite_t *vis)
dc_texturemid = FixedDiv(dc_texturemid,this_scale); dc_texturemid = FixedDiv(dc_texturemid,this_scale);
//Oh lordy, mercy me. Don't freak out if sprites go offscreen! //Oh lordy, mercy me. Don't freak out if sprites go offscreen!
if (vis->xiscale > 0) /*if (vis->xiscale > 0)
frac = FixedDiv(frac, this_scale); frac = FixedDiv(frac, this_scale);
else if (vis->x1 <= 0) else if (vis->x1 <= 0)
frac = (vis->x1 - vis->x2) * vis->xiscale; frac = (vis->x1 - vis->x2) * vis->xiscale;*/
sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale);
//dc_hires = 1; //dc_hires = 1;
@ -1301,7 +1301,7 @@ static void R_ProjectSprite(mobj_t *thing)
} }
if (vis->x1 > x1) if (vis->x1 > x1)
vis->startfrac += vis->xiscale*(vis->x1-x1); vis->startfrac += FixedDiv(vis->xiscale, this_scale)*(vis->x1-x1);
//Fab: lumppat is the lump number of the patch to use, this is different //Fab: lumppat is the lump number of the patch to use, this is different
// than lumpid for sprites-in-pwad : the graphics are patched // than lumpid for sprites-in-pwad : the graphics are patched
@ -2053,6 +2053,9 @@ void R_ClipSprites(void)
continue; continue;
} }
if (ds->portalpass > 0 && ds->portalpass <= portalrender)
continue; // is a portal
r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1;
r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2; r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2;

View file

@ -336,6 +336,8 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
const column_t *column; const column_t *column;
UINT8 *desttop, *dest, *deststart, *destend; UINT8 *desttop, *dest, *deststart, *destend;
const UINT8 *source, *deststop; const UINT8 *source, *deststop;
fixed_t pwidth; // patch width
fixed_t offx = 0; // x offset
if (rendermode == render_none) if (rendermode == render_none)
return; return;
@ -476,16 +478,36 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
} }
} }
deststart = desttop; if (pscale != FRACUNIT) // scale width properly
destend = desttop + SHORT(patch->width) * dupx; {
pwidth = SHORT(patch->width)<<FRACBITS;
pwidth = FixedMul(pwidth, pscale);
pwidth = FixedMul(pwidth, dupx<<FRACBITS);
pwidth >>= FRACBITS;
}
else
pwidth = SHORT(patch->width) * dupx;
for (col = 0; (col>>FRACBITS) < SHORT(patch->width); col += colfrac, ++x, desttop++) deststart = desttop;
destend = desttop + pwidth;
for (col = 0; (col>>FRACBITS) < SHORT(patch->width); col += colfrac, ++offx, desttop++)
{ {
INT32 topdelta, prevdelta = -1; INT32 topdelta, prevdelta = -1;
if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) if (flip) // offx is measured from right edge instead of left
continue; {
if (x >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) if (x+pwidth-offx < 0) // don't draw off the left of the screen (WRAP PREVENTION)
break; break;
if (x+pwidth-offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
continue;
}
else
{
if (x+offx < 0) // don't draw off the left of the screen (WRAP PREVENTION)
continue;
if (x+offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
break;
}
column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[col>>FRACBITS])); column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[col>>FRACBITS]));
while (column->topdelta != 0xff) while (column->topdelta != 0xff)