Fix world to collider local in shape containsPoint#926
Closed
jmiskovic wants to merge 1 commit intobjornbytes:devfrom
Closed
Fix world to collider local in shape containsPoint#926jmiskovic wants to merge 1 commit intobjornbytes:devfrom
jmiskovic wants to merge 1 commit intobjornbytes:devfrom
Conversation
Owner
|
I think diff --git src/modules/physics/physics.c src/modules/physics/physics.c
index b17b08a4..74a46368 100644
--- src/modules/physics/physics.c
+++ src/modules/physics/physics.c
@@ -2090,8 +2090,8 @@ void lovrShapeGetAABB(Shape* shape, float aabb[6]) {
static void inverseTransformPoint(float* point, float* position, float* orientation) {
float inverse[4];
quat_conjugate(quat_init(inverse, orientation));
- quat_rotate(inverse, point);
vec3_sub(point, position);
+ quat_rotate(inverse, point);
}
static void inverseTransformRay(float* origin, float* direction, float* position, float* orientation) {Also, it looks like all the |
Contributor
Author
Owner
|
Ok, I applied the diff from the comment. Thanks! |
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.

I noticed that shape attached to collider does incorrect query on :containsPoint().
I think the order of translation/rotation was wrong, but since inverseTransformPoint is used twice it was easier to switch to lovrColliderGetLocalPoint. The added benefit is that it will work better with motion interpolation.
Minimal reproduction:
I also checked
Shape:raycast(), that one gives correct results.