Refactor: Weight Paint Select Linked Faces #104577

Merged
Christoph Lendenfeld merged 15 commits from ChrisLend/blender:weight_paint_refactor_face_select into main 2023-02-23 08:26:44 +01:00
1 changed files with 10 additions and 5 deletions
Showing only changes of commit 4d31f0e500 - Show all commits

View File

@ -239,14 +239,19 @@ static void build_poly_connections(blender::AtomicDisjointSet &islands,
continue;
}
const MPoly &poly = polys[poly_index];
for (const int outer_loop_index : IndexRange(0, poly.totloop)) {
const MLoop &outer_mloop = loops[poly.loopstart + outer_loop_index];
const Span<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop);
ChrisLend marked this conversation as resolved
Review

I suggest using a separate const Span<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop); variable. Then the next loop can use for (const int outer_loop_index : poly_loops.index_range()) { and you don't have to add poly.totloop every time a loop in the poly is accessed.

I suggest using a separate `const Span<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop);` variable. Then the next loop can use `for (const int outer_loop_index : poly_loops.index_range()) {` and you don't have to add `poly.totloop` every time a loop in the poly is accessed.
Review

Use references instead of pointers, that should be your default in C++ code.

Use references instead of pointers, that should be your default in C++ code.

sure thing, missed that
out of curiosity: what is the reason for it?

sure thing, missed that out of curiosity: what is the reason for it?
Review

There are quite a few benefits-- they indicate non-null, they allow using . instead of ->, they can't be indexed (so they can't be mistaken for pointers to arrays). There's more info here:

https://stackoverflow.com/questions/57483/what-are-the-differences-between-a-pointer-variable-and-a-reference-variable

There are quite a few benefits-- they indicate non-null, they allow using `.` instead of `->`, they can't be indexed (so they can't be mistaken for pointers to arrays). There's more info here: https://stackoverflow.com/questions/57483/what-are-the-differences-between-a-pointer-variable-and-a-reference-variable
for (const int poly_loop_index : poly_loops.index_range()) {
const MLoop &outer_mloop = poly_loops[poly_loop_index];
if (skip_seams && (edges[outer_mloop.e].flag & ME_SEAM) != 0) {
continue;
}
for (int inner_loop_index = outer_loop_index + 1; inner_loop_index < poly.totloop;
inner_loop_index++) {
const MLoop &inner_mloop = loops[poly.loopstart + inner_loop_index];
for (const MLoop &inner_mloop :
poly_loops.slice(poly_loop_index, poly_loops.size() - poly_loop_index)) {
if (&outer_mloop == &inner_mloop) {
continue;
}
if (skip_seams && (edges[inner_mloop.e].flag & ME_SEAM) != 0) {
continue;
}