浏览代码

Merge pull request #7093 from arose/patch-4

Faster checkEdge function
Mr.doob 10 年之前
父节点
当前提交
9a1650d0bd
共有 1 个文件被更改,包括 20 次插入4 次删除
  1. 20 4
      src/renderers/webgl/WebGLObjects.js

+ 20 - 4
src/renderers/webgl/WebGLObjects.js

@@ -191,13 +191,29 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
 
 	function checkEdge( edges, a, b ) {
 
-		var hash = a < b ? a + '_' + b : b + '_' + a;
+		if ( a > b ){
 
-		if ( edges.hasOwnProperty( hash ) ) return false;
+			var tmp = a;
+			a = b;
+			b = tmp;
 
-		edges[ hash ] = 1;
+		}
+
+		var list = edges[ a ];
+
+		if( list === undefined ){
+
+			edges[ a ] = [ b ];
+			return true;
+
+		}else if( list.indexOf( b ) === -1 ){
+
+			list.push( b );
+			return true;
+
+		}
 
-		return true;
+		return false;
 
 	}