Exemple #1
0
void QuickSort::sortZ(RGRID *array, unsigned *idx, int first,int last)
{
	if(first<last){
	int low,high;float list_separator;
	RGRID temp;
	unsigned tmpidx;

	low = first;
	high = last;
	list_separator = array[(first+last)/2].pos.z;
	do
	{
		while(array[low].pos.z<list_separator) low++;
		while(array[high].pos.z>list_separator) high--;

		if(low<=high)
		{
			temp = array[low];
			tmpidx = idx[low];
			idx[low] = idx[high];
			array[low++] = array[high];
			idx[high] = tmpidx;
			array[high--]=temp;
		}
	}while(low<=high);
	if(first<high)
		sortZ(array, idx, first,high);
	if(low<last)
		sortZ(array, idx, low,last);}
}
Exemple #2
0
void QuickSort::sortZ(PosAndId *array,int first,int last)
{
	if(first<last){
	int low,high;float list_separator;
	PosAndId temp;

	low = first;
	high = last;
	list_separator = array[(first+last)/2].pos.z;
	do
	{
		while(array[low].pos.z<list_separator) low++;
		while(array[high].pos.z>list_separator) high--;

		if(low<=high)
		{
			temp = array[low];
			array[low++] = array[high];
			array[high--]=temp;
		}
	}while(low<=high);
	if(first<high)
		sortZ(array,first,high);
	if(low<last)
		sortZ(array,low,last);}
}
//--------------------------------------------------------------
void ofApp::draw(){
    for(int i=0; i<numTrees; i++) {
        Tree* tree = trees[i];
        move(tree);
    }
    vz *= friction;
    sortZ();
}