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