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
23592359 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
23602360 // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER
23612361 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+ }
23632381 }
23642382 }
23652383
@@ -2370,7 +2388,6 @@ void Application::queryVoxels() { · 4 unmodified lines
23702388
23712389 // set our preferred PPS to be exactly evenly divided among all of the voxel servers...
23722390 int perServerPPS = DEFAULT_MAX_VOXEL_PPS/voxelServerCount;
2373− printf("queryVoxels()... perServerPPS=%d\n",perServerPPS);
23742391
23752392 _voxelQuery.setMaxVoxelPacketsPerSecond(perServerPPS);
23762393
@@ -2379,28 +2396,42 @@ void Application::queryVoxels() { · 2 unmodified lines
23792396 // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER
23802397 if (node->getActiveSocket() != NULL && node->getType() == NODE_TYPE_VOXEL_SERVER) {
23812398
2382− // we can use this to get the voxel server details
2383− //QUuid nodeUUID = node->getUUID();
2384− //const JurisdictionMap& map = (_voxelServerJurisdictions)[nodeUUID];
23852399
2386− // set up the packet for sending...
2387− unsigned char* endOfVoxelQueryPacket = voxelQueryPacket;
2400+ // get the server bounds for this server
2401+ QUuid nodeUUID = node->getUUID();
2402+ const JurisdictionMap& map = (_voxelServerJurisdictions)[nodeUUID];
23882403
2389− // insert packet type/version and node UUID
2390− endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, PACKET_TYPE_VOXEL_QUERY);
2391− QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122();
2392− memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size());
2393− endOfVoxelQueryPacket += ownerUUID.size();
2404+ unsigned char* rootCode = map.getRootOctalCode();
2405+
2406+ if (rootCode) {
2407+ VoxelPositionSize rootDetails;
2408+ voxelDetailsForCode(rootCode, rootDetails);
2409+ AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
2410+ serverBounds.scale(TREE_SCALE);
23942411
2395− // encode the query data...
2396− endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket);
2412+ ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds);
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);
23972426
2398− int packetLength = endOfVoxelQueryPacket - voxelQueryPacket;
2427+ int packetLength = endOfVoxelQueryPacket - voxelQueryPacket;
23992428
2400− nodeSocket->send(node->getActiveSocket(), voxelQueryPacket, packetLength);
2429+ nodeSocket->send(node->getActiveSocket(), voxelQueryPacket, packetLength);
24012430
2402− // Feed number of bytes to corresponding channel of the bandwidth meter
2403− _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength);
2431+ // Feed number of bytes to corresponding channel of the bandwidth meter
2432+ _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength);
2433+ }
2434+ }
24042435 }
24052436 }
24062437 }

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