Add locking around the code that reads polyline entity data and builds GPU structures for them

This commit is contained in:
Brad Davis 2016-12-01 14:09:36 -08:00
parent c3db2704ed
commit 5bade2ef9a
2 changed files with 10 additions and 4 deletions

View file

@ -161,8 +161,14 @@ void RenderablePolyLineEntityItem::update(const quint64& now) {
uniforms.color = toGlm(getXColor());
memcpy(&_uniformBuffer.edit<PolyLineUniforms>(), &uniforms, sizeof(PolyLineUniforms));
if (_pointsChanged || _strokeWidthsChanged || _normalsChanged) {
updateVertices();
updateGeometry();
QWriteLocker lock(&_quadReadWriteLock);
if (_points.size() < 2 || _normals.size() < 2 || _strokeWidths.size() < 2) {
_empty = true;
}
if (!_empty) {
updateVertices();
updateGeometry();
}
}
}
@ -170,8 +176,7 @@ void RenderablePolyLineEntityItem::update(const quint64& now) {
void RenderablePolyLineEntityItem::render(RenderArgs* args) {
checkFading();
QWriteLocker lock(&_quadReadWriteLock);
if (_points.size() < 2 || _normals.size () < 2 || _strokeWidths.size() < 2) {
if (_empty) {
return;
}

View file

@ -50,6 +50,7 @@ protected:
gpu::BufferPointer _verticesBuffer;
gpu::BufferView _uniformBuffer;
unsigned int _numVertices;
bool _empty { true };
QVector<glm::vec3> _vertices;
};