Make all math types #[repr(C)]

This makes it possible to use them within `fj` types.
This commit is contained in:
Hanno Braun 2022-03-17 15:43:44 +01:00
parent 15294c2ca2
commit e89d58e325
7 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,7 @@ use super::{Point, Vector};
/// An axis-aligned bounding box (AABB) /// An axis-aligned bounding box (AABB)
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Aabb<const D: usize> { pub struct Aabb<const D: usize> {
/// The minimum coordinates of the AABB /// The minimum coordinates of the AABB
pub min: Point<D>, pub min: Point<D>,

View File

@ -10,6 +10,7 @@ use super::{
/// The dimensionality of the point is defined by the const generic `D` /// The dimensionality of the point is defined by the const generic `D`
/// parameter. /// parameter.
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Point<const D: usize> { pub struct Point<const D: usize> {
/// The coordinates of the point /// The coordinates of the point
pub coords: Vector<D>, pub coords: Vector<D>,

View File

@ -9,6 +9,7 @@ use decorum::R64;
/// [`Ord`], and [`Hash`], enabling `Scalar` (and types built on top of it), to /// [`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. /// be used as keys in hash maps, hash sets, and similar types.
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
#[repr(C)]
pub struct Scalar(f64); pub struct Scalar(f64);
impl Scalar { impl Scalar {

View File

@ -7,6 +7,7 @@ use super::Point;
/// The dimensionality of the segment is defined by the const generic `D` /// The dimensionality of the segment is defined by the const generic `D`
/// parameter. /// parameter.
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Segment<const D: usize> { pub struct Segment<const D: usize> {
points: [Point<D>; 2], points: [Point<D>; 2],
} }

View File

@ -1,6 +1,7 @@
use super::{Aabb, Point, Segment, Triangle, Vector}; use super::{Aabb, Point, Segment, Triangle, Vector};
/// A transform /// A transform
#[repr(C)]
pub struct Transform(parry3d_f64::math::Isometry<f64>); pub struct Transform(parry3d_f64::math::Isometry<f64>);
impl Transform { impl Transform {

View File

@ -5,6 +5,7 @@ use super::{Point, Scalar};
/// The dimensionality of the triangle is defined by the const generic `D` /// The dimensionality of the triangle is defined by the const generic `D`
/// parameter. /// parameter.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Triangle<const D: usize> { pub struct Triangle<const D: usize> {
points: [Point<D>; 3], points: [Point<D>; 3],
color: [u8; 4], color: [u8; 4],

View File

@ -10,6 +10,7 @@ use super::{
/// The dimensionality of the vector is defined by the const generic `D` /// The dimensionality of the vector is defined by the const generic `D`
/// parameter. /// parameter.
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[repr(C)]
pub struct Vector<const D: usize> { pub struct Vector<const D: usize> {
/// The vector components /// The vector components
pub components: [Scalar; D], pub components: [Scalar; D],