InstancedRenderContext<'T, 'K> Type
Contextual object for instanced cell-grid rendering on the MonoGame backend. Bundles the key/material/transform functions and manages internal reusable storage and snapshot pooling to avoid per-frame allocations.
Ported from Mibo.Raylib/Layout3D/Renderer3D.fs with type swaps per §5/§6.2:
Raylib_cs.Mesh→ PrimitiveMeshSystem.Numerics.Matrix4x4→ Matrix (converted at the Core↔backend boundary viaConversions).System.Numerics.Vector3→ Vector3 (same).
Mibo.Core.Layout3D (backend-agnostic) and is
reused unchanged; only the renderer glue is ported.
Constructors
| Constructor |
Description
|
Full Usage:
InstancedRenderContext(getKey, getParts, getTransform)
Parameters: Returns: InstancedRenderContext<'T, 'K>
|
Constructs a context over zero-copy ModelPart slices (e.g. ModelParts.ofModel results): each group emits one instanced command per part, folding the part's own absolute bone into a pooled per-part snapshot and passing the part's real buffer offsets. The getTransform bone fold of the two-element ctor must NOT be used here — the context applies per-part bones itself.
|
Full Usage:
InstancedRenderContext(getKey, getMeshesMaterialAndShader, getTransform)
Parameters:
'T -> 'K
getMeshesMaterialAndShader : 'T -> (PrimitiveMesh * Material3D * Effect voption)[]
getTransform : Vector3 -> 'T -> Matrix
Returns: InstancedRenderContext<'T, 'K>
|
Overload constructor for per-sub-mesh shaders: each triple may carry an
|
Full Usage:
InstancedRenderContext(getKey, getMeshesAndMaterial, getTransform)
Parameters:
'T -> 'K
getMeshesAndMaterial : 'T -> (PrimitiveMesh * Material3D)[]
getTransform : Vector3 -> 'T -> Matrix
Returns: InstancedRenderContext<'T, 'K>
|
|
Instance members
| Instance member |
Description
|
Full Usage:
this.GetKey
Returns: 'T -> 'K
|
|
|
|
|
|
Full Usage:
this.RenderInstanced
Parameters:
RenderBuffer3D
grid : CellGrid2D<'T>
occupancy : Occupancy
|
|
|
Fills the context from every populated cell of a 2D footprint grid — square or hex — and emits the instanced draws, one per key. Each cell is its own instance, so a cell that covers several cells draws at one cell; use the occupancy member for those.
|
Full Usage:
this.RenderInstancedWithEffect
Parameters:
RenderBuffer3D
grid : CellGrid2D<'T>
occupancy : Occupancy
shaderForKey : 'K -> Effect voption
|
|
Full Usage:
this.RenderInstancedWithEffect
Parameters:
RenderBuffer3D
grid : CellGrid2D<'T>
shaderForKey : 'K -> Effect voption
|
|
Full Usage:
this.RenderWindowInstanced
Parameters:
RenderBuffer3D
left : int
top : int
right : int
bottom : int
grid : CellGrid2D<'T>
occupancy : Occupancy
|
|
Full Usage:
this.RenderWindowInstanced
Parameters:
RenderBuffer3D
left : int
top : int
right : int
bottom : int
grid : CellGrid2D<'T>
|
Like
|
Full Usage:
this.RenderWindowInstancedWithEffect
Parameters:
RenderBuffer3D
left : int
top : int
right : int
bottom : int
grid : CellGrid2D<'T>
occupancy : Occupancy
shaderForKey : 'K -> Effect voption
|
|
Full Usage:
this.RenderWindowInstancedWithEffect
Parameters:
RenderBuffer3D
left : int
top : int
right : int
bottom : int
grid : CellGrid2D<'T>
shaderForKey : 'K -> Effect voption
|
|
Full Usage:
this.ResetFrameBuffers
|
Returns pooled snapshot arrays to ArrayPool
and clears internal tracking state. Call once per frame before
invoking Skippable if GC pressure from instanced rendering is acceptable, but recommended for steady-state zero-alloc rendering. |
Static members
| Static member |
Description
|
Full Usage:
InstancedRenderContext.Rect(getKey, getMeshesAndMaterial, getTransform)
Parameters:
'T -> 'K
getMeshesAndMaterial : 'T -> (PrimitiveMesh * Material3D)[]
getTransform : CellRect -> Vector3 -> 'T -> Matrix
Returns: InstancedRenderContext<'T, 'K>
|
Builds a context whose transform receives the rectangle each instance
covers — the anchor's own cell on the cell-walk members, the anchor's
rectangle on the occupancy members — so one model scales to the cells it
stands for:
|
Mibo