Last change
on this file since 4587 was
3617,
checked in by ldelgass, 12 years ago
|
Compile fixes for USE_POINTSET_RENDERER (not tested).
|
-
Property svn:eol-style set to
native
|
File size:
1.1 KB
|
Line | |
---|
1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | */ |
---|
6 | |
---|
7 | #include <vrmath/Vector3f.h> |
---|
8 | #include <vrmath/Matrix4x4d.h> |
---|
9 | |
---|
10 | #include "BucketSort.h" |
---|
11 | |
---|
12 | using namespace PCA; |
---|
13 | using namespace vrmath; |
---|
14 | |
---|
15 | void |
---|
16 | BucketSort::init() |
---|
17 | { |
---|
18 | _count = 0; |
---|
19 | memset(_buffer, 0, sizeof(ClusterList*) * _size); |
---|
20 | } |
---|
21 | |
---|
22 | void |
---|
23 | BucketSort::sort(ClusterAccel* clusterAccel, const Matrix4x4d& cameraMat, int level) |
---|
24 | { |
---|
25 | if (clusterAccel == 0) { |
---|
26 | return; |
---|
27 | } |
---|
28 | Cluster* cluster = clusterAccel->startPointerCluster[level - 1]; |
---|
29 | Cluster* c = &(cluster[0]); |
---|
30 | Cluster* end = &(cluster[clusterAccel->numOfClusters[level - 1] - 1]); |
---|
31 | |
---|
32 | for (; c <= end; c = (Cluster*) ((char *)c + sizeof(Cluster))) { |
---|
33 | Vector4f pt = cameraMat.transform(Vector4f(c->centroid, 1)); |
---|
34 | Vector3f pos(pt.x, pt.y, pt.z); |
---|
35 | addBucket(c, pos.length()*_invMaxLength); |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | void |
---|
40 | BucketSort::addBucket(Cluster* cluster, float ratio) |
---|
41 | { |
---|
42 | int index = (int) (ratio * _size); |
---|
43 | ClusterList* c = &(_memChunck[_count++]); |
---|
44 | c->data = cluster; |
---|
45 | c->next =_buffer[index]; |
---|
46 | _buffer[index] = c; |
---|
47 | } |
---|
48 | |
---|
Note: See
TracBrowser
for help on using the repository browser.