mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 10:21:04 +00:00
Fix createUnion internal function of polygon.cpp
Added special treatment in cases of horizontal lines which input argument to createUnion is “ints == 0”. Conditionals were sorted, it was being generate extra scan segment pair next to pair in analysis, instead of an augmentation of it.
This commit is contained in:
parent
62802cfbdf
commit
8ae289d7e6
@ -40,15 +40,21 @@ static void createUnion(std::vector<int>& pairs,
|
||||
int& ints)
|
||||
{
|
||||
bool unionDone = false;
|
||||
ASSERT(ints >= 0);
|
||||
if (ints == 0) {
|
||||
pairs.push_back(x);
|
||||
pairs.push_back(x);
|
||||
ints+=2;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0; i < ints - (ints%2); i+=2) {
|
||||
// Case:
|
||||
// pairs[i] pairs[i+1]
|
||||
// O --------- O
|
||||
// -x-
|
||||
if (x < pairs[i]) {
|
||||
pairs.insert(pairs.begin()+i, x);
|
||||
pairs.insert(pairs.begin()+i, x);
|
||||
ints+=2;
|
||||
if (x == pairs[i] - 1) {
|
||||
pairs[i] = x;
|
||||
unionDone = true;
|
||||
break;
|
||||
}
|
||||
@ -56,8 +62,10 @@ static void createUnion(std::vector<int>& pairs,
|
||||
// pairs[i] pairs[i+1]
|
||||
// O --------- O
|
||||
// -x-
|
||||
else if (x == pairs[i] - 1) {
|
||||
pairs[i] = x;
|
||||
else if (x < pairs[i] - 1) {
|
||||
pairs.insert(pairs.begin()+i, x);
|
||||
pairs.insert(pairs.begin()+i, x);
|
||||
ints+=2;
|
||||
unionDone = true;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user