Browse Source

Emitter: remove template instances in context, which cause problems with selection

trethaller 4 years ago
parent
commit
725107f4e9
1 changed files with 6 additions and 1 deletions
  1. 6 1
      hrt/prefab/fx/Emitter.hx

+ 6 - 1
hrt/prefab/fx/Emitter.hx

@@ -767,8 +767,10 @@ class EmitterObject extends h3d.scene.Object {
 			// Should we do this manually here or make a recursive makeInstance on the template?
 			var materials = particleTemplate.getAll(hrt.prefab.Material);
 			for(mat in materials) {
-				if(mat.enabled)
+				if(mat.enabled) {
 					mat.makeInstance(template);
+					template.shared.contexts.remove(mat);
+				}
 			}
 
 			// Setup shaders
@@ -777,6 +779,7 @@ class EmitterObject extends h3d.scene.Object {
 			for( shader in shaders ) {
 				if( !shader.enabled ) continue;
 				var shCtx = shader.makeInstance(template);
+				template.shared.contexts.remove(shader);
 				if( shCtx == null ) continue;
 				hrt.prefab.fx.BaseFX.getShaderAnims(template, shader, shaderAnims);
 			}
@@ -803,6 +806,8 @@ class EmitterObject extends h3d.scene.Object {
 				batch = new h3d.scene.MeshBatch(meshPrim, mesh.material, this);
 				batch.name = "batch";
 			}
+
+			template.shared.contexts.remove(particleTemplate);
 			template.local3d.remove();
 		}
 	}