summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/render_tile.cpp
diff options
context:
space:
mode:
authorLauren Budorick <lauren@mapbox.com>2017-04-27 15:56:55 -0700
committerGitHub <noreply@github.com>2017-04-27 15:56:55 -0700
commitf6e79d70735361438655f279c8699a786d25458c (patch)
treecc01ae7aba097bae4aa84beb12ac6b8f34f4d51a /src/mbgl/renderer/render_tile.cpp
parent839ad87f37a4880804fb4c79157d998ac59954b5 (diff)
downloadqtlocation-mapboxgl-f6e79d70735361438655f279c8699a786d25458c.tar.gz
[core] Render fill-extrusion layers (#8431)
Diffstat (limited to 'src/mbgl/renderer/render_tile.cpp')
-rw-r--r--src/mbgl/renderer/render_tile.cpp48
1 files changed, 36 insertions, 12 deletions
diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp
index 5c7c491be0..ce59186e61 100644
--- a/src/mbgl/renderer/render_tile.cpp
+++ b/src/mbgl/renderer/render_tile.cpp
@@ -5,11 +5,12 @@ namespace mbgl {
using namespace style;
-mat4 RenderTile::translatedMatrix(const std::array<float, 2>& translation,
- TranslateAnchorType anchor,
- const TransformState& state) const {
+mat4 RenderTile::translateVtxMatrix(const mat4& tileMatrix,
+ const std::array<float, 2>& translation,
+ TranslateAnchorType anchor,
+ const TransformState& state) const {
if (translation[0] == 0 && translation[1] == 0) {
- return matrix;
+ return tileMatrix;
}
mat4 vtxMatrix;
@@ -17,18 +18,41 @@ mat4 RenderTile::translatedMatrix(const std::array<float, 2>& translation,
if (anchor == TranslateAnchorType::Viewport) {
const double sin_a = std::sin(-state.getAngle());
const double cos_a = std::cos(-state.getAngle());
- matrix::translate(vtxMatrix, matrix,
- id.pixelsToTileUnits(translation[0] * cos_a - translation[1] * sin_a, state.getZoom()),
- id.pixelsToTileUnits(translation[0] * sin_a + translation[1] * cos_a, state.getZoom()),
- 0);
+ matrix::translate(vtxMatrix, tileMatrix,
+ id.pixelsToTileUnits(translation[0] * cos_a - translation[1] * sin_a, state.getZoom()),
+ id.pixelsToTileUnits(translation[0] * sin_a + translation[1] * cos_a, state.getZoom()),
+ 0);
} else {
- matrix::translate(vtxMatrix, matrix,
- id.pixelsToTileUnits(translation[0], state.getZoom()),
- id.pixelsToTileUnits(translation[1], state.getZoom()),
- 0);
+ matrix::translate(vtxMatrix, tileMatrix,
+ id.pixelsToTileUnits(translation[0], state.getZoom()),
+ id.pixelsToTileUnits(translation[1], state.getZoom()),
+ 0);
}
return vtxMatrix;
}
+mat4 RenderTile::translatedMatrix(const std::array<float, 2>& translation,
+ TranslateAnchorType anchor,
+ const TransformState& state) const {
+ return translateVtxMatrix(matrix, translation, anchor, state);
+}
+
+mat4 RenderTile::translatedClipMatrix(const std::array<float, 2>& translation,
+ TranslateAnchorType anchor,
+ const TransformState& state) const {
+ return translateVtxMatrix(nearClippedMatrix, translation, anchor, state);
+}
+
+void RenderTile::calculateMatrices(const mat4& projMatrix,
+ const mat4& projClipMatrix,
+ const TransformState& transform) {
+ // Calculate two matrices for this tile: matrix is the standard tile matrix; nearClippedMatrix
+ // clips the near plane to 100 to save depth buffer precision
+ transform.matrixFor(matrix, id);
+ transform.matrixFor(nearClippedMatrix, id);
+ matrix::multiply(matrix, projMatrix, matrix);
+ matrix::multiply(nearClippedMatrix, projClipMatrix, nearClippedMatrix);
+}
+
} // namespace mbgl