mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-24 01:47:20 +01:00
Transform now uses Basis::create_looking_at.
This commit is contained in:
parent
010e1b51a8
commit
6f53257e05
@ -83,35 +83,7 @@ void Transform::rotate_basis(const Vector3 &p_axis, real_t p_phi) {
|
||||
}
|
||||
|
||||
void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND(p_eye == p_target);
|
||||
ERR_FAIL_COND(p_up.length() == 0);
|
||||
#endif
|
||||
// Reference: MESA source code
|
||||
Vector3 v_x, v_y, v_z;
|
||||
|
||||
/* Make rotation matrix */
|
||||
|
||||
/* Z vector */
|
||||
v_z = p_eye - p_target;
|
||||
|
||||
v_z.normalize();
|
||||
|
||||
v_y = p_up;
|
||||
|
||||
v_x = v_y.cross(v_z);
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND(v_x.length() == 0);
|
||||
#endif
|
||||
|
||||
/* Recompute Y = Z cross X */
|
||||
v_y = v_z.cross(v_x);
|
||||
|
||||
v_x.normalize();
|
||||
v_y.normalize();
|
||||
|
||||
basis.set(v_x, v_y, v_z);
|
||||
|
||||
basis = Basis::create_looking_at(p_target - p_eye, p_up);
|
||||
origin = p_eye;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user