Merge pull request #70773 from KoBeWi/lector

Add range iterator to LocalVector
This commit is contained in:
Rémi Verschelde 2023-01-21 20:53:29 +01:00
commit c3539b4561
No known key found for this signature in database
GPG Key ID: C3336907360768E1
42 changed files with 473 additions and 503 deletions

View File

@ -444,9 +444,7 @@ private:
params.result_array = nullptr;
params.subindex_array = nullptr;
for (unsigned int n = 0; n < changed_items.size(); n++) {
const BVHHandle &h = changed_items[n];
for (const BVHHandle &h : changed_items) {
// use the expanded aabb for pairing
const BOUNDS &expanded_aabb = tree._pairs[h.id()].expanded_aabb;
BVHABB_CLASS abb;
@ -465,9 +463,7 @@ private:
params.result_count_overall = 0; // might not be needed
tree.cull_aabb(params, false);
for (unsigned int i = 0; i < tree._cull_hits.size(); i++) {
uint32_t ref_id = tree._cull_hits[i];
for (const uint32_t ref_id : tree._cull_hits) {
// don't collide against ourself
if (ref_id == changed_item_ref_id) {
continue;

View File

@ -313,20 +313,20 @@ public:
//remove simplex and continue
simplex_list.erase(simplex->SE);
for (uint32_t k = 0; k < simplex->grid_positions.size(); k++) {
Vector3i p = simplex->grid_positions[k].pos;
acceleration_grid[p.x][p.y][p.z].erase(simplex->grid_positions[k].E);
for (const GridPos &gp : simplex->grid_positions) {
Vector3i p = gp.pos;
acceleration_grid[p.x][p.y][p.z].erase(gp.E);
}
memdelete(simplex);
}
E = N;
}
for (uint32_t j = 0; j < triangles.size(); j++) {
if (triangles[j].bad) {
for (const Triangle &triangle : triangles) {
if (triangle.bad) {
continue;
}
Simplex *new_simplex = memnew(Simplex(triangles[j].triangle[0], triangles[j].triangle[1], triangles[j].triangle[2], i));
Simplex *new_simplex = memnew(Simplex(triangle.triangle[0], triangle.triangle[1], triangle.triangle[2], i));
circum_sphere_compute(points, new_simplex);
new_simplex->SE = simplex_list.push_back(new_simplex);
{

View File

@ -141,21 +141,19 @@ real_t Geometry3D::get_closest_distance_between_segments(const Vector3 &p_p0, co
void Geometry3D::MeshData::optimize_vertices() {
HashMap<int, int> vtx_remap;
for (uint32_t i = 0; i < faces.size(); i++) {
for (uint32_t j = 0; j < faces[i].indices.size(); j++) {
int idx = faces[i].indices[j];
if (!vtx_remap.has(idx)) {
for (MeshData::Face &face : faces) {
for (int &index : face.indices) {
if (!vtx_remap.has(index)) {
int ni = vtx_remap.size();
vtx_remap[idx] = ni;
vtx_remap[index] = ni;
}
faces[i].indices[j] = vtx_remap[idx];
index = vtx_remap[index];
}
}
for (uint32_t i = 0; i < edges.size(); i++) {
int a = edges[i].vertex_a;
int b = edges[i].vertex_b;
for (MeshData::Edge edge : edges) {
int a = edge.vertex_a;
int b = edge.vertex_b;
if (!vtx_remap.has(a)) {
int ni = vtx_remap.size();
@ -166,8 +164,8 @@ void Geometry3D::MeshData::optimize_vertices() {
vtx_remap[b] = ni;
}
edges[i].vertex_a = vtx_remap[a];
edges[i].vertex_b = vtx_remap[b];
edge.vertex_a = vtx_remap[a];
edge.vertex_b = vtx_remap[b];
}
LocalVector<Vector3> new_vertices;
@ -673,10 +671,10 @@ Geometry3D::MeshData Geometry3D::build_convex_mesh(const Vector<Plane> &p_planes
MeshData::Face face;
// Add face indices.
for (uint32_t j = 0; j < vertices.size(); j++) {
for (const Vector3 &vertex : vertices) {
int idx = -1;
for (uint32_t k = 0; k < mesh.vertices.size(); k++) {
if (mesh.vertices[k].distance_to(vertices[j]) < 0.001f) {
if (mesh.vertices[k].distance_to(vertex) < 0.001f) {
idx = k;
break;
}
@ -684,7 +682,7 @@ Geometry3D::MeshData Geometry3D::build_convex_mesh(const Vector<Plane> &p_planes
if (idx == -1) {
idx = mesh.vertices.size();
mesh.vertices.push_back(vertices[j]);
mesh.vertices.push_back(vertex);
}
face.indices.push_back(idx);

View File

@ -99,8 +99,7 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) {
}
}
for (unsigned int i = 0; i < to_remove.size(); i++) {
List<Operation>::Element *E = to_remove[i];
for (List<Operation>::Element *E : to_remove) {
// Delete all object references
E->get().delete_reference();
E->erase();

View File

@ -377,11 +377,11 @@ void WorkerThreadPool::wait_for_group_task_completion(GroupID p_group) {
Group *group = *groupp;
if (group->low_priority_native_tasks.size() > 0) {
for (uint32_t i = 0; i < group->low_priority_native_tasks.size(); i++) {
group->low_priority_native_tasks[i]->low_priority_thread->wait_to_finish();
native_thread_allocator.free(group->low_priority_native_tasks[i]->low_priority_thread);
for (Task *task : group->low_priority_native_tasks) {
task->low_priority_thread->wait_to_finish();
native_thread_allocator.free(task->low_priority_thread);
task_mutex.lock();
task_allocator.free(group->low_priority_native_tasks[i]);
task_allocator.free(task);
task_mutex.unlock();
}
@ -449,8 +449,8 @@ void WorkerThreadPool::finish() {
task_available_semaphore.post();
}
for (uint32_t i = 0; i < threads.size(); i++) {
threads[i].thread.wait_to_finish();
for (ThreadData &data : threads) {
data.thread.wait_to_finish();
}
threads.clear();

View File

@ -169,6 +169,70 @@ public:
return data[p_index];
}
struct Iterator {
_FORCE_INLINE_ T &operator*() const {
return *elem_ptr;
}
_FORCE_INLINE_ T *operator->() const { return elem_ptr; }
_FORCE_INLINE_ Iterator &operator++() {
elem_ptr++;
return *this;
}
_FORCE_INLINE_ Iterator &operator--() {
elem_ptr--;
return *this;
}
_FORCE_INLINE_ bool operator==(const Iterator &b) const { return elem_ptr == b.elem_ptr; }
_FORCE_INLINE_ bool operator!=(const Iterator &b) const { return elem_ptr != b.elem_ptr; }
Iterator(T *p_ptr) { elem_ptr = p_ptr; }
Iterator() {}
Iterator(const Iterator &p_it) { elem_ptr = p_it.elem_ptr; }
private:
T *elem_ptr = nullptr;
};
struct ConstIterator {
_FORCE_INLINE_ const T &operator*() const {
return *elem_ptr;
}
_FORCE_INLINE_ const T *operator->() const { return elem_ptr; }
_FORCE_INLINE_ ConstIterator &operator++() {
elem_ptr++;
return *this;
}
_FORCE_INLINE_ ConstIterator &operator--() {
elem_ptr--;
return *this;
}
_FORCE_INLINE_ bool operator==(const ConstIterator &b) const { return elem_ptr == b.elem_ptr; }
_FORCE_INLINE_ bool operator!=(const ConstIterator &b) const { return elem_ptr != b.elem_ptr; }
ConstIterator(const T *p_ptr) { elem_ptr = p_ptr; }
ConstIterator() {}
ConstIterator(const ConstIterator &p_it) { elem_ptr = p_it.elem_ptr; }
private:
const T *elem_ptr = nullptr;
};
_FORCE_INLINE_ Iterator begin() {
return Iterator(data);
}
_FORCE_INLINE_ Iterator end() {
return Iterator(data + size());
}
_FORCE_INLINE_ ConstIterator begin() const {
return ConstIterator(ptr());
}
_FORCE_INLINE_ ConstIterator end() const {
return ConstIterator(ptr() + size());
}
void insert(U p_pos, T p_val) {
ERR_FAIL_UNSIGNED_INDEX(p_pos, count + 1);
if (p_pos == count) {

View File

@ -151,8 +151,8 @@ void unregister_named_setters_getters() {
bool Variant::has_member(Variant::Type p_type, const StringName &p_member) {
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
for (uint32_t i = 0; i < variant_setters_getters_names[p_type].size(); i++) {
if (variant_setters_getters_names[p_type][i] == p_member) {
for (const StringName &member : variant_setters_getters_names[p_type]) {
if (member == p_member) {
return true;
}
}
@ -172,8 +172,8 @@ Variant::Type Variant::get_member_type(Variant::Type p_type, const StringName &p
}
void Variant::get_member_list(Variant::Type p_type, List<StringName> *r_members) {
for (uint32_t i = 0; i < variant_setters_getters_names[p_type].size(); i++) {
r_members->push_back(variant_setters_getters_names[p_type][i]);
for (const StringName &member : variant_setters_getters_names[p_type]) {
r_members->push_back(member);
}
}

View File

@ -353,11 +353,11 @@ Error VulkanContext::_get_preferred_validation_layers(uint32_t *count, const cha
ERR_FAIL_V(ERR_CANT_CREATE);
}
for (uint32_t i = 0; i < instance_validation_layers_alt.size(); i++) {
if (_check_layers(instance_validation_layers_alt[i].size(), instance_validation_layers_alt[i].ptr(), instance_layer_count, instance_layers)) {
*count = instance_validation_layers_alt[i].size();
for (const LocalVector<const char *> &layer : instance_validation_layers_alt) {
if (_check_layers(layer.size(), layer.ptr(), instance_layer_count, instance_layers)) {
*count = layer.size();
if (names != nullptr) {
*names = instance_validation_layers_alt[i].ptr();
*names = layer.ptr();
}
break;
}

View File

@ -2181,8 +2181,7 @@ void EditorInspectorArray::_notification(int p_what) {
odd_style->set_bg_color(color.darkened(-0.08));
even_style->set_bg_color(color.darkened(0.08));
for (int i = 0; i < (int)array_elements.size(); i++) {
ArrayElement &ae = array_elements[i];
for (ArrayElement &ae : array_elements) {
if (ae.move_texture_rect) {
ae.move_texture_rect->set_texture(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons")));
}

View File

@ -230,10 +230,10 @@ void EditorToaster::_auto_hide_or_free_toasts() {
}
// Delete the control right away (removed as child) as it might cause issues otherwise when iterative over the vbox_container children.
for (unsigned int i = 0; i < to_delete.size(); i++) {
vbox_container->remove_child(to_delete[i]);
to_delete[i]->queue_free();
toasts.erase(to_delete[i]);
for (Control *c : to_delete) {
vbox_container->remove_child(c);
c->queue_free();
toasts.erase(c);
}
if (toasts.is_empty()) {

View File

@ -503,8 +503,8 @@ bool EditorExportPlatform::_export_customize_dictionary(Dictionary &dict, LocalV
case Variant::OBJECT: {
Ref<Resource> res = v;
if (res.is_valid()) {
for (uint32_t j = 0; j < customize_resources_plugins.size(); j++) {
Ref<Resource> new_res = customize_resources_plugins[j]->_customize_resource(res, "");
for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) {
Ref<Resource> new_res = plugin->_customize_resource(res, "");
if (new_res.is_valid()) {
changed = true;
if (new_res != res) {
@ -550,8 +550,8 @@ bool EditorExportPlatform::_export_customize_array(Array &arr, LocalVector<Ref<E
case Variant::OBJECT: {
Ref<Resource> res = v;
if (res.is_valid()) {
for (uint32_t j = 0; j < customize_resources_plugins.size(); j++) {
Ref<Resource> new_res = customize_resources_plugins[j]->_customize_resource(res, "");
for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) {
Ref<Resource> new_res = plugin->_customize_resource(res, "");
if (new_res.is_valid()) {
changed = true;
if (new_res != res) {
@ -597,8 +597,8 @@ bool EditorExportPlatform::_export_customize_object(Object *p_object, LocalVecto
case Variant::OBJECT: {
Ref<Resource> res = p_object->get(E.name);
if (res.is_valid()) {
for (uint32_t j = 0; j < customize_resources_plugins.size(); j++) {
Ref<Resource> new_res = customize_resources_plugins[j]->_customize_resource(res, "");
for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) {
Ref<Resource> new_res = plugin->_customize_resource(res, "");
if (new_res.is_valid()) {
changed = true;
if (new_res != res) {
@ -715,16 +715,16 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector
ERR_FAIL_COND_V(ps.is_null(), p_path);
Node *node = ps->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE); // Make sure the child scene root gets the correct inheritance chain.
ERR_FAIL_COND_V(node == nullptr, p_path);
if (customize_scenes_plugins.size()) {
for (uint32_t i = 0; i < customize_scenes_plugins.size(); i++) {
Node *customized = customize_scenes_plugins[i]->_customize_scene(node, p_path);
if (!customize_scenes_plugins.is_empty()) {
for (Ref<EditorExportPlugin> &plugin : customize_scenes_plugins) {
Node *customized = plugin->_customize_scene(node, p_path);
if (customized != nullptr) {
node = customized;
modified = true;
}
}
}
if (customize_resources_plugins.size()) {
if (!customize_resources_plugins.is_empty()) {
if (_export_customize_scene_resources(node, node, customize_resources_plugins)) {
modified = true;
}
@ -746,9 +746,9 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector
Ref<Resource> res = ResourceLoader::load(p_path, "", ResourceFormatLoader::CACHE_MODE_IGNORE);
ERR_FAIL_COND_V(res.is_null(), p_path);
if (customize_resources_plugins.size()) {
for (uint32_t i = 0; i < customize_resources_plugins.size(); i++) {
Ref<Resource> new_res = customize_resources_plugins[i]->_customize_resource(res, p_path);
if (!customize_resources_plugins.is_empty()) {
for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) {
Ref<Resource> new_res = plugin->_customize_resource(res, p_path);
if (new_res.is_valid()) {
modified = true;
if (new_res != res) {
@ -960,7 +960,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
bool convert_text_to_binary = GLOBAL_GET("editor/export/convert_text_resources_to_binary");
if (convert_text_to_binary || customize_resources_plugins.size() || customize_scenes_plugins.size()) {
if (convert_text_to_binary || !customize_resources_plugins.is_empty() || !customize_scenes_plugins.is_empty()) {
// See if we have something to open
Ref<FileAccess> f = FileAccess::open(export_base_path.path_join("file_cache"), FileAccess::READ);
if (f.is_valid()) {
@ -1179,7 +1179,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
idx++;
}
if (convert_text_to_binary || customize_resources_plugins.size() || customize_scenes_plugins.size()) {
if (convert_text_to_binary || !customize_resources_plugins.is_empty() || !customize_scenes_plugins.is_empty()) {
// End scene customization
String fcache = export_base_path.path_join("file_cache");
@ -1196,12 +1196,12 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
ERR_PRINT("Error opening export file cache: " + fcache);
}
for (uint32_t i = 0; i < customize_resources_plugins.size(); i++) {
customize_resources_plugins[i]->_end_customize_resources();
for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) {
plugin->_end_customize_resources();
}
for (uint32_t i = 0; i < customize_scenes_plugins.size(); i++) {
customize_scenes_plugins[i]->_end_customize_scenes();
for (Ref<EditorExportPlugin> &plugin : customize_scenes_plugins) {
plugin->_end_customize_scenes();
}
}
//save config!

View File

@ -566,9 +566,9 @@ int BoneMapper::search_bone_by_name(Skeleton3D *p_skeleton, Vector<String> p_pic
if (hit_list.size() > 0) {
shortest = hit_list[0];
for (uint32_t i = 0; i < hit_list.size(); i++) {
if (hit_list[i].length() < shortest.length()) {
shortest = hit_list[i]; // Prioritize parent.
for (const String &hit : hit_list) {
if (hit.length() < shortest.length()) {
shortest = hit; // Prioritize parent.
}
}
}
@ -592,9 +592,9 @@ int BoneMapper::search_bone_by_name(Skeleton3D *p_skeleton, Vector<String> p_pic
if (hit_list.size() > 0) {
shortest = hit_list[0];
for (uint32_t i = 0; i < hit_list.size(); i++) {
if (hit_list[i].length() <= shortest.length()) {
shortest = hit_list[i]; // Prioritize parent.
for (const String &hit : hit_list) {
if (hit.length() <= shortest.length()) {
shortest = hit; // Prioritize parent.
}
}
}

View File

@ -43,10 +43,10 @@
void ShaderEditorPlugin::_update_shader_list() {
shader_list->clear();
for (uint32_t i = 0; i < edited_shaders.size(); i++) {
Ref<Resource> shader = edited_shaders[i].shader;
for (EditedShader &edited_shader : edited_shaders) {
Ref<Resource> shader = edited_shader.shader;
if (shader.is_null()) {
shader = edited_shaders[i].shader_inc;
shader = edited_shader.shader_inc;
}
String path = shader->get_path();
@ -62,8 +62,8 @@ void ShaderEditorPlugin::_update_shader_list() {
}
bool unsaved = false;
if (edited_shaders[i].shader_editor) {
unsaved = edited_shaders[i].shader_editor->is_unsaved();
if (edited_shader.shader_editor) {
unsaved = edited_shader.shader_editor->is_unsaved();
}
// TODO: Handle visual shaders too.
@ -86,7 +86,7 @@ void ShaderEditorPlugin::_update_shader_list() {
}
for (int i = FILE_SAVE; i < FILE_MAX; i++) {
file_menu->get_popup()->set_item_disabled(file_menu->get_popup()->get_item_index(i), edited_shaders.size() == 0);
file_menu->get_popup()->set_item_disabled(file_menu->get_popup()->get_item_index(i), edited_shaders.is_empty());
}
_update_shader_list_status();
@ -175,36 +175,36 @@ void ShaderEditorPlugin::selected_notify() {
}
TextShaderEditor *ShaderEditorPlugin::get_shader_editor(const Ref<Shader> &p_for_shader) {
for (uint32_t i = 0; i < edited_shaders.size(); i++) {
if (edited_shaders[i].shader == p_for_shader) {
return edited_shaders[i].shader_editor;
for (EditedShader &edited_shader : edited_shaders) {
if (edited_shader.shader == p_for_shader) {
return edited_shader.shader_editor;
}
}
return nullptr;
}
VisualShaderEditor *ShaderEditorPlugin::get_visual_shader_editor(const Ref<Shader> &p_for_shader) {
for (uint32_t i = 0; i < edited_shaders.size(); i++) {
if (edited_shaders[i].shader == p_for_shader) {
return edited_shaders[i].visual_shader_editor;
for (EditedShader &edited_shader : edited_shaders) {
if (edited_shader.shader == p_for_shader) {
return edited_shader.visual_shader_editor;
}
}
return nullptr;
}
void ShaderEditorPlugin::save_external_data() {
for (uint32_t i = 0; i < edited_shaders.size(); i++) {
if (edited_shaders[i].shader_editor) {
edited_shaders[i].shader_editor->save_external_data();
for (EditedShader &edited_shader : edited_shaders) {
if (edited_shader.shader_editor) {
edited_shader.shader_editor->save_external_data();
}
}
_update_shader_list();
}
void ShaderEditorPlugin::apply_changes() {
for (uint32_t i = 0; i < edited_shaders.size(); i++) {
if (edited_shaders[i].shader_editor) {
edited_shaders[i].shader_editor->apply_shaders();
for (EditedShader &edited_shader : edited_shaders) {
if (edited_shader.shader_editor) {
edited_shader.shader_editor->apply_shaders();
}
}
}
@ -234,8 +234,8 @@ void ShaderEditorPlugin::_close_shader(int p_index) {
void ShaderEditorPlugin::_resource_saved(Object *obj) {
// May have been renamed on save.
for (uint32_t i = 0; i < edited_shaders.size(); i++) {
if (edited_shaders[i].shader.ptr() == obj) {
for (EditedShader &edited_shader : edited_shaders) {
if (edited_shader.shader.ptr() == obj) {
_update_shader_list();
return;
}

View File

@ -169,8 +169,7 @@ void GenericTilePolygonEditor::_base_control_draw() {
}
// Draw the polygons.
for (unsigned int i = 0; i < polygons.size(); i++) {
const Vector<Vector2> &polygon = polygons[i];
for (const Vector<Vector2> &polygon : polygons) {
Color color = polygon_color;
if (!in_creation_polygon.is_empty()) {
color = color.darkened(0.3);
@ -285,8 +284,8 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_do_method(this, "emit_signal", "polygons_changed");
undo_redo->add_undo_method(this, "clear_polygons");
for (unsigned int i = 0; i < polygons.size(); i++) {
undo_redo->add_undo_method(this, "add_polygon", polygons[i]);
for (const PackedVector2Array &poly : polygons) {
undo_redo->add_undo_method(this, "add_polygon", poly);
}
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");
@ -298,8 +297,8 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_do_method(this, "emit_signal", "polygons_changed");
undo_redo->add_undo_method(this, "clear_polygons");
for (unsigned int i = 0; i < polygons.size(); i++) {
undo_redo->add_undo_method(this, "add_polygon", polygons[i]);
for (const PackedVector2Array &polygon : polygons) {
undo_redo->add_undo_method(this, "add_polygon", polygon);
}
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");
@ -327,8 +326,8 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
}
for (unsigned int i = 0; i < polygons.size(); i++) {
Vector<Point2> new_polygon;
for (int point_index = 0; point_index < polygons[i].size(); point_index++) {
Vector2 point = polygons[i][point_index];
for (const Vector2 &vec : polygons[i]) {
Vector2 point = vec;
switch (p_item_pressed) {
case ROTATE_RIGHT: {
point = Vector2(-point.y, point.x);
@ -351,8 +350,8 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
}
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_do_method(this, "emit_signal", "polygons_changed");
for (unsigned int i = 0; i < polygons.size(); i++) {
undo_redo->add_undo_method(this, "set_polygon", polygons[i]);
for (const PackedVector2Array &polygon : polygons) {
undo_redo->add_undo_method(this, "set_polygon", polygon);
}
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");

View File

@ -3088,8 +3088,8 @@ void TileMapEditorTerrainsPlugin::_update_terrains_cache() {
per_terrain_terrains_patterns.resize(tile_set->get_terrain_sets_count());
for (int i = 0; i < tile_set->get_terrain_sets_count(); i++) {
per_terrain_terrains_patterns[i].resize(tile_set->get_terrains_count(i));
for (int j = 0; j < (int)per_terrain_terrains_patterns[i].size(); j++) {
per_terrain_terrains_patterns[i][j].clear();
for (RBSet<TileSet::TerrainsPattern> &pattern : per_terrain_terrains_patterns[i]) {
pattern.clear();
}
}
@ -3519,8 +3519,8 @@ void TileMapEditor::_update_bottom_panel() {
// Update the visibility of controls.
missing_tileset_label->set_visible(!tile_set.is_valid());
for (unsigned int tab_index = 0; tab_index < tabs_data.size(); tab_index++) {
tabs_data[tab_index].panel->hide();
for (TileMapEditorPlugin::TabData &tab_data : tabs_data) {
tab_data.panel->hide();
}
if (tile_set.is_valid()) {
tabs_data[tabs_bar->get_current_tab()].panel->show();
@ -3609,15 +3609,15 @@ void TileMapEditor::_tab_changed(int p_tab_id) {
tabs_plugins[tabs_bar->get_current_tab()]->edit(tile_map_id, tile_map_layer);
// Update toolbar.
for (unsigned int tab_index = 0; tab_index < tabs_data.size(); tab_index++) {
tabs_data[tab_index].toolbar->hide();
for (TileMapEditorPlugin::TabData &tab_data : tabs_data) {
tab_data.toolbar->hide();
}
tabs_data[p_tab_id].toolbar->show();
// Update visible panel.
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
for (unsigned int tab_index = 0; tab_index < tabs_data.size(); tab_index++) {
tabs_data[tab_index].panel->hide();
for (TileMapEditorPlugin::TabData &tab_data : tabs_data) {
tab_data.panel->hide();
}
if (tile_map && tile_map->get_tileset().is_valid()) {
tabs_data[tabs_bar->get_current_tab()].panel->show();
@ -3994,10 +3994,10 @@ TileMapEditor::TileMapEditor() {
tile_map_toolbar->add_child(tabs_bar);
// Tabs toolbars.
for (unsigned int tab_index = 0; tab_index < tabs_data.size(); tab_index++) {
tabs_data[tab_index].toolbar->hide();
if (!tabs_data[tab_index].toolbar->get_parent()) {
tile_map_toolbar->add_child(tabs_data[tab_index].toolbar);
for (TileMapEditorPlugin::TabData &tab_data : tabs_data) {
tab_data.toolbar->hide();
if (!tab_data.toolbar->get_parent()) {
tile_map_toolbar->add_child(tab_data.toolbar);
}
}

View File

@ -1977,8 +1977,8 @@ public:
}
}
~RegExContainer() {
for (unsigned int i = 0; i < color_regexes.size(); i++) {
memdelete(color_regexes[i]);
for (RegEx *regex : color_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < class_tscn_regexes.size(); i++) {
memdelete(class_tscn_regexes[i]);
@ -1986,38 +1986,38 @@ public:
memdelete(class_shader_regexes[i]);
memdelete(class_regexes[i]);
}
for (unsigned int i = 0; i < enum_regexes.size(); i++) {
memdelete(enum_regexes[i]);
for (RegEx *regex : enum_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < gdscript_function_regexes.size(); i++) {
memdelete(gdscript_function_regexes[i]);
for (RegEx *regex : gdscript_function_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < project_settings_regexes.size(); i++) {
memdelete(project_settings_regexes[i]);
for (RegEx *regex : project_settings_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < input_map_regexes.size(); i++) {
memdelete(input_map_regexes[i]);
for (RegEx *regex : input_map_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < gdscript_properties_regexes.size(); i++) {
memdelete(gdscript_properties_regexes[i]);
for (RegEx *regex : gdscript_properties_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < gdscript_signals_regexes.size(); i++) {
memdelete(gdscript_signals_regexes[i]);
for (RegEx *regex : gdscript_signals_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < shaders_regexes.size(); i++) {
memdelete(shaders_regexes[i]);
for (RegEx *regex : shaders_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < builtin_types_regexes.size(); i++) {
memdelete(builtin_types_regexes[i]);
for (RegEx *regex : builtin_types_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < csharp_function_regexes.size(); i++) {
memdelete(csharp_function_regexes[i]);
for (RegEx *regex : csharp_function_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < csharp_properties_regexes.size(); i++) {
memdelete(csharp_properties_regexes[i]);
for (RegEx *regex : csharp_properties_regexes) {
memdelete(regex);
}
for (unsigned int i = 0; i < csharp_signal_regexes.size(); i++) {
memdelete(csharp_signal_regexes[i]);
for (RegEx *regex : csharp_signal_regexes) {
memdelete(regex);
}
}
};

View File

@ -731,24 +731,21 @@ COMMAND_1(free, RID, p_object) {
NavMap *map = map_owner.get_or_null(p_object);
// Removes any assigned region
LocalVector<NavRegion *> regions = map->get_regions();
for (uint32_t i = 0; i < regions.size(); i++) {
map->remove_region(regions[i]);
regions[i]->set_map(nullptr);
for (NavRegion *region : map->get_regions()) {
map->remove_region(region);
region->set_map(nullptr);
}
// Removes any assigned links
LocalVector<NavLink *> links = map->get_links();
for (uint32_t i = 0; i < links.size(); i++) {
map->remove_link(links[i]);
links[i]->set_map(nullptr);
for (NavLink *link : map->get_links()) {
map->remove_link(link);
link->set_map(nullptr);
}
// Remove any assigned agent
LocalVector<RvoAgent *> agents = map->get_agents();
for (uint32_t i = 0; i < agents.size(); i++) {
map->remove_agent(agents[i]);
agents[i]->set_map(nullptr);
for (RvoAgent *agent : map->get_agents()) {
map->remove_agent(agent);
agent->set_map(nullptr);
}
int map_index = active_maps.find(map);
@ -806,9 +803,9 @@ void GodotNavigationServer::flush_queries() {
MutexLock lock(commands_mutex);
MutexLock lock2(operations_mutex);
for (size_t i(0); i < commands.size(); i++) {
commands[i]->exec(this);
memdelete(commands[i]);
for (SetCommand *command : commands) {
command->exec(this);
memdelete(command);
}
commands.clear();
}

View File

@ -103,9 +103,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
float begin_d = 1e20;
float end_d = 1e20;
// Find the initial poly and the end poly on this map.
for (size_t i(0); i < polygons.size(); i++) {
const gd::Polygon &p = polygons[i];
for (const gd::Polygon &p : polygons) {
// Only consider the polygon if it in a region with compatible layers.
if ((p_navigation_layers & p.owner->get_navigation_layers()) == 0) {
continue;
@ -190,9 +188,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
while (true) {
// Takes the current least_cost_poly neighbors (iterating over its edges) and compute the traveled_distance.
for (size_t i = 0; i < navigation_polys[least_cost_id].poly->edges.size(); i++) {
const gd::Edge &edge = navigation_polys[least_cost_id].poly->edges[i];
for (const gd::Edge &edge : navigation_polys[least_cost_id].poly->edges) {
// Iterate over connections in this edge, then compute the new optimized travel distance assigned to this polygon.
for (int connection_index = 0; connection_index < edge.connections.size(); connection_index++) {
const gd::Edge::Connection &connection = edge.connections[connection_index];
@ -465,9 +461,7 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector
Vector3 closest_point;
real_t closest_point_d = 1e20;
for (size_t i(0); i < polygons.size(); i++) {
const gd::Polygon &p = polygons[i];
for (const gd::Polygon &p : polygons) {
// For each face check the distance to the segment
for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) {
const Face3 f(p.points[0].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
@ -623,20 +617,20 @@ void NavMap::sync() {
// Check if we need to update the links.
if (regenerate_polygons) {
for (uint32_t r = 0; r < regions.size(); r++) {
regions[r]->scratch_polygons();
for (NavRegion *region : regions) {
region->scratch_polygons();
}
regenerate_links = true;
}
for (uint32_t r = 0; r < regions.size(); r++) {
if (regions[r]->sync()) {
for (NavRegion *region : regions) {
if (region->sync()) {
regenerate_links = true;
}
}
for (uint32_t l = 0; l < links.size(); l++) {
if (links[l]->check_dirty()) {
for (NavLink *link : links) {
if (link->check_dirty()) {
regenerate_links = true;
}
}
@ -649,34 +643,32 @@ void NavMap::sync() {
_new_pm_edge_free_count = 0;
// Remove regions connections.
for (uint32_t r = 0; r < regions.size(); r++) {
regions[r]->get_connections().clear();
for (NavRegion *region : regions) {
region->get_connections().clear();
}
// Resize the polygon count.
int count = 0;
for (uint32_t r = 0; r < regions.size(); r++) {
count += regions[r]->get_polygons().size();
for (const NavRegion *region : regions) {
count += region->get_polygons().size();
}
polygons.resize(count);
// Copy all region polygons in the map.
count = 0;
for (uint32_t r = 0; r < regions.size(); r++) {
const LocalVector<gd::Polygon> &polygons_source = regions[r]->get_polygons();
for (const NavRegion *region : regions) {
const LocalVector<gd::Polygon> &polygons_source = region->get_polygons();
for (uint32_t n = 0; n < polygons_source.size(); n++) {
polygons[count + n] = polygons_source[n];
}
count += regions[r]->get_polygons().size();
count += region->get_polygons().size();
}
_new_pm_polygon_count = polygons.size();
// Group all edges per key.
HashMap<gd::EdgeKey, Vector<gd::Edge::Connection>, gd::EdgeKey> connections;
for (uint32_t poly_id = 0; poly_id < polygons.size(); poly_id++) {
gd::Polygon &poly(polygons[poly_id]);
for (gd::Polygon &poly : polygons) {
for (uint32_t p = 0; p < poly.points.size(); p++) {
int next_point = (p + 1) % poly.points.size();
gd::EdgeKey ek(poly.points[p].key, poly.points[next_point].key);
@ -787,8 +779,7 @@ void NavMap::sync() {
link_polygons.resize(links.size());
// Search for polygons within range of a nav link.
for (uint32_t l = 0; l < links.size(); l++) {
const NavLink *link = links[l];
for (const NavLink *link : links) {
const Vector3 start = link->get_start_location();
const Vector3 end = link->get_end_location();
@ -820,9 +811,7 @@ void NavMap::sync() {
}
// Find any polygons within the search radius of the end point.
for (uint32_t end_index = 0; end_index < polygons.size(); end_index++) {
gd::Polygon &end_poly = polygons[end_index];
for (gd::Polygon &end_poly : polygons) {
// For each face check the distance to the end
for (uint32_t end_point_id = 2; end_point_id < end_poly.points.size(); end_point_id += 1) {
const Face3 end_face(end_poly.points[0].pos, end_poly.points[end_point_id - 1].pos, end_poly.points[end_point_id].pos);
@ -906,8 +895,8 @@ void NavMap::sync() {
// cannot use LocalVector here as RVO library expects std::vector to build KdTree
std::vector<RVO::Agent *> raw_agents;
raw_agents.reserve(agents.size());
for (size_t i(0); i < agents.size(); i++) {
raw_agents.push_back(agents[i]->get_agent());
for (RvoAgent *agent : agents) {
raw_agents.push_back(agent->get_agent());
}
rvo.buildAgentTree(raw_agents);
}
@ -941,8 +930,8 @@ void NavMap::step(real_t p_deltatime) {
}
void NavMap::dispatch_callbacks() {
for (int i(0); i < static_cast<int>(controlled_agents.size()); i++) {
controlled_agents[i]->dispatch_callback();
for (RvoAgent *agent : controlled_agents) {
agent->dispatch_callback();
}
}

View File

@ -266,9 +266,7 @@ void NavigationMeshGenerator::_parse_geometry(const Transform3D &p_navmesh_trans
if (err == OK) {
PackedVector3Array faces;
for (uint32_t j = 0; j < md.faces.size(); ++j) {
const Geometry3D::MeshData::Face &face = md.faces[j];
for (const Geometry3D::MeshData::Face &face : md.faces) {
for (uint32_t k = 2; k < face.indices.size(); ++k) {
faces.push_back(md.vertices[face.indices[0]]);
faces.push_back(md.vertices[face.indices[k - 1]]);
@ -392,9 +390,7 @@ void NavigationMeshGenerator::_parse_geometry(const Transform3D &p_navmesh_trans
if (err == OK) {
PackedVector3Array faces;
for (uint32_t j = 0; j < md.faces.size(); ++j) {
const Geometry3D::MeshData::Face &face = md.faces[j];
for (const Geometry3D::MeshData::Face &face : md.faces) {
for (uint32_t k = 2; k < face.indices.size(); ++k) {
faces.push_back(md.vertices[face.indices[0]]);
faces.push_back(md.vertices[face.indices[k - 1]]);

View File

@ -426,8 +426,8 @@ bool RaycastOcclusionCull::Scenario::update() {
return false;
}
for (unsigned int i = 0; i < removed_instances.size(); i++) {
instances.erase(removed_instances[i]);
for (const RID &scenario : removed_instances) {
instances.erase(scenario);
}
if (dirty_instances_array.size() / WorkerThreadPool::get_singleton()->get_thread_count() > 128) {

View File

@ -803,10 +803,10 @@ void TileMap::_make_quadrant_dirty(HashMap<Vector2i, TileMapQuadrant>::Iterator
void TileMap::_make_all_quadrants_dirty() {
// Make all quandrants dirty, then trigger an update later.
for (unsigned int layer = 0; layer < layers.size(); layer++) {
for (KeyValue<Vector2i, TileMapQuadrant> &E : layers[layer].quadrant_map) {
for (TileMapLayer &layer : layers) {
for (KeyValue<Vector2i, TileMapQuadrant> &E : layer.quadrant_map) {
if (!E.value.dirty_list_element.in_list()) {
layers[layer].dirty_quadrant_list.add(&E.value.dirty_list_element);
layer.dirty_quadrant_list.add(&E.value.dirty_list_element);
}
}
}
@ -1014,8 +1014,8 @@ void TileMap::_rendering_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_CANVAS: {
bool node_visible = is_visible_in_tree();
for (int layer = 0; layer < (int)layers.size(); layer++) {
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layers[layer].quadrant_map) {
for (TileMapLayer &layer : layers) {
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layer.quadrant_map) {
TileMapQuadrant &q = E_quadrant.value;
for (const KeyValue<Vector2i, RID> &kv : q.occluders) {
Transform2D xform;
@ -1030,8 +1030,8 @@ void TileMap::_rendering_notification(int p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
bool node_visible = is_visible_in_tree();
for (int layer = 0; layer < (int)layers.size(); layer++) {
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layers[layer].quadrant_map) {
for (TileMapLayer &layer : layers) {
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layer.quadrant_map) {
TileMapQuadrant &q = E_quadrant.value;
// Update occluders transform.
@ -1050,8 +1050,8 @@ void TileMap::_rendering_notification(int p_what) {
if (!is_inside_tree()) {
return;
}
for (int layer = 0; layer < (int)layers.size(); layer++) {
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layers[layer].quadrant_map) {
for (TileMapLayer &layer : layers) {
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layer.quadrant_map) {
TileMapQuadrant &q = E_quadrant.value;
// Update occluders transform.
@ -1071,8 +1071,8 @@ void TileMap::_rendering_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_CANVAS: {
for (int layer = 0; layer < (int)layers.size(); layer++) {
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layers[layer].quadrant_map) {
for (TileMapLayer &layer : layers) {
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layer.quadrant_map) {
TileMapQuadrant &q = E_quadrant.value;
for (const KeyValue<Vector2i, RID> &kv : q.occluders) {
RS::get_singleton()->canvas_light_occluder_attach_to_canvas(kv.value, RID());
@ -1257,16 +1257,16 @@ void TileMap::_rendering_update_dirty_quadrants(SelfList<TileMapQuadrant>::List
if (_rendering_quadrant_order_dirty) {
int index = -(int64_t)0x80000000; //always must be drawn below children.
for (int layer = 0; layer < (int)layers.size(); layer++) {
for (TileMapLayer &layer : layers) {
// Sort the quadrants coords per local coordinates.
RBMap<Vector2i, Vector2i, TileMapQuadrant::CoordsWorldComparator> local_to_map;
for (const KeyValue<Vector2i, TileMapQuadrant> &E : layers[layer].quadrant_map) {
for (const KeyValue<Vector2i, TileMapQuadrant> &E : layer.quadrant_map) {
local_to_map[map_to_local(E.key)] = E.key;
}
// Sort the quadrants.
for (const KeyValue<Vector2i, Vector2i> &E : local_to_map) {
TileMapQuadrant &q = layers[layer].quadrant_map[E.value];
TileMapQuadrant &q = layer.quadrant_map[E.value];
for (const RID &ci : q.canvas_items) {
RS::get_singleton()->canvas_item_set_draw_index(ci, index++);
}
@ -1453,8 +1453,8 @@ void TileMap::_physics_notification(int p_what) {
if (is_inside_tree() && (!collision_animatable || in_editor)) {
// Update the new transform directly if we are not in animatable mode.
Transform2D gl_transform = get_global_transform();
for (int layer = 0; layer < (int)layers.size(); layer++) {
for (KeyValue<Vector2i, TileMapQuadrant> &E : layers[layer].quadrant_map) {
for (TileMapLayer &layer : layers) {
for (KeyValue<Vector2i, TileMapQuadrant> &E : layer.quadrant_map) {
TileMapQuadrant &q = E.value;
for (RID body : q.bodies) {
@ -1476,8 +1476,8 @@ void TileMap::_physics_notification(int p_what) {
if (is_inside_tree() && !in_editor && collision_animatable) {
// Only active when animatable. Send the new transform to the physics...
new_transform = get_global_transform();
for (int layer = 0; layer < (int)layers.size(); layer++) {
for (KeyValue<Vector2i, TileMapQuadrant> &E : layers[layer].quadrant_map) {
for (TileMapLayer &layer : layers) {
for (KeyValue<Vector2i, TileMapQuadrant> &E : layer.quadrant_map) {
TileMapQuadrant &q = E.value;
for (RID body : q.bodies) {
@ -1667,13 +1667,12 @@ void TileMap::_navigation_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
if (is_inside_tree()) {
for (int layer = 0; layer < (int)layers.size(); layer++) {
for (TileMapLayer &layer : layers) {
Transform2D tilemap_xform = get_global_transform();
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layers[layer].quadrant_map) {
for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layer.quadrant_map) {
TileMapQuadrant &q = E_quadrant.value;
for (const KeyValue<Vector2i, Vector<RID>> &E_region : q.navigation_regions) {
for (int layer_index = 0; layer_index < E_region.value.size(); layer_index++) {
RID region = E_region.value[layer_index];
for (const RID &region : E_region.value) {
if (!region.is_valid()) {
continue;
}
@ -2815,8 +2814,8 @@ void TileMap::clear_layer(int p_layer) {
void TileMap::clear() {
// Remove all tiles.
_clear_internals();
for (unsigned int i = 0; i < layers.size(); i++) {
layers[i].tile_map.clear();
for (TileMapLayer &layer : layers) {
layer.tile_map.clear();
}
_recreate_internals();
used_rect_cache_dirty = true;
@ -3956,15 +3955,15 @@ PackedStringArray TileMap::get_configuration_warnings() const {
// Retrieve the set of Z index values with a Y-sorted layer.
RBSet<int> y_sorted_z_index;
for (int layer = 0; layer < (int)layers.size(); layer++) {
if (layers[layer].y_sort_enabled) {
y_sorted_z_index.insert(layers[layer].z_index);
for (const TileMapLayer &layer : layers) {
if (layer.y_sort_enabled) {
y_sorted_z_index.insert(layer.z_index);
}
}
// Check if we have a non-sorted layer in a Z-index with a Y-sorted layer.
for (int layer = 0; layer < (int)layers.size(); layer++) {
if (!layers[layer].y_sort_enabled && y_sorted_z_index.has(layers[layer].z_index)) {
for (const TileMapLayer &layer : layers) {
if (!layer.y_sort_enabled && y_sorted_z_index.has(layer.z_index)) {
warnings.push_back(RTR("A Y-sorted layer has the same Z-index value as a not Y-sorted layer.\nThis may lead to unwanted behaviors, as a layer that is not Y-sorted will be Y-sorted as a whole with tiles from Y-sorted layers."));
break;
}
@ -3973,8 +3972,8 @@ PackedStringArray TileMap::get_configuration_warnings() const {
if (tile_set.is_valid() && tile_set->get_tile_shape() == TileSet::TILE_SHAPE_ISOMETRIC) {
bool warn = !is_y_sort_enabled();
if (!warn) {
for (int layer = 0; layer < (int)layers.size(); layer++) {
if (!layers[layer].y_sort_enabled) {
for (const TileMapLayer &layer : layers) {
if (!layer.y_sort_enabled) {
warn = true;
break;
}

View File

@ -455,8 +455,8 @@ int32_t LightmapGI::_compute_bsp_tree(const Vector<Vector3> &p_points, const Loc
Plane best_plane;
float best_plane_score = -1.0;
for (uint32_t i = 0; i < p_simplex_indices.size(); i++) {
const BSPSimplex &s = p_simplices[p_simplex_indices[i]];
for (const int idx : p_simplex_indices) {
const BSPSimplex &s = p_simplices[idx];
for (int j = 0; j < 4; j++) {
uint32_t plane_index = s.planes[j];
if (planes_tested[plane_index] == node_index) {
@ -484,8 +484,8 @@ int32_t LightmapGI::_compute_bsp_tree(const Vector<Vector3> &p_points, const Loc
int over_count = 0;
int under_count = 0;
for (uint32_t k = 0; k < p_simplex_indices.size(); k++) {
int side = _bsp_get_simplex_side(p_points, p_simplices, plane, p_simplex_indices[k]);
for (const int &index : p_simplex_indices) {
int side = _bsp_get_simplex_side(p_points, p_simplices, plane, index);
if (side == -2) {
continue; //this simplex is invalid, skip for now
} else if (side < 0) {
@ -523,8 +523,7 @@ int32_t LightmapGI::_compute_bsp_tree(const Vector<Vector3> &p_points, const Loc
LocalVector<int32_t> indices_under;
//split again, but add to list
for (uint32_t i = 0; i < p_simplex_indices.size(); i++) {
uint32_t index = p_simplex_indices[i];
for (const uint32_t index : p_simplex_indices) {
int side = _bsp_get_simplex_side(p_points, p_simplices, best_plane, index);
if (side == -2) {
@ -977,8 +976,8 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
}
}
for (uint32_t i = 0; i < new_probe_positions.size(); i++) {
probes_found.push_back(new_probe_positions[i]);
for (const Vector3 &position : new_probe_positions) {
probes_found.push_back(position);
}
}
@ -1219,8 +1218,8 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
LocalVector<BSPNode> bsp_nodes;
LocalVector<int32_t> planes_tested;
planes_tested.resize(bsp_planes.size());
for (uint32_t i = 0; i < planes_tested.size(); i++) {
planes_tested[i] = 0x7FFFFFFF;
for (int &index : planes_tested) {
index = 0x7FFFFFFF;
}
if (p_bake_step) {

View File

@ -143,8 +143,8 @@ bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const {
} else if (name.begins_with("libraries")) {
Dictionary d;
for (uint32_t i = 0; i < animation_libraries.size(); i++) {
d[animation_libraries[i].name] = animation_libraries[i].library;
for (const AnimationLibraryData &lib : animation_libraries) {
d[lib.name] = lib.library;
}
r_ret = d;
@ -1269,13 +1269,13 @@ void AnimationPlayer::_animation_set_cache_update() {
bool clear_cache_needed = false;
// Update changed and add otherwise
for (uint32_t i = 0; i < animation_libraries.size(); i++) {
for (const KeyValue<StringName, Ref<Animation>> &K : animation_libraries[i].library->animations) {
StringName key = animation_libraries[i].name == StringName() ? K.key : StringName(String(animation_libraries[i].name) + "/" + String(K.key));
for (const AnimationLibraryData &lib : animation_libraries) {
for (const KeyValue<StringName, Ref<Animation>> &K : lib.library->animations) {
StringName key = lib.name == StringName() ? K.key : StringName(String(lib.name) + "/" + String(K.key));
if (!animation_set.has(key)) {
AnimationData ad;
ad.animation = K.value;
ad.animation_library = animation_libraries[i].name;
ad.animation_library = lib.name;
ad.name = key;
ad.last_update = animation_set_update_pass;
animation_set.insert(ad.name, ad);
@ -1283,11 +1283,11 @@ void AnimationPlayer::_animation_set_cache_update() {
AnimationData &ad = animation_set[key];
if (ad.last_update != animation_set_update_pass) {
// Was not updated, update. If the animation is duplicated, the second one will be ignored.
if (ad.animation != K.value || ad.animation_library != animation_libraries[i].name) {
if (ad.animation != K.value || ad.animation_library != lib.name) {
// Animation changed, update and clear caches.
clear_cache_needed = true;
ad.animation = K.value;
ad.animation_library = animation_libraries[i].name;
ad.animation_library = lib.name;
}
ad.last_update = animation_set_update_pass;
@ -1405,11 +1405,11 @@ Error AnimationPlayer::add_animation_library(const StringName &p_name, const Ref
int insert_pos = 0;
for (uint32_t i = 0; i < animation_libraries.size(); i++) {
ERR_FAIL_COND_V_MSG(animation_libraries[i].name == p_name, ERR_ALREADY_EXISTS, "Can't add animation library twice with name: " + String(p_name));
ERR_FAIL_COND_V_MSG(animation_libraries[i].library == p_animation_library, ERR_ALREADY_EXISTS, "Can't add animation library twice (adding as '" + p_name.operator String() + "', exists as '" + animation_libraries[i].name.operator String() + "'.");
for (const AnimationLibraryData &lib : animation_libraries) {
ERR_FAIL_COND_V_MSG(lib.name == p_name, ERR_ALREADY_EXISTS, "Can't add animation library twice with name: " + String(p_name));
ERR_FAIL_COND_V_MSG(lib.library == p_animation_library, ERR_ALREADY_EXISTS, "Can't add animation library twice (adding as '" + p_name.operator String() + "', exists as '" + lib.name.operator String() + "'.");
if (animation_libraries[i].name.operator String() >= p_name.operator String()) {
if (lib.name.operator String() >= p_name.operator String()) {
break;
}
@ -1468,21 +1468,21 @@ void AnimationPlayer::rename_animation_library(const StringName &p_name, const S
#endif
bool found = false;
for (uint32_t i = 0; i < animation_libraries.size(); i++) {
ERR_FAIL_COND_MSG(animation_libraries[i].name == p_new_name, "Can't rename animation library to another existing name: " + String(p_new_name));
if (animation_libraries[i].name == p_name) {
for (AnimationLibraryData &lib : animation_libraries) {
ERR_FAIL_COND_MSG(lib.name == p_new_name, "Can't rename animation library to another existing name: " + String(p_new_name));
if (lib.name == p_name) {
found = true;
animation_libraries[i].name = p_new_name;
lib.name = p_new_name;
// rename connections
animation_libraries[i].library->disconnect(SNAME("animation_added"), callable_mp(this, &AnimationPlayer::_animation_added));
animation_libraries[i].library->disconnect(SNAME("animation_removed"), callable_mp(this, &AnimationPlayer::_animation_removed));
animation_libraries[i].library->disconnect(SNAME("animation_renamed"), callable_mp(this, &AnimationPlayer::_animation_renamed));
lib.library->disconnect(SNAME("animation_added"), callable_mp(this, &AnimationPlayer::_animation_added));
lib.library->disconnect(SNAME("animation_removed"), callable_mp(this, &AnimationPlayer::_animation_removed));
lib.library->disconnect(SNAME("animation_renamed"), callable_mp(this, &AnimationPlayer::_animation_renamed));
animation_libraries[i].library->connect(SNAME("animation_added"), callable_mp(this, &AnimationPlayer::_animation_added).bind(p_new_name));
animation_libraries[i].library->connect(SNAME("animation_removed"), callable_mp(this, &AnimationPlayer::_animation_removed).bind(p_new_name));
animation_libraries[i].library->connect(SNAME("animation_renamed"), callable_mp(this, &AnimationPlayer::_animation_renamed).bind(p_new_name));
lib.library->connect(SNAME("animation_added"), callable_mp(this, &AnimationPlayer::_animation_added).bind(p_new_name));
lib.library->connect(SNAME("animation_removed"), callable_mp(this, &AnimationPlayer::_animation_removed).bind(p_new_name));
lib.library->connect(SNAME("animation_renamed"), callable_mp(this, &AnimationPlayer::_animation_renamed).bind(p_new_name));
for (const KeyValue<StringName, Ref<Animation>> &K : animation_libraries[i].library->animations) {
for (const KeyValue<StringName, Ref<Animation>> &K : lib.library->animations) {
StringName old_name = p_name == StringName() ? K.key : StringName(String(p_name) + "/" + String(K.key));
StringName new_name = p_new_name == StringName() ? K.key : StringName(String(p_new_name) + "/" + String(K.key));
_rename_animation(old_name, new_name);
@ -1502,8 +1502,8 @@ void AnimationPlayer::rename_animation_library(const StringName &p_name, const S
}
bool AnimationPlayer::has_animation_library(const StringName &p_name) const {
for (uint32_t i = 0; i < animation_libraries.size(); i++) {
if (animation_libraries[i].name == p_name) {
for (const AnimationLibraryData &lib : animation_libraries) {
if (lib.name == p_name) {
return true;
}
}
@ -1512,9 +1512,9 @@ bool AnimationPlayer::has_animation_library(const StringName &p_name) const {
}
Ref<AnimationLibrary> AnimationPlayer::get_animation_library(const StringName &p_name) const {
for (uint32_t i = 0; i < animation_libraries.size(); i++) {
if (animation_libraries[i].name == p_name) {
return animation_libraries[i].library;
for (const AnimationLibraryData &lib : animation_libraries) {
if (lib.name == p_name) {
return lib.library;
}
}
ERR_FAIL_V(Ref<AnimationLibrary>());
@ -1522,15 +1522,15 @@ Ref<AnimationLibrary> AnimationPlayer::get_animation_library(const StringName &p
TypedArray<StringName> AnimationPlayer::_get_animation_library_list() const {
TypedArray<StringName> ret;
for (uint32_t i = 0; i < animation_libraries.size(); i++) {
ret.push_back(animation_libraries[i].name);
for (const AnimationLibraryData &lib : animation_libraries) {
ret.push_back(lib.name);
}
return ret;
}
void AnimationPlayer::get_animation_library_list(List<StringName> *p_libraries) const {
for (uint32_t i = 0; i < animation_libraries.size(); i++) {
p_libraries->push_back(animation_libraries[i].name);
for (const AnimationLibraryData &lib : animation_libraries) {
p_libraries->push_back(lib.name);
}
}

View File

@ -59,9 +59,9 @@ void Popup::_initialize_visible_parents() {
void Popup::_deinitialize_visible_parents() {
if (is_embedded()) {
for (uint32_t i = 0; i < visible_parents.size(); ++i) {
visible_parents[i]->disconnect("focus_entered", callable_mp(this, &Popup::_parent_focused));
visible_parents[i]->disconnect("tree_exited", callable_mp(this, &Popup::_deinitialize_visible_parents));
for (Window *parent_window : visible_parents) {
parent_window->disconnect("focus_entered", callable_mp(this, &Popup::_parent_focused));
parent_window->disconnect("tree_exited", callable_mp(this, &Popup::_deinitialize_visible_parents));
}
visible_parents.clear();

View File

@ -4754,17 +4754,17 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol
// The frame has advanced, time to validate the previous frame
uint32_t current_page_size = base_page_size;
for (uint32_t i = 0; i < data_tracks.size(); i++) {
uint32_t track_size = data_tracks[i].data.size(); // track size
track_size += data_tracks[i].get_temp_packet_size(); // Add the temporary data
for (const AnimationCompressionDataState &state : data_tracks) {
uint32_t track_size = state.data.size(); // track size
track_size += state.get_temp_packet_size(); // Add the temporary data
if (track_size > Compression::MAX_DATA_TRACK_SIZE) {
rollback = true; //track to large, time track can't point to keys any longer, because key offset is 12 bits
break;
}
current_page_size += track_size;
}
for (uint32_t i = 0; i < time_tracks.size(); i++) {
current_page_size += time_tracks[i].packets.size() * 4; // time packet is 32 bits
for (const AnimationCompressionTimeState &state : time_tracks) {
current_page_size += state.packets.size() * 4; // time packet is 32 bits
}
if (!rollback && current_page_size > p_page_size) {
@ -4776,22 +4776,22 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol
if (rollback) {
// Not valid any longer, so rollback and commit page
for (uint32_t i = 0; i < data_tracks.size(); i++) {
data_tracks[i].temp_packets.resize(data_tracks[i].validated_packet_count);
for (AnimationCompressionDataState &state : data_tracks) {
state.temp_packets.resize(state.validated_packet_count);
}
for (uint32_t i = 0; i < time_tracks.size(); i++) {
time_tracks[i].key_index = time_tracks[i].validated_key_index; //rollback key
time_tracks[i].packets.resize(time_tracks[i].validated_packet_count);
for (AnimationCompressionTimeState &state : time_tracks) {
state.key_index = state.validated_key_index; //rollback key
state.packets.resize(state.validated_packet_count);
}
} else {
// All valid, so save rollback information
for (uint32_t i = 0; i < data_tracks.size(); i++) {
data_tracks[i].validated_packet_count = data_tracks[i].temp_packets.size();
for (AnimationCompressionDataState &state : data_tracks) {
state.validated_packet_count = state.temp_packets.size();
}
for (uint32_t i = 0; i < time_tracks.size(); i++) {
time_tracks[i].validated_key_index = time_tracks[i].key_index;
time_tracks[i].validated_packet_count = time_tracks[i].packets.size();
for (AnimationCompressionTimeState &state : time_tracks) {
state.validated_key_index = state.key_index;
state.validated_packet_count = state.packets.size();
}
// Accept this frame as the frame being processed (as long as it exists)
@ -4976,8 +4976,8 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol
}
uint32_t new_size = 0;
for (uint32_t i = 0; i < compression.pages.size(); i++) {
new_size += compression.pages[i].data.size();
for (const Compression::Page &page : compression.pages) {
new_size += page.data.size();
}
print_line("Original size: " + itos(orig_size) + " - Compressed size: " + itos(new_size) + " " + String::num(float(new_size) / float(orig_size) * 100, 2) + "% pages: " + itos(compression.pages.size()));
@ -5289,8 +5289,8 @@ int Animation::_get_compressed_key_count(uint32_t p_compressed_track) const {
int key_count = 0;
for (uint32_t i = 0; i < compression.pages.size(); i++) {
const uint8_t *page_data = compression.pages[i].data.ptr();
for (const Compression::Page &page : compression.pages) {
const uint8_t *page_data = page.data.ptr();
// Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported.
const uint32_t *indices = (const uint32_t *)page_data;
const uint16_t *time_keys = (const uint16_t *)&page_data[indices[p_compressed_track * 3 + 0]];
@ -5323,8 +5323,8 @@ bool Animation::_fetch_compressed_by_index(uint32_t p_compressed_track, int p_in
ERR_FAIL_COND_V(!compression.enabled, false);
ERR_FAIL_UNSIGNED_INDEX_V(p_compressed_track, compression.bounds.size(), false);
for (uint32_t i = 0; i < compression.pages.size(); i++) {
const uint8_t *page_data = compression.pages[i].data.ptr();
for (const Compression::Page &page : compression.pages) {
const uint8_t *page_data = page.data.ptr();
// Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported.
const uint32_t *indices = (const uint32_t *)page_data;
const uint16_t *time_keys = (const uint16_t *)&page_data[indices[p_compressed_track * 3 + 0]];
@ -5374,7 +5374,7 @@ bool Animation::_fetch_compressed_by_index(uint32_t p_compressed_track, int p_in
}
}
r_time = compression.pages[i].time_offset + double(frame) / double(compression.fps);
r_time = page.time_offset + double(frame) / double(compression.fps);
for (uint32_t l = 0; l < COMPONENTS; l++) {
r_value[l] = decode[l];
}

View File

@ -41,8 +41,8 @@ void ImmediateMesh::surface_set_color(const Color &p_color) {
if (!uses_colors) {
colors.resize(vertices.size());
for (uint32_t i = 0; i < colors.size(); i++) {
colors[i] = p_color;
for (Color &color : colors) {
color = p_color;
}
uses_colors = true;
}
@ -54,8 +54,8 @@ void ImmediateMesh::surface_set_normal(const Vector3 &p_normal) {
if (!uses_normals) {
normals.resize(vertices.size());
for (uint32_t i = 0; i < normals.size(); i++) {
normals[i] = p_normal;
for (Vector3 &normal : normals) {
normal = p_normal;
}
uses_normals = true;
}
@ -66,8 +66,8 @@ void ImmediateMesh::surface_set_tangent(const Plane &p_tangent) {
ERR_FAIL_COND_MSG(!surface_active, "Not creating any surface. Use surface_begin() to do it.");
if (!uses_tangents) {
tangents.resize(vertices.size());
for (uint32_t i = 0; i < tangents.size(); i++) {
tangents[i] = p_tangent;
for (Plane &tangent : tangents) {
tangent = p_tangent;
}
uses_tangents = true;
}
@ -78,8 +78,8 @@ void ImmediateMesh::surface_set_uv(const Vector2 &p_uv) {
ERR_FAIL_COND_MSG(!surface_active, "Not creating any surface. Use surface_begin() to do it.");
if (!uses_uvs) {
uvs.resize(vertices.size());
for (uint32_t i = 0; i < uvs.size(); i++) {
uvs[i] = p_uv;
for (Vector2 &uv : uvs) {
uv = p_uv;
}
uses_uvs = true;
}
@ -90,8 +90,8 @@ void ImmediateMesh::surface_set_uv2(const Vector2 &p_uv2) {
ERR_FAIL_COND_MSG(!surface_active, "Not creating any surface. Use surface_begin() to do it.");
if (!uses_uv2s) {
uv2s.resize(vertices.size());
for (uint32_t i = 0; i < uv2s.size(); i++) {
uv2s[i] = p_uv2;
for (Vector2 &uv : uv2s) {
uv = p_uv2;
}
uses_uv2s = true;
}

View File

@ -364,9 +364,7 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
const LocalVector<Pair<int, int>> &close_verts = E->value;
bool found = false;
for (unsigned int k = 0; k < close_verts.size(); k++) {
const Pair<int, int> &idx = close_verts[k];
for (const Pair<int, int> &idx : close_verts) {
bool is_uvs_close = (!uvs_ptr || uvs_ptr[j].distance_squared_to(uvs_ptr[idx.second]) < CMP_EPSILON2);
bool is_uv2s_close = (!uv2s_ptr || uv2s_ptr[j].distance_squared_to(uv2s_ptr[idx.second]) < CMP_EPSILON2);
ERR_FAIL_INDEX(idx.second, normals.size());
@ -599,8 +597,7 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
const LocalVector<int> &corners = vertex_corners[j];
const Vector3 &vertex_normal = normals_ptr[j];
for (unsigned int k = 0; k < corners.size(); k++) {
const int &corner_idx = corners[k];
for (const int &corner_idx : corners) {
const Vector3 &ray_normal = ray_normals[corner_idx];
if (ray_normal.length_squared() < CMP_EPSILON2) {
@ -635,8 +632,8 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
split_vertex_indices.push_back(j);
split_vertex_normals.push_back(n);
int new_idx = split_vertex_count++;
for (unsigned int l = 0; l < group_indices.size(); l++) {
new_indices_ptr[group_indices[l]] = new_idx;
for (const int &index : group_indices) {
new_indices_ptr[index] = new_idx;
}
}
}
@ -1241,10 +1238,10 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform,
}
//generate surfaces
for (unsigned int i = 0; i < surfaces_tools.size(); i++) {
surfaces_tools[i]->index();
Array arrays = surfaces_tools[i]->commit_to_arrays();
add_surface(surfaces_tools[i]->get_primitive_type(), arrays, Array(), Dictionary(), surfaces_tools[i]->get_material(), surfaces_tools[i]->get_meta("name"));
for (Ref<SurfaceTool> &tool : surfaces_tools) {
tool->index();
Array arrays = tool->commit_to_arrays();
add_surface(tool->get_primitive_type(), arrays, Array(), Dictionary(), tool->get_material(), tool->get_meta("name"));
}
set_lightmap_size_hint(Size2(size_x, size_y));

View File

@ -402,8 +402,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
}
}
for (uint32_t i = 0; i < deferred_node_paths.size(); i++) {
const DeferredNodePathProperties &dnp = deferred_node_paths[i];
for (const DeferredNodePathProperties &dnp : deferred_node_paths) {
Node *other = dnp.base->get_node_or_null(dnp.path);
dnp.base->set(dnp.property, other);
}

View File

@ -732,13 +732,13 @@ void SurfaceTool::index() {
LocalVector<Vertex> old_vertex_array = vertex_array;
vertex_array.clear();
for (uint32_t i = 0; i < old_vertex_array.size(); i++) {
int *idxptr = indices.getptr(old_vertex_array[i]);
for (const Vertex &vertex : old_vertex_array) {
int *idxptr = indices.getptr(vertex);
int idx;
if (!idxptr) {
idx = indices.size();
vertex_array.push_back(old_vertex_array[i]);
indices[old_vertex_array[i]] = idx;
vertex_array.push_back(vertex);
indices[vertex] = idx;
} else {
idx = *idxptr;
}
@ -756,9 +756,8 @@ void SurfaceTool::deindex() {
LocalVector<Vertex> old_vertex_array = vertex_array;
vertex_array.clear();
for (uint32_t i = 0; i < index_array.size(); i++) {
uint32_t index = index_array[i];
ERR_FAIL_COND(index >= old_vertex_array.size());
for (const int &index : index_array) {
ERR_FAIL_COND(uint32_t(index) >= old_vertex_array.size());
vertex_array.push_back(old_vertex_array[index]);
}
format &= ~Mesh::ARRAY_FORMAT_INDEX;
@ -1000,8 +999,7 @@ void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const
}
int vfrom = vertex_array.size();
for (uint32_t vi = 0; vi < nvertices.size(); vi++) {
Vertex v = nvertices[vi];
for (Vertex &v : nvertices) {
v.vertex = p_xform.xform(v.vertex);
if (nformat & RS::ARRAY_FORMAT_NORMAL) {
v.normal = p_xform.basis.xform(v.normal);
@ -1014,8 +1012,8 @@ void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const
vertex_array.push_back(v);
}
for (uint32_t i = 0; i < nindices.size(); i++) {
int dst_index = nindices[i] + vfrom;
for (const int &index : nindices) {
int dst_index = index + vfrom;
index_array.push_back(dst_index);
}
if (index_array.size() % 3) {
@ -1132,9 +1130,9 @@ void SurfaceTool::generate_tangents() {
TangentGenerationContextUserData triangle_data;
triangle_data.vertices = &vertex_array;
for (uint32_t i = 0; i < vertex_array.size(); i++) {
vertex_array[i].binormal = Vector3();
vertex_array[i].tangent = Vector3();
for (Vertex &vertex : vertex_array) {
vertex.binormal = Vector3();
vertex.tangent = Vector3();
}
triangle_data.indices = &index_array;
msc.m_pUserData = &triangle_data;
@ -1176,12 +1174,12 @@ void SurfaceTool::generate_normals(bool p_flip) {
}
}
for (uint32_t vi = 0; vi < vertex_array.size(); vi++) {
Vector3 *lv = vertex_hash.getptr(vertex_array[vi]);
for (Vertex &vertex : vertex_array) {
Vector3 *lv = vertex_hash.getptr(vertex);
if (!lv) {
vertex_array[vi].normal = Vector3();
vertex.normal = Vector3();
} else {
vertex_array[vi].normal = lv->normalized();
vertex.normal = lv->normalized();
}
}

View File

@ -135,8 +135,8 @@ void TextParagraph::_bind_methods() {
void TextParagraph::_shape_lines() {
if (lines_dirty) {
for (int i = 0; i < (int)lines_rid.size(); i++) {
TS->free_rid(lines_rid[i]);
for (const RID &line_rid : lines_rid) {
TS->free_rid(line_rid);
}
lines_rid.clear();
@ -234,14 +234,14 @@ void TextParagraph::_shape_lines() {
} else {
// Autowrap disabled.
for (int i = 0; i < (int)lines_rid.size(); i++) {
for (const RID &line_rid : lines_rid) {
if (alignment == HORIZONTAL_ALIGNMENT_FILL) {
TS->shaped_text_fit_to_width(lines_rid[i], width, jst_flags);
TS->shaped_text_fit_to_width(line_rid, width, jst_flags);
overrun_flags.set_flag(TextServer::OVERRUN_JUSTIFICATION_AWARE);
TS->shaped_text_overrun_trim_to_width(lines_rid[i], width, overrun_flags);
TS->shaped_text_fit_to_width(lines_rid[i], width, jst_flags | TextServer::JUSTIFICATION_CONSTRAIN_ELLIPSIS);
TS->shaped_text_overrun_trim_to_width(line_rid, width, overrun_flags);
TS->shaped_text_fit_to_width(line_rid, width, jst_flags | TextServer::JUSTIFICATION_CONSTRAIN_ELLIPSIS);
} else {
TS->shaped_text_overrun_trim_to_width(lines_rid[i], width, overrun_flags);
TS->shaped_text_overrun_trim_to_width(line_rid, width, overrun_flags);
}
}
}
@ -268,8 +268,8 @@ RID TextParagraph::get_dropcap_rid() const {
void TextParagraph::clear() {
_THREAD_SAFE_METHOD_
for (int i = 0; i < (int)lines_rid.size(); i++) {
TS->free_rid(lines_rid[i]);
for (const RID &line_rid : lines_rid) {
TS->free_rid(line_rid);
}
lines_rid.clear();
TS->shaped_text_clear(rid);
@ -915,17 +915,17 @@ int TextParagraph::hit_test(const Point2 &p_coords) const {
return 0;
}
}
for (int i = 0; i < (int)lines_rid.size(); i++) {
if (TS->shaped_text_get_orientation(lines_rid[i]) == TextServer::ORIENTATION_HORIZONTAL) {
if ((p_coords.y >= ofs.y) && (p_coords.y <= ofs.y + TS->shaped_text_get_size(lines_rid[i]).y)) {
return TS->shaped_text_hit_test_position(lines_rid[i], p_coords.x);
for (const RID &line_rid : lines_rid) {
if (TS->shaped_text_get_orientation(line_rid) == TextServer::ORIENTATION_HORIZONTAL) {
if ((p_coords.y >= ofs.y) && (p_coords.y <= ofs.y + TS->shaped_text_get_size(line_rid).y)) {
return TS->shaped_text_hit_test_position(line_rid, p_coords.x);
}
ofs.y += TS->shaped_text_get_size(lines_rid[i]).y;
ofs.y += TS->shaped_text_get_size(line_rid).y;
} else {
if ((p_coords.x >= ofs.x) && (p_coords.x <= ofs.x + TS->shaped_text_get_size(lines_rid[i]).x)) {
return TS->shaped_text_hit_test_position(lines_rid[i], p_coords.y);
if ((p_coords.x >= ofs.x) && (p_coords.x <= ofs.x + TS->shaped_text_get_size(line_rid).x)) {
return TS->shaped_text_hit_test_position(line_rid, p_coords.y);
}
ofs.y += TS->shaped_text_get_size(lines_rid[i]).x;
ofs.y += TS->shaped_text_get_size(line_rid).x;
}
}
return TS->shaped_text_get_range(rid).y;
@ -1027,8 +1027,8 @@ TextParagraph::TextParagraph() {
}
TextParagraph::~TextParagraph() {
for (int i = 0; i < (int)lines_rid.size(); i++) {
TS->free_rid(lines_rid[i]);
for (const RID &line_rid : lines_rid) {
TS->free_rid(line_rid);
}
lines_rid.clear();
TS->free_rid(rid);

View File

@ -404,8 +404,8 @@ void TileSet::_update_terrains_cache() {
if (terrains_cache_dirty) {
// Organizes tiles into structures.
per_terrain_pattern_tiles.resize(terrain_sets.size());
for (int i = 0; i < (int)per_terrain_pattern_tiles.size(); i++) {
per_terrain_pattern_tiles[i].clear();
for (RBMap<TileSet::TerrainsPattern, RBSet<TileMapCell>> &tiles : per_terrain_pattern_tiles) {
tiles.clear();
}
for (const KeyValue<int, Ref<TileSetSource>> &kv : sources) {
@ -1342,8 +1342,8 @@ void TileSet::clear_tile_proxies() {
int TileSet::add_pattern(Ref<TileMapPattern> p_pattern, int p_index) {
ERR_FAIL_COND_V(!p_pattern.is_valid(), -1);
ERR_FAIL_COND_V_MSG(p_pattern->is_empty(), -1, "Cannot add an empty pattern to the TileSet.");
for (unsigned int i = 0; i < patterns.size(); i++) {
ERR_FAIL_COND_V_MSG(patterns[i] == p_pattern, -1, "TileSet has already this pattern.");
for (const Ref<TileMapPattern> &pattern : patterns) {
ERR_FAIL_COND_V_MSG(pattern == p_pattern, -1, "TileSet has already this pattern.");
}
ERR_FAIL_COND_V(p_index > (int)patterns.size(), -1);
if (p_index < 0) {
@ -4190,8 +4190,8 @@ real_t TileSetAtlasSource::get_tile_animation_total_duration(const Vector2i p_at
ERR_FAIL_COND_V_MSG(!tiles.has(p_atlas_coords), 1, vformat("TileSetAtlasSource has no tile at %s.", Vector2i(p_atlas_coords)));
real_t sum = 0.0;
for (int frame = 0; frame < (int)tiles[p_atlas_coords].animation_frames_durations.size(); frame++) {
sum += tiles[p_atlas_coords].animation_frames_durations[frame];
for (const real_t &duration : tiles[p_atlas_coords].animation_frames_durations) {
sum += duration;
}
return sum;
}
@ -4573,8 +4573,8 @@ void TileSetAtlasSource::_clear_tiles_outside_texture() {
}
}
for (unsigned int i = 0; i < to_remove.size(); i++) {
remove_tile(to_remove[i]);
for (const Vector2i &v : to_remove) {
remove_tile(v);
}
}

View File

@ -852,17 +852,12 @@ Vector3 GodotConvexPolygonShape3D::get_support(const Vector3 &p_normal) const {
// Get the array of vertices
const Vector3 *const vertices_array = mesh.vertices.ptr();
// Get the array of extreme vertices
const int *const extreme_array = extreme_vertices.ptr();
const uint32_t extreme_size = extreme_vertices.size();
// Start with an initial assumption of the first extreme vertex
int best_vertex = extreme_array[0];
// Start with an initial assumption of the first extreme vertex.
int best_vertex = extreme_vertices[0];
real_t max_support = p_normal.dot(vertices_array[best_vertex]);
// Check the remaining extreme vertices for a better vertex
for (uint32_t i = 0; i < extreme_size; ++i) {
int vert = extreme_array[i];
// Check the remaining extreme vertices for a better vertex.
for (const int &vert : extreme_vertices) {
real_t s = p_normal.dot(vertices_array[vert]);
if (s > max_support) {
best_vertex = vert;
@ -870,27 +865,18 @@ Vector3 GodotConvexPolygonShape3D::get_support(const Vector3 &p_normal) const {
}
}
// If we checked all vertices in the mesh then we're done
if (extreme_size == mesh.vertices.size()) {
// If we checked all vertices in the mesh then we're done.
if (extreme_vertices.size() == mesh.vertices.size()) {
return vertices_array[best_vertex];
}
// Get the array of neighbor arrays for each vertex
const LocalVector<int> *const vertex_neighbors_array = vertex_neighbors.ptr();
// Move along the surface until we reach the true support vertex.
int last_vertex = -1;
while (true) {
int next_vertex = -1;
// Get the array of neighbors around the best vertex
const LocalVector<int> &neighbors = vertex_neighbors_array[best_vertex];
const int *const neighbors_array = neighbors.ptr();
const uint32_t neighbors_size = neighbors.size();
// Iterate over all the neighbors checking for a better vertex
for (uint32_t i = 0; i < neighbors_size; ++i) {
int vert = neighbors_array[i];
// Iterate over all the neighbors checking for a better vertex.
for (const int &vert : vertex_neighbors[best_vertex]) {
if (vert != last_vertex) {
real_t s = p_normal.dot(vertices_array[vert]);
if (s > max_support) {
@ -1149,8 +1135,7 @@ void GodotConvexPolygonShape3D::_setup(const Vector<Vector3> &p_vertices) {
if (extreme_vertices.size() < mesh.vertices.size()) {
vertex_neighbors.resize(mesh.vertices.size());
for (uint32_t i = 0; i < mesh.edges.size(); i++) {
Geometry3D::MeshData::Edge &edge = mesh.edges[i];
for (Geometry3D::MeshData::Edge &edge : mesh.edges) {
vertex_neighbors[edge.vertex_a].push_back(edge.vertex_b);
vertex_neighbors[edge.vertex_b].push_back(edge.vertex_a);
}

View File

@ -167,14 +167,11 @@ void GodotSoftBody3D::update_rendering_server(PhysicsServer3DRenderingServerHand
}
void GodotSoftBody3D::update_normals_and_centroids() {
uint32_t i, ni;
for (i = 0, ni = nodes.size(); i < ni; ++i) {
nodes[i].n = Vector3();
for (Node &node : nodes) {
node.n = Vector3();
}
for (i = 0, ni = faces.size(); i < ni; ++i) {
Face &face = faces[i];
for (Face &face : faces) {
const Vector3 n = vec3_cross(face.n[0]->x - face.n[2]->x, face.n[0]->x - face.n[1]->x);
face.n[0]->n += n;
face.n[1]->n += n;
@ -184,8 +181,7 @@ void GodotSoftBody3D::update_normals_and_centroids() {
face.centroid = 0.33333333333 * (face.n[0]->x + face.n[1]->x + face.n[2]->x);
}
for (i = 0, ni = nodes.size(); i < ni; ++i) {
Node &node = nodes[i];
for (Node &node : nodes) {
real_t len = node.n.length();
if (len > CMP_EPSILON) {
node.n /= len;
@ -235,9 +231,7 @@ void GodotSoftBody3D::update_area() {
int i, ni;
// Face area.
for (i = 0, ni = faces.size(); i < ni; ++i) {
Face &face = faces[i];
for (Face &face : faces) {
const Vector3 &x0 = face.n[0]->x;
const Vector3 &x1 = face.n[1]->x;
const Vector3 &x2 = face.n[2]->x;
@ -255,12 +249,11 @@ void GodotSoftBody3D::update_area() {
memset(counts.ptr(), 0, counts.size() * sizeof(int));
}
for (i = 0, ni = nodes.size(); i < ni; ++i) {
nodes[i].area = 0.0;
for (Node &node : nodes) {
node.area = 0.0;
}
for (i = 0, ni = faces.size(); i < ni; ++i) {
const Face &face = faces[i];
for (const Face &face : faces) {
for (int j = 0; j < 3; ++j) {
const int index = (int)(face.n[j] - &nodes[0]);
counts[index]++;
@ -278,8 +271,7 @@ void GodotSoftBody3D::update_area() {
}
void GodotSoftBody3D::reset_link_rest_lengths() {
for (uint32_t i = 0, ni = links.size(); i < ni; ++i) {
Link &link = links[i];
for (Link &link : links) {
link.rl = (link.n[0]->x - link.n[1]->x).length();
link.c1 = link.rl * link.rl;
}
@ -287,8 +279,7 @@ void GodotSoftBody3D::reset_link_rest_lengths() {
void GodotSoftBody3D::update_link_constants() {
real_t inv_linear_stiffness = 1.0 / linear_stiffness;
for (uint32_t i = 0, ni = links.size(); i < ni; ++i) {
Link &link = links[i];
for (Link &link : links) {
link.c0 = (link.n[0]->im + link.n[1]->im) * inv_linear_stiffness;
}
}
@ -619,9 +610,9 @@ void GodotSoftBody3D::generate_bending_constraints(int p_distance) {
}
}
}
for (i = 0; i < links.size(); ++i) {
const int ia = (int)(links[i].n[0] - &nodes[0]);
const int ib = (int)(links[i].n[1] - &nodes[0]);
for (Link &link : links) {
const int ia = (int)(link.n[0] - &nodes[0]);
const int ib = (int)(link.n[1] - &nodes[0]);
int idx = ib * n + ia;
int idx_inv = ia * n + ib;
adj[idx] = 1;
@ -635,9 +626,9 @@ void GodotSoftBody3D::generate_bending_constraints(int p_distance) {
// Build node links.
node_links.resize(nodes.size());
for (i = 0; i < links.size(); ++i) {
const int ia = (int)(links[i].n[0] - &nodes[0]);
const int ib = (int)(links[i].n[1] - &nodes[0]);
for (Link &link : links) {
const int ia = (int)(link.n[0] - &nodes[0]);
const int ib = (int)(link.n[1] - &nodes[0]);
if (node_links[ia].find(ib) == -1) {
node_links[ia].push_back(ib);
}
@ -649,8 +640,7 @@ void GodotSoftBody3D::generate_bending_constraints(int p_distance) {
for (uint32_t ii = 0; ii < node_links.size(); ii++) {
for (uint32_t jj = 0; jj < node_links[ii].size(); jj++) {
int k = node_links[ii][jj];
for (uint32_t kk = 0; kk < node_links[k].size(); kk++) {
int l = node_links[k][kk];
for (const int &l : node_links[k]) {
if ((int)ii != l) {
int idx_ik = k * n + ii;
int idx_kj = l * n + k;
@ -916,8 +906,7 @@ void GodotSoftBody3D::set_drag_coefficient(real_t p_val) {
}
void GodotSoftBody3D::add_velocity(const Vector3 &p_velocity) {
for (uint32_t i = 0, ni = nodes.size(); i < ni; ++i) {
Node &node = nodes[i];
for (Node &node : nodes) {
if (node.im > 0) {
node.v += p_velocity;
}
@ -929,26 +918,22 @@ void GodotSoftBody3D::apply_forces(const LocalVector<GodotArea3D *> &p_wind_area
return;
}
uint32_t i, ni;
int32_t j;
real_t volume = 0.0;
const Vector3 &org = nodes[0].x;
// Iterate over faces (try not to iterate elsewhere if possible).
for (i = 0, ni = faces.size(); i < ni; ++i) {
const Face &face = faces[i];
for (const Face &face : faces) {
Vector3 wind_force(0, 0, 0);
// Compute volume.
volume += vec3_dot(face.n[0]->x - org, vec3_cross(face.n[1]->x - org, face.n[2]->x - org));
// Compute nodal forces from area winds.
int wind_area_count = p_wind_areas.size();
if (wind_area_count > 0) {
for (j = 0; j < wind_area_count; j++) {
wind_force += _compute_area_windforce(p_wind_areas[j], &face);
if (!p_wind_areas.is_empty()) {
for (const GodotArea3D *area : p_wind_areas) {
wind_force += _compute_area_windforce(area, &face);
}
for (j = 0; j < 3; j++) {
@ -962,8 +947,7 @@ void GodotSoftBody3D::apply_forces(const LocalVector<GodotArea3D *> &p_wind_area
// Apply nodal pressure forces.
if (pressure_coefficient > CMP_EPSILON) {
real_t ivolumetp = 1.0 / Math::abs(volume) * pressure_coefficient;
for (i = 0, ni = nodes.size(); i < ni; ++i) {
Node &node = nodes[i];
for (Node &node : nodes) {
if (node.im > 0) {
node.f += node.n * (node.area * ivolumetp);
}
@ -1048,9 +1032,7 @@ void GodotSoftBody3D::predict_motion(real_t p_delta) {
real_t clamp_delta_v = max_displacement * inv_delta;
// Integrate.
uint32_t i, ni;
for (i = 0, ni = nodes.size(); i < ni; ++i) {
Node &node = nodes[i];
for (Node &node : nodes) {
node.q = node.x;
Vector3 delta_v = node.f * node.im * p_delta;
for (int c = 0; c < 3; c++) {
@ -1065,9 +1047,7 @@ void GodotSoftBody3D::predict_motion(real_t p_delta) {
update_bounds();
// Node tree update.
for (i = 0, ni = nodes.size(); i < ni; ++i) {
const Node &node = nodes[i];
for (const Node &node : nodes) {
AABB node_aabb(node.x, Vector3());
node_aabb.expand_to(node.x + node.v * p_delta);
node_aabb.grow_by(collision_margin);
@ -1088,17 +1068,13 @@ void GodotSoftBody3D::predict_motion(real_t p_delta) {
void GodotSoftBody3D::solve_constraints(real_t p_delta) {
const real_t inv_delta = 1.0 / p_delta;
uint32_t i, ni;
for (i = 0, ni = links.size(); i < ni; ++i) {
Link &link = links[i];
for (Link &link : links) {
link.c3 = link.n[1]->q - link.n[0]->q;
link.c2 = 1 / (link.c3.length_squared() * link.c0);
}
// Solve velocities.
for (i = 0, ni = nodes.size(); i < ni; ++i) {
Node &node = nodes[i];
for (Node &node : nodes) {
node.x = node.q + node.v * p_delta;
}
@ -1108,9 +1084,7 @@ void GodotSoftBody3D::solve_constraints(real_t p_delta) {
solve_links(1.0, ti);
}
const real_t vc = (1.0 - damping_coefficient) * inv_delta;
for (i = 0, ni = nodes.size(); i < ni; ++i) {
Node &node = nodes[i];
for (Node &node : nodes) {
node.x += node.bv * p_delta;
node.bv = Vector3();
@ -1123,8 +1097,7 @@ void GodotSoftBody3D::solve_constraints(real_t p_delta) {
}
void GodotSoftBody3D::solve_links(real_t kst, real_t ti) {
for (uint32_t i = 0, ni = links.size(); i < ni; ++i) {
Link &link = links[i];
for (Link &link : links) {
if (link.c0 > 0) {
Node &node_a = *link.n[0];
Node &node_b = *link.n[1];
@ -1183,9 +1156,7 @@ void GodotSoftBody3D::query_ray(const Vector3 &p_from, const Vector3 &p_to, Godo
void GodotSoftBody3D::initialize_face_tree() {
face_tree.clear();
for (uint32_t i = 0; i < faces.size(); ++i) {
Face &face = faces[i];
for (Face &face : faces) {
AABB face_aabb;
face_aabb.position = face.n[0]->x;
@ -1199,9 +1170,7 @@ void GodotSoftBody3D::initialize_face_tree() {
}
void GodotSoftBody3D::update_face_tree(real_t p_delta) {
for (uint32_t i = 0; i < faces.size(); ++i) {
const Face &face = faces[i];
for (const Face &face : faces) {
AABB face_aabb;
const Node *node0 = face.n[0];

View File

@ -540,9 +540,7 @@ void GI::SDFGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_re
occlusion_texture = RD::get_singleton()->texture_create_shared(tv, occlusion_data);
}
for (uint32_t i = 0; i < cascades.size(); i++) {
SDFGI::Cascade &cascade = cascades[i];
for (SDFGI::Cascade &cascade : cascades) {
/* 3D Textures */
cascade.sdf_tex = RD::get_singleton()->texture_create(tf_sdf, RD::TextureView());
@ -743,9 +741,7 @@ void GI::SDFGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_re
}
//direct light
for (uint32_t i = 0; i < cascades.size(); i++) {
SDFGI::Cascade &cascade = cascades[i];
for (SDFGI::Cascade &cascade : cascades) {
Vector<RD::Uniform> uniforms;
{
RD::Uniform u;
@ -1134,8 +1130,7 @@ void GI::SDFGI::free_data() {
}
GI::SDFGI::~SDFGI() {
for (uint32_t i = 0; i < cascades.size(); i++) {
const SDFGI::Cascade &c = cascades[i];
for (const SDFGI::Cascade &c : cascades) {
RD::get_singleton()->free(c.light_data);
RD::get_singleton()->free(c.light_aniso_0_tex);
RD::get_singleton()->free(c.light_aniso_1_tex);
@ -1198,8 +1193,7 @@ void GI::SDFGI::update(RID p_env, const Vector3 &p_world_position) {
int32_t drag_margin = (cascade_size / SDFGI::PROBE_DIVISOR) / 2;
for (uint32_t i = 0; i < cascades.size(); i++) {
SDFGI::Cascade &cascade = cascades[i];
for (SDFGI::Cascade &cascade : cascades) {
cascade.dirty_regions = Vector3i();
Vector3 probe_half_size = Vector3(1, 1, 1) * cascade.cell_size * float(cascade_size / SDFGI::PROBE_DIVISOR) * 0.5;

View File

@ -1365,8 +1365,8 @@ void RenderForwardClustered::_pre_opaque_render(RenderDataRD *p_render_data, boo
}
//cube shadows are rendered in their own way
for (uint32_t i = 0; i < p_render_data->cube_shadows.size(); i++) {
_render_shadow_pass(p_render_data->render_shadows[p_render_data->cube_shadows[i]].light, p_render_data->shadow_atlas, p_render_data->render_shadows[p_render_data->cube_shadows[i]].pass, p_render_data->render_shadows[p_render_data->cube_shadows[i]].instances, camera_plane, lod_distance_multiplier, p_render_data->scene_data->screen_mesh_lod_threshold, true, true, true, p_render_data->render_info);
for (const int &index : p_render_data->cube_shadows) {
_render_shadow_pass(p_render_data->render_shadows[index].light, p_render_data->shadow_atlas, p_render_data->render_shadows[index].pass, p_render_data->render_shadows[index].instances, camera_plane, lod_distance_multiplier, p_render_data->scene_data->screen_mesh_lod_threshold, true, true, true, p_render_data->render_info);
}
if (p_render_data->directional_shadows.size()) {
@ -2415,8 +2415,7 @@ void RenderForwardClustered::_render_shadow_process() {
void RenderForwardClustered::_render_shadow_end(uint32_t p_barrier) {
RD::get_singleton()->draw_command_begin_label("Shadow Render");
for (uint32_t i = 0; i < scene_state.shadow_passes.size(); i++) {
SceneState::ShadowPass &shadow_pass = scene_state.shadow_passes[i];
for (SceneState::ShadowPass &shadow_pass : scene_state.shadow_passes) {
RenderListParameters render_list_parameters(render_list[RENDER_LIST_SECONDARY].elements.ptr() + shadow_pass.element_from, render_list[RENDER_LIST_SECONDARY].element_info.ptr() + shadow_pass.element_from, shadow_pass.element_count, shadow_pass.flip_cull, shadow_pass.pass_mode, 0, true, false, shadow_pass.rp_uniform_set, false, Vector2(), shadow_pass.lod_distance_multiplier, shadow_pass.screen_mesh_lod_threshold, 1, shadow_pass.element_from, RD::BARRIER_MASK_NO_BARRIER);
_render_list_with_threads(&render_list_parameters, shadow_pass.framebuffer, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, shadow_pass.initial_depth_action, shadow_pass.final_depth_action, Vector<Color>(), 1.0, 0, shadow_pass.rect);
}
@ -3376,9 +3375,7 @@ int RenderForwardClustered::sdfgi_get_pending_region_count(const Ref<RenderScene
Ref<RendererRD::GI::SDFGI> sdfgi = rb->get_custom_data(RB_SCOPE_SDFGI);
int dirty_count = 0;
for (uint32_t i = 0; i < sdfgi->cascades.size(); i++) {
const RendererRD::GI::SDFGI::Cascade &c = sdfgi->cascades[i];
for (const RendererRD::GI::SDFGI::Cascade &c : sdfgi->cascades) {
if (c.dirty_regions == RendererRD::GI::SDFGI::Cascade::DIRTY_ALL) {
dirty_count++;
} else {
@ -4007,11 +4004,11 @@ RenderForwardClustered::~RenderForwardClustered() {
RSG::light_storage->directional_shadow_atlas_set_size(0);
{
for (uint32_t i = 0; i < scene_state.uniform_buffers.size(); i++) {
RD::get_singleton()->free(scene_state.uniform_buffers[i]);
for (const RID &rid : scene_state.uniform_buffers) {
RD::get_singleton()->free(rid);
}
for (uint32_t i = 0; i < scene_state.implementation_uniform_buffers.size(); i++) {
RD::get_singleton()->free(scene_state.implementation_uniform_buffers[i]);
for (const RID &rid : scene_state.implementation_uniform_buffers) {
RD::get_singleton()->free(rid);
}
RD::get_singleton()->free(scene_state.lightmap_buffer);
RD::get_singleton()->free(scene_state.lightmap_capture_buffer);

View File

@ -579,8 +579,8 @@ void RenderForwardMobile::_pre_opaque_render(RenderDataRD *p_render_data) {
}
//cube shadows are rendered in their own way
for (uint32_t i = 0; i < p_render_data->cube_shadows.size(); i++) {
_render_shadow_pass(p_render_data->render_shadows[p_render_data->cube_shadows[i]].light, p_render_data->shadow_atlas, p_render_data->render_shadows[p_render_data->cube_shadows[i]].pass, p_render_data->render_shadows[p_render_data->cube_shadows[i]].instances, camera_plane, lod_distance_multiplier, p_render_data->scene_data->screen_mesh_lod_threshold, true, true, true, p_render_data->render_info);
for (const int &index : p_render_data->cube_shadows) {
_render_shadow_pass(p_render_data->render_shadows[index].light, p_render_data->shadow_atlas, p_render_data->render_shadows[index].pass, p_render_data->render_shadows[index].instances, camera_plane, lod_distance_multiplier, p_render_data->scene_data->screen_mesh_lod_threshold, true, true, true, p_render_data->render_info);
}
if (p_render_data->directional_shadows.size()) {
@ -1340,8 +1340,7 @@ void RenderForwardMobile::_render_shadow_process() {
void RenderForwardMobile::_render_shadow_end(uint32_t p_barrier) {
RD::get_singleton()->draw_command_begin_label("Shadow Render");
for (uint32_t i = 0; i < scene_state.shadow_passes.size(); i++) {
SceneState::ShadowPass &shadow_pass = scene_state.shadow_passes[i];
for (SceneState::ShadowPass &shadow_pass : scene_state.shadow_passes) {
RenderListParameters render_list_parameters(render_list[RENDER_LIST_SECONDARY].elements.ptr() + shadow_pass.element_from, render_list[RENDER_LIST_SECONDARY].element_info.ptr() + shadow_pass.element_from, shadow_pass.element_count, shadow_pass.flip_cull, shadow_pass.pass_mode, shadow_pass.rp_uniform_set, 0, false, Vector2(), shadow_pass.lod_distance_multiplier, shadow_pass.screen_mesh_lod_threshold, 1, shadow_pass.element_from, RD::BARRIER_MASK_NO_BARRIER);
_render_list_with_threads(&render_list_parameters, shadow_pass.framebuffer, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, shadow_pass.initial_depth_action, shadow_pass.final_depth_action, Vector<Color>(), 1.0, 0, shadow_pass.rect);
}
@ -2810,8 +2809,8 @@ RenderForwardMobile::~RenderForwardMobile() {
}
{
for (uint32_t i = 0; i < scene_state.uniform_buffers.size(); i++) {
RD::get_singleton()->free(scene_state.uniform_buffers[i]);
for (const RID &rid : scene_state.uniform_buffers) {
RD::get_singleton()->free(rid);
}
RD::get_singleton()->free(scene_state.lightmap_buffer);
RD::get_singleton()->free(scene_state.lightmap_capture_buffer);

View File

@ -165,8 +165,7 @@ void ShaderRD::_clear_version(Version *p_version) {
}
void ShaderRD::_build_variant_code(StringBuilder &builder, uint32_t p_variant, const Version *p_version, const StageTemplate &p_template) {
for (uint32_t i = 0; i < p_template.chunks.size(); i++) {
const StageTemplate::Chunk &chunk = p_template.chunks[i];
for (const StageTemplate::Chunk &chunk : p_template.chunks) {
switch (chunk.type) {
case StageTemplate::Chunk::TYPE_VERSION_DEFINES: {
builder.append("\n"); //make sure defines begin at newline

View File

@ -842,15 +842,15 @@ void MeshStorage::mesh_instance_set_blend_shape_weight(RID p_mesh_instance, int
}
void MeshStorage::_mesh_instance_clear(MeshInstance *mi) {
for (uint32_t i = 0; i < mi->surfaces.size(); i++) {
if (mi->surfaces[i].versions) {
for (uint32_t j = 0; j < mi->surfaces[i].version_count; j++) {
RD::get_singleton()->free(mi->surfaces[i].versions[j].vertex_array);
for (const RendererRD::MeshStorage::MeshInstance::Surface surface : mi->surfaces) {
if (surface.versions) {
for (uint32_t j = 0; j < surface.version_count; j++) {
RD::get_singleton()->free(surface.versions[j].vertex_array);
}
memfree(mi->surfaces[i].versions);
memfree(surface.versions);
}
if (mi->surfaces[i].vertex_buffer.is_valid()) {
RD::get_singleton()->free(mi->surfaces[i].vertex_buffer);
if (surface.vertex_buffer.is_valid()) {
RD::get_singleton()->free(surface.vertex_buffer);
}
}
mi->surfaces.clear();
@ -866,8 +866,8 @@ void MeshStorage::_mesh_instance_clear(MeshInstance *mi) {
void MeshStorage::_mesh_instance_add_surface(MeshInstance *mi, Mesh *mesh, uint32_t p_surface) {
if (mesh->blend_shape_count > 0 && mi->blend_weights_buffer.is_null()) {
mi->blend_weights.resize(mesh->blend_shape_count);
for (uint32_t i = 0; i < mi->blend_weights.size(); i++) {
mi->blend_weights[i] = 0;
for (float &weight : mi->blend_weights) {
weight = 0;
}
mi->blend_weights_buffer = RD::get_singleton()->storage_buffer_create(sizeof(float) * mi->blend_weights.size(), mi->blend_weights.to_byte_array());
mi->weights_dirty = true;

View File

@ -851,9 +851,9 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
collision_heightmap_texture = p_particles->sdf_collision_texture;
//replace in all other history frames where used because parameters are no longer valid if screen moves
for (uint32_t i = 1; i < p_particles->frame_history.size(); i++) {
if (p_particles->frame_history[i].collider_count > 0 && p_particles->frame_history[i].colliders[0].type == ParticlesFrameParams::COLLISION_TYPE_2D_SDF) {
p_particles->frame_history[i].colliders[0] = frame_params.colliders[0];
for (ParticlesFrameParams &params : p_particles->frame_history) {
if (params.collider_count > 0 && params.colliders[0].type == ParticlesFrameParams::COLLISION_TYPE_2D_SDF) {
params.colliders[0] = frame_params.colliders[0];
}
}
}

View File

@ -3096,15 +3096,15 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
#endif
if (cull_to > thread_cull_threshold) {
//multiple threads
for (uint32_t i = 0; i < scene_cull_result_threads.size(); i++) {
scene_cull_result_threads[i].clear();
for (InstanceCullResult &thread : scene_cull_result_threads) {
thread.clear();
}
WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &RendererSceneCull::_scene_cull_threaded, &cull_data, scene_cull_result_threads.size(), -1, true, SNAME("RenderCullInstances"));
WorkerThreadPool::get_singleton()->wait_for_group_task_completion(group_task);
for (uint32_t i = 0; i < scene_cull_result_threads.size(); i++) {
scene_cull_result.append_from(scene_cull_result_threads[i]);
for (InstanceCullResult &thread : scene_cull_result_threads) {
scene_cull_result.append_from(thread);
}
} else {
@ -4134,8 +4134,8 @@ RendererSceneCull::RendererSceneCull() {
scene_cull_result.init(&rid_cull_page_pool, &geometry_instance_cull_page_pool, &instance_cull_page_pool);
scene_cull_result_threads.resize(WorkerThreadPool::get_singleton()->get_thread_count());
for (uint32_t i = 0; i < scene_cull_result_threads.size(); i++) {
scene_cull_result_threads[i].init(&rid_cull_page_pool, &geometry_instance_cull_page_pool, &instance_cull_page_pool);
for (InstanceCullResult &thread : scene_cull_result_threads) {
thread.init(&rid_cull_page_pool, &geometry_instance_cull_page_pool, &instance_cull_page_pool);
}
indexer_update_iterations = GLOBAL_GET("rendering/limits/spatial_indexer/update_iterations_per_frame");
@ -4163,8 +4163,8 @@ RendererSceneCull::~RendererSceneCull() {
}
scene_cull_result.reset();
for (uint32_t i = 0; i < scene_cull_result_threads.size(); i++) {
scene_cull_result_threads[i].reset();
for (InstanceCullResult &thread : scene_cull_result_threads) {
thread.reset();
}
scene_cull_result_threads.clear();

View File

@ -330,8 +330,8 @@ String ShaderPreprocessor::vector_to_string(const LocalVector<char32_t> &p_v, in
String ShaderPreprocessor::tokens_to_string(const LocalVector<Token> &p_tokens) {
LocalVector<char32_t> result;
for (uint32_t i = 0; i < p_tokens.size(); i++) {
result.push_back(p_tokens[i].text);
for (const Token &token : p_tokens) {
result.push_back(token.text);
}
return vector_to_string(result);
}

View File

@ -2802,9 +2802,7 @@ void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry
Vector<Vector3> vertices;
Vector<Vector3> normals;
for (uint32_t i = 0; i < p_mesh_data.faces.size(); i++) {
const Geometry3D::MeshData::Face &f = p_mesh_data.faces[i];
for (const Geometry3D::MeshData::Face &f : p_mesh_data.faces) {
for (uint32_t j = 2; j < f.indices.size(); j++) {
vertices.push_back(p_mesh_data.vertices[f.indices[0]]);
normals.push_back(f.plane.normal);