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

Panic when using a bevy mesh as a collider, ccd enabled and scaled transform #234

Closed
paul-hansen opened this issue Aug 12, 2022 · 8 comments
Labels
duplicate This issue or pull request already exists

Comments

@paul-hansen
Copy link

paul-hansen commented Aug 12, 2022

Description

I'm getting a panic when two objects collide if one has a collider created using from_bevy_mesh and the entity has a scaled transform and the other object has ccd enabled.

thread 'main' panicked at 'internal error: entered unreachable code', C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\query\nonlinear_time_of_impact\nonlinear_time_of_impact_support_map_support_map.rs:201:40
Click for full traceback
thread 'main' panicked at 'internal error: entered unreachable code', C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\query\nonlinear_time_of_impact\nonlinear_time_of_impact_support_map_support_map.rs:201:40
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src\panicking.rs:142
   2: core::panicking::panic
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src\panicking.rs:48
   3: parry3d::query::nonlinear_time_of_impact::nonlinear_time_of_impact_support_map_support_map::compute_toi<parry3d::query::default_query_dispatcher::DefaultQueryDispatcher,parry3d::shape::ball::Ball,parry3d::shape::ball::Ball>
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\query\nonlinear_time_of_impact\nonlinear_time_of_impact_support_map_support_map.rs:201
   4: parry3d::query::nonlinear_time_of_impact::nonlinear_time_of_impact_support_map_support_map::nonlinear_time_of_impact_support_map_support_map<parry3d::query::default_query_dispatcher::DefaultQueryDispatcher,parry3d::shape::ball::Ball,parry3d::shape::ball::
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\query\nonlinear_time_of_impact\nonlinear_time_of_impact_support_map_support_map.rs:81
   5: parry3d::query::nonlinear_time_of_impact::nonlinear_time_of_impact_composite_shape_shape::impl$1::visit<parry3d::query::default_query_dispatcher::DefaultQueryDispatcher,dyn$<parry3d::shape::composite_shape::SimdCompositeShape> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\query\nonlinear_time_of_impact\nonlinear_time_of_impact_composite_shape_shape.rs:142
   6: parry3d::partitioning::qbvh::qbvh::QBVH<u32>::traverse_best_first<u32,parry3d::query::nonlinear_time_of_impact::nonlinear_time_of_impact_composite_shape_shape::NonlinearTOICompositeShapeShapeBestFirstVisitor<parry3d::query::default_query_dispatcher::Defau
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\partitioning\qbvh\traversal.rs:101
   7: parry3d::query::nonlinear_time_of_impact::nonlinear_time_of_impact_composite_shape_shape::nonlinear_time_of_impact_composite_shape_shape<parry3d::query::default_query_dispatcher::DefaultQueryDispatcher,dyn$<parry3d::shape::composite_shape::SimdCompositeSh
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\query\nonlinear_time_of_impact\nonlinear_time_of_impact_composite_shape_shape.rs:34
   8: parry3d::query::nonlinear_time_of_impact::nonlinear_time_of_impact_composite_shape_shape::nonlinear_time_of_impact_shape_composite_shape<parry3d::query::default_query_dispatcher::DefaultQueryDispatcher,dyn$<parry3d::shape::composite_shape::SimdCompositeSh
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\query\nonlinear_time_of_impact\nonlinear_time_of_impact_composite_shape_shape.rs:54
   9: parry3d::query::default_query_dispatcher::impl$0::nonlinear_time_of_impact
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\query\default_query_dispatcher.rs:379
  10: rapier3d::dynamics::ccd::toi_entry::TOIEntry::try_from_colliders<dyn$<parry3d::query::query_dispatcher::QueryDispatcher> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.14.0\src\dynamics\ccd\toi_entry.rs:131
  11: rapier3d::dynamics::ccd::ccd_solver::impl$1::predict_impacts_at_next_positions::closure$0
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.14.0\src\dynamics\ccd\ccd_solver.rs:319
  12: core::ops::function::impls::impl$3::call_mut<tuple$<ref$<rapier3d::geometry::collider_components::ColliderHandle> >,rapier3d::dynamics::ccd::ccd_solver::impl$1::predict_impacts_at_next_positions::closure_env$0>
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\ops\function.rs:290
  13: parry3d::query::visitors::bounding_volume_intersections_visitor::impl$1::visit<rapier3d::geometry::collider_components::ColliderHandle,ref_mut$<rapier3d::dynamics::ccd::ccd_solver::impl$1::predict_impacts_at_next_positions::closure_env$0> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\query\visitors\bounding_volume_intersections_visitor.rs:42
  14: parry3d::partitioning::qbvh::qbvh::QBVH<rapier3d::geometry::collider_components::ColliderHandle>::traverse_depth_first_with_stack<rapier3d::geometry::collider_components::ColliderHandle,parry3d::query::visitors::bounding_volume_intersections_visitor::Boun
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\partitioning\qbvh\traversal.rs:43
  15: parry3d::partitioning::qbvh::qbvh::QBVH<rapier3d::geometry::collider_components::ColliderHandle>::traverse_depth_first<rapier3d::geometry::collider_components::ColliderHandle,parry3d::query::visitors::bounding_volume_intersections_visitor::BoundingVolumeI
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\parry3d-0.9.0\src\partitioning\qbvh\traversal.rs:19
  16: rapier3d::pipeline::query_pipeline::QueryPipeline::colliders_with_aabb_intersecting_aabb<rapier3d::dynamics::ccd::ccd_solver::impl$1::predict_impacts_at_next_positions::closure_env$0>
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.14.0\src\pipeline\query_pipeline.rs:683
  17: rapier3d::dynamics::ccd::ccd_solver::CCDSolver::predict_impacts_at_next_positions
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.14.0\src\dynamics\ccd\ccd_solver.rs:283
  18: rapier3d::pipeline::physics_pipeline::PhysicsPipeline::run_ccd_motion_clamping
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.14.0\src\pipeline\physics_pipeline.rs:329
  19: rapier3d::pipeline::physics_pipeline::PhysicsPipeline::step
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.14.0\src\pipeline\physics_pipeline.rs:562
  20: bevy_rapier3d::plugin::context::RapierContext::step_simulation
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_rapier3d-0.16.0\src\plugin\context.rs:237
  21: bevy_rapier3d::plugin::systems::step_simulation<tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_rapier3d-0.16.0\src\plugin\systems.rs:603
  22: core::ops::function::FnMut::call_mut<void (*)(bevy_ecs::change_detection::ResMut<bevy_rapier3d::plugin::context::RapierContext>,bevy_ecs::system::system_param::Res<bevy_rapier3d::plugin::configuration::RapierConfiguration>,bevy_ecs::system::system_param::
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\ops\function.rs:164
  23: core::ops::function::impls::impl$3::call_mut<tuple$<bevy_ecs::change_detection::ResMut<bevy_rapier3d::plugin::context::RapierContext>,bevy_ecs::system::system_param::Res<bevy_rapier3d::plugin::configuration::RapierConfiguration>,bevy_ecs::system::system_p
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\ops\function.rs:290
  24: bevy_ecs::system::function_system::impl$30::run::call_inner<tuple$<>,bevy_ecs::change_detection::ResMut<bevy_rapier3d::plugin::context::RapierContext>,bevy_ecs::system::system_param::Res<bevy_rapier3d::plugin::configuration::RapierConfiguration>,bevy_ecs:
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.8.0\src\system\function_system.rs:564
  25: bevy_ecs::system::function_system::impl$30::run<tuple$<>,void (*)(bevy_ecs::change_detection::ResMut<bevy_rapier3d::plugin::context::RapierContext>,bevy_ecs::system::system_param::Res<bevy_rapier3d::plugin::configuration::RapierConfiguration>,bevy_ecs::sy
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.8.0\src\system\function_system.rs:567
  26: bevy_ecs::system::function_system::impl$6::run_unsafe<tuple$<>,tuple$<>,tuple$<bevy_ecs::change_detection::ResMut<bevy_rapier3d::plugin::context::RapierContext>,bevy_ecs::system::system_param::Res<bevy_rapier3d::plugin::configuration::RapierConfiguration>
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.8.0\src\system\function_system.rs:403
  27: bevy_ecs::schedule::executor_parallel::impl$2::prepare_systems::async_block$0
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.8.0\src\schedule\executor_parallel.rs:194
  28: core::future::from_generator::impl$1::poll<enum$<bevy_ecs::schedule::executor_parallel::impl$2::prepare_systems::async_block_env$0> >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\future\mod.rs:91
  29: async_executor::impl$4::spawn::async_block$0<tuple$<>,core::future::from_generator::GenFuture<enum$<bevy_ecs::schedule::executor_parallel::impl$2::prepare_systems::async_block_env$0> > >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\async-executor-1.4.1\src\lib.rs:144
  30: core::future::from_generator::impl$1::poll<enum$<async_executor::impl$4::spawn::async_block_env$0<tuple$<>,core::future::from_generator::GenFuture<enum$<bevy_ecs::schedule::executor_parallel::impl$2::prepare_systems::async_block_env$0> > > > >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\future\mod.rs:91
  31: async_task::raw::RawTask<core::future::from_generator::GenFuture<enum$<async_executor::impl$4::spawn::async_block_env$0<tuple$<>,core::future::from_generator::GenFuture<enum$<bevy_ecs::schedule::executor_parallel::impl$2::prepare_systems::async_block_env$
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\async-task-4.3.0\src\raw.rs:511
  32: async_task::runnable::Runnable::run
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\async-task-4.3.0\src\runnable.rs:309
  33: async_executor::Executor::try_tick
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\async-executor-1.4.1\src\lib.rs:181
  34: bevy_tasks::task_pool::impl$1::scope::closure$0<bevy_ecs::schedule::executor_parallel::impl$1::run_systems::closure_env$0,tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_tasks-0.8.0\src\task_pool.rs:201
  35: std::thread::local::LocalKey<async_executor::LocalExecutor>::try_with<async_executor::LocalExecutor,bevy_tasks::task_pool::impl$1::scope::closure_env$0<bevy_ecs::schedule::executor_parallel::impl$1::run_systems::closure_env$0,tuple$<> >,alloc::vec::Vec<tu
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\std\src\thread\local.rs:445
  36: std::thread::local::LocalKey<async_executor::LocalExecutor>::with<async_executor::LocalExecutor,bevy_tasks::task_pool::impl$1::scope::closure_env$0<bevy_ecs::schedule::executor_parallel::impl$1::run_systems::closure_env$0,tuple$<> >,alloc::vec::Vec<tuple$
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\std\src\thread\local.rs:421
  37: bevy_tasks::task_pool::TaskPool::scope<bevy_ecs::schedule::executor_parallel::impl$1::run_systems::closure_env$0,tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_tasks-0.8.0\src\task_pool.rs:148
  38: bevy_ecs::schedule::executor_parallel::impl$1::run_systems
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.8.0\src\schedule\executor_parallel.rs:126
  39: bevy_ecs::schedule::stage::impl$1::run
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.8.0\src\schedule\stage.rs:884
  40: bevy_ecs::schedule::Schedule::run_once
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.8.0\src\schedule\mod.rs:342
  41: bevy_ecs::schedule::impl$1::run
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.8.0\src\schedule\mod.rs:360
  42: bevy_app::app::App::update
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.8.0\src\app.rs:119
  43: bevy_winit::winit_runner_with::closure$0
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_winit-0.8.0\src\lib.rs:618
  44: winit::platform_impl::platform::event_loop::impl$2::run_return::closure$0<tuple$<>,bevy_winit::winit_runner_with::closure_env$0>
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop.rs:206
  45: alloc::boxed::impl$45::call_mut<tuple$<enum$<winit::event::Event<tuple$<> > >,ref_mut$<enum$<winit::event_loop::ControlFlow> > >,dyn$<core::ops::function::FnMut<tuple$<enum$<winit::event::Event<tuple$<> > >,ref_mut$<enum$<winit::event_loop::ControlFlow> >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\alloc\src\boxed.rs:1879
  46: winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure$0<tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop\runner.rs:245
  47: core::panic::unwind_safe::impl$23::call_once<tuple$<>,winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\panic\unwind_safe.rs:271
  48: std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > >,tuple$<> >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\std\src\panicking.rs:492
  49: hashbrown::raw::sse2::Group::load
  50: std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > > >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\std\src\panicking.rs:456
  51: std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > >,tuple$<> >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\std\src\panic.rs:137
  52: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::catch_unwind<tuple$<>,tuple$<>,winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop\runner.rs:152
  53: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::call_event_handler<tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop\runner.rs:239
  54: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::move_state_to<tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop\runner.rs:341
  55: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::main_events_cleared<tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop\runner.rs:227
  56: winit::platform_impl::platform::event_loop::flush_paint_messages<tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop.rs:726
  57: winit::platform_impl::platform::event_loop::thread_event_target_callback::closure$0<tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop.rs:2091
  58: core::ops::function::FnOnce::call_once<winit::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<tuple$<> >,tuple$<> >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\ops\function.rs:248
  59: core::panic::unwind_safe::impl$23::call_once<isize,winit::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<tuple$<> > >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\panic\unwind_safe.rs:271
  60: std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<tuple$<> > >,isize>
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\std\src\panicking.rs:492
  61: hashbrown::raw::sse2::Group::load
  62: std::panicking::try<isize,core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<tuple$<> > > >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\std\src\panicking.rs:456
  63: std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<tuple$<> > >,isize>
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\std\src\panic.rs:137
  64: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::catch_unwind<tuple$<>,isize,winit::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<tuple$<> > >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop\runner.rs:152
  65: winit::platform_impl::platform::event_loop::thread_event_target_callback<tuple$<> >
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop.rs:2271
  66: CallWindowProcW
  67: EnumChildWindows
  68: IsIconic
  69: KiUserCallbackDispatcher
  70: NtUserDispatchMessage
  71: DispatchMessageW
  72: winit::platform_impl::platform::event_loop::EventLoop<tuple$<> >::run_return<tuple$<>,bevy_winit::winit_runner_with::closure_env$0>
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop.rs:221
  73: winit::platform_impl::platform::event_loop::EventLoop<tuple$<> >::run<tuple$<>,bevy_winit::winit_runner_with::closure_env$0>
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\windows\event_loop.rs:191
  74: winit::event_loop::EventLoop<tuple$<> >::run<tuple$<>,bevy_winit::winit_runner_with::closure_env$0>
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\event_loop.rs:154
  75: bevy_winit::run<bevy_winit::winit_runner_with::closure_env$0>
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_winit-0.8.0\src\lib.rs:240
  76: bevy_winit::winit_runner_with
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_winit-0.8.0\src\lib.rs:663
  77: bevy_winit::winit_runner
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_winit-0.8.0\src\lib.rs:280
  78: core::ops::function::Fn::call<void (*)(bevy_app::app::App),tuple$<bevy_app::app::App> >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\ops\function.rs:77
  79: alloc::boxed::impl$46::call<tuple$<bevy_app::app::App>,dyn$<core::ops::function::Fn<tuple$<bevy_app::app::App>,assoc$<Output,tuple$<> > > >,alloc::alloc::Global>
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\alloc\src\boxed.rs:1886
  80: bevy_app::app::App::run
             at C:\Users\Paul\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.8.0\src\app.rs:135
  81: bevy_rapier_ccd_unreachable_bug::main
             at .\src\main.rs:5
  82: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\ops\function.rs:248

My use case is I have an asteroid field that has randomly placed asteroids with random scales. I have a custom collider mesh for the asteroids and I want my bullets that shoot the asteroids to use ccd so they don't go through the asteroids.

System

Windows 11
Bevy 0.8
bevy_rapier3d 0.16 (also main branch)

Minimal reproduction

This code demonstrates the error, it creates a fixed rigid body using a bevy mesh as a collider and a transform scaled to 2X, then creates a dynamic rigid body with ccd enabled and sends it at it with a high velocity.

use bevy::prelude::*;
use bevy_rapier3d::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands
        .spawn()
        .insert_bundle(TransformBundle::from_transform(
            Transform::from_xyz(0.0, 0.0, 20.0)
                // Commenting out this line it no longer panics
                .with_scale(Vec3::splat(2.0)),
        ))
        .insert(
            // If you use a different collider that isn't a bevy mesh here it no longer panics
            Collider::from_bevy_mesh(
                &Mesh::from(shape::Cube { size: 3.0 }),
                &ComputedColliderShape::TriMesh,
            )
            .unwrap(),
        )
        .insert(RigidBody::Fixed);

    commands
        .spawn()
        .insert(Collider::ball(1.0))
        .insert(RigidBody::Dynamic)
        // Commenting out this line it no longer panics
        .insert(Ccd::enabled())
        .insert(Velocity::linear(Vec3::Z * 10000.0));
}
@janhohenheim
Copy link
Contributor

janhohenheim commented Mar 14, 2023

I think there's a regression in rapier 0.21. Getting this error for the first time now in an otherwise unchanged codebase (other than upgrading to Bevy 0.10)
Interestingly, it only happens on Wasm and not native.

@paul-hansen
Copy link
Author

Just tried this again to see if anything has changed with the new versions and the example I provided still consistently panics, hitting this unreachable!() line.

Here's an updated example:

[dependencies]
bevy = "0.10.0"
bevy_rapier3d = "0.21.0"
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn((
        TransformBundle::from_transform(
            Transform::from_xyz(0.0, 0.0, 20.0)
                // Commenting out this line it no longer panics
                .with_scale(Vec3::splat(2.0)),
        ),
        // If you use a different collider that isn't a bevy mesh here it no longer panics
        Collider::from_bevy_mesh(
            &Mesh::from(shape::Cube { size: 3.0 }),
            &ComputedColliderShape::TriMesh,
        )
        .unwrap(),
        RigidBody::Fixed,
    ));

    commands.spawn((
        Collider::ball(1.0),
        RigidBody::Dynamic,
        // Commenting out this line it no longer panics
        // Ccd::enabled(),
        Velocity::linear(Vec3::Z * 10000.0),
    ));
}

@janhohenheim
Copy link
Contributor

As for me, my code magically works now. Strange 🤷‍♂️

@marcelchampagne
Copy link

Also ran into this same issue.

@hgeist2
Copy link

hgeist2 commented Jul 6, 2023

It only happens when i use ComputedColliderShape::TriMesh, if i switch to ComputedColliderShape::ConvexDecomposition(VHACDParameters::default()), it stops

@1755
Copy link

1755 commented Mar 24, 2024

Have the same issue with CCD and TriMesh (and WASM):

bevy = "0.13.0"
bevy_rapier3d = { version = "0.25.0", features = [ "enhanced-determinism", "debug-render-3d", "wasm-bindgen", "serde-serialize" ] }

parry3d-0.13.6/src/query/nonlinear_time_of_impact/nonlinear_time_of_impact_support_map_support_map.rs:201:40:
internal error: entered unreachable code

@Vrixyz
Copy link
Contributor

Vrixyz commented May 24, 2024

Recent duplicate here: #386

@Vrixyz Vrixyz closed this as completed May 24, 2024
@Vrixyz Vrixyz added duplicate This issue or pull request already exists labels May 24, 2024
@paul-hansen
Copy link
Author

Updated example for bevy 0.13 and bevy_rapier3d 0.26 no longer panics but returns the error:

ERROR log: Closest points not found despite setting the max distance to infinity. 
main.rs
use bevy::{math::vec3, prelude::*};
use bevy_rapier3d::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(RapierPhysicsPlugin::<NoUserData>::default())
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn((
        TransformBundle::from_transform(
            Transform::from_xyz(0.0, 0.0, 20.0)
                // Commenting out this line it no longer panics
                .with_scale(Vec3::splat(2.0)),
        ),
        // If you use a different collider that isn't a bevy mesh here it no longer panics
        Collider::from_bevy_mesh(
            &Mesh::from(Cuboid {
                half_size: vec3(1.5, 1.5, 1.5),
            }),
            &ComputedColliderShape::TriMesh,
        )
        .unwrap(),
        RigidBody::Fixed,
    ));

    commands.spawn((
        Collider::ball(1.0),
        RigidBody::Dynamic,
        // Commenting out this line it no longer panics
        Ccd::enabled(),
        Velocity::linear(Vec3::Z * 10000.0),
    ));
}
Cargo.toml
[package]
name = "bevy_rapier_bug_test"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = { version = "0.13.2", features=["wayland"] }
bevy_rapier3d = "0.26.0"
full log including updated system specs ``` 2024-05-24T15:35:14.760568Z INFO bevy_winit::system: Creating new window "App" (0v1) 2024-05-24T15:35:15.052064Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3080", vendor: 4318, device: 8726, device_type: Discre teGpu, driver: "NVIDIA", driver_info: "555.42.02", backend: Vulkan } 2024-05-24T15:35:15.300280Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux rolling EndeavourOS", kerne l: "6.9.1-arch1-1", cpu: "AMD Ryzen 9 7950X 16-Core Processor", core_count: "16", memory: "62.0 GiB" } 2024-05-24T15:35:15.305132Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305139Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305141Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305170Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305172Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305173Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305178Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305180Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305182Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305186Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305188Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305190Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305198Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305199Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305204Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305205Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305207Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305211Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:15.305213Z ERROR log: Closest points not found despite setting the max distance to infinity. 2024-05-24T15:35:26.825476Z INFO bevy_window::system: No windows are open, exiting 2024-05-24T15:35:26.825743Z INFO bevy_winit::system: Closing window 0v1 ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

6 participants