Revert back to merge sort for geometry sorting.

Some issues have been reported, and are difficult to track as they happen randomly.
experimental
Nehon 10 years ago
parent d17bdb6485
commit 04f8956992
  1. 20
      jme3-core/src/main/java/com/jme3/renderer/queue/GeometryList.java

@ -33,7 +33,7 @@ package com.jme3.renderer.queue;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.util.ListSort; import com.jme3.util.SortUtil;
/** /**
* This class is a special purpose list of {@link Geometry} objects for render * This class is a special purpose list of {@link Geometry} objects for render
@ -47,8 +47,8 @@ public class GeometryList {
private static final int DEFAULT_SIZE = 32; private static final int DEFAULT_SIZE = 32;
private Geometry[] geometries; private Geometry[] geometries;
private ListSort listSort; private Geometry[] geometries2;
private int size; private int size;
private GeometryComparator comparator; private GeometryComparator comparator;
@ -60,9 +60,9 @@ public class GeometryList {
*/ */
public GeometryList(GeometryComparator comparator) { public GeometryList(GeometryComparator comparator) {
size = 0; size = 0;
geometries = new Geometry[DEFAULT_SIZE]; geometries = new Geometry[DEFAULT_SIZE];
geometries2 = new Geometry[DEFAULT_SIZE];
this.comparator = comparator; this.comparator = comparator;
listSort = new ListSort<Geometry>();
} }
public void setComparator(GeometryComparator comparator) { public void setComparator(GeometryComparator comparator) {
@ -118,6 +118,8 @@ public class GeometryList {
Geometry[] temp = new Geometry[size * 2]; Geometry[] temp = new Geometry[size * 2];
System.arraycopy(geometries, 0, temp, 0, size); System.arraycopy(geometries, 0, temp, 0, size);
geometries = temp; // original list replaced by double-size list geometries = temp; // original list replaced by double-size list
geometries2 = new Geometry[size * 2];
} }
geometries[size++] = g; geometries[size++] = g;
} }
@ -139,10 +141,10 @@ public class GeometryList {
public void sort() { public void sort() {
if (size > 1) { if (size > 1) {
// sort the spatial list using the comparator // sort the spatial list using the comparator
if(listSort.getLength() != size){ System.arraycopy(geometries, 0, geometries2, 0, size);
listSort.allocateStack(size); SortUtil.msort(geometries2, geometries, 0, size-1, comparator);
}
listSort.sort(geometries,comparator);
} }
} }
} }
Loading…
Cancel
Save