FArcUIWorldWidgetMath
Pure geometry for the world-space UI widget quad — the part that decides where a nameplate sits in the scene, how large its offscreen texture should be at the current distance, whether it needs re-rendering this frame and where a click ray lands on it in widget-local UV. Every method is static and device-free so the headless test pins the exact transforms and hit math the runtime uses. Matrices are row-major (worldMatrix maps a unit quad centered on the origin, XY plane, to world space).
- Module
- ArcUI
- Header
#include "ArcUI/FArcUIWorldWidgetMath.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
static constexpr uint32_t | kNeverRendered | Default 0xFFFFFFFFu. |
Public functions
| Returns | Name | Description |
|---|---|---|
Mat4 | BillboardMatrix | Camera-facing billboard: a unit quad scaled to (widthWorld, heightWorld), oriented so its +X follows the camera's right and +Y the camera's up, translated to worldPos. |
Mat4 | OrientedMatrix | Transform-oriented quad: the entity's world matrix supplies orientation, localOffset shifts the quad along the entity's local axes, and the quad is scaled to (widthWorld, heightWorld). |
float | HeightForWidth | The quad's world height from its design pixel size and physical width: keeps the design aspect (designSize.y / designSize.x). |
void | LodResolution | Distance-driven LOD resolution for the offscreen target. |
uint32_t | LodBucket | The discrete LOD bucket a distance falls in (0 = full res at/under the reference distance, then one step per doubling). |
bool | ShouldRefresh | Whether the offscreen texture must be re-rendered this frame: the content changed (contentDirty), or the LOD bucket moved (resolution changed), or nothing has been rendered yet (lastBucket == kNeverRendered). |
bool | RayQuadUV | Ray vs. |
Function details
BillboardMatrix
static Mat4 BillboardMatrix(const Vec3& worldPos, const Vec3& cameraPos, const Vec3& cameraUp, float widthWorld, float heightWorld)Camera-facing billboard: a unit quad scaled to (widthWorld, heightWorld), oriented so its +X follows the camera's right and +Y the camera's up, translated to worldPos. cameraUp is the camera's world up (usually (0,1,0)); the right axis is derived from the view direction so the quad never rolls.
OrientedMatrix
static Mat4 OrientedMatrix(const Mat4& entityWorld, const Vec3& localOffset, float widthWorld, float heightWorld)Transform-oriented quad: the entity's world matrix supplies orientation, localOffset shifts the quad along the entity's local axes, and the quad is scaled to (widthWorld, heightWorld). A plaque bolted to a moving actor.
HeightForWidth
static float HeightForWidth(const Vec2& designSize, float widthWorld)The quad's world height from its design pixel size and physical width: keeps the design aspect (designSize.y / designSize.x).
LodResolution
static void LodResolution(const Vec2& designSize, float distance, float referenceDistance, uint32_t maxTexels, uint32_t& outWidth, uint32_t& outHeight)Distance-driven LOD resolution for the offscreen target. At or nearer than referenceDistance the longest edge is maxTexels; it halves per LOD as the widget recedes, clamped to a small floor so far nameplates still render legibly. The design aspect is preserved. Returns integer pixel extents.
LodBucket
static uint32_t LodBucket(float distance, float referenceDistance)The discrete LOD bucket a distance falls in (0 = full res at/under the reference distance, then one step per doubling). Re-render policy keys off this so a widget drifting slowly does not re-render every frame — only when it crosses a bucket boundary (or its content goes dirty).
ShouldRefresh
static bool ShouldRefresh(bool contentDirty, uint32_t lastBucket, uint32_t currentBucket)Whether the offscreen texture must be re-rendered this frame: the content changed (contentDirty), or the LOD bucket moved (resolution changed), or nothing has been rendered yet (lastBucket == kNeverRendered).
RayQuadUV
static bool RayQuadUV(const Vec3& rayOrigin, const Vec3& rayDir, const Mat4& worldMatrix, bool singleSided, float& outU, float& outV, float& outDistance)Ray vs. the quad described by worldMatrix. On a hit, outU/outV are the widget-local UV in [0,1] (origin top-left, matching the offscreen render and the Arc coordinate space), outDistance the ray parameter. Returns false when the ray misses the quad or hits its back face while singleSided is true.