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

C#: Replace Xform and XformInv with * operator #64729

Merged
merged 1 commit into from
Aug 23, 2022

Conversation

raulsntos
Copy link
Member

@raulsntos raulsntos commented Aug 22, 2022

  • In cases where both Xform/XformInv and the * operator were implemented the Xform/XformInv methods were removed in favor of the * operator.
  • In cases where the Xform/XformInv existed but not the * operator, the Xform/XformInv methods were replaced with the * operator.
  • In cases where no method existed, a new * operator has been implemented to support the same operations that are supported in GDScript.
  • Fixes the Transform.Xform and Transform.XformInv with Rect2 implementation to use a zero Rect2 size to start expanding from (which is how it's implemented in C++).

@@ -552,11 +527,11 @@ public Transform2D(real_t rotation, Vector2 origin)
Vector2 to2 = new Vector2(rect.Position.x + rect.Size.x, rect.Position.y + rect.Size.y) * transform;
Vector2 to3 = new Vector2(rect.Position.x + rect.Size.x, rect.Position.y) * transform;

return new Rect2(pos, rect.Size).Expand(to1).Expand(to2).Expand(to3);
return new Rect2(pos, new Vector2()).Expand(to1).Expand(to2).Expand(to3);
Copy link
Member

Choose a reason for hiding this comment

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

This is a separate bug fix. It looks good, but it's questionable to sneak this in with Xform refactor.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, I thought since I was modifying all the Xform methods and I noticed this difference with the C++ implementation it might make sense to include it rather than create a separate PR but probably should extract it.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with it being in this PR, or another, but it should at least be mentioned in the PR description.

- In cases where both `Xform`/`XformInv` and the `*` operator were
implemented the `Xform`/`XformInv` methods were removed in favor of the
`*` operator.
- In cases where the `Xform`/`XformInv` existed but not the `*` operator,
the `Xform`/`XformInv` methods were replaced with the `*` operator.
- In cases where no method existed, a new `*` operator has been
implemented to support the same operations that are supported in GDScript.
- Fixes the `Transform.Xform` and `Transform.XformInv` with `Rect2`
implementation to use a zero `Rect2` size to start expanding from
(which is how it's implemented in C++).
@raulsntos raulsntos force-pushed the csharp-xform-operator branch from 90f8e21 to 0b8b733 Compare August 22, 2022 19:11
@raulsntos raulsntos added the bug label Aug 22, 2022
@neikeq
Copy link
Contributor

neikeq commented Aug 22, 2022

Is it the same as GDScript? Was xform replaced with operators there?

@akien-mga
Copy link
Member

Yes.

@akien-mga akien-mga merged commit 7e4817a into godotengine:master Aug 23, 2022
@akien-mga
Copy link
Member

Thanks!

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