This commit is contained in:
Rachael Alexanderson 2017-05-02 23:26:34 -04:00
commit a9412ec815
8 changed files with 71 additions and 64 deletions

View file

@ -267,6 +267,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
mo->Vel.X = mo->Vel.Y = 0; mo->Vel.X = mo->Vel.Y = 0;
player->Vel.Zero(); player->Vel.Zero();
mo->Vel.Z = pmo->Vel.Z; mo->Vel.Z = pmo->Vel.Z;
mo->floorz = pmo->floorz;
if (!(pmo->special2 & MF_JUSTHIT)) if (!(pmo->special2 & MF_JUSTHIT))
{ {
mo->renderflags &= ~RF_INVISIBLE; mo->renderflags &= ~RF_INVISIBLE;

View file

@ -2511,7 +2511,7 @@ void OpenGLSWFrameBuffer::DoClear(int left, int top, int right, int bottom, int
{ {
if (In2D < 2) if (In2D < 2)
{ {
Super::Clear(left, top, right, bottom, palcolor, color); Super::DoClear(left, top, right, bottom, palcolor, color);
return; return;
} }
if (!InScene) if (!InScene)

View file

@ -67,8 +67,13 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &
// Determine actor z // Determine actor z
double zpos = decal->Z; double zpos = decal->Z;
sector_t *front = line->frontsector;
sector_t *back = (line->backsector != nullptr) ? line->backsector : line->frontsector; sector_t *back = (line->backsector != nullptr) ? line->backsector : line->frontsector;
// for 3d-floor segments use the model sector as reference
sector_t *front;
if ((decal->RenderFlags&RF_CLIPMASK) == RF_CLIPMID) front = decal->Sector;
else front = line->frontsector;
switch (decal->RenderFlags & RF_RELMASK) switch (decal->RenderFlags & RF_RELMASK)
{ {
default: default:

View file

@ -163,10 +163,7 @@ size_t SndFileDecoder::read(char *buffer, size_t bytes)
while(total < frames) while(total < frames)
{ {
size_t todo = MIN<size_t>(frames-total, 64/SndInfo.channels); size_t todo = MIN<size_t>(frames-total, 64/SndInfo.channels);
float tmp[64];
// libsndfile uses SSE optimization on Intel platform
// This requires proper read buffer alignment
alignas(16) float tmp[64];
size_t got = (size_t)sf_readf_float(SndFile, tmp, todo); size_t got = (size_t)sf_readf_float(SndFile, tmp, todo);
if(got < todo) frames = total + got; if(got < todo) frames = total + got;

View file

@ -554,7 +554,7 @@ namespace swrenderer
// [ZZ] Only if not an active mirror // [ZZ] Only if not an active mirror
if (!markportal) if (!markportal)
{ {
RenderDecal::RenderDecals(Thread, mLineSegment->sidedef, draw_segment, wallshade, rw_lightleft, rw_lightstep, mLineSegment, WallC, foggy, basecolormap, walltop.ScreenY, wallbottom.ScreenY); RenderDecal::RenderDecals(Thread, mLineSegment->sidedef, draw_segment, wallshade, rw_lightleft, rw_lightstep, mLineSegment, WallC, foggy, basecolormap, walltop.ScreenY, wallbottom.ScreenY, false);
} }
if (markportal) if (markportal)

View file

@ -515,6 +515,8 @@ namespace swrenderer
RenderWallPart renderWallpart(Thread); RenderWallPart renderWallpart(Thread);
renderWallpart.Render(drawerargs, frontsector, curline, WallC, rw_pic, x1, x2, wallupper.ScreenY, walllower.ScreenY, texturemid, MaskedSWall, walltexcoords.UPos, yscale, top, bot, true, wallshade, rw_offset, rw_light, rw_lightstep, nullptr, ds->foggy, basecolormap); renderWallpart.Render(drawerargs, frontsector, curline, WallC, rw_pic, x1, x2, wallupper.ScreenY, walllower.ScreenY, texturemid, MaskedSWall, walltexcoords.UPos, yscale, top, bot, true, wallshade, rw_offset, rw_light, rw_lightstep, nullptr, ds->foggy, basecolormap);
RenderDecal::RenderDecals(Thread, curline->sidedef, ds, wallshade, rw_light, rw_lightstep, curline, WallC, ds->foggy, basecolormap, wallupper.ScreenY, walllower.ScreenY, true);
} }
// kg3D - walls of fake floors // kg3D - walls of fake floors
@ -926,7 +928,6 @@ namespace swrenderer
break; break;
} }
} }
return;
} }
// Clip a midtexture to the floor and ceiling of the sector in front of it. // Clip a midtexture to the floor and ceiling of the sector in front of it.

View file

@ -57,19 +57,15 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer namespace swrenderer
{ {
void RenderDecal::RenderDecals(RenderThread *thread, side_t *sidedef, DrawSegment *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom) void RenderDecal::RenderDecals(RenderThread *thread, side_t *sidedef, DrawSegment *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass)
{ {
for (DBaseDecal *decal = sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext) for (DBaseDecal *decal = sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext)
{ {
Render(thread, sidedef, decal, draw_segment, wallshade, lightleft, lightstep, curline, wallC, foggy, basecolormap, walltop, wallbottom, 0); Render(thread, sidedef, decal, draw_segment, wallshade, lightleft, lightstep, curline, wallC, foggy, basecolormap, walltop, wallbottom, drawsegPass);
} }
} }
// pass = 0: when seg is first drawn void RenderDecal::Render(RenderThread *thread, side_t *wall, DBaseDecal *decal, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &savecoord, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass)
// = 1: drawing masked textures (including sprites)
// Currently, only pass = 0 is done or used
void RenderDecal::Render(RenderThread *thread, side_t *wall, DBaseDecal *decal, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &savecoord, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, int pass)
{ {
DVector2 decal_left, decal_right, decal_pos; DVector2 decal_left, decal_right, decal_pos;
int x1, x2; int x1, x2;
@ -77,7 +73,7 @@ namespace swrenderer
uint8_t flipx; uint8_t flipx;
double zpos; double zpos;
int needrepeat = 0; int needrepeat = 0;
sector_t *front, *back; sector_t *back;
bool calclighting; bool calclighting;
bool rereadcolormap; bool rereadcolormap;
FDynamicColormap *usecolormap; FDynamicColormap *usecolormap;
@ -90,8 +86,13 @@ namespace swrenderer
// Determine actor z // Determine actor z
zpos = decal->Z; zpos = decal->Z;
front = curline->frontsector;
back = (curline->backsector != NULL) ? curline->backsector : curline->frontsector; back = (curline->backsector != NULL) ? curline->backsector : curline->frontsector;
// for 3d-floor segments use the model sector as reference
sector_t *front;
if ((decal->RenderFlags&RF_CLIPMASK) == RF_CLIPMID) front = decal->Sector;
else front = curline->frontsector;
switch (decal->RenderFlags & RF_RELMASK) switch (decal->RenderFlags & RF_RELMASK)
{ {
default: default:
@ -171,6 +172,30 @@ namespace swrenderer
FWallTmapVals WallT; FWallTmapVals WallT;
WallT.InitFromWallCoords(thread, &WallC); WallT.InitFromWallCoords(thread, &WallC);
if (drawsegPass)
{
uint32_t clipMode = decal->RenderFlags & RF_CLIPMASK;
if (clipMode != RF_CLIPMID && clipMode != RF_CLIPFULL)
return;
// Clip decal to stay within the draw segment wall
mceilingclip = walltop;
mfloorclip = wallbottom;
// Rumor has it that if RT_CLIPMASK is specified then the decal should be clipped according
// to the full drawsegment visibility, as implemented in the remarked section below.
//
// This is problematic because not all 3d floors may have been drawn yet at this point. The
// code below might work ok for cases where there is only one 3d floor.
/*if (clipMode == RF_CLIPFULL)
{
mceilingclip = clipper->sprtopclip - clipper->x1;
mfloorclip = clipper->sprbottomclip - clipper->x1;
}*/
}
else
{
// Get the top and bottom clipping arrays // Get the top and bottom clipping arrays
switch (decal->RenderFlags & RF_CLIPMASK) switch (decal->RenderFlags & RF_CLIPMASK)
{ {
@ -181,53 +206,31 @@ namespace swrenderer
case RF_CLIPFULL: case RF_CLIPFULL:
if (curline->backsector == NULL) if (curline->backsector == NULL)
{ {
if (pass != 0)
{
return;
}
mceilingclip = walltop; mceilingclip = walltop;
mfloorclip = wallbottom; mfloorclip = wallbottom;
} }
else if (pass == 0) else
{ {
mceilingclip = walltop; mceilingclip = walltop;
mfloorclip = thread->OpaquePass->ceilingclip; mfloorclip = thread->OpaquePass->ceilingclip;
needrepeat = 1; needrepeat = 1;
} }
else
{
mceilingclip = clipper->sprtopclip - clipper->x1;
mfloorclip = clipper->sprbottomclip - clipper->x1;
}
break; break;
case RF_CLIPUPPER: case RF_CLIPUPPER:
if (pass != 0)
{
return;
}
mceilingclip = walltop; mceilingclip = walltop;
mfloorclip = thread->OpaquePass->ceilingclip; mfloorclip = thread->OpaquePass->ceilingclip;
break; break;
case RF_CLIPMID: case RF_CLIPMID:
if (curline->backsector != NULL && pass != 2)
{
return; return;
}
mceilingclip = clipper->sprtopclip - clipper->x1;
mfloorclip = clipper->sprbottomclip - clipper->x1;
break;
case RF_CLIPLOWER: case RF_CLIPLOWER:
if (pass != 0)
{
return;
}
mceilingclip = thread->OpaquePass->floorclip; mceilingclip = thread->OpaquePass->floorclip;
mfloorclip = wallbottom; mfloorclip = wallbottom;
break; break;
} }
}
yscale = decal->ScaleY; yscale = decal->ScaleY;
texturemid = WallSpriteTile->TopOffset + (zpos - thread->Viewport->viewpoint.Pos.Z) / yscale; texturemid = WallSpriteTile->TopOffset + (zpos - thread->Viewport->viewpoint.Pos.Z) / yscale;

View file

@ -12,10 +12,10 @@ namespace swrenderer
class RenderDecal class RenderDecal
{ {
public: public:
static void RenderDecals(RenderThread *thread, side_t *wall, DrawSegment *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom); static void RenderDecals(RenderThread *thread, side_t *wall, DrawSegment *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass);
private: private:
static void Render(RenderThread *thread, side_t *wall, DBaseDecal *first, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, int pass); static void Render(RenderThread *thread, side_t *wall, DBaseDecal *first, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass);
static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip); static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip);
}; };
} }