Repository navigation
Adds a lattice for a heightfield in .wireframe, an opt-out that makes the GPU pick independent of the
display mode, and ViewportController.sceneBounds(of:), and fixes tap-to-measure on direct-mesh bodies
built with the initializer. One behaviour change to read about: a heightfield in .wireframe is no
longer a no-op. Nothing is source-incompatible.
Changed (read before upgrading)
- A heightfield in
.wireframeis drawn as a lattice, and its lattice lines are picked (#254).
In 1.3.2 it drew nothing and picked nothing, so a terrain scene switched to.wireframewent blank.
Every other display mode draws a heightfield exactly as in 1.3.2.
Added
.wireframedraws a heightfield as a lattice (#254, part of #139). Lines of constant grid position
are drawn on the displaced surface, in the body's colour with the width and dash of
edgeLineConfiguration, see-through like a mesh's edges, and nothing of the surface itself; section
planes,transformand tile culling apply as for the shaded surface. Each tile's lines are the
smallest power-of-two number of cells apart that spansheightfieldLatticePixelson screen, never
finer than the tile's mesh cell. The lines are picked (the cell under the pixel,
PickResult.heightfieldset,refinePickunchanged) and the gaps are not. Verified on an M4 Mac
only; a line is drawn half as wide on a tile border when the field is seen from very far (#262).ViewportConfiguration.heightfieldLatticePixelsand
OffscreenRenderOptions.heightfieldLatticePixels(default 16, range1...256as
Heightfield.latticePixelsRange;Heightfield.defaultLatticePixels): how far apart the lattice lines
are on screen. No effect in other display modes.PickingConfiguration.followsDisplayMode(defaulttrue) and
OffscreenRenderOptions.pickFollowsDisplayMode(defaulttrue, copied byinit(matching:))
(#250). Since 1.3.0 the GPU pick follows the display mode: faces are stamped only when the mode shows
surfaces, and a mesh body's edges and arcs only when it shows edges, so.shadedand.wireframe
each disable a pick kind. WithfollowsDisplayMode = falseevery kind a body carries is stamped in
every display mode (what the pick did before 1.3.0), depth tested against the others as in
.shadedWithEdges:.wireframepicks faces,.shadedpicks edges. A heightfield's surface is
stamped in every mode (its lattice is not stamped separately), and an overlay body's edges and arcs
are too. The setting changes only the pick, not what is drawn; the default is unchanged.
ViewportController.selectionFilternarrows to one kind, but it runs after the pick resolves a
primitive per pixel, so a rejected kind still occupies its pixels (#260).PickingConfiguration.init
gains a defaultedfollowsDisplayMode:parameter.ViewportController.sceneBounds(of:): the scene's world bounds from the viewport's own cache
(#252). Returns the union of the bounds of the visible geometry-layer bodies (hidden and overlay
bodies left out,nilwhen none has geometry), each moved by its currenttransform. A body is
scanned only when its bounds change, so a transform change rescans nothing and the call is cheap on
every camera move; it shares the cache the dynamic pivot, orthographic eye placement and double-tap
focus use, so an app needs none of its own. A call with a selection leaves the rest of the scene
cached.
Fixed
- Tap-to-measure on direct-mesh bodies built with the initializer (#247, #136 M14).
ViewportBody.worldHitPoint(ray:triangleIndex:)read a direct-mesh body's triangles fromvertices
(the vertex-pick array) instead ofmeshPositions, so a body built with
ViewportBody(id:vertexData: [], indices:..., meshPositions:meshNormals:)returnednilfor a
measurement tap, or a wrong point whenverticesheld unrelated points, andhandleMeasurementPick
dropped the tap. It now reads the same positions the renderer draws andSceneRaycastreads, with the
body'stransformapplied as before. Bodies fromViewportBody.directMesh(...)were not affected. - The dynamic pivot's bounds cache never dropped the entry of a body that had no bounds, so such entries
stayed untilinvalidateCache().
Docs
- The heightfield cost tables now cover an iPad Pro (M2) and an iPhone 15 Pro (
docs/reference/Heightfield.md,
"Cost on an iPad" and "Cost on an iPhone"), with a warning in the cookbook. On the iPhone the default
(4 px, MSAA 4) measured about 4 ms early in a run and 6 to 13 ms once the phone had warmed; on the iPad
it measured about 20 ms, a figure that is much slower than the iPhone's for no reason found, and the iPad
is being re-measured (#139). The 4 px default is unchanged on every platform. - The gestures cookbook no longer assigns to the immutable
ViewportController.configuration(#249). - The lattice's design, cost and limits are in
docs/reference/Heightfield.md("The wireframe lattice"),
and the picking page documents thefollowsDisplayModeopt-out and its limits.