Skip to content

Commit

Permalink
Merge branch 'dev' into subdir_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
PikminGuts92 committed Mar 5, 2024
2 parents e24e8e6 + 2263335 commit c841426
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 55 deletions.
17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ authors = ["PikminGuts92"]
edition = "2021"

[workspace.dependencies]
clap = { version = "4.4.18", features = ["derive"] }
gltf = { version = "=1.3.0", default-features = false, features = [ "import", "names", "utils" ] }
gltf-json = { version = "=1.3.0", features = [ "names" ] }
clap = { version = "4.5.1", features = ["derive"] }
gltf = { version = "=1.4.0", default-features = false, features = [ "import", "names", "utils" ] }
gltf-json = { version = "=1.4.0", features = [ "names" ] }
grim = { path = "core/grim" }
itertools = "0.12.0"
itertools = "0.12.1"
lazy_static = "1.4.0"
log = "0.4.20"
serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.111"
simplelog = "0.12.1"
thiserror = "1.0.56"
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
# simplelog = "0.12.1"
simplelog = { git = "https://github.com/Drakulix/simplelog.rs", rev = "4ef071d" }
thiserror = "1.0.57"

[workspace.lints.rust]
dead_code = "allow"
Expand Down
21 changes: 10 additions & 11 deletions apps/cli/p9_scene_tool/src/apps/project2milo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,23 @@ impl SubApp for Project2MiloApp {

// Create milos files...

// Write everything?
let sys_info = SystemInfo {
version: 25,
platform: Platform::PS3,
endian: IOEndian::Big,
};

let output_dir = PathBuf::from(&self.output_path);
if !output_dir.exists() {
// Create outout path if it doesn't exist
create_dir_all(&output_dir).expect("Failed to create output directory");
}

// Get platform ext
let platform_ext = match self.platform.to_ascii_lowercase().as_str() {
"ps3" => "ps3",
"wii" => "wii",
_ => "xbox"
let (platform, platform_ext) = match self.platform.to_ascii_lowercase().as_str() {
"ps3" => (Platform::PS3, "ps3"),
"wii" => (Platform::Wii, "wii"),
_ => (Platform::X360, "xbox")
};

let sys_info = SystemInfo {
version: 25,
platform: platform,
endian: IOEndian::Big,
};

// Name, object dir init
Expand Down
1 change: 1 addition & 0 deletions apps/cli/scene_tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition.workspace = true
[dependencies]
clap = { workspace = true }
grim = { workspace = true, features = [ "midi" ] }
simplelog = { workspace = true }
thiserror = { workspace = true }

[lints]
Expand Down
4 changes: 2 additions & 2 deletions apps/cli/scene_tool/src/apps/dir2milo.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::apps::{SubApp};
use crate::apps::SubApp;
use clap::Parser;

use std::error::Error;

use std::path::{Path};
use std::path::Path;


use grim::{Platform, SystemInfo};
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/scene_tool/src/apps/milo2dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use thiserror::Error;
use grim::{Platform, SystemInfo};
use grim::io::*;
use grim::scene::{Object, ObjectDir, MiloEnvironment, PackedObject, Tex};
use grim::texture::{write_rgba_to_file};
use grim::texture::write_rgba_to_file;

// TODO: Use this error somewhere or refactor
#[derive(Debug, Error)]
Expand Down
19 changes: 19 additions & 0 deletions apps/cli/scene_tool/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
mod apps;
use apps::SceneTool;
use simplelog::*;

#[cfg(debug_assertions)]
const LOG_LEVEL: LevelFilter = LevelFilter::Debug;

#[cfg(not(debug_assertions))]
const LOG_LEVEL: LevelFilter = LevelFilter::Info;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let log_config = ConfigBuilder::new()
.add_filter_allow_str("grim")
.add_filter_allow_str("scene_tool")
.build();

// Setup logging
CombinedLogger::init(
vec![
TermLogger::new(LOG_LEVEL, log_config, TerminalMode::Mixed, ColorChoice::Auto),
]
)?;

let mut scene = SceneTool::new();
scene.run()
}
6 changes: 3 additions & 3 deletions core/grim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ nalgebra = { version = "0.32.3", optional = true }
nom = "7.1.3"
# pyo3 = { version = "0.17.3", optional = true, features = [ "extension-module" ] }
pyo3 = { git = "https://github.com/PyO3/pyo3", branch = "cfg-feature-pyo3", optional = true, features = [ "experimental-inspect", "extension-module" ] }
rayon = "1.8.0"
regex = { version = "1.10.2", default-features = false, features = [ "std" ] }
rayon = "1.8.1"
regex = { version = "1.10.3", default-features = false, features = [ "std" ] }
serde = { optional = true, workspace = true }
thiserror = { workspace = true }
wav = { version = "1.0.0", optional = true }
Expand All @@ -50,4 +50,4 @@ bench = false
crate-type = [ "lib", "cdylib" ]

[lints]
workspace = true
workspace = true
10 changes: 8 additions & 2 deletions core/grim/src/io/archive.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{SystemInfo};
use crate::SystemInfo;
use crate::io::compression::*;
use crate::io::stream::{BinaryStream, IOEndian, MemoryStream, SeekFrom, Stream};
use crate::scene::{Object, ObjectDir, PackedObject, MiloObject};
Expand Down Expand Up @@ -156,6 +156,8 @@ impl MiloArchive {

pub fn unpack_directory(&self, info: &SystemInfo) -> Result<MiloObject, Box<dyn Error>> {
let mut stream = self.get_stream();
let stream_size = stream.len().unwrap() as u64;

let stream = stream.as_mut();
let mut reader = BinaryStream::from_stream_with_endian(stream, info.endian);

Expand Down Expand Up @@ -259,10 +261,14 @@ impl MiloArchive {
}
}

if stream.pos() < stream_size {
log::warn!("Read less data than length of milo file. Likely not parsed correctly.");
}

todo!();

// TODO: (Refactor)
/*Ok(ObjectDir::ObjectDir(ObjectDirInstance {
/* Ok(ObjectDir::ObjectDir(ObjectDirInstance {
entries: packed_entries
.into_iter()
.map(Object::Packed)
Expand Down
24 changes: 12 additions & 12 deletions core/grim/src/model/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ impl GltfExporter {

json::Buffer {
name: None,
byte_length: total_size as u32,
byte_length: total_size.into(),
uri: Some(str_data),
extensions: None,
extras: Default::default()
Expand All @@ -1075,38 +1075,38 @@ impl GltfExporter {
gltf.buffer_views = vec![
json::buffer::View {
name: Some(String::from("verts_norms")),
byte_length: bv_verts_norms as u32,
byte_offset: Some(0),
byte_stride: Some(12),
byte_length: bv_verts_norms.into(),
byte_offset: Some(0u64.into()),
byte_stride: Some(json::buffer::Stride(12)),
buffer: json::Index::new(0),
target: None,
extensions: None,
extras: Default::default()
},
json::buffer::View {
name: Some(String::from("uvs")),
byte_length: bv_uvs as u32,
byte_offset: Some(bv_verts_norms as u32),
byte_stride: Some(8),
byte_length: bv_uvs.into(),
byte_offset: Some(bv_verts_norms.into()),
byte_stride: Some(json::buffer::Stride(8)),
buffer: json::Index::new(0),
target: None,
extensions: None,
extras: Default::default()
},
json::buffer::View {
name: Some(String::from("weights_tans")),
byte_length: bv_weights_tans as u32,
byte_offset: Some((bv_verts_norms + bv_uvs) as u32),
byte_stride: Some(16),
byte_length: bv_weights_tans.into(),
byte_offset: Some((bv_verts_norms + bv_uvs).into()),
byte_stride: Some(json::buffer::Stride(16)),
buffer: json::Index::new(0),
target: None,
extensions: None,
extras: Default::default()
},
json::buffer::View {
name: Some(String::from("faces")),
byte_length: bv_faces as u32,
byte_offset: Some((bv_verts_norms + bv_uvs + bv_weights_tans) as u32),
byte_length: bv_faces.into(),
byte_offset: Some((bv_verts_norms + bv_uvs + bv_weights_tans).into()),
byte_stride: None,
buffer: json::Index::new(0),
target: None,
Expand Down
3 changes: 2 additions & 1 deletion core/grim/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ impl SystemInfo {
let mut endian = IOEndian::Big;
let mut version = 25;

if platform == Platform::X360 {
// Devkit wii is little endian for some reason
if platform == Platform::X360 || platform == Platform::Wii {
if let Some((end, ver)) = milo.guess_endian_version() {
endian = end;
version = ver;
Expand Down
1 change: 1 addition & 0 deletions core/grim/src/texture/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ impl Bitmap {
let tpl_enc = match self.encoding {
72 => TPLEncoding::CMP,
328 => TPLEncoding::CMP_ALPHA,
584 => TPLEncoding::CMP, // I think it's the same as 72?
_ => {
return Err(Box::new(BitmapError::UnsupportedEncoding {
version: self.encoding,
Expand Down
14 changes: 7 additions & 7 deletions core/grim_gltf/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use gltf_json as json;
use itertools::*;
use serde::ser::Serialize;
use std::collections::{HashMap};
use std::collections::HashMap;

pub struct AccessorBuilder {
// Key = stride, Value = (idx, data)
Expand Down Expand Up @@ -93,8 +93,8 @@ impl AccessorBuilder {
// Create accessor
let accessor = json::Accessor {
buffer_view: Some(json::Index::new(buff_idx as u32)),
byte_offset: Some(buff_off as u32),
count: count as u32,
byte_offset: Some(buff_off.into()),
count: count.into(),
component_type: json::validation::Checked::Valid(json::accessor::GenericComponentType(comp_type)),
extensions: None,
extras: Default::default(),
Expand Down Expand Up @@ -139,11 +139,11 @@ impl AccessorBuilder {

views.push(json::buffer::View {
name: None,
byte_length: data_size as u32,
byte_offset: Some(data_offset as u32),
byte_length: data_size.into(),
byte_offset: Some(data_offset.into()),
byte_stride: match stride {
64 => None, // Hacky way to disable writing stride for inverse bind transforms
s if s % 4 == 0 => Some(stride as u32),
s if s % 4 == 0 => Some(json::buffer::Stride(stride)),
_ => None // Don't encode if not multiple
},
buffer: json::Index::new(0),
Expand All @@ -163,7 +163,7 @@ impl AccessorBuilder {
// Create buffer json
let buffer = json::Buffer {
name: None,
byte_length: buffer_data.len() as u32,
byte_length: buffer_data.len().into(),
uri: match name.into() {
s if !s.is_empty() => Some(s),
_ => None
Expand Down
6 changes: 3 additions & 3 deletions core/grim_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ proc-macro = true
[dependencies]
grim_traits = { path = "../grim_traits" }
lazy_static = { workspace = true }
proc-macro2 = "1.0.76"
proc-macro2 = "1.0.78"
quote = "1.0.35"
syn = { version = "2.0.48", default-features = false, features = [ "clone-impls", "derive", "parsing", "printing", "proc-macro" ] }
syn = { version = "2.0.49", default-features = false, features = [ "clone-impls", "derive", "parsing", "printing", "proc-macro" ] }

[lints]
workspace = true
workspace = true
4 changes: 2 additions & 2 deletions utils/anim_preview/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition.workspace = true
grim = { workspace = true }
keyframe = "1.1.1"
nalgebra = "0.32.3"
rerun = { version = "0.12.0", features = [ "native_viewer" ] }
rerun = { version = "0.13.0", features = [ "native_viewer" ] }
shared = { path = "../shared" }

[lints]
workspace = true
workspace = true
6 changes: 3 additions & 3 deletions utils/lipsync_preview/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ edition.workspace = true

[dependencies]
grim = { workspace = true, features = [ "audio" ] }
eframe = "0.25.0"
egui_plot = "0.25.0"
eframe = "0.26.2"
egui_plot = "0.26.2"
keyframe = "1.1.1"
nalgebra = "0.32.3"
#rerun = "0.2.0"
shared = { path = "../shared" }

[lints]
workspace = true
workspace = true

0 comments on commit c841426

Please sign in to comment.