Skip to content

Panic when a RayCaster's Translation is the same as the point of collision when using debug rendering when using the "debug_glam_assert" feature of Bevy. #912

@Rhodium365

Description

@Rhodium365

This happens when using the "debug_glam_assert" feature of Bevy by enabling it within cargo.toml and using the PhysicsDebugPlugin of Avian.

To get this to occur, spawn a RigidBody with a Collider, then either spawn a RayCaster with a Transform inside of the the RigidBody's Collider, or spawn a RayCaster outside of the RigidBody's Collider and then move the RayCaster's Transform inside the Rigidbodys Collider (for example, attaching a RayCaster to a projectile and then shooting the projectile at a wall)

this issue can be worked around by removing the "debug_glam_assert" feature from bevy in cargo.toml

These logs are printed when the panic occurs:

thread 'Compute Task Pool (3)' panicked at C:\Users\user\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\glam-0.30.8\src\f32\vec3.rs:601:9:
assertion failed: normalized.is_finite()
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library\std\src\panicking.rs:697
   1: core::panicking::panic_fmt
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library\core\src\panicking.rs:75
   2: core::panicking::panic
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library\core\src\panicking.rs:145
   3: avian2d::debug_render::gizmos::impl$0::draw_arrow
             at C:\Users\user\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\avian2d-0.4.1\src\debug_render\gizmos.rs:147
   4: avian2d::debug_render::gizmos::impl$0::draw_raycast
             at C:\Users\user\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\avian2d-0.4.1\src\debug_render\gizmos.rs:494
   5: avian2d::debug_render::debug_render_raycasts
             at C:\Users\user\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\avian2d-0.4.1\src\debug_render\mod.rs:405
   6: core::ops::function::FnMut::call_mut
             at C:\Users\user\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:166
   7: core::ops::function::impls::impl$3::call_mut
             at C:\Users\user\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:294
   8: bevy_ecs::system::function_system::impl$40::run::call_inner
             at C:\Users\user\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\bevy_ecs-0.17.3\src\system\function_system.rs:926
   9: bevy_ecs::system::function_system::impl$40::run
             at C:\Users\user\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\bevy_ecs-0.17.3\src\system\function_system.rs:929
  10: bevy_ecs::system::function_system::impl$12::run_unsafe<void (*)(bevy_ecs::system::query::Query<tuple$<ref$<avian2d::spatial_query::ray_caster::RayCaster>,ref$<avian2d::spatial_query::ray_caster::RayHits> >,tuple$<> >,bevy_gizmos::gizmos::Gizmos<avian2d::de
             at C:\Users\user\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\bevy_ecs-0.17.3\src\system\function_system.rs:711
  11: core::hint::black_box
             at C:\Users\user\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\hint.rs:482
Encountered a panic in system `avian2d::debug_render::debug_render_raycasts`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions