Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spatial::look_at() now preserves its scale values #26897

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions scene/3d/spatial.cpp
Expand Up @@ -675,8 +675,7 @@ void Spatial::set_identity() {

void Spatial::look_at(const Vector3 &p_target, const Vector3 &p_up) {

Transform lookat;
lookat.origin = get_global_transform().origin;
Transform lookat(get_global_transform());
if (lookat.origin == p_target) {
ERR_EXPLAIN("Node origin and target are in the same position, look_at() failed");
ERR_FAIL();
Expand All @@ -686,7 +685,10 @@ void Spatial::look_at(const Vector3 &p_target, const Vector3 &p_up) {
ERR_EXPLAIN("Up vector and direction between node origin and target are aligned, look_at() failed");
ERR_FAIL();
}
Vector3 original_scale(lookat.basis.get_scale());
lookat = lookat.looking_at(p_target, p_up);
// as basis was normalized, we just need to apply original scale back
lookat.basis.scale(original_scale);
set_global_transform(lookat);
}

Expand Down