Fix look_to variable naming (#8627)
# Objective - If I understand correctly, forward points in `direction`, so the negative of `direction` should be back. ## Migration Guide - `Transform::look_to` method changed default value of `direction.try_normalize()` from `Vec3::Z` to `Vec3::NEG_Z`
This commit is contained in:
parent
ebac7e8268
commit
df3e81c1fb
@ -349,19 +349,19 @@ impl Transform {
|
|||||||
/// and [`Transform::up`] points towards `up`.
|
/// and [`Transform::up`] points towards `up`.
|
||||||
///
|
///
|
||||||
/// In some cases it's not possible to construct a rotation. Another axis will be picked in those cases:
|
/// In some cases it's not possible to construct a rotation. Another axis will be picked in those cases:
|
||||||
/// * if `direction` is zero, `Vec3::Z` is used instead
|
/// * if `direction` is zero, `Vec3::NEG_Z` is used instead
|
||||||
/// * if `up` is zero, `Vec3::Y` is used instead
|
/// * if `up` is zero, `Vec3::Y` is used instead
|
||||||
/// * if `direction` is parallel with `up`, an orthogonal vector is used as the "right" direction
|
/// * if `direction` is parallel with `up`, an orthogonal vector is used as the "right" direction
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn look_to(&mut self, direction: Vec3, up: Vec3) {
|
pub fn look_to(&mut self, direction: Vec3, up: Vec3) {
|
||||||
let forward = -direction.try_normalize().unwrap_or(Vec3::Z);
|
let back = -direction.try_normalize().unwrap_or(Vec3::NEG_Z);
|
||||||
let up = up.try_normalize().unwrap_or(Vec3::Y);
|
let up = up.try_normalize().unwrap_or(Vec3::Y);
|
||||||
let right = up
|
let right = up
|
||||||
.cross(forward)
|
.cross(back)
|
||||||
.try_normalize()
|
.try_normalize()
|
||||||
.unwrap_or_else(|| up.any_orthonormal_vector());
|
.unwrap_or_else(|| up.any_orthonormal_vector());
|
||||||
let up = forward.cross(right);
|
let up = back.cross(right);
|
||||||
self.rotation = Quat::from_mat3(&Mat3::from_cols(right, up, forward));
|
self.rotation = Quat::from_mat3(&Mat3::from_cols(right, up, back));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Multiplies `self` with `transform` component by component, returning the
|
/// Multiplies `self` with `transform` component by component, returning the
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user