Cleanup: GPv3: Use `const` in a few places

This commit is contained in:
Falk David 2024-04-02 16:39:54 +02:00
parent 8a1c2b172a
commit 45a0b6cc1a
3 changed files with 26 additions and 25 deletions

View File

@ -578,7 +578,7 @@ void Drawing::set_texture_matrices(Span<float4x2> matrices, const IndexMask &sel
const float4x2 texspace = matrices[pos];
/* We do the computation using doubles to avoid numerical precision errors. */
double4x3 strokemat4x3 = double4x3(expand_4x2_mat(strokemat));
const double4x3 strokemat4x3 = double4x3(expand_4x2_mat(strokemat));
/*
* We want to solve for `texture_matrix` in the equation: `texspace = texture_matrix *

View File

@ -639,22 +639,23 @@ static GPENCIL_tObject *grease_pencil_object_cache_populate(GPENCIL_PrivateData
vcount = 0;
};
const auto drawcall_add = [&](blender::gpu::Batch *draw_geom, int v_first, int v_count) {
const auto drawcall_add =
[&](blender::gpu::Batch *draw_geom, const int v_first, const int v_count) {
#if DISABLE_BATCHING
DRW_shgroup_call_range(grp, ob, geom, v_first, v_count);
return;
DRW_shgroup_call_range(grp, ob, geom, v_first, v_count);
return;
#endif
int last = vfirst + vcount;
/* Interrupt draw-call grouping if the sequence is not consecutive. */
if ((draw_geom != iter_geom) || (v_first - last > 0)) {
drawcall_flush();
}
iter_geom = draw_geom;
if (vfirst == -1) {
vfirst = v_first;
}
vcount = v_first + v_count - vfirst;
};
int last = vfirst + vcount;
/* Interrupt draw-call grouping if the sequence is not consecutive. */
if ((draw_geom != iter_geom) || (v_first - last > 0)) {
drawcall_flush();
}
iter_geom = draw_geom;
if (vfirst == -1) {
vfirst = v_first;
}
vcount = v_first + v_count - vfirst;
};
int t_offset = 0;
const Vector<DrawingInfo> drawings = retrieve_visible_drawings(*pd->scene, grease_pencil);
@ -701,7 +702,7 @@ static GPENCIL_tObject *grease_pencil_object_cache_populate(GPENCIL_PrivateData
visible_strokes.foreach_index([&](const int stroke_i) {
const IndexRange points = points_by_curve[stroke_i];
const int material_index = stroke_materials[stroke_i];
MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, material_index + 1);
const MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, material_index + 1);
const bool hide_material = (gp_style->flag & GP_MATERIAL_HIDE) != 0;
const bool show_stroke = ((gp_style->flag & GP_MATERIAL_STROKE_SHOW) != 0);
@ -736,9 +737,9 @@ static GPENCIL_tObject *grease_pencil_object_cache_populate(GPENCIL_PrivateData
gpencil_material_resources_get(
matpool, mat_ofs + material_index, &new_tex_stroke, &new_tex_fill, &new_ubo_mat);
bool resource_changed = (ubo_mat != new_ubo_mat) ||
(new_tex_fill && (new_tex_fill != tex_fill)) ||
(new_tex_stroke && (new_tex_stroke != tex_stroke));
const bool resource_changed = (ubo_mat != new_ubo_mat) ||
(new_tex_fill && (new_tex_fill != tex_fill)) ||
(new_tex_stroke && (new_tex_stroke != tex_stroke));
if (resource_changed) {
drawcall_flush();
@ -771,16 +772,16 @@ static GPENCIL_tObject *grease_pencil_object_cache_populate(GPENCIL_PrivateData
}
if (show_fill) {
int v_first = t_offset * 3;
int v_count = num_stroke_triangles * 3;
const int v_first = t_offset * 3;
const int v_count = num_stroke_triangles * 3;
drawcall_add(geom, v_first, v_count);
}
t_offset += num_stroke_triangles;
if (show_stroke) {
int v_first = t_offset * 3;
int v_count = num_stroke_vertices * 2 * 3;
const int v_first = t_offset * 3;
const int v_count = num_stroke_vertices * 2 * 3;
drawcall_add(geom, v_first, v_count);
}

View File

@ -589,12 +589,12 @@ static void grease_pencil_geom_batch_ensure(Object &object,
};
visible_strokes.foreach_index([&](const int curve_i, const int pos) {
IndexRange points = points_by_curve[curve_i];
const IndexRange points = points_by_curve[curve_i];
const bool is_cyclic = cyclic[curve_i];
const int verts_start_offset = verts_start_offsets[pos];
const int tris_start_offset = tris_start_offsets[pos];
const int num_verts = 1 + points.size() + (is_cyclic ? 1 : 0) + 1;
IndexRange verts_range = IndexRange(verts_start_offset, num_verts);
const IndexRange verts_range = IndexRange(verts_start_offset, num_verts);
MutableSpan<GreasePencilStrokeVert> verts_slice = verts.slice(verts_range);
MutableSpan<GreasePencilColorVert> cols_slice = cols.slice(verts_range);
const float4x2 texture_matrix = texture_matrices[curve_i] * object_space_to_layer_space;