Skip to content

Commit ff87097

Browse files
authored
Extrude can send IDs for the new faces (#671)
When extruding a 2D shape into a 3D shape, a bunch of new faces are created. These faces need IDs. The backend currently generates these IDs randomly. Add a new option to allow the client to send the IDs.
1 parent e8c8562 commit ff87097

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

modeling-cmds/src/def_enum.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ define_modeling_cmd_enum! {
2424
Angle,
2525
CutType,
2626
CameraMovement,
27+
ExtrudedFaceInfo,
2728
AnnotationOptions, AnnotationType, CameraDragInteractionType, Color, DistanceType, EntityType,
2829
PathComponentConstraintBound, PathComponentConstraintType, PathSegment, PerspectiveCameraParameters,
2930
Point2d, Point3d, SceneSelectionType, SceneToolType,
@@ -99,6 +100,10 @@ define_modeling_cmd_enum! {
99100
pub target: ModelingCmdId,
100101
/// How far off the plane to extrude
101102
pub distance: LengthUnit,
103+
/// Which IDs should the new faces have?
104+
/// If this isn't given, the engine will generate IDs.
105+
#[serde(default)]
106+
pub faces: Option<ExtrudedFaceInfo>,
102107
}
103108

104109
/// Extrude the object along a path.

modeling-cmds/src/shared.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use enum_iterator::Sequence;
22
use parse_display_derive::{Display, FromStr};
33
use schemars::JsonSchema;
44
use serde::{Deserialize, Serialize};
5+
use uuid::Uuid;
56

67
#[cfg(feature = "cxx")]
78
use crate::impl_extern_type;
@@ -619,6 +620,29 @@ impl From<EngineErrorCode> for http::StatusCode {
619620
}
620621
}
621622

623+
/// IDs for the extruded faces.
624+
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
625+
pub struct ExtrudedFaceInfo {
626+
/// The face made from the original 2D shape being extruded.
627+
/// If the solid is extruded from a shape which already has an ID
628+
/// (e.g. extruding something which was sketched on a face), this
629+
/// doesn't need to be sent.
630+
pub bottom: Option<Uuid>,
631+
/// Top face of the extrusion (parallel and further away from the original 2D shape being extruded).
632+
pub top: Uuid,
633+
/// Any intermediate sides between the top and bottom.
634+
pub sides: Vec<SideFace>,
635+
}
636+
637+
/// IDs for a side face, extruded from the path of some sketch/2D shape.
638+
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
639+
pub struct SideFace {
640+
/// ID of the path this face is being extruded from.
641+
pub path_id: Uuid,
642+
/// Desired ID for the resulting face.
643+
pub face_id: Uuid,
644+
}
645+
622646
/// Camera settings including position, center, fov etc
623647
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
624648
pub struct CameraSettings {

modeling-session/examples/cube_png.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ async fn main() -> Result<()> {
107107
Extrude {
108108
distance: CUBE_WIDTH * 2.0,
109109
target: path,
110+
faces: None,
110111
}
111112
.into(),
112113
)

modeling-session/examples/cube_png_batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ async fn main() -> Result<()> {
9898
cmd: ModelingCmd::Extrude(Extrude {
9999
distance: CUBE_WIDTH * 2.0,
100100
target: path,
101+
faces: None,
101102
}),
102103
cmd_id: random_id(),
103104
});

modeling-session/examples/lsystem_png_batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ async fn main() -> Result<()> {
137137
cmd: ModelingCmd::Extrude(Extrude {
138138
distance: LengthUnit(1.0),
139139
target: path,
140+
faces: None,
140141
}),
141142
cmd_id: random_id(),
142143
});

0 commit comments

Comments
 (0)