source: trunk/packages/vizservers/nanovis/BucketSort.cpp @ 3492

Last change on this file since 3492 was 3492, checked in by ldelgass, 6 years ago

Fix camera reset for nanovis. Includes refactoring of vector/matrix classes
in nanovis to consolidate into vrmath library. Also add preliminary canonical
view control to clients for testing.

  • Property svn:eol-style set to native
File size: 1000 bytes
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2#include "BucketSort.h"
3
4using namespace PCA;
5
6#include <vrmath/Vector3f.h>
7#include <vrmath/Matrix4x4d.h>
8
9void 
10BucketSort::init()
11{
12    _count = 0;
13    memset(_buffer, 0, sizeof(ClusterList*) * _size);
14}
15
16void 
17BucketSort::sort(ClusterAccel* clusterAccel, const Matrix4x4d& cameraMat, int level)
18{
19    if (clusterAccel == 0) {
20        return;
21    }
22    Cluster* cluster = clusterAccel->startPointerCluster[level - 1];
23    Cluster* c = &(cluster[0]);
24    Cluster* end = &(cluster[clusterAccel->numOfClusters[level - 1] - 1]);
25
26    Vector3f pos;
27    for (; c <= end; c = (Cluster*) ((char *)c + sizeof(Cluster))) {
28        pos = cameraMat.transform(c->centroid);
29        addBucket(c, pos.length()*_invMaxLength);
30    }
31}       
32
33void 
34BucketSort::addBucket(Cluster* cluster, float ratio)
35{
36    int index = (int) (ratio * _size);
37    ClusterList* c = &(_memChunck[_count++]);
38    c->data = cluster;
39    c->next =_buffer[index];
40    _buffer[index] = c;
41}
42
Note: See TracBrowser for help on using the repository browser.