public sealed class ScenePickerWhich 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 MarkerRadiusHow near a click has to be to a shapeless entity to pick it, in render pixels.
public int SegmentsHow many divisions a curved shape is tested with.
Methods (7)
public ScenePicker(SceneDocument document)Builds a picker over a scene.
public Entity Under(Ray ray, EditorCamera camera, int width, int height)Which entity a ray hits first.
public void Within(Marquee marquee, EditorCamera camera, int width, int height, List<Entity> into)public SubObject Under(Entity entity, Vector2 pointer, EditorCamera camera, int width, int height, SubObjectFilter filter = All, float tolerance = 10)public void Within(Entity entity, Marquee marquee, EditorCamera camera, int width, int height, MeshElementKind kind, List<int> into)Which elements of an entity's mesh a rubber-band took.
public MeshElements? ElementsOf(Entity entity)public void Invalidate()Forgets the shapes built so far, for a caller that changed Segments.
Used by (5)
- BlockoutCreateTestsVixen.Editor.Blockout.Tests
- EditorApplicationVixen.Editor.App
- MarqueeTestsVixen.Editor.SceneView.Tests
- OutlinerColumnTestsVixen.Editor.App.Tests
- PickingTestsVixen.Editor.SceneView.Tests