Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Fixed incorrect variable name used for `voxels` in `Colorbar` [#5208](https://github.com/MakieOrg/Makie.jl/pull/5208)
- Fixed `Time` ticks breaking when axis limits crossed over midnight [#5212](https://github.com/MakieOrg/Makie.jl/pull/5212).
- Fixed issue where segments of solid `lines` disappeared when positions were large enough [#5216](https://github.com/MakieOrg/Makie.jl/pull/5216)
- Fixed `meshscatter` markers not updating correctly in GLMakie [#5217](https://github.com/MakieOrg/Makie.jl/pull/5217)

## Unreleased
Expand Down
9 changes: 6 additions & 3 deletions GLMakie/src/plot-primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -703,18 +703,21 @@ function draw_atomic(screen::Screen, scene::Scene, plot::Lines)

if isnothing(plot.linestyle[])
positions = :positions_transformed_f32c
# unused dummy data
map!(pos -> collect(Float32.(eachindex(pos))), attr, positions, :gl_last_length)
else
positions = :gl_projected_positions
register_computation!(attr, [positions, :resolution], [:gl_last_length]) do (pos, res), changed, cached
return (sumlengths(pos, res),)
end
end

# Derived vertex attributes
register_computation!(generate_indices, attr, [positions], [:gl_indices, :gl_valid_vertex])
register_computation!(attr, [:gl_indices], [:gl_total_length]) do (indices,), changed, cached
return (Int32(length(indices) - 2),)
end
register_computation!(attr, [positions, :resolution], [:gl_last_length]) do (pos, res), changed, cached
return (sumlengths(pos, res),)
end


inputs = [
# relevant to creation time decisions
Expand Down
37 changes: 21 additions & 16 deletions Makie/src/backend-functionality.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,29 @@ end

function add_computation!(attr, ::Val{:uniform_pattern}, ::Val{:uniform_pattern_length})
# linestyle/pattern handling
return register_computation!(
attr, [:linestyle], [:uniform_pattern, :uniform_pattern_length]
) do (linestyle,), changed, cached
if isnothing(linestyle)
sdf = fill(Float16(-1.0), 100) # compat for switching from linestyle to solid/nothing
len = 1.0f0 # should be irrelevant, compat for strictly solid lines
else
sdf = Makie.linestyle_to_sdf(linestyle)
len = Float32(last(linestyle) - first(linestyle))
end
if isnothing(cached)
tex = ShaderAbstractions.Sampler(sdf, x_repeat = :repeat)
else
tex = cached.uniform_pattern
ShaderAbstractions.update!(tex, sdf)
if attr[:linestyle][] === nothing
add_constants!(attr, uniform_pattern = nothing, uniform_pattern_length = 1.0f0)
else
register_computation!(
attr, [:linestyle], [:uniform_pattern, :uniform_pattern_length]
) do (linestyle,), changed, cached
if isnothing(linestyle)
sdf = fill(Float16(-1.0), 100) # compat for switching from linestyle to solid/nothing
len = 1.0f0 # should be irrelevant, compat for strictly solid lines
else
sdf = Makie.linestyle_to_sdf(linestyle)
len = Float32(last(linestyle) - first(linestyle))
end
if isnothing(cached)
tex = ShaderAbstractions.Sampler(sdf, x_repeat = :repeat)
else
tex = cached.uniform_pattern
ShaderAbstractions.update!(tex, sdf)
end
return (tex, len)
end
return (tex, len)
end
return
end


Expand Down
3 changes: 3 additions & 0 deletions ReferenceTests/src/tests/dates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ date_time_range = range(date_time, step = Week(5), length = 10)
scatter(f[1, 1], time_range, 1:10, axis = (xticklabelrotation = pi / 4,))
scatter(f[1, 2], date_range, 1:10, axis = (xticklabelrotation = pi / 4,))
scatter(f[2, 1], date_time_range, 1:10, axis = (xticklabelrotation = pi / 4,))
# Edge case: large xs that are still considered float-safe should not break line rendering
a, p = lines(f[2, 2], Date(2000):Year(1):Date(2009), sin.(1:10), axis = (xticklabelrotation = pi / 4,))
@test Makie.is_identity_transform(a.scene.float32convert)
f
end

Expand Down
14 changes: 8 additions & 6 deletions WGLMakie/src/javascript/Lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -1140,8 +1140,8 @@ function unpack_array(array) {
return array;
}

function compute_lastlen(points, point_ndim, pvm, res, is_lines) {
if (!is_lines) return new Float32Array(points.length / point_ndim).fill(0);
function compute_lastlen(points, point_ndim, pvm, res, is_lines_with_linestyle) {
if (!is_lines_with_linestyle) return new Float32Array(points.length / point_ndim).fill(0);
if (points.length === 0) return new Float32Array(0);

const num_points = points.length / point_ndim;
Expand Down Expand Up @@ -1228,7 +1228,9 @@ function get_projectionview(cam, plot) {

function get_last_len(plot, points) {
const cam = plot.scene.wgl_camera;
const is_lines = !plot.is_segments;
// LineSegments don't need lastlen because the line pattern isn't continuous between segments
// lines without linestyle don't need it either, because there is no pattern to continue
const is_lines_with_linestyle = !plot.is_segments && (plot.plot_data.pattern != false);
const pvm = get_projectionview(cam, plot);
const res = cam.resolution;
const point_ndim = plot.ndims["positions_transformed_f32c"] || 2;
Expand All @@ -1244,12 +1246,12 @@ function get_last_len(plot, points) {
point_ndim,
pvm.value,
res.value,
is_lines
is_lines_with_linestyle
);
plot.update_buffer("lastlen", lastlen);
};
}
return compute_lastlen(points, point_ndim, pvm.value, res.value, is_lines);

return compute_lastlen(points, point_ndim, pvm.value, res.value, is_lines_with_linestyle);
}

export function add_line_attributes(plot, attributes) {
Expand Down
11 changes: 5 additions & 6 deletions WGLMakie/src/javascript/WGLMakie.bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -24246,8 +24246,8 @@ function unpack_array(array) {
}
return array;
}
function compute_lastlen(points, point_ndim, pvm, res, is_lines) {
if (!is_lines) return new Float32Array(points.length / point_ndim).fill(0);
function compute_lastlen(points, point_ndim, pvm, res, is_lines_with_linestyle) {
if (!is_lines_with_linestyle) return new Float32Array(points.length / point_ndim).fill(0);
if (points.length === 0) return new Float32Array(0);
const num_points = points.length / point_ndim;
const output = new Float32Array(num_points);
Expand Down Expand Up @@ -24302,7 +24302,7 @@ function get_projectionview(cam, plot) {
}
function get_last_len(plot, points) {
const cam = plot.scene.wgl_camera;
const is_lines = !plot.is_segments;
const is_lines_with_linestyle = !plot.is_segments && plot.plot_data.pattern != false;
const pvm = get_projectionview(cam, plot);
const res = cam.resolution;
const point_ndim = plot.ndims["positions_transformed_f32c"] || 2;
Expand All @@ -24313,11 +24313,10 @@ function get_last_len(plot, points) {
const geom = plot.mesh.geometry;
const ia = geom.interleaved_attributes;
const new_points = ia.positions_transformed_f32c.array;
const lastlen = compute_lastlen(new_points, point_ndim, pvm.value, res.value, is_lines);
plot.update_buffer("lastlen", lastlen);
compute_lastlen(new_points, point_ndim, pvm.value, res.value, is_lines_with_linestyle);
};
}
return compute_lastlen(points, point_ndim, pvm.value, res.value, is_lines);
return compute_lastlen(points, point_ndim, pvm.value, res.value, is_lines_with_linestyle);
}
function add_line_attributes(plot, attributes) {
const new_data = {};
Expand Down
2 changes: 0 additions & 2 deletions WGLMakie/src/plot-primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,6 @@ using Makie.ComputePipeline
function serialize_three(scene::Scene, plot::Union{Lines, LineSegments})
attr = plot.attributes

# TODO: This always sets a pattern, so we are rendering solid lines as a
# gapless pattern... We probably shouldn't so we don't require lastlength
Makie.add_computation!(attr, :uniform_pattern, :uniform_pattern_length)
backend_colors!(attr)

Expand Down
1 change: 1 addition & 0 deletions WGLMakie/src/serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using Colors: N0f8
tlength(T) = length(T)
tlength(::Type{<:Real}) = 1

serialize_three(::Nothing) = false
serialize_three(val::Number) = val
serialize_three(val::Vec2f) = convert(Vector{Float32}, val)
serialize_three(val::Vec3f) = convert(Vector{Float32}, val)
Expand Down
Loading