# HG changeset patch # User Tess Snider # Date 2021-07-24 11:25:18 # Node ID 11d11a57837d0abe03d3c253c702d294bbed9ff5 # Parent a1bd6e3474d609f9984bd74e51bf2bdaa59eb870 Reorganizing the white-reaction clip extrapolation to see if it works better. diff --git a/Models/ReactionTest.cs b/Models/ReactionTest.cs --- a/Models/ReactionTest.cs +++ b/Models/ReactionTest.cs @@ -210,34 +210,40 @@ namespace DesertPaintCodex.Models } else { - State = TestState.ClippedResult; - BadReaction = CalculateReaction(); - + Reaction? reaction = CalculateReaction(); + bool extrapolated = false; + // SPECIAL CASE: // Check to see if we've got a white-shift reaction that's partially clipped, where we can // still extrapolate the reaction, based on the available information. - if (!testing3Way && (BadReaction != null)) + if (!testing3Way && (reaction != null)) { PaintColor baseColor = _recipe.BaseColor; - if ((BadReaction.Red < baseColor.Red) && - (BadReaction.Green < baseColor.Green) && - (BadReaction.Blue < baseColor.Blue)) + if ((reaction.Red < baseColor.Red) && + (reaction.Green < baseColor.Green) && + (reaction.Blue < baseColor.Blue)) { // White-shift down clip. - bool extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Red, 0, BadReaction.Red); - if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 0, BadReaction.Green); - if (!extrapolated) ExtrapolateWhiteFromOneChannel(_observedColor.Blue, 0, BadReaction.Blue); + extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Red, 0, reaction.Red); + if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 0, reaction.Green); + if (!extrapolated) ExtrapolateWhiteFromOneChannel(_observedColor.Blue, 0, reaction.Blue); } - else if ((BadReaction.Red > baseColor.Red) && - (BadReaction.Green > baseColor.Green) && - (BadReaction.Blue > baseColor.Blue)) + else if ((reaction.Red > baseColor.Red) && + (reaction.Green > baseColor.Green) && + (reaction.Blue > baseColor.Blue)) { // White-shift up clip. - bool extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Red, 255, BadReaction.Red); - if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 255, BadReaction.Green); - if (!extrapolated) ExtrapolateWhiteFromOneChannel(_observedColor.Blue, 255, BadReaction.Blue); + extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Red, 255, reaction.Red); + if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 255, reaction.Green); + if (!extrapolated) ExtrapolateWhiteFromOneChannel(_observedColor.Blue, 255, reaction.Blue); } } + + if (!extrapolated) + { + State = TestState.ClippedResult; + BadReaction = CalculateReaction(); + } } PlayerProfile? profile = ProfileManager.CurrentProfile; @@ -255,10 +261,9 @@ namespace DesertPaintCodex.Models { if (result == clipBound) return false; - Clipped = ClipType.None; + State = TestState.GoodResult; Reaction = new Reaction(reaction, reaction, reaction); - BadReaction = null; - State = TestState.GoodResult; + return true; }