Skip to content

Commit

Permalink
Update stupid gltf crates
Browse files Browse the repository at this point in the history
  • Loading branch information
PikminGuts92 committed Feb 19, 2024
1 parent c352090 commit 40dd809
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ edition = "2021"

[workspace.dependencies]
clap = { version = "4.5.1", features = ["derive"] }
gltf = { version = "=1.3.0", default-features = false, features = [ "import", "names", "utils" ] }
gltf-json = { version = "=1.3.0", features = [ "names" ] }
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.1"
lazy_static = "1.4.0"
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
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

0 comments on commit 40dd809

Please sign in to comment.