Skip to content

Commit 8b4b734

Browse files
committed
Fix trail fade not being bloomed
I have no idea why putting cap after draw makes the alpha work correctly but whatever makes more sense to draw the end after the rest anyway.
1 parent 3e9d4ef commit 8b4b734

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

src/progressed/content/effects/TrailFadeFx.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package progressed.content.effects;
22

3+
import arc.util.*;
34
import mindustry.entities.*;
45
import mindustry.graphics.*;
56
import progressed.entities.bullet.explosive.RocketBulletType.*;
7+
import progressed.graphics.*;
68
import progressed.graphics.trails.*;
79

810
import static arc.graphics.g2d.Draw.*;
@@ -19,8 +21,8 @@ public class TrailFadeFx{
1921
if(!state.isPaused()){
2022
trail.shorten();
2123
}
22-
trail.drawCap(e.color, e.rotation);
2324
trail.draw(e.color, e.rotation);
25+
trail.drawCap(e.color, e.rotation);
2426
}),
2527

2628
rocketTrailFade = new Effect(440f, e -> {
@@ -32,8 +34,8 @@ public class TrailFadeFx{
3234
if(!state.isPaused()){
3335
data.trail.shorten();
3436
}
35-
data.trail.drawCap(e.color, e.rotation);
3637
data.trail.draw(e.color, e.rotation);
38+
data.trail.drawCap(e.color, e.rotation);
3739
}),
3840

3941
driftTrailFade = new Effect(400f, e -> {
@@ -45,8 +47,8 @@ public class TrailFadeFx{
4547
trail.shorten();
4648
trail.drift();
4749
}
48-
trail.drawCap(e.color, e.rotation);
4950
trail.draw(e.color, e.rotation);
51+
trail.drawCap(e.color, e.rotation);
5052
}),
5153

5254
heightTrailFade = new Effect(400f, e -> {
@@ -57,7 +59,12 @@ public class TrailFadeFx{
5759
if(!state.isPaused()){
5860
trail.shorten();
5961
}
60-
trail.drawCap(e.color, e.rotation);
61-
trail.draw(e.color, e.rotation);
62+
int col = e.color.rgba8888();
63+
float size = e.rotation;
64+
Draw3D.highBloom(() -> {
65+
Tmp.c1.rgba8888(col);
66+
trail.draw(Tmp.c1, size);
67+
trail.drawCap(Tmp.c1, size);
68+
});
6269
}).layer(Layer.flyingUnit + 1.9f);
6370
}

src/progressed/entities/bullet/pseudo3d/ArcBasicBulletType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void draw(Bullet b){
7373
});
7474
}
7575

76-
Draw.z(layer);
76+
Draw.z(layer + data.z / 3000f); //Higher elevation should draw above
7777
drawTrail(b);
7878
Draw3D.highBloom(bloomSprite, () -> {
7979
Draw.scl(1f + hMul(data.z));

src/progressed/entities/bullet/pseudo3d/ArcBulletType.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,10 @@ public void drawTrail(Bullet b){
297297
if(trailLength > 0 && b.trail != null){
298298
float z = Draw.z();
299299
Draw.z(z - 0.0001f);
300-
Draw3D.highBloom(bloomTrail, () -> b.trail.draw(trailColor, trailWidth));
300+
Draw3D.highBloom(bloomTrail, () -> {
301+
b.trail.draw(trailColor, trailWidth);
302+
b.trail.drawCap(trailColor, trailWidth);
303+
});
301304
Draw.z(z);
302305
}
303306
}
@@ -507,9 +510,6 @@ public Bullet create3DInherit(Bullet b, float angle, float inaccCone, float grav
507510
bullet.data = data;
508511
bullet.drag = drag;
509512
bullet.hitSize = hitSize;
510-
if(trailLength > 0){
511-
bullet.trail = b.trail.copy();
512-
}
513513
bullet.add();
514514
return bullet;
515515
}

src/progressed/graphics/trails/HeightTrail.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@ public int size(){
4646

4747
public void drawCap(Color color, float width, boolean fade){
4848
if(points.size > 4){
49-
Draw.color(color);
50-
if(fade) Draw.alpha(Draw3D.scaleAlpha(lastH));
5149
int i = points.size - 4;
5250
float x1 = x(i - 4), y1 = y(i - 4),
5351
x2 = x(-1), y2 = y(-1),
5452
w1 = w(-1), w = w1 * width / (points.size / 4) * i / 4f * 2f;
5553
if(w1 <= 0.001f) return;
54+
if(fade){
55+
Draw.color(Tmp.c1.set(color).mulA(Draw3D.scaleAlpha(lastH)));
56+
}else{
57+
Draw.color(color);
58+
}
5659
Draw.rect("hcircle", x2, y2, w, w, Angles.angle(x1, y1, x2, y2));
57-
Draw.reset();
60+
Draw.color();
5861
}
5962
}
6063

@@ -78,11 +81,10 @@ public void draw(Color color, float width, boolean fade){
7881
y2 = y(i + 4);
7982
w2 = w(i + 4);
8083
z2 = items[i + 4 + 3];
81-
8284
}else{
83-
x2 = Draw3D.x(lastX, lastH);
84-
y2 = Draw3D.y(lastY, lastH);
85-
w2 = lastW * hScale(lastH);
85+
x2 = x(-1);
86+
y2 = y(-1);
87+
w2 = w(-1);
8688
z2 = lastH;
8789
}
8890

@@ -114,7 +116,7 @@ public void draw(Color color, float width, boolean fade){
114116
lastAngle = a2;
115117
}
116118

117-
Draw.reset();
119+
Draw.color();
118120
}
119121

120122
@Override

0 commit comments

Comments
 (0)