Vixen
02b45cc4
csharp
public sealed class ScenePicker

Which entity is under a click, worked out on the processor.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

⚠ This is not what PickingBuffer is, and it is not meant to replace it. Drawing object ids with the same vertex path as the picture is the only way to be right for a skinned mesh, an instanced forest or anything whose shader moved its vertices, and that stage is written and tested. What it needs is a host that owns a render target for it, and until there is one SceneViewport.Picking is null and every click in the viewport selects nothing at all — which is what this is for. A scene of primitives and markers is a scene a ray can be tested against exactly, and the arithmetic is the same arithmetic whether or not a GPU is involved.

⚠ The ray goes into each shape's local space rather than the vertices coming out of it. A cube is twenty-four vertices and a torus six hundred; transforming them per entity per click is the whole cost of the test, and inverting one matrix is not. The parameter along the ray survives the transform unchanged so long as the direction is not renormalised on the way in — which is what makes distances from differently scaled entities comparable, and what makes a click on the near cube not select the far one behind it.

An entity with no shape is a marker, and a marker is a cross. A cross has no area to hit, so what is tested is a small sphere about the origin — sized in render pixels rather than world units, because a light two hundred metres away is a handful of pixels and has to stay clickable. That is the same reason a gizmo is a constant size on screen.

Fields and properties (2)

  • public float MarkerRadius

    How near a click has to be to a shapeless entity to pick it, in render pixels.

  • public int Segments

    How many divisions a curved shape is tested with.

Methods (7)

Used by (5)

  • BlockoutCreateTestsVixen.Editor.Blockout.Tests
  • EditorApplicationVixen.Editor.App
  • MarqueeTestsVixen.Editor.SceneView.Tests
  • OutlinerColumnTestsVixen.Editor.App.Tests
  • PickingTestsVixen.Editor.SceneView.Tests