Browse Source

Fix the renderList sort function to be truly stable

Multiple objects can have the same id. Using that id to compare the render
objects makes the sort function unstable. Use the webgl object's index in the
render list instead. That number is guaranteed to be unique.

This fixes #2966.
Tomas Carnecky 12 năm trước cách đây
mục cha
commit
ec0ce9558b
2 tập tin đã thay đổi với 2 bổ sung4 xóa
  1. 1 2
      src/renderers/WebGLRenderer.js
  2. 1 2
      src/renderers/WebGLRenderer2.js

+ 1 - 2
src/renderers/WebGLRenderer.js

@@ -4159,6 +4159,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			webglObject = renderList[ i ];
 			object = webglObject.object;
 
+			webglObject.id = i;
 			webglObject.render = false;
 
 			if ( object.visible ) {
@@ -4186,8 +4187,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 						}
 
-						webglObject.id = object.id;
-
 					}
 
 				}

+ 1 - 2
src/renderers/WebGLRenderer2.js

@@ -1284,6 +1284,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			webglObject = renderList[ i ];
 			object = webglObject.object;
 
+			webglObject.id = i;
 			webglObject.render = false;
 
 			if ( object.visible ) {
@@ -1311,8 +1312,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 						}
 
-						webglObject.id = object.id;
-
 					}
 
 				}