浏览代码

[OPTI] RenderContext passes as array.

clandrin 3 年之前
父节点
当前提交
be8de8d548
共有 2 个文件被更改,包括 9 次插入5 次删除
  1. 5 3
      h3d/scene/RenderContext.hx
  2. 4 2
      h3d/scene/Scene.hx

+ 5 - 3
h3d/scene/RenderContext.hx

@@ -31,7 +31,7 @@ class RenderContext extends h3d.impl.RenderContext {
 	var cachedShaderList : Array<hxsl.ShaderList>;
 	var cachedPassObjects : Array<Renderer.PassObjects>;
 	var cachedPos : Int;
-	var passes : Map<Int, h3d.pass.PassObject>;
+	var passes : Array<h3d.pass.PassObject>;
 	var lights : Light;
 	var currentManager : h3d.pass.ShaderManager;
 
@@ -98,8 +98,10 @@ class RenderContext extends h3d.impl.RenderContext {
 			allocPool = o.nextAlloc;
 		o.pass = pass;
 		o.obj = obj;
-		o.next = passes.get(pass.passId);
-		passes.set(pass.passId, o);
+		if ( passes.length <= pass.passId )
+			passes.resize(pass.passId);
+		o.next = passes[pass.passId];
+		passes[pass.passId] = o;
 		return o;
 	}
 

+ 4 - 2
h3d/scene/Scene.hx

@@ -408,8 +408,10 @@ class Scene extends Object implements h3d.IDrawable implements hxd.SceneEvents.I
 
 		var passes = [];
 		var passIndex = -1;
-		for ( passId in ctx.passes.keys() ) {
-			var curPass = ctx.passes.get(passId);
+		for ( passId in 0...ctx.passes.length ) {
+			var curPass = ctx.passes[passId];
+			if ( curPass == null )
+				continue;
 			var pobjs = ctx.cachedPassObjects[++passIndex];
 			if( pobjs == null ) {
 				pobjs = new Renderer.PassObjects();