Merge branch 'master' into asmjit

This commit is contained in:
Christoph Oelckers 2018-11-25 23:33:23 +01:00
commit 90d79865a5
23 changed files with 243 additions and 195 deletions

View file

@ -1673,6 +1673,7 @@ void subsector_t::BuildPolyBSP()
for (unsigned int i = 0; i < BSP->Subsectors.Size(); ++i) for (unsigned int i = 0; i < BSP->Subsectors.Size(); ++i)
{ {
BSP->Subsectors[i].sector = sector; BSP->Subsectors[i].sector = sector;
BSP->Subsectors[i].section = section;
} }
} }

View file

@ -556,17 +556,17 @@ static void GenericParse (FScanner &sc, FGenericParse *parser, const char **keyw
else else
{ {
info = PClass::FindClass (sc.String); info = PClass::FindClass (sc.String);
if (!info->IsDescendantOf (RUNTIME_CLASS(AActor))) if (info == NULL)
{
Printf ("Unknown actor %s in %s %s\n",
sc.String, type, name.GetChars());
}
else if (!info->IsDescendantOf (RUNTIME_CLASS(AActor)))
{ {
Printf ("%s is not an Actor (in %s %s)\n", Printf ("%s is not an Actor (in %s %s)\n",
sc.String, type, name.GetChars()); sc.String, type, name.GetChars());
info = NULL; info = NULL;
} }
else if (info == NULL)
{
Printf ("Unknown actor %s in %s %s\n",
sc.String, type, name.GetChars());
}
} }
SET_FIELD (const PClass *, info); SET_FIELD (const PClass *, info);
break; break;

View file

@ -77,6 +77,15 @@ public:
return clip_first_line + core_skip - first_line; return clip_first_line + core_skip - first_line;
} }
// Varyings
float worldposX[MAXWIDTH];
float worldposY[MAXWIDTH];
float worldposZ[MAXWIDTH];
uint32_t texel[MAXWIDTH];
int32_t texelV[MAXWIDTH];
fixed_t lightarray[MAXWIDTH];
uint32_t dynlights[MAXWIDTH];
static PolyTriangleThreadData *Get(DrawerThread *thread); static PolyTriangleThreadData *Get(DrawerThread *thread);
private: private:

View file

@ -227,7 +227,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat
if (x > xstart) if (x > xstart)
{ {
if (writeColor) if (writeColor)
drawfunc(y, xstart, x, args); drawfunc(y, xstart, x, args, thread);
if (writeStencil) if (writeStencil)
{ {
@ -379,29 +379,54 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat
} }
template<typename ModeT, typename OptT> template<typename ModeT, typename OptT>
void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args) void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread)
{ {
using namespace TriScreenDrawerModes; using namespace TriScreenDrawerModes;
uint32_t fixedlight;
uint32_t shade_fade_r, shade_fade_g, shade_fade_b, shade_light_r, shade_light_g, shade_light_b, desaturate, inv_desaturate;
fixed_t fuzzscale;
int _fuzzpos;
const uint32_t *texPixels, *translation;
int texWidth, texHeight;
uint32_t fillcolor;
int actoralpha;
float v1X, v1Y, v1W, v1U, v1V, v1WorldX, v1WorldY, v1WorldZ; float v1X, v1Y, v1W, v1U, v1V, v1WorldX, v1WorldY, v1WorldZ;
float startX, startY; float startX, startY;
float stepW, stepU, stepV, stepWorldX, stepWorldY, stepWorldZ; float stepW, stepU, stepV, stepWorldX, stepWorldY, stepWorldZ;
float posW, posU, posV, posWorldX, posWorldY, posWorldZ; float posW, posU, posV, posWorldX, posWorldY, posWorldZ;
PolyLight *lights;
int num_lights;
float worldnormalX, worldnormalY, worldnormalZ;
uint32_t dynlightcolor;
const uint32_t *texPixels, *translation;
int texWidth, texHeight;
uint32_t fillcolor;
int alpha;
uint32_t light; uint32_t light;
fixed_t shade, lightpos, lightstep; fixed_t shade, lightpos, lightstep;
uint32_t shade_fade_r, shade_fade_g, shade_fade_b, shade_light_r, shade_light_g, shade_light_b, desaturate, inv_desaturate;
int16_t dynlights_r[MAXWIDTH / 16], dynlights_g[MAXWIDTH / 16], dynlights_b[MAXWIDTH / 16]; float *worldposX = thread->worldposX;
int16_t posdynlight_r, posdynlight_g, posdynlight_b; float *worldposY = thread->worldposY;
fixed_t lightarray[MAXWIDTH / 16]; float *worldposZ = thread->worldposZ;
uint32_t *texel = thread->texel;
int32_t *texelV = thread->texelV;
fixed_t *lightarray = thread->lightarray;
uint32_t *dynlights = thread->dynlights;
if (!(ModeT::SWFlags & SWSTYLEF_Fill) && !(ModeT::SWFlags & SWSTYLEF_FogBoundary))
{
texPixels = (const uint32_t*)args->uniforms->TexturePixels();
texWidth = args->uniforms->TextureWidth();
texHeight = args->uniforms->TextureHeight();
}
if (ModeT::SWFlags & SWSTYLEF_Translated)
{
translation = (const uint32_t*)args->uniforms->Translation();
}
if ((ModeT::SWFlags & SWSTYLEF_Fill) || (ModeT::SWFlags & SWSTYLEF_Skycap) || (ModeT::Flags & STYLEF_ColorIsFixed))
{
fillcolor = args->uniforms->Color();
}
if (!(ModeT::Flags & STYLEF_Alpha1))
{
actoralpha = args->uniforms->Alpha();
}
v1X = args->v1->x; v1X = args->v1->x;
v1Y = args->v1->y; v1Y = args->v1->y;
@ -417,50 +442,6 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
posU = v1U + stepU * startX + args->gradientY.U * startY; posU = v1U + stepU * startX + args->gradientY.U * startY;
posV = v1V + stepV * startX + args->gradientY.V * startY; posV = v1V + stepV * startX + args->gradientY.V * startY;
texPixels = (const uint32_t*)args->uniforms->TexturePixels();
translation = (const uint32_t*)args->uniforms->Translation();
texWidth = args->uniforms->TextureWidth();
texHeight = args->uniforms->TextureHeight();
fillcolor = args->uniforms->Color();
alpha = args->uniforms->Alpha();
light = args->uniforms->Light();
if (OptT::Flags & SWOPT_FixedLight)
{
light += light >> 7; // 255 -> 256
}
else
{
float globVis = args->uniforms->GlobVis() * (1.0f / 32.0f);
shade = (fixed_t)((2.0f - (light + 12.0f) / 128.0f) * (float)FRACUNIT);
lightpos = (fixed_t)(globVis * posW * (float)FRACUNIT);
lightstep = (fixed_t)(globVis * stepW * (float)FRACUNIT);
int affineOffset = x0 / 16 * 16 - x0;
lightpos = lightpos + lightstep * affineOffset;
lightstep = lightstep * 16;
fixed_t maxvis = 24 * FRACUNIT / 32;
fixed_t maxlight = 31 * FRACUNIT / 32;
for (int x = x0 / 16; x <= x1 / 16 + 1; x++)
{
lightarray[x] = (FRACUNIT - clamp<fixed_t>(shade - MIN(maxvis, lightpos), 0, maxlight)) >> 8;
lightpos += lightstep;
}
int offset = x0 >> 4;
int t1 = x0 & 15;
int t0 = 16 - t1;
lightpos = (lightarray[offset] * t0 + lightarray[offset + 1] * t1);
for (int x = x0 / 16; x <= x1 / 16; x++)
{
lightarray[x] = lightarray[x + 1] - lightarray[x];
}
}
if (OptT::Flags & SWOPT_DynLights) if (OptT::Flags & SWOPT_DynLights)
{ {
v1WorldX = args->v1->worldX * v1W; v1WorldX = args->v1->worldX * v1W;
@ -472,6 +453,61 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
posWorldX = v1WorldX + stepWorldX * startX + args->gradientY.WorldX * startY; posWorldX = v1WorldX + stepWorldX * startX + args->gradientY.WorldX * startY;
posWorldY = v1WorldY + stepWorldY * startX + args->gradientY.WorldY * startY; posWorldY = v1WorldY + stepWorldY * startX + args->gradientY.WorldY * startY;
posWorldZ = v1WorldZ + stepWorldZ * startX + args->gradientY.WorldZ * startY; posWorldZ = v1WorldZ + stepWorldZ * startX + args->gradientY.WorldZ * startY;
}
if (!(OptT::Flags & SWOPT_FixedLight))
{
float globVis = args->uniforms->GlobVis() * (1.0f / 32.0f);
light = args->uniforms->Light();
shade = (fixed_t)((2.0f - (light + 12.0f) / 128.0f) * (float)FRACUNIT);
lightpos = (fixed_t)(globVis * posW * (float)FRACUNIT);
lightstep = (fixed_t)(globVis * stepW * (float)FRACUNIT);
}
for (int x = x0; x < x1; x++)
{
if (OptT::Flags & SWOPT_DynLights)
{
float rcp_posW = 1.0f / posW;
worldposX[x] = posWorldX * rcp_posW;
worldposY[x] = posWorldY * rcp_posW;
worldposZ[x] = posWorldZ * rcp_posW;
posWorldX += stepWorldX;
posWorldY += stepWorldY;
posWorldZ += stepWorldZ;
}
if (!(OptT::Flags & SWOPT_FixedLight))
{
fixed_t maxvis = 24 * FRACUNIT / 32;
fixed_t maxlight = 31 * FRACUNIT / 32;
lightarray[x] = (FRACUNIT - clamp<fixed_t>(shade - MIN(maxvis, lightpos), 0, maxlight)) >> 8;
lightpos += lightstep;
}
if (!(ModeT::SWFlags & SWSTYLEF_Fill) && !(ModeT::SWFlags & SWSTYLEF_FogBoundary))
{
float rcpW = 0x01000000 / posW;
int32_t u = (int32_t)(posU * rcpW);
int32_t v = (int32_t)(posV * rcpW);
uint32_t texelX = ((((uint32_t)u << 8) >> 16) * texWidth) >> 16;
uint32_t texelY = ((((uint32_t)v << 8) >> 16) * texHeight) >> 16;
texel[x] = texelX * texHeight + texelY;
texelV[x] = v;
posU += stepU;
posV += stepV;
}
posW += stepW;
}
if (OptT::Flags & SWOPT_DynLights)
{
PolyLight *lights;
int num_lights;
float worldnormalX, worldnormalY, worldnormalZ;
uint32_t dynlightcolor;
lights = args->uniforms->Lights(); lights = args->uniforms->Lights();
num_lights = args->uniforms->NumLights(); num_lights = args->uniforms->NumLights();
@ -503,26 +539,12 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
worldnormalZ *= rcplen; worldnormalZ *= rcplen;
} }
int affineOffset = x0 / 16 * 16 - x0; for (int x = x0; x < x1; x++)
float posLightW = posW + stepW * affineOffset;
posWorldX = posWorldX + stepWorldX * affineOffset;
posWorldY = posWorldY + stepWorldY * affineOffset;
posWorldZ = posWorldZ + stepWorldZ * affineOffset;
float stepLightW = stepW * 16.0f;
stepWorldX *= 16.0f;
stepWorldY *= 16.0f;
stepWorldZ *= 16.0f;
for (int x = x0 / 16; x <= x1 / 16 + 1; x++)
{ {
uint32_t lit_r = RPART(dynlightcolor); uint32_t lit_r = RPART(dynlightcolor);
uint32_t lit_g = GPART(dynlightcolor); uint32_t lit_g = GPART(dynlightcolor);
uint32_t lit_b = BPART(dynlightcolor); uint32_t lit_b = BPART(dynlightcolor);
float rcp_posW = 1.0f / posLightW;
float worldposX = posWorldX * rcp_posW;
float worldposY = posWorldY * rcp_posW;
float worldposZ = posWorldZ * rcp_posW;
for (int i = 0; i < num_lights; i++) for (int i = 0; i < num_lights; i++)
{ {
float lightposX = lights[i].x; float lightposX = lights[i].x;
@ -538,9 +560,9 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
// L = light-pos // L = light-pos
// dist = sqrt(dot(L, L)) // dist = sqrt(dot(L, L))
// distance_attenuation = 1 - MIN(dist * (1/radius), 1) // distance_attenuation = 1 - MIN(dist * (1/radius), 1)
float Lx = lightposX - worldposX; float Lx = lightposX - worldposX[x];
float Ly = lightposY - worldposY; float Ly = lightposY - worldposY[x];
float Lz = lightposZ - worldposZ; float Lz = lightposZ - worldposZ[x];
float dist2 = Lx * Lx + Ly * Ly + Lz * Lz; float dist2 = Lx * Lx + Ly * Ly + Lz * Lz;
#ifdef NO_SSE #ifdef NO_SSE
//float rcp_dist = 1.0f / sqrt(dist2); //float rcp_dist = 1.0f / sqrt(dist2);
@ -572,29 +594,14 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
lit_r = MIN<uint32_t>(lit_r, 255); lit_r = MIN<uint32_t>(lit_r, 255);
lit_g = MIN<uint32_t>(lit_g, 255); lit_g = MIN<uint32_t>(lit_g, 255);
lit_b = MIN<uint32_t>(lit_b, 255); lit_b = MIN<uint32_t>(lit_b, 255);
dynlights_r[x] = lit_r; dynlights[x] = MAKEARGB(255, lit_r, lit_g, lit_b);
dynlights_g[x] = lit_g;
dynlights_b[x] = lit_b;
posLightW += stepLightW;
posWorldX += stepWorldX;
posWorldY += stepWorldY;
posWorldZ += stepWorldZ;
} }
}
int offset = x0 >> 4; if (OptT::Flags & SWOPT_FixedLight)
int t1 = x0 & 15; {
int t0 = 16 - t1; fixedlight = args->uniforms->Light();
posdynlight_r = (dynlights_r[offset] * t0 + dynlights_r[offset + 1] * t1); fixedlight += fixedlight >> 7; // 255 -> 256
posdynlight_g = (dynlights_g[offset] * t0 + dynlights_g[offset + 1] * t1);
posdynlight_b = (dynlights_b[offset] * t0 + dynlights_b[offset + 1] * t1);
for (int x = x0 / 16; x <= x1 / 16; x++)
{
dynlights_r[x] = dynlights_r[x + 1] - dynlights_r[x];
dynlights_g[x] = dynlights_g[x + 1] - dynlights_g[x];
dynlights_b[x] = dynlights_b[x + 1] - dynlights_b[x];
}
} }
if (OptT::Flags & SWOPT_ColoredFog) if (OptT::Flags & SWOPT_ColoredFog)
@ -609,8 +616,6 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
inv_desaturate = 256 - desaturate; inv_desaturate = 256 - desaturate;
} }
fixed_t fuzzscale;
int _fuzzpos;
if (ModeT::BlendOp == STYLEOP_Fuzz) if (ModeT::BlendOp == STYLEOP_Fuzz)
{ {
fuzzscale = (200 << FRACBITS) / viewheight; fuzzscale = (200 << FRACBITS) / viewheight;
@ -620,19 +625,55 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
uint32_t *dest = (uint32_t*)args->dest; uint32_t *dest = (uint32_t*)args->dest;
uint32_t *destLine = dest + args->pitch * y; uint32_t *destLine = dest + args->pitch * y;
int x = x0; int sseend = x0;
while (x < x1) #ifndef NO_SSE
if (ModeT::BlendOp == STYLEOP_Add &&
ModeT::BlendSrc == STYLEALPHA_One &&
ModeT::BlendDest == STYLEALPHA_Zero &&
(ModeT::Flags & STYLEF_Alpha1) &&
!(OptT::Flags & SWOPT_ColoredFog) &&
!(ModeT::Flags & STYLEF_RedIsAlpha) &&
!(ModeT::SWFlags & SWSTYLEF_Skycap) &&
!(ModeT::SWFlags & SWSTYLEF_FogBoundary) &&
!(ModeT::SWFlags & SWSTYLEF_Fill))
{
sseend += (x1 - x0) / 2 * 2;
__m128i mlightshade;
if (OptT::Flags & SWOPT_FixedLight)
mlightshade = _mm_set1_epi16(fixedlight);
__m128i alphamask = _mm_set1_epi32(0xff000000);
for (int x = x0; x < sseend; x += 2)
{
__m128i mfg = _mm_unpacklo_epi8(_mm_setr_epi32(texPixels[texel[x]], texPixels[texel[x + 1]], 0, 0), _mm_setzero_si128());
if (!(OptT::Flags & SWOPT_FixedLight))
mlightshade = _mm_shuffle_epi32(_mm_shufflelo_epi16(_mm_loadl_epi64((const __m128i*)&lightarray[x]), _MM_SHUFFLE(2, 2, 0, 0)), _MM_SHUFFLE(1, 1, 0, 0));
if (OptT::Flags & SWOPT_DynLights)
{
__m128i mdynlight = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)&dynlights[x]), _mm_setzero_si128());
mfg = _mm_srli_epi16(_mm_mullo_epi16(_mm_min_epi16(_mm_add_epi16(mdynlight, mlightshade), _mm_set1_epi16(256)), mfg), 8);
}
else
{
mfg = _mm_srli_epi16(_mm_mullo_epi16(mlightshade, mfg), 8);
}
_mm_storel_epi64((__m128i*)&destLine[x], _mm_or_si128(_mm_packus_epi16(mfg, _mm_setzero_si128()), alphamask));
}
}
#endif
for (int x = sseend; x < x1; x++)
{ {
if (ModeT::BlendOp == STYLEOP_Fuzz) if (ModeT::BlendOp == STYLEOP_Fuzz)
{ {
using namespace swrenderer; using namespace swrenderer;
float rcpW = 0x01000000 / posW; unsigned int sampleshadeout = APART(texPixels[texel[x]]);
int32_t u = (int32_t)(posU * rcpW);
int32_t v = (int32_t)(posV * rcpW);
uint32_t texelX = ((((uint32_t)u << 8) >> 16) * texWidth) >> 16;
uint32_t texelY = ((((uint32_t)v << 8) >> 16) * texHeight) >> 16;
unsigned int sampleshadeout = APART(texPixels[texelX * texHeight + texelY]);
sampleshadeout += sampleshadeout >> 7; // 255 -> 256 sampleshadeout += sampleshadeout >> 7; // 255 -> 256
int scaled_x = (x * fuzzscale) >> FRACBITS; int scaled_x = (x * fuzzscale) >> FRACBITS;
@ -654,14 +695,9 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
} }
else if (ModeT::SWFlags & SWSTYLEF_Skycap) else if (ModeT::SWFlags & SWSTYLEF_Skycap)
{ {
float rcpW = 0x01000000 / posW; uint32_t fg = texPixels[texel[x]];
int32_t u = (int32_t)(posU * rcpW);
int32_t v = (int32_t)(posV * rcpW);
uint32_t texelX = ((((uint32_t)u << 8) >> 16) * texWidth) >> 16;
uint32_t texelY = ((((uint32_t)v << 8) >> 16) * texHeight) >> 16;
uint32_t fg = texPixels[texelX * texHeight + texelY];
int v = texelV[x];
int start_fade = 2; // How fast it should fade out int start_fade = 2; // How fast it should fade out
int alpha_top = clamp(v >> (16 - start_fade), 0, 256); int alpha_top = clamp(v >> (16 - start_fade), 0, 256);
int alpha_bottom = clamp(((2 << 24) - v) >> (16 - start_fade), 0, 256); int alpha_bottom = clamp(((2 << 24) - v) >> (16 - start_fade), 0, 256);
@ -695,11 +731,11 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
int lightshade; int lightshade;
if (OptT::Flags & SWOPT_FixedLight) if (OptT::Flags & SWOPT_FixedLight)
{ {
lightshade = light; lightshade = fixedlight;
} }
else else
{ {
lightshade = lightpos >> 4; lightshade = lightarray[x];
} }
uint32_t shadedfg_r, shadedfg_g, shadedfg_b; uint32_t shadedfg_r, shadedfg_g, shadedfg_b;
@ -731,26 +767,17 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
{ {
fg = fillcolor; fg = fillcolor;
} }
else if (ModeT::SWFlags & SWSTYLEF_Translated)
{
fg = translation[((const uint8_t*)texPixels)[texel[x]]];
}
else if (ModeT::Flags & STYLEF_RedIsAlpha)
{
fg = ((const uint8_t*)texPixels)[texel[x]];
}
else else
{ {
float rcpW = 0x01000000 / posW; fg = texPixels[texel[x]];
int32_t u = (int32_t)(posU * rcpW);
int32_t v = (int32_t)(posV * rcpW);
uint32_t texelX = ((((uint32_t)u << 8) >> 16) * texWidth) >> 16;
uint32_t texelY = ((((uint32_t)v << 8) >> 16) * texHeight) >> 16;
if (ModeT::SWFlags & SWSTYLEF_Translated)
{
fg = translation[((const uint8_t*)texPixels)[texelX * texHeight + texelY]];
}
else if (ModeT::Flags & STYLEF_RedIsAlpha)
{
fg = ((const uint8_t*)texPixels)[texelX * texHeight + texelY];
}
else
{
fg = texPixels[texelX * texHeight + texelY];
}
} }
if ((ModeT::Flags & STYLEF_ColorIsFixed) && !(ModeT::SWFlags & SWSTYLEF_Fill)) if ((ModeT::Flags & STYLEF_ColorIsFixed) && !(ModeT::SWFlags & SWSTYLEF_Fill))
@ -765,17 +792,17 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
if (!(ModeT::Flags & STYLEF_Alpha1)) if (!(ModeT::Flags & STYLEF_Alpha1))
{ {
fgalpha = (fgalpha * alpha) >> 8; fgalpha = (fgalpha * actoralpha) >> 8;
} }
int lightshade; uint32_t lightshade;
if (OptT::Flags & SWOPT_FixedLight) if (OptT::Flags & SWOPT_FixedLight)
{ {
lightshade = light; lightshade = fixedlight;
} }
else else
{ {
lightshade = lightpos >> 4; lightshade = lightarray[x];
} }
uint32_t shadedfg_r, shadedfg_g, shadedfg_b; uint32_t shadedfg_r, shadedfg_g, shadedfg_b;
@ -792,24 +819,18 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
if (OptT::Flags & SWOPT_DynLights) if (OptT::Flags & SWOPT_DynLights)
{ {
uint32_t lit_r = posdynlight_r >> 4; shadedfg_r = MIN(shadedfg_r + ((fg_r * RPART(dynlights[x])) >> 8), (uint32_t)255);
uint32_t lit_g = posdynlight_g >> 4; shadedfg_g = MIN(shadedfg_g + ((fg_g * GPART(dynlights[x])) >> 8), (uint32_t)255);
uint32_t lit_b = posdynlight_b >> 4; shadedfg_b = MIN(shadedfg_b + ((fg_b * BPART(dynlights[x])) >> 8), (uint32_t)255);
shadedfg_r = MIN(shadedfg_r + ((fg_r * lit_r) >> 8), (uint32_t)255);
shadedfg_g = MIN(shadedfg_g + ((fg_g * lit_g) >> 8), (uint32_t)255);
shadedfg_b = MIN(shadedfg_b + ((fg_b * lit_b) >> 8), (uint32_t)255);
} }
} }
else else
{ {
if (OptT::Flags & SWOPT_DynLights) if (OptT::Flags & SWOPT_DynLights)
{ {
uint32_t lit_r = posdynlight_r >> 4; shadedfg_r = (RPART(fg) * MIN(lightshade + RPART(dynlights[x]), (uint32_t)256)) >> 8;
uint32_t lit_g = posdynlight_g >> 4; shadedfg_g = (GPART(fg) * MIN(lightshade + GPART(dynlights[x]), (uint32_t)256)) >> 8;
uint32_t lit_b = posdynlight_b >> 4; shadedfg_b = (BPART(fg) * MIN(lightshade + BPART(dynlights[x]), (uint32_t)256)) >> 8;
shadedfg_r = (RPART(fg) * MIN(lightshade + lit_r, (uint32_t)256)) >> 8;
shadedfg_g = (GPART(fg) * MIN(lightshade + lit_g, (uint32_t)256)) >> 8;
shadedfg_b = (BPART(fg) * MIN(lightshade + lit_b, (uint32_t)256)) >> 8;
} }
else else
{ {
@ -927,24 +948,11 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
destLine[x] = MAKEARGB(255, out_r, out_g, out_b); destLine[x] = MAKEARGB(255, out_r, out_g, out_b);
} }
} }
posW += stepW;
posU += stepU;
posV += stepV;
if (OptT::Flags & SWOPT_DynLights)
{
posdynlight_r += dynlights_r[x >> 4];
posdynlight_g += dynlights_g[x >> 4];
posdynlight_b += dynlights_b[x >> 4];
}
if (!(OptT::Flags & SWOPT_FixedLight))
lightpos += lightarray[x >> 4];
x++;
} }
} }
template<typename ModeT> template<typename ModeT>
void DrawSpan32(int y, int x0, int x1, const TriDrawTriangleArgs *args) void DrawSpan32(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread)
{ {
using namespace TriScreenDrawerModes; using namespace TriScreenDrawerModes;
@ -953,16 +961,16 @@ void DrawSpan32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
if (!args->uniforms->FixedLight()) if (!args->uniforms->FixedLight())
{ {
if (args->uniforms->SimpleShade()) if (args->uniforms->SimpleShade())
DrawSpanOpt32<ModeT, DrawerOpt>(y, x0, x1, args); DrawSpanOpt32<ModeT, DrawerOpt>(y, x0, x1, args, thread);
else else
DrawSpanOpt32<ModeT, DrawerOptC>(y, x0, x1, args); DrawSpanOpt32<ModeT, DrawerOptC>(y, x0, x1, args, thread);
} }
else else
{ {
if (args->uniforms->SimpleShade()) if (args->uniforms->SimpleShade())
DrawSpanOpt32<ModeT, DrawerOptF>(y, x0, x1, args); DrawSpanOpt32<ModeT, DrawerOptF>(y, x0, x1, args, thread);
else else
DrawSpanOpt32<ModeT, DrawerOptCF>(y, x0, x1, args); DrawSpanOpt32<ModeT, DrawerOptCF>(y, x0, x1, args, thread);
} }
} }
else else
@ -970,22 +978,22 @@ void DrawSpan32(int y, int x0, int x1, const TriDrawTriangleArgs *args)
if (!args->uniforms->FixedLight()) if (!args->uniforms->FixedLight())
{ {
if (args->uniforms->SimpleShade()) if (args->uniforms->SimpleShade())
DrawSpanOpt32<ModeT, DrawerOptL>(y, x0, x1, args); DrawSpanOpt32<ModeT, DrawerOptL>(y, x0, x1, args, thread);
else else
DrawSpanOpt32<ModeT, DrawerOptLC>(y, x0, x1, args); DrawSpanOpt32<ModeT, DrawerOptLC>(y, x0, x1, args, thread);
} }
else else
{ {
if (args->uniforms->SimpleShade()) if (args->uniforms->SimpleShade())
DrawSpanOpt32<ModeT, DrawerOptLF>(y, x0, x1, args); DrawSpanOpt32<ModeT, DrawerOptLF>(y, x0, x1, args, thread);
else else
DrawSpanOpt32<ModeT, DrawerOptLCF>(y, x0, x1, args); DrawSpanOpt32<ModeT, DrawerOptLCF>(y, x0, x1, args, thread);
} }
} }
} }
template<typename ModeT, typename OptT> template<typename ModeT, typename OptT>
void DrawSpanOpt8(int y, int x0, int x1, const TriDrawTriangleArgs *args) void DrawSpanOpt8(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread)
{ {
using namespace TriScreenDrawerModes; using namespace TriScreenDrawerModes;
@ -1501,23 +1509,23 @@ void DrawSpanOpt8(int y, int x0, int x1, const TriDrawTriangleArgs *args)
} }
template<typename ModeT> template<typename ModeT>
void DrawSpan8(int y, int x0, int x1, const TriDrawTriangleArgs *args) void DrawSpan8(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread)
{ {
using namespace TriScreenDrawerModes; using namespace TriScreenDrawerModes;
if (args->uniforms->NumLights() == 0 && args->uniforms->DynLightColor() == 0) if (args->uniforms->NumLights() == 0 && args->uniforms->DynLightColor() == 0)
{ {
if (!args->uniforms->FixedLight()) if (!args->uniforms->FixedLight())
DrawSpanOpt8<ModeT, DrawerOptC>(y, x0, x1, args); DrawSpanOpt8<ModeT, DrawerOptC>(y, x0, x1, args, thread);
else else
DrawSpanOpt8<ModeT, DrawerOptCF>(y, x0, x1, args); DrawSpanOpt8<ModeT, DrawerOptCF>(y, x0, x1, args, thread);
} }
else else
{ {
if (!args->uniforms->FixedLight()) if (!args->uniforms->FixedLight())
DrawSpanOpt8<ModeT, DrawerOptLC>(y, x0, x1, args); DrawSpanOpt8<ModeT, DrawerOptLC>(y, x0, x1, args, thread);
else else
DrawSpanOpt8<ModeT, DrawerOptLCF>(y, x0, x1, args); DrawSpanOpt8<ModeT, DrawerOptLCF>(y, x0, x1, args, thread);
} }
} }
@ -2049,7 +2057,7 @@ void DrawRect32(const void *destOrg, int destWidth, int destHeight, int destPitc
DrawRectOpt32<ModeT, DrawerOptCF>(destOrg, destWidth, destHeight, destPitch, args, thread); DrawRectOpt32<ModeT, DrawerOptCF>(destOrg, destWidth, destHeight, destPitch, args, thread);
} }
void(*ScreenTriangle::SpanDrawers8[])(int, int, int, const TriDrawTriangleArgs *) = void(*ScreenTriangle::SpanDrawers8[])(int, int, int, const TriDrawTriangleArgs *, PolyTriangleThreadData *) =
{ {
&DrawSpan8<TriScreenDrawerModes::StyleOpaque>, &DrawSpan8<TriScreenDrawerModes::StyleOpaque>,
&DrawSpan8<TriScreenDrawerModes::StyleSkycap>, &DrawSpan8<TriScreenDrawerModes::StyleSkycap>,
@ -2081,7 +2089,7 @@ void(*ScreenTriangle::SpanDrawers8[])(int, int, int, const TriDrawTriangleArgs *
&DrawSpan8<TriScreenDrawerModes::StyleAddShadedTranslated> &DrawSpan8<TriScreenDrawerModes::StyleAddShadedTranslated>
}; };
void(*ScreenTriangle::SpanDrawers32[])(int, int, int, const TriDrawTriangleArgs *) = void(*ScreenTriangle::SpanDrawers32[])(int, int, int, const TriDrawTriangleArgs *, PolyTriangleThreadData *) =
{ {
&DrawSpan32<TriScreenDrawerModes::StyleOpaque>, &DrawSpan32<TriScreenDrawerModes::StyleOpaque>,
&DrawSpan32<TriScreenDrawerModes::StyleSkycap>, &DrawSpan32<TriScreenDrawerModes::StyleSkycap>,

View file

@ -142,8 +142,8 @@ class ScreenTriangle
public: public:
static void Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread); static void Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread);
static void(*SpanDrawers8[])(int y, int x0, int x1, const TriDrawTriangleArgs *args); static void(*SpanDrawers8[])(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread);
static void(*SpanDrawers32[])(int y, int x0, int x1, const TriDrawTriangleArgs *args); static void(*SpanDrawers32[])(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread);
static void(*RectDrawers8[])(const void *, int, int, int, const RectDrawArgs *, PolyTriangleThreadData *); static void(*RectDrawers8[])(const void *, int, int, int, const RectDrawArgs *, PolyTriangleThreadData *);
static void(*RectDrawers32[])(const void *, int, int, int, const RectDrawArgs *, PolyTriangleThreadData *); static void(*RectDrawers32[])(const void *, int, int, int, const RectDrawArgs *, PolyTriangleThreadData *);

View file

@ -1586,17 +1586,13 @@ FSerializer &Serialize(FSerializer &arc, const char *key, DObject *&value, DObje
if (retcode) *retcode = true; if (retcode) *retcode = true;
if (arc.isWriting()) if (arc.isWriting())
{ {
if (value != nullptr) if (value != nullptr && !(value->ObjectFlags & (OF_EuthanizeMe | OF_Transient)))
{ {
int ndx; int ndx;
if (value == WP_NOCHANGE) if (value == WP_NOCHANGE)
{ {
ndx = -1; ndx = -1;
} }
else if (value->ObjectFlags & (OF_EuthanizeMe | OF_Transient))
{
return arc;
}
else else
{ {
int *pndx = arc.w->mObjectMap.CheckKey(value); int *pndx = arc.w->mObjectMap.CheckKey(value);

View file

@ -1423,6 +1423,24 @@ TXT_QUIETUS_PIECE = "SEGMENT OF QUIETUS";
TXT_WRAITHVERGE_PIECE = "SEGMENT OF WRAITHVERGE"; TXT_WRAITHVERGE_PIECE = "SEGMENT OF WRAITHVERGE";
TXT_BLOODSCOURGE_PIECE = "SEGMENT OF BLOODSCOURGE"; TXT_BLOODSCOURGE_PIECE = "SEGMENT OF BLOODSCOURGE";
// Friendly names
FN_FIREDEMON = "Afrit";
FN_DEMON1 = "Serpent";
FN_ETTIN = "Ettin";
FN_CENTAUR = "Centaur";
FN_SLAUGHTAUR = "Slaughtaur";
FN_BISHOP = "Bishop";
FN_ICEGUY = "Wendigo";
FN_SERPENT = "Stalker";
FN_WRAITH = "Reiver";
FN_DRAGON = "Death Wyvern";
FN_KORAX = "Korax";
FN_FBOSS = "Zedek";
FN_MBOSS = "Menelkir";
FN_CBOSS = "Traductus";
FN_HERESIARCH = "Heresiarch";
// Strife locks // Strife locks
TXT_NEEDKEY = "You don't have the key"; TXT_NEEDKEY = "You don't have the key";

View file

@ -24,6 +24,7 @@ class Bishop : Actor
DeathSound "BishopDeath"; DeathSound "BishopDeath";
ActiveSound "BishopActiveSounds"; ActiveSound "BishopActiveSounds";
Obituary"$OB_BISHOP"; Obituary"$OB_BISHOP";
Tag "$FN_BISHOP";
} }
States States

View file

@ -21,6 +21,7 @@ class Centaur : Actor
HowlSound "PuppyBeat"; HowlSound "PuppyBeat";
Obituary "$OB_CENTAUR"; Obituary "$OB_CENTAUR";
DamageFactor "Electric", 3; DamageFactor "Electric", 3;
Tag "$FN_CENTAUR";
} }
States States
{ {
@ -107,6 +108,7 @@ class CentaurLeader : Centaur
Speed 10; Speed 10;
Obituary "$OB_SLAUGHTAUR"; Obituary "$OB_SLAUGHTAUR";
HitObituary "$OB_SLAUGHTAURHIT"; HitObituary "$OB_SLAUGHTAURHIT";
Tag "$FN_SLAUGHTAUR";
} }
States States
{ {

View file

@ -15,7 +15,8 @@ class ClericBoss : Actor
+DONTMORPH +DONTMORPH
PainSound "PlayerClericPain"; PainSound "PlayerClericPain";
DeathSound "PlayerClericCrazyDeath"; DeathSound "PlayerClericCrazyDeath";
Obituary "$OBCBOSS"; Obituary "$OB_CBOSS";
Tag "$FN_CBOSS";
} }
States States

View file

@ -20,6 +20,7 @@ class Demon1 : Actor
DeathSound "DemonDeath"; DeathSound "DemonDeath";
ActiveSound "DemonActive"; ActiveSound "DemonActive";
Obituary "$OB_DEMON1"; Obituary "$OB_DEMON1";
Tag "$FN_DEMON1";
} }
const ChunkFlags = SXF_TRANSFERTRANSLATION | SXF_ABSOLUTEVELOCITY; const ChunkFlags = SXF_TRANSFERTRANSLATION | SXF_ABSOLUTEVELOCITY;

View file

@ -19,6 +19,7 @@ class Dragon : Actor
DeathSound "DragonDeath"; DeathSound "DragonDeath";
ActiveSound "DragonActive"; ActiveSound "DragonActive";
Obituary "$OB_DRAGON"; Obituary "$OB_DRAGON";
Tag "$FN_DRAGON";
} }
States States

View file

@ -22,6 +22,7 @@ class Ettin : Actor
ActiveSound "EttinActive"; ActiveSound "EttinActive";
HowlSound "PuppyBeat"; HowlSound "PuppyBeat";
Obituary "$OB_ETTIN"; Obituary "$OB_ETTIN";
Tag "$FN_ETTIN";
} }
States States
{ {

View file

@ -17,6 +17,7 @@ class FighterBoss : Actor
PainSound "PlayerFighterPain"; PainSound "PlayerFighterPain";
DeathSound "PlayerFighterCrazyDeath"; DeathSound "PlayerFighterCrazyDeath";
Obituary "$OB_FBOSS"; Obituary "$OB_FBOSS";
Tag "$FN_FBOSS";
} }
States States

View file

@ -24,6 +24,7 @@ class FireDemon : Actor
DeathSound "FireDemonDeath"; DeathSound "FireDemonDeath";
ActiveSound "FireDemonActive"; ActiveSound "FireDemonActive";
Obituary "$OB_FIREDEMON"; Obituary "$OB_FIREDEMON";
Tag "$FN_FIREDEMON";
} }
States States

View file

@ -70,6 +70,7 @@ class Heresiarch : Actor
DeathSound "SorcererDeathScream"; DeathSound "SorcererDeathScream";
ActiveSound "SorcererActive"; ActiveSound "SorcererActive";
Obituary "$OB_HERESIARCH"; Obituary "$OB_HERESIARCH";
Tag "$FN_HERESIARCH";
} }
States States

View file

@ -65,6 +65,7 @@ class ZRock4 : Actor
{ {
Radius 20; Radius 20;
Height 16; Height 16;
+SOLID
} }
States States
{ {

View file

@ -20,6 +20,7 @@ class IceGuy : Actor
AttackSound "IceGuyAttack"; AttackSound "IceGuyAttack";
ActiveSound "IceGuyActive"; ActiveSound "IceGuyActive";
Obituary "$OB_ICEGUY"; Obituary "$OB_ICEGUY";
Tag "$FN_ICEGUY";
} }

View file

@ -60,6 +60,7 @@ class Korax : Actor
DeathSound "KoraxDeath"; DeathSound "KoraxDeath";
ActiveSound "KoraxActive"; ActiveSound "KoraxActive";
Obituary "$OB_KORAX"; Obituary "$OB_KORAX";
Tag "$FN_KORAX";
} }
States States

View file

@ -16,6 +16,7 @@ class MageBoss : Actor
PainSound "PlayerMagePain"; PainSound "PlayerMagePain";
DeathSound "PlayerMageCrazyDeath"; DeathSound "PlayerMageCrazyDeath";
Obituary "$OB_MBOSS"; Obituary "$OB_MBOSS";
Tag "$FN_MBOSS";
} }
States States

View file

@ -22,6 +22,7 @@ class Serpent : Actor
PainSound "SerpentPain"; PainSound "SerpentPain";
DeathSound "SerpentDeath"; DeathSound "SerpentDeath";
HitObituary "$OB_SERPENTHIT"; HitObituary "$OB_SERPENTHIT";
Tag "$FN_SERPENT";
} }
States States

View file

@ -21,6 +21,7 @@ class Wraith : Actor
ActiveSound "WraithActive"; ActiveSound "WraithActive";
HitObituary "$OB_WRAITHHIT"; HitObituary "$OB_WRAITHHIT";
Obituary "$OB_WRAITH"; Obituary "$OB_WRAITH";
Tag "$FN_WRAITH";
} }
States States