Merge branch 'main' of github.com:aziis98/asd-2024

main
Luca Lombardo 6 months ago
commit 6912e3c823

@ -1,9 +1,9 @@
use std::{collections::HashMap, env, ops::AddAssign, time::Instant}; use std::{collections::HashMap, env, ops::AddAssign, time::Instant};
use asd::{gfa::Entry, parser}; use asd::{gfa::Entry, parser};
use macroquad::{prelude::*, rand}; use macroquad::{prelude::*, rand, ui::root_ui};
use nalgebra::{Point2, SVector}; use nalgebra::{Point2, SVector};
use petgraph::{algo::dijkstra, stable_graph::StableGraph}; use petgraph::{algo::dijkstra, graph::NodeIndex, stable_graph::StableGraph};
use rayon::prelude::*; use rayon::prelude::*;
@ -24,6 +24,37 @@ async fn main() {
loop { loop {
// Update // Update
let start_update = Instant::now();
update(&mut graph, &desired_distance_matrix);
let update_elapsed = start_update.elapsed();
// Render
let start_render = Instant::now();
clear_background(WHITE);
draw_graph(&graph);
let render_elapsed = start_render.elapsed();
root_ui().label(
None,
format!("update: {:?}, render: {:?}", update_elapsed, render_elapsed).as_str(),
);
// println!("update: {:?}, render: {:?}", update_elapsed, render_elapsed);
next_frame().await
}
}
fn update(
graph: &mut StableGraph<(String, Point2<f32>), ()>,
desired_distance_matrix: &HashMap<NodeIndex, HashMap<NodeIndex, f32>>,
) {
for _ in 1..2 { for _ in 1..2 {
let forces = graph let forces = graph
.node_indices() .node_indices()
@ -89,21 +120,6 @@ async fn main() {
pos.add_assign(force); pos.add_assign(force);
}); });
} }
// Render
let now = Instant::now();
clear_background(WHITE);
draw_graph(&graph);
let elapsed = now.elapsed();
println!("frame: {:?}", elapsed);
next_frame().await
}
} }
fn load_graph() -> StableGraph<(String, Point2<f32>), ()> { fn load_graph() -> StableGraph<(String, Point2<f32>), ()> {

Loading…
Cancel
Save