diff --git a/src/bin/flat/main.rs b/src/bin/flat/main.rs index cb287d9..c1788f8 100644 --- a/src/bin/flat/main.rs +++ b/src/bin/flat/main.rs @@ -200,9 +200,8 @@ impl Space { objects: hits.into_iter().filter_map(|HitInternal { object, distance }| if distance < dist { let pos = ray.forward(distance).pos; - // NB: object.loc.rot задан относительно object.loc.pos, поэтому и ray_to_global надо делать относительно object.loc.pos, а не pos. - let rel = object.loc.rot.inverse() * cell.ray_to_global(Ray { pos: object.loc.pos, dir: pos - object.loc.pos }).dir; - let dir = object.loc.rot.inverse() * cell.ray_to_global(Ray { pos: object.loc.pos, dir: ray.dir }).dir; + let rel = object.loc.rot.inverse() * (pos - object.loc.pos); + let dir = object.loc.rot.inverse() * ray.dir; Some(Hit { id: object.id, distance, pos: cell.pos_to_global(pos), rel: Ray { pos: rel, dir } }) } else { None } ).collect(), @@ -265,11 +264,12 @@ impl Space { match self.which_subspace(obj.loc.pos) { Inner | Outer => { // NB: не работает для частей Outer с |y| < external_halflength. Но они и не нужны. + let m = mat2(vec2(1., 0.), vec2(0., self.rect.du(obj.loc.pos.y))); Object { id: obj.id, loc: Location { pos: cell.pos_to_local(obj.loc.pos), // в плоской СК для Inner или её продолжении на Outer - rot: obj.loc.rot, + rot: m * obj.loc.rot, }, r: obj.r, }