forked from 1b-agent/opencadstudio-upstream
Correct pyramid rotation and property sections
This commit is contained in:
1 parent
0bfa48909f
commit
f9641bd9d5
2 files changed
+44
-4
No files matched your search
@@ -2074,6 +2074,9 @@ impl OpenCADStudio {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if specialized_primitive {
|
||||||
|
retain_specialized_primitive_sections(&mut sections);
|
||||||
|
}
|
||||||
let title = match entity {
|
let title = match entity {
|
||||||
acadrust::EntityType::Insert(ins) => {
|
acadrust::EntityType::Insert(ins) => {
|
||||||
let is_xref = self.tabs[i]
|
let is_xref = self.tabs[i]
|
||||||
@@ -3047,6 +3050,30 @@ fn aggregate_solid_history_sections(
|
|||||||
merged
|
merged
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn retain_specialized_primitive_sections(
|
||||||
|
sections: &mut Vec<crate::scene::model::object::PropSection>,
|
||||||
|
) {
|
||||||
|
sections.iter_mut().for_each(|section| {
|
||||||
|
section.props.retain(|property| {
|
||||||
|
matches!(
|
||||||
|
property.field,
|
||||||
|
"color"
|
||||||
|
| "layer"
|
||||||
|
| "linetype"
|
||||||
|
| "linetype_scale"
|
||||||
|
| "plot_style"
|
||||||
|
| "lineweight"
|
||||||
|
| "transparency"
|
||||||
|
| "hyperlink"
|
||||||
|
| "material"
|
||||||
|
| "solid_history_type"
|
||||||
|
) || crate::scene::model::solid_history::is_primitive_property(property.field)
|
||||||
|
|| crate::scene::model::solid_history::is_history_choice(property.field)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
sections.retain(|section| !section.props.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
fn merge_sections(
|
fn merge_sections(
|
||||||
left: &[crate::scene::model::object::PropSection],
|
left: &[crate::scene::model::object::PropSection],
|
||||||
right: &[crate::scene::model::object::PropSection],
|
right: &[crate::scene::model::object::PropSection],
|
||||||
|
|||||||
@@ -384,6 +384,16 @@ fn pyramid_display_radius(value: &SolidHistoryPyramid, radius: f64) -> f64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pyramid_display_rotation(value: &SolidHistoryPyramid) -> Option<f64> {
|
||||||
|
let vertex_rotation = matrix(value.base.transform)
|
||||||
|
.map(|matrix| matrix.x_axis.y.atan2(matrix.x_axis.x))?;
|
||||||
|
if pyramid_is_inscribed(value) {
|
||||||
|
Some(vertex_rotation)
|
||||||
|
} else {
|
||||||
|
Some(vertex_rotation + std::f64::consts::PI / value.sides.clamp(3, 32) as f64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn pyramid_properties(
|
fn pyramid_properties(
|
||||||
document: &acadrust::CadDocument,
|
document: &acadrust::CadDocument,
|
||||||
handle: acadrust::Handle,
|
handle: acadrust::Handle,
|
||||||
@@ -392,9 +402,7 @@ fn pyramid_properties(
|
|||||||
let Some(position) = world_point(value.base.transform, [0.0; 3]) else {
|
let Some(position) = world_point(value.base.transform, [0.0; 3]) else {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
let rotation = matrix(value.base.transform)
|
let rotation = pyramid_display_rotation(value).unwrap_or(0.0);
|
||||||
.map(|matrix| matrix.x_axis.y.atan2(matrix.x_axis.x))
|
|
||||||
.unwrap_or(0.0);
|
|
||||||
let (record_history, object_show_history, show_history_mode) =
|
let (record_history, object_show_history, show_history_mode) =
|
||||||
history_flags(document, handle).unwrap_or((false, false, 1));
|
history_flags(document, handle).unwrap_or((false, false, 1));
|
||||||
let (show_history, show_history_editable) =
|
let (show_history, show_history_editable) =
|
||||||
@@ -998,7 +1006,12 @@ fn apply_pyramid_geometry_property(
|
|||||||
return Some(false);
|
return Some(false);
|
||||||
}
|
}
|
||||||
let current_angle = projected.y.atan2(projected.x);
|
let current_angle = projected.y.atan2(projected.x);
|
||||||
let delta = (target - current_angle + std::f64::consts::PI)
|
let target_vertex_angle = if pyramid_is_inscribed(value) {
|
||||||
|
target
|
||||||
|
} else {
|
||||||
|
target - std::f64::consts::PI / value.sides.clamp(3, 32) as f64
|
||||||
|
};
|
||||||
|
let delta = (target_vertex_angle - current_angle + std::f64::consts::PI)
|
||||||
.rem_euclid(std::f64::consts::TAU)
|
.rem_euclid(std::f64::consts::TAU)
|
||||||
- std::f64::consts::PI;
|
- std::f64::consts::PI;
|
||||||
if delta.abs() <= 1e-12 {
|
if delta.abs() <= 1e-12 {
|
||||||
|
|||||||
Reference in new issue
Block a user