Fixed physics collider visualization offset#555
Open
erikrl2 wants to merge 7 commits intoTheCherno:masterfrom
Open
Fixed physics collider visualization offset#555erikrl2 wants to merge 7 commits intoTheCherno:masterfrom
erikrl2 wants to merge 7 commits intoTheCherno:masterfrom
Conversation
(the collider radius is only dependent on the entity's x-scale)
(the collider radius is only dependent on the entity's x-scale)
Author
|
Commit history is such a mess because I failed rebasing to master. |
TheCherno
requested changes
Jul 4, 2022
| { | ||
| glm::vec2 Offset = { 0.0f, 0.0f }; | ||
| glm::vec2 Size = { 0.5f, 0.5f }; | ||
| float Rotation = 0.0f; |
Owner
There was a problem hiding this comment.
Why has this Rotation variable been added to BoxCollider2DComponent? It doesn't seem to have any UI for setting it anywhere, so it seems like it would just always be 0.
There was a problem hiding this comment.
I think a box collider should be able to be rotated independently. Instead of removing rotation. You can add the field in SceneHierarchyPanel and make it serializable.
TheCherno
requested changes
Jul 4, 2022
| { | ||
| glm::vec2 Offset = { 0.0f, 0.0f }; | ||
| glm::vec2 Size = { 0.5f, 0.5f }; | ||
| float Rotation = 0.0f; |
Author
|
I applied your requested changes @TheCherno 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the issue
The collider visualization rectangle does not match the actual position of the collider when using offset:
PR impact
List of related issues/PRs this will solve:
Proposed fix
Adding the offset and rotation to the
Box2Dbox shape:Calculating the relative transform of the visualization rectangle before the entity's transform:
Now it looks like:
Also fixed this for circle colliders.
Note:
Needed to add Rotation attribute to
BoxCollider2DComponent. You could expose this to the editor and serialize it.