mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
attempt to fix random crash in physics step
- related to out-of-bounds index that isn't checked in the physics lib internals
This commit is contained in:
@@ -60,6 +60,7 @@ use crate::{
|
||||
tilemap::TileMap,
|
||||
},
|
||||
};
|
||||
use fyrox_core::err;
|
||||
pub use rapier2d::geometry;
|
||||
use rapier2d::math::{Pose2, Vec2};
|
||||
use rapier2d::parry::query::DefaultQueryDispatcher;
|
||||
@@ -78,6 +79,7 @@ use rapier2d::{
|
||||
parry::query::ShapeCastOptions,
|
||||
pipeline::{DebugRenderPipeline, EventHandler, PhysicsPipeline},
|
||||
};
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
fmt::{Debug, Formatter},
|
||||
@@ -740,20 +742,28 @@ impl PhysicsWorld {
|
||||
max_ccd_substeps: self.integration_parameters.max_ccd_substeps as usize,
|
||||
};
|
||||
|
||||
self.pipeline.step(
|
||||
(*self.gravity).into(),
|
||||
&integration_parameters,
|
||||
&mut self.islands,
|
||||
&mut self.broad_phase,
|
||||
&mut self.narrow_phase,
|
||||
&mut self.bodies,
|
||||
&mut self.colliders,
|
||||
&mut self.joints.set,
|
||||
&mut self.multibody_joints.set,
|
||||
&mut self.ccd_solver,
|
||||
&(),
|
||||
&*self.event_handler,
|
||||
);
|
||||
if let Err(message) = std::panic::catch_unwind(AssertUnwindSafe(|| {
|
||||
self.pipeline.step(
|
||||
(*self.gravity).into(),
|
||||
&integration_parameters,
|
||||
&mut self.islands,
|
||||
&mut self.broad_phase,
|
||||
&mut self.narrow_phase,
|
||||
&mut self.bodies,
|
||||
&mut self.colliders,
|
||||
&mut self.joints.set,
|
||||
&mut self.multibody_joints.set,
|
||||
&mut self.ccd_solver,
|
||||
&(),
|
||||
&*self.event_handler,
|
||||
);
|
||||
})) {
|
||||
if let Some(message) = message.downcast_ref::<&str>() {
|
||||
err!("A critical error occurred during physics step. Reason: {message}");
|
||||
} else {
|
||||
err!("A critical error occurred during physics step. The reason is unknown.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.performance_statistics.step_time += instant::Instant::now() - time;
|
||||
|
||||
@@ -55,6 +55,7 @@ use crate::{
|
||||
},
|
||||
utils::raw_mesh::{RawMeshBuilder, RawVertex},
|
||||
};
|
||||
use fyrox_core::err;
|
||||
use fyrox_graph::{NodeWrapper, SceneGraph};
|
||||
pub use rapier3d::geometry;
|
||||
use rapier3d::{
|
||||
@@ -72,6 +73,7 @@ use rapier3d::{
|
||||
pipeline::{DebugRenderPipeline, EventHandler, PhysicsPipeline, QueryPipeline},
|
||||
prelude::{FrictionModel, HeightFieldCellStatus, JointAxis, MassProperties},
|
||||
};
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::{
|
||||
cell::Cell,
|
||||
cmp::Ordering,
|
||||
@@ -1183,20 +1185,28 @@ impl PhysicsWorld {
|
||||
friction_model: FrictionModel::default(),
|
||||
};
|
||||
|
||||
self.pipeline.step(
|
||||
(*self.gravity).into(),
|
||||
&integration_parameters,
|
||||
&mut self.islands,
|
||||
&mut self.broad_phase,
|
||||
&mut self.narrow_phase,
|
||||
&mut self.bodies,
|
||||
&mut self.colliders,
|
||||
&mut self.joints.set,
|
||||
&mut self.multibody_joints.set,
|
||||
&mut self.ccd_solver,
|
||||
&(),
|
||||
&*self.event_handler,
|
||||
);
|
||||
if let Err(message) = std::panic::catch_unwind(AssertUnwindSafe(|| {
|
||||
self.pipeline.step(
|
||||
(*self.gravity).into(),
|
||||
&integration_parameters,
|
||||
&mut self.islands,
|
||||
&mut self.broad_phase,
|
||||
&mut self.narrow_phase,
|
||||
&mut self.bodies,
|
||||
&mut self.colliders,
|
||||
&mut self.joints.set,
|
||||
&mut self.multibody_joints.set,
|
||||
&mut self.ccd_solver,
|
||||
&(),
|
||||
&*self.event_handler,
|
||||
);
|
||||
})) {
|
||||
if let Some(message) = message.downcast_ref::<&str>() {
|
||||
err!("A critical error occurred during physics step. Reason: {message}");
|
||||
} else {
|
||||
err!("A critical error occurred during physics step. The reason is unknown.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.performance_statistics.step_time += instant::Instant::now() - time;
|
||||
|
||||
Reference in New Issue
Block a user