浏览代码

copy mainPass properties when cloning the material

ncannasse 11 年之前
父节点
当前提交
35847b3a20
共有 2 个文件被更改,包括 20 次插入1 次删除
  1. 2 1
      h3d/mat/Material.hx
  2. 18 0
      h3d/mat/Pass.hx

+ 2 - 1
h3d/mat/Material.hx

@@ -73,7 +73,8 @@ class Material {
 		#if debug
 		if( Type.getClass(m) != Type.getClass(this) ) throw this + " is missing clone()";
 		#end
-		// DO NOT clone passes (it's up to the superclass to recreate the shaders)
+		m.mainPass.loadProps(mainPass);
+		// DO NOT clone passes (it's up to the superclass to recreate the passes + shaders)
 		m.castShadows = castShadows;
 		m.receiveShadows = receiveShadows;
 		return m;

+ 18 - 0
h3d/mat/Pass.hx

@@ -42,6 +42,24 @@ class Pass {
 		colorMask = 15;
 	}
 
+	public function loadProps( p : Pass ) {
+		name = p.name;
+		passId = p.passId;
+		bits = p.bits;
+		enableLights = p.enableLights;
+		dynamicParameters = p.dynamicParameters;
+		culling = p.culling;
+		depthWrite = p.depthWrite;
+		depthTest = p.depthTest;
+		blendSrc = p.blendSrc;
+		blendDst = p.blendDst;
+		blendOp = p.blendOp;
+		blendAlphaSrc = p.blendAlphaSrc;
+		blendAlphaDst = p.blendAlphaDst;
+		blendAlphaOp = p.blendAlphaOp;
+		colorMask = p.colorMask;
+	}
+
 	public function setPassName( name : String ) {
 		this.name = name;
 		passId = hxsl.Globals.allocID(name);