cargo fmt一遍文件
This commit is contained in:
parent
dd8833d0c6
commit
ba9750e265
@ -6,10 +6,10 @@
|
|||||||
* -------------------------------
|
* -------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod sr1_render;
|
mod render;
|
||||||
mod simulator;
|
mod simulator;
|
||||||
mod sr1_data;
|
mod sr1_data;
|
||||||
mod render;
|
mod sr1_render;
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
@ -41,4 +41,4 @@ fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
|||||||
m.add_class::<render::camera::CenterCameraRs>()?;
|
m.add_class::<render::camera::CenterCameraRs>()?;
|
||||||
m.add_class::<render::screen::PartFrame>()?;
|
m.add_class::<render::screen::PartFrame>()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -6,63 +6,60 @@
|
|||||||
* -------------------------------
|
* -------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rapier2d_f64::prelude::*;
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
use rapier2d_f64::prelude::*;
|
||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
#[pyo3(name = "simluation")]
|
#[pyo3(name = "simluation")]
|
||||||
pub fn simluation() -> PyResult<()> {
|
pub fn simluation() -> PyResult<()> {
|
||||||
let mut rigid_body_set = RigidBodySet::new();
|
let mut rigid_body_set = RigidBodySet::new();
|
||||||
let mut collider_set = ColliderSet::new();
|
let mut collider_set = ColliderSet::new();
|
||||||
|
|
||||||
/* Create the ground. */
|
/* Create the ground. */
|
||||||
let collider = ColliderBuilder::cuboid(100.0, 0.1).build();
|
let collider = ColliderBuilder::cuboid(100.0, 0.1).build();
|
||||||
collider_set.insert(collider);
|
collider_set.insert(collider);
|
||||||
|
|
||||||
/* Create the bouncing ball. */
|
/* Create the bouncing ball. */
|
||||||
let rigid_body = RigidBodyBuilder::dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 10.0])
|
.translation(vector![0.0, 10.0])
|
||||||
.build();
|
.build();
|
||||||
let collider = ColliderBuilder::ball(0.5).restitution(0.7).build();
|
let collider = ColliderBuilder::ball(0.5).restitution(0.7).build();
|
||||||
let ball_body_handle = rigid_body_set.insert(rigid_body);
|
let ball_body_handle = rigid_body_set.insert(rigid_body);
|
||||||
collider_set.insert_with_parent(collider, ball_body_handle, &mut rigid_body_set);
|
collider_set.insert_with_parent(collider, ball_body_handle, &mut rigid_body_set);
|
||||||
|
|
||||||
/* Create other structures necessary for the simulation. */
|
/* Create other structures necessary for the simulation. */
|
||||||
let gravity = vector![0.0, -9.81];
|
let gravity = vector![0.0, -9.81];
|
||||||
let integration_parameters = IntegrationParameters::default();
|
let integration_parameters = IntegrationParameters::default();
|
||||||
let mut physics_pipeline = PhysicsPipeline::new();
|
let mut physics_pipeline = PhysicsPipeline::new();
|
||||||
let mut island_manager = IslandManager::new();
|
let mut island_manager = IslandManager::new();
|
||||||
let mut broad_phase = BroadPhase::new();
|
let mut broad_phase = BroadPhase::new();
|
||||||
let mut narrow_phase = NarrowPhase::new();
|
let mut narrow_phase = NarrowPhase::new();
|
||||||
let mut impulse_joint_set = ImpulseJointSet::new();
|
let mut impulse_joint_set = ImpulseJointSet::new();
|
||||||
let mut multibody_joint_set = MultibodyJointSet::new();
|
let mut multibody_joint_set = MultibodyJointSet::new();
|
||||||
let mut ccd_solver = CCDSolver::new();
|
let mut ccd_solver = CCDSolver::new();
|
||||||
let physics_hooks = ();
|
let physics_hooks = ();
|
||||||
let event_handler = ();
|
let event_handler = ();
|
||||||
|
|
||||||
/* Run the game loop, stepping the simulation once per frame. */
|
/* Run the game loop, stepping the simulation once per frame. */
|
||||||
for _ in 0..200 {
|
for _ in 0..200 {
|
||||||
physics_pipeline.step(
|
physics_pipeline.step(
|
||||||
&gravity,
|
&gravity,
|
||||||
&integration_parameters,
|
&integration_parameters,
|
||||||
&mut island_manager,
|
&mut island_manager,
|
||||||
&mut broad_phase,
|
&mut broad_phase,
|
||||||
&mut narrow_phase,
|
&mut narrow_phase,
|
||||||
&mut rigid_body_set,
|
&mut rigid_body_set,
|
||||||
&mut collider_set,
|
&mut collider_set,
|
||||||
&mut impulse_joint_set,
|
&mut impulse_joint_set,
|
||||||
&mut multibody_joint_set,
|
&mut multibody_joint_set,
|
||||||
&mut ccd_solver,
|
&mut ccd_solver,
|
||||||
None,
|
None,
|
||||||
&physics_hooks,
|
&physics_hooks,
|
||||||
&event_handler,
|
&event_handler,
|
||||||
);
|
);
|
||||||
|
|
||||||
let ball_body = &rigid_body_set[ball_body_handle];
|
let ball_body = &rigid_body_set[ball_body_handle];
|
||||||
println!(
|
println!("Ball altitude: {}", ball_body.translation().y);
|
||||||
"Ball altitude: {}",
|
}
|
||||||
ball_body.translation().y
|
Ok(())
|
||||||
);
|
}
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user