Skip to content

Commit

Permalink
nested tuples into one tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzart committed Nov 1, 2023
1 parent a2e59ac commit 84e5165
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 40 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bff-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ egui = "0.23.0"
egui_extras = { version = "0.23.0", features = ["image"], default-features = false }
hound = "3.5.1"
image = { version = "0.24.7", features = ["dds", "png"], default-features = false }
itertools = "0.11.0"
rfd = "0.12.0"
rodio = { version = "0.17.1", features = ["wav"], default-features = false }
serde = "1.0.188"
Expand Down
31 changes: 5 additions & 26 deletions bff-gui/src/panels/left.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ impl Gui {
.width_range(70.0..=ui.available_width() / 2.0)
.show_inside(ui, |ui| {
if let Some(bigfile) = &self.bigfile {
// ui.style_mut().spacing.item_spacing.y = 5.0;

let version = &bigfile.manifest.version;
let platform = bigfile.manifest.platform;
let binding = match ui.memory(|mem| {
Expand Down Expand Up @@ -150,7 +148,7 @@ impl Gui {

let resources: Arc<Vec<Name>> = if new_state.resources.is_none() || changed_list
{
let mut res: Vec<(Name, (Name, usize))> = bigfile
let mut res: Vec<(Name, Name, usize)> = bigfile
.objects
.values()
.filter(|res| {
Expand All @@ -161,19 +159,18 @@ impl Gui {
.get(&res.class_name)
.unwrap_or(&true)
})
.map(|r| (r.name, (r.class_name, r.size())))
.map(|r| (r.name, r.class_name, r.size()))
.collect();
// resources.sort_by(compare)
match new_state.sort.sort_type {
SortType::Name => res.sort_by_cached_key(|k| k.0.to_string()),
SortType::Ext => res.sort_by_cached_key(|k| k.1 .0.to_string()),
SortType::Size => res.sort_by_cached_key(|k| k.1 .1),
SortType::Ext => res.sort_by_cached_key(|k| k.1.to_string()),
SortType::Size => res.sort_by_cached_key(|k| k.2),
}
if new_state.sort.reverse {
res.reverse();
}
let only_names: Arc<Vec<Name>> =
Arc::new(res.into_iter().map(|(name, _)| name).collect());
Arc::new(res.into_iter().map(|(name, _, _)| name).collect());
new_state.resources = Some(Arc::clone(&only_names));
Arc::clone(&only_names)
} else {
Expand Down Expand Up @@ -269,23 +266,6 @@ impl Gui {
for row in row_range {
let resource = resources.get(row).unwrap();
let nickname = self.nicknames.get(resource);
// let job = egui::text::LayoutJob {
// text: format!(
// "{}.{}",
// match nickname {
// Some(nn) => nn.to_owned(),
// None => resource.to_string(),
// },
// bigfile.objects.get(resource).unwrap().class_name
// ),
// wrap: egui::text::TextWrapping {
// max_rows: 1,
// max_width: ui.available_width(),
// ..Default::default()
// },
// break_on_newline: false,
// ..Default::default()
// };
let mut tooltip_text = format!(
"Size: {} bytes",
bigfile.objects.get(resource).unwrap().size()
Expand Down Expand Up @@ -359,7 +339,6 @@ impl Gui {
}
}
}
// self.resource_name = Some(resource.name);
}
}
},
Expand Down
27 changes: 13 additions & 14 deletions bff-gui/src/traits/mesh.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Arc;

use itertools::MultiUnzip;
use three_d::CpuModel;

use super::export::Export;
Expand All @@ -18,9 +19,11 @@ impl GenerateMesh for bff::class::mesh::v1_291_03_06_pc::MeshV1_291_03_06PC {
.iter()
.map(|group| {
// println!("{}", mesh.body.mesh_buffer.vertex_buffers.len());
let (positions, (uvs, (normals, tangents))): (
let (positions, uvs, normals, tangents): (
Vec<Vec3>,
(Vec<Vec2>, (Vec<Vec3>, Vec<Vec4>)),
Vec<Vec2>,
Vec<Vec3>,
Vec<Vec4>,
) = self
.body
.mesh_buffer
Expand Down Expand Up @@ -76,20 +79,16 @@ impl GenerateMesh for bff::class::mesh::v1_291_03_06_pc::MeshV1_291_03_06PC {
.map(|(p, u, n, t)| {
(
Vec3::from(*p),
(
Vec2::from(*u),
(
{
let mut norm = n.map(|i| (i as f32 - 128.0) / 128.0);
norm[2] *= -1.0;
Vec3::from(norm)
},
Vec4::from(t.map(|i| (i as f32 - 128.0) / 128.0)),
),
),
Vec2::from(*u),
{
let mut norm = n.map(|i| (i as f32 - 128.0) / 128.0);
norm[2] *= -1.0;
Vec3::from(norm)
},
Vec4::from(t.map(|i| (i as f32 - 128.0) / 128.0)),
)
})
.unzip();
.multiunzip();
let indices: Vec<u16> = self
.body
.mesh_buffer
Expand Down

0 comments on commit 84e5165

Please sign in to comment.