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

Example chain_2d crashes when clicking #416

Closed
kainosaur opened this issue Jul 11, 2024 · 4 comments
Closed

Example chain_2d crashes when clicking #416

kainosaur opened this issue Jul 11, 2024 · 4 comments

Comments

@kainosaur
Copy link

thread 'main' panicked at crates\avian2d\../../src\position.rs:252:9:
the given sine and cosine produce an invalid rotation
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `avian2d::dynamics::solver::xpbd::solve_constraint<avian2d::dynamics::solver::joints::revolute::RevoluteJoint, 2>`!
Encountered a panic in system `avian2d::schedule::run_substep_schedule`!
Encountered a panic in system `avian2d::schedule::run_physics_schedule`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
@Khanoto
Copy link
Contributor

Khanoto commented Jul 12, 2024

image

Check the angles you're using, must respect the condition : sin² + cos² = 1

@kainosaur
Copy link
Author

I am using this example unmodified.

@Khanoto
Copy link
Contributor

Khanoto commented Jul 12, 2024

Since you said it come from clicking, I think it may come from the follow_mouse func

But the only thing I notice is that it may be reversed between the follower pos and cursor pos
image

just a suggestion, I haven't tried

@hocop hocop mentioned this issue Jul 13, 2024
Jondolf pushed a commit that referenced this issue Jul 13, 2024
# Objective

Fixes [415](#415) and [416](#416)

## Solution

Old implementation was only for small angles. When impact on `RevoluteJoint` is big, XPBD [tries to apply](https://github.com/Jondolf/avian/blob/main/src/dynamics/solver/xpbd/positional_constraint.rs#L70) a big update on angles and fails

Implemented `add_angle` function using precise computation of sin and cos
@Jondolf
Copy link
Owner

Jondolf commented Jul 13, 2024

Fixed by #421 :)

@Jondolf Jondolf closed this as completed Jul 13, 2024
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

No branches or pull requests

3 participants