History

Merge pull request #1120 from ZappoMan/rate_control

Only send PACKET_TYPE_VOXEL_QUERY messages to voxel servers that are in view.

Philip Rosedale committed 13 years ago

Commit 6957d992 parents bf07ffd 660eddd1 file · +49 −18Browse files

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

Unified · Split

interface/src/Application.cpp+49−18
@@ -2359,7 +2359,25 @@ void Application::queryVoxels() { · 2358 unmodified lines
2359 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {2359 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2360 // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER2360 // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER
2361 if (node->getActiveSocket() != NULL && node->getType() == NODE_TYPE_VOXEL_SERVER) {2361 if (node->getActiveSocket() != NULL && node->getType() == NODE_TYPE_VOXEL_SERVER) {
2362 voxelServerCount++;2362
2363 // get the server bounds for this server
2364 QUuid nodeUUID = node->getUUID();
2365 const JurisdictionMap& map = (_voxelServerJurisdictions)[nodeUUID];
2366
2367 unsigned char* rootCode = map.getRootOctalCode();
2368
2369 if (rootCode) {
2370 VoxelPositionSize rootDetails;
2371 voxelDetailsForCode(rootCode, rootDetails);
2372 AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
2373 serverBounds.scale(TREE_SCALE);
2374
2375 ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds);
2376
2377 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
2378 voxelServerCount++;
2379 }
2380 }
2363 }2381 }
2364 }2382 }
2365 2383
@@ -2370,7 +2388,6 @@ void Application::queryVoxels() { · 4 unmodified lines
2370 2388
2371 // set our preferred PPS to be exactly evenly divided among all of the voxel servers...2389 // set our preferred PPS to be exactly evenly divided among all of the voxel servers...
2372 int perServerPPS = DEFAULT_MAX_VOXEL_PPS/voxelServerCount;2390 int perServerPPS = DEFAULT_MAX_VOXEL_PPS/voxelServerCount;
2373 printf("queryVoxels()... perServerPPS=%d\n",perServerPPS);
2374 2391
2375 _voxelQuery.setMaxVoxelPacketsPerSecond(perServerPPS);2392 _voxelQuery.setMaxVoxelPacketsPerSecond(perServerPPS);
2376 2393
@@ -2379,28 +2396,42 @@ void Application::queryVoxels() { · 2 unmodified lines
2379 // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER2396 // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER
2380 if (node->getActiveSocket() != NULL && node->getType() == NODE_TYPE_VOXEL_SERVER) {2397 if (node->getActiveSocket() != NULL && node->getType() == NODE_TYPE_VOXEL_SERVER) {
2381 2398
2382 // we can use this to get the voxel server details
2383 //QUuid nodeUUID = node->getUUID();
2384 //const JurisdictionMap& map = (_voxelServerJurisdictions)[nodeUUID];
2385 2399
2386 // set up the packet for sending...2400 // get the server bounds for this server
2387 unsigned char* endOfVoxelQueryPacket = voxelQueryPacket;2401 QUuid nodeUUID = node->getUUID();
2402 const JurisdictionMap& map = (_voxelServerJurisdictions)[nodeUUID];
2388 2403
2389 // insert packet type/version and node UUID2404 unsigned char* rootCode = map.getRootOctalCode();
2390 endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, PACKET_TYPE_VOXEL_QUERY);2405
2391 QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122();2406 if (rootCode) {
2392 memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size());2407 VoxelPositionSize rootDetails;
2393 endOfVoxelQueryPacket += ownerUUID.size();2408 voxelDetailsForCode(rootCode, rootDetails);
2409 AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
2410 serverBounds.scale(TREE_SCALE);
2394 2411
2395 // encode the query data...2412 ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds);
2396 endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket);2413
2414 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
2415 // set up the packet for sending...
2416 unsigned char* endOfVoxelQueryPacket = voxelQueryPacket;
2417
2418 // insert packet type/version and node UUID
2419 endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, PACKET_TYPE_VOXEL_QUERY);
2420 QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122();
2421 memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size());
2422 endOfVoxelQueryPacket += ownerUUID.size();
2423
2424 // encode the query data...
2425 endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket);
2397 2426
2398 int packetLength = endOfVoxelQueryPacket - voxelQueryPacket;2427 int packetLength = endOfVoxelQueryPacket - voxelQueryPacket;
2399 2428
2400 nodeSocket->send(node->getActiveSocket(), voxelQueryPacket, packetLength);2429 nodeSocket->send(node->getActiveSocket(), voxelQueryPacket, packetLength);
2401 2430
2402 // Feed number of bytes to corresponding channel of the bandwidth meter2431 // Feed number of bytes to corresponding channel of the bandwidth meter
2403 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength);2432 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength);
2433 }
2434 }
2404 }2435 }
2405 }2436 }
2406}2437}

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