mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:00:41 +02:00
Merge pull request #140 from overte-org/fix/voxel_deadlock
Fix voxel deadlock and improve performance
This commit is contained in:
commit
d322273315
1 changed files with 29 additions and 9 deletions
|
@ -198,13 +198,17 @@ bool isEdged(PolyVoxEntityItem::PolyVoxSurfaceStyle surfaceStyle) {
|
||||||
|
|
||||||
void RenderablePolyVoxEntityItem::setVoxelData(const QByteArray& voxelData) {
|
void RenderablePolyVoxEntityItem::setVoxelData(const QByteArray& voxelData) {
|
||||||
// accept compressed voxel information from the entity-server
|
// accept compressed voxel information from the entity-server
|
||||||
|
bool changed = false;
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
if (_voxelData != voxelData) {
|
if (_voxelData != voxelData) {
|
||||||
_voxelData = voxelData;
|
_voxelData = voxelData;
|
||||||
_voxelDataDirty = true;
|
_voxelDataDirty = true;
|
||||||
startUpdates();
|
changed = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (changed) {
|
||||||
|
startUpdates();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderablePolyVoxEntityItem::setVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle) {
|
void RenderablePolyVoxEntityItem::setVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle) {
|
||||||
|
@ -249,6 +253,9 @@ bool RenderablePolyVoxEntityItem::setVoxel(const ivec3& v, uint8_t toValue) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
result = setVoxelInternal(v, toValue);
|
result = setVoxelInternal(v, toValue);
|
||||||
});
|
});
|
||||||
|
if (result) {
|
||||||
|
startUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -294,10 +301,12 @@ bool RenderablePolyVoxEntityItem::setAll(uint8_t toValue) {
|
||||||
result |= setVoxelInternal(v, toValue);
|
result |= setVoxelInternal(v, toValue);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (result) {
|
||||||
|
startUpdates();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RenderablePolyVoxEntityItem::setCuboid(const glm::vec3& lowPosition, const glm::vec3& cuboidSize, int toValue) {
|
bool RenderablePolyVoxEntityItem::setCuboid(const glm::vec3& lowPosition, const glm::vec3& cuboidSize, int toValue) {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (_locked) {
|
if (_locked) {
|
||||||
|
@ -316,11 +325,12 @@ bool RenderablePolyVoxEntityItem::setCuboid(const glm::vec3& lowPosition, const
|
||||||
result |= setVoxelInternal(v, toValue);
|
result |= setVoxelInternal(v, toValue);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (result) {
|
||||||
|
startUpdates();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool RenderablePolyVoxEntityItem::setVoxelInVolume(const vec3& position, uint8_t toValue) {
|
bool RenderablePolyVoxEntityItem::setVoxelInVolume(const vec3& position, uint8_t toValue) {
|
||||||
if (_locked) {
|
if (_locked) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -350,6 +360,9 @@ bool RenderablePolyVoxEntityItem::setSphereInVolume(const vec3& center, float ra
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (result) {
|
||||||
|
startUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -407,6 +420,9 @@ bool RenderablePolyVoxEntityItem::setSphere(const vec3& centerWorldCoords, float
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (result) {
|
||||||
|
startUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -452,6 +468,9 @@ bool RenderablePolyVoxEntityItem::setCapsule(const vec3& startWorldCoords, const
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (result) {
|
||||||
|
startUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -718,7 +737,7 @@ void RenderablePolyVoxEntityItem::changeUpdates(bool value) {
|
||||||
EntitySimulationPointer simulation = entityTree->getSimulation();
|
EntitySimulationPointer simulation = entityTree->getSimulation();
|
||||||
if (simulation) {
|
if (simulation) {
|
||||||
_updateNeeded = value;
|
_updateNeeded = value;
|
||||||
_flags |= Simulation::DIRTY_UPDATEABLE;
|
markDirtyFlags(Simulation::DIRTY_UPDATEABLE);
|
||||||
simulation->changeEntity(getThisPointer());
|
simulation->changeEntity(getThisPointer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -972,9 +991,7 @@ bool RenderablePolyVoxEntityItem::setVoxelInternal(const ivec3& v, uint8_t toVal
|
||||||
setVoxelMarkNeighbors(v.x, v.y, v.z, toValue);
|
setVoxelMarkNeighbors(v.x, v.y, v.z, toValue);
|
||||||
}
|
}
|
||||||
_volDataDirty = true;
|
_volDataDirty = true;
|
||||||
startUpdates();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,7 +1066,7 @@ void RenderablePolyVoxEntityItem::setVoxelsFromData(QByteArray uncompressedData,
|
||||||
quint16 voxelXSize, quint16 voxelYSize, quint16 voxelZSize) {
|
quint16 voxelXSize, quint16 voxelYSize, quint16 voxelZSize) {
|
||||||
// this accepts the payload from uncompressVolumeData
|
// this accepts the payload from uncompressVolumeData
|
||||||
ivec3 low{ 0 };
|
ivec3 low{ 0 };
|
||||||
int index = 0;
|
bool result = false;
|
||||||
|
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
if (isEdged()) {
|
if (isEdged()) {
|
||||||
|
@ -1057,11 +1074,14 @@ void RenderablePolyVoxEntityItem::setVoxelsFromData(QByteArray uncompressedData,
|
||||||
}
|
}
|
||||||
loop3(ivec3(0), ivec3(voxelXSize, voxelYSize, voxelZSize), [&](const ivec3& v) {
|
loop3(ivec3(0), ivec3(voxelXSize, voxelYSize, voxelZSize), [&](const ivec3& v) {
|
||||||
int uncompressedIndex = (v.z * (voxelYSize) * (voxelXSize)) + (v.y * (voxelZSize)) + v.x;
|
int uncompressedIndex = (v.z * (voxelYSize) * (voxelXSize)) + (v.y * (voxelZSize)) + v.x;
|
||||||
setVoxelInternal(v, uncompressedData[uncompressedIndex]);
|
result |= setVoxelInternal(v, uncompressedData[uncompressedIndex]);
|
||||||
});
|
});
|
||||||
|
|
||||||
_state = PolyVoxState::UncompressingFinished;
|
_state = PolyVoxState::UncompressingFinished;
|
||||||
});
|
});
|
||||||
|
if (result) {
|
||||||
|
startUpdates();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderablePolyVoxEntityItem::compressVolumeDataAndSendEditPacket() {
|
void RenderablePolyVoxEntityItem::compressVolumeDataAndSendEditPacket() {
|
||||||
|
|
Loading…
Reference in a new issue