Publish structs

This commit is contained in:
numzero 2024-06-25 13:07:03 +03:00
parent 455b69d447
commit 13da06b294

View File

@ -105,30 +105,32 @@ pub fn main() {
} }
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
struct Location { pub struct Location {
/// Положение в основной СК /// Положение в основной СК
pos: Vec2, pub pos: Vec2,
/// Преобразование вектора из локальной ортонормированной в основную СК /// Преобразование вектора из локальной ортонормированной в основную СК
rot: Mat2, pub rot: Mat2,
} }
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
struct Object { pub struct Object {
id: i32, pub id: i32,
loc: Location, pub loc: Location,
r: f32, pub r: f32,
} }
struct Hit { #[derive(Copy, Clone, Debug)]
distance: f32, pub struct Hit {
id: i32, pub distance: f32,
pos: Vec2, // положение в основной СК pub id: i32,
rel: Ray, // в локальной ортонормированной СК объекта pub pos: Vec2, // положение в основной СК
pub rel: Ray, // в локальной ортонормированной СК объекта
} }
struct FlatTraceResult { #[derive(Clone, Debug)]
end: Option<Ray>, pub struct FlatTraceResult {
objects: Vec<Hit>, pub end: Option<Ray>,
pub objects: Vec<Hit>,
} }
fn draw_ray_2(gc: &mut Vec<Draw>, space: &Space, base: Vec2, dir: Vec2) { fn draw_ray_2(gc: &mut Vec<Draw>, space: &Space, base: Vec2, dir: Vec2) {
@ -277,13 +279,13 @@ impl Renderable for Tube {
} }
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
struct Ray { pub struct Ray {
pos: Vec2, pub pos: Vec2,
dir: Vec2, pub dir: Vec2,
} }
impl Ray { impl Ray {
fn forward(&self, dist: f32) -> Ray { pub fn forward(&self, dist: f32) -> Ray {
Ray { pos: self.pos + self.dir * dist, dir: self.dir } Ray { pos: self.pos + self.dir * dist, dir: self.dir }
} }
} }