From 8cee7703a6673f9505332de1581055c821b756f0 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 20 Aug 2019 17:54:03 -0300 Subject: Yay very basic 3D (only white) finally shows. --- core/math/camera_matrix.cpp | 6 ++++++ core/math/camera_matrix.h | 2 ++ 2 files changed, 8 insertions(+) (limited to 'core/math') diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index 380bae871a..9018a78c57 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -485,6 +485,12 @@ void CameraMatrix::invert() { } } +void CameraMatrix::flip_y() { + for (int i = 0; i < 4; i++) { + matrix[1][i] = -matrix[1][i]; + } +} + CameraMatrix::CameraMatrix() { set_identity(); diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index 2eed6d25d6..a7a85fee8d 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -90,6 +90,8 @@ struct CameraMatrix { int get_pixels_per_meter(int p_for_pixel_width) const; operator Transform() const; + void flip_y(); + CameraMatrix(); CameraMatrix(const Transform &p_transform); ~CameraMatrix(); -- cgit v1.2.3 From 920db604d26e2e82b6289807ad8a0607b310eef6 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 6 Sep 2019 22:51:27 -0300 Subject: Rewrote large part of rendering, omni and spot shadows now work. --- core/math/camera_matrix.cpp | 22 ++++++++++++++++++++++ core/math/camera_matrix.h | 1 + 2 files changed, 23 insertions(+) (limited to 'core/math') diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index 9018a78c57..070616f061 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -512,6 +512,28 @@ CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const { return new_matrix; } +void CameraMatrix::set_depth_correction() { + + real_t *m = &matrix[0][0]; + + m[0] = 1; + m[1] = 0.0; + m[2] = 0.0; + m[3] = 0.0; + m[4] = 0.0; + m[5] = -1; + m[6] = 0.0; + m[7] = 0.0; + m[8] = 0.0; + m[9] = 0.0; + m[10] = 0.5; + m[11] = 0.0; + m[12] = 0.0; + m[13] = 0.0; + m[14] = 0.5; + m[15] = 1.0; +} + void CameraMatrix::set_light_bias() { real_t *m = &matrix[0][0]; diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index a7a85fee8d..2a25109367 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -50,6 +50,7 @@ struct CameraMatrix { void set_identity(); void set_zero(); void set_light_bias(); + void set_depth_correction(); void set_light_atlas_rect(const Rect2 &p_rect); void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov = false); void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov, int p_eye, real_t p_intraocular_dist, real_t p_convergence_dist); -- cgit v1.2.3 From 9d7b7f931b6924399903e4954a0c32d59c15d4c3 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 9 Sep 2019 17:50:51 -0300 Subject: Reflection probes working --- core/math/camera_matrix.cpp | 4 ++-- core/math/camera_matrix.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'core/math') diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index 070616f061..9e2d10c1f6 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -512,7 +512,7 @@ CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const { return new_matrix; } -void CameraMatrix::set_depth_correction() { +void CameraMatrix::set_depth_correction(bool p_flip_y) { real_t *m = &matrix[0][0]; @@ -521,7 +521,7 @@ void CameraMatrix::set_depth_correction() { m[2] = 0.0; m[3] = 0.0; m[4] = 0.0; - m[5] = -1; + m[5] = p_flip_y ? -1 : 1; m[6] = 0.0; m[7] = 0.0; m[8] = 0.0; diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index 2a25109367..b5c75ca562 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -50,7 +50,7 @@ struct CameraMatrix { void set_identity(); void set_zero(); void set_light_bias(); - void set_depth_correction(); + void set_depth_correction(bool p_flip_y = true); void set_light_atlas_rect(const Rect2 &p_rect); void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov = false); void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov, int p_eye, real_t p_intraocular_dist, real_t p_convergence_dist); -- cgit v1.2.3 From acf0f6c8a7955517ef71ec95c683a6ff7bd5f437 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 3 Oct 2019 17:39:08 -0300 Subject: GIProbes working. --- core/math/vector3.h | 10 ++ core/math/vector3i.cpp | 25 +++++ core/math/vector3i.h | 242 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 277 insertions(+) create mode 100644 core/math/vector3i.cpp create mode 100644 core/math/vector3i.h (limited to 'core/math') diff --git a/core/math/vector3.h b/core/math/vector3.h index 4ad3017109..3bf8644af9 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -32,6 +32,7 @@ #define VECTOR3_H #include "core/math/math_funcs.h" +#include "core/math/vector3i.h" #include "core/ustring.h" class Basis; @@ -147,6 +148,15 @@ struct Vector3 { _FORCE_INLINE_ bool operator>=(const Vector3 &p_v) const; operator String() const; + _FORCE_INLINE_ operator Vector3i() const { + return Vector3i(x, y, z); + } + + _FORCE_INLINE_ Vector3(const Vector3i &p_ivec) { + x = p_ivec.x; + y = p_ivec.y; + z = p_ivec.z; + } _FORCE_INLINE_ Vector3(real_t p_x, real_t p_y, real_t p_z) { x = p_x; diff --git a/core/math/vector3i.cpp b/core/math/vector3i.cpp new file mode 100644 index 0000000000..d5e05c1398 --- /dev/null +++ b/core/math/vector3i.cpp @@ -0,0 +1,25 @@ +#include "vector3i.h" + +void Vector3i::set_axis(int p_axis, int32_t p_value) { + ERR_FAIL_INDEX(p_axis, 3); + coord[p_axis] = p_value; +} +int32_t Vector3i::get_axis(int p_axis) const { + + ERR_FAIL_INDEX_V(p_axis, 3, 0); + return operator[](p_axis); +} + +int Vector3i::min_axis() const { + + return x < y ? (x < z ? 0 : 2) : (y < z ? 1 : 2); +} +int Vector3i::max_axis() const { + + return x < y ? (y < z ? 2 : 1) : (x < z ? 2 : 0); +} + +Vector3i::operator String() const { + + return (itos(x) + ", " + itos(y) + ", " + itos(z)); +} diff --git a/core/math/vector3i.h b/core/math/vector3i.h new file mode 100644 index 0000000000..cb2e2bdd2d --- /dev/null +++ b/core/math/vector3i.h @@ -0,0 +1,242 @@ +#ifndef VECTOR3I_H +#define VECTOR3I_H + +#include "core/typedefs.h" +#include "core/ustring.h" + +struct Vector3i { + + enum Axis { + AXIS_X, + AXIS_Y, + AXIS_Z, + }; + + union { + struct { + int32_t x; + int32_t y; + int32_t z; + }; + + int32_t coord[3]; + }; + + _FORCE_INLINE_ const int32_t &operator[](int p_axis) const { + + return coord[p_axis]; + } + + _FORCE_INLINE_ int32_t &operator[](int p_axis) { + + return coord[p_axis]; + } + + void set_axis(int p_axis, int32_t p_value); + int32_t get_axis(int p_axis) const; + + int min_axis() const; + int max_axis() const; + + _FORCE_INLINE_ void zero(); + + _FORCE_INLINE_ Vector3i abs() const; + _FORCE_INLINE_ Vector3i sign() const; + + /* Operators */ + + _FORCE_INLINE_ Vector3i &operator+=(const Vector3i &p_v); + _FORCE_INLINE_ Vector3i operator+(const Vector3i &p_v) const; + _FORCE_INLINE_ Vector3i &operator-=(const Vector3i &p_v); + _FORCE_INLINE_ Vector3i operator-(const Vector3i &p_v) const; + _FORCE_INLINE_ Vector3i &operator*=(const Vector3i &p_v); + _FORCE_INLINE_ Vector3i operator*(const Vector3i &p_v) const; + _FORCE_INLINE_ Vector3i &operator/=(const Vector3i &p_v); + _FORCE_INLINE_ Vector3i operator/(const Vector3i &p_v) const; + + _FORCE_INLINE_ Vector3i &operator*=(int32_t p_scalar); + _FORCE_INLINE_ Vector3i operator*(int32_t p_scalar) const; + _FORCE_INLINE_ Vector3i &operator/=(int32_t p_scalar); + _FORCE_INLINE_ Vector3i operator/(int32_t p_scalar) const; + + _FORCE_INLINE_ Vector3i operator-() const; + + _FORCE_INLINE_ bool operator==(const Vector3i &p_v) const; + _FORCE_INLINE_ bool operator!=(const Vector3i &p_v) const; + _FORCE_INLINE_ bool operator<(const Vector3i &p_v) const; + _FORCE_INLINE_ bool operator<=(const Vector3i &p_v) const; + _FORCE_INLINE_ bool operator>(const Vector3i &p_v) const; + _FORCE_INLINE_ bool operator>=(const Vector3i &p_v) const; + + operator String() const; + + _FORCE_INLINE_ Vector3i(int32_t p_x, int32_t p_y, int32_t p_z) { + x = p_x; + y = p_y; + z = p_z; + } + _FORCE_INLINE_ Vector3i() { x = y = z = 0; } +}; + +Vector3i Vector3i::abs() const { + + return Vector3i(ABS(x), ABS(y), ABS(z)); +} + +Vector3i Vector3i::sign() const { + + return Vector3i(SGN(x), SGN(y), SGN(z)); +} + +/* Operators */ + +Vector3i &Vector3i::operator+=(const Vector3i &p_v) { + + x += p_v.x; + y += p_v.y; + z += p_v.z; + return *this; +} + +Vector3i Vector3i::operator+(const Vector3i &p_v) const { + + return Vector3i(x + p_v.x, y + p_v.y, z + p_v.z); +} + +Vector3i &Vector3i::operator-=(const Vector3i &p_v) { + + x -= p_v.x; + y -= p_v.y; + z -= p_v.z; + return *this; +} +Vector3i Vector3i::operator-(const Vector3i &p_v) const { + + return Vector3i(x - p_v.x, y - p_v.y, z - p_v.z); +} + +Vector3i &Vector3i::operator*=(const Vector3i &p_v) { + + x *= p_v.x; + y *= p_v.y; + z *= p_v.z; + return *this; +} +Vector3i Vector3i::operator*(const Vector3i &p_v) const { + + return Vector3i(x * p_v.x, y * p_v.y, z * p_v.z); +} + +Vector3i &Vector3i::operator/=(const Vector3i &p_v) { + + x /= p_v.x; + y /= p_v.y; + z /= p_v.z; + return *this; +} + +Vector3i Vector3i::operator/(const Vector3i &p_v) const { + + return Vector3i(x / p_v.x, y / p_v.y, z / p_v.z); +} + +Vector3i &Vector3i::operator*=(int32_t p_scalar) { + + x *= p_scalar; + y *= p_scalar; + z *= p_scalar; + return *this; +} + +_FORCE_INLINE_ Vector3i operator*(int32_t p_scalar, const Vector3i &p_vec) { + + return p_vec * p_scalar; +} + +Vector3i Vector3i::operator*(int32_t p_scalar) const { + + return Vector3i(x * p_scalar, y * p_scalar, z * p_scalar); +} + +Vector3i &Vector3i::operator/=(int32_t p_scalar) { + + x /= p_scalar; + y /= p_scalar; + z /= p_scalar; + return *this; +} + +Vector3i Vector3i::operator/(int32_t p_scalar) const { + + return Vector3i(x / p_scalar, y / p_scalar, z / p_scalar); +} + +Vector3i Vector3i::operator-() const { + + return Vector3i(-x, -y, -z); +} + +bool Vector3i::operator==(const Vector3i &p_v) const { + + return (x == p_v.x && y == p_v.y && z == p_v.z); +} + +bool Vector3i::operator!=(const Vector3i &p_v) const { + + return (x != p_v.x || y == p_v.y || z == p_v.z); +} + +bool Vector3i::operator<(const Vector3i &p_v) const { + + if (x == p_v.x) { + if (y == p_v.y) + return z < p_v.z; + else + return y < p_v.y; + } else { + return x < p_v.x; + } +} + +bool Vector3i::operator>(const Vector3i &p_v) const { + + if (x == p_v.x) { + if (y == p_v.y) + return z > p_v.z; + else + return y > p_v.y; + } else { + return x > p_v.x; + } +} + +bool Vector3i::operator<=(const Vector3i &p_v) const { + + if (x == p_v.x) { + if (y == p_v.y) + return z <= p_v.z; + else + return y < p_v.y; + } else { + return x < p_v.x; + } +} + +bool Vector3i::operator>=(const Vector3i &p_v) const { + + if (x == p_v.x) { + if (y == p_v.y) + return z >= p_v.z; + else + return y > p_v.y; + } else { + return x > p_v.x; + } +} + +void Vector3i::zero() { + + x = y = z = 0; +} + +#endif // VECTOR3I_H -- cgit v1.2.3 From 26318f3bd1b9fa9c7b7708cbef95b4cee56f1718 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sat, 5 Oct 2019 10:30:13 +0300 Subject: Fix Vector3 ambiguities and out of bounds init. --- core/math/vector3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/math') diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index 71ff79c0fc..353b2acd16 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -103,7 +103,7 @@ Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, Vector3 out; out = 0.5 * ((p1 * 2.0) + (-p0 + p2) * t + - (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + + (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); return out; } @@ -122,7 +122,7 @@ Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, c Vector3 out; out = 0.5 * ((p1 * 2.0) + (-p0 + p2) * t + - (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + + (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); return out; } -- cgit v1.2.3 From da0457fa29e1ea63f89b1e1d73e72c4dc80a9966 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 31 Oct 2019 19:54:21 -0300 Subject: Several fixes to GIProbes --- core/math/vector3i.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/math') diff --git a/core/math/vector3i.h b/core/math/vector3i.h index cb2e2bdd2d..dac713502d 100644 --- a/core/math/vector3i.h +++ b/core/math/vector3i.h @@ -183,7 +183,7 @@ bool Vector3i::operator==(const Vector3i &p_v) const { bool Vector3i::operator!=(const Vector3i &p_v) const { - return (x != p_v.x || y == p_v.y || z == p_v.z); + return (x != p_v.x || y != p_v.y || z != p_v.z); } bool Vector3i::operator<(const Vector3i &p_v) const { -- cgit v1.2.3 From fff4240bb43a9e5680017087def8b884a23ff657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 5 Nov 2019 12:01:00 +0100 Subject: Fix code formatting issues and VS compilation Also temporarily disable multicheck build so that we get a full build even when there are style issues on Vulkan. Fixes #33356. --- core/math/vector3i.cpp | 30 ++++++++++++++++++++++++++++++ core/math/vector3i.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) (limited to 'core/math') diff --git a/core/math/vector3i.cpp b/core/math/vector3i.cpp index d5e05c1398..6ddebc4a07 100644 --- a/core/math/vector3i.cpp +++ b/core/math/vector3i.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* vector3i.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + #include "vector3i.h" void Vector3i::set_axis(int p_axis, int32_t p_value) { diff --git a/core/math/vector3i.h b/core/math/vector3i.h index dac713502d..4b13864f78 100644 --- a/core/math/vector3i.h +++ b/core/math/vector3i.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* vector3i.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + #ifndef VECTOR3I_H #define VECTOR3I_H -- cgit v1.2.3 From ee1e89f8c0dc4659a2ed4b5afd5e7c1c596f7af1 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 21 Jan 2020 14:24:22 -0300 Subject: Modified rendering to use cluster instead of foward --- core/math/basis.cpp | 12 ++++++++++++ core/math/basis.h | 3 +++ core/math/camera_matrix.cpp | 30 ++++++++++++++++++++++++++++++ core/math/camera_matrix.h | 16 ++++++++++++++++ 4 files changed, 61 insertions(+) (limited to 'core/math') diff --git a/core/math/basis.cpp b/core/math/basis.cpp index ddf5f13d55..14079f811d 100644 --- a/core/math/basis.cpp +++ b/core/math/basis.cpp @@ -244,6 +244,18 @@ void Basis::scale_local(const Vector3 &p_scale) { *this = scaled_local(p_scale); } +float Basis::get_uniform_scale() const { + return (elements[0].length() + elements[1].length() + elements[2].length()) / 3.0; +} + +void Basis::make_scale_uniform() { + float l = (elements[0].length() + elements[1].length() + elements[2].length()) / 3.0; + for (int i = 0; i < 3; i++) { + elements[i].normalize(); + elements[i] *= l; + } +} + Basis Basis::scaled_local(const Vector3 &p_scale) const { Basis b; b.set_diagonal(p_scale); diff --git a/core/math/basis.h b/core/math/basis.h index 6c3a939d70..0261cf67c6 100644 --- a/core/math/basis.h +++ b/core/math/basis.h @@ -108,6 +108,9 @@ public: void scale_local(const Vector3 &p_scale); Basis scaled_local(const Vector3 &p_scale) const; + void make_scale_uniform(); + float get_uniform_scale() const; + Vector3 get_scale() const; Vector3 get_scale_abs() const; Vector3 get_scale_local() const; diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index 9e2d10c1f6..c4981b954b 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -276,6 +276,36 @@ Vector2 CameraMatrix::get_viewport_half_extents() const { return Vector2(res.x, res.y); } +void CameraMatrix::get_far_plane_size(real_t &r_width, real_t &r_height) const { + + const real_t *matrix = (const real_t *)this->matrix; + ///////--- Far Plane ---/////// + Plane far_plane = Plane(matrix[3] - matrix[2], + matrix[7] - matrix[6], + matrix[11] - matrix[10], + -matrix[15] + matrix[14]); + far_plane.normalize(); + + ///////--- Right Plane ---/////// + Plane right_plane = Plane(matrix[3] - matrix[0], + matrix[7] - matrix[4], + matrix[11] - matrix[8], + -matrix[15] + matrix[12]); + right_plane.normalize(); + + Plane top_plane = Plane(matrix[3] - matrix[1], + matrix[7] - matrix[5], + matrix[11] - matrix[9], + -matrix[15] + matrix[13]); + top_plane.normalize(); + + Vector3 res; + far_plane.intersect_3(right_plane, top_plane, &res); + + r_width = res.x; + r_height = res.y; +} + bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8points) const { Vector planes = get_projection_planes(Transform()); diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index b5c75ca562..60f7d15974 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -75,6 +75,7 @@ struct CameraMatrix { bool get_endpoints(const Transform &p_transform, Vector3 *p_8points) const; Vector2 get_viewport_half_extents() const; + void get_far_plane_size(real_t &r_width, real_t &r_height) const; void invert(); CameraMatrix inverse() const; @@ -93,6 +94,21 @@ struct CameraMatrix { void flip_y(); + bool operator==(const CameraMatrix &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]) { + return false; + } + } + } + return true; + } + + bool operator!=(const CameraMatrix &p_cam) const { + return !(*this == p_cam); + } + CameraMatrix(); CameraMatrix(const Transform &p_transform); ~CameraMatrix(); -- cgit v1.2.3 From db81928e08cb58d5f67908c6dfcf9433e572ffe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 11 Feb 2020 14:01:43 +0100 Subject: Vulkan: Move thirdparty code out of drivers, style fixes - `vk_enum_string_helper.h` is a generated file taken from the SDK (Vulkan-ValidationLayers). - `vk_mem_alloc.h` is a library from GPUOpen: https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator --- core/math/vector3i.cpp | 4 ++-- core/math/vector3i.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'core/math') diff --git a/core/math/vector3i.cpp b/core/math/vector3i.cpp index 6ddebc4a07..8a4ddf03b9 100644 --- a/core/math/vector3i.cpp +++ b/core/math/vector3i.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/vector3i.h b/core/math/vector3i.h index 4b13864f78..6f9754d3b9 100644 --- a/core/math/vector3i.h +++ b/core/math/vector3i.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ -- cgit v1.2.3