|
@@ -22,7 +22,7 @@ use super::{line::Lines, Object, ObjectCore};
|
|
|
))]
|
|
|
#[br(map = Self::from_bytes)]
|
|
|
#[bw(map = |&x| Self::into_bytes(x))]
|
|
|
-pub struct ObjectFlags {
|
|
|
+pub struct HatchFlag {
|
|
|
pub all_calc: B1,
|
|
|
pub follow_edge_once: B1,
|
|
|
pub continuous_pattern: B1, // Hatch type 4 when combined with bidirectional_pattern
|
|
@@ -51,48 +51,48 @@ pub struct ObjectFlags {
|
|
|
#[brw(magic(46u32))] // Number of fields in this struct
|
|
|
pub struct LegacyHatchSetting {
|
|
|
pub mark_contour: U32,
|
|
|
+ pub hatch_0_enable: U32,
|
|
|
+ pub hatch_0_pen: U32,
|
|
|
+ pub hatch_0_flags: FieldOf<HatchFlag>,
|
|
|
+ pub hatch_0_edge_offset: F64,
|
|
|
+ pub hatch_0_line_spacing: F64,
|
|
|
+ pub hatch_0_start_offset: F64,
|
|
|
+ pub hatch_0_end_offset: F64,
|
|
|
+ pub hatch_0_angle: F64,
|
|
|
pub hatch_1_enable: U32,
|
|
|
pub hatch_1_pen: U32,
|
|
|
- pub hatch_1_flags: FieldOf<ObjectFlags>,
|
|
|
+ pub hatch_1_flags: FieldOf<HatchFlag>,
|
|
|
pub hatch_1_edge_offset: F64,
|
|
|
pub hatch_1_line_spacing: F64,
|
|
|
pub hatch_1_start_offset: F64,
|
|
|
pub hatch_1_end_offset: F64,
|
|
|
pub hatch_1_angle: F64,
|
|
|
+ pub any_hatch_enabled: U32,
|
|
|
+ pub hatch_0_rotate_angle: F64,
|
|
|
+ pub hatch_1_rotate_angle: F64,
|
|
|
pub hatch_2_enable: U32,
|
|
|
pub hatch_2_pen: U32,
|
|
|
- pub hatch_2_flags: FieldOf<ObjectFlags>,
|
|
|
+ pub hatch_2_flags: FieldOf<HatchFlag>,
|
|
|
pub hatch_2_edge_offset: F64,
|
|
|
pub hatch_2_line_spacing: F64,
|
|
|
pub hatch_2_start_offset: F64,
|
|
|
pub hatch_2_end_offset: F64,
|
|
|
pub hatch_2_angle: F64,
|
|
|
- pub any_hatch_enabled: U32,
|
|
|
- pub hatch_1_auto_rotate_angle: F64,
|
|
|
- pub hatch_2_auto_rotate_angle: F64,
|
|
|
- pub hatch_3_enable: U32,
|
|
|
- pub hatch_3_pen: U32,
|
|
|
- pub hatch_3_flags: FieldOf<ObjectFlags>,
|
|
|
- pub hatch_3_edge_offset: F64,
|
|
|
- pub hatch_3_line_spacing: F64,
|
|
|
- pub hatch_3_start_offset: F64,
|
|
|
- pub hatch_3_end_offset: F64,
|
|
|
- pub hatch_3_angle: F64,
|
|
|
- pub hatch_3_auto_rotate_angle: F64,
|
|
|
+ pub hatch_2_rotate_angle: F64,
|
|
|
+ pub hatch_0_line_reduction: F64,
|
|
|
pub hatch_1_line_reduction: F64,
|
|
|
pub hatch_2_line_reduction: F64,
|
|
|
- pub hatch_3_line_reduction: F64,
|
|
|
+ pub hatch_0_loop_count: U32,
|
|
|
pub hatch_1_loop_count: U32,
|
|
|
pub hatch_2_loop_count: U32,
|
|
|
- pub hatch_3_loop_count: U32,
|
|
|
+ pub hatch_0_loop_distance: F64,
|
|
|
pub hatch_1_loop_distance: F64,
|
|
|
pub hatch_2_loop_distance: F64,
|
|
|
- pub hatch_3_loop_distance: F64,
|
|
|
_unknown_1: [Field; 3],
|
|
|
pub contour_priority: U32,
|
|
|
+ pub hatch_0_count: U32,
|
|
|
pub hatch_1_count: U32,
|
|
|
pub hatch_2_count: U32,
|
|
|
- pub hatch_3_count: U32,
|
|
|
}
|
|
|
|
|
|
// Custom Debug implementation to only print known fields
|
|
@@ -101,6 +101,14 @@ impl Debug for LegacyHatchSetting {
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
f.debug_struct("LegacyHatchSetting")
|
|
|
.field("mark_contour", &self.mark_contour)
|
|
|
+ .field("hatch_0_enable", &self.hatch_0_enable)
|
|
|
+ .field("hatch_0_pen", &self.hatch_0_pen)
|
|
|
+ .field("hatch_0_flags", &self.hatch_0_flags)
|
|
|
+ .field("hatch_0_edge_offset", &self.hatch_0_edge_offset)
|
|
|
+ .field("hatch_0_line_spacing", &self.hatch_0_line_spacing)
|
|
|
+ .field("hatch_0_start_offset", &self.hatch_0_start_offset)
|
|
|
+ .field("hatch_0_end_offset", &self.hatch_0_end_offset)
|
|
|
+ .field("hatch_0_angle", &self.hatch_0_angle)
|
|
|
.field("hatch_1_enable", &self.hatch_1_enable)
|
|
|
.field("hatch_1_pen", &self.hatch_1_pen)
|
|
|
.field("hatch_1_flags", &self.hatch_1_flags)
|
|
@@ -109,6 +117,9 @@ impl Debug for LegacyHatchSetting {
|
|
|
.field("hatch_1_start_offset", &self.hatch_1_start_offset)
|
|
|
.field("hatch_1_end_offset", &self.hatch_1_end_offset)
|
|
|
.field("hatch_1_angle", &self.hatch_1_angle)
|
|
|
+ .field("any_hatch_enabled", &self.any_hatch_enabled)
|
|
|
+ .field("hatch_0_auto_rotate_angle", &self.hatch_0_rotate_angle)
|
|
|
+ .field("hatch_1_auto_rotate_angle", &self.hatch_1_rotate_angle)
|
|
|
.field("hatch_2_enable", &self.hatch_2_enable)
|
|
|
.field("hatch_2_pen", &self.hatch_2_pen)
|
|
|
.field("hatch_2_flags", &self.hatch_2_flags)
|
|
@@ -117,31 +128,20 @@ impl Debug for LegacyHatchSetting {
|
|
|
.field("hatch_2_start_offset", &self.hatch_2_start_offset)
|
|
|
.field("hatch_2_end_offset", &self.hatch_2_end_offset)
|
|
|
.field("hatch_2_angle", &self.hatch_2_angle)
|
|
|
- .field("any_hatch_enabled", &self.any_hatch_enabled)
|
|
|
- .field("hatch_1_auto_rotate_angle", &self.hatch_1_auto_rotate_angle)
|
|
|
- .field("hatch_2_auto_rotate_angle", &self.hatch_2_auto_rotate_angle)
|
|
|
- .field("hatch_3_enable", &self.hatch_3_enable)
|
|
|
- .field("hatch_3_pen", &self.hatch_3_pen)
|
|
|
- .field("hatch_3_flags", &self.hatch_3_flags)
|
|
|
- .field("hatch_3_edge_offset", &self.hatch_3_edge_offset)
|
|
|
- .field("hatch_3_line_spacing", &self.hatch_3_line_spacing)
|
|
|
- .field("hatch_3_start_offset", &self.hatch_3_start_offset)
|
|
|
- .field("hatch_3_end_offset", &self.hatch_3_end_offset)
|
|
|
- .field("hatch_3_angle", &self.hatch_3_angle)
|
|
|
- .field("hatch_3_auto_rotate_angle", &self.hatch_3_auto_rotate_angle)
|
|
|
+ .field("hatch_2_auto_rotate_angle", &self.hatch_2_rotate_angle)
|
|
|
+ .field("hatch_0_line_reduction", &self.hatch_0_line_reduction)
|
|
|
.field("hatch_1_line_reduction", &self.hatch_1_line_reduction)
|
|
|
.field("hatch_2_line_reduction", &self.hatch_2_line_reduction)
|
|
|
- .field("hatch_3_line_reduction", &self.hatch_3_line_reduction)
|
|
|
+ .field("hatch_0_loop_count", &self.hatch_0_loop_count)
|
|
|
.field("hatch_1_loop_count", &self.hatch_1_loop_count)
|
|
|
.field("hatch_2_loop_count", &self.hatch_2_loop_count)
|
|
|
- .field("hatch_3_loop_count", &self.hatch_3_loop_count)
|
|
|
+ .field("hatch_0_loop_distance", &self.hatch_0_loop_distance)
|
|
|
.field("hatch_1_loop_distance", &self.hatch_1_loop_distance)
|
|
|
.field("hatch_2_loop_distance", &self.hatch_2_loop_distance)
|
|
|
- .field("hatch_3_loop_distance", &self.hatch_3_loop_distance)
|
|
|
.field("contour_priority", &self.contour_priority)
|
|
|
+ .field("hatch_0_count", &self.hatch_0_count)
|
|
|
.field("hatch_1_count", &self.hatch_1_count)
|
|
|
.field("hatch_2_count", &self.hatch_2_count)
|
|
|
- .field("hatch_3_count", &self.hatch_3_count)
|
|
|
.finish()
|
|
|
}
|
|
|
}
|
|
@@ -156,13 +156,13 @@ pub struct HatchSetting {
|
|
|
pub count: U32,
|
|
|
pub enabled: U32,
|
|
|
pub pen: U32,
|
|
|
- pub flags: FieldOf<ObjectFlags>,
|
|
|
+ pub flags: FieldOf<HatchFlag>,
|
|
|
pub edge_offset: F64,
|
|
|
pub line_spacing: F64,
|
|
|
pub start_offset: F64,
|
|
|
pub end_offset: F64,
|
|
|
pub angle: F64,
|
|
|
- pub auto_rotate_angle: F64,
|
|
|
+ pub rotate_angle: F64,
|
|
|
pub line_reduction: F64,
|
|
|
pub loop_distance: F64,
|
|
|
pub loop_count: U32,
|
|
@@ -183,7 +183,7 @@ impl Debug for HatchSetting {
|
|
|
.field("start_offset", &self.start_offset)
|
|
|
.field("end_offset", &self.end_offset)
|
|
|
.field("angle", &self.angle)
|
|
|
- .field("auto_rotate_angle", &self.auto_rotate_angle)
|
|
|
+ .field("auto_rotate_angle", &self.rotate_angle)
|
|
|
.field("line_reduction", &self.line_reduction)
|
|
|
.field("loop_distance", &self.loop_distance)
|
|
|
.field("loop_count", &self.loop_count)
|
|
@@ -191,6 +191,82 @@ impl Debug for HatchSetting {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+impl Default for HatchSetting {
|
|
|
+ fn default() -> Self {
|
|
|
+ Self {
|
|
|
+ count: 1.into(),
|
|
|
+ enabled: false.into(),
|
|
|
+ pen: 0.into(),
|
|
|
+ flags: HatchFlag::new().into(),
|
|
|
+ edge_offset: 0.0.into(),
|
|
|
+ line_spacing: 0.0.into(),
|
|
|
+ start_offset: 0.0.into(),
|
|
|
+ end_offset: 0.0.into(),
|
|
|
+ angle: 0.0.into(),
|
|
|
+ rotate_angle: 0.0.into(),
|
|
|
+ line_reduction: 0.0.into(),
|
|
|
+ loop_distance: 0.0.into(),
|
|
|
+ loop_count: 0.into(),
|
|
|
+ _unknown_1: [vec![0, 0, 0, 0, 0, 0, 0, 0].into(), vec![0, 0, 0, 0].into()].into(),
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+impl From<Vec<HatchSetting>> for LegacyHatchSetting {
|
|
|
+ fn from(value: Vec<HatchSetting>) -> Self {
|
|
|
+ LegacyHatchSetting {
|
|
|
+ mark_contour: false.into(),
|
|
|
+ hatch_0_enable: value.get(0).map(|x| x.enabled).unwrap_or_default(),
|
|
|
+ hatch_0_pen: value.get(0).map(|x| x.pen).unwrap_or_default(),
|
|
|
+ hatch_0_flags: value.get(0).map(|x| x.flags).unwrap_or_default(),
|
|
|
+ hatch_0_edge_offset: value.get(0).map(|x| x.edge_offset).unwrap_or_default(),
|
|
|
+ hatch_0_line_spacing: value.get(0).map(|x| x.line_spacing).unwrap_or_default(),
|
|
|
+ hatch_0_start_offset: value.get(0).map(|x| x.start_offset).unwrap_or_default(),
|
|
|
+ hatch_0_end_offset: value.get(0).map(|x| x.end_offset).unwrap_or_default(),
|
|
|
+ hatch_0_angle: value.get(0).map(|x| x.angle).unwrap_or_default(),
|
|
|
+ hatch_1_enable: value.get(1).map(|x| x.enabled).unwrap_or_default(),
|
|
|
+ hatch_1_pen: value.get(1).map(|x| x.pen).unwrap_or_default(),
|
|
|
+ hatch_1_flags: value.get(1).map(|x| x.flags).unwrap_or_default(),
|
|
|
+ hatch_1_edge_offset: value.get(1).map(|x| x.edge_offset).unwrap_or_default(),
|
|
|
+ hatch_1_line_spacing: value.get(1).map(|x| x.line_spacing).unwrap_or_default(),
|
|
|
+ hatch_1_start_offset: value.get(1).map(|x| x.start_offset).unwrap_or_default(),
|
|
|
+ hatch_1_end_offset: value.get(1).map(|x| x.end_offset).unwrap_or_default(),
|
|
|
+ hatch_1_angle: value.get(1).map(|x| x.angle).unwrap_or_default(),
|
|
|
+ any_hatch_enabled: value.iter().any(|x| x.enabled.into()).into(),
|
|
|
+ hatch_0_rotate_angle: value.get(0).map(|x| x.rotate_angle).unwrap_or_default(),
|
|
|
+ hatch_1_rotate_angle: value.get(1).map(|x| x.rotate_angle).unwrap_or_default(),
|
|
|
+ hatch_2_enable: value.get(2).map(|x| x.enabled).unwrap_or_default(),
|
|
|
+ hatch_2_pen: value.get(2).map(|x| x.pen).unwrap_or_default(),
|
|
|
+ hatch_2_flags: value.get(2).map(|x| x.flags).unwrap_or_default(),
|
|
|
+ hatch_2_edge_offset: value.get(2).map(|x| x.edge_offset).unwrap_or_default(),
|
|
|
+ hatch_2_line_spacing: value.get(2).map(|x| x.line_spacing).unwrap_or_default(),
|
|
|
+ hatch_2_start_offset: value.get(2).map(|x| x.start_offset).unwrap_or_default(),
|
|
|
+ hatch_2_end_offset: value.get(2).map(|x| x.end_offset).unwrap_or_default(),
|
|
|
+ hatch_2_angle: value.get(2).map(|x| x.angle).unwrap_or_default(),
|
|
|
+ hatch_2_rotate_angle: value.get(2).map(|x| x.rotate_angle).unwrap_or_default(),
|
|
|
+ hatch_0_line_reduction: value.get(0).map(|x| x.line_reduction).unwrap_or_default(),
|
|
|
+ hatch_1_line_reduction: value.get(1).map(|x| x.line_reduction).unwrap_or_default(),
|
|
|
+ hatch_2_line_reduction: value.get(2).map(|x| x.line_reduction).unwrap_or_default(),
|
|
|
+ hatch_0_loop_count: value.get(0).map(|x| x.loop_count).unwrap_or_default(),
|
|
|
+ hatch_1_loop_count: value.get(1).map(|x| x.loop_count).unwrap_or_default(),
|
|
|
+ hatch_2_loop_count: value.get(2).map(|x| x.loop_count).unwrap_or_default(),
|
|
|
+ hatch_0_loop_distance: value.get(0).map(|x| x.loop_distance).unwrap_or_default(),
|
|
|
+ hatch_1_loop_distance: value.get(1).map(|x| x.loop_distance).unwrap_or_default(),
|
|
|
+ hatch_2_loop_distance: value.get(2).map(|x| x.loop_distance).unwrap_or_default(),
|
|
|
+ _unknown_1: [
|
|
|
+ vec![0, 0, 0, 0, 0, 0, 0, 0].into(),
|
|
|
+ vec![0, 0, 0, 0, 0, 0, 0, 0].into(),
|
|
|
+ vec![0, 0, 0, 0, 0, 0, 0, 0].into(),
|
|
|
+ ]
|
|
|
+ .into(),
|
|
|
+ contour_priority: false.into(),
|
|
|
+ hatch_0_count: value.get(0).map(|x| x.count).unwrap_or_default(),
|
|
|
+ hatch_1_count: value.get(1).map(|x| x.count).unwrap_or_default(),
|
|
|
+ hatch_2_count: value.get(2).map(|x| x.count).unwrap_or_default(),
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#[derive(BinRead, BinWrite, Debug, Diff, PartialEq)]
|
|
|
#[diff(attr(
|
|
|
#[derive(Debug, PartialEq)]
|
|
@@ -206,7 +282,7 @@ pub struct HatchLine {
|
|
|
#[brw(magic(16_u32))] // ObjectType::HatchLine
|
|
|
pub struct HatchLines {
|
|
|
pub core: ObjectCore,
|
|
|
- pub hatches: ArrayOf<HatchLine>,
|
|
|
+ pub hatch_line: ArrayOf<HatchLine>,
|
|
|
}
|
|
|
|
|
|
#[derive(BinRead, BinWrite, Debug, Diff, PartialEq)]
|
|
@@ -215,7 +291,7 @@ pub struct HatchLines {
|
|
|
))]
|
|
|
pub struct Hatches {
|
|
|
pub core: ObjectCore,
|
|
|
- pub hatches: ArrayOf<HatchLines>,
|
|
|
+ pub hatch_lines: ArrayOf<HatchLines>,
|
|
|
}
|
|
|
|
|
|
#[binrw]
|