mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-27 01:25:52 +00:00
Merge pull request #375 from hannobraun/fj
Make all math types `#[repr(C)]`
This commit is contained in:
commit
7268a0c9fc
@ -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>,
|
||||||
|
@ -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>,
|
||||||
|
@ -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 {
|
||||||
|
@ -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],
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
|
@ -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],
|
||||||
|
@ -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],
|
||||||
|
Loading…
Reference in New Issue
Block a user