summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2021-07-15 23:45:57 -0400
committerAaron Franke <arnfranke@yahoo.com>2021-07-23 17:38:28 -0400
commit4e6efd1b07f1c6d53d226977ddc729333b74306a (patch)
treea52f672e7f622bb65e3b65f2a2edc9d19b1ecdcf /servers/rendering
parentb918c4c3ce84af1f8af2d06ef31784f48a15551a (diff)
Use C++ iterators for Lists in many situations
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.cpp23
-rw-r--r--servers/rendering/renderer_rd/shader_compiler_rd.cpp12
-rw-r--r--servers/rendering/renderer_scene_cull.cpp36
-rw-r--r--servers/rendering/rendering_device_binds.h6
-rw-r--r--servers/rendering/shader_language.cpp10
5 files changed, 41 insertions, 46 deletions
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
index 2657fa3ae8..9d898f6275 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
@@ -2716,9 +2716,7 @@ void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_su
mesh->surfaces[mesh->surface_count] = s;
mesh->surface_count++;
- for (List<MeshInstance *>::Element *E = mesh->instances.front(); E; E = E->next()) {
- //update instances
- MeshInstance *mi = E->get();
+ for (MeshInstance *mi : mesh->instances) {
_mesh_instance_add_surface(mi, mesh, mesh->surface_count - 1);
}
@@ -3029,8 +3027,7 @@ void RendererStorageRD::mesh_clear(RID p_mesh) {
mesh->surface_count = 0;
mesh->material_cache.clear();
//clear instance data
- for (List<MeshInstance *>::Element *E = mesh->instances.front(); E; E = E->next()) {
- MeshInstance *mi = E->get();
+ for (MeshInstance *mi : mesh->instances) {
_mesh_instance_clear(mi);
}
mesh->has_bone_weights = false;
@@ -8413,10 +8410,10 @@ void RendererStorageRD::global_variables_load_settings(bool p_load_textures) {
List<PropertyInfo> settings;
ProjectSettings::get_singleton()->get_property_list(&settings);
- for (List<PropertyInfo>::Element *E = settings.front(); E; E = E->next()) {
- if (E->get().name.begins_with("shader_globals/")) {
- StringName name = E->get().name.get_slice("/", 1);
- Dictionary d = ProjectSettings::get_singleton()->get(E->get().name);
+ for (PropertyInfo &E : settings) {
+ if (E.name.begins_with("shader_globals/")) {
+ StringName name = E.name.get_slice("/", 1);
+ Dictionary d = ProjectSettings::get_singleton()->get(E.name);
ERR_CONTINUE(!d.has("type"));
ERR_CONTINUE(!d.has("value"));
@@ -8584,8 +8581,8 @@ void RendererStorageRD::_update_global_variables() {
if (global_variables.must_update_buffer_materials) {
// only happens in the case of a buffer variable added or removed,
// so not often.
- for (List<RID>::Element *E = global_variables.materials_using_buffer.front(); E; E = E->next()) {
- Material *material = material_owner.getornull(E->get());
+ for (RID E : global_variables.materials_using_buffer) {
+ Material *material = material_owner.getornull(E);
ERR_CONTINUE(!material); //wtf
_material_queue_update(material, true, false);
@@ -8597,8 +8594,8 @@ void RendererStorageRD::_update_global_variables() {
if (global_variables.must_update_texture_materials) {
// only happens in the case of a buffer variable added or removed,
// so not often.
- for (List<RID>::Element *E = global_variables.materials_using_texture.front(); E; E = E->next()) {
- Material *material = material_owner.getornull(E->get());
+ for (RID E : global_variables.materials_using_texture) {
+ Material *material = material_owner.getornull(E);
ERR_CONTINUE(!material); //wtf
_material_queue_update(material, false, true);
diff --git a/servers/rendering/renderer_rd/shader_compiler_rd.cpp b/servers/rendering/renderer_rd/shader_compiler_rd.cpp
index 1dde92d8ff..8c4070562e 100644
--- a/servers/rendering/renderer_rd/shader_compiler_rd.cpp
+++ b/servers/rendering/renderer_rd/shader_compiler_rd.cpp
@@ -760,11 +760,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
if (var_frag_to_light.size() > 0) {
String gcode = "\n\nstruct {\n";
- for (List<Pair<StringName, SL::ShaderNode::Varying>>::Element *E = var_frag_to_light.front(); E; E = E->next()) {
- gcode += "\t" + _prestr(E->get().second.precision) + _typestr(E->get().second.type) + " " + _mkid(E->get().first);
- if (E->get().second.array_size > 0) {
+ for (Pair<StringName, SL::ShaderNode::Varying> &E : var_frag_to_light) {
+ gcode += "\t" + _prestr(E.second.precision) + _typestr(E.second.type) + " " + _mkid(E.first);
+ if (E.second.array_size > 0) {
gcode += "[";
- gcode += itos(E->get().second.array_size);
+ gcode += itos(E.second.array_size);
gcode += "]";
}
gcode += ";\n";
@@ -1394,8 +1394,8 @@ void ShaderCompilerRD::initialize(DefaultIdentifierActions p_actions) {
ShaderLanguage::get_builtin_funcs(&func_list);
- for (List<String>::Element *E = func_list.front(); E; E = E->next()) {
- internal_functions.insert(E->get());
+ for (String &E : func_list) {
+ internal_functions.insert(E);
}
texture_functions.insert("texture");
texture_functions.insert("textureProj");
diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp
index 3336623f21..2ade8454bb 100644
--- a/servers/rendering/renderer_scene_cull.cpp
+++ b/servers/rendering/renderer_scene_cull.cpp
@@ -2876,8 +2876,8 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
Vector<Instance *> lights_with_shadow;
- for (List<Instance *>::Element *E = scenario->directional_lights.front(); E; E = E->next()) {
- if (!E->get()->visible) {
+ for (Instance *E : scenario->directional_lights) {
+ if (!E->visible) {
continue;
}
@@ -2885,13 +2885,13 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
break;
}
- InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
+ InstanceLightData *light = static_cast<InstanceLightData *>(E->base_data);
//check shadow..
if (light) {
- if (p_using_shadows && p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(E->get()->base) && !(RSG::storage->light_get_type(E->get()->base) == RS::LIGHT_DIRECTIONAL && RSG::storage->light_directional_is_sky_only(E->get()->base))) {
- lights_with_shadow.push_back(E->get());
+ if (p_using_shadows && p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(E->base) && !(RSG::storage->light_get_type(E->base) == RS::LIGHT_DIRECTIONAL && RSG::storage->light_directional_is_sky_only(E->base))) {
+ lights_with_shadow.push_back(E);
}
//add to list
directional_lights.push_back(light->instance);
@@ -3391,8 +3391,7 @@ void RendererSceneCull::render_probes() {
idx++;
}
- for (List<Instance *>::Element *E = probe->owner->scenario->directional_lights.front(); E; E = E->next()) {
- Instance *instance = E->get();
+ for (Instance *instance : probe->owner->scenario->directional_lights) {
InstanceLightData *instance_light = (InstanceLightData *)instance->base_data;
if (!instance->visible) {
continue;
@@ -3465,8 +3464,7 @@ void RendererSceneCull::render_probes() {
idx++;
}
- for (List<Instance *>::Element *E = probe->owner->scenario->directional_lights.front(); E; E = E->next()) {
- Instance *instance = E->get();
+ for (Instance *instance : probe->owner->scenario->directional_lights) {
InstanceLightData *instance_light = (InstanceLightData *)instance->base_data;
if (!instance->visible) {
continue;
@@ -3573,26 +3571,26 @@ void RendererSceneCull::render_particle_colliders() {
void RendererSceneCull::_update_instance_shader_parameters_from_material(Map<StringName, Instance::InstanceShaderParameter> &isparams, const Map<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material) {
List<RendererStorage::InstanceShaderParam> plist;
RSG::storage->material_get_instance_shader_parameters(p_material, &plist);
- for (List<RendererStorage::InstanceShaderParam>::Element *E = plist.front(); E; E = E->next()) {
- StringName name = E->get().info.name;
+ for (RendererStorage::InstanceShaderParam &E : plist) {
+ StringName name = E.info.name;
if (isparams.has(name)) {
- if (isparams[name].info.type != E->get().info.type) {
- WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E->get().info.name + "', but they do it with different data types. Only the first one (in order) will display correctly.");
+ if (isparams[name].info.type != E.info.type) {
+ WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E.info.name + "', but they do it with different data types. Only the first one (in order) will display correctly.");
}
- if (isparams[name].index != E->get().index) {
- WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E->get().info.name + "', but they do it with different indices. Only the first one (in order) will display correctly.");
+ if (isparams[name].index != E.index) {
+ WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E.info.name + "', but they do it with different indices. Only the first one (in order) will display correctly.");
}
continue; //first one found always has priority
}
Instance::InstanceShaderParameter isp;
- isp.index = E->get().index;
- isp.info = E->get().info;
- isp.default_value = E->get().default_value;
+ isp.index = E.index;
+ isp.info = E.info;
+ isp.default_value = E.default_value;
if (existing_isparams.has(name)) {
isp.value = existing_isparams[name].value;
} else {
- isp.value = E->get().default_value;
+ isp.value = E.default_value;
}
isparams[name] = isp;
}
diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h
index 4c31880faf..df1b40974f 100644
--- a/servers/rendering/rendering_device_binds.h
+++ b/servers/rendering/rendering_device_binds.h
@@ -388,9 +388,9 @@ protected:
versions.clear();
List<Variant> keys;
p_versions.get_key_list(&keys);
- for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
- StringName name = E->get();
- Ref<RDShaderBytecode> bc = p_versions[E->get()];
+ for (Variant &E : keys) {
+ StringName name = E;
+ Ref<RDShaderBytecode> bc = p_versions[E];
ERR_CONTINUE(bc.is_null());
versions[name] = bc;
}
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 3b9aca200b..2db246c31f 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -4448,12 +4448,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
String member_name = String(ident.ptr());
if (shader->structs.has(st)) {
StructNode *n = shader->structs[st].shader_struct;
- for (List<MemberNode *>::Element *E = n->members.front(); E; E = E->next()) {
- if (String(E->get()->name) == member_name) {
- member_type = E->get()->datatype;
- array_size = E->get()->array_size;
+ for (MemberNode *E : n->members) {
+ if (String(E->name) == member_name) {
+ member_type = E->datatype;
+ array_size = E->array_size;
if (member_type == TYPE_STRUCT) {
- member_struct_name = E->get()->struct_name;
+ member_struct_name = E->struct_name;
}
ok = true;
break;