Skip to content

Commit

Permalink
Merge branch 'breaking-0.22' into vorncolors
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer authored Nov 14, 2024
2 parents 0481841 + 885b4f1 commit 53972ce
Show file tree
Hide file tree
Showing 98 changed files with 163,183 additions and 279 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/Docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ on:
pull_request:
branches:
- master
- breaking-0.21
- breaking-0.22
push:
tags:
- '*'
branches:
- master
- breaking-0.21

workflow_dispatch:

concurrency:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*.md'
branches:
- master
- breaking-0.22
push:
tags:
- '*'
Expand Down Expand Up @@ -46,6 +47,9 @@ jobs:
pkg"registry up"
Pkg.update()
pkg"dev . ./MakieCore"
pkg"add GeometryBasics#master"
pkg"add MeshIO#ff/GeometryBasics_refactor"
pkg"add ShaderAbstractions#ff/GeometryBasics_refactor"
Pkg.test("Makie"; coverage=true)
- uses: julia-actions/julia-processcoverage@v1
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/compilation-benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*.md'
branches:
- master
- breaking-0.22

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/reference_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*.md'
branches:
- master
- breaking-0.22
push:
tags:
- '*'
Expand Down Expand Up @@ -45,6 +46,9 @@ jobs:
# dev mono repo versions
pkg"registry up"
Pkg.update()
pkg"add MeshIO#ff/GeometryBasics_refactor"
pkg"add GeometryBasics#master"
pkg"add ShaderAbstractions#ff/GeometryBasics_refactor"
pkg"dev . ./MakieCore ./CairoMakie ./ReferenceTests"
- name: Run the tests
continue-on-error: true
Expand Down Expand Up @@ -95,6 +99,9 @@ jobs:
# dev mono repo versions
pkg"registry up"
Pkg.update()
pkg"add MeshIO#ff/GeometryBasics_refactor"
pkg"add GeometryBasics#master"
pkg"add ShaderAbstractions#ff/GeometryBasics_refactor"
pkg"dev . ./MakieCore ./GLMakie ./ReferenceTests"
- name: Run the tests
id: referencetests
Expand Down Expand Up @@ -145,6 +152,9 @@ jobs:
# dev mono repo versions
pkg"registry up"
Pkg.update()
pkg"add MeshIO#ff/GeometryBasics_refactor"
pkg"add GeometryBasics#master"
pkg"add ShaderAbstractions#ff/GeometryBasics_refactor"
pkg"dev . ./MakieCore ./WGLMakie ./ReferenceTests"
- name: Run the tests
continue-on-error: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/relocatability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*.md'
branches:
- master
- breaking-0.22
push:
tags:
- '*'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/rprmakie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*.md'
branches:
- master
- breaking-0.22
push:
tags:
- '*'
Expand Down Expand Up @@ -43,6 +44,9 @@ jobs:
using Pkg;
pkg"registry up"
Pkg.update()
pkg"add GeometryBasics#master"
pkg"add MeshIO#ff/GeometryBasics_refactor"
pkg"add ShaderAbstractions#ff/GeometryBasics_refactor"
# dev mono repo versions
pkg"dev . ./MakieCore ./RPRMakie ./ReferenceTests"
- name: Run the tests
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [Breaking]

- Updated to GeometryBasics 0.5: [GeometryBasics#173](https://github.com/JuliaGeometry/GeometryBasics.jl/pull/173), [GeometryBasics#219](https://github.com/JuliaGeometry/GeometryBasics.jl/pull/219) [#4319](https://github.com/MakieOrg/Makie.jl/pull/4319)
- Removed `meta` infrastructure. Vertex attributes are now passed as kwargs.
- Simplified GeometryBasics Mesh type, improving compile times
- Added `FaceView` to allow different vertex attributes to use different indices for specifying data of the same vertex. This can be used to specify per-face data.
- Added `GeometryBasics.face_normals(points, faces)`
- Changed the order of `Rect2` coordinates to be counter-clockwise.
- Updated `Cylinder` to avoid visually rounding off the top and bottom.
- Added `MetaMesh` to store non-vertex metadata in a GeometryBasics Mesh object. These are now produced by MeshIO for `.obj` files, containing information from `.mtl` files.
- Renamed `Tesselation/tesselation` to `Tessellation/tessellation` [GeometryBasics#227](https://github.com/JuliaGeometry/GeometryBasics.jl/pull/227) [#4564](https://github.com/MakieOrg/Makie.jl/pull/4564)
- Added `Makie.mesh` option for `MetaMesh` which applies some of the bundled information [#4368](https://github.com/MakieOrg/Makie.jl/pull/4368), [#4496](https://github.com/MakieOrg/Makie.jl/pull/4496)


## [Unreleased]

- `Voronoiplot`s automatic colors are now defined based on the underlying point set instead of only those generators appearing in the tessellation. This makes the selected colors consistent between tessellations when generators might have been deleted or added. [#4357](https://github.com/MakieOrg/Makie.jl/pull/4357)
Expand Down
6 changes: 3 additions & 3 deletions CairoMakie/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CairoMakie"
uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
author = ["Simon Danisch <[email protected]>"]
version = "0.12.16"
version = "0.13.0"

[deps]
CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
Expand All @@ -22,9 +22,9 @@ Cairo_jll = "1.18.0"
Colors = "0.10, 0.11, 0.12, 0.13"
FileIO = "1.1"
FreeType = "3, 4.0"
GeometryBasics = "0.4.11"
GeometryBasics = "0.4.11, 0.5"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.21.16"
Makie = "=0.22.0"
PrecompileTools = "1.0"
julia = "1.3"

Expand Down
16 changes: 10 additions & 6 deletions CairoMakie/src/overrides.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function draw_plot(scene::Scene, screen::Screen, poly::Poly)
# dispatch on input arguments to poly to use smarter drawing methods than
# meshes if possible.
# however, since recipes exist, we can't explicitly handle all cases here
# so, we should also take a look at converted
# so, we should also take a look at converted
# First, we check whether a `draw_poly` method exists for the input arguments
# before conversion:
return if Base.hasmethod(draw_poly, Tuple{Scene, Screen, typeof(poly), typeof.(to_value.(poly.args))...})
Expand Down Expand Up @@ -85,10 +85,14 @@ draw_poly(scene::Scene, screen::Screen, poly, rect::Rect2) = draw_poly(scene, sc
draw_poly(scene::Scene, screen::Screen, poly, bezierpath::BezierPath) = draw_poly(scene, screen, poly, [bezierpath])

function draw_poly(scene::Scene, screen::Screen, poly, shapes::Vector{<:Union{Rect2, BezierPath}})
model = poly.model[]
space = to_value(get(poly, :space, :data))
clipped_shapes = clip_shape.(Ref(poly.clip_planes[]), shapes, space, Ref(model))
projected_shapes = project_shape.(Ref(poly), space, clipped_shapes, Ref(model))
model = poly.model[]::Mat4d
space = to_value(get(poly, :space, :data))::Symbol
planes = poly.clip_planes[]::Vector{Plane3f}

projected_shapes = map(shapes) do shape
clipped = clip_shape(planes, shape, space, model)
return project_shape(poly, space, clipped, model)
end

color = to_cairo_color(poly.color[], poly)

Expand Down Expand Up @@ -188,7 +192,7 @@ end
function draw_poly(scene::Scene, screen::Screen, poly, polygons::AbstractArray{<: MultiPolygon})
model = poly.model[]
space = to_value(get(poly, :space, :data))
projected_polys = map(polygons) do polygon
projected_polys = map(polygons) do polygon
project_multipolygon(poly, space, polygon, poly.clip_planes[], model)
end

Expand Down
1 change: 1 addition & 0 deletions CairoMakie/src/precompiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let
include(shared_precompile)
end
end
precompile(openurl, (String,))
precompile(draw_atomic_scatter, (Scene, Cairo.CairoContext, Tuple{typeof(identity),typeof(identity)},
Vector{ColorTypes.RGBA{Float32}}, Vec{2,Float32}, ColorTypes.RGBA{Float32},
Float32, BezierPath, Vec{2,Float32}, Quaternionf,
Expand Down
28 changes: 6 additions & 22 deletions CairoMakie/src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,6 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Unio

isempty(positions) && return

# workaround for a LineSegments object created from a GLNormalMesh
# the input argument is a view of points using faces, which results in
# a vector of tuples of two points. we convert those to a list of points
# so they don't trip up the rest of the pipeline
# TODO this shouldn't be necessary anymore!
if positions isa SubArray{<:Point3, 1, P, <:Tuple{Array{<:AbstractFace}}} where P
positions = let
pos = Point3f[]
for tup in positions
push!(pos, tup[1])
push!(pos, tup[2])
end
pos
end
end

# color is now a color or an array of colors
# if it's an array of colors, each segment must be stroked separately
color = to_color(primitive.calculated_colors[])
Expand Down Expand Up @@ -912,7 +896,7 @@ function draw_mesh2D(scene, screen, @nospecialize(plot::Makie.Mesh), @nospeciali
space = to_value(get(plot, :space, :data))::Symbol
transform_func = Makie.transform_func(plot)
model = plot.model[]::Mat4d
vs = project_position(scene, transform_func, space, GeometryBasics.metafree(GeometryBasics.coordinates(mesh)), model)::Vector{Point2f}
vs = project_position(scene, transform_func, space, GeometryBasics.coordinates(mesh), model)::Vector{Point2f}
fs = decompose(GLTriangleFace, mesh)::Vector{GLTriangleFace}
uv = decompose_uv(mesh)::Union{Nothing, Vector{Vec2f}}
# Note: This assume the function is only called from mesh plots
Expand Down Expand Up @@ -1200,7 +1184,7 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Maki

pos = primitive[1][]
# For correct z-ordering we need to be in view/camera or screen space
model = copy(model)
model = copy(model)::Mat4d
view = scene.camera.view[]

zorder = sortperm(pos, by = p -> begin
Expand Down Expand Up @@ -1253,17 +1237,17 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Maki
pos = Makie.voxel_positions(primitive)
scale = Makie.voxel_size(primitive)
colors = Makie.voxel_colors(primitive)
marker = GeometryBasics.normal_mesh(Rect3f(Point3f(-0.5), Vec3f(1)))
# Face culling
marker = GeometryBasics.expand_faceviews(normal_mesh(Rect3f(Point3f(-0.5), Vec3f(1))))


if !isempty(primitive.clip_planes[]) && Makie.is_data_space(primitive.space[])
valid = [is_visible(primitive.clip_planes[], p) for p in pos]
pos = pos[valid]
colors = colors[valid]
end

# For correct z-ordering we need to be in view/camera or screen space
model = copy(primitive.model[])
model = copy(primitive.model[])::Mat4d
view = scene.camera.view[]

zorder = sortperm(pos, by = p -> begin
Expand Down
39 changes: 20 additions & 19 deletions CairoMakie/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end

# much faster than dot-ing `project_position` because it skips all the repeated mat * mat
function project_position(
scene::Scene, space::Symbol, ps::Vector{<: VecTypes{N, T1}},
scene::Scene, space::Symbol, ps::Vector{<: VecTypes{N, T1}},
indices::Vector{<:Integer}, model::Mat4, yflip::Bool = true
) where {N, T1}

Expand Down Expand Up @@ -44,7 +44,7 @@ function _project_position(scene::Scene, space, ps::AbstractArray{<: VecTypes{N,
end

function project_position(
scene::Scene, space::Symbol, ps::AbstractArray{<: VecTypes{N, T1}},
scene::Scene, space::Symbol, ps::AbstractArray{<: VecTypes{N, T1}},
indices::Base.OneTo, model::Mat4, yflip::Bool = true
) where {N, T1}

Expand Down Expand Up @@ -149,14 +149,15 @@ function clip_shape(clip_planes::Vector{Plane3f}, shape::Rect2, space::Symbol, m
if !Makie.is_data_space(space) || isempty(clip_planes)
return shape
end

xy = origin(shape)
w, h = widths(shape)
ps = [xy, xy + Vec2(w, 0), xy + Vec2f(w, h), xy + Vec2(0, h)]
ps = Vec2f[xy, xy + Vec2f(w, 0), xy + Vec2f(w, h), xy + Vec2f(0, h)]
if any(p -> Makie.is_clipped(clip_planes, p), ps)
push!(ps, xy)
ps = clip_poly(clip_planes, ps, space, model)
return BezierPath([MoveTo(ps[1]), LineTo.(ps[2:end])..., ClosePath()])
commands = Makie.PathCommand[MoveTo(ps[1]), LineTo.(ps[2:end])..., ClosePath()]
return BezierPath(commands::Vector{Makie.PathCommand})
else
return shape
end
Expand All @@ -173,7 +174,7 @@ function project_polygon(@nospecialize(scenelike), space, poly::Polygon{N, T}, c

ext_proj = PT[project(p) for p in clip_poly(clip_planes, ext, space, model)]
interiors_proj = Vector{PT}[
PT[project(p) for p in clip_poly(clip_planes, decompose(PT, points), space, model)]
PT[project(p) for p in clip_poly(clip_planes, decompose(PT, points), space, model)]
for points in poly.interiors]

return Polygon(ext_proj, interiors_proj)
Expand All @@ -195,7 +196,7 @@ end
# at clip planes
per_point_colors = colors <: AbstractArray
per_point_linewidths = (T <: Lines) && (linewidths <: AbstractArray)

quote
@get_attribute(plot, (space, model))

Expand All @@ -207,7 +208,7 @@ end
@inbounds for (i, point) in enumerate(points)
clip_points[i] = transform * to_ndim(Vec4d, to_ndim(Vec3d, point, 0), 1)
end

# yflip and clip -> screen/pixel coords
res = scene.camera.resolution[]

Expand All @@ -219,14 +220,14 @@ end
end

# Fix lines with points far outside the clipped region not drawing at all
# TODO this can probably be done more efficiently by checking -1 ≤ x, y ≤ 1
# TODO this can probably be done more efficiently by checking -1 ≤ x, y ≤ 1
# directly and calculating intersections directly (1D)
push!(clip_planes,
Plane3f(Vec3f(-1, 0, 0), -1f0), Plane3f(Vec3f(+1, 0, 0), -1f0),
Plane3f(Vec3f(0, -1, 0), -1f0), Plane3f(Vec3f(0, +1, 0), -1f0)
)


# outputs
screen_points = sizehint!(Vec2f[], length(clip_points))
$(if per_point_colors
Expand Down Expand Up @@ -314,8 +315,8 @@ end
end)
elseif !hidden
# if not hidden, always push the first element to 1:end-1 line points
# if the start of the segment is disconnected (moved), make sure the

# if the start of the segment is disconnected (moved), make sure the
# line separates before it
if disconnect1 && !last_is_nan
push!(screen_points, Vec2f(NaN))
Expand All @@ -326,7 +327,7 @@ end
:(push!(color_output, c1))
end)
end

last_is_nan = false
push!(screen_points, clip2screen(p1, res))
$(if per_point_linewidths
Expand All @@ -336,7 +337,7 @@ end
:(push!(color_output, c1))
end)

# if the end of the segment is disconnected (moved), add the adjusted
# if the end of the segment is disconnected (moved), add the adjusted
# point and separate it from from the next segment
if disconnect2
last_is_nan = true
Expand All @@ -351,8 +352,8 @@ end
end
end

# If last_is_nan == true, the last segment is either hidden or the moved
# end point has been added. If it is false we're missing the last regular
# If last_is_nan == true, the last segment is either hidden or the moved
# end point has been added. If it is false we're missing the last regular
# clip_points
if !last_is_nan
push!(screen_points, clip2screen(clip_points[end], res))
Expand All @@ -365,7 +366,7 @@ end
end

else # LineSegments

for i in 1:2:length(clip_points)-1
$(if per_point_colors
quote
Expand Down Expand Up @@ -525,8 +526,8 @@ end
"""
cairo_scatter_marker(marker)
Convert a Makie marker to a Cairo-compatible marker. This defaults to calling
`Makie.to_spritemarker`, but can be overridden for specific markers that can
Convert a Makie marker to a Cairo-compatible marker. This defaults to calling
`Makie.to_spritemarker`, but can be overridden for specific markers that can
be directly rendered to vector formats using Cairo.
"""
cairo_scatter_marker(marker) = Makie.to_spritemarker(marker)
Expand Down
Loading

0 comments on commit 53972ce

Please sign in to comment.