build~ [build skip]

This commit is contained in:
shenjack 2023-05-24 00:55:48 +08:00
parent 577d438b64
commit 90bc705f6d
5 changed files with 39 additions and 9 deletions

View File

@ -18,6 +18,13 @@
- 基于 `PyConsole` - 基于 `PyConsole`
- 用于替换 `DR sdk` 的默认控制台方法 - 用于替换 `DR sdk` 的默认控制台方法
## DR rs 0.2.9.1
### 实现
- `types::sr1::get_max_box`
- 部分实现
## DR rs 0.2.9.0 ## DR rs 0.2.9.0
### 新功能 ### 新功能
@ -33,4 +40,3 @@
- [#19](https://github.com/shenjackyuanjie/Difficult-Rocket/issues/19) `BorrowMutError` - [#19](https://github.com/shenjackyuanjie/Difficult-Rocket/issues/19) `BorrowMutError`

View File

@ -12,7 +12,7 @@ package_path = 'Difficult_Rocket_rs'
setup( setup(
name='Difficult_Rocket_rs', name='Difficult_Rocket_rs',
version="0.2.9.0", version="0.2.9.1",
author='shenjackyuanjie', author='shenjackyuanjie',
author_email='3695888@qq.com', author_email='3695888@qq.com',
rust_extensions=[RustExtension(target="Difficult_Rocket_rs.Difficult_Rocket_rs", rust_extensions=[RustExtension(target="Difficult_Rocket_rs.Difficult_Rocket_rs",

View File

@ -28,7 +28,7 @@ enum LoadState {
} }
#[pyfunction] #[pyfunction]
fn get_version_str() -> String { "0.2.8.0".to_string() } fn get_version_str() -> String { "0.2.9.1".to_string() }
#[pyfunction] #[pyfunction]
fn test_call(py_obj: &PyAny) -> PyResult<bool> { fn test_call(py_obj: &PyAny) -> PyResult<bool> {

View File

@ -168,8 +168,6 @@ pub mod translate {
} }
pub mod console { pub mod console {
use std::println;
use pyo3::prelude::*; use pyo3::prelude::*;
#[pyclass] #[pyclass]

View File

@ -18,6 +18,7 @@ pub mod sr1 {
Activate as RawActivate, Connection, Connections, DisconnectedPart as RawDisconnectedPart, DisconnectedParts as RawDisconnectedParts, Activate as RawActivate, Connection, Connections, DisconnectedPart as RawDisconnectedPart, DisconnectedParts as RawDisconnectedParts,
Engine as RawEngine, Part as RawPartData, Parts as RawParts, Pod as RawPod, RawShip, Staging as RawStaging, Step as RawStep, Tank as RawTank, Engine as RawEngine, Part as RawPartData, Parts as RawParts, Pod as RawPod, RawShip, Staging as RawStaging, Step as RawStep, Tank as RawTank,
}; };
use crate::types::math::{Point2D, Rotatable};
#[inline] #[inline]
pub fn map_ptype_textures(ptype: String) -> String { pub fn map_ptype_textures(ptype: String) -> String {
@ -194,6 +195,14 @@ pub mod sr1 {
pub attr: Option<SR1PartTypeAttr>, // 部件特殊属性 pub attr: Option<SR1PartTypeAttr>, // 部件特殊属性
} }
impl SR1PartType {
pub fn get_box(&self) -> (f64, f64, f64, f64) {
let x = self.width as f64 / 2.0;
let y = self.height as f64 / 2.0;
(-x, -y, x, y)
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SR1PartList { pub struct SR1PartList {
pub types: Vec<SR1PartType>, pub types: Vec<SR1PartType>,
@ -757,10 +766,24 @@ pub mod sr1 {
pub fn get_max_box(parts: &Vec<SR1PartData>, part_list: &SR1PartList) -> (f64, f64, f64, f64) { pub fn get_max_box(parts: &Vec<SR1PartData>, part_list: &SR1PartList) -> (f64, f64, f64, f64) {
let mut max_box = (0_f64, 0_f64, 0_f64, 0_f64); let mut max_box = (0_f64, 0_f64, 0_f64, 0_f64);
// for part in parts.iter() { for part in parts.iter() {
// let part_type = part_list.get_part_type(part.id); let part_type = part_list.get_part_type(part.part_type_id.clone()).unwrap();
// } let (x1, y1, x2, y2) = part_type.get_box();
todo!("get_max_box") // rotate
let p1 = Point2D::new(x1, y1);
let p2 = Point2D::new(x2, y2);
let p1 = p1.rotate_radius(part.angle);
let p2 = p2.rotate_radius(part.angle);
let p1 = p1.add(part.x, part.y);
let p2 = p2.add(part.x, part.y);
let (x1, y1, x2, y2) = (p1.x, p1.y, p2.x, p2.y);
// get max box
max_box.0 = max_box.0.min(x1);
max_box.1 = max_box.1.min(y1);
max_box.2 = max_box.2.max(x2);
max_box.3 = max_box.3.max(y2);
}
max_box
} }
} }
@ -794,6 +817,9 @@ pub mod math {
#[inline] #[inline]
pub fn distance_00(&self) -> f64 { self.distance(&Point2D::new(0.0, 0.0)) } pub fn distance_00(&self) -> f64 { self.distance(&Point2D::new(0.0, 0.0)) }
#[inline]
pub fn add(&self, x: f64, y: f64) -> Self { Point2D::new(self.x + x, self.y + y) }
} }
impl Rotatable for Point2D { impl Rotatable for Point2D {