cargo fmt

This commit is contained in:
Hakan 2026-05-12 10:36:15 +03:00
commit ca07268c7c
204 changed files with 13988 additions and 5516 deletions

View file

@ -2,7 +2,7 @@ use acadrust::entities::{Ole2Frame, OleObjectType};
use glam::Vec3;
use crate::command::EntityTransform;
use crate::entities::common::{diamond_grip, ro_prop as ro, edit_prop as edit, square_grip};
use crate::entities::common::{diamond_grip, edit_prop as edit, ro_prop as ro, square_grip};
use crate::entities::traits::{Grippable, PropertyEditable, Transformable, TruckConvertible};
use crate::scene::acad_to_truck::{TruckEntity, TruckObject};
use crate::scene::object::{GripApply, GripDef, PropSection};
@ -13,7 +13,7 @@ fn to_truck(ole: &Ole2Frame) -> TruckEntity {
let y0 = ole.lower_right_corner.y as f32;
let x1 = ole.lower_right_corner.x as f32;
let y1 = ole.upper_left_corner.y as f32;
let z = ole.upper_left_corner.z as f32;
let z = ole.upper_left_corner.z as f32;
if (x1 - x0).abs() < 1e-6 && (y1 - y0).abs() < 1e-6 {
let s = 0.5_f32;
@ -30,12 +30,20 @@ fn to_truck(ole: &Ole2Frame) -> TruckEntity {
let cy = (y0 + y1) * 0.5;
let pts = vec![
// Rectangle
[x0, y0, z], [x1, y0, z], [x1, y0, z], [x1, y1, z],
[x1, y1, z], [x0, y1, z], [x0, y1, z], [x0, y0, z],
[x0, y0, z],
[x1, y0, z],
[x1, y0, z],
[x1, y1, z],
[x1, y1, z],
[x0, y1, z],
[x0, y1, z],
[x0, y0, z],
// Diagonal X
[x0, y0, z], [x1, y1, z],
[x0, y0, z],
[x1, y1, z],
[f32::NAN; 3],
[x1, y0, z], [x0, y1, z],
[x1, y0, z],
[x0, y1, z],
];
let center = Vec3::new(cx, cy, z);
TruckEntity {
@ -59,7 +67,11 @@ fn grips(ole: &Ole2Frame) -> Vec<GripDef> {
ole.lower_right_corner.z as f32,
);
let center = (ul + lr) * 0.5;
vec![square_grip(0, ul), square_grip(1, lr), diamond_grip(2, center)]
vec![
square_grip(0, ul),
square_grip(1, lr),
diamond_grip(2, center),
]
}
fn properties(ole: &Ole2Frame) -> PropSection {
@ -81,7 +93,9 @@ fn properties(ole: &Ole2Frame) -> PropSection {
}
fn apply_geom_prop(ole: &mut Ole2Frame, field: &str, value: &str) {
let Ok(v) = value.trim().parse::<f64>() else { return };
let Ok(v) = value.trim().parse::<f64>() else {
return;
};
match field {
"ole_ulx" => ole.upper_left_corner.x = v,
"ole_uly" => ole.upper_left_corner.y = v,
@ -139,15 +153,25 @@ impl TruckConvertible for Ole2Frame {
}
impl Grippable for Ole2Frame {
fn grips(&self) -> Vec<GripDef> { grips(self) }
fn apply_grip(&mut self, grip_id: usize, apply: GripApply) { apply_grip(self, grip_id, apply); }
fn grips(&self) -> Vec<GripDef> {
grips(self)
}
fn apply_grip(&mut self, grip_id: usize, apply: GripApply) {
apply_grip(self, grip_id, apply);
}
}
impl PropertyEditable for Ole2Frame {
fn geometry_properties(&self, _text_style_names: &[String]) -> PropSection { properties(self) }
fn apply_geom_prop(&mut self, field: &str, value: &str) { apply_geom_prop(self, field, value); }
fn geometry_properties(&self, _text_style_names: &[String]) -> PropSection {
properties(self)
}
fn apply_geom_prop(&mut self, field: &str, value: &str) {
apply_geom_prop(self, field, value);
}
}
impl Transformable for Ole2Frame {
fn apply_transform(&mut self, t: &EntityTransform) { apply_transform(self, t); }
fn apply_transform(&mut self, t: &EntityTransform) {
apply_transform(self, t);
}
}