Skip to content

Commit

Permalink
Merge branch 'master' into ff/volume
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer authored Feb 7, 2025
2 parents c44d029 + b7cc362 commit a6fbf5a
Show file tree
Hide file tree
Showing 38 changed files with 843 additions and 778 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Moved Axis3 clip planes slightly outside to avoid clipping objects on the border with 0 margin [#4742](https://github.com/MakieOrg/Makie.jl/pull/4742)
- Fixed an issue with transformations not propagating to child plots when their spaces only match indirectly. [#4723](https://github.com/MakieOrg/Makie.jl/pull/4723)
- Added a tutorial on creating an inset plot [#4697](https://github.com/MakieOrg/Makie.jl/pull/4697)
- Enhanced Pattern support: Added general CairoMakie implementation, improved quality, added anchoring, added support in band, density, added tests & fixed various bugs and inconsistencies. [#4715](https://github.com/MakieOrg/Makie.jl/pull/4715)
Expand Down
25 changes: 25 additions & 0 deletions ReferenceTests/src/tests/figures_and_makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,31 @@ end
Makie.step!(st)
end

@reference_test "Axis3 clipping" begin
# Data from Brillouin.jl
basis = Vec3f[[-6.2831855, 6.2831855, 6.2831855], [6.2831855, -6.2831855, 6.2831855], [6.2831855, 6.2831855, -6.2831855]]
fs = [[6, 3, 4, 14, 13, 5], [15, 13, 14, 17, 18, 16], [17, 14, 4, 11], [17, 11, 12, 24, 23, 18], [3, 1, 2, 12, 11, 4], [1, 3, 6, 10], [24, 12, 2, 22], [5, 13, 15, 8], [19, 20, 7, 8, 15, 16], [16, 18, 23, 19], [10, 6, 5, 8, 7, 9], [24, 22, 21, 20, 19, 23], [1, 10, 9, 21, 22, 2], [20, 21, 9, 7]]
verts = Vec3i[[1, -1, -2], [2, 1, -1], [1, -2, -1], [2, -1, 1], [-2, -3, -1], [-1, -3, -2], [-3, -1, -2], [-3, -2, -1], [-2, -1, -3], [-1, -2, -3], [3, 1, 2], [3, 2, 1], [-1, -2, 1], [1, -1, 2], [-2, -1, 1], [-1, 1, 2], [2, 1, 3], [1, 2, 3], [-1, 2, 1], [-2, 1, -1], [-1, 1, -2], [1, 2, -1], [1, 3, 2], [2, 3, 1]]
ps = map(((a,b,c),) -> Point3f(basis[1] * a + basis[2] * b + basis[3] * c), verts)
ls = Point3f[]
for f in fs
append!(ls, ps[f])
push!(ls, ps[f[1]], Point3f(NaN))
end
_fs = decompose(GLTriangleFace, [NgonFace(f...) for f in fs])
m = GeometryBasics.mesh(Point3f.(ps), _fs, normal = face_normals(ps, _fs))

# Should create closed square and hexagonal cells
f = Figure()
a = Axis3(f[1, 1], aspect = :data,
xautolimitmargin=(0,0), yautolimitmargin=(0,0), zautolimitmargin=(0,0)
)
lines!(a, ls, linewidth = 3, transparency = true)
mesh!(a, m, color = (:orange, 0.2), transparency = true)
scatter!(a, ps, markersize = 30, transparency = true)
f
end

@reference_test "Colorbar for recipes" begin
fig, ax, pl = barplot(1:3; color=1:3, colormap=Makie.Categorical(:viridis), figure=(;size=(800, 800)))
Colorbar(fig[1, 2], pl; size=100)
Expand Down
2 changes: 1 addition & 1 deletion WGLMakie/src/events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function connect_scene_events!(screen::Screen, scene::Scene, comm::Observable)
tick_callback(Makie.RegularRenderTick)
# @info "tick $(e.tick[].count) $(e.tick[].delta_time)"
else
stop!(timer)
Makie.stop!(timer)
end
return
end
Expand Down
4 changes: 3 additions & 1 deletion src/makielayout/blocks/axis3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ function initialize_block!(ax::Axis3)
cameracontrols!(scene, cam)
scene.theme.clip_planes = map(scene, scene.transformation.model, ax.finallimits) do model, lims
_planes = planes(lims)
return apply_transform.(Ref(model), _planes)
_planes = apply_transform.(Ref(model), _planes)
nudge = 1f0 + 1f-5 # clip slightly outside to avoid float precision issues with 0 margin
return map(plane -> Plane3f(plane.normal, nudge * plane.distance), _planes)
end

mi1 = Observable(!(pi/2 <= mod1(ax.azimuth[], 2pi) < 3pi/2))
Expand Down
23 changes: 12 additions & 11 deletions src/utilities/timing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

mutable struct BudgetedTimer
callback::Any

target_delta_time::Float64
min_sleep::Float64
budget::Float64
last_time::UInt64

running::Bool
task::Union{Nothing, Task}

Expand All @@ -21,13 +21,13 @@ end
BudgetedTimer(callback, target_delta_time[, start = true])
A timer that keeps track of a time budget between invocations of `sleep(timer)`,
`busysleep(timer)` or roundtrips of the timed task. The budget is then used to
`busysleep(timer)` or roundtrips of the timed task. The budget is then used to
correct the next sleep so that the average sleep time matches the targeted delta
time.
To avoid lag spikes from hurrying the timer for multiple iterations/invocations
only the difference to the nearest multiple of `target_delta_time` is counted.
E.g. if two calls to `sleep(timer)` are 2.3 delta times apart, 0.3 will be
only the difference to the nearest multiple of `target_delta_time` is counted.
E.g. if two calls to `sleep(timer)` are 2.3 delta times apart, 0.3 will be
relevant difference for the budget.
"""
function BudgetedTimer(delta_time::AbstractFloat; min_sleep = 0.015)
Expand All @@ -49,9 +49,10 @@ function start!(timer::BudgetedTimer)
timer.budget = 0.0
timer.last_time = time_ns()
timer.running = true
timer.callback(timer) # error check
timer.task = @async while timer.running
timer.callback(timer)
sleep(timer)
timer.callback(timer)
end
return
end
Expand Down Expand Up @@ -91,9 +92,9 @@ function update_budget!(timer::BudgetedTimer)
# used 0 .. 1.5 delta_time, keep difference (1 .. -0.5 delta times) as budget
timer.budget = diff_to_target
else
# more than 1.5 delta_time used, get difference to next multiple of
# more than 1.5 delta_time used, get difference to next multiple of
# delta_time as the budget
timer.budget = ((diff_to_target - 0.5 * timer.target_delta_time)
timer.budget = ((diff_to_target - 0.5 * timer.target_delta_time)
% timer.target_delta_time) + 0.5 * timer.target_delta_time
end
timer.last_time = t
Expand All @@ -117,7 +118,7 @@ function Base.sleep(timer::BudgetedTimer)
# for in the last iteration and biasing for the minimum sleep time
sleep_time = timer.target_delta_time + timer.budget - time_passed - 0.5 * timer.min_sleep
if sleep_time > 0.0
sleep(sleep_time)
sleep(sleep_time)
else
yield()
end
Expand All @@ -132,7 +133,7 @@ end
Sleep until one `timer.target_delta_time` has passed since the last call to
`sleep(timer)` or `busysleep(timer)` with the current time budget included.
This uses `Base.sleep()` for an initial longer sleep and a time-checking while
This uses `Base.sleep()` for an initial longer sleep and a time-checking while
loop for the remaining time for more precision.
This always yields to other tasks.
Expand All @@ -142,7 +143,7 @@ function busysleep(timer::BudgetedTimer)
time_passed = 1e-9 * (time_ns() - timer.last_time)
sleep_time = timer.target_delta_time - time_passed + timer.budget - timer.min_sleep
if sleep_time > 0.0
sleep(sleep_time)
sleep(sleep_time)
else
yield()
end
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a6fbf5a

Please sign in to comment.