mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-04 07:16:55 +00:00
Remove redundant access to point model coords
This commit is contained in:
parent
1e33846f93
commit
bff0d20f83
@ -45,19 +45,15 @@ impl Camera {
|
|||||||
//
|
//
|
||||||
// To do that, first compute the model's highest point, as well as
|
// To do that, first compute the model's highest point, as well as
|
||||||
// the furthest point from the origin, in x and y.
|
// the furthest point from the origin, in x and y.
|
||||||
let highest_point = aabb.max.z();
|
let highest_point = aabb.max.z;
|
||||||
let furthest_point = [
|
let furthest_point =
|
||||||
aabb.min.x().abs(),
|
[aabb.min.x.abs(), aabb.max.x, aabb.min.y.abs(), aabb.max.y]
|
||||||
aabb.max.x(),
|
.into_iter()
|
||||||
aabb.min.y().abs(),
|
.reduce(Scalar::max)
|
||||||
aabb.max.y(),
|
// `reduce` can only return `None`, if there are no items in
|
||||||
]
|
// the iterator. And since we're creating an array full of
|
||||||
.into_iter()
|
// items above, we know this can't panic.
|
||||||
.reduce(Scalar::max)
|
.unwrap();
|
||||||
// `reduce` can only return `None`, if there are no items in
|
|
||||||
// the iterator. And since we're creating an array full of
|
|
||||||
// items above, we know this can't panic.
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// The actual furthest point is not far enough. We don't want the
|
// The actual furthest point is not far enough. We don't want the
|
||||||
// model to fill the whole screen.
|
// model to fill the whole screen.
|
||||||
@ -74,7 +70,7 @@ impl Camera {
|
|||||||
|
|
||||||
let initial_offset = {
|
let initial_offset = {
|
||||||
let mut offset = aabb.center();
|
let mut offset = aabb.center();
|
||||||
*offset.z_mut() = Scalar::ZERO;
|
offset.z = Scalar::ZERO;
|
||||||
-offset
|
-offset
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,8 +80,8 @@ impl Camera {
|
|||||||
|
|
||||||
rotation: Transform::identity(),
|
rotation: Transform::identity(),
|
||||||
translation: Translation::from([
|
translation: Translation::from([
|
||||||
initial_offset.x().into_f64(),
|
initial_offset.x.into_f64(),
|
||||||
initial_offset.y().into_f64(),
|
initial_offset.y.into_f64(),
|
||||||
-initial_distance.into_f64(),
|
-initial_distance.into_f64(),
|
||||||
]),
|
]),
|
||||||
}
|
}
|
||||||
|
@ -90,22 +90,22 @@ impl Approximation {
|
|||||||
// As this is a cycle, neighboring edges are going to share vertices.
|
// As this is a cycle, neighboring edges are going to share vertices.
|
||||||
// Let's remove all those duplicates.
|
// Let's remove all those duplicates.
|
||||||
points.sort_by(|a, b| {
|
points.sort_by(|a, b| {
|
||||||
if a.x() < b.x() {
|
if a.x < b.x {
|
||||||
return Ordering::Less;
|
return Ordering::Less;
|
||||||
}
|
}
|
||||||
if a.x() > b.x() {
|
if a.x > b.x {
|
||||||
return Ordering::Greater;
|
return Ordering::Greater;
|
||||||
}
|
}
|
||||||
if a.y() < b.y() {
|
if a.y < b.y {
|
||||||
return Ordering::Less;
|
return Ordering::Less;
|
||||||
}
|
}
|
||||||
if a.y() > b.y() {
|
if a.y > b.y {
|
||||||
return Ordering::Greater;
|
return Ordering::Greater;
|
||||||
}
|
}
|
||||||
if a.z() < b.z() {
|
if a.z < b.z {
|
||||||
return Ordering::Less;
|
return Ordering::Less;
|
||||||
}
|
}
|
||||||
if a.z() > b.z() {
|
if a.z > b.z {
|
||||||
return Ordering::Greater;
|
return Ordering::Greater;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ use crate::{
|
|||||||
impl Shape for fj::Sweep {
|
impl Shape for fj::Sweep {
|
||||||
fn bounding_volume(&self) -> Aabb<3> {
|
fn bounding_volume(&self) -> Aabb<3> {
|
||||||
let mut aabb = self.shape.bounding_volume();
|
let mut aabb = self.shape.bounding_volume();
|
||||||
*aabb.max.z_mut() = self.length.into();
|
aabb.max.z = self.length.into();
|
||||||
aabb
|
aabb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,6 @@ impl<const D: usize> Point<D> {
|
|||||||
coords: self.coords.to_t(),
|
coords: self.coords.to_t(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Access a mutable reference to the point's z coordinate
|
|
||||||
pub fn z_mut(&mut self) -> &mut Scalar {
|
|
||||||
&mut self.coords.0[2]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Point<1> {
|
impl Point<1> {
|
||||||
@ -77,23 +72,6 @@ impl Point<2> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Point<3> {
|
|
||||||
/// Access the point's x coordinate
|
|
||||||
pub fn x(&self) -> Scalar {
|
|
||||||
self.coords.x
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Access the point's y coordinate
|
|
||||||
pub fn y(&self) -> Scalar {
|
|
||||||
self.coords.y
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Access the point's z coordinate
|
|
||||||
pub fn z(&self) -> Scalar {
|
|
||||||
self.coords.z
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ops::Deref for Point<1> {
|
impl ops::Deref for Point<1> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user