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); assert(getType() == EntityTypes::PolyVox);
Q_ASSERT(args->_batch); Q_ASSERT(args->_batch);
bool voxelDataDirty;
bool volDataDirty;
withWriteLock([&] {
voxelDataDirty = _voxelDataDirty;
volDataDirty = _volDataDirty;
if (_voxelDataDirty) { if (_voxelDataDirty) {
_voxelDataDirty = false; _voxelDataDirty = false;
decompressVolumeData(); } else if (_volDataDirty) {
}
if (_volDataDirty && !_voxelDataDirty) {
_volDataDirty = false; _volDataDirty = false;
}
});
if (voxelDataDirty) {
decompressVolumeData();
} else if (volDataDirty) {
getMesh(); getMesh();
} }

View file

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