-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsg.rs
50 lines (40 loc) · 1022 Bytes
/
csg.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use serde::Serialize;
use serde::Deserialize;
use bevy::prelude::*;
//just for now ..
pub type Position = Vec3;
pub type Rotation = Vec3;
//maybe use bevy primitive shapes ?
#[derive(Debug, Serialize, Deserialize)]
enum ShapeType {
Cube,
Sphere,
Cylinder,
}
#[derive(Debug, Serialize, Deserialize)]
struct Shape {
id: u32,
shape_type: ShapeType,
dimensions: Vec<f32>, // Can vary: [size] for Cube, [radius] for Sphere, [height, radius] for Cylinder
position: Position,
rotation: Rotation,
}
#[derive(Debug, Serialize, Deserialize)]
enum OperationType {
Union,
Intersection,
Subtraction
}
#[derive(Debug, Serialize, Deserialize)]
struct Operation {
id: u32,
operation_type: OperationType,
inputs: Vec<u32>, // References to other Operation IDs or Shape IDs
}
//this is a Save file that would be saved or loaded
#[derive(Debug, Serialize, Deserialize)]
struct CSGModel {
shapes: Vec<Shape>,
operations: Vec<Operation>,
root_operation: u32,
}