summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/display_server.cpp5
-rw-r--r--servers/display_server.h1
-rw-r--r--servers/physics_3d/godot_shape_3d.cpp28
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp4
-rw-r--r--servers/rendering/renderer_rd/shaders/light_data_inc.glsl4
-rw-r--r--servers/rendering/rendering_device.cpp2
-rw-r--r--servers/rendering/rendering_server_default.h1
-rw-r--r--servers/rendering/shader_types.cpp1
-rw-r--r--servers/rendering_server.cpp15
-rw-r--r--servers/rendering_server.h2
-rw-r--r--servers/xr/xr_pose.cpp16
-rw-r--r--servers/xr/xr_pose.h13
-rw-r--r--servers/xr/xr_positional_tracker.cpp5
-rw-r--r--servers/xr/xr_positional_tracker.h2
14 files changed, 67 insertions, 32 deletions
diff --git a/servers/display_server.cpp b/servers/display_server.cpp
index eb12b5ffc0..d4ff42bc34 100644
--- a/servers/display_server.cpp
+++ b/servers/display_server.cpp
@@ -155,6 +155,10 @@ String DisplayServer::clipboard_get() const {
ERR_FAIL_V_MSG(String(), "Clipboard is not supported by this display server.");
}
+bool DisplayServer::clipboard_has() const {
+ return !clipboard_get().is_empty();
+}
+
void DisplayServer::clipboard_set_primary(const String &p_text) {
WARN_PRINT("Primary clipboard is not supported by this display server.");
}
@@ -359,6 +363,7 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("clipboard_set", "clipboard"), &DisplayServer::clipboard_set);
ClassDB::bind_method(D_METHOD("clipboard_get"), &DisplayServer::clipboard_get);
+ ClassDB::bind_method(D_METHOD("clipboard_has"), &DisplayServer::clipboard_has);
ClassDB::bind_method(D_METHOD("clipboard_set_primary", "clipboard_primary"), &DisplayServer::clipboard_set_primary);
ClassDB::bind_method(D_METHOD("clipboard_get_primary"), &DisplayServer::clipboard_get_primary);
diff --git a/servers/display_server.h b/servers/display_server.h
index 2fb9b5946b..0c2bc5dd3a 100644
--- a/servers/display_server.h
+++ b/servers/display_server.h
@@ -160,6 +160,7 @@ public:
virtual void clipboard_set(const String &p_text);
virtual String clipboard_get() const;
+ virtual bool clipboard_has() const;
virtual void clipboard_set_primary(const String &p_text);
virtual String clipboard_get_primary() const;
diff --git a/servers/physics_3d/godot_shape_3d.cpp b/servers/physics_3d/godot_shape_3d.cpp
index 26fa470233..666e773c1c 100644
--- a/servers/physics_3d/godot_shape_3d.cpp
+++ b/servers/physics_3d/godot_shape_3d.cpp
@@ -52,11 +52,11 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002
-#define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998
+constexpr double edge_support_threshold = 0.0002;
+constexpr double face_support_threshold = 0.9998;
-#define _CYLINDER_EDGE_IS_VALID_SUPPORT_THRESHOLD 0.002
-#define _CYLINDER_FACE_IS_VALID_SUPPORT_THRESHOLD 0.999
+constexpr double cylinder_edge_support_threshold = 0.002;
+constexpr double cylinder_face_support_threshold = 0.999;
void GodotShape3D::configure(const AABB &p_aabb) {
aabb = p_aabb;
@@ -184,7 +184,7 @@ Vector3 GodotSeparationRayShape3D::get_support(const Vector3 &p_normal) const {
}
void GodotSeparationRayShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {
- if (Math::abs(p_normal.z) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
+ if (Math::abs(p_normal.z) < edge_support_threshold) {
r_amount = 2;
r_type = FEATURE_EDGE;
r_supports[0] = Vector3(0, 0, 0);
@@ -335,7 +335,7 @@ void GodotBoxShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *
Vector3 axis;
axis[i] = 1.0;
real_t dot = p_normal.dot(axis);
- if (Math::abs(dot) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
+ if (Math::abs(dot) > face_support_threshold) {
//Vector3 axis_b;
bool neg = dot < 0;
@@ -376,7 +376,7 @@ void GodotBoxShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *
Vector3 axis;
axis[i] = 1.0;
- if (Math::abs(p_normal.dot(axis)) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
+ if (Math::abs(p_normal.dot(axis)) < edge_support_threshold) {
r_amount = 2;
r_type = FEATURE_EDGE;
@@ -522,7 +522,7 @@ void GodotCapsuleShape3D::get_supports(const Vector3 &p_normal, int p_max, Vecto
real_t d = n.y;
- if (Math::abs(d) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
+ if (Math::abs(d) < edge_support_threshold) {
// make it flat
n.y = 0.0;
n.normalize();
@@ -703,7 +703,7 @@ Vector3 GodotCylinderShape3D::get_support(const Vector3 &p_normal) const {
void GodotCylinderShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {
real_t d = p_normal.y;
- if (Math::abs(d) > _CYLINDER_FACE_IS_VALID_SUPPORT_THRESHOLD) {
+ if (Math::abs(d) > cylinder_face_support_threshold) {
real_t h = (d > 0) ? height : -height;
Vector3 n = p_normal;
@@ -718,7 +718,7 @@ void GodotCylinderShape3D::get_supports(const Vector3 &p_normal, int p_max, Vect
r_supports[1].x += radius;
r_supports[2] = n;
r_supports[2].z += radius;
- } else if (Math::abs(d) < _CYLINDER_EDGE_IS_VALID_SUPPORT_THRESHOLD) {
+ } else if (Math::abs(d) < cylinder_edge_support_threshold) {
// make it flat
Vector3 n = p_normal;
n.y = 0.0;
@@ -911,7 +911,7 @@ void GodotConvexPolygonShape3D::get_supports(const Vector3 &p_normal, int p_max,
}
for (int i = 0; i < fc; i++) {
- if (faces[i].plane.normal.dot(p_normal) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
+ if (faces[i].plane.normal.dot(p_normal) > face_support_threshold) {
int ic = faces[i].indices.size();
const int *ind = faces[i].indices.ptr();
@@ -940,7 +940,7 @@ void GodotConvexPolygonShape3D::get_supports(const Vector3 &p_normal, int p_max,
for (int i = 0; i < ec; i++) {
real_t dot = (vertices[edges[i].a] - vertices[edges[i].b]).normalized().dot(p_normal);
dot = ABS(dot);
- if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD && (edges[i].a == vtx || edges[i].b == vtx)) {
+ if (dot < edge_support_threshold && (edges[i].a == vtx || edges[i].b == vtx)) {
r_amount = 2;
r_type = FEATURE_EDGE;
r_supports[0] = vertices[edges[i].a];
@@ -1140,7 +1140,7 @@ void GodotFaceShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3
Vector3 n = p_normal;
/** TEST FACE AS SUPPORT **/
- if (Math::abs(normal.dot(n)) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
+ if (Math::abs(normal.dot(n)) > face_support_threshold) {
r_amount = 3;
r_type = FEATURE_FACE;
for (int i = 0; i < 3; i++) {
@@ -1174,7 +1174,7 @@ void GodotFaceShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3
// check if edge is valid as a support
real_t dot = (vertex[i] - vertex[nx]).normalized().dot(n);
dot = ABS(dot);
- if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
+ if (dot < edge_support_threshold) {
r_amount = 2;
r_type = FEATURE_EDGE;
r_supports[0] = vertex[i];
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index 33f5a178e0..126f40584a 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -514,7 +514,7 @@ Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_ba
ambient_color_sky_mix = env->ambient_sky_contribution;
const float ambient_energy = env->ambient_light_energy;
ambient_color = env->ambient_light;
- ambient_color.to_linear();
+ ambient_color = ambient_color.to_linear();
ambient_color.r *= ambient_energy;
ambient_color.g *= ambient_energy;
ambient_color.b *= ambient_energy;
@@ -533,7 +533,7 @@ Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_ba
} else {
const float bg_energy = env->bg_energy;
Color panorama_color = ((environment_background == RS::ENV_BG_CLEAR_COLOR) ? storage->get_default_clear_color() : env->bg_color);
- panorama_color.to_linear();
+ panorama_color = panorama_color.to_linear();
panorama_color.r *= bg_energy;
panorama_color.g *= bg_energy;
panorama_color.b *= bg_energy;
diff --git a/servers/rendering/renderer_rd/shaders/light_data_inc.glsl b/servers/rendering/renderer_rd/shaders/light_data_inc.glsl
index fdc7729338..52787bb204 100644
--- a/servers/rendering/renderer_rd/shaders/light_data_inc.glsl
+++ b/servers/rendering/renderer_rd/shaders/light_data_inc.glsl
@@ -1,6 +1,6 @@
#define LIGHT_BAKE_DISABLED 0
-#define LIGHT_BAKE_DYNAMIC 1
-#define LIGHT_BAKE_STATIC 2
+#define LIGHT_BAKE_STATIC 1
+#define LIGHT_BAKE_DYNAMIC 2
struct LightData { //this structure needs to be as packed as possible
highp vec3 position;
diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp
index 46fb3c8537..6fc5d0b3e8 100644
--- a/servers/rendering/rendering_device.cpp
+++ b/servers/rendering/rendering_device.cpp
@@ -451,7 +451,7 @@ void RenderingDevice::_bind_methods() {
ClassDB::bind_method(D_METHOD("compute_list_add_barrier", "compute_list"), &RenderingDevice::compute_list_add_barrier);
ClassDB::bind_method(D_METHOD("compute_list_end", "post_barrier"), &RenderingDevice::compute_list_end, DEFVAL(BARRIER_MASK_ALL));
- ClassDB::bind_method(D_METHOD("free", "rid"), &RenderingDevice::free);
+ ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingDevice::free);
ClassDB::bind_method(D_METHOD("capture_timestamp", "name"), &RenderingDevice::capture_timestamp);
ClassDB::bind_method(D_METHOD("get_captured_timestamps_count"), &RenderingDevice::get_captured_timestamps_count);
diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h
index ee684c69ed..54fd897a77 100644
--- a/servers/rendering/rendering_server_default.h
+++ b/servers/rendering/rendering_server_default.h
@@ -259,7 +259,6 @@ public:
command_queue.push(RSG::storage, &RendererStorage::mesh_initialize, mesh);
command_queue.push(RSG::storage, &RendererStorage::mesh_set_blend_shape_count, mesh, p_blend_shape_count);
for (int i = 0; i < p_surfaces.size(); i++) {
- RSG::storage->mesh_add_surface(mesh, p_surfaces[i]);
command_queue.push(RSG::storage, &RendererStorage::mesh_add_surface, mesh, p_surfaces[i]);
}
}
diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp
index 9ae60c14cb..b8bb211a7a 100644
--- a/servers/rendering/shader_types.cpp
+++ b/servers/rendering/shader_types.cpp
@@ -435,7 +435,6 @@ ShaderTypes::ShaderTypes() {
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["OBJECT_POSITION"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["UVW"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["EXTENTS"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["TRANSFORM"] = constt(ShaderLanguage::TYPE_MAT4);
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["SDF"] = constt(ShaderLanguage::TYPE_FLOAT);
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["ALBEDO"] = ShaderLanguage::TYPE_VEC3;
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["DENSITY"] = ShaderLanguage::TYPE_FLOAT;
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 863aae6e4c..84e54eab22 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -1927,8 +1927,8 @@ void RenderingServer::_bind_methods() {
BIND_ENUM_CONSTANT(LIGHT_PARAM_MAX);
BIND_ENUM_CONSTANT(LIGHT_BAKE_DISABLED);
- BIND_ENUM_CONSTANT(LIGHT_BAKE_DYNAMIC);
BIND_ENUM_CONSTANT(LIGHT_BAKE_STATIC);
+ BIND_ENUM_CONSTANT(LIGHT_BAKE_DYNAMIC);
BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DUAL_PARABOLOID);
BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_CUBE);
@@ -2771,13 +2771,14 @@ void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry
const Geometry3D::MeshData::Face &f = p_mesh_data.faces[i];
for (int j = 2; j < f.indices.size(); j++) {
-#define _ADD_VERTEX(m_idx) \
- vertices.push_back(p_mesh_data.vertices[f.indices[m_idx]]); \
- normals.push_back(f.plane.normal);
+ vertices.push_back(p_mesh_data.vertices[f.indices[0]]);
+ normals.push_back(f.plane.normal);
+
+ vertices.push_back(p_mesh_data.vertices[f.indices[j - 1]]);
+ normals.push_back(f.plane.normal);
- _ADD_VERTEX(0);
- _ADD_VERTEX(j - 1);
- _ADD_VERTEX(j);
+ vertices.push_back(p_mesh_data.vertices[f.indices[j]]);
+ normals.push_back(f.plane.normal);
}
}
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index 945fd052c6..b067db3d27 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -447,8 +447,8 @@ public:
enum LightBakeMode {
LIGHT_BAKE_DISABLED,
- LIGHT_BAKE_DYNAMIC,
LIGHT_BAKE_STATIC,
+ LIGHT_BAKE_DYNAMIC,
};
virtual void light_set_bake_mode(RID p_light, LightBakeMode p_bake_mode) = 0;
diff --git a/servers/xr/xr_pose.cpp b/servers/xr/xr_pose.cpp
index 0862fefef5..400f13b9c2 100644
--- a/servers/xr/xr_pose.cpp
+++ b/servers/xr/xr_pose.cpp
@@ -33,6 +33,10 @@
#include "servers/xr_server.h"
void XRPose::_bind_methods() {
+ BIND_ENUM_CONSTANT(XR_TRACKING_CONFIDENCE_NONE);
+ BIND_ENUM_CONSTANT(XR_TRACKING_CONFIDENCE_LOW);
+ BIND_ENUM_CONSTANT(XR_TRACKING_CONFIDENCE_HIGH);
+
ClassDB::bind_method(D_METHOD("set_has_tracking_data", "has_tracking_data"), &XRPose::set_has_tracking_data);
ClassDB::bind_method(D_METHOD("get_has_tracking_data"), &XRPose::get_has_tracking_data);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "has_tracking_data"), "set_has_tracking_data", "get_has_tracking_data");
@@ -53,6 +57,10 @@ void XRPose::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &XRPose::set_angular_velocity);
ClassDB::bind_method(D_METHOD("get_angular_velocity"), &XRPose::get_angular_velocity);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
+
+ ClassDB::bind_method(D_METHOD("set_tracking_confidence", "tracking_confidence"), &XRPose::set_tracking_confidence);
+ ClassDB::bind_method(D_METHOD("get_tracking_confidence"), &XRPose::get_tracking_confidence);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "tracking_confidence"), "set_tracking_confidence", "get_tracking_confidence");
}
void XRPose::set_has_tracking_data(const bool p_has_tracking_data) {
@@ -108,3 +116,11 @@ void XRPose::set_angular_velocity(const Vector3 p_velocity) {
Vector3 XRPose::get_angular_velocity() const {
return angular_velocity;
}
+
+void XRPose::set_tracking_confidence(const XRPose::TrackingConfidence p_tracking_confidence) {
+ tracking_confidence = p_tracking_confidence;
+}
+
+XRPose::TrackingConfidence XRPose::get_tracking_confidence() const {
+ return tracking_confidence;
+}
diff --git a/servers/xr/xr_pose.h b/servers/xr/xr_pose.h
index 8c1fc63360..f306c22390 100644
--- a/servers/xr/xr_pose.h
+++ b/servers/xr/xr_pose.h
@@ -37,12 +37,20 @@ class XRPose : public RefCounted {
GDCLASS(XRPose, RefCounted);
public:
+ // TrackingConfidence gives an indication of how reliable our transform data is.
+ enum TrackingConfidence {
+ XR_TRACKING_CONFIDENCE_NONE, // No tracking information is available for this pose.
+ XR_TRACKING_CONFIDENCE_LOW, // Tracking information may be inaccurate or estimated.
+ XR_TRACKING_CONFIDENCE_HIGH // Tracking information is deemed accurate and up to date.
+ };
+
private:
bool has_tracking_data = false;
StringName name;
Transform3D transform;
Vector3 linear_velocity;
Vector3 angular_velocity;
+ TrackingConfidence tracking_confidence = XR_TRACKING_CONFIDENCE_NONE;
protected:
static void _bind_methods();
@@ -63,6 +71,11 @@ public:
void set_angular_velocity(const Vector3 p_velocity);
Vector3 get_angular_velocity() const;
+
+ void set_tracking_confidence(const TrackingConfidence p_tracking_confidence);
+ TrackingConfidence get_tracking_confidence() const;
};
+VARIANT_ENUM_CAST(XRPose::TrackingConfidence);
+
#endif
diff --git a/servers/xr/xr_positional_tracker.cpp b/servers/xr/xr_positional_tracker.cpp
index 74907a5675..62e011654e 100644
--- a/servers/xr/xr_positional_tracker.cpp
+++ b/servers/xr/xr_positional_tracker.cpp
@@ -56,7 +56,7 @@ void XRPositionalTracker::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_pose", "name"), &XRPositionalTracker::has_pose);
ClassDB::bind_method(D_METHOD("get_pose", "name"), &XRPositionalTracker::get_pose);
ClassDB::bind_method(D_METHOD("invalidate_pose", "name"), &XRPositionalTracker::invalidate_pose);
- ClassDB::bind_method(D_METHOD("set_pose", "name", "transform", "linear_velocity", "angular_velocity"), &XRPositionalTracker::set_pose);
+ ClassDB::bind_method(D_METHOD("set_pose", "name", "transform", "linear_velocity", "angular_velocity", "tracking_confidence"), &XRPositionalTracker::set_pose);
ADD_SIGNAL(MethodInfo("pose_changed", PropertyInfo(Variant::OBJECT, "pose", PROPERTY_HINT_RESOURCE_TYPE, "XRPose")));
ClassDB::bind_method(D_METHOD("get_input", "name"), &XRPositionalTracker::get_input);
@@ -137,7 +137,7 @@ void XRPositionalTracker::invalidate_pose(const StringName &p_action_name) {
}
}
-void XRPositionalTracker::set_pose(const StringName &p_action_name, const Transform3D &p_transform, const Vector3 &p_linear_velocity, const Vector3 &p_angular_velocity) {
+void XRPositionalTracker::set_pose(const StringName &p_action_name, const Transform3D &p_transform, const Vector3 &p_linear_velocity, const Vector3 &p_angular_velocity, const XRPose::TrackingConfidence p_tracking_confidence) {
Ref<XRPose> new_pose;
new_pose.instantiate();
@@ -146,6 +146,7 @@ void XRPositionalTracker::set_pose(const StringName &p_action_name, const Transf
new_pose->set_transform(p_transform);
new_pose->set_linear_velocity(p_linear_velocity);
new_pose->set_angular_velocity(p_angular_velocity);
+ new_pose->set_tracking_confidence(p_tracking_confidence);
poses[p_action_name] = new_pose;
emit_signal("pose_changed", new_pose);
diff --git a/servers/xr/xr_positional_tracker.h b/servers/xr/xr_positional_tracker.h
index 2bcbf2c018..2f358cbb21 100644
--- a/servers/xr/xr_positional_tracker.h
+++ b/servers/xr/xr_positional_tracker.h
@@ -82,7 +82,7 @@ public:
bool has_pose(const StringName &p_action_name) const;
Ref<XRPose> get_pose(const StringName &p_action_name) const;
void invalidate_pose(const StringName &p_action_name);
- void set_pose(const StringName &p_action_name, const Transform3D &p_transform, const Vector3 &p_linear_velocity, const Vector3 &p_angular_velocity);
+ void set_pose(const StringName &p_action_name, const Transform3D &p_transform, const Vector3 &p_linear_velocity, const Vector3 &p_angular_velocity, const XRPose::TrackingConfidence p_tracking_confidence = XRPose::XR_TRACKING_CONFIDENCE_HIGH);
Variant get_input(const StringName &p_action_name) const;
void set_input(const StringName &p_action_name, const Variant &p_value);