Skip to content

fix: Reduce redundant cell checks for large radii in partition circle fill logic #1426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,8 @@ void PartitionData::hLineCircle(Int x1, Int x2, Int y)
}

// -----------------------------------------------------------------------------
// Marks all partition cells that intersect a circle of the given center and radius
// as covered by this object using a variation of the midpoint circle algorithm.
void PartitionData::doCircleFill(
Real centerX,
Real centerY,
Expand All @@ -1855,7 +1857,12 @@ void PartitionData::doCircleFill(

Int y = cellRadius - 1;
Int dec = 3 - 2*cellRadius;

#if RETAIL_COMPATIBLE_CRC
for (Int x = 0; x < cellRadius; x++)
#else
for (Int x = 0; x <= y; x++)
#endif
{
hLineCircle(cellCenterX - x, cellCenterX + x, cellCenterY + y);
hLineCircle(cellCenterX - x, cellCenterX + x, cellCenterY - y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,8 @@ void PartitionData::hLineCircle(Int x1, Int x2, Int y)
}

// -----------------------------------------------------------------------------
// Marks all partition cells that intersect a circle of the given center and radius
// as covered by this object using a variation of the midpoint circle algorithm.
void PartitionData::doCircleFill(
Real centerX,
Real centerY,
Expand All @@ -1859,7 +1861,12 @@ void PartitionData::doCircleFill(

Int y = cellRadius - 1;
Int dec = 3 - 2*cellRadius;

#if RETAIL_COMPATIBLE_CRC
for (Int x = 0; x < cellRadius; x++)
#else
for (Int x = 0; x <= y; x++)
#endif
{
hLineCircle(cellCenterX - x, cellCenterX + x, cellCenterY + y);
hLineCircle(cellCenterX - x, cellCenterX + x, cellCenterY - y);
Expand Down
Loading