From 29bd3b3acc0f0b6b165c1810f0632ddf86cd26de Mon Sep 17 00:00:00 2001 From: Nan Date: Mon, 6 May 2024 21:38:14 +0800 Subject: [PATCH] refactor mods --- README.md | 1 - demo/src/blend.rs | 1 - demo/src/playback.rs | 1 - demo/src/two_bone_ik.rs | 1 - src/lib.rs | 31 +++++++++++++++---------------- src/math.rs | 32 ++++++++++++++++---------------- tests/additive.rs | 2 +- tests/blend.rs | 1 - tests/look_at.rs | 2 +- tests/partial_blend.rs | 1 - tests/playback.rs | 1 - tests/two_bone_ik.rs | 2 +- 12 files changed, 34 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 9a855bb..6a0f7e1 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,6 @@ Here is a very sample example: ```rust use glam::Mat4; use ozz_animation_rs::*; -use ozz_animation_rs::math::*; use std::cell::RefCell; use std::rc::Rc; diff --git a/demo/src/blend.rs b/demo/src/blend.rs index b4dea46..093f726 100644 --- a/demo/src/blend.rs +++ b/demo/src/blend.rs @@ -1,6 +1,5 @@ use bevy::prelude::*; use bevy::tasks::futures_lite::future::try_zip; -use ozz_animation_rs::math::*; use ozz_animation_rs::*; use std::sync::{Arc, RwLock}; diff --git a/demo/src/playback.rs b/demo/src/playback.rs index c05b859..cbeedaa 100644 --- a/demo/src/playback.rs +++ b/demo/src/playback.rs @@ -1,6 +1,5 @@ use bevy::prelude::*; use bevy::tasks::futures_lite::future::try_zip; -use ozz_animation_rs::math::*; use ozz_animation_rs::*; use std::sync::{Arc, RwLock}; diff --git a/demo/src/two_bone_ik.rs b/demo/src/two_bone_ik.rs index 06876cb..6908164 100644 --- a/demo/src/two_bone_ik.rs +++ b/demo/src/two_bone_ik.rs @@ -1,5 +1,4 @@ use bevy::prelude::*; -use ozz_animation_rs::math::*; use ozz_animation_rs::*; use std::sync::{Arc, RwLock}; diff --git a/src/lib.rs b/src/lib.rs index f2fe0f6..9c31da4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,6 @@ //! ```no_run //! use glam::Mat4; //! use ozz_animation_rs::*; -//! use ozz_animation_rs::math::*; //! use std::cell::RefCell; //! use std::rc::Rc; //! @@ -50,32 +49,32 @@ #![feature(const_collections_with_hasher)] #![feature(portable_simd)] -mod animation; -mod archive; -mod base; -mod blending_job; +pub mod animation; +pub mod archive; +pub mod base; +pub mod blending_job; mod endian; -mod ik_aim_job; -mod ik_two_bone_job; -mod local_to_model_job; -mod sampling_job; -mod skeleton; -mod skinning_job; -mod track; -mod track_sampling_job; -mod track_triggering_job; - +pub mod ik_aim_job; +pub mod ik_two_bone_job; +pub mod local_to_model_job; pub mod math; #[cfg(all(feature = "wasm", feature = "nodejs"))] pub mod nodejs; +pub mod sampling_job; +pub mod skeleton; +pub mod skinning_job; +pub mod track; +pub mod track_sampling_job; +pub mod track_triggering_job; pub use animation::Animation; pub use archive::{Archive, ArchiveRead}; -pub use base::*; +pub use base::{OzzBuf, OzzError, OzzMutBuf, OzzObj, SKELETON_MAX_JOINTS, SKELETON_MAX_SOA_JOINTS, SKELETON_NO_PARENT}; pub use blending_job::{BlendingContext, BlendingJob, BlendingJobArc, BlendingJobRc, BlendingJobRef, BlendingLayer}; pub use ik_aim_job::IKAimJob; pub use ik_two_bone_job::IKTwoBoneJob; pub use local_to_model_job::{LocalToModelJob, LocalToModelJobArc, LocalToModelJobRc, LocalToModelJobRef}; +pub use math::{SoaMat4, SoaQuat, SoaTransform, SoaVec3}; pub use sampling_job::{ InterpSoaFloat3, InterpSoaQuaternion, SamplingContext, SamplingJob, SamplingJobArc, SamplingJobRc, SamplingJobRef, }; diff --git a/src/math.rs b/src/math.rs index 780af6a..3ad9946 100644 --- a/src/math.rs +++ b/src/math.rs @@ -17,21 +17,21 @@ use std::simd::*; use crate::archive::{Archive, ArchiveRead}; use crate::base::OzzError; -pub const ZERO: f32x4 = f32x4::from_array([0.0; 4]); -pub const ONE: f32x4 = f32x4::from_array([1.0; 4]); -pub const TWO: f32x4 = f32x4::from_array([2.0; 4]); -pub const THREE: f32x4 = f32x4::from_array([3.0; 4]); -pub const NEG_ONE: f32x4 = f32x4::from_array([-1.0; 4]); -pub const FRAC_1_2: f32x4 = f32x4::from_array([0.5; 4]); -pub const PI: f32x4 = f32x4::from_array([core::f32::consts::PI; 4]); -pub const FRAC_2_PI: f32x4 = f32x4::from_array([core::f32::consts::FRAC_2_PI; 4]); -pub const FRAC_PI_2: f32x4 = f32x4::from_array([core::f32::consts::FRAC_PI_2; 4]); - -pub const X_AXIS: f32x4 = f32x4::from_array([1.0, 0.0, 0.0, 0.0]); -pub const Y_AXIS: f32x4 = f32x4::from_array([0.0, 1.0, 0.0, 0.0]); -pub const Z_AXIS: f32x4 = f32x4::from_array([0.0, 0.0, 1.0, 0.0]); - -pub const QUAT_UNIT: f32x4 = f32x4::from_array([0.0, 0.0, 0.0, 1.0]); +pub(crate) const ZERO: f32x4 = f32x4::from_array([0.0; 4]); +pub(crate) const ONE: f32x4 = f32x4::from_array([1.0; 4]); +pub(crate) const TWO: f32x4 = f32x4::from_array([2.0; 4]); +pub(crate) const THREE: f32x4 = f32x4::from_array([3.0; 4]); +pub(crate) const NEG_ONE: f32x4 = f32x4::from_array([-1.0; 4]); +pub(crate) const FRAC_1_2: f32x4 = f32x4::from_array([0.5; 4]); +pub(crate) const PI: f32x4 = f32x4::from_array([core::f32::consts::PI; 4]); +pub(crate) const FRAC_2_PI: f32x4 = f32x4::from_array([core::f32::consts::FRAC_2_PI; 4]); +pub(crate) const FRAC_PI_2: f32x4 = f32x4::from_array([core::f32::consts::FRAC_PI_2; 4]); + +pub(crate) const X_AXIS: f32x4 = f32x4::from_array([1.0, 0.0, 0.0, 0.0]); +pub(crate) const Y_AXIS: f32x4 = f32x4::from_array([0.0, 1.0, 0.0, 0.0]); +pub(crate) const Z_AXIS: f32x4 = f32x4::from_array([0.0, 0.0, 1.0, 0.0]); + +pub(crate) const QUAT_UNIT: f32x4 = f32x4::from_array([0.0, 0.0, 0.0, 1.0]); const SIGN: i32x4 = i32x4::from_array([core::i32::MIN; 4]); const SIGN_W: i32x4 = i32x4::from_array([0, 0, 0, core::i32::MIN]); @@ -708,7 +708,7 @@ impl AosMat4 { } // -// SoaVec3 +// SoaMat4 // #[repr(C)] #[derive(Debug, Default, Clone, Copy, PartialEq)] diff --git a/tests/additive.rs b/tests/additive.rs index ee5dba1..64f7593 100644 --- a/tests/additive.rs +++ b/tests/additive.rs @@ -1,5 +1,5 @@ use glam::{Mat4, Vec4}; -use ozz_animation_rs::math::*; +use ozz_animation_rs::math::f32_cos; use ozz_animation_rs::*; use std::cell::RefCell; use std::rc::Rc; diff --git a/tests/blend.rs b/tests/blend.rs index 6769807..de80671 100644 --- a/tests/blend.rs +++ b/tests/blend.rs @@ -1,5 +1,4 @@ use glam::Mat4; -use ozz_animation_rs::math::*; use ozz_animation_rs::*; use std::cell::RefCell; use std::rc::Rc; diff --git a/tests/look_at.rs b/tests/look_at.rs index 91cbcce..91284a9 100644 --- a/tests/look_at.rs +++ b/tests/look_at.rs @@ -1,5 +1,5 @@ use glam::{Mat4, Quat, Vec3A}; -use ozz_animation_rs::math::*; +use ozz_animation_rs::math::{f32_cos, f32_sin}; use ozz_animation_rs::*; use std::cell::RefCell; use std::rc::Rc; diff --git a/tests/partial_blend.rs b/tests/partial_blend.rs index 792e14e..379e4aa 100644 --- a/tests/partial_blend.rs +++ b/tests/partial_blend.rs @@ -1,5 +1,4 @@ use glam::{Mat4, Vec4}; -use ozz_animation_rs::math::*; use ozz_animation_rs::*; use std::cell::RefCell; use std::rc::Rc; diff --git a/tests/playback.rs b/tests/playback.rs index 08efd2e..52be5c5 100644 --- a/tests/playback.rs +++ b/tests/playback.rs @@ -1,5 +1,4 @@ use glam::Mat4; -use ozz_animation_rs::math::*; use ozz_animation_rs::*; use std::cell::RefCell; use std::rc::Rc; diff --git a/tests/two_bone_ik.rs b/tests/two_bone_ik.rs index 9ebb265..fa4df6b 100644 --- a/tests/two_bone_ik.rs +++ b/tests/two_bone_ik.rs @@ -1,5 +1,5 @@ use glam::{Mat4, Quat, Vec3A}; -use ozz_animation_rs::math::*; +use ozz_animation_rs::math::f32_cos; use ozz_animation_rs::*; use std::cell::RefCell; use std::rc::Rc;