fromsoftware_shared/dl_math/
linear.rs

1use super::{F32Matrix4x4, F32Vector3, F32Vector4};
2
3#[repr(C, align(16))]
4#[derive(Debug, Clone, Copy, PartialEq)]
5pub struct Segment {
6    /// The starting point of the segment.
7    pub origin: F32Vector4,
8    /// The direction and length of the segment from the origin.
9    pub dir: F32Vector4,
10}
11
12#[repr(C, align(16))]
13#[derive(Debug, Clone, Copy, PartialEq)]
14pub struct Ray {
15    /// The starting point of the ray.
16    pub origin: F32Vector4,
17    /// The direction of the ray.
18    pub dir: F32Vector4,
19}
20
21#[repr(C, align(16))]
22#[derive(Debug, Clone, Copy, PartialEq)]
23pub struct Line {
24    /// A point on the line.
25    pub origin: F32Vector4,
26    /// The direction of the line.
27    pub dir: F32Vector4,
28}
29
30#[repr(C, align(16))]
31#[derive(Debug, Clone, Copy, PartialEq)]
32pub struct Rectangle {
33    /// The first edge vector from the origin.
34    pub edge1: F32Vector4,
35    /// The second edge vector from the origin.
36    pub edge2: F32Vector4,
37    /// The origin point of the rectangle.
38    pub origin: F32Vector4,
39}
40
41#[repr(C, align(16))]
42#[derive(Debug, Clone, Copy, PartialEq)]
43pub struct Plane {
44    /// The plane equation `(nx, ny, nz, d)`.
45    pub plane: F32Vector4,
46}
47
48#[repr(C, align(16))]
49#[derive(Debug, Clone, Copy, PartialEq)]
50pub struct Sphere {
51    /// The sphere's center `(x, y, z)` and radius `w`.
52    pub sphere: F32Vector4,
53}
54
55#[repr(C, align(16))]
56#[derive(Debug, Clone, Copy, PartialEq)]
57pub struct Aabb {
58    /// The minimum corner of the box.
59    pub min: F32Vector4,
60    /// The maximum corner of the box.
61    pub max: F32Vector4,
62}
63
64#[repr(C, align(16))]
65#[derive(Debug, Clone, Copy, PartialEq)]
66pub struct Obb {
67    /// The half-size of the box along its local axes.
68    pub extents: F32Vector4,
69    /// The transformation matrix from local to world space.
70    pub xform: F32Matrix4x4,
71}
72
73#[repr(C, align(16))]
74#[derive(Debug, Clone, Copy, PartialEq)]
75pub struct Lss {
76    /// The central line segment.
77    pub segment: Segment,
78    /// The radius of the capsule.
79    pub radius: f32,
80}
81
82#[repr(C, align(16))]
83#[derive(Debug, Clone, Copy, PartialEq)]
84pub struct Rss {
85    /// The central rectangle.
86    pub rectangle: Rectangle,
87    /// The radius of the swept sphere.
88    pub radius: f32,
89}
90
91#[repr(C, align(16))]
92#[derive(Debug, Clone, Copy, PartialEq)]
93pub struct Triangle {
94    /// The first vertex of the triangle.
95    pub origin: F32Vector4,
96    /// The vector from the origin to the second vertex.
97    pub edge1: F32Vector4,
98    /// The vector from the origin to the third vertex.
99    pub edge2: F32Vector4,
100}
101
102#[repr(C, align(16))]
103#[derive(Debug, Clone, Copy, PartialEq)]
104pub struct Triangle3 {
105    /// The first vertex of the triangle.
106    pub origin: F32Vector3,
107    /// The vector from the origin to the second vertex.
108    pub edge1: F32Vector3,
109    /// The vector from the origin to the third vertex.
110    pub edge2: F32Vector3,
111}
112
113#[repr(C, align(16))]
114#[derive(Debug, Clone, Copy, PartialEq)]
115pub struct Frustum {
116    /// The six planes that define the frustum volume.
117    pub planes: [Plane; 6],
118}