metauni / metaboard

Multiplayer drawing boards for sharing knowledge in Roblox.
Mozilla Public License 2.0
28 stars 6 forks source link

Localised ZIndexing #78

Closed blinkybool closed 1 year ago

blinkybool commented 1 year ago

The problem

Writing on a metaboard in VR is less enjoyable the longer you write, because the z-distance from the board of each subsequent curve creeps higher and higher off the board, affecting your ability to write accurately. Even at a medium distance, you can tell at certain angles that the writing is hovering above the board a bit. I've also noticed lines looking like they've gone off the edge of the board when watching in orbcam, due to the wide-angle perspective

This is because of the policy that new curves should always appear on top of older curves. So for lines in the workspace, this must be achieved by positioning them further from the surface of the board.

Here is the snippet from PartCanvas > Line which sets this z-distance.

    local z =
        - Config.SurfaceCanvas.ZThicknessStuds / 2
        - Config.SurfaceCanvas.InitialZOffsetStuds
        - props.ZIndex * Config.SurfaceCanvas.StudsPerZIndex

The effect has recently been dramatically reduced, by changing StudsPerZIndex from 0.001 to 0.0002, and InitialZOffsetStuds from 0.0492 to 0, and ZThicknessStuds from 0.001 to 0.0001 (lower than this has no visual difference for thickness). StudsPerZIndex cannot be any lower without introducing z-fighting at a medium distance.

However on a normal usage board (the board I wrote a proof tree on in foundations) I can still perceive a small gap appearing for the "later" curves. The first half of them are remarkably flat on the board.

So I'd like @dmurfet to try out the new zDistance and see how usable it is after a lot of writing. Maybe it's satisfactory already, but if not...

A solution

Making sure a figure has a higher zIndex than every other figure is overkill. It just needs to be higher than the figures it intersects. So we could instead take advantage of the eraseGrid (or something equivalent) to identify the (likely small) set of curves which touch any of the same grid cells. Then the desired zIndex can safely be the maximum of these.

I can think of pathological scenarios where a whole row of cells has an increasing zIndex like a staircase (imagine there is a single line drawn over every cell boundary). It's not clear to me how often this would happen in practice (it may not be very pathological).

dmurfet commented 1 year ago

I just tried this in VR and as far as I'm concerned this problem is solved. I can't perceive the gap between the strokes and the board, even after writing many strokes.