Let the comparator be reset without having to create
a whole new list. And some whitespace changes. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10777 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
1e3e14ba75
commit
c69756acbc
@ -55,7 +55,7 @@ public class GeometryList {
|
|||||||
/**
|
/**
|
||||||
* Initializes the GeometryList to use the given {@link GeometryComparator}
|
* Initializes the GeometryList to use the given {@link GeometryComparator}
|
||||||
* to use for comparing geometries.
|
* to use for comparing geometries.
|
||||||
*
|
*
|
||||||
* @param comparator The comparator to use.
|
* @param comparator The comparator to use.
|
||||||
*/
|
*/
|
||||||
public GeometryList(GeometryComparator comparator) {
|
public GeometryList(GeometryComparator comparator) {
|
||||||
@ -65,18 +65,22 @@ public class GeometryList {
|
|||||||
this.comparator = comparator;
|
this.comparator = comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setComparator(GeometryComparator comparator) {
|
||||||
|
this.comparator = comparator;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the GeometryComparator that this Geometry list uses
|
* Returns the GeometryComparator that this Geometry list uses
|
||||||
* for sorting.
|
* for sorting.
|
||||||
*/
|
*/
|
||||||
public GeometryComparator getComparator() {
|
public GeometryComparator getComparator() {
|
||||||
return comparator;
|
return comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the camera that will be set on the geometry comparators
|
* Set the camera that will be set on the geometry comparators
|
||||||
* via {@link GeometryComparator#setCamera(com.jme3.renderer.Camera)}.
|
* via {@link GeometryComparator#setCamera(com.jme3.renderer.Camera)}.
|
||||||
*
|
*
|
||||||
* @param cam Camera to use for sorting.
|
* @param cam Camera to use for sorting.
|
||||||
*/
|
*/
|
||||||
public void setCamera(Camera cam){
|
public void setCamera(Camera cam){
|
||||||
@ -85,7 +89,7 @@ public class GeometryList {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of elements in this GeometryList.
|
* Returns the number of elements in this GeometryList.
|
||||||
*
|
*
|
||||||
* @return Number of elements in the list
|
* @return Number of elements in the list
|
||||||
*/
|
*/
|
||||||
public int size(){
|
public int size(){
|
||||||
@ -94,7 +98,7 @@ public class GeometryList {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the element at the given index.
|
* Returns the element at the given index.
|
||||||
*
|
*
|
||||||
* @param index The index to lookup
|
* @param index The index to lookup
|
||||||
* @return Geometry at the index
|
* @return Geometry at the index
|
||||||
*/
|
*/
|
||||||
@ -103,7 +107,7 @@ public class GeometryList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a geometry to the list.
|
* Adds a geometry to the list.
|
||||||
* List size is doubled if there is no room.
|
* List size is doubled if there is no room.
|
||||||
*
|
*
|
||||||
* @param g
|
* @param g
|
||||||
@ -114,7 +118,7 @@ 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];
|
geometries2 = new Geometry[size * 2];
|
||||||
}
|
}
|
||||||
geometries[size++] = g;
|
geometries[size++] = g;
|
||||||
@ -137,13 +141,13 @@ 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
|
||||||
|
|
||||||
// SortUtil.qsort(geometries, 0, size, comparator);
|
// SortUtil.qsort(geometries, 0, size, comparator);
|
||||||
// Arrays.sort(geometries, 0, size, comparator);
|
// Arrays.sort(geometries, 0, size, comparator);
|
||||||
|
|
||||||
System.arraycopy(geometries, 0, geometries2, 0, size);
|
System.arraycopy(geometries, 0, geometries2, 0, size);
|
||||||
SortUtil.msort(geometries2, geometries, 0, size-1, comparator);
|
SortUtil.msort(geometries2, geometries, 0, size-1, comparator);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user