Fix sketchOnFace point&click for booleans (#6713)

* fix bool sketchOnFace

* fix chamfer test

* add test

* Kurt composite attempt (#6722)

* composite attempt

* Add forward edge to CSG artifacts in artifact graph

* Fix comment

* Move the doc comments above the attributes

* Fix to update the correct field of Path

* Update output

---------

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>

* use rust defined composite solid edges instead

* Update src/hooks/useEngineConnectionSubscriptions.ts

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>

* Revert PNG screenshots

* Fix TS formatting

---------

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
This commit is contained in:
Kurt Hutten
2025-05-07 08:25:12 +10:00
committed by GitHub
parent 996517f5c4
commit d187a29e55
17 changed files with 256 additions and 73 deletions

View File

@ -150,6 +150,10 @@ pub struct CompositeSolid {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub tool_ids: Vec<ArtifactId>,
pub code_ref: CodeRef,
/// This is the ID of the composite solid that this is part of, if any, as a
/// composite solid can be used as input for another composite solid.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub composite_solid_id: Option<ArtifactId>,
}
#[derive(Debug, Clone, Copy, Serialize, PartialEq, Eq, ts_rs::TS)]
@ -182,6 +186,10 @@ pub struct Path {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub solid2d_id: Option<ArtifactId>,
pub code_ref: CodeRef,
/// This is the ID of the composite solid that this is part of, if any, as
/// this can be used as input for another composite solid.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub composite_solid_id: Option<ArtifactId>,
}
#[derive(Debug, Clone, Serialize, PartialEq, ts_rs::TS)]
@ -585,6 +593,7 @@ impl CompositeSolid {
};
merge_ids(&mut self.solid_ids, new.solid_ids);
merge_ids(&mut self.tool_ids, new.tool_ids);
merge_opt_id(&mut self.composite_solid_id, new.composite_solid_id);
None
}
@ -609,6 +618,7 @@ impl Path {
merge_opt_id(&mut self.sweep_id, new.sweep_id);
merge_ids(&mut self.seg_ids, new.seg_ids);
merge_opt_id(&mut self.solid2d_id, new.solid2d_id);
merge_opt_id(&mut self.composite_solid_id, new.composite_solid_id);
None
}
@ -921,6 +931,7 @@ fn artifacts_to_update(
sweep_id: None,
solid2d_id: None,
code_ref,
composite_solid_id: None,
}));
let plane = artifacts.get(&ArtifactId::new(*current_plane_id));
if let Some(Artifact::Plane(plane)) = plane {
@ -1359,20 +1370,59 @@ fn artifacts_to_update(
.for_each(|id| new_solid_ids.push(id)),
_ => {}
}
let return_arr = new_solid_ids
.into_iter()
.map(|solid_id| {
Artifact::CompositeSolid(CompositeSolid {
id: solid_id,
sub_type,
solid_ids: solid_ids.clone(),
tool_ids: tool_ids.clone(),
code_ref: code_ref.clone(),
})
})
.collect::<Vec<_>>();
// TODO: Should we add the reverse graph edges?
let mut return_arr = Vec::new();
// Create the new composite solids and update their linked artifacts
for solid_id in &new_solid_ids {
// Create the composite solid
return_arr.push(Artifact::CompositeSolid(CompositeSolid {
id: *solid_id,
sub_type,
solid_ids: solid_ids.clone(),
tool_ids: tool_ids.clone(),
code_ref: code_ref.clone(),
composite_solid_id: None,
}));
// Update the artifacts that were used as input for this composite solid
for input_id in &solid_ids {
if let Some(artifact) = artifacts.get(input_id) {
match artifact {
Artifact::CompositeSolid(comp) => {
let mut new_comp = comp.clone();
new_comp.composite_solid_id = Some(*solid_id);
return_arr.push(Artifact::CompositeSolid(new_comp));
}
Artifact::Path(path) => {
let mut new_path = path.clone();
new_path.composite_solid_id = Some(*solid_id);
return_arr.push(Artifact::Path(new_path));
}
_ => {}
}
}
}
// Update the tool artifacts if this is a subtract operation
for tool_id in &tool_ids {
if let Some(artifact) = artifacts.get(tool_id) {
match artifact {
Artifact::CompositeSolid(comp) => {
let mut new_comp = comp.clone();
new_comp.composite_solid_id = Some(*solid_id);
return_arr.push(Artifact::CompositeSolid(new_comp));
}
Artifact::Path(path) => {
let mut new_path = path.clone();
new_path.composite_solid_id = Some(*solid_id);
return_arr.push(Artifact::Path(new_path));
}
_ => {}
}
}
}
}
return Ok(return_arr);
}