Merge branch 'master' of https://github.com/rheit/zdoom into zscript

This commit is contained in:
Christoph Oelckers 2016-11-06 15:13:44 +01:00
commit 779f9d7a72
6 changed files with 44 additions and 17 deletions

View file

@ -2046,7 +2046,8 @@ void AM_drawSubsectors()
scale / scaley, scale / scaley,
rotation, rotation,
colormap, colormap,
floorlight floorlight,
f_y + f_h
); );
} }
} }

View file

@ -1114,7 +1114,7 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof
// Draw a column with support for non-power-of-two ranges // Draw a column with support for non-power-of-two ranges
void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*draw1column)()) void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*draw1column)())
{ {
if (sampler.uv_max == 0) // power of two if (sampler.uv_max == 0 || sampler.uv_step == 0) // power of two
{ {
int count = y2 - y1; int count = y2 - y1;
@ -1162,7 +1162,7 @@ void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*d
// Draw four columns with support for non-power-of-two ranges // Draw four columns with support for non-power-of-two ranges
void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*draw4columns)()) void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*draw4columns)())
{ {
if (sampler[0].uv_max == 0) // power of two, no wrap handling needed if (sampler[0].uv_max == 0 || sampler[0].uv_step == 0) // power of two, no wrap handling needed
{ {
int count = y2 - y1; int count = y2 - y1;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)

View file

@ -1282,7 +1282,7 @@ void DCanvas::FinishSimplePolys()
void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
double originx, double originy, double scalex, double scaley, DAngle rotation, double originx, double originy, double scalex, double scaley, DAngle rotation,
FDynamicColormap *colormap, int lightlevel) FDynamicColormap *colormap, int lightlevel, int bottomclip)
{ {
#ifndef NO_SWRENDER #ifndef NO_SWRENDER
// Use an equation similar to player sprites to determine shade // Use an equation similar to player sprites to determine shade
@ -1300,6 +1300,11 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
return; return;
} }
if (bottomclip <= 0)
{
bottomclip = Height;
}
// Find the extents of the polygon, in particular the highest and lowest points. // Find the extents of the polygon, in particular the highest and lowest points.
for (botpt = toppt = 0, boty = topy = points[0].Y, leftx = rightx = points[0].X, i = 1; i <= npoints; ++i) for (botpt = toppt = 0, boty = topy = points[0].Y, leftx = rightx = points[0].X, i = 1; i <= npoints; ++i)
{ {
@ -1322,7 +1327,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
rightx = points[i].X; rightx = points[i].X;
} }
} }
if (topy >= Height || // off the bottom of the screen if (topy >= bottomclip || // off the bottom of the screen
boty <= 0 || // off the top of the screen boty <= 0 || // off the top of the screen
leftx >= Width || // off the right of the screen leftx >= Width || // off the right of the screen
rightx <= 0) // off the left of the screen rightx <= 0) // off the left of the screen
@ -1348,10 +1353,26 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
R_SetupSpanBits(tex); R_SetupSpanBits(tex);
R_SetSpanColormap(colormap != NULL ? &colormap->Maps[clamp(shade >> FRACBITS, 0, NUMCOLORMAPS-1) * 256] : identitymap); R_SetSpanColormap(colormap != NULL ? &colormap->Maps[clamp(shade >> FRACBITS, 0, NUMCOLORMAPS-1) * 256] : identitymap);
R_SetSpanSource(tex->GetPixels()); R_SetSpanSource(tex->GetPixels());
if (ds_xbits != 0)
{
scalex = double(1u << (32 - ds_xbits)) / scalex; scalex = double(1u << (32 - ds_xbits)) / scalex;
scaley = double(1u << (32 - ds_ybits)) / scaley;
ds_xstep = xs_RoundToInt(cosrot * scalex); ds_xstep = xs_RoundToInt(cosrot * scalex);
}
else
{ // Texture is one pixel wide.
scalex = 0;
ds_xstep = 0;
}
if (ds_ybits != 0)
{
scaley = double(1u << (32 - ds_ybits)) / scaley;
ds_ystep = xs_RoundToInt(sinrot * scaley); ds_ystep = xs_RoundToInt(sinrot * scaley);
}
else
{ // Texture is one pixel tall.
scaley = 0;
ds_ystep = 0;
}
// Travel down the right edge and create an outline of that edge. // Travel down the right edge and create an outline of that edge.
pt1 = toppt; pt1 = toppt;
@ -1361,13 +1382,13 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
{ {
x = FLOAT2FIXED(points[pt1].X + 0.5f); x = FLOAT2FIXED(points[pt1].X + 0.5f);
y2 = xs_RoundToInt(points[pt2].Y + 0.5f); y2 = xs_RoundToInt(points[pt2].Y + 0.5f);
if (y1 >= y2 || (y1 < 0 && y2 < 0) || (y1 >= Height && y2 >= Height)) if (y1 >= y2 || (y1 < 0 && y2 < 0) || (y1 >= bottomclip && y2 >= bottomclip))
{ {
} }
else else
{ {
fixed_t xinc = FLOAT2FIXED((points[pt2].X - points[pt1].X) / (points[pt2].Y - points[pt1].Y)); fixed_t xinc = FLOAT2FIXED((points[pt2].X - points[pt1].X) / (points[pt2].Y - points[pt1].Y));
int y3 = MIN(y2, Height); int y3 = MIN(y2, bottomclip);
if (y1 < 0) if (y1 < 0)
{ {
x += xinc * -y1; x += xinc * -y1;
@ -1392,13 +1413,13 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
{ {
x = FLOAT2FIXED(points[pt1].X + 0.5f); x = FLOAT2FIXED(points[pt1].X + 0.5f);
y2 = xs_RoundToInt(points[pt2].Y + 0.5f); y2 = xs_RoundToInt(points[pt2].Y + 0.5f);
if (y1 >= y2 || (y1 < 0 && y2 < 0) || (y1 >= Height && y2 >= Height)) if (y1 >= y2 || (y1 < 0 && y2 < 0) || (y1 >= bottomclip && y2 >= bottomclip))
{ {
} }
else else
{ {
fixed_t xinc = FLOAT2FIXED((points[pt2].X - points[pt1].X) / (points[pt2].Y - points[pt1].Y)); fixed_t xinc = FLOAT2FIXED((points[pt2].X - points[pt1].X) / (points[pt2].Y - points[pt1].Y));
int y3 = MIN(y2, Height); int y3 = MIN(y2, bottomclip);
if (y1 < 0) if (y1 < 0)
{ {
x += xinc * -y1; x += xinc * -y1;

View file

@ -224,7 +224,7 @@ public:
// Fill a simple polygon with a texture // Fill a simple polygon with a texture
virtual void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, virtual void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
double originx, double originy, double scalex, double scaley, DAngle rotation, double originx, double originy, double scalex, double scaley, DAngle rotation,
struct FDynamicColormap *colormap, int lightlevel); struct FDynamicColormap *colormap, int lightlevel, int bottomclip);
// Set an area to a specified color // Set an area to a specified color
virtual void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color); virtual void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color);

View file

@ -3084,11 +3084,16 @@ void D3DFB::FlatFill(int left, int top, int right, int bottom, FTexture *src, bo
// //
// Here, "simple" means that a simple triangle fan can draw it. // Here, "simple" means that a simple triangle fan can draw it.
// //
// Bottomclip is ignored by this implementation, since the hardware renderer
// will unconditionally draw the status bar border every frame on top of the
// polygons, so there's no need to waste time setting up a special scissor
// rectangle here and needlessly forcing separate batches.
//
//========================================================================== //==========================================================================
void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
double originx, double originy, double scalex, double scaley, double originx, double originy, double scalex, double scaley,
DAngle rotation, FDynamicColormap *colormap, int lightlevel) DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip)
{ {
// Use an equation similar to player sprites to determine shade // Use an equation similar to player sprites to determine shade
double fadelevel = clamp((LIGHT2SHADE(lightlevel)/65536. - 12) / NUMCOLORMAPS, 0.0, 1.0); double fadelevel = clamp((LIGHT2SHADE(lightlevel)/65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
@ -3109,7 +3114,7 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
} }
if (In2D < 2) if (In2D < 2)
{ {
Super::FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley, rotation, colormap, lightlevel); Super::FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley, rotation, colormap, lightlevel, bottomclip);
return; return;
} }
if (!InScene) if (!InScene)

View file

@ -265,7 +265,7 @@ public:
void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor); void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor);
void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
double originx, double originy, double scalex, double scaley, double originx, double originy, double scalex, double scaley,
DAngle rotation, FDynamicColormap *colormap, int lightlevel); DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip) override;
bool WipeStartScreen(int type); bool WipeStartScreen(int type);
void WipeEndScreen(); void WipeEndScreen();
bool WipeDo(int ticks); bool WipeDo(int ticks);