-
-
Notifications
You must be signed in to change notification settings - Fork 120
Matrix index out of bounds. #310
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
Comments
I'm getting this too, an only panic I've seen in a long time. Would be nice to get this fixed. |
Problem: How to Reproduce: use rapier2d::prelude::*;
fn main() {
let mut rigid_body_set = RigidBodySet::new();
let mut collider_set = ColliderSet::new();
/* Create the ground. */
let collider = ColliderBuilder::ball(100.0).build();
collider_set.insert(collider);
/* Create the bouncing ball. */
let rigid_body = RigidBodyBuilder::dynamic()
.translation(vector![0.0, 0.0])
.build();
let a = point![40.0, 0.0];
let b = point![ 0.0, 80.0];
let c = point![ 0.0, 80.0];
let collider = ColliderBuilder::triangle(a, b, c).restitution(0.7).build();
let triangle_body_handle = rigid_body_set.insert(rigid_body);
collider_set.insert_with_parent(collider, triangle_body_handle, &mut rigid_body_set);
/* Create other structures necessary for the simulation. */
let gravity = vector![0.0, -9.81];
let integration_parameters = IntegrationParameters::default();
let mut physics_pipeline = PhysicsPipeline::new();
let mut island_manager = IslandManager::new();
let mut broad_phase = DefaultBroadPhase::new();
let mut narrow_phase = NarrowPhase::new();
let mut impulse_joint_set = ImpulseJointSet::new();
let mut multibody_joint_set = MultibodyJointSet::new();
let mut ccd_solver = CCDSolver::new();
let mut query_pipeline = QueryPipeline::new();
let physics_hooks = ();
let event_handler = ();
/* Run the game loop, stepping the simulation once per frame. */
for _ in 0..3 {
physics_pipeline.step(
&gravity,
&integration_parameters,
&mut island_manager,
&mut broad_phase,
&mut narrow_phase,
&mut rigid_body_set,
&mut collider_set,
&mut impulse_joint_set,
&mut multibody_joint_set,
&mut ccd_solver,
Some(&mut query_pipeline),
&physics_hooks,
&event_handler,
);
let triangle_body = &rigid_body_set[triangle_body_handle];
println!("Triangle altitude: {}", triangle_body.translation().y); // Prints NaN
}
} Output: What Happens:
let u = (ac_bp - ab_bp) / (ac_bp - ab_bp + ab_cp - ac_cp); // proj on bc = b + bc * u This resolves in the NaN. Propagation and Panic: let inter_with_near_halfspace = (aabb.mins[i] - origin[i]) * denom;
let inter_with_far_halfspace = (aabb.maxs[i] - origin[i]) * denom; Both results are
This becomes Note: I’m not sure how critical this is in practice, since you normally create triangles with valid, distinct points. |
Just to add: |
Uh oh!
There was an error while loading. Please reload this page.
// Error / Panic --------------------------------------------------------------
parry2d-f64-0.18.0/src/query/clip/clip_aabb_line.rs:141:19:
Matrix index out of bounds.
// What happened ---------------------------------------------------------
I accidentally created a triangle ColliderShape with:
point_a -> Vec2 { data: [40.0, 0.0] }
point_b -> Vec2 { data: [ 0.0, 80.0] } // Same as point_c
point_c -> Vec2 { data: [ 0.0, 80.0] } // Same as point_b
In clip_aabb_line.rs the origin parameter has NAN values -> pub fn clip_aabb_line(...);
In the loop in the else part:
let mut inter_with_near_halfspace = (aabb.mins[i] - origin[i]) * denom; // Results in NaN (origin[i] == NaN)
let mut inter_with_far_halfspace = (aabb.maxs[i] - origin[i]) * denom; // Results in NaN (origin[i] == NaN)
near_diag stays false
near_side stays 0
in line 141 [0 - 1] Matrix index out of bounds.
// Solution ----------------------------------------------------------------
The text was updated successfully, but these errors were encountered: