mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:49:05 +02:00
tighten up mutex locks to keep at 60 fps
This commit is contained in:
parent
f6981feacf
commit
54364a235d
2 changed files with 9 additions and 11 deletions
|
@ -47,11 +47,7 @@ void VoxelPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char*
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
||||||
Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
|
Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
|
||||||
if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {
|
if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {
|
||||||
|
|
||||||
voxelServer->lock(); // do we really need to lock this? just to get the ID?
|
|
||||||
int nodeID = voxelServer->getNodeID();
|
int nodeID = voxelServer->getNodeID();
|
||||||
voxelServer->unlock();
|
|
||||||
|
|
||||||
if (packetData[0] == PACKET_TYPE_ENVIRONMENT_DATA) {
|
if (packetData[0] == PACKET_TYPE_ENVIRONMENT_DATA) {
|
||||||
app->_environment.parseData(&senderAddress, packetData, messageLength);
|
app->_environment.parseData(&senderAddress, packetData, messageLength);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -538,15 +538,15 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer);
|
int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer);
|
||||||
unsigned char* voxelData = sourceBuffer + numBytesPacketHeader;
|
unsigned char* voxelData = sourceBuffer + numBytesPacketHeader;
|
||||||
|
|
||||||
pthread_mutex_lock(&_treeLock);
|
|
||||||
|
|
||||||
switch(command) {
|
switch(command) {
|
||||||
case PACKET_TYPE_VOXEL_DATA: {
|
case PACKET_TYPE_VOXEL_DATA: {
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
"readBitstreamToTree()");
|
"readBitstreamToTree()");
|
||||||
// ask the VoxelTree to read the bitstream into the tree
|
// ask the VoxelTree to read the bitstream into the tree
|
||||||
ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID());
|
ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID());
|
||||||
|
pthread_mutex_lock(&_treeLock);
|
||||||
_tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args);
|
_tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args);
|
||||||
|
pthread_mutex_unlock(&_treeLock);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PACKET_TYPE_VOXEL_DATA_MONOCHROME: {
|
case PACKET_TYPE_VOXEL_DATA_MONOCHROME: {
|
||||||
|
@ -554,7 +554,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
"readBitstreamToTree()");
|
"readBitstreamToTree()");
|
||||||
// ask the VoxelTree to read the MONOCHROME bitstream into the tree
|
// ask the VoxelTree to read the MONOCHROME bitstream into the tree
|
||||||
ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID());
|
ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID());
|
||||||
|
pthread_mutex_lock(&_treeLock);
|
||||||
_tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args);
|
_tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args);
|
||||||
|
pthread_mutex_unlock(&_treeLock);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PACKET_TYPE_Z_COMMAND:
|
case PACKET_TYPE_Z_COMMAND:
|
||||||
|
@ -572,7 +574,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
while (totalLength <= numBytes) {
|
while (totalLength <= numBytes) {
|
||||||
if (0==strcmp(command,(char*)"erase all")) {
|
if (0==strcmp(command,(char*)"erase all")) {
|
||||||
qDebug("got Z message == erase all\n");
|
qDebug("got Z message == erase all\n");
|
||||||
|
pthread_mutex_lock(&_treeLock);
|
||||||
_tree->eraseAllVoxels();
|
_tree->eraseAllVoxels();
|
||||||
|
pthread_mutex_unlock(&_treeLock);
|
||||||
_voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this??
|
_voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this??
|
||||||
}
|
}
|
||||||
if (0==strcmp(command,(char*)"add scene")) {
|
if (0==strcmp(command,(char*)"add scene")) {
|
||||||
|
@ -590,8 +594,6 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY);
|
setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&_treeLock);
|
|
||||||
|
|
||||||
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(numBytes);
|
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(numBytes);
|
||||||
|
|
||||||
return numBytes;
|
return numBytes;
|
||||||
|
@ -1824,13 +1826,13 @@ VoxelNode* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const {
|
||||||
|
|
||||||
void VoxelSystem::createVoxel(float x, float y, float z, float s,
|
void VoxelSystem::createVoxel(float x, float y, float z, float s,
|
||||||
unsigned char red, unsigned char green, unsigned char blue, bool destructive) {
|
unsigned char red, unsigned char green, unsigned char blue, bool destructive) {
|
||||||
pthread_mutex_lock(&_treeLock);
|
|
||||||
|
|
||||||
//qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s);
|
//qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s);
|
||||||
|
pthread_mutex_lock(&_treeLock);
|
||||||
_tree->createVoxel(x, y, z, s, red, green, blue, destructive);
|
_tree->createVoxel(x, y, z, s, red, green, blue, destructive);
|
||||||
setupNewVoxelsForDrawing();
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&_treeLock);
|
pthread_mutex_unlock(&_treeLock);
|
||||||
|
|
||||||
|
setupNewVoxelsForDrawing();
|
||||||
};
|
};
|
||||||
|
|
||||||
void VoxelSystem::createLine(glm::vec3 point1, glm::vec3 point2, float unitSize, rgbColor color, bool destructive) {
|
void VoxelSystem::createLine(glm::vec3 point1, glm::vec3 point2, float unitSize, rgbColor color, bool destructive) {
|
||||||
|
|
Loading…
Reference in a new issue