summaryrefslogtreecommitdiff
path: root/servers/rendering/renderer_rd/storage_rd
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2022-12-29 01:24:45 +0100
committerkobewi <kobewi4e@gmail.com>2023-01-21 18:44:42 +0100
commit615c5170345b2b549be6271d11319a10a5ce34bf (patch)
treee8a8011f1c5a166636a9f68b65e108ad7bc878a0 /servers/rendering/renderer_rd/storage_rd
parent277d5361df22c4aa18e93354190b7694dfdf6249 (diff)
Use range iterators in LocalVector loops
Diffstat (limited to 'servers/rendering/renderer_rd/storage_rd')
-rw-r--r--servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp18
-rw-r--r--servers/rendering/renderer_rd/storage_rd/particles_storage.cpp6
2 files changed, 12 insertions, 12 deletions
diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
index 62da62403f..46a0d85ba8 100644
--- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
@@ -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;
diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
index e4149f6bbd..f4c3e769a8 100644
--- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
@@ -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];
}
}
}