lines
This commit is contained in:
43
src/lib.rs
43
src/lib.rs
@@ -52,7 +52,7 @@ impl ToVec3 for fj_math::Vector<3> {
|
||||
|
||||
|
||||
#[derive(Component)]
|
||||
struct FjSolidWrapper{
|
||||
struct FjSolidWrapper {
|
||||
handle: fj_core::storage::Handle<Solid>,
|
||||
}
|
||||
|
||||
@@ -156,18 +156,16 @@ fn update_fj_model_system(
|
||||
..default()
|
||||
},
|
||||
FjConvertedFlag
|
||||
|
||||
));
|
||||
add_debug_info_to_entity(&mut commands, solid, &mut meshes, &mut materials);
|
||||
}
|
||||
}
|
||||
|
||||
fn render_line(mut commands: &mut Commands,
|
||||
fn render_line<const T: usize>(mut commands: &mut Commands,
|
||||
fj_model: &FjMeshWrapper,
|
||||
mut meshes: &mut ResMut<Assets<Mesh>>,
|
||||
mut materials: &mut ResMut<Assets<StandardMaterial>>,
|
||||
line: Line<2>) {
|
||||
|
||||
line: Line<T>) {
|
||||
let origin = line.origin().to_xyz();
|
||||
let direction = line.direction().to_xyz();
|
||||
let opposite_corner = Vec3::new(
|
||||
@@ -199,19 +197,17 @@ fn render_line(mut commands: &mut Commands,
|
||||
// RaycastPickTarget::default(), // <- Needed for the raycast backend.
|
||||
// PickableBundle::default() // <- This one too
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
fn add_debug_info_to_entity(mut commands: &mut Commands,
|
||||
fj_model: &FjMeshWrapper,
|
||||
mut meshes: &mut ResMut<Assets<Mesh>>,
|
||||
mut materials: &mut ResMut<Assets<StandardMaterial>>
|
||||
mut materials: &mut ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
|
||||
for region in fj_model.sketch.regions(){
|
||||
for cycle in region.all_cycles(){
|
||||
for half_edge in cycle.half_edges(){
|
||||
match half_edge.path(){
|
||||
for region in fj_model.sketch.regions() {
|
||||
for cycle in region.all_cycles() {
|
||||
for half_edge in cycle.half_edges() {
|
||||
match half_edge.path() {
|
||||
SurfacePath::Circle(x) => {}
|
||||
SurfacePath::Line(x) => {
|
||||
render_line(commands, fj_model, meshes, materials, x)
|
||||
@@ -225,7 +221,6 @@ fn add_debug_info_to_entity(mut commands: &mut Commands,
|
||||
}
|
||||
|
||||
|
||||
|
||||
for shell in fj_model.handle.shells() {
|
||||
println!("{:?}. shell", shell);
|
||||
for face in shell.faces() {
|
||||
@@ -238,6 +233,8 @@ fn add_debug_info_to_entity(mut commands: &mut Commands,
|
||||
x.aabb();
|
||||
}
|
||||
GlobalPath::Line(x) => {
|
||||
render_line(commands, fj_model, meshes, materials, x);
|
||||
|
||||
let origin = x.origin();
|
||||
let direction = x.direction();
|
||||
let opposite_corner = Vec3::new(
|
||||
@@ -249,16 +246,6 @@ fn add_debug_info_to_entity(mut commands: &mut Commands,
|
||||
let red: f32 = rng.gen_range(0.0..1.0);
|
||||
let green: f32 = rng.gen_range(0.0..1.0);
|
||||
let blue: f32 = rng.gen_range(0.0..1.0);
|
||||
commands.spawn(( // line on base of sweep
|
||||
PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(shape::Box::from_corners(opposite_corner.into(), origin.to_vec3()))),
|
||||
material: materials.add(Color::rgb(red, green, blue).into()),
|
||||
transform: Transform::from_xyz(0.0, 0.0, 0.0),
|
||||
..default()
|
||||
},
|
||||
// RaycastPickTarget::default(), // <- Needed for the raycast backend.
|
||||
// PickableBundle::default() // <- This one too
|
||||
));
|
||||
commands.spawn(( // line on top of sweep, just offset by the sweep vector
|
||||
PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(shape::Box::from_corners(opposite_corner.into(), origin.to_vec3()))),
|
||||
@@ -279,16 +266,6 @@ fn add_debug_info_to_entity(mut commands: &mut Commands,
|
||||
// RaycastPickTarget::default(), // <- Needed for the raycast backend.
|
||||
// PickableBundle::default() // <- This one too
|
||||
));
|
||||
commands.spawn(( // vertex
|
||||
PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.025 })),
|
||||
material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()),
|
||||
transform: Transform::from_xyz(origin.to_xyz().x.into_f32(), origin.to_xyz().y.into_f32(), origin.to_xyz().z.into_f32()),
|
||||
..default()
|
||||
},
|
||||
// RaycastPickTarget::default(), // <- Needed for the raycast backend.
|
||||
// PickableBundle::default() // <- This one too
|
||||
));
|
||||
commands.spawn(( // swept vertex
|
||||
PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.025 })),
|
||||
|
||||
Reference in New Issue
Block a user