diff --git a/.circleci/config.yml b/.circleci/config.yml index c60d750..ee92a84 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -108,11 +108,11 @@ workflows: - linux_x86_64: filters: branches: - only: [ "-master", "test", "test-full", "test-linux-x64" ] + only: [ "master", "test", "test-full", "test-linux-x64" ] - linux_aarch64: filters: branches: - only: [ "-master", "test", "test-full", "test-linux-arm64" ] + only: [ "master", "test", "test-full", "test-linux-arm64" ] # - windows_x86_64: # filters: # branches: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28d3d50..05a8d1b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,9 @@ name: Main on: push: - branches: [ "-master" ] + branches: [ "master" ] pull_request: - branches: [ "-master" ] + branches: [ "master" ] env: CARGO_TERM_COLOR: always diff --git a/tests/additive.rs b/tests/additive.rs index 8b51b09..ee5dba1 100644 --- a/tests/additive.rs +++ b/tests/additive.rs @@ -1,6 +1,7 @@ use glam::{Mat4, Vec4}; use ozz_animation_rs::math::*; use ozz_animation_rs::*; +use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen_test::*; @@ -60,12 +61,12 @@ where let mut sample_job_base: SamplingJob = SamplingJob::default(); sample_job_base.set_animation(animation_base.clone()); sample_job_base.set_context(SamplingContext::new(animation_base.num_tracks())); - let sample_out_base = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let sample_out_base = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); sample_job_base.set_output(sample_out_base.clone()); let mut blending_job = BlendingJob::default(); blending_job.set_skeleton(skeleton.clone()); - let blending_out = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let blending_out = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); blending_job.set_output(blending_out.clone()); let mut layer_base = BlendingLayer::new(sample_out_base.clone()); @@ -90,13 +91,13 @@ where let mut l2m_job: LocalToModelJob = LocalToModelJob::default(); l2m_job.set_skeleton(skeleton.clone()); l2m_job.set_input(blending_out.clone()); - let l2m_out = ozz_buf(vec![Mat4::default(); skeleton.num_joints()]); + let l2m_out = Rc::new(RefCell::new(vec![Mat4::default(); skeleton.num_joints()])); l2m_job.set_output(l2m_out.clone()); let mut sample_job_splay: SamplingJob = SamplingJob::default(); sample_job_splay.set_animation(animation_splay.clone()); sample_job_splay.set_context(SamplingContext::new(animation_splay.num_tracks())); - let sample_out_splay = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let sample_out_splay = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); sample_job_splay.set_output(sample_out_splay.clone()); sample_job_splay.set_ratio(0.0); // Only needs the first frame pose @@ -108,7 +109,7 @@ where let mut sample_job_curl: SamplingJob = SamplingJob::default(); sample_job_curl.set_animation(animation_curl.clone()); sample_job_curl.set_context(SamplingContext::new(animation_curl.num_tracks())); - let sample_out_curl = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let sample_out_curl = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); sample_job_curl.set_output(sample_out_curl.clone()); sample_job_curl.set_ratio(0.0); // Only needs the first frame pose @@ -118,9 +119,9 @@ where .push(BlendingLayer::new(sample_out_curl.clone())); tester1(&TestDataInit { - sample_out_splay: sample_out_splay.vec().unwrap().clone(), + sample_out_splay: sample_out_splay.buf().unwrap().to_vec(), sample_ctx_splay: sample_job_splay.context().unwrap().clone_without_animation_id(), - sample_out_curl: sample_out_curl.vec().unwrap().clone(), + sample_out_curl: sample_out_curl.buf().unwrap().to_vec(), sample_ctx_curl: sample_job_curl.context().unwrap().clone_without_animation_id(), }); @@ -142,10 +143,10 @@ where ratio, &TestData { ratio, - sample_out_base: sample_out_base.vec().unwrap().clone(), + sample_out_base: sample_out_base.buf().unwrap().to_vec(), sample_ctx_base: sample_job_base.context().unwrap().clone_without_animation_id(), - blending_out: blending_out.vec().unwrap().clone(), - l2m_out: l2m_out.vec().unwrap().clone(), + blending_out: blending_out.buf().unwrap().to_vec(), + l2m_out: l2m_out.buf().unwrap().to_vec(), }, ); } diff --git a/tests/blend.rs b/tests/blend.rs index d0aedcd..6769807 100644 --- a/tests/blend.rs +++ b/tests/blend.rs @@ -1,6 +1,7 @@ use glam::Mat4; use ozz_animation_rs::math::*; use ozz_animation_rs::*; +use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen_test::*; @@ -50,24 +51,24 @@ where let mut sample_job1: SamplingJob = SamplingJob::default(); sample_job1.set_animation(animation1.clone()); sample_job1.set_context(SamplingContext::new(animation1.num_tracks())); - let sample_out1 = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let sample_out1 = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); sample_job1.set_output(sample_out1.clone()); let mut sample_job2: SamplingJob = SamplingJob::default(); sample_job2.set_animation(animation2.clone()); sample_job2.set_context(SamplingContext::new(animation2.num_tracks())); - let sample_out2 = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let sample_out2 = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); sample_job2.set_output(sample_out2.clone()); let mut sample_job3: SamplingJob = SamplingJob::default(); sample_job3.set_animation(animation3.clone()); sample_job3.set_context(SamplingContext::new(animation3.num_tracks())); - let sample_out3 = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let sample_out3 = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); sample_job3.set_output(sample_out3.clone()); let mut blending_job = BlendingJob::default(); blending_job.set_skeleton(skeleton.clone()); - let blending_out = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let blending_out = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); blending_job.set_output(blending_out.clone()); blending_job.layers_mut().push(BlendingLayer::new(sample_out1.clone())); blending_job.layers_mut().push(BlendingLayer::new(sample_out2.clone())); @@ -76,7 +77,7 @@ where let mut l2m_job: LocalToModelJob = LocalToModelJob::default(); l2m_job.set_skeleton(skeleton.clone()); l2m_job.set_input(blending_out.clone()); - let l2m_out = ozz_buf(vec![Mat4::default(); skeleton.num_joints()]); + let l2m_out = Rc::new(RefCell::new(vec![Mat4::default(); skeleton.num_joints()])); l2m_job.set_output(l2m_out.clone()); for i in range { @@ -105,14 +106,14 @@ where ratio, &TestData { ratio, - sample_out1: sample_out1.vec().unwrap().clone(), + sample_out1: sample_out1.buf().unwrap().to_vec(), sample_ctx1: sample_job1.context().unwrap().clone_without_animation_id(), - sample_out2: sample_out2.vec().unwrap().clone(), + sample_out2: sample_out2.buf().unwrap().to_vec(), sample_ctx2: sample_job2.context().unwrap().clone_without_animation_id(), - sample_out3: sample_out3.vec().unwrap().clone(), + sample_out3: sample_out3.buf().unwrap().to_vec(), sample_ctx3: sample_job3.context().unwrap().clone_without_animation_id(), - blending_out: blending_out.vec().unwrap().clone(), - l2m_out: l2m_out.vec().unwrap().clone(), + blending_out: blending_out.buf().unwrap().to_vec(), + l2m_out: l2m_out.buf().unwrap().to_vec(), }, ); } diff --git a/tests/look_at.rs b/tests/look_at.rs index a79b35c..91cbcce 100644 --- a/tests/look_at.rs +++ b/tests/look_at.rs @@ -1,6 +1,7 @@ use glam::{Mat4, Quat, Vec3A}; use ozz_animation_rs::math::*; use ozz_animation_rs::*; +use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen_test::*; @@ -58,10 +59,10 @@ where panic!("Invalid joints chain"); } - let locals1 = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); - let locals2 = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); - let models1 = ozz_buf(vec![Mat4::default(); skeleton.num_joints()]); - let models2 = ozz_buf(vec![Mat4::default(); skeleton.num_joints()]); + let locals1 = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); + let locals2 = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); + let models1 = Rc::new(RefCell::new(vec![Mat4::default(); skeleton.num_joints()])); + let models2 = Rc::new(RefCell::new(vec![Mat4::default(); skeleton.num_joints()])); let mut sample_job: SamplingJob = SamplingJob::default(); sample_job.set_animation(animation.clone()); @@ -102,7 +103,7 @@ where let mut previous_joint = SKELETON_NO_PARENT; for (idx, joint) in joints_chain.iter().enumerate() { - ik_job.set_joint(models1.vec().unwrap()[*joint as usize].into()); + ik_job.set_joint(models1.buf().unwrap()[*joint as usize].into()); ik_job.set_up(Vec3A::X); if idx == joints_chain.len() - 1 { @@ -115,13 +116,13 @@ where ik_job.set_offset(EYES_OFFSET); ik_job.set_forward(Vec3A::Y); } else { - let transform: Mat4 = models1.vec().unwrap()[previous_joint as usize].into(); + let transform: Mat4 = models1.buf().unwrap()[previous_joint as usize].into(); let corrected_forward_ms = transform.transform_vector3a(ik_job.joint_correction().mul_vec3a(ik_job.forward())); let corrected_offset_ms = transform.transform_point3a(ik_job.joint_correction().mul_vec3a(ik_job.offset())); - let transform: Mat4 = models1.vec().unwrap()[*joint as usize].into(); + let transform: Mat4 = models1.buf().unwrap()[*joint as usize].into(); let inv_transform = transform.inverse(); ik_job.set_offset(inv_transform.transform_point3a(corrected_offset_ms)); ik_job.set_forward(inv_transform.transform_vector3a(corrected_forward_ms)); @@ -132,7 +133,7 @@ where reacheds[idx] = ik_job.reached(); { - let mut locals_mut = locals2.vec_mut().unwrap(); + let mut locals_mut = locals2.borrow_mut(); let idx = *joint as usize; let quat = locals_mut[idx / 4].rotation.col(idx & 3) * ik_job.joint_correction(); locals_mut[idx / 4].rotation.set_col(idx & 3, quat); @@ -147,10 +148,10 @@ where tester( idx, &TestData { - locals1: locals1.vec().unwrap().clone(), - locals2: locals2.vec().unwrap().clone(), - models1: models1.vec().unwrap().clone(), - models2: models2.vec().unwrap().clone(), + locals1: locals1.buf().unwrap().to_vec(), + locals2: locals2.buf().unwrap().to_vec(), + models1: models1.buf().unwrap().to_vec(), + models2: models2.buf().unwrap().to_vec(), joint_corrections, reacheds, }, diff --git a/tests/partial_blend.rs b/tests/partial_blend.rs index 27db15a..792e14e 100644 --- a/tests/partial_blend.rs +++ b/tests/partial_blend.rs @@ -1,6 +1,7 @@ use glam::{Mat4, Vec4}; use ozz_animation_rs::math::*; use ozz_animation_rs::*; +use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen_test::*; @@ -47,18 +48,18 @@ where let mut sample_job_lower: SamplingJob = SamplingJob::default(); sample_job_lower.set_animation(animation_lower.clone()); sample_job_lower.set_context(SamplingContext::new(animation_lower.num_tracks())); - let sample_out_lower = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let sample_out_lower = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); sample_job_lower.set_output(sample_out_lower.clone()); let mut sample_job_upper: SamplingJob = SamplingJob::default(); sample_job_upper.set_animation(animation_upper.clone()); sample_job_upper.set_context(SamplingContext::new(animation_upper.num_tracks())); - let sample_out_upper = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let sample_out_upper = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); sample_job_upper.set_output(sample_out_upper.clone()); let mut blending_job = BlendingJob::default(); blending_job.set_skeleton(skeleton.clone()); - let blending_out = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let blending_out = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); blending_job.set_output(blending_out.clone()); let mut layer_lower = BlendingLayer::new(sample_out_lower.clone()); @@ -82,7 +83,7 @@ where let mut l2m_job: LocalToModelJob = LocalToModelJob::default(); l2m_job.set_skeleton(skeleton.clone()); l2m_job.set_input(blending_out.clone()); - let l2m_out = ozz_buf(vec![Mat4::default(); skeleton.num_joints()]); + let l2m_out = Rc::new(RefCell::new(vec![Mat4::default(); skeleton.num_joints()])); l2m_job.set_output(l2m_out.clone()); for i in range { @@ -102,12 +103,12 @@ where ratio, &TestData { ratio, - sample_out_lower: sample_out_lower.vec().unwrap().clone(), + sample_out_lower: sample_out_lower.buf().unwrap().to_vec(), sample_ctx_lower: sample_job_lower.context().unwrap().clone_without_animation_id(), - sample_out_upper: sample_out_upper.vec().unwrap().clone(), + sample_out_upper: sample_out_upper.buf().unwrap().to_vec(), sample_ctx_upper: sample_job_upper.context().unwrap().clone_without_animation_id(), - blending_out: blending_out.vec().unwrap().clone(), - l2m_out: l2m_out.vec().unwrap().clone(), + blending_out: blending_out.buf().unwrap().to_vec(), + l2m_out: l2m_out.buf().unwrap().to_vec(), }, ); } diff --git a/tests/playback.rs b/tests/playback.rs index 8885bfd..08efd2e 100644 --- a/tests/playback.rs +++ b/tests/playback.rs @@ -1,6 +1,7 @@ use glam::Mat4; use ozz_animation_rs::math::*; use ozz_animation_rs::*; +use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen_test::*; @@ -47,13 +48,13 @@ where let mut sample_job: SamplingJob = SamplingJob::default(); sample_job.set_animation(animation.clone()); sample_job.set_context(SamplingContext::new(animation.num_tracks())); - let sample_out = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); + let sample_out = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); sample_job.set_output(sample_out.clone()); let mut l2m_job: LocalToModelJob = LocalToModelJob::default(); l2m_job.set_skeleton(skeleton.clone()); l2m_job.set_input(sample_out.clone()); - let l2m_out = ozz_buf(vec![Mat4::default(); skeleton.num_joints()]); + let l2m_out = Rc::new(RefCell::new(vec![Mat4::default(); skeleton.num_joints()])); l2m_job.set_output(l2m_out.clone()); for i in range { @@ -66,9 +67,9 @@ where ratio, &TestData { ratio, - sample_out: sample_out.vec().unwrap().clone(), + sample_out: sample_out.buf().unwrap().to_vec(), sample_ctx: sample_job.context().unwrap().clone_without_animation_id(), - l2m_out: l2m_out.vec().unwrap().clone(), + l2m_out: l2m_out.buf().unwrap().to_vec(), }, ); } diff --git a/tests/two_bone_ik.rs b/tests/two_bone_ik.rs index f1f7873..9ebb265 100644 --- a/tests/two_bone_ik.rs +++ b/tests/two_bone_ik.rs @@ -1,6 +1,7 @@ use glam::{Mat4, Quat, Vec3A}; use ozz_animation_rs::math::*; use ozz_animation_rs::*; +use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen_test::*; @@ -48,9 +49,9 @@ where let mid_joint = skeleton.joint_by_name("forearm").unwrap(); let end_joint = skeleton.joint_by_name("wrist").unwrap(); - let locals = ozz_buf(vec![SoaTransform::default(); skeleton.num_soa_joints()]); - let models1 = ozz_buf(vec![Mat4::default(); skeleton.num_joints()]); - let models2 = ozz_buf(vec![Mat4::default(); skeleton.num_joints()]); + let locals = Rc::new(RefCell::new(vec![SoaTransform::default(); skeleton.num_soa_joints()])); + let models1 = Rc::new(RefCell::new(vec![Mat4::default(); skeleton.num_joints()])); + let models2 = Rc::new(RefCell::new(vec![Mat4::default(); skeleton.num_joints()])); let mut l2m_job1: LocalToModelJob = LocalToModelJob::default(); l2m_job1.set_skeleton(skeleton.clone()); @@ -96,7 +97,7 @@ where models2.borrow_mut().clone_from_slice(models1.borrow().as_slice()); { - let mut locals_mut = locals.vec_mut().unwrap(); + let mut locals_mut = locals.borrow_mut(); let idx = start_joint as usize; let quat = locals_mut[idx / 4].rotation.col(idx & 3) * ik_job.start_joint_correction(); @@ -116,9 +117,9 @@ where tester( idx, &TestData { - locals: locals.vec().unwrap().clone(), - models1: models1.vec().unwrap().clone(), - models2: models2.vec().unwrap().clone(), + locals: locals.buf().unwrap().to_vec(), + models1: models1.buf().unwrap().to_vec(), + models2: models2.buf().unwrap().to_vec(), start_correction: ik_job.start_joint_correction(), mid_correction: ik_job.mid_joint_correction(), reached: ik_job.reached(),