History

Merging upstream

matsukaze committed 12 years ago

Commit 259b2852 parents bbf4f88 8797c35243 files · +6973 −4353Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 243 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+27−26
@@ -16,7 +16,6 @@ · 15 unmodified lines
1616 #include <PerfStat.h>
1717 #include <SharedUtil.h>
1818 #include <NodeList.h>
19−#include <NodeTypes.h>
2019
2120 #include "Application.h"
2221 #include "CoverageMap.h"
@@ -581,17 +580,17 @@ bool VoxelSystem::readFromSchematicFile(const char* filename) { · 558 unmodified lines
581580 return result;
582581 }
583582
584−int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
583+int VoxelSystem::parseData(const QByteArray& packet) {
585584 bool showTimingDetails = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
586585 PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData()",showTimingDetails);
587586
588− unsigned char command = *sourceBuffer;
589− int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer);
587+ PacketType command = packetTypeForPacket(packet);
588+ int numBytesPacketHeader = numBytesForPacketHeader(packet);
590589 switch(command) {
591− case PACKET_TYPE_VOXEL_DATA: {
592− PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() PACKET_TYPE_VOXEL_DATA part...",showTimingDetails);
593−
594− unsigned char* dataAt = sourceBuffer + numBytesPacketHeader;
590+ case PacketTypeVoxelData: {
591+ PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() PacketType_VOXEL_DATA part...",showTimingDetails);
592+
593+ const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(packet.data()) + numBytesPacketHeader;
595594
596595 VOXEL_PACKET_FLAGS flags = (*(VOXEL_PACKET_FLAGS*)(dataAt));
597596 dataAt += sizeof(VOXEL_PACKET_FLAGS);
@@ -608,7 +607,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 10 unmodified lines
608607 int flightTime = arrivedAt - sentAt;
609608
610609 VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;
611− int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE;
610+ int dataBytes = packet.size() - VOXEL_PACKET_HEADER_SIZE;
612611
613612 int subsection = 1;
614613 while (dataBytes > 0) {
@@ -636,7 +635,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 21 unmodified lines
636635 " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d"
637636 " subsection:%d sectionLength:%d uncompressed:%d",
638637 debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed),
639− sequence, flightTime, numBytes, dataBytes, subsection, sectionLength, packetData.getUncompressedSize());
638+ sequence, flightTime, packet.size(), dataBytes, subsection, sectionLength,
639+ packetData.getUncompressedSize());
640640 }
641641 _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);
642642 unlockTree();
@@ -647,7 +647,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 4 unmodified lines
647647 }
648648 subsection++;
649649 }
650− break;
650+ default:
651+ break;
651652 }
652653 if (!_useFastVoxelPipeline || _writeRenderFullVBO) {
653654 setupNewVoxelsForDrawing();
@@ -655,9 +656,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 1 unmodified line
655656 setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY);
656657 }
657658
658− Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(numBytes);
659+ Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(packet.size());
659660
660− return numBytes;
661+ return packet.size();
661662 }
662663
663664 void VoxelSystem::setupNewVoxelsForDrawing() {
@@ -668,8 +669,8 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 4 unmodified lines
668669 return; // bail early if we're not initialized
669670 }
670671
671− uint64_t start = usecTimestampNow();
672− uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000;
672+ quint64 start = usecTimestampNow();
673+ quint64 sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000;
673674
674675 bool iAmDebugging = false; // if you're debugging set this to true, so you won't get skipped for slow debugging
675676 if (!iAmDebugging && sinceLastTime <= std::max((float) _setupNewVoxelsForDrawingLastElapsed, SIXTY_FPS_IN_MILLISECONDS)) {
@@ -729,7 +730,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 53 unmodified lines
729730 _bufferWriteLock.unlock();
730731 }
731732
732− uint64_t end = usecTimestampNow();
733+ quint64 end = usecTimestampNow();
733734 int elapsedmsec = (end - start) / 1000;
734735 _setupNewVoxelsForDrawingLastFinished = end;
735736 _setupNewVoxelsForDrawingLastElapsed = elapsedmsec;
@@ -746,8 +747,8 @@ void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) { · 10 unmodified lines
746747 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
747748 "setupNewVoxelsForDrawingSingleNode() xxxxx");
748749
749− uint64_t start = usecTimestampNow();
750− uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000;
750+ quint64 start = usecTimestampNow();
751+ quint64 sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000;
751752
752753 bool iAmDebugging = false; // if you're debugging set this to true, so you won't get skipped for slow debugging
753754 if (allowBailEarly && !iAmDebugging &&
@@ -777,7 +778,7 @@ void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) { · 23 unmodified lines
777778
778779 _bufferWriteLock.unlock();
779780 }
780− uint64_t end = usecTimestampNow();
781+ quint64 end = usecTimestampNow();
781782 int elapsedmsec = (end - start) / 1000;
782783 _setupNewVoxelsForDrawingLastFinished = end;
783784 _setupNewVoxelsForDrawingLastElapsed = elapsedmsec;
@@ -786,14 +787,14 @@ void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) { · 2 unmodified lines
786787 void VoxelSystem::checkForCulling() {
787788
788789 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "checkForCulling()");
789− uint64_t start = usecTimestampNow();
790+ quint64 start = usecTimestampNow();
790791
791792 // track how long its been since we were last moving. If we have recently moved then only use delta frustums, if
792793 // it's been a long time since we last moved, then go ahead and do a full frustum cull.
793794 if (isViewChanging()) {
794795 _lastViewIsChanging = start;
795796 }
796− uint64_t sinceLastMoving = (start - _lastViewIsChanging) / 1000;
797+ quint64 sinceLastMoving = (start - _lastViewIsChanging) / 1000;
797798 bool enoughTime = (sinceLastMoving >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS));
798799
799800 // These has changed events will occur before we stop. So we need to remember this for when we finally have stopped
@@ -815,7 +816,7 @@ void VoxelSystem::checkForCulling() { · 15 unmodified lines
815816 hideOutOfView(forceFullFrustum);
816817
817818 if (forceFullFrustum) {
818− uint64_t endViewCulling = usecTimestampNow();
819+ quint64 endViewCulling = usecTimestampNow();
819820 _lastViewCullingElapsed = (endViewCulling - start) / 1000;
820821 }
821822
@@ -824,7 +825,7 @@ void VoxelSystem::checkForCulling() { · 2 unmodified lines
824825 // VBO reubuilding. Possibly we should do this only if our actual VBO usage crosses some lower boundary.
825826 cleanupRemovedVoxels();
826827
827− uint64_t sinceLastAudit = (start - _lastAudit) / 1000;
828+ quint64 sinceLastAudit = (start - _lastAudit) / 1000;
828829
829830 if (Menu::getInstance()->isOptionChecked(MenuOption::AutomaticallyAuditTree)) {
830831 if (sinceLastAudit >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) {
@@ -1895,7 +1896,7 @@ void VoxelSystem::falseColorizeBySource() { · 1064 unmodified lines
18951896 // create a bunch of colors we'll use during colorization
18961897
18971898 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
1898− if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
1899+ if (node->getType() == NodeType::VoxelServer) {
18991900 uint16_t nodeID = VoxelTreeElement::getSourceNodeUUIDKey(node->getUUID());
19001901 int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS;
19011902 args.colors[nodeID] = groupColors[groupColor];
@@ -2995,7 +2996,7 @@ void VoxelSystem::falseColorizeOccludedV2() { · 1093 unmodified lines
29952996 }
29962997
29972998 void VoxelSystem::nodeAdded(SharedNodePointer node) {
2998− if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
2999+ if (node->getType() == NodeType::VoxelServer) {
29993000 qDebug("VoxelSystem... voxel server %s added...", node->getUUID().toString().toLocal8Bit().constData());
30003001 _voxelServerCount++;
30013002 }
@@ -3016,7 +3017,7 @@ bool VoxelSystem::killSourceVoxelsOperation(OctreeElement* element, void* extraD · 14 unmodified lines
30163017 }
30173018
30183019 void VoxelSystem::nodeKilled(SharedNodePointer node) {
3019− if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
3020+ if (node->getType() == NodeType::VoxelServer) {
30203021 _voxelServerCount--;
30213022 QUuid nodeUUID = node->getUUID();
30223023 qDebug("VoxelSystem... voxel server %s removed...", nodeUUID.toString().toLocal8Bit().constData());