Browse Source

changes for 1.51.0

master
Alison Watson 1 year ago
parent
commit
8ccad24f22
  1. 10
      source/framework/data/model.rs
  2. 10
      source/framework/data/read.rs
  3. 2
      source/framework/data/vertex.rs

10
source/framework/data/model.rs

@ -381,10 +381,9 @@ impl Model {
rd.seek(SeekFrom::Start(ofs_join))?;
for join in read::hunk(rd, num_join * 4 * 12)?.chunks(4 * 12) {
let mut trs = [0.0; 10];
let nam = read::u32le_sz(join, 0);
let par = read::u32le_sz(join, 4);
read::array(read::f32le_32, join, &mut trs, 4, 8);
let trs = read::array(read::f32le_32, join, [0.0; 10], 4, 8);
let nam = SmolStr::new(from_stab(&stab, nam)?);
@ -421,11 +420,8 @@ impl Model {
for pose in read::hunk(rd, num_pose * 4 * 22)?.chunks(4 * 22) {
let par = read::u32le_sz(pose, 0);
let msk = read::u32le_32(pose, 4);
let mut ofs = [0.0; 10];
let mut scl = [0.0; 10];
read::array(read::f32le_32, pose, &mut ofs, 4, 8);
read::array(read::f32le_32, pose, &mut scl, 4, 48);
let ofs = read::array(read::f32le_32, pose, [0.0; 10], 4, 8);
let scl = read::array(read::f32le_32, pose, [0.0; 10], 4, 48);
poses.push(Pose { par, msk, ofs, scl });
}

10
source/framework/data/read.rs

@ -45,12 +45,12 @@ pub fn f64le_64(b: &[u8], p: usize) -> f64 {
])
}
pub fn array<'a, 'b, T>(
f: impl Fn(&[u8], usize) -> T, b: &'a [u8], v: &'b mut [T], step: usize,
pub fn array<T, const N: usize>(
f: impl Fn(&[u8], usize) -> T, b: &[u8], mut v: [T; N], step: usize,
beg: usize,
) -> &'b [T] {
for (i, p) in (beg..beg + v.len() * step).step_by(step).enumerate() {
v[i] = f(b, p);
) -> [T; N] {
for (p, v) in (beg..beg + N * step).step_by(step).zip(v.iter_mut()) {
*v = f(b, p);
}
v

2
source/framework/data/vertex.rs

@ -1,6 +1,6 @@
use crate::math::{Vec3, Vec4};
#[repr(C, packed)]
#[repr(packed)]
pub struct Vertex {
pub pos: Vec3,
pub tex: Vec3,

Loading…
Cancel
Save