Showing the changes to interface/src/VoxelSystem.cpp (1 of 2 files). Show all
Unified · Split
| @@ -538,15 +538,15 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 537 unmodified lines | |||
| 538 | int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer); | 538 | int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer); |
| 539 | unsigned char* voxelData = sourceBuffer + numBytesPacketHeader; | 539 | unsigned char* voxelData = sourceBuffer + numBytesPacketHeader; |
| 540 | 540 | ||
| 541 | pthread_mutex_lock(&_treeLock); | ||
| 542 | |||
| 543 | switch(command) { | 541 | switch(command) { |
| 544 | case PACKET_TYPE_VOXEL_DATA: { | 542 | case PACKET_TYPE_VOXEL_DATA: { |
| 545 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 543 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 546 | "readBitstreamToTree()"); | 544 | "readBitstreamToTree()"); |
| 547 | // ask the VoxelTree to read the bitstream into the tree | 545 | // ask the VoxelTree to read the bitstream into the tree |
| 548 | ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); | 546 | ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); |
| 547 | pthread_mutex_lock(&_treeLock); | ||
| 549 | _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); | 548 | _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); |
| 549 | pthread_mutex_unlock(&_treeLock); | ||
| 550 | } | 550 | } |
| 551 | break; | 551 | break; |
| 552 | case PACKET_TYPE_VOXEL_DATA_MONOCHROME: { | 552 | case PACKET_TYPE_VOXEL_DATA_MONOCHROME: { |
| @@ -554,7 +554,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 1 unmodified line | |||
| 554 | "readBitstreamToTree()"); | 554 | "readBitstreamToTree()"); |
| 555 | // ask the VoxelTree to read the MONOCHROME bitstream into the tree | 555 | // ask the VoxelTree to read the MONOCHROME bitstream into the tree |
| 556 | ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); | 556 | ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); |
| 557 | pthread_mutex_lock(&_treeLock); | ||
| 557 | _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); | 558 | _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); |
| 559 | pthread_mutex_unlock(&_treeLock); | ||
| 558 | } | 560 | } |
| 559 | break; | 561 | break; |
| 560 | case PACKET_TYPE_Z_COMMAND: | 562 | case PACKET_TYPE_Z_COMMAND: |
| @@ -572,7 +574,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 11 unmodified lines | |||
| 572 | while (totalLength <= numBytes) { | 574 | while (totalLength <= numBytes) { |
| 573 | if (0==strcmp(command,(char*)"erase all")) { | 575 | if (0==strcmp(command,(char*)"erase all")) { |
| 574 | qDebug("got Z message == erase all\n"); | 576 | qDebug("got Z message == erase all\n"); |
| 577 | pthread_mutex_lock(&_treeLock); | ||
| 575 | _tree->eraseAllVoxels(); | 578 | _tree->eraseAllVoxels(); |
| 579 | pthread_mutex_unlock(&_treeLock); | ||
| 576 | _voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this?? | 580 | _voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this?? |
| 577 | } | 581 | } |
| 578 | if (0==strcmp(command,(char*)"add scene")) { | 582 | if (0==strcmp(command,(char*)"add scene")) { |
| @@ -590,8 +594,6 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 11 unmodified lines | |||
| 590 | setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY); | 594 | setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY); |
| 591 | } | 595 | } |
| 592 | 596 | ||
| 593 | pthread_mutex_unlock(&_treeLock); | ||
| 594 | |||
| 595 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(numBytes); | 597 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(numBytes); |
| 596 | 598 | ||
| 597 | return numBytes; | 599 | return numBytes; |
| @@ -1824,13 +1826,13 @@ VoxelNode* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const { · 1226 unmodified lines | |||
| 1824 | 1826 | ||
| 1825 | void VoxelSystem::createVoxel(float x, float y, float z, float s, | 1827 | void VoxelSystem::createVoxel(float x, float y, float z, float s, |
| 1826 | unsigned char red, unsigned char green, unsigned char blue, bool destructive) { | 1828 | unsigned char red, unsigned char green, unsigned char blue, bool destructive) { |
| 1827 | pthread_mutex_lock(&_treeLock); | ||
| 1828 | 1829 | ||
| 1829 | //qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s); | 1830 | //qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s); |
| 1831 | pthread_mutex_lock(&_treeLock); | ||
| 1830 | _tree->createVoxel(x, y, z, s, red, green, blue, destructive); | 1832 | _tree->createVoxel(x, y, z, s, red, green, blue, destructive); |
| 1831 | setupNewVoxelsForDrawing(); | ||
| 1832 | |||
| 1833 | pthread_mutex_unlock(&_treeLock); | 1833 | pthread_mutex_unlock(&_treeLock); |
| 1834 | |||
| 1835 | setupNewVoxelsForDrawing(); | ||
| 1834 | }; | 1836 | }; |
| 1835 | 1837 | ||
| 1836 | void VoxelSystem::createLine(glm::vec3 point1, glm::vec3 point2, float unitSize, rgbColor color, bool destructive) { | 1838 | void VoxelSystem::createLine(glm::vec3 point1, glm::vec3 point2, float unitSize, rgbColor color, bool destructive) { |