core: add nearClippedProjectionMatrix to MLNCustomStyleLayer (#4364)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
@@ -22,8 +22,14 @@ struct CustomLayerRenderParameters {
|
|||||||
double bearing;
|
double bearing;
|
||||||
double pitch;
|
double pitch;
|
||||||
double fieldOfView;
|
double fieldOfView;
|
||||||
|
|
||||||
|
/// Standard projection matrix (nearZ = 1 tile unit).
|
||||||
|
/// Use this for 2D/flat custom geometry.
|
||||||
std::array<double, 16> projectionMatrix;
|
std::array<double, 16> projectionMatrix;
|
||||||
|
|
||||||
|
/// A 4×4 matrix representing the map view’s current near clip projection state.
|
||||||
|
std::array<double, 16> nearClippedProjectionMatrix;
|
||||||
|
|
||||||
CustomLayerRenderParameters(const PaintParameters&);
|
CustomLayerRenderParameters(const PaintParameters&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ typedef struct MLNStyleLayerDrawingContext {
|
|||||||
CGFloat pitch;
|
CGFloat pitch;
|
||||||
/// The vertical field of view, in degrees, for the map’s perspective.
|
/// The vertical field of view, in degrees, for the map’s perspective.
|
||||||
CGFloat fieldOfView;
|
CGFloat fieldOfView;
|
||||||
/// A 4×4 matrix representing the map view’s current projection state.
|
/// Standard projection matrix (nearZ = 1 tile unit). Use for 2D/flat geometry.
|
||||||
MLNMatrix4 projectionMatrix;
|
MLNMatrix4 projectionMatrix;
|
||||||
|
/// A 4×4 matrix representing the map view’s current near clip projection state.
|
||||||
|
MLNMatrix4 nearClippedProjectionMatrix;
|
||||||
} MLNStyleLayerDrawingContext;
|
} MLNStyleLayerDrawingContext;
|
||||||
|
|
||||||
/// A style layer that is rendered by Metal code that you provide.
|
/// A style layer that is rendered by Metal code that you provide.
|
||||||
|
|||||||
@@ -117,7 +117,8 @@ public:
|
|||||||
.direction = mbgl::util::wrap(parameters.bearing, 0., 360.),
|
.direction = mbgl::util::wrap(parameters.bearing, 0., 360.),
|
||||||
.pitch = static_cast<CGFloat>(parameters.pitch),
|
.pitch = static_cast<CGFloat>(parameters.pitch),
|
||||||
.fieldOfView = static_cast<CGFloat>(parameters.fieldOfView),
|
.fieldOfView = static_cast<CGFloat>(parameters.fieldOfView),
|
||||||
.projectionMatrix = MLNMatrix4Make(parameters.projectionMatrix)};
|
.projectionMatrix = MLNMatrix4Make(parameters.projectionMatrix),
|
||||||
|
.nearClippedProjectionMatrix = MLNMatrix4Make(parameters.nearClippedProjectionMatrix)};
|
||||||
|
|
||||||
if (layer.mapView) {
|
if (layer.mapView) {
|
||||||
[layer drawInMapView:layer.mapView withContext:drawingContext];
|
[layer drawInMapView:layer.mapView withContext:drawingContext];
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ CustomLayerRenderParameters::CustomLayerRenderParameters(const mbgl::PaintParame
|
|||||||
mat4 projMatrix;
|
mat4 projMatrix;
|
||||||
state.getProjMatrix(projMatrix);
|
state.getProjMatrix(projMatrix);
|
||||||
projectionMatrix = projMatrix;
|
projectionMatrix = projMatrix;
|
||||||
|
nearClippedProjectionMatrix = paintParameters.transformParams.nearClippedProjMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|||||||
Reference in New Issue
Block a user