@@ -39,7 +39,20 @@ struct Vector2;
3939struct Vector3i ;
4040
4141struct [[nodiscard]] Vector3 {
42- static const int AXIS_COUNT = 3 ;
42+ static const Vector3 LEFT;
43+ static const Vector3 RIGHT;
44+ static const Vector3 UP;
45+ static const Vector3 DOWN;
46+ static const Vector3 FORWARD;
47+ static const Vector3 BACK;
48+ static const Vector3 MODEL_LEFT;
49+ static const Vector3 MODEL_RIGHT;
50+ static const Vector3 MODEL_TOP;
51+ static const Vector3 MODEL_BOTTOM;
52+ static const Vector3 MODEL_FRONT;
53+ static const Vector3 MODEL_REAR;
54+
55+ static constexpr int AXIS_COUNT = 3 ;
4356
4457 enum Axis {
4558 AXIS_X,
@@ -195,6 +208,19 @@ struct [[nodiscard]] Vector3 {
195208 x (p_x), y (p_y), z (p_z) {}
196209};
197210
211+ inline constexpr Vector3 Vector3::LEFT = { -1 , 0 , 0 };
212+ inline constexpr Vector3 Vector3::RIGHT = { 1 , 0 , 0 };
213+ inline constexpr Vector3 Vector3::UP = { 0 , 1 , 0 };
214+ inline constexpr Vector3 Vector3::DOWN = { 0 , -1 , 0 };
215+ inline constexpr Vector3 Vector3::FORWARD = { 0 , 0 , -1 };
216+ inline constexpr Vector3 Vector3::BACK = { 0 , 0 , 1 };
217+ inline constexpr Vector3 Vector3::MODEL_LEFT = { 1 , 0 , 0 };
218+ inline constexpr Vector3 Vector3::MODEL_RIGHT = { -1 , 0 , 0 };
219+ inline constexpr Vector3 Vector3::MODEL_TOP = { 0 , 1 , 0 };
220+ inline constexpr Vector3 Vector3::MODEL_BOTTOM = { 0 , -1 , 0 };
221+ inline constexpr Vector3 Vector3::MODEL_FRONT = { 0 , 0 , 1 };
222+ inline constexpr Vector3 Vector3::MODEL_REAR = { 0 , 0 , -1 };
223+
198224Vector3 Vector3::cross (const Vector3 &p_with) const {
199225 Vector3 ret (
200226 (y * p_with.z ) - (z * p_with.y ),
@@ -334,7 +360,7 @@ Vector3 Vector3::get_any_perpendicular() const {
334360 // since it could be a different vector depending on the prior branching code Math::abs(x) <= Math::abs(y) && Math::abs(x) <= Math::abs(z).
335361 // However, it would be reasonable to use any of the axes of the basis, as it is simpler to calculate.
336362 ERR_FAIL_COND_V_MSG (is_zero_approx (), Vector3 (0 , 0 , 0 ), " The Vector3 must not be zero." );
337- return cross ((Math::abs (x) <= Math::abs (y) && Math::abs (x) <= Math::abs (z)) ? Vector3 ( 1 , 0 , 0 ) : Vector3 ( 0 , 1 , 0 ) ).normalized ();
363+ return cross ((Math::abs (x) <= Math::abs (y) && Math::abs (x) <= Math::abs (z)) ? Vector3::RIGHT : Vector3::UP ).normalized ();
338364}
339365
340366/* Operators */
0 commit comments