MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _rendering_update

Method _rendering_update

scene/2d/tile_map_layer.cpp:212–464  ·  view source on GitHub ↗

////////////////////////// Rendering //////////////////////////////////////

Source from the content-addressed store, hash-verified

210
211/////////////////////////////// Rendering //////////////////////////////////////
212void TileMapLayer::_rendering_update(bool p_force_cleanup) {
213 RenderingServer *rs = RenderingServer::get_singleton();
214
215 // Check if we should cleanup everything.
216 bool forced_cleanup = p_force_cleanup || !enabled || tile_set.is_null() || !is_visible_in_tree();
217
218 // ----------- Layer level processing -----------
219 if (!forced_cleanup) {
220 // Modulate the layer.
221 Color layer_modulate = get_modulate();
222#ifdef TOOLS_ENABLED
223 if (highlight_mode == HIGHLIGHT_MODE_BELOW) {
224 layer_modulate = layer_modulate.darkened(0.5);
225 } else if (highlight_mode == HIGHLIGHT_MODE_ABOVE) {
226 layer_modulate = layer_modulate.darkened(0.5);
227 layer_modulate.a *= 0.3;
228 }
229#endif // TOOLS_ENABLED
230 rs->canvas_item_set_modulate(get_canvas_item(), layer_modulate);
231 }
232
233 // ----------- Quadrants processing -----------
234
235 // List all rendering quadrants to update, creating new ones if needed.
236 SelfList<RenderingQuadrant>::List dirty_rendering_quadrant_list;
237
238 // Check if anything changed that might change the quadrant shape.
239 // If so, recreate everything.
240 bool quadrant_shape_changed = dirty.flags[DIRTY_FLAGS_LAYER_Y_SORT_ENABLED] || dirty.flags[DIRTY_FLAGS_TILE_SET] ||
241 (is_y_sort_enabled() && (dirty.flags[DIRTY_FLAGS_LAYER_Y_SORT_ORIGIN] || dirty.flags[DIRTY_FLAGS_LAYER_X_DRAW_ORDER_REVERSED] || dirty.flags[DIRTY_FLAGS_LAYER_LOCAL_TRANSFORM])) ||
242 (!is_y_sort_enabled() && dirty.flags[DIRTY_FLAGS_LAYER_RENDERING_QUADRANT_SIZE]);
243
244 // Free all quadrants.
245 if (forced_cleanup || quadrant_shape_changed) {
246 for (const KeyValue<Vector2i, Ref<RenderingQuadrant>> &kv : rendering_quadrant_map) {
247 for (const RID &ci : kv.value->canvas_items) {
248 if (ci.is_valid()) {
249 rs->free(ci);
250 }
251 }
252 kv.value->cells.clear();
253 }
254 rendering_quadrant_map.clear();
255 _rendering_was_cleaned_up = true;
256 }
257
258 if (!forced_cleanup) {
259 // List all quadrants to update, recreating them if needed.
260 if (dirty.flags[DIRTY_FLAGS_TILE_SET] || dirty.flags[DIRTY_FLAGS_LAYER_IN_TREE] || _rendering_was_cleaned_up) {
261 // Update all cells.
262 for (KeyValue<Vector2i, CellData> &kv : tile_map_layer_data) {
263 CellData &cell_data = kv.value;
264 _rendering_quadrants_update_cell(cell_data, dirty_rendering_quadrant_list);
265 }
266 } else {
267 // Update dirty cells.
268 for (SelfList<CellData> *cell_data_list_element = dirty.cell_list.first(); cell_data_list_element; cell_data_list_element = cell_data_list_element->next()) {
269 CellData &cell_data = *cell_data_list_element->self();

Callers

nothing calls this directly

Calls 15

RIDClass · 0.85
RandomPCGClass · 0.85
darkenedMethod · 0.80
firstMethod · 0.80
selfMethod · 0.80
get_tile_dataMethod · 0.80

Tested by

no test coverage detected