浏览代码

fixed issue with dynamic parameters and not sync particles

ncannasse 8 年之前
父节点
当前提交
91d787f609
共有 3 个文件被更改,包括 7 次插入3 次删除
  1. 4 0
      h3d/parts/GpuParticles.hx
  2. 1 1
      h3d/pass/Default.hx
  3. 2 2
      h3d/shader/Manager.hx

+ 4 - 0
h3d/parts/GpuParticles.hx

@@ -644,6 +644,10 @@ class GpuParticles extends h3d.scene.MultiMaterial {
 	}
 
 	override function draw( ctx : h3d.scene.RenderContext ) {
+
+		if( primitive == null || primitive.buffer.isDisposed() )
+			return; // wait next sync()
+
 		var g = groups[ctx.drawPass.index];
 		g.syncParams();
 		g.pshader.time = currentTime;

+ 1 - 1
h3d/pass/Default.hx

@@ -100,7 +100,7 @@ class Default extends Base {
 			if( t == null )
 				p.texture = 0;
 			else {
-				var t : h3d.mat.Texture = manager.getParamValue(t, shaders);
+				var t : h3d.mat.Texture = manager.getParamValue(t, shaders, true);
 				p.texture = t == null ? 0 : t.id;
 			}
 			p = p.next;

+ 2 - 2
h3d/shader/Manager.hx

@@ -133,7 +133,7 @@ class Manager {
 		return 0;
 	}
 
-	public inline function getParamValue( p : hxsl.RuntimeShader.AllocParam, shaders : hxsl.ShaderList ) : Dynamic {
+	public inline function getParamValue( p : hxsl.RuntimeShader.AllocParam, shaders : hxsl.ShaderList, opt = false ) : Dynamic {
 		if( p.perObjectGlobal != null ) {
 			var v = globals.fastGet(p.perObjectGlobal.gid);
 			if( v == null ) throw "Missing global value " + p.perObjectGlobal.path;
@@ -143,7 +143,7 @@ class Manager {
 		var n = p.instance;
 		while( n-- > 0 ) si = si.next;
 		var v = si.s.getParamValue(p.index);
-		if( v == null ) throw "Missing param value " + si.s + "." + p.name;
+		if( v == null && !opt ) throw "Missing param value " + si.s + "." + p.name;
 		return v;
 	}