Class TextCollider
Builds the collider of solid lettering: one convex hull per glyph, placed where the glyph sits in the text, inside a single ConvexHullCollider.
public static class TextCollider
- Inheritance
-
TextCollider
Remarks
A hull fills a glyph's holes and its concave bays, so an O collides as a disc and a C as a D; for
letters that tumble and pile up that is right, and it is cheap. Lettering that must be walked into
or shot through its holes wants a MeshCollider on a static instead.
The hulls of a string are kept with the font that shaped them, keyed by the text and the options, so a word dropped a hundred times shares one set and Stride's own cache of built Bepu hulls hits. Two fonts of the same name are two fonts: each has its own store, released with it. A store holds 64 strings and starts again when a 65th arrives; a counter that changes every frame does not fill it for ever.
A mass on the options is the word's: the toolkit divides it among the hulls, since Bepu adds a hull's mass once per hull.
Methods
Create(TextShape)
Creates the collider of text.
public static ConvexHullCollider Create(Primitive3D.TextShape text)
Parameters
textPrimitive3D.TextShapeThe lettering, as
Primitive3D.Textmakes it.
Returns
- ConvexHullCollider
A collider with one hull per glyph.
Exceptions
- ArgumentNullException
The shape is null.
- ArgumentException
The text has no glyph with a shape: nothing to collide with.
CreateHulls(MeshFont, string, TextMeshOptions?)
The hulls of a string, one per glyph, shared between every body that shows the same lettering with the same options.
public static DecomposedHulls CreateHulls(MeshFont font, string text, TextMeshOptions? options = null)
Parameters
fontMeshFontThe font.
textstringThe text.
optionsTextMeshOptionsSize, depth and layout, the same as the mesh's.
Returns
- DecomposedHulls
The hulls, placed where the glyphs sit.
Exceptions
- ArgumentNullException
The font or the text is null.
- ArgumentException
The text has no glyph with a shape.
HullCount(ConvexHullCollider)
How many hulls a collider holds: one per glyph for lettering, which is what a mass given for the whole word is divided by.
public static int HullCount(ConvexHullCollider collider)
Parameters
colliderConvexHullColliderThe collider.
Returns
- int
The number of hulls, at least 1.
Exceptions
- ArgumentNullException
The collider is null.