@@ -39,7 +39,20 @@ struct Vector2;
39
39
struct Vector3i ;
40
40
41
41
struct [[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 ;
43
56
44
57
enum Axis {
45
58
AXIS_X,
@@ -207,6 +220,19 @@ struct [[nodiscard]] Vector3 {
207
220
x (p_x), y (p_y), z (p_z) {}
208
221
};
209
222
223
+ inline constexpr Vector3 Vector3::LEFT = { -1 , 0 , 0 };
224
+ inline constexpr Vector3 Vector3::RIGHT = { 1 , 0 , 0 };
225
+ inline constexpr Vector3 Vector3::UP = { 0 , 1 , 0 };
226
+ inline constexpr Vector3 Vector3::DOWN = { 0 , -1 , 0 };
227
+ inline constexpr Vector3 Vector3::FORWARD = { 0 , 0 , -1 };
228
+ inline constexpr Vector3 Vector3::BACK = { 0 , 0 , 1 };
229
+ inline constexpr Vector3 Vector3::MODEL_LEFT = { 1 , 0 , 0 };
230
+ inline constexpr Vector3 Vector3::MODEL_RIGHT = { -1 , 0 , 0 };
231
+ inline constexpr Vector3 Vector3::MODEL_TOP = { 0 , 1 , 0 };
232
+ inline constexpr Vector3 Vector3::MODEL_BOTTOM = { 0 , -1 , 0 };
233
+ inline constexpr Vector3 Vector3::MODEL_FRONT = { 0 , 0 , 1 };
234
+ inline constexpr Vector3 Vector3::MODEL_REAR = { 0 , 0 , -1 };
235
+
210
236
Vector3 Vector3::cross (const Vector3 &p_with) const {
211
237
Vector3 ret (
212
238
(y * p_with.z ) - (z * p_with.y ),
@@ -346,7 +372,7 @@ Vector3 Vector3::get_any_perpendicular() const {
346
372
// 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).
347
373
// However, it would be reasonable to use any of the axes of the basis, as it is simpler to calculate.
348
374
ERR_FAIL_COND_V_MSG (is_zero_approx (), Vector3 (0 , 0 , 0 ), " The Vector3 must not be zero." );
349
- return cross ((Math::abs (x) <= Math::abs (y) && Math::abs (x) <= Math::abs (z)) ? Vector3 ( 1 , 0 , 0 ) : Vector3 ( 0 , 1 , 0 ) ).normalized ();
375
+ return cross ((Math::abs (x) <= Math::abs (y) && Math::abs (x) <= Math::abs (z)) ? Vector3::RIGHT : Vector3::UP ).normalized ();
350
376
}
351
377
352
378
/* Operators */
0 commit comments