fix locking around polyvox state flags

This commit is contained in:
Seth Alves 2016-03-25 14:06:57 -07:00
parent d97ab1e2fc
commit f3ba16ab3e
2 changed files with 14 additions and 6 deletions

View file

@ -554,12 +554,20 @@ void RenderablePolyVoxEntityItem::render(RenderArgs* args) {
assert(getType() == EntityTypes::PolyVox);
Q_ASSERT(args->_batch);
if (_voxelDataDirty) {
_voxelDataDirty = false;
bool voxelDataDirty;
bool volDataDirty;
withWriteLock([&] {
voxelDataDirty = _voxelDataDirty;
volDataDirty = _volDataDirty;
if (_voxelDataDirty) {
_voxelDataDirty = false;
} else if (_volDataDirty) {
_volDataDirty = false;
}
});
if (voxelDataDirty) {
decompressVolumeData();
}
if (_volDataDirty && !_voxelDataDirty) {
_volDataDirty = false;
} else if (volDataDirty) {
getMesh();
}

View file

@ -129,7 +129,7 @@ public:
uint8_t getVoxelInternal(int x, int y, int z);
bool setVoxelInternal(int x, int y, int z, uint8_t toValue);
void setVolDataDirty() { _volDataDirty = true; }
void setVolDataDirty() { withWriteLock([&] { _volDataDirty = true; }); }
private:
// The PolyVoxEntityItem class has _voxelData which contains dimensions and compressed voxel data. The dimensions