Files
MapLibreParticleLab/src/mbgl/renderer/layer_tweaker.cpp
Tim Sylvester 8d9fe37a6b Topic/drawable extrusion (#1288)
Co-authored-by: Alex Cristici <alex.cristici@gmail.com>
2023-08-31 15:36:19 +02:00

34 lines
1.3 KiB
C++

#include <mbgl/renderer/layer_tweaker.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/style/layer_properties.hpp>
#include <mbgl/renderer/render_tree.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/util/mat4.hpp>
namespace mbgl {
LayerTweaker::LayerTweaker(Immutable<style::LayerProperties> properties)
: evaluatedProperties(std::move(properties)) {}
mat4 LayerTweaker::getTileMatrix(const UnwrappedTileID& tileID,
const RenderTree& renderTree,
const TransformState& state,
const std::array<float, 2>& translation,
style::TranslateAnchorType anchor,
bool nearClipped,
bool inViewportPixelUnits) {
// from RenderTile::prepare
mat4 tileMatrix;
state.matrixFor(/*out*/ tileMatrix, tileID);
// nearClippedMatrix has near plane moved further, to enhance depth buffer precision
const auto& params = renderTree.getParameters().transformParams;
const auto& projMatrix = nearClipped ? params.nearClippedProjMatrix : params.projMatrix;
matrix::multiply(tileMatrix, projMatrix, tileMatrix);
return RenderTile::translateVtxMatrix(tileID, tileMatrix, translation, anchor, state, inViewportPixelUnits);
}
} // namespace mbgl