Skip to content

Fix area weighting in polygon geometric center calculation#119167

Open
red-bean-pasta wants to merge 1 commit into
godotengine:masterfrom
red-bean-pasta:fix-polygon-centroid
Open

Fix area weighting in polygon geometric center calculation#119167
red-bean-pasta wants to merge 1 commit into
godotengine:masterfrom
red-bean-pasta:fix-polygon-centroid

Conversation

@red-bean-pasta
Copy link
Copy Markdown

AbstractPolygon2DEditor::_get_geometric_center() calculated the centroid of each sub-polygon, but then averaged those centroids equally. This may produce incorrect result when the sub-polygons have different areas.

This PR changes the final centroid calculation to use area-weighted average.

After / Before:
geometric_centroid_fix

@red-bean-pasta red-bean-pasta requested review from a team as code owners May 2, 2026 09:31
Copy link
Copy Markdown
Member

@YeldhamDev YeldhamDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The position of the center of mass makes more sense with PR, and the good looks fine. Would still like a review from someone who's better at geometrical math.

jak6jak added a commit to jak6jak-experiment/godot that referenced this pull request May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants