From 73d7bb84e03b27f77a62f784db25f0ff96d058a8 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 12 Feb 2023 21:19:17 +0800 Subject: [PATCH] simluate! --- libs/Difficult_Rocket_rs/__init__.py | 2 ++ libs/Difficult_Rocket_rs/src/src/lib.rs | 1 + libs/Difficult_Rocket_rs/src/src/simulator.rs | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/Difficult_Rocket_rs/__init__.py b/libs/Difficult_Rocket_rs/__init__.py index 092314c..e8ea900 100644 --- a/libs/Difficult_Rocket_rs/__init__.py +++ b/libs/Difficult_Rocket_rs/__init__.py @@ -19,6 +19,8 @@ if TYPE_CHECKING: def get_version_str() -> str: ... + def simluation() -> None: ... + class PartDatas: """ 用于在 PyObj 里塞一个浓眉大眼的 HashMap""" def __new__(cls, py_part_data: Dict[int, SR1PartData]) -> "PartDatas": ... diff --git a/libs/Difficult_Rocket_rs/src/src/lib.rs b/libs/Difficult_Rocket_rs/src/src/lib.rs index 04c28d3..dd87cc2 100644 --- a/libs/Difficult_Rocket_rs/src/src/lib.rs +++ b/libs/Difficult_Rocket_rs/src/src/lib.rs @@ -33,6 +33,7 @@ fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(get_version_str, m)?)?; m.add_function(wrap_pyfunction!(test_call, m)?)?; m.add_function(wrap_pyfunction!(sr1_render::better_update_parts, m)?)?; + m.add_function(wrap_pyfunction!(simulator::simluation, m)?)?; m.add_class::()?; m.add_class::()?; Ok(()) diff --git a/libs/Difficult_Rocket_rs/src/src/simulator.rs b/libs/Difficult_Rocket_rs/src/src/simulator.rs index bfefbc6..13caf5e 100644 --- a/libs/Difficult_Rocket_rs/src/src/simulator.rs +++ b/libs/Difficult_Rocket_rs/src/src/simulator.rs @@ -7,8 +7,11 @@ */ use rapier2d::prelude::*; +use pyo3::prelude::*; -fn main() { +#[pyfunction] +#[pyo3(name = "simluation")] +pub fn simluation() -> PyResult<()> { let mut rigid_body_set = RigidBodySet::new(); let mut collider_set = ColliderSet::new(); @@ -61,4 +64,5 @@ fn main() { ball_body.translation().y ); } + Ok(()) } \ No newline at end of file