History

update NodeBounds.cpp to new tbb node iteration

Stephen Birarda committed 12 years ago

Commit d82e2fb1 parent aa7e9951 file · +17 −21Browse files

Showing the changes to interface/src/ui/NodeBounds.cpp (1 of 1 file). Show all

Unified · Split

interface/src/ui/NodeBounds.cpp+17−21
@@ -53,65 +53,61 @@ void NodeBounds::draw() { · 52 unmodified lines
5353 float selectedScale = 0;
5454
5555 NodeList* nodeList = NodeList::getInstance();
56− NodeHashSnapshot snapshotHash = nodeList->getNodeHash().snapshot_table();
57−
58− for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
59− SharedNodePointer node = it->second;
60−
56+ nodeList->eachNode([&](const SharedNodePointer& node){
6157 NodeType_t nodeType = node->getType();
62−
58+
6359 if (nodeType == NodeType::VoxelServer && _showVoxelNodes) {
6460 serverJurisdictions = &voxelServerJurisdictions;
6561 } else if (nodeType == NodeType::EntityServer && _showEntityNodes) {
6662 serverJurisdictions = &entityServerJurisdictions;
6763 } else {
68− continue;
64+ return;
6965 }
70−
66+
7167 QUuid nodeUUID = node->getUUID();
7268 serverJurisdictions->lockForRead();
7369 if (serverJurisdictions->find(nodeUUID) != serverJurisdictions->end()) {
7470 const JurisdictionMap& map = (*serverJurisdictions)[nodeUUID];
75−
71+
7672 unsigned char* rootCode = map.getRootOctalCode();
77−
73+
7874 if (rootCode) {
7975 VoxelPositionSize rootDetails;
8076 voxelDetailsForCode(rootCode, rootDetails);
8177 serverJurisdictions->unlock();
8278 glm::vec3 location(rootDetails.x, rootDetails.y, rootDetails.z);
8379 location *= (float)TREE_SCALE;
84−
80+
8581 AACube serverBounds(location, rootDetails.s * TREE_SCALE);
86−
82+
8783 glm::vec3 center = serverBounds.getVertex(BOTTOM_RIGHT_NEAR)
88− + ((serverBounds.getVertex(TOP_LEFT_FAR) - serverBounds.getVertex(BOTTOM_RIGHT_NEAR)) / 2.0f);
89−
84+ + ((serverBounds.getVertex(TOP_LEFT_FAR) - serverBounds.getVertex(BOTTOM_RIGHT_NEAR)) / 2.0f);
85+
9086 const float VOXEL_NODE_SCALE = 1.00f;
9187 const float ENTITY_NODE_SCALE = 0.99f;
92−
88+
9389 float scaleFactor = rootDetails.s * TREE_SCALE;
94−
90+
9591 // Scale by 0.92 - 1.00 depending on the scale of the node. This allows smaller nodes to scale in
9692 // a bit and not overlap larger nodes.
9793 scaleFactor *= 0.92 + (rootDetails.s * 0.08);
98−
94+
9995 // Scale different node types slightly differently because it's common for them to overlap.
10096 if (nodeType == NodeType::VoxelServer) {
10197 scaleFactor *= VOXEL_NODE_SCALE;
10298 } else if (nodeType == NodeType::EntityServer) {
10399 scaleFactor *= ENTITY_NODE_SCALE;
104100 }
105−
101+
106102 float red, green, blue;
107103 getColorForNodeType(nodeType, red, green, blue);
108104 drawNodeBorder(center, scaleFactor, red, green, blue);
109−
105+
110106 float distance;
111107 BoxFace face;
112108 bool inside = serverBounds.contains(mouseRayOrigin);
113109 bool colliding = serverBounds.findRayIntersection(mouseRayOrigin, mouseRayDirection, distance, face);
114−
110+
115111 // If the camera is inside a node it will be "selected" if you don't have your cursor over another node
116112 // that you aren't inside.
117113 if (colliding && (!selectedNode || (!inside && (distance < selectedDistance || selectedIsInside)))) {
@@ -127,7 +123,7 @@ void NodeBounds::draw() { · 9 unmodified lines
127123 } else {
128124 serverJurisdictions->unlock();
129125 }
130− }
126+ });
131127
132128 if (selectedNode) {
133129 glPushMatrix();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t