MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / UpdateLayout

Method UpdateLayout

Source/Engine/UI/TextRender.cpp:123–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123void TextRender::UpdateLayout()
124{
125 PROFILE_CPU();
126 PROFILE_MEM(UI);
127
128 // Clear
129 _ib.Clear();
130 _vb.Clear();
131 _localBox = BoundingBox(Vector3::Zero);
132 BoundingBox::Transform(_localBox, _transform, _box);
133 BoundingSphere::FromBox(_box, _sphere);
134#if MODEL_USE_PRECISE_MESH_INTERSECTS
135 _collisionProxy.Clear();
136#endif
137
138 // Skip if no font in use
139 if (Font == nullptr || !Font->IsLoaded())
140 return;
141
142 // Skip if material is not ready
143 if (Material == nullptr || !Material->IsLoaded() || !Material->IsReady())
144 return;
145
146 // Clear flag
147 _isDirty = false;
148
149 // Skip if no need to calculate the layout
150 String textData;
151 String* textPtr = &_text.Value;
152 if (textPtr->IsEmpty())
153 {
154 if (_text.Id.IsEmpty())
155 return;
156 textData = Localization::GetString(_text.Id);
157 textPtr = &textData;
158 if (!_isLocalized)
159 {
160 _isLocalized = true;
161 Localization::LocalizationChanged.Bind<TextRender, &TextRender::UpdateLayout>(this);
162 }
163 if (textPtr->IsEmpty())
164 return;
165 }
166 else if (_isLocalized)
167 {
168 _isLocalized = false;
169 Localization::LocalizationChanged.Unbind<TextRender, &TextRender::UpdateLayout>(this);
170 }
171 const String& text = *textPtr;
172
173 // Pick a font (remove DPI text scale as the text is being placed in the world)
174 auto font = Font->CreateFont(_size);
175 float scale = _layoutOptions.Scale / FontManager::FontScale;
176
177 // Prepare
178 FontTextureAtlas* fontAtlas = nullptr;
179 Float2 invAtlasSize = Float2::One;
180 FontCharacterEntry previous;

Callers

nothing calls this directly

Calls 15

Float2Class · 0.85
CreateFontMethod · 0.80
ProcessTextMethod · 0.80
GetCharacterMethod · 0.80
EnsureTextureCreatedMethod · 0.80
SetBaseMaterialMethod · 0.80
GetKerningMethod · 0.80
UpdateActorMethod · 0.80
BoundingBoxClass · 0.50
TransformClass · 0.50
GetStringFunction · 0.50
VariantFunction · 0.50

Tested by

no test coverage detected