-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fixed physics collider visualization offset #555
base: master
Are you sure you want to change the base?
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)
Commit history is such a mess because I failed rebasing to master. |
Hazel/src/Hazel/Scene/Components.h
Outdated
@@ -120,6 +120,7 @@ namespace Hazel { | |||
{ | |||
glm::vec2 Offset = { 0.0f, 0.0f }; | |||
glm::vec2 Size = { 0.5f, 0.5f }; | |||
float Rotation = 0.0f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Hazel/src/Hazel/Scene/Components.h
Outdated
@@ -120,6 +120,7 @@ namespace Hazel { | |||
{ | |||
glm::vec2 Offset = { 0.0f, 0.0f }; | |||
glm::vec2 Size = { 0.5f, 0.5f }; | |||
float Rotation = 0.0f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.
I applied your requested changes @TheCherno 👍 |
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
Box2D
box 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.