Skip to content
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

Clarify Geometry.offset_polygon_2d regarding vertices translation #38390

Merged
merged 1 commit into from
Jul 2, 2020
Merged

Clarify Geometry.offset_polygon_2d regarding vertices translation #38390

merged 1 commit into from
Jul 2, 2020

Conversation

Xrayez
Copy link
Contributor

@Xrayez Xrayez commented May 1, 2020

Kind of closes godotengine/godot-proposals#777 (renaming is subject to discussion, but I think it's more about the confusion in the first place).

The method is used to either inflate or deflate a polygon.
For translating/transforming a polygon, use Transform2D.xform, as in #31761.

@Xrayez Xrayez requested a review from a team as a code owner May 1, 2020 14:56
doc/classes/Geometry.xml Outdated Show resolved Hide resolved
@Xrayez Xrayez marked this pull request as draft May 28, 2020 12:24
@@ -200,6 +200,13 @@
Inflates or deflates [code]polygon[/code] by [code]delta[/code] units (pixels). If [code]delta[/code] is positive, makes the polygon grow outward. If [code]delta[/code] is negative, shrinks the polygon inward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. Returns an empty array if [code]delta[/code] is negative and the absolute value of it approximately exceeds the minimum bounding rectangle dimensions of the polygon.
Each polygon's vertices will be rounded as determined by [code]join_type[/code], see [enum PolyJoinType].
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling [method is_polygon_clockwise].
[b]Note:[/b] for translating the polygon's vertices specifically, use [method Transform2D.xform] method:
[codeblock]
var polygon = PackedVector2Array([Vector2(0, 0), Vector2(100, 0), Vector2(100, 100), Vector2(0, 100)])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PackedVector2ArrayPoolVector2Array in 3.2.

@Xrayez Xrayez marked this pull request as ready for review July 1, 2020 10:31
@Xrayez
Copy link
Contributor Author

Xrayez commented Jul 1, 2020

Not sure why I marked this as WIP, likely because of godotengine/godot-proposals#913, but it's fine to merge as is. The offset terminology is common for polygon inflating/deflating/buffering etc.

@akien-mga akien-mga added this to the 4.0 milestone Jul 1, 2020
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Left a nitpick but marking as approved already to remember to merge it.

The method is used to either inflate or deflate a polygon.
For translating/transforming a polygon, use `Transform2D.xform`.
@akien-mga akien-mga merged commit f4aea93 into godotengine:master Jul 2, 2020
@akien-mga
Copy link
Member

Thanks!

@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jul 2, 2020
@Xrayez Xrayez deleted the doc-offset-poly-translate branch July 2, 2020 12:29
@akien-mga
Copy link
Member

Cherry-picked for 3.2.3.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jul 3, 2020
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.

create/fix offset_polygon_2d(), an offsetting function for PoolVector2Array by a single vector
3 participants