Showing the changes to interface/src/ui/NodeBounds.cpp (1 of 1 file). Show all
Unified · Split
| @@ -53,65 +53,61 @@ void NodeBounds::draw() { · 52 unmodified lines | ||
| 53 | 53 | float selectedScale = 0; |
| 54 | 54 | |
| 55 | 55 | 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){ | |
| 61 | 57 | NodeType_t nodeType = node->getType(); |
| 62 | − | |
| 58 | + | |
| 63 | 59 | if (nodeType == NodeType::VoxelServer && _showVoxelNodes) { |
| 64 | 60 | serverJurisdictions = &voxelServerJurisdictions; |
| 65 | 61 | } else if (nodeType == NodeType::EntityServer && _showEntityNodes) { |
| 66 | 62 | serverJurisdictions = &entityServerJurisdictions; |
| 67 | 63 | } else { |
| 68 | − continue; | |
| 64 | + return; | |
| 69 | 65 | } |
| 70 | − | |
| 66 | + | |
| 71 | 67 | QUuid nodeUUID = node->getUUID(); |
| 72 | 68 | serverJurisdictions->lockForRead(); |
| 73 | 69 | if (serverJurisdictions->find(nodeUUID) != serverJurisdictions->end()) { |
| 74 | 70 | const JurisdictionMap& map = (*serverJurisdictions)[nodeUUID]; |
| 75 | − | |
| 71 | + | |
| 76 | 72 | unsigned char* rootCode = map.getRootOctalCode(); |
| 77 | − | |
| 73 | + | |
| 78 | 74 | if (rootCode) { |
| 79 | 75 | VoxelPositionSize rootDetails; |
| 80 | 76 | voxelDetailsForCode(rootCode, rootDetails); |
| 81 | 77 | serverJurisdictions->unlock(); |
| 82 | 78 | glm::vec3 location(rootDetails.x, rootDetails.y, rootDetails.z); |
| 83 | 79 | location *= (float)TREE_SCALE; |
| 84 | − | |
| 80 | + | |
| 85 | 81 | AACube serverBounds(location, rootDetails.s * TREE_SCALE); |
| 86 | − | |
| 82 | + | |
| 87 | 83 | 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 | + | |
| 90 | 86 | const float VOXEL_NODE_SCALE = 1.00f; |
| 91 | 87 | const float ENTITY_NODE_SCALE = 0.99f; |
| 92 | − | |
| 88 | + | |
| 93 | 89 | float scaleFactor = rootDetails.s * TREE_SCALE; |
| 94 | − | |
| 90 | + | |
| 95 | 91 | // Scale by 0.92 - 1.00 depending on the scale of the node. This allows smaller nodes to scale in |
| 96 | 92 | // a bit and not overlap larger nodes. |
| 97 | 93 | scaleFactor *= 0.92 + (rootDetails.s * 0.08); |
| 98 | − | |
| 94 | + | |
| 99 | 95 | // Scale different node types slightly differently because it's common for them to overlap. |
| 100 | 96 | if (nodeType == NodeType::VoxelServer) { |
| 101 | 97 | scaleFactor *= VOXEL_NODE_SCALE; |
| 102 | 98 | } else if (nodeType == NodeType::EntityServer) { |
| 103 | 99 | scaleFactor *= ENTITY_NODE_SCALE; |
| 104 | 100 | } |
| 105 | − | |
| 101 | + | |
| 106 | 102 | float red, green, blue; |
| 107 | 103 | getColorForNodeType(nodeType, red, green, blue); |
| 108 | 104 | drawNodeBorder(center, scaleFactor, red, green, blue); |
| 109 | − | |
| 105 | + | |
| 110 | 106 | float distance; |
| 111 | 107 | BoxFace face; |
| 112 | 108 | bool inside = serverBounds.contains(mouseRayOrigin); |
| 113 | 109 | bool colliding = serverBounds.findRayIntersection(mouseRayOrigin, mouseRayDirection, distance, face); |
| 114 | − | |
| 110 | + | |
| 115 | 111 | // If the camera is inside a node it will be "selected" if you don't have your cursor over another node |
| 116 | 112 | // that you aren't inside. |
| 117 | 113 | if (colliding && (!selectedNode || (!inside && (distance < selectedDistance || selectedIsInside)))) { |
| @@ -127,7 +123,7 @@ void NodeBounds::draw() { · 9 unmodified lines | ||
| 127 | 123 | } else { |
| 128 | 124 | serverJurisdictions->unlock(); |
| 129 | 125 | } |
| 130 | − } | |
| 126 | + }); | |
| 131 | 127 | |
| 132 | 128 | if (selectedNode) { |
| 133 | 129 | glPushMatrix(); |