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

Make all math types #[repr(C)] #375

Merged
merged 1 commit into from
Mar 17, 2022
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
1 change: 1 addition & 0 deletions fj-math/src/aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use super::{Point, Vector};

/// An axis-aligned bounding box (AABB)
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Aabb<const D: usize> {
/// The minimum coordinates of the AABB
pub min: Point<D>,
Expand Down
1 change: 1 addition & 0 deletions fj-math/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use super::{
/// The dimensionality of the point is defined by the const generic `D`
/// parameter.
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Point<const D: usize> {
/// The coordinates of the point
pub coords: Vector<D>,
Expand Down
1 change: 1 addition & 0 deletions fj-math/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use decorum::R64;
/// [`Ord`], and [`Hash`], enabling `Scalar` (and types built on top of it), to
/// be used as keys in hash maps, hash sets, and similar types.
#[derive(Clone, Copy)]
#[repr(C)]
pub struct Scalar(f64);

impl Scalar {
Expand Down
1 change: 1 addition & 0 deletions fj-math/src/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use super::Point;
/// The dimensionality of the segment is defined by the const generic `D`
/// parameter.
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Segment<const D: usize> {
points: [Point<D>; 2],
}
Expand Down
1 change: 1 addition & 0 deletions fj-math/src/transform.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::{Aabb, Point, Segment, Triangle, Vector};

/// A transform
#[repr(C)]
pub struct Transform(parry3d_f64::math::Isometry<f64>);

impl Transform {
Expand Down
1 change: 1 addition & 0 deletions fj-math/src/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use super::{Point, Scalar};
/// The dimensionality of the triangle is defined by the const generic `D`
/// parameter.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Triangle<const D: usize> {
points: [Point<D>; 3],
color: [u8; 4],
Expand Down
1 change: 1 addition & 0 deletions fj-math/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use super::{
/// The dimensionality of the vector is defined by the const generic `D`
/// parameter.
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Vector<const D: usize> {
/// The vector components
pub components: [Scalar; D],
Expand Down