From 08e4b647650294d2d365f23b3620019472d8cec1 Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Fri, 27 Sep 2013 15:31:37 +0300 Subject: Surface shader changed on smooth update if no object yet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setSmoothSurfaceEnabled not effective if no object, ie. if setting the status before setting the model. Task-number: QTRD-2342 Change-Id: I6087bfc208cd5ebbc58071fbeabcf9b825629abd Reviewed-by: Tomi Korpipää --- src/datavisualization/engine/surface3drenderer.cpp | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index 25a6a519..e3e89b14 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -1732,29 +1732,34 @@ void Surface3DRenderer::calculateSceneScalingFactors() bool Surface3DRenderer::updateSmoothStatus(bool enable) { - m_cachedSmoothSurface = enable; - if (!m_cachedSmoothSurface && !m_flatSupported) { + if (!enable && !m_flatSupported) { qWarning() << "Warning: Flat qualifier not supported on your platform's GLSL language." " Requires at least GLSL version 1.5."; - m_cachedSmoothSurface = true; + enable = true; } - if (!m_surfaceObj) - return m_cachedSmoothSurface; + bool changed = false; + if (enable != m_cachedSmoothSurface) { + m_cachedSmoothSurface = enable; + changed = true; + } - if (m_cachedSmoothSurface == false && !m_flatSupported) - m_cachedSmoothSurface = true; + if (changed) + initSurfaceShaders(); - if (m_cachedSmoothSurface) { - m_surfaceObj->setUpSmoothData(m_dataArray, m_sampleSpace, m_heightNormalizer, true, - m_cachedSelectionMode != QDataVis::ModeNone); + // If no surface object created yet, don't try to update the object, instead return + if (!m_surfaceObj || !changed) { + return m_cachedSmoothSurface; } else { - m_surfaceObj->setUpData(m_dataArray, m_sampleSpace, m_heightNormalizer, true, - m_cachedSelectionMode != QDataVis::ModeNone); + if (m_cachedSmoothSurface) { + m_surfaceObj->setUpSmoothData(m_dataArray, m_sampleSpace, m_heightNormalizer, true, + m_cachedSelectionMode != QDataVis::ModeNone); + } else { + m_surfaceObj->setUpData(m_dataArray, m_sampleSpace, m_heightNormalizer, true, + m_cachedSelectionMode != QDataVis::ModeNone); + } } - initSurfaceShaders(); - return m_cachedSmoothSurface; } -- cgit v1.2.3