diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-15 15:30:51 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-15 15:30:51 +0200 |
commit | e04589e8b766882375a30c00fb715687a7cc9821 (patch) | |
tree | ad7a05fbe76b3271a0a674795e66b88e6c6c2cbb /light-client/tools/src | |
parent | 23c43903e65bcd03f5fa97874fa3cee74afda33a (diff) | |
download | hurrycurry-e04589e8b766882375a30c00fb715687a7cc9821.tar hurrycurry-e04589e8b766882375a30c00fb715687a7cc9821.tar.bz2 hurrycurry-e04589e8b766882375a30c00fb715687a7cc9821.tar.zst |
atlas packing
Diffstat (limited to 'light-client/tools/src')
-rw-r--r-- | light-client/tools/src/bin/tex_pack.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/light-client/tools/src/bin/tex_pack.rs b/light-client/tools/src/bin/tex_pack.rs index 23056608..7ac3346c 100644 --- a/light-client/tools/src/bin/tex_pack.rs +++ b/light-client/tools/src/bin/tex_pack.rs @@ -31,8 +31,11 @@ fn main() { for path in inputs { let file = BufReader::new(File::open(&path).unwrap()); let tex = file.lines().map(Result::unwrap).collect::<Vec<String>>(); + let name = path.file_stem().unwrap().to_str().unwrap().to_string(); let (width, height) = (tex[0].len(), tex.len()); + println!("adding {width}x{height} {name}"); + if cursor_x + width > atlas_size { cursor_y += row_height; row_height = 0; @@ -42,7 +45,7 @@ fn main() { panic!("texture too big or atlas full") } row_height = row_height.max(atlas_size); - let texcoord = [cursor_x, cursor_y]; + let texcoord = [cursor_x, cursor_y, width, height]; for (y, line) in tex.iter().enumerate() { if line.is_empty() { @@ -53,12 +56,9 @@ fn main() { } } - metadata.push(( - texcoord, - path.file_stem().unwrap().to_str().unwrap().to_string(), - )); + metadata.push((texcoord, name)); - cursor_x += atlas_size; + cursor_x += width; } let mut atlas_out = BufWriter::new(File::create(atlas_out).unwrap()); @@ -71,7 +71,7 @@ fn main() { writeln!(atlas_out).unwrap(); } - for ([x, y], name) in metadata { - writeln!(atlas_meta_out, "{x},{y},{name}").unwrap(); + for ([x, y, w, h], name) in metadata { + writeln!(atlas_meta_out, "{x},{y},{w},{h},{name}").unwrap(); } } |