#include #include #include #include #include namespace mbgl { using namespace style; mat4 RenderTile::translateVtxMatrix(const mat4& tileMatrix, const std::array& translation, TranslateAnchorType anchor, const TransformState& state, const bool inViewportPixelUnits) const { if (translation[0] == 0 && translation[1] == 0) { return tileMatrix; } mat4 vtxMatrix; const float angle = inViewportPixelUnits ? (anchor == TranslateAnchorType::Map ? state.getAngle() : 0) : (anchor == TranslateAnchorType::Viewport ? -state.getAngle() : 0); Point translate = util::rotate(Point{ translation[0], translation[1] }, angle); if (inViewportPixelUnits) { matrix::translate(vtxMatrix, tileMatrix, translate.x, translate.y, 0); } else { matrix::translate(vtxMatrix, tileMatrix, id.pixelsToTileUnits(translate.x, state.getZoom()), id.pixelsToTileUnits(translate.y, state.getZoom()), 0); } return vtxMatrix; } mat4 RenderTile::translatedMatrix(const std::array& translation, TranslateAnchorType anchor, const TransformState& state) const { return translateVtxMatrix(matrix, translation, anchor, state, false); } mat4 RenderTile::translatedClipMatrix(const std::array& translation, TranslateAnchorType anchor, const TransformState& state) const { return translateVtxMatrix(nearClippedMatrix, translation, anchor, state, false); } void RenderTile::startRender(Painter& painter) { tile.upload(painter.context); // Calculate two matrices for this tile: matrix is the standard tile matrix; nearClippedMatrix // clips the near plane to 100 to save depth buffer precision painter.state.matrixFor(matrix, id); painter.state.matrixFor(nearClippedMatrix, id); matrix::multiply(matrix, painter.projMatrix, matrix); matrix::multiply(nearClippedMatrix, painter.nearClippedProjMatrix, nearClippedMatrix); } } // namespace mbgl