Skip to content

Commit

Permalink
Merge pull request #375 from hannobraun/fj
Browse files Browse the repository at this point in the history
Make all math types `#[repr(C)]`
  • Loading branch information
hannobraun authored Mar 17, 2022
2 parents 15294c2 + e89d58e commit 7268a0c
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 0 deletions.
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

0 comments on commit 7268a0c

Please sign in to comment.