Neat?
This commit is contained in:
parent
0a4078d4f3
commit
cac83b9003
|
|
@ -238,7 +238,6 @@ impl Space {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_objects_inner(&self) -> Vec<Object> {
|
fn list_objects_inner(&self) -> Vec<Object> {
|
||||||
let cell = RectInside { rect: self.rect };
|
|
||||||
self.objs.iter().map(|&obj| {
|
self.objs.iter().map(|&obj| {
|
||||||
match self.which_subspace(obj.loc.pos) {
|
match self.which_subspace(obj.loc.pos) {
|
||||||
Inner | Outer => {
|
Inner | Outer => {
|
||||||
|
|
@ -247,7 +246,7 @@ impl Space {
|
||||||
Object {
|
Object {
|
||||||
id: obj.id,
|
id: obj.id,
|
||||||
loc: Location {
|
loc: Location {
|
||||||
pos: cell.pos_to_local(obj.loc.pos), // в плоской СК для Inner или её продолжении на Outer
|
pos: vec2(obj.loc.pos.x, self.rect.u(obj.loc.pos.y)), // в плоской СК для Inner или её продолжении на Outer
|
||||||
rot: m * obj.loc.rot,
|
rot: m * obj.loc.rot,
|
||||||
},
|
},
|
||||||
r: obj.r,
|
r: obj.r,
|
||||||
|
|
@ -273,9 +272,8 @@ impl Space {
|
||||||
.filter(|&(_, t)| t >= 0.0 && t < limit)
|
.filter(|&(_, t)| t >= 0.0 && t < limit)
|
||||||
.map(|(obj, t)| {
|
.map(|(obj, t)| {
|
||||||
let pos = ray.forward(t).pos;
|
let pos = ray.forward(t).pos;
|
||||||
let rel = obj.loc.rot.inverse() * (pos - obj.loc.pos);
|
let rel = obj.loc.rot.inverse() * Ray { pos: pos - obj.loc.pos, dir: ray.dir };
|
||||||
let dir = obj.loc.rot.inverse() * ray.dir;
|
Hit { id: obj.id, distance: t, pos: globalize(pos), rel }
|
||||||
Hit { id: obj.id, distance: t, pos: globalize(pos), rel: Ray { pos: rel, dir } }
|
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
@ -452,6 +450,14 @@ impl Ray {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::ops::Mul<Ray> for Mat2 {
|
||||||
|
type Output = Ray;
|
||||||
|
|
||||||
|
fn mul(self, rhs: Ray) -> Self::Output {
|
||||||
|
Ray { pos: self * rhs.pos, dir: self * rhs.dir }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mod basic_shapes {
|
mod basic_shapes {
|
||||||
use glam::{Vec2, vec2};
|
use glam::{Vec2, vec2};
|
||||||
use crate::Ray;
|
use crate::Ray;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user