ITADN

spatial query triggers an unwrap on a none value

#957OpenDracks 创建于 2026-03-17
C-BugP-RegressionA-Spatial-QueryP-CrashS-Needs-Investigation
D
Drackscommented
Hello, I was trying to upgrade my project to avian 0.6, And I've got a rust panic with the following stacktrack: ``` thread 'Compute Task Pool (3)' panicked at /home/dracks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/avian3d-0.6.0/src/spatial_query/system_param.rs:1244:54: called `Option::unwrap()` on a `None` value stack backtrace: 0: __rustc::rust_begin_unwind at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/panicking.rs:697:5 1: core::panicking::panic_fmt at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:75:14 2: core::panicking::panic at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:145:5 3: core::option::unwrap_failed at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/option.rs:2130:5 4: core::option::Option<T>::unwrap at /home/dracks/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:1009:21 5: avian3d::spatial_query::system_param::SpatialQuery::shape_intersections_callback::{{closure}}::{{closure}} at /home/dracks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/avian3d-0.6.0/src/spatial_query/system_param.rs:1244:54 6: avian3d::collider_tree::traverse::<impl avian3d::collider_tree::tree::ColliderTree>::aabb_traverse::{{closure}} at /home/dracks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/avian3d-0.6.0/src/collider_tree/traverse.rs:238:21 7: obvhs::bvh2::Bvh2::aabb_traverse at /home/dracks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/obvhs-0.3.0/src/bvh2/mod.rs:373:17 8: avian3d::collider_tree::traverse::<impl avian3d::collider_tree::tree::ColliderTree>::aabb_traverse at /home/dracks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/avian3d-0.6.0/src/collider_tree/traverse.rs:231:18 9: avian3d::spatial_query::system_param::SpatialQuery::shape_intersections_callback::{{closure}} at /home/dracks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/avian3d-0.6.0/src/spatial_query/system_param.rs:1243:18 10: core::iter::traits::iterator::Iterator::for_each::call::{{closure}} at /home/dracks/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:824:29 11: core::ops::try_trait::NeverShortCircuit<T>::wrap_mut_2::{{closure}} at /home/dracks/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/try_trait.rs:401:39 12: core::array::iter::iter_inner::PolymorphicIter<[core::mem::maybe_uninit::MaybeUninit<T>]>::try_fold::{{closure}} at /home/dracks/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/iter/iter_inner.rs:220:13 13: <core::ops::index_range::IndexRange as core::iter::traits::iterator::Iterator>::try_fold at /home/dracks/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/index_range.rs:169:21 14: core::array::iter::iter_inner::PolymorphicIter<[core::mem::maybe_uninit::MaybeUninit<T>]>::try_fold at /home/dracks/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/iter/iter_inner.rs:215:20 15: core::array::iter::iter_inner::PolymorphicIter<[core::mem::maybe_uninit::MaybeUninit<T>]>::fold at /home/dracks/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/iter/iter_inner.rs:202:14 16: <core::array::iter::IntoIter<T,_> as core::iter::traits::iterator::Iterator>::fold at /home/dracks/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/iter.rs:253:27 17: core::iter::traits::iterator::Iterator::for_each at /home/dracks/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:827:14 18: avian3d::spatial_query::system_param::SpatialQuery::shape_intersections_callback at /home/dracks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/avian3d-0.6.0/src/spatial_query/system_param.rs:1242:42 19: avian3d::spatial_query::system_param::SpatialQuery::shape_intersections at /home/dracks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/avian3d-0.6.0/src/spatial_query/system_param.rs:1173:14 20: tbs_engine::game::bullet::handle_blast at ./crates/tbs-engine/src/game/bullet.rs:331:34 ``` I'm not sure if maybe I did something wrong, I start using avian some weeks ago, but this was working on 0.5. The system the stacktrace is referencing is this one: ```rust fn handle_blast( mut time: MessageReader<TurnUpdateMsg>, spatial_query: SpatialQuery, mut damage_writer: MessageWriter<DamageMsg>, explosions_query: Query<(&GlobalTransform, &Explosion, &Blast)>, ) { let delta = time.total_delta_as_secs_f32(); for (transform, explosion, blast) in explosions_query.iter() { let explosion_center = transform.translation(); // Query all colliders within the current explosion radius let hits = spatial_query.shape_intersections( &Collider::sphere(explosion.size()), explosion_center, Quat::IDENTITY, &SpatialQueryFilter::default(), ); for hit_entity in hits.iter() { damage_writer.write(DamageMsg::new( blast.player.clone(), *hit_entity, blast.damage.damage * delta * (1. - explosion.progress()), )); } } } ``` Thanks!
12 条评论