public static Quaternion LookRotationForcedUp(Quaternion rotation, Vector3 up) { Vector3 vector3 = new Vector3(); Vector3 vector31 = new Vector3(); Vector3 vector32 = new Vector3(); Vector3 vector33 = new Vector3(); Vector3 vector34 = new Vector3(); float single = up.x * up.x + up.y * up.y + up.z * up.z; if (single < 1.401298E-45f) { return(rotation); } float single1 = TransformHelpers.InvSqrt(single); up.x = up.x * single1; up.y = up.y * single1; up.z = up.z * single1; vector33.x = up.x; vector33.y = up.y; vector33.z = up.z; float single2 = 1f; float single3 = single2; vector34.x = single2; vector3.z = single3; float single4 = 0f; single3 = single4; vector34.y = single4; float single5 = single3; single3 = single5; vector34.z = single5; float single6 = single3; single3 = single6; vector3.x = single6; vector3.y = single3; vector3 = rotation * vector3; vector34 = rotation * vector34; float single7 = vector3.x * vector33.x + vector3.y * vector33.y + vector3.z * vector33.z; float single8 = vector34.x * vector33.x + vector34.y * vector33.y + vector34.z * vector33.z; if (single7 * single7 <= single8 * single8) { vector31.x = vector3.x; vector31.y = vector3.y; vector31.z = vector3.z; } else { vector31.x = vector33.x; vector31.y = vector33.y; vector31.z = vector33.z; vector32.x = vector34.x; vector32.y = vector34.y; vector32.z = vector34.z; vector3.x = -(vector31.y * vector32.z - vector31.z * vector32.y); vector3.y = -(vector31.z * vector32.x - vector31.x * vector32.z); vector3.z = -(vector31.x * vector32.y - vector31.y * vector32.x); float single9 = TransformHelpers.InvSqrt(vector3.x, vector3.y, vector3.z); vector31.x = single9 * vector3.x; vector31.y = single9 * vector3.y; vector31.z = single9 * vector3.z; } vector32.x = vector33.x; vector32.y = vector33.y; vector32.z = vector33.z; vector34.x = vector31.y * vector32.z - vector31.z * vector32.y; vector34.y = vector31.z * vector32.x - vector31.x * vector32.z; vector34.z = vector31.x * vector32.y - vector31.y * vector32.x; float single10 = TransformHelpers.InvSqrt(vector34.x, vector34.y, vector34.z); vector32.x = vector34.x * single10; vector32.y = vector34.y * single10; vector32.z = vector34.z * single10; vector31.x = vector33.x; vector31.y = vector33.y; vector31.z = vector33.z; vector3.x = vector31.y * vector32.z - vector31.z * vector32.y; vector3.y = vector31.z * vector32.x - vector31.x * vector32.z; vector3.z = vector31.x * vector32.y - vector31.y * vector32.x; if (vector3.x * vector3.x + vector3.y * vector3.y + vector3.z * vector3.z < 1.401298E-45f) { return(rotation); } return(Quaternion.LookRotation(vector3, up)); }