Hit objects from different space regions
This commit is contained in:
parent
11e48580b9
commit
9ec5f17754
|
|
@ -192,7 +192,7 @@ impl Space {
|
||||||
fn trace_outer(&self, ray: Ray) -> FlatTraceResult {
|
fn trace_outer(&self, ray: Ray) -> FlatTraceResult {
|
||||||
assert_eq!(self.which_subspace(ray.pos), Outer);
|
assert_eq!(self.which_subspace(ray.pos), Outer);
|
||||||
let cell = basic_shapes::Rect { size: vec2(self.rect.outer_radius, self.rect.external_halflength) };
|
let cell = basic_shapes::Rect { size: vec2(self.rect.outer_radius, self.rect.external_halflength) };
|
||||||
let objs = Self::trace_to_objects(self.list_objects_outer(), ray);
|
let objs = Self::trace_to_objects(self.list_objects_outer().as_slice(), ray);
|
||||||
if let Some(dist) = cell.trace_into(ray) {
|
if let Some(dist) = cell.trace_into(ray) {
|
||||||
FlatTraceResult {
|
FlatTraceResult {
|
||||||
end: Some(ray.forward(dist)),
|
end: Some(ray.forward(dist)),
|
||||||
|
|
@ -213,8 +213,25 @@ impl Space {
|
||||||
.expect("Can't get outta the wall!")
|
.expect("Can't get outta the wall!")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_objects_outer(&self) -> &[Object] {
|
fn list_objects_outer(&self) -> Vec<Object> {
|
||||||
self.objs.as_slice()
|
self.objs.iter().map(|&obj| {
|
||||||
|
match self.which_subspace(obj.loc.pos) {
|
||||||
|
Outer => obj,
|
||||||
|
Inner => {
|
||||||
|
let Vec2 { x, y } = obj.loc.pos; // в основной СК
|
||||||
|
let y = self.rect.u(y) + y.signum() * (self.rect.external_halflength - self.rect.internal_halflength);
|
||||||
|
Object {
|
||||||
|
id: obj.id,
|
||||||
|
loc: Location {
|
||||||
|
pos: vec2(x, y), // в плоском продолжении СК Outer на область Inner
|
||||||
|
rot: obj.loc.rot,
|
||||||
|
},
|
||||||
|
r: obj.r,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Boundary => panic!("Object {} was destroyed by the space curvature", obj.id),
|
||||||
|
}
|
||||||
|
}).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trace_to_objects(objs: &[Object], ray: Ray) -> Vec<Hit> {
|
fn trace_to_objects(objs: &[Object], ray: Ray) -> Vec<Hit> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user