1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- use std::fmt::Debug;
- use binrw::{BinRead, BinWrite};
- use diff::Diff;
- use crate::{
- field_of::FieldOf,
- types::{Field, ObjectType, Point, F64, U32},
- };
- use super::{ObjectCore, Translate};
- #[cfg_attr(feature = "default-debug", derive(Debug))]
- #[derive(BinRead, BinWrite, Clone, Diff, PartialEq)]
- #[diff(attr(
- #[derive(Debug, PartialEq)]
- ))]
- pub struct Circle {
- pub core: ObjectCore,
- #[brw(magic(6u32))] // Number of following fields in struct
- pub origin: FieldOf<Point>,
- pub radius: F64,
- pub start_angle: F64, // Radians
- pub clockwise: U32,
- pub _unknown_1: [Field; 2],
- }
- // Custom Debug implementation to only print known fields
- #[cfg(not(feature = "default-debug"))]
- impl Debug for Circle {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- f.debug_struct("Circle")
- .field("core", &self.core)
- .field("origin", &self.origin)
- .field("radius", &self.radius)
- .field("start_angle", &self.start_angle)
- .field("clockwise", &self.clockwise)
- .finish()
- }
- }
- impl Default for Circle {
- fn default() -> Self {
- Self {
- core: ObjectCore::default(ObjectType::Circle),
- origin: Point { x: 0.0, y: 0.0 }.into(),
- radius: 0.0.into(),
- start_angle: 0.0.into(),
- clockwise: 0.into(),
- _unknown_1: [
- vec![0, 0, 0, 0].into(), // 0_u32
- vec![
- 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63,
- ] // ???
- .into(),
- ],
- }
- }
- }
- impl Translate for Circle {
- fn translate(&mut self, origin: Option<Point>, z: Option<f64>) {
- self.core.translate(origin, z);
- origin.map(|origin| self.origin = origin.into());
- }
- }
|