Skip to content

Commit

Permalink
Extrude bug (#2986)
Browse files Browse the repository at this point in the history
* fix bug

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* images

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
  • Loading branch information
jessfraz committed Jul 10, 2024
1 parent 21e2a92 commit 73e26cb
Show file tree
Hide file tree
Showing 23 changed files with 66 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ src/wasm-lib/grackle/stdlib_cube_partial.json
Mac_App_Distribution.provisionprofile

*.tsbuildinfo

venv
2 changes: 1 addition & 1 deletion docs/kcl/angledLineOfYLength.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/kcl/getEdge.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/kcl/revolve.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/wasm-lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/wasm-lib/kcl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kcl-lib"
description = "KittyCAD Language implementation and tools"
version = "0.1.71"
version = "0.1.72"
edition = "2021"
license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app"
Expand Down
37 changes: 22 additions & 15 deletions src/wasm-lib/kcl/src/std/extrude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,24 @@ async fn inner_extrude(length: f64, sketch_group_set: SketchGroupSet, args: Args
let sketch_groups: Vec<Box<SketchGroup>> = sketch_group_set.into();
let mut extrude_groups = Vec::new();
for sketch_group in &sketch_groups {
// Make sure we exited sketch mode if sketching on a plane.
if let SketchSurface::Plane(_) = sketch_group.on {
// Disable the sketch mode.
// This is necessary for when people don't close the sketch explicitly.
// The sketch mode will mess up the extrude direction if still active.
args.batch_modeling_cmd(uuid::Uuid::new_v4(), kittycad::types::ModelingCmd::SketchModeDisable {})
.await?;
}
// Before we extrude, we need to enable the sketch mode.
// We do this here in case extrude is called out of order.
args.batch_modeling_cmd(
uuid::Uuid::new_v4(),
kittycad::types::ModelingCmd::EnableSketchMode {
animated: false,
ortho: false,
entity_id: sketch_group.on.id(),
adjust_camera: false,
planar_normal: if let SketchSurface::Plane(plane) = &sketch_group.on {
// We pass in the normal for the plane here.
Some(plane.z_axis.clone().into())
} else {
None
},
},
)
.await?;

args.send_modeling_cmd(
id,
Expand All @@ -95,6 +105,10 @@ async fn inner_extrude(length: f64, sketch_group_set: SketchGroupSet, args: Args
},
)
.await?;

// Disable the sketch mode.
args.batch_modeling_cmd(uuid::Uuid::new_v4(), kittycad::types::ModelingCmd::SketchModeDisable {})
.await?;
extrude_groups.push(do_post_extrude(sketch_group.clone(), length, id, args.clone()).await?);
}

Expand All @@ -107,13 +121,6 @@ pub(crate) async fn do_post_extrude(
id: Uuid,
args: Args,
) -> Result<Box<ExtrudeGroup>, KclError> {
// We need to do this after extrude for sketch on face.
if let SketchSurface::Face(_) = sketch_group.on {
// Disable the sketch mode.
args.batch_modeling_cmd(uuid::Uuid::new_v4(), kittycad::types::ModelingCmd::SketchModeDisable {})
.await?;
}

// Bring the object to the front of the scene.
// See: https://github.com/KittyCAD/modeling-app/issues/806
args.batch_modeling_cmd(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/wasm-lib/kcl/tests/outputs/serial_test_example_get_edge0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/wasm-lib/kcl/tests/outputs/serial_test_example_revolve4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/wasm-lib/kcl/tests/outputs/serial_test_example_revolve5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions src/wasm-lib/tests/executor/inputs/extrude-custom-plane.kcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// create a sketch with name sketch000
const sketch000 = startSketchOn('XY')
|> startProfileAt([0.0, 0.0], %)
|> line([1.0, 1.0], %, $line000)
|> line([0.0, -1.0], %, $line001)
|> line([-1.0, 0.0], %, $line002)

// create an extrusion with name extrude000
const extrude000 = extrude(1.0, sketch000)

// define a plane with name plane005
const plane005 = {
plane: {
origin: [0.0, 0.0, 1.0],
x_axis: [0.707107, 0.707107, 0.0],
y_axis: [-0.0, 0.0, 1.0],
z_axis: [0.707107, -0.707107, 0.0]
}
}

// create a sketch with name sketch001
const sketch001 = startSketchOn(plane005)
|> startProfileAt([0.100000, 0.250000], %)
|> line([0.075545, 0.494260], %, $line003)
|> line([0.741390, -0.113317], %, $line004)
|> line([-0.816935, -0.380943], %, $line005)

// create an extrusion with name extrude001
const extrude001 = extrude(1.0, sketch001)
7 changes: 7 additions & 0 deletions src/wasm-lib/tests/executor/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2501,3 +2501,10 @@ async fn serial_test_order_sketch_extrude_out_of_order() {
0.999,
);
}

#[tokio::test(flavor = "multi_thread")]
async fn serial_test_extrude_custom_plane() {
let code = include_str!("inputs/extrude-custom-plane.kcl");
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
twenty_twenty::assert_image("tests/executor/outputs/extrude-custom-plane.png", &result, 0.999);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/wasm-lib/tests/executor/outputs/revolve_on_edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/wasm-lib/tests/executor/outputs/revolve_on_face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/wasm-lib/tests/executor/outputs/revolve_on_face_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/wasm-lib/tests/executor/outputs/revolve_on_face_circle_edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/wasm-lib/tests/executor/outputs/tangential_arc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/wasm-lib/tests/executor/outputs/tangential_arc_to.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 73e26cb

Please sign in to comment.