forked from dimforge/bevy_rapier
-
Notifications
You must be signed in to change notification settings - Fork 1
attempt to reproduce a crash with a more complex example #26
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
Open
ThierryBerger
wants to merge
4
commits into
RapierContext_Component
Choose a base branch
from
RapierContext_Component_crash_investigation
base: RapierContext_Component
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
14fc82f
attempt to reproduce a crash with a more complex example
ThierryBerger 3631e17
real reproduction!
ThierryBerger ece7d00
ugly fix by bypassing generational index
ThierryBerger 74866d1
more investigation, I probably have a path to a fix
ThierryBerger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| use bevy::{input::common_conditions::input_just_pressed, prelude::*}; | ||
| use bevy_rapier3d::prelude::*; | ||
|
|
||
| const N_WORLDS: usize = 2; | ||
|
|
||
| fn main() { | ||
| App::new() | ||
| .insert_resource(ClearColor(Color::srgb( | ||
| 0xF9 as f32 / 255.0, | ||
| 0xF9 as f32 / 255.0, | ||
| 0xFF as f32 / 255.0, | ||
| ))) | ||
| .add_plugins(( | ||
| DefaultPlugins, | ||
| RapierPhysicsPlugin::<NoUserData>::default() | ||
| .with_custom_initialization(RapierContextInitialization::NoAutomaticRapierContext), | ||
| RapierDebugRenderPlugin::default(), | ||
| )) | ||
| .insert_resource(TimestepMode::Interpolated { | ||
| dt: 1.0 / 60.0, | ||
| time_scale: 1.0, | ||
| substeps: 2, | ||
| }) | ||
| .add_systems( | ||
| Startup, | ||
| ((create_worlds, setup_physics).chain(), setup_graphics), | ||
| ) | ||
| .add_systems( | ||
| Update, | ||
| change_world, //.run_if(input_just_pressed(KeyCode::KeyC)), | ||
| ) | ||
| .run(); | ||
| } | ||
|
|
||
| fn create_worlds(mut commands: Commands) { | ||
| for i in 0..N_WORLDS { | ||
| let mut world = commands.spawn(RapierContext::default()); | ||
| if i == 0 { | ||
| world.insert(DefaultRapierContext); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn setup_graphics(mut commands: Commands) { | ||
| commands.spawn(Camera3dBundle { | ||
| transform: Transform::from_xyz(0.0, 3.0, -10.0) | ||
| .looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), | ||
| ..Default::default() | ||
| }); | ||
| } | ||
|
|
||
| fn change_world( | ||
| query_context: Query<Entity, With<DefaultRapierContext>>, | ||
| q_other_ctx: Query<Entity, (With<RapierContext>, Without<DefaultRapierContext>)>, | ||
| mut query_links: Query<&mut RapierContextEntityLink>, | ||
| ) { | ||
| let default_context = query_context.single(); | ||
| for mut link in query_links.iter_mut() { | ||
| if link.0 == default_context { | ||
| link.0 = q_other_ctx.single(); | ||
| continue; | ||
| } | ||
| link.0 = default_context; | ||
| } | ||
| } | ||
|
|
||
| pub fn setup_physics(mut commands: Commands) { | ||
| /* | ||
| * Create the cube | ||
| */ | ||
|
|
||
| let color = [ | ||
| Hsla::hsl(220.0, 1.0, 0.3), | ||
| Hsla::hsl(180.0, 1.0, 0.3), | ||
| Hsla::hsl(260.0, 1.0, 0.7), | ||
| ][0 % 3]; | ||
|
|
||
| commands.spawn(( | ||
| TransformBundle::from(Transform::from_xyz(0.0, 0.0, 0.0)), | ||
| RigidBody::Dynamic, | ||
| Collider::cuboid(0.5, 0.5, 0.5), | ||
| ColliderDebugColor(color), | ||
| ActiveEvents::all(), | ||
| )); | ||
|
|
||
| /* | ||
| * Ground | ||
| */ | ||
| let color = Hsla::hsl(260.0, 1.0, 0.7); | ||
| let ground_size = 5.1; | ||
| let ground_height = 0.1; | ||
| let starting_y = -0.5 - ground_height; | ||
|
|
||
| commands.spawn(( | ||
| TransformBundle::from(Transform::from_xyz(0.0, starting_y, 0.0)), | ||
| Collider::cuboid(ground_size, ground_height, ground_size), | ||
| ColliderDebugColor(color), | ||
| )); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a possible fix: bypassing generational check. I'm not sure generation is very important for mapping colliders to entities 🤔 ; for a collider to change entity, we'd need either very cursed code, as from my understanding it would recreate a new collider within rapier (so another index).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my assumption is correct, we could simplify this mapping to map to index only rather than index + generation 💭 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems completely incorrect ; generation is updated when we remove an entry, so it's needed to be sure we're targeting the correct entity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal error: entity not found for collision event with collider handle: ColliderHandle(Index { index: 0, generation: 0 }).is interesting:There shouldn't be a generation 0 ; not after the first step 🤔 (maybe even not ever?) ; it seems to mean the arena grew unexpectedly