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

feat: add ShapeCast function #247

Merged
merged 2 commits into from
Aug 5, 2023
Merged

feat: add ShapeCast function #247

merged 2 commits into from
Aug 5, 2023

Conversation

zOadT
Copy link
Collaborator

@zOadT zOadT commented Aug 4, 2023

This is part of Box2d 2.4.1. There is currently a bug in my implementation, will take a look at it later again.

const vertices = simplex.m_v;

// Get support point in -r direction
const indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(r)));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

BTW: In theory we could also write

const indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, r).neg());

Creates a Vec2 object less, but I don't think its worth it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it's ok, I'm changing vector functions anyway

@zOadT
Copy link
Collaborator Author

zOadT commented Aug 4, 2023

Think I found the problem, the test is wrong. Will try to fix it tomorrow!

@zOadT
Copy link
Collaborator Author

zOadT commented Aug 5, 2023

Works now, but the example has to be made a bit more accessible

// GJK-raycast
// Algorithm by Gino van den Bergen.
// "Smooth Mesh Contacts with GJK" in Game Physics Pearls. 2010
export const ShapeCast = function(output: ShapeCastOutput, input: ShapeCastInput): boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we put this in its own file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We would only have to export Simplex from Distance.ts. Would that be ok? Or should I move Simplex into its own file?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nevermind actually, this is good, thanks

@zOadT zOadT marked this pull request as ready for review August 5, 2023 08:15
@zOadT zOadT merged commit a904b1f into master Aug 5, 2023
1 check passed
@zOadT zOadT deleted the shape-cast branch August 5, 2023 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants