summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/variant/projection.hpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-10-07 22:25:54 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-10-07 22:25:54 +0200
commitdb8679443fb6fcd5f9a97abf3e25c9e64f256607 (patch)
tree3adaf7df7db0ce66302490f3e5e9cbf263645929 /include/godot_cpp/variant/projection.hpp
parent0eba81ef79b96922a0e1637f812e4e1df4d29a4c (diff)
parent65eeb94f75d00cf523da114de3587f930cdec13f (diff)
downloadredot-cpp-db8679443fb6fcd5f9a97abf3e25c9e64f256607.tar.gz
Merge pull request #885 from aaronfranke/core-data-structs
Update core data structures to match the engine
Diffstat (limited to 'include/godot_cpp/variant/projection.hpp')
-rw-r--r--include/godot_cpp/variant/projection.hpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/include/godot_cpp/variant/projection.hpp b/include/godot_cpp/variant/projection.hpp
index 5472490..6510cb0 100644
--- a/include/godot_cpp/variant/projection.hpp
+++ b/include/godot_cpp/variant/projection.hpp
@@ -32,13 +32,12 @@
#define GODOT_PROJECTION_HPP
#include <godot_cpp/core/math.hpp>
-
-#include <godot_cpp/variant/array.hpp>
#include <godot_cpp/variant/vector3.hpp>
#include <godot_cpp/variant/vector4.hpp>
namespace godot {
+class Array;
struct AABB;
struct Plane;
struct Rect2;
@@ -55,14 +54,16 @@ struct _NO_DISCARD_ Projection {
PLANE_BOTTOM
};
- Vector4 matrix[4];
+ Vector4 columns[4];
_FORCE_INLINE_ const Vector4 &operator[](const int p_axis) const {
- return matrix[p_axis];
+ DEV_ASSERT((unsigned int)p_axis < 4);
+ return columns[p_axis];
}
_FORCE_INLINE_ Vector4 &operator[](const int p_axis) {
- return matrix[p_axis];
+ DEV_ASSERT((unsigned int)p_axis < 4);
+ return columns[p_axis];
}
float determinant() const;
@@ -97,7 +98,7 @@ struct _NO_DISCARD_ Projection {
Projection jitter_offseted(const Vector2 &p_offset) const;
static real_t get_fovy(real_t p_fovx, real_t p_aspect) {
- return Math::rad2deg(Math::atan(p_aspect * Math::tan(Math::deg2rad(p_fovx) * 0.5)) * 2.0);
+ return Math::rad_to_deg(Math::atan(p_aspect * Math::tan(Math::deg_to_rad(p_fovx) * 0.5)) * 2.0);
}
real_t get_z_far() const;
@@ -107,8 +108,8 @@ struct _NO_DISCARD_ Projection {
bool is_orthogonal() const;
Array get_projection_planes(const Transform3D &p_transform) const;
- bool get_endpoints(const Transform3D &p_transform, Vector3 *p_8points) const;
+ bool get_endpoints(const Transform3D &p_transform, Vector3 *p_8points) const;
Vector2 get_viewport_half_extents() const;
Vector2 get_far_plane_half_extents() const;
@@ -136,7 +137,7 @@ struct _NO_DISCARD_ Projection {
bool operator==(const Projection &p_cam) const {
for (uint32_t i = 0; i < 4; i++) {
for (uint32_t j = 0; j < 4; j++) {
- if (matrix[i][j] != p_cam.matrix[i][j]) {
+ if (columns[i][j] != p_cam.columns[i][j]) {
return false;
}
}
@@ -158,10 +159,10 @@ struct _NO_DISCARD_ Projection {
Vector3 Projection::xform(const Vector3 &p_vec3) const {
Vector3 ret;
- ret.x = matrix[0][0] * p_vec3.x + matrix[1][0] * p_vec3.y + matrix[2][0] * p_vec3.z + matrix[3][0];
- ret.y = matrix[0][1] * p_vec3.x + matrix[1][1] * p_vec3.y + matrix[2][1] * p_vec3.z + matrix[3][1];
- ret.z = matrix[0][2] * p_vec3.x + matrix[1][2] * p_vec3.y + matrix[2][2] * p_vec3.z + matrix[3][2];
- real_t w = matrix[0][3] * p_vec3.x + matrix[1][3] * p_vec3.y + matrix[2][3] * p_vec3.z + matrix[3][3];
+ ret.x = columns[0][0] * p_vec3.x + columns[1][0] * p_vec3.y + columns[2][0] * p_vec3.z + columns[3][0];
+ ret.y = columns[0][1] * p_vec3.x + columns[1][1] * p_vec3.y + columns[2][1] * p_vec3.z + columns[3][1];
+ ret.z = columns[0][2] * p_vec3.x + columns[1][2] * p_vec3.y + columns[2][2] * p_vec3.z + columns[3][2];
+ real_t w = columns[0][3] * p_vec3.x + columns[1][3] * p_vec3.y + columns[2][3] * p_vec3.z + columns[3][3];
return ret / w;
}