Pārlūkot izejas kodu

allow to apply shader to all children when added to group parent

Nicolas Cannasse 4 gadi atpakaļ
vecāks
revīzija
9b59f3e8b3
1 mainītis faili ar 10 papildinājumiem un 1 dzēšanām
  1. 10 1
      hrt/prefab/Shader.hx

+ 10 - 1
hrt/prefab/Shader.hx

@@ -90,7 +90,16 @@ class Shader extends Prefab {
 				for( m in material.getMaterials(ctx) )
 					m.mainPass.addShader(shader);
 			} else {
-				for( obj in shared.getObjects(parent, h3d.scene.Object) )
+				var objs;
+				if( parent.type == "object" ) {
+					// apply to all immediate children
+					objs = [];
+					for( c in parent.children )
+						for( o in shared.getObjects(c, h3d.scene.Object) )
+							objs.push(o);
+				} else
+					objs = shared.getObjects(parent, h3d.scene.Object);
+				for( obj in objs )
 					for( m in obj.getMaterials(false) )
 						m.mainPass.addShader(shader);
 			}