ModelBoundsUtility
- Namespace: Turian.Engine.Core
- Source File: ModelBoundsUtility.cs
Resolves a ModelComponent's bounds. Bounds are baked at import time in local (model) space only — never cached in world space at runtime — so anything that needs a node's on-screen extent, such as headless scene reporting or viewport picking, transforms them itself.
Public Methods
ComputeLocalBounds
public static Bounds ComputeLocalBounds(ModelComponent component, bool loadModels, bool isResolved)
Resolves a model component's bounds in its own local space.
Parameters:
component(ModelComponent): The component to measure.loadModels(bool): Whether to resolveModelInstancewhen the component references a whole model rather than a single mesh. Loading a model uploads its GPU resources, so callers that only need a mesh's precomputed bounds can passfalseto skip that.isResolved(bool):truewhen the component's reference resolved to bounds (even if those bounds are empty becauseloadModelswasfalse);falsewhen the reference is missing or could not be loaded.
Returns: Bounds
- The component's local-space bounds, or
Emptyif unresolved.
ToWorldBounds
public static Bounds ToWorldBounds(Bounds local, Matrix4x4 transform)
Transforms local-space bounds into world space by transforming all eight corners and re-encapsulating — cheaper alternatives (transforming just the centre and extents) do not hold once rotation is involved.
Parameters:
local(Bounds): Bounds in the source space.transform(Matrix4x4): The transform from that space into world space.
Returns: Bounds