WorldPanelPointer
- Namespace: Turian.Engine.UI
- Source File: WorldPanelPointer.cs
Projects a screen-space pointer onto a world-space UI panel: builds a ray from the camera through the pointer, intersects the panel's unit quad and returns the hit in panel pixels. The pixel mapping is the exact inverse of worldui.vert's UV (u = localX + 0.5, v = localY + 0.5), so a hovered pixel here is the pixel the shader drew there.
Remarks
Matrices follow the engine's row-vector convention: a point is transformed as v · M, and view * projection is "apply view, then projection".
Public Methods
TryHit
public static bool TryHit(Matrix4x4 model, Matrix4x4 viewProjection, Vector2 pointerPixels, Vector2 viewportPixels, Vector2 panelPixels, Vector2 hit)
Tries to hit the panel described by model.
Parameters:
model(Matrix4x4): The panel's world transform (unit quad on local XY,[-0.5, 0.5]).viewProjection(Matrix4x4): The camera'sview * projectionmatrix.pointerPixels(Vector2): Pointer position in viewport pixels, origin top-left.viewportPixels(Vector2): Viewport size in pixels.panelPixels(Vector2): Panel size in pixels the UI was rasterised at.hit(Vector2): The hit position in panel pixels (origin top-left), when this returnstrue.
Returns: bool
truewhen the ray hits inside the panel quad.