Skip to content

Commit

Permalink
Fix 3D heatmaps in CairoMakie (#2959)
Browse files Browse the repository at this point in the history
* use rect heatmap for 3D

* update NEWS

* add test for 3D heatmap

---------

Co-authored-by: Simon <[email protected]>
  • Loading branch information
ffreyer and SimonDanisch authored Jul 18, 2023
1 parent 12dd058 commit 767756f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion CairoMakie/src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,17 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Unio
t = Makie.transform_func(primitive)
identity_transform = (t === identity || t isa Tuple && all(x-> x === identity, t)) && (abs(model[1, 2]) < 1e-15)
regular_grid = xs isa AbstractRange && ys isa AbstractRange
xy_aligned = let
# Only allow scaling and translation
pv = scene.camera.projectionview[]
M = Mat4f(
pv[1, 1], 0.0, 0.0, 0.0,
0.0, pv[2, 2], 0.0, 0.0,
0.0, 0.0, pv[3, 3], 0.0,
pv[1, 4], pv[2, 4], pv[3, 4], 1.0
)
pv M
end

if interpolate
if !regular_grid
Expand All @@ -624,7 +635,8 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Unio
xymax = project_position(scene, space, Point2f(last.(imsize)), model)
w, h = xymax .- xy

can_use_fast_path = !(is_vector && !interpolate) && regular_grid && identity_transform
can_use_fast_path = !(is_vector && !interpolate) && regular_grid && identity_transform &&
(interpolate || xy_aligned)
use_fast_path = can_use_fast_path && !disable_fast_path

if use_fast_path
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## master

- Fixed incorrect rendering of 3D heatmaps [#2959](https://github.com/MakieOrg/Makie.jl/pull/2959)
- Deprecated `flatten_plots` in favor of `collect_atomic_plots`. Using the new `collect_atomic_plots` fixed a bug in CairoMakie where the z-level of plots within recipes was not respected. [#2793](https://github.com/MakieOrg/Makie.jl/pull/2793)
- Fixed incorrect line depth in GLMakie [#2843](https://github.com/MakieOrg/Makie.jl/pull/2843)
- Fixed incorrect line alpha in dense lines in GLMakie [#2843](https://github.com/MakieOrg/Makie.jl/pull/2843)
Expand Down
5 changes: 5 additions & 0 deletions ReferenceTests/src/tests/examples3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,8 @@ end
end
fig
end

# TODO: get 3D images working in CairoMakie and test them here too
@reference_test "Heatmap 3D" begin
heatmap(-2..2, -1..1, rand(100, 100); axis = (; type = LScene))
end

0 comments on commit 767756f

Please sign in to comment.