Expand UDMF and ZScript API for side's own additive colors

Add 'useowncoloradd_{top,mid,bottom}' sidedef properties to the UDMF 
spec
Only use side's additive colors if 'useowncoloradd_(top|mid|bottom)' is 
set.
Rename UseOwnColors flag to UseOwnSpecialColors
Add UseOwnAdditiveColor flag to side_t::part
Add EnableAdditiveColor to side_t
Add Side.EnableAdditiveColor to ZScript API
This commit is contained in:
Kevin Caccamo 2018-12-23 01:36:25 -05:00 committed by Christoph Oelckers
parent 286886e161
commit e04fc026ff
6 changed files with 65 additions and 18 deletions

View file

@ -201,9 +201,12 @@ Note: All <bool> fields default to false unless mentioned otherwise.
uppercolor_bottom = <int>; // Material color of the top of the lower tier. uppercolor_bottom = <int>; // Material color of the top of the lower tier.
lowercolor_bottom = <int>; // Material color of the bottom of the lower tier. (Hardware rendering only.) lowercolor_bottom = <int>; // Material color of the bottom of the lower tier. (Hardware rendering only.)
coloradd_top = <int>; // Additive material color to apply to top section of sidedef. Takes precedence over sector setting. Default is black (0x000000) useowncoloradd_top = <bool>; // Whether or not to use the given additive color for the top section of the sidedef.
coloradd_mid = <int>; // Additive material color to apply to middle section of sidedef. Takes precedence over sector setting. Default is black (0x000000) coloradd_top = <int>; // Additive material color to apply to top section of sidedef. Default is black (0x000000)
coloradd_bottom = <int>; // Additive material color to apply to bottom section of sidedef. Takes precedence over sector setting. Default is black (0x000000) useowncoloradd_mid = <bool>; // Whether or not to use the given additive color for the middle section of the sidedef.
coloradd_mid = <int>; // Additive material color to apply to middle section of sidedef. Default is black (0x000000)
useowncoloradd_bottom = <bool>; // Whether or not to use the given additive color for the bottom section of the sidedef.
coloradd_bottom = <int>; // Additive material color to apply to bottom section of sidedef. Default is black (0x000000)
} }
sector sector

View file

@ -659,8 +659,11 @@ xx(clampgradient_bottom)
xx(useowncolors_bottom) xx(useowncolors_bottom)
xx(uppercolor_bottom) xx(uppercolor_bottom)
xx(lowercolor_bottom) xx(lowercolor_bottom)
xx(useowncoloradd_top)
xx(coloradd_top) xx(coloradd_top)
xx(useowncoloradd_mid)
xx(coloradd_mid) xx(coloradd_mid)
xx(useowncoloradd_bottom)
xx(coloradd_bottom) xx(coloradd_bottom)
xx(Renderstyle) xx(Renderstyle)

View file

@ -1329,7 +1329,7 @@ public:
break; break;
case NAME_useowncolors_top: case NAME_useowncolors_top:
Flag(sd->textures[side_t::top].flags, side_t::part::UseOwnColors, key); Flag(sd->textures[side_t::top].flags, side_t::part::UseOwnSpecialColors, key);
break; break;
case NAME_uppercolor_top: case NAME_uppercolor_top:
@ -1353,7 +1353,7 @@ public:
break; break;
case NAME_useowncolors_mid: case NAME_useowncolors_mid:
Flag(sd->textures[side_t::mid].flags, side_t::part::UseOwnColors, key); Flag(sd->textures[side_t::mid].flags, side_t::part::UseOwnSpecialColors, key);
break; break;
case NAME_uppercolor_mid: case NAME_uppercolor_mid:
@ -1377,7 +1377,7 @@ public:
break; break;
case NAME_useowncolors_bottom: case NAME_useowncolors_bottom:
Flag(sd->textures[side_t::bottom].flags, side_t::part::UseOwnColors, key); Flag(sd->textures[side_t::bottom].flags, side_t::part::UseOwnSpecialColors, key);
break; break;
case NAME_uppercolor_bottom: case NAME_uppercolor_bottom:
@ -1400,6 +1400,14 @@ public:
sd->SetAdditiveColor(side_t::bottom, CheckInt(key)); sd->SetAdditiveColor(side_t::bottom, CheckInt(key));
break; break;
case NAME_useowncoloradd_top:
sd->textures[side_t::top].flags |= side_t::part::UseOwnAdditiveColor * CheckBool(key);
case NAME_useowncoloradd_mid:
sd->textures[side_t::mid].flags |= side_t::part::UseOwnAdditiveColor * CheckBool(key);
case NAME_useowncoloradd_bottom:
sd->textures[side_t::bottom].flags |= side_t::part::UseOwnAdditiveColor * CheckBool(key);
default: default:
break; break;

View file

@ -1150,7 +1150,8 @@ struct side_t
NoGradient = 1, NoGradient = 1,
FlipGradient = 2, FlipGradient = 2,
ClampGradient = 4, ClampGradient = 4,
UseOwnColors = 8, UseOwnSpecialColors = 8,
UseOwnAdditiveColor = 16,
}; };
double xOffset; double xOffset;
double yOffset; double yOffset;
@ -1301,22 +1302,37 @@ struct side_t
auto &part = textures[which]; auto &part = textures[which];
if (part.flags & part::NoGradient) slot = 0; if (part.flags & part::NoGradient) slot = 0;
if (part.flags & part::FlipGradient) slot ^= 1; if (part.flags & part::FlipGradient) slot ^= 1;
return (part.flags & part::UseOwnColors) ? part.SpecialColors[slot] : frontsector->SpecialColors[sector_t::walltop + slot]; return (part.flags & part::UseOwnSpecialColors) ? part.SpecialColors[slot] : frontsector->SpecialColors[sector_t::walltop + slot];
} }
void SetAdditiveColor(int which, PalEntry rgb, bool use = true) void EnableAdditiveColor(int which, bool enable)
{ {
rgb.a = use ? 255 : 0; int flag = enable ? part::UseOwnAdditiveColor : 0;
if (enable)
{
textures[which].flags |= flag;
}
else
{
textures[which].flags &= (~flag);
}
}
void SetAdditiveColor(int which, PalEntry rgb)
{
rgb.a = 255;
textures[which].AdditiveColor = rgb; textures[which].AdditiveColor = rgb;
} }
PalEntry GetAdditiveColor(int which, sector_t *frontsector) const PalEntry GetAdditiveColor(int which, sector_t *frontsector) const
{ {
auto &color = textures[which].AdditiveColor; if (textures[which].flags & part::UseOwnAdditiveColor) {
if (color.a == 0) { return textures[which].AdditiveColor;
}
else
{
return frontsector->AdditiveColors[sector_t::walltop]; // Used as additive color for all walls return frontsector->AdditiveColors[sector_t::walltop]; // Used as additive color for all walls
} }
return color;
} }
DInterpolation *SetInterpolation(int position); DInterpolation *SetInterpolation(int position);

View file

@ -1558,11 +1558,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0; return 0;
} }
static void SetSideAdditiveColor(side_t *self, int tier, int color, bool use) static void SetSideAdditiveColor(side_t *self, int tier, int color)
{ {
if (tier >= 0 && tier < 3) if (tier >= 0 && tier < 3)
{ {
self->SetAdditiveColor(tier, color, use); self->SetAdditiveColor(tier, color);
} }
} }
@ -1571,8 +1571,24 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
PARAM_SELF_STRUCT_PROLOGUE(side_t); PARAM_SELF_STRUCT_PROLOGUE(side_t);
PARAM_INT(tier); PARAM_INT(tier);
PARAM_COLOR(color); PARAM_COLOR(color);
PARAM_BOOL(use); SetSideAdditiveColor(self, tier, color);
SetSideAdditiveColor(self, tier, color, use); return 0;
}
static void EnableSideAdditiveColor(side_t *self, int tier, bool enable)
{
if (tier >= 0 && tier < 3)
{
self->EnableAdditiveColor(tier, enable);
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_Side, EnableAdditiveColor, EnableSideAdditiveColor)
{
PARAM_SELF_STRUCT_PROLOGUE(side_t);
PARAM_INT(tier);
PARAM_BOOL(enable);
EnableSideAdditiveColor(self, tier, enable);
return 0; return 0;
} }

View file

@ -87,7 +87,8 @@ struct Side native play
native void MultiplyTextureYScale(int which, double delta); native void MultiplyTextureYScale(int which, double delta);
native void SetSpecialColor(int tier, int position, Color scolor); native void SetSpecialColor(int tier, int position, Color scolor);
native Color GetAdditiveColor(int tier); native Color GetAdditiveColor(int tier);
native void SetAdditiveColor(int tier, Color color, bool use = true); native void SetAdditiveColor(int tier, Color color);
native void EnableAdditiveColor(int tier, bool enable);
//native DInterpolation *SetInterpolation(int position); //native DInterpolation *SetInterpolation(int position);
//native void StopInterpolation(int position); //native void StopInterpolation(int position);