Skip to content

Commit f6d1e44

Browse files
committed
ShaderTarget: add guard to prevent multiple applies of the same shader target
1 parent 40f6f86 commit f6d1e44

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

hrt/prefab/fx/ShaderTarget.hx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class ShaderTargetObj extends h3d.scene.Object {
44
public var tag : String;
55
public var priority : Int = 1;
66
public var shadersRoot : ShaderTarget;
7+
var guard = 0;
78

89
public function apply(fx : hrt.prefab.fx.FX) {
910
function reparentChildren(obj : hrt.prefab.Object3D) {
@@ -53,10 +54,16 @@ class ShaderTargetObj extends h3d.scene.Object {
5354
public function removeShaders() {
5455
for (s in shadersRoot.findAll(Shader))
5556
s.dispose();
57+
guard--;
58+
}
59+
60+
public function isApplied() {
61+
return guard > 0;
5662
}
5763

5864
function applyShader(s: Shader) {
5965
s.apply3d((o) -> return !Std.isOfType(o, hrt.prefab.fx.FX.FXAnimation) );
66+
guard++;
6067
}
6168

6269
override function onRemove() {
@@ -104,7 +111,7 @@ class ShaderTarget extends Object3D {
104111
}
105112

106113
for (s in sts) {
107-
if (s.tag != null && actives.get(s.tag) != s)
114+
if ((s.tag != null && actives.get(s.tag) != s) || s.isApplied())
108115
continue;
109116
s.applyShaders();
110117
}

0 commit comments

Comments
 (0)