diff options
-rw-r--r-- | core/io/http_client_tcp.cpp | 1 | ||||
-rw-r--r-- | doc/classes/Node3D.xml | 1 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs | 37 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs | 35 | ||||
-rw-r--r-- | modules/websocket/wsl_peer.cpp | 4 | ||||
-rw-r--r-- | thirdparty/enet/godot.cpp | 2 |
6 files changed, 53 insertions, 27 deletions
diff --git a/core/io/http_client_tcp.cpp b/core/io/http_client_tcp.cpp index 3788fa501e..2f45238951 100644 --- a/core/io/http_client_tcp.cpp +++ b/core/io/http_client_tcp.cpp @@ -60,6 +60,7 @@ Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, Ref<TLSOp } ERR_FAIL_COND_V(tls_options.is_valid() && tls_options->is_server(), ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V_MSG(tls_options.is_valid() && !StreamPeerTLS::is_available(), ERR_UNAVAILABLE, "HTTPS is not available in this build."); ERR_FAIL_COND_V(conn_host.length() < HOST_MIN_LEN, ERR_INVALID_PARAMETER); if (conn_port < 0) { diff --git a/doc/classes/Node3D.xml b/doc/classes/Node3D.xml index 27cb3915ee..b4857bacde 100644 --- a/doc/classes/Node3D.xml +++ b/doc/classes/Node3D.xml @@ -7,6 +7,7 @@ Most basic 3D game object, with a [Transform3D] and visibility settings. All other 3D game objects inherit from Node3D. Use [Node3D] as a parent node to move, scale, rotate and show/hide children in a 3D project. Affine operations (rotate, scale, translate) happen in parent's local coordinate system, unless the [Node3D] object is set as top-level. Affine operations in this coordinate system correspond to direct affine operations on the [Node3D]'s transform. The word local below refers to this coordinate system. The coordinate system that is attached to the [Node3D] object itself is referred to as object-local coordinate system. [b]Note:[/b] Unless otherwise specified, all methods that have angle parameters must have angles specified as [i]radians[/i]. To convert degrees to radians, use [method @GlobalScope.deg_to_rad]. + [b]Note:[/b] Be aware that "Spatial" nodes are now called "Node3D" starting with Godot 4. Any Godot 3.x references to "Spatial" nodes refer to "Node3D" in Godot 4. </description> <tutorials> <link title="Introduction to 3D">$DOCS_URL/tutorials/3d/introduction_to_3d.html</link> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs index ca963cbf4f..36f5d8e2ab 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs @@ -613,6 +613,43 @@ namespace Godot } /// <summary> + /// Creates a <see cref="Basis"/> with a rotation such that the forward + /// axis (-Z) points towards the <paramref name="target"/> position. + /// The up axis (+Y) points as close to the <paramref name="up"/> vector + /// as possible while staying perpendicular to the forward axis. + /// The resulting Basis is orthonormalized. + /// The <paramref name="target"/> and <paramref name="up"/> vectors + /// cannot be zero, and cannot be parallel to each other. + /// </summary> + /// <param name="target">The position to look at.</param> + /// <param name="up">The relative up direction.</param> + /// <returns>The resulting basis matrix.</returns> + public static Basis LookingAt(Vector3 target, Vector3 up) + { +#if DEBUG + if (target.IsZeroApprox()) + { + throw new ArgumentException("The vector can't be zero.", nameof(target)); + } + if (up.IsZeroApprox()) + { + throw new ArgumentException("The vector can't be zero.", nameof(up)); + } +#endif + Vector3 column2 = -target.Normalized(); + Vector3 column0 = up.Cross(column2); +#if DEBUG + if (column0.IsZeroApprox()) + { + throw new ArgumentException("The target vector and up vector can't be parallel to each other."); + } +#endif + column0.Normalize(); + Vector3 column1 = column2.Cross(column0); + return new Basis(column0, column1, column2); + } + + /// <summary> /// Returns the orthonormalized version of the basis matrix (useful to /// call occasionally to avoid rounding errors for orthogonal matrices). /// This performs a Gram-Schmidt orthonormalization on the basis of the matrix. diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs index b34e95c04d..1e2aaa299f 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs @@ -164,14 +164,14 @@ namespace Godot } /// <summary> - /// Returns a copy of the transform rotated such that its - /// -Z axis (forward) points towards the <paramref name="target"/> position. - /// - /// The transform will first be rotated around the given <paramref name="up"/> vector, - /// and then fully aligned to the <paramref name="target"/> by a further rotation around - /// an axis perpendicular to both the <paramref name="target"/> and <paramref name="up"/> vectors. - /// - /// Operations take place in global space. + /// Returns a copy of the transform rotated such that the forward axis (-Z) + /// points towards the <paramref name="target"/> position. + /// The up axis (+Y) points as close to the <paramref name="up"/> vector + /// as possible while staying perpendicular to the forward axis. + /// The resulting transform is orthonormalized. + /// The existing rotation, scale, and skew information from the original transform is discarded. + /// The <paramref name="target"/> and <paramref name="up"/> vectors cannot be zero, + /// cannot be parallel to each other, and are defined in global/parent space. /// </summary> /// <param name="target">The object to look at.</param> /// <param name="up">The relative up direction.</param> @@ -249,24 +249,7 @@ namespace Godot private void SetLookAt(Vector3 eye, Vector3 target, Vector3 up) { - // Make rotation matrix - // Z vector - Vector3 column2 = eye - target; - - column2.Normalize(); - - Vector3 column1 = up; - - Vector3 column0 = column1.Cross(column2); - - // Recompute Y = Z cross X - column1 = column2.Cross(column0); - - column0.Normalize(); - column1.Normalize(); - - Basis = new Basis(column0, column1, column2); - + Basis = Basis.LookingAt(target - eye, up); Origin = eye; } diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp index 816d5276b9..109d5102c3 100644 --- a/modules/websocket/wsl_peer.cpp +++ b/modules/websocket/wsl_peer.cpp @@ -332,7 +332,7 @@ void WSLPeer::_do_client_handshake() { if (connection == tcp) { // Start SSL handshake tls = Ref<StreamPeerTLS>(StreamPeerTLS::create()); - ERR_FAIL_COND_MSG(tls.is_null(), "SSL is not available in this build."); + ERR_FAIL_COND(tls.is_null()); if (tls->connect_to_stream(tcp, requested_host, tls_options) != OK) { close(-1); return; // Error. @@ -501,6 +501,8 @@ Error WSLPeer::connect_to_url(const String &p_url, Ref<TLSOptions> p_options) { path = "/"; } + ERR_FAIL_COND_V_MSG(use_tls && !StreamPeerTLS::is_available(), ERR_UNAVAILABLE, "WSS is not available in this build."); + requested_url = p_url; requested_host = host; diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp index ea7f4957a2..2cbfe59fc6 100644 --- a/thirdparty/enet/godot.cpp +++ b/thirdparty/enet/godot.cpp @@ -436,6 +436,7 @@ ENetSocket enet_socket_create(ENetSocketType type) { } int enet_host_dtls_server_setup(ENetHost *host, void *p_options) { + ERR_FAIL_COND_V_MSG(!DTLSServer::is_available(), -1, "DTLS server is not available in this build."); ENetGodotSocket *sock = (ENetGodotSocket *)host->socket; if (!sock->can_upgrade()) { return -1; @@ -446,6 +447,7 @@ int enet_host_dtls_server_setup(ENetHost *host, void *p_options) { } int enet_host_dtls_client_setup(ENetHost *host, const char *p_for_hostname, void *p_options) { + ERR_FAIL_COND_V_MSG(!PacketPeerDTLS::is_available(), -1, "DTLS is not available in this build."); ENetGodotSocket *sock = (ENetGodotSocket *)host->socket; if (!sock->can_upgrade()) { return -1; |