فهرست منبع

Faster checkEdge function

This one uses a double hash, though the second hash is just a list that is linearly scanned as it is expected to be very small (there are not many edges per vertex).
Alexander Rose 10 سال پیش
والد
کامیت
28e91c464e
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 ) {
 	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;
 
 
 	}
 	}