diff options
Diffstat (limited to 'light-client/tools/src/bin/tex_pack.rs')
| -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();      }  } | 
