From 3923a92f11eed7af6ab398ba095823f0216dc807 Mon Sep 17 00:00:00 2001 From: Kevin Caccamo Date: Sun, 23 Dec 2018 01:36:25 -0500 Subject: [PATCH] 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 --- specs/udmf_zdoom.txt | 9 ++++++--- src/namedef.h | 3 +++ src/p_udmf.cpp | 14 +++++++++++--- src/r_defs.h | 30 +++++++++++++++++++++++------- src/scripting/vmthunks.cpp | 24 ++++++++++++++++++++---- wadsrc/static/zscript/mapdata.zs | 3 ++- 6 files changed, 65 insertions(+), 18 deletions(-) diff --git a/specs/udmf_zdoom.txt b/specs/udmf_zdoom.txt index e455746d6..d817f4e1b 100644 --- a/specs/udmf_zdoom.txt +++ b/specs/udmf_zdoom.txt @@ -201,9 +201,12 @@ Note: All fields default to false unless mentioned otherwise. uppercolor_bottom = ; // Material color of the top of the lower tier. lowercolor_bottom = ; // Material color of the bottom of the lower tier. (Hardware rendering only.) - coloradd_top = ; // Additive material color to apply to top section of sidedef. Takes precedence over sector setting. Default is black (0x000000) - coloradd_mid = ; // Additive material color to apply to middle section of sidedef. Takes precedence over sector setting. Default is black (0x000000) - coloradd_bottom = ; // Additive material color to apply to bottom section of sidedef. Takes precedence over sector setting. Default is black (0x000000) + useowncoloradd_top = ; // Whether or not to use the given additive color for the top section of the sidedef. + coloradd_top = ; // Additive material color to apply to top section of sidedef. Default is black (0x000000) + useowncoloradd_mid = ; // Whether or not to use the given additive color for the middle section of the sidedef. + coloradd_mid = ; // Additive material color to apply to middle section of sidedef. Default is black (0x000000) + useowncoloradd_bottom = ; // Whether or not to use the given additive color for the bottom section of the sidedef. + coloradd_bottom = ; // Additive material color to apply to bottom section of sidedef. Default is black (0x000000) } sector diff --git a/src/namedef.h b/src/namedef.h index 0042d2fea..037801537 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -663,8 +663,11 @@ xx(clampgradient_bottom) xx(useowncolors_bottom) xx(uppercolor_bottom) xx(lowercolor_bottom) +xx(useowncoloradd_top) xx(coloradd_top) +xx(useowncoloradd_mid) xx(coloradd_mid) +xx(useowncoloradd_bottom) xx(coloradd_bottom) xx(Renderstyle) diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 54748b11a..0d17b451b 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1332,7 +1332,7 @@ public: break; 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; case NAME_uppercolor_top: @@ -1356,7 +1356,7 @@ public: break; 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; case NAME_uppercolor_mid: @@ -1380,7 +1380,7 @@ public: break; 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; case NAME_uppercolor_bottom: @@ -1403,6 +1403,14 @@ public: sd->SetAdditiveColor(side_t::bottom, CheckInt(key)); 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: break; diff --git a/src/r_defs.h b/src/r_defs.h index 8af410b3f..31b7c1821 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1160,7 +1160,8 @@ struct side_t NoGradient = 1, FlipGradient = 2, ClampGradient = 4, - UseOwnColors = 8, + UseOwnSpecialColors = 8, + UseOwnAdditiveColor = 16, }; double xOffset; double yOffset; @@ -1311,22 +1312,37 @@ struct side_t auto &part = textures[which]; if (part.flags & part::NoGradient) slot = 0; 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; } PalEntry GetAdditiveColor(int which, sector_t *frontsector) const { - auto &color = textures[which].AdditiveColor; - if (color.a == 0) { + if (textures[which].flags & part::UseOwnAdditiveColor) { + return textures[which].AdditiveColor; + } + else + { return frontsector->AdditiveColors[sector_t::walltop]; // Used as additive color for all walls } - return color; } DInterpolation *SetInterpolation(int position); diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 6180d2b16..48bc54770 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -1649,11 +1649,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField) 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) { - self->SetAdditiveColor(tier, color, use); + self->SetAdditiveColor(tier, color); } } @@ -1662,8 +1662,24 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField) PARAM_SELF_STRUCT_PROLOGUE(side_t); PARAM_INT(tier); PARAM_COLOR(color); - PARAM_BOOL(use); - SetSideAdditiveColor(self, tier, color, use); + SetSideAdditiveColor(self, tier, color); + 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; } diff --git a/wadsrc/static/zscript/mapdata.zs b/wadsrc/static/zscript/mapdata.zs index 155888581..53a6b4bad 100644 --- a/wadsrc/static/zscript/mapdata.zs +++ b/wadsrc/static/zscript/mapdata.zs @@ -87,7 +87,8 @@ struct Side native play native void MultiplyTextureYScale(int which, double delta); native void SetSpecialColor(int tier, int position, Color scolor); 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 void StopInterpolation(int position);