puts "=================================================================="
puts "GPU grid -viewAdaptive 1: cell spacing tracks camera zoom"
puts "=================================================================="
# -viewAdaptive derives both the cell size and the rendered bounds from
# the visible region (camera scale + viewport unprojection). Zooming in
# should keep cells visible and roughly the same screen-space density;
# zooming out should adapt the rendered extents to enclose the new view.

pload MODELING VISUALIZATION

vclear
vinit View1 w=400 h=400
vaxo

box b 1 1 1
vdisplay b -dispMode 1
vfit

vgrid -type gpu -viewAdaptive 1
vdump $imagedir/${casename}_fit.png

# Zoom out 10x - bounds must widen so the grid still fills the view.
vzoom 0.1
vdump $imagedir/${casename}_zoom_out.png

# Zoom in 100x relative to current - cells must subdivide and remain visible.
vzoom 100
vdump $imagedir/${casename}_zoom_in.png

# Same again with a circular grid to exercise the polar bounds branch.
vzoom 0.0001
vgrid -type gpu -viewAdaptive 1 -step 0.5 24
vdump $imagedir/${casename}_circ.png

vgrid off
