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

Add transform methods for PoolVector*Array #31761

Merged
merged 1 commit into from
Sep 1, 2019
Merged

Add transform methods for PoolVector*Array #31761

merged 1 commit into from
Sep 1, 2019

Conversation

Xrayez
Copy link
Contributor

@Xrayez Xrayez commented Aug 29, 2019

Added array version of Vector2 transforms in 2D and Vector3 in 3D.

PoolVector2Array and PoolVector3Array were the only missing Variant types in both Transform2D and Transform respectively.

This should simplify use cases where the points needs to be transformed in batch, and it's not limited to drawing.

This should also help polygon transformations to aid boolean operations: #28987. I'd like to remove exposed transform_points_2d there which was included for the same reason if this gets merged (I wasn't aware of this feature myself).

It's going to become as easy as:

points = Transform2D(0, Vector2(100, 100).xform(points)

Instead of:

var points_transformed = []
var trans = Transform2D(0, Vector2(100, 100)
for p in points:
	points_transformed.append(trans.xform(p))

Test project

xform-pool-vector-array.zip

@Xrayez Xrayez requested a review from a team as a code owner August 29, 2019 10:36
@bojidar-bg
Copy link
Contributor

Might be nice to update Transform2D in the C# bindings, and probably to add a similar feature to 3D as well.

@Xrayez
Copy link
Contributor Author

Xrayez commented Aug 29, 2019

Upon a glance, C# bindings don't seem to have Rect2 transforms either.

As for 3D, seems relatively easy to add, since it would just wrap those Vector3 transforms without me having to learn 3D math!

Similarly to `Vector2` and `Rect2` transforms in 2D and Vector3, Plane,
and AABB in 3D. PoolVector2Array and PoolVector3Array were the only
missing Variant types in both Transform2D and Transform respectively.
@Xrayez Xrayez changed the title Add transform methods for PoolVector2Array Add transform methods for PoolVector*Array Aug 29, 2019
@Xrayez
Copy link
Contributor Author

Xrayez commented Aug 29, 2019

Similar enhancements done for 3D (literally almost copy-pasted), seems to work but I don't have extensive knowledge in 3D to test this more thoroughly.

@akien-mga akien-mga added this to the 3.2 milestone Sep 1, 2019
@akien-mga akien-mga merged commit c693b5a into godotengine:master Sep 1, 2019
@akien-mga
Copy link
Member

Thanks!

@Xrayez Xrayez deleted the trans2d-vector2array branch September 1, 2019 11:07
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.

4 participants