Skip to content

Commit 724c02a

Browse files
committed
detect large global coordinate jumps early in run as additional filter on bad runs
1 parent 0649ed7 commit 724c02a

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

large-scale-viz/high_perf_character_render/src/bin/extract_compact_runs.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::{Context, Result};
22
use clap::Parser;
3-
use sprite_video_renderer::data::{ParquetFilter, ParquetReader};
3+
use sprite_video_renderer::data::{ParquetFilter, CoordinateMapper, ParquetReader};
44
use std::fs::{File, OpenOptions};
55
use std::io::{BufRead, BufReader, BufWriter, Write};
66
use std::path::PathBuf;
@@ -96,6 +96,8 @@ fn main() -> Result<()> {
9696
log::info!("Loaded progress: {} files already processed", processed_files.len());
9797
}
9898

99+
let coordinate_mapper = CoordinateMapper::load("../../assets/map_data.json").unwrap();
100+
99101
// Open output file in append mode
100102
let mut output_file = BufWriter::new(
101103
OpenOptions::new()
@@ -113,7 +115,7 @@ fn main() -> Result<()> {
113115
);
114116

115117
let mut total_runs_extracted = 0;
116-
let starting_maps = vec![0i64, 37, 40, 39, 38];
118+
let starting_maps = vec![0i64, 37, 40, 38];
117119
let starting_and_adjacent_maps = vec![0i64, 37, 40, 39, 38, 12, 32];
118120
let gap_threshold = Duration::minutes(2);
119121
let min_duration = Duration::seconds(args.min_duration_secs);
@@ -179,13 +181,26 @@ fn main() -> Result<()> {
179181
let curr_map = frames[j].coords[2];
180182
let prev_map = frames[j-1].coords[2];
181183

182-
let should_split = time_gap >= gap_threshold
184+
//////////////////////////
185+
let current_coord = frames[j].coords.map(|x| x as i64);
186+
let previous_coord = frames[j-1].coords.map(|x| x as i64);
187+
188+
// Convert to pixel positions
189+
let current_global_pos = coordinate_mapper.convert_coords(&current_coord);
190+
let previous_global_pos = coordinate_mapper.convert_coords(&previous_coord);
191+
let dx = current_global_pos[0] - previous_global_pos[0];
192+
let dy = current_global_pos[1] - previous_global_pos[1];
193+
let global_step_delta = (dx*dx + dy*dy).sqrt();
194+
let early_big_jump_fail = args.pallet_start_only && (j as i64 - run_start as i64) < 140 && global_step_delta > 30.0;
195+
///////////////
196+
197+
let should_split = time_gap >= gap_threshold || early_big_jump_fail
183198
|| (starting_maps.contains(&curr_map) && !starting_and_adjacent_maps.contains(&prev_map));
184199

185200
if should_split {
186201
let duration = frames[j-1].timestamp - frames[run_start].timestamp;
187202
let pallet_start_ok = if args.pallet_start_only { starting_maps.contains(&frames[run_start].coords[2]) } else { true };
188-
if duration >= min_duration && pallet_start_ok {
203+
if duration >= min_duration && pallet_start_ok && !early_big_jump_fail {
189204
// Write this run
190205
write_compact_run(
191206
&mut output_file,
@@ -205,6 +220,7 @@ fn main() -> Result<()> {
205220
if run_start < user_env_end {
206221
let duration = frames[user_env_end - 1].timestamp - frames[run_start].timestamp;
207222
let pallet_start_ok = if args.pallet_start_only { starting_maps.contains(&frames[run_start].coords[2]) } else { true };
223+
208224
if duration >= min_duration && pallet_start_ok {
209225
write_compact_run(
210226
&mut output_file,

0 commit comments

Comments
 (0)