master
mitchellhansen 10 months ago
parent 6dc8e2a47f
commit 78222ad55a

@ -52,7 +52,7 @@ impl ToVec3 for fj_math::Vector<3> {
#[derive(Component)]
struct FjSolidWrapper{
struct FjSolidWrapper {
handle: fj_core::storage::Handle<Solid>,
}
@ -148,26 +148,24 @@ fn update_fj_model_system(
for (entity, solid) in &query {
let bevy_mesh = convert_mesh(&solid.mesh);
commands.entity(entity).insert(
(
PbrBundle {
mesh: meshes.add(Mesh::from(bevy_mesh.clone())),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_xyz(0.0, 0.0, 0.0),
..default()
},
FjConvertedFlag
));
(
PbrBundle {
mesh: meshes.add(Mesh::from(bevy_mesh.clone())),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_xyz(0.0, 0.0, 0.0),
..default()
},
FjConvertedFlag
));
add_debug_info_to_entity(&mut commands, solid, &mut meshes, &mut materials);
}
}
fn render_line(mut commands: &mut Commands,
fj_model: &FjMeshWrapper,
mut meshes: &mut ResMut<Assets<Mesh>>,
mut materials: &mut ResMut<Assets<StandardMaterial>>,
line: Line<2>) {
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<T>) {
let origin = line.origin().to_xyz();
let direction = line.direction().to_xyz();
let opposite_corner = Vec3::new(
@ -199,23 +197,21 @@ 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(){
SurfacePath::Circle(x) => {}
SurfacePath::Line(x) => {
render_line(commands, fj_model, meshes, materials, x)
}
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)
}
}
// 1d point
half_edge.boundary().inner[0].coords;
@ -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 })),
@ -307,7 +284,7 @@ fn add_debug_info_to_entity(mut commands: &mut Commands,
// I want to insert a component when dragging starts, that contains
// data about the exact ray hit location.
// On::<Pointer<DragStart>>::run(run),
// On::<Pointer<DragStart>>::target_insert(DragCaster::default()),
// On::<Pointer<DragStart>>::target_insert(DragCaster::default()),
// On::<Pointer<Drag>>::target_component_mut::<DragCaster>(|drag, mut caster| {
// caster.hit_location = drag.hit.position.unwrap();
//

Loading…
Cancel
Save