From 6ec2eb3147b02dab62ea8ac3cff0b706628dc353 Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Wed, 27 Aug 2014 11:36:41 +0300 Subject: Diffuse and specular color for static optimization Change-Id: I2c51ba06c6af9193a70f4a268dfd2fbd6c6910b3 Reviewed-by: Miikka Heikkinen --- .../utils/scatterobjectbufferhelper.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/datavisualization/utils/scatterobjectbufferhelper.cpp') diff --git a/src/datavisualization/utils/scatterobjectbufferhelper.cpp b/src/datavisualization/utils/scatterobjectbufferhelper.cpp index 1639eb1f..9ecdffdd 100644 --- a/src/datavisualization/utils/scatterobjectbufferhelper.cpp +++ b/src/datavisualization/utils/scatterobjectbufferhelper.cpp @@ -114,23 +114,25 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal int offset = pos * verticeCount; if (item.rotation().isIdentity()) { - for (int j = 0; j < verticeCount; j++) + for (int j = 0; j < verticeCount; j++) { buffered_vertices[j + offset] = scaled_vertices[j] + item.translation(); + buffered_normals[j + offset] = indexed_normals[j]; + } } else { QMatrix4x4 matrix; - matrix.rotate(seriesRotation * item.rotation()); - modelMatrix = matrix.transposed(); - modelMatrix.scale(modelScaler); + QQuaternion totalRotation = seriesRotation * item.rotation(); + matrix.rotate(totalRotation); + matrix.scale(modelScaler); + QMatrix4x4 itModelMatrix = matrix.inverted(); + modelMatrix = matrix.transposed(); // Because of row-column major difference - for (int j = 0; j < verticeCount; j++) + for (int j = 0; j < verticeCount; j++) { buffered_vertices[j + offset] = indexed_vertices[j] * modelMatrix + item.translation(); + buffered_normals[j + offset] = indexed_normals[j] * itModelMatrix; + } } - offset = pos * normalsCount; - for (int j = 0; j < normalsCount; j++) - buffered_normals[j + offset] = indexed_normals[j]; - if (cache->colorStyle() == Q3DTheme::ColorStyleUniform) { offset = pos * uvsCount; for (int j = 0; j < uvsCount; j++) -- cgit v1.2.3