Vixen
02b45cc4
csharp
public sealed class SceneProbe

What a ray and a pointer meet in a scene, worked out on the processor.

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

Remarks

ScenePicker's twin, and it shares that type's whole argument. The geometry the editor draws is MeshPrimitives' own, built from a kind and a matrix, so testing a ray against it exactly costs one matrix inversion per entity and is the same arithmetic whether or not there is a GPU. What it is not is the readback doc 20 asks for: a shader that moved its vertices, a skinned mesh or an instanced forest is geometry this cannot see, and the day the viewport draws one of those this becomes the fallback rather than the answer.

⚠ The ray goes into local space and the vertices do not come out of it — except for the vertex query, which has to. A ray test survives the transform; "which vertex is nearest the pointer on screen" does not, because screen space is on the other side of the projection. So the surface half is one inversion per entity and the vertex half is one projection per vertex, and the second is why it is bounded by a screen-space rejection against the entity's box first.

Fields and properties (1)

  • public int Segments

    How many divisions a curved shape is tested with.

Methods (6)

  • public SceneProbe(SceneDocument document)

    Builds a probe over a scene.

  • public bool Raycast(Ray ray, out SurfaceHit hit)

    Casts a ray into the scene.

  • public bool Raycast(Ray ray, IReadOnlyList<Entity> ignore, out SurfaceHit hit)

    Casts a ray, ignoring some entities.

  • public bool TryNearestVertex(Vector2 pointer, EditorCamera camera, int width, int height, float radius, IReadOnlyList<Entity> ignore, out Vector3 position)

    The vertex nearest the pointer, within a radius measured on screen.

  • public bool TrySnap(Ray ray, Vector2 pointer, EditorCamera camera, int width, int height, SnapContext snap, Vector3 origin, IReadOnlyList<Entity> ignore, out SnapHit hit)
  • public void Invalidate()

    Forgets the shapes built so far, for a caller that changed Segments.

Used by (4)

  • BlockoutCreateTestsVixen.Editor.Blockout.Tests
  • EditorApplicationVixen.Editor.App
  • SnapContextTestsVixen.Editor.SceneView.Tests
  • SnapTestsVixen.Editor.SceneView.Tests