Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Nalgebra 0.32 #145

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions networking/firmware_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ edition = "2021"
[dependencies]
deku = { version = "0.15", default-features = false, features = ["alloc"] }
# We support multiple versions of nalgebra since it changes so much.
nalgebra032 = { package = "nalgebra", version = "0.32", default-features = false, optional = true }
nalgebra031 = { package = "nalgebra", version = "0.31", default-features = false, optional = true }
nalgebra030 = { package = "nalgebra", version = "0.30", default-features = false, optional = true }

[dev-dependencies]
nalgebra032 = { package = "nalgebra", version = "0.32" }
nalgebra031 = { package = "nalgebra", version = "0.31" }
nalgebra030 = { package = "nalgebra", version = "0.30" }
63 changes: 29 additions & 34 deletions networking/firmware_protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,42 @@ pub struct SlimeQuaternion {
pub w: f32,
}

#[cfg(any(test, feature = "nalgebra031"))]
mod nalgebra031_impls {
use super::*;
use nalgebra031::Quaternion;

impl From<Quaternion<f32>> for SlimeQuaternion {
fn from(q: Quaternion<f32>) -> Self {
Self {
i: q.i as _,
j: q.j as _,
k: q.k as _,
w: q.w as _,
#[allow(unused_macros)]
macro_rules! impl_Nalgebra {
() => {
use super::*;
impl From<Quaternion<f32>> for SlimeQuaternion {
fn from(q: Quaternion<f32>) -> Self {
Self {
i: q.i,
j: q.j,
k: q.k,
w: q.w,
}
}
}
}
impl From<SlimeQuaternion> for Quaternion<f32> {
fn from(q: SlimeQuaternion) -> Self {
Self::new(q.w as _, q.i as _, q.j as _, q.k as _)
impl From<SlimeQuaternion> for Quaternion<f32> {
fn from(q: SlimeQuaternion) -> Self {
Self::new(q.w, q.i, q.j, q.k)
}
}
}
};
}

#[cfg(any(test, feature = "nalgebra032"))]
mod nalgebra032_impls {
use nalgebra032::Quaternion;
impl_Nalgebra!();
}
#[cfg(any(test, feature = "nalgebra031"))]
mod nalgebra031_impls {
use nalgebra031::Quaternion;
impl_Nalgebra!();
}
#[cfg(any(test, feature = "nalgebra030"))]
mod nalgebra030_impls {
use super::*;
use nalgebra030::Quaternion;

impl From<Quaternion<f32>> for SlimeQuaternion {
fn from(q: Quaternion<f32>) -> Self {
Self {
i: q.i as _,
j: q.j as _,
k: q.k as _,
w: q.w as _,
}
}
}
impl From<SlimeQuaternion> for Quaternion<f32> {
fn from(q: SlimeQuaternion) -> Self {
Self::new(q.w as _, q.i as _, q.j as _, q.k as _)
}
}
impl_Nalgebra!();
}

#[derive(PartialEq, Eq, Debug, DekuRead, DekuWrite)]
Expand Down