Fix `LegacySmoke` alpha calculations

This commit is contained in:
Alden Wu 2022-10-03 16:02:33 -07:00
parent 0bac5ef465
commit 929eb8559e
1 changed files with 12 additions and 8 deletions

View File

@ -67,6 +67,8 @@ protected class LegacySmokeDrawNode : SmokeDrawNode
protected new LegacySmoke Source => (LegacySmoke)base.Source;
private double initialFadeOutDurationTrunc;
private double firstVisiblePointTime;
private double initialFadeOutTime;
private double reFadeInTime;
private double finalFadeOutTime;
@ -83,20 +85,22 @@ public override void ApplyState()
{
base.ApplyState();
initialFadeOutDurationTrunc = Math.Min(initial_fade_out_duration, SmokeEndTime - SmokeStartTime);
rotationSeed = Source.RotationSeed;
rotationRNG = new Random(rotationSeed);
initialFadeOutTime = Math.Min(CurrentTime, SmokeEndTime);
reFadeInTime = re_fade_in_speed * (CurrentTime - SmokeEndTime) + SmokeEndTime - initialFadeOutDurationTrunc;
finalFadeOutTime = final_fade_out_speed * (CurrentTime - SmokeEndTime) + SmokeEndTime - initialFadeOutDurationTrunc * (1 + 1 / re_fade_in_speed);
initialFadeOutDurationTrunc = Math.Min(initial_fade_out_duration, SmokeEndTime - SmokeStartTime);
firstVisiblePointTime = SmokeEndTime - initialFadeOutDurationTrunc;
initialFadeOutTime = CurrentTime;
reFadeInTime = CurrentTime - initialFadeOutDurationTrunc - firstVisiblePointTime * (1 - 1 / re_fade_in_speed);
finalFadeOutTime = CurrentTime - initialFadeOutDurationTrunc - firstVisiblePointTime * (1 - 1 / final_fade_out_speed);
}
protected override Color4 PointColour(SmokePoint point)
{
var color = Color4.White;
double timeDoingInitialFadeOut = initialFadeOutTime - point.Time;
double timeDoingInitialFadeOut = Math.Min(initialFadeOutTime, SmokeEndTime) - point.Time;
if (timeDoingInitialFadeOut > 0)
{
@ -106,8 +110,8 @@ protected override Color4 PointColour(SmokePoint point)
if (color.A > 0)
{
double timeDoingReFadeIn = reFadeInTime - point.Time;
double timeDoingFinalFadeOut = finalFadeOutTime - point.Time;
double timeDoingReFadeIn = reFadeInTime - point.Time / re_fade_in_speed;
double timeDoingFinalFadeOut = finalFadeOutTime - point.Time / final_fade_out_speed;
if (timeDoingFinalFadeOut > 0)
{