Skip to content

Commit 77fc559

Browse files
committed
SpriteHandler.h:
* Improved naming convention in VectorSprite::finalize_topology().
1 parent 3c04740 commit 77fc559

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

SpriteHandler.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -929,54 +929,54 @@ class VectorSprite : public Sprite
929929

930930
// 3. Try to connect linesegs via positions.
931931

932-
bool_vector visited(N, false); // Mark line segments.
933-
std::vector<int> path_indices;
934-
std::vector<int> temp_path_indices;
935-
std::unordered_set<int> visited_in_this_walk;
932+
bool_vector segs_visited(N, false); // Mark line segments.
933+
std::vector<int> path_seg_indices;
934+
std::vector<int> temp_path_seg_indices;
935+
std::unordered_set<int> segs_visited_in_this_walk;
936936

937-
for (int start_idx = 0; start_idx < N; ++start_idx)
937+
for (int start_seg_idx = 0; start_seg_idx < N; ++start_seg_idx)
938938
{
939-
if (visited[start_idx])
939+
if (segs_visited[start_seg_idx])
940940
continue;
941941

942-
path_indices.clear();
942+
path_seg_indices.clear();
943943

944-
for (int initial_vtx = 0; initial_vtx < 2; ++initial_vtx)
944+
for (int init_vtx_idx = 0; init_vtx_idx < 2; ++init_vtx_idx)
945945
{
946-
int curr_idx = start_idx;
947-
int curr_vtx = initial_vtx;
948-
Vec2 start_pos = vector_frame->open_polylines[start_idx].pos[initial_vtx];
946+
int curr_seg_idx = start_seg_idx;
947+
int curr_vtx_idx = init_vtx_idx;
948+
Vec2 start_pos = vector_frame->open_polylines[start_seg_idx].pos[init_vtx_idx];
949949

950-
temp_path_indices.clear();
951-
visited_in_this_walk.clear();
950+
temp_path_seg_indices.clear();
951+
segs_visited_in_this_walk.clear();
952952

953953
for (;;)
954954
{
955955
// Check early exit.
956-
if (visited[curr_idx] || visited_in_this_walk.count(curr_idx))
956+
if (segs_visited[curr_seg_idx] || segs_visited_in_this_walk.count(curr_seg_idx))
957957
break;
958958

959-
visited_in_this_walk.insert(curr_idx);
960-
temp_path_indices.push_back(curr_idx);
959+
segs_visited_in_this_walk.insert(curr_seg_idx);
960+
temp_path_seg_indices.push_back(curr_seg_idx);
961961

962-
const auto& seg = vector_frame->open_polylines[curr_idx];
962+
const auto& seg = vector_frame->open_polylines[curr_seg_idx];
963963
//visited[curr_idx] = true;
964964
//path_indices.emplace_back(curr_idx);
965965

966-
Vec2 next_pos = seg.pos[1 - curr_vtx];
966+
Vec2 next_pos = seg.pos[1 - curr_vtx_idx];
967967

968-
// Closed loop check.
968+
// Closed path (loop) check.
969969
if (math::distance_squared(next_pos, start_pos) < c_snap_dist_sq)
970970
{
971-
// Closed loop detected!
972-
std::vector<LineSeg> closed;
973-
for (int idx : temp_path_indices)
971+
// Closed path (loop) detected!
972+
std::vector<LineSeg> closed_path;
973+
for (int seg_idx : temp_path_seg_indices)
974974
{
975-
closed.emplace_back(vector_frame->open_polylines[idx]);
976-
visited[idx] = true;
975+
closed_path.emplace_back(vector_frame->open_polylines[seg_idx]);
976+
segs_visited[seg_idx] = true;
977977
}
978978

979-
vector_frame->closed_polylines.emplace_back(std::move(closed));
979+
vector_frame->closed_polylines.emplace_back(std::move(closed_path));
980980
break;
981981
}
982982

@@ -989,16 +989,16 @@ class VectorSprite : public Sprite
989989
if (next_pos_idx == -1)
990990
break;
991991

992-
const auto& candidates = pos_lineseg_map[next_pos_idx];
992+
const auto& candidate_segs = pos_lineseg_map[next_pos_idx];
993993

994994
// Try to find unvisited segment.
995995
bool found = false;
996-
for (const auto& lsd : candidates)
996+
for (const auto& lsd : candidate_segs)
997997
{
998-
if (!visited[lsd.idx] && !visited_in_this_walk.count(lsd.idx))
998+
if (!segs_visited[lsd.idx] && !segs_visited_in_this_walk.count(lsd.idx))
999999
{
1000-
curr_idx = lsd.idx;
1001-
curr_vtx = lsd.v_idx;
1000+
curr_seg_idx = lsd.idx;
1001+
curr_vtx_idx = lsd.v_idx;
10021002
found = true;
10031003
break;
10041004
}
@@ -1012,7 +1012,7 @@ class VectorSprite : public Sprite
10121012

10131013
// Remove visited from open_polylines (in reverse to not break indices).
10141014
for (int i = N - 1; i >= 0; --i)
1015-
if (visited[i])
1015+
if (segs_visited[i])
10161016
stlutils::erase_at(vector_frame->open_polylines, i);
10171017
}
10181018

0 commit comments

Comments
 (0)