summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/bullet/rigid_body_bullet.cpp11
-rw-r--r--modules/csg/csg.cpp26
-rw-r--r--modules/gdscript/gdscript_editor.cpp2
-rw-r--r--modules/gltf/gltf_document.cpp5
-rw-r--r--modules/gridmap/grid_map.cpp5
-rw-r--r--modules/mono/csharp_script.cpp4
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs4
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.cpp8
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.h4
-rw-r--r--modules/navigation/nav_map.cpp4
10 files changed, 32 insertions, 41 deletions
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index b511c5f8d8..7b20fad28c 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -530,26 +530,23 @@ void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) {
can_integrate_forces = false;
destroy_kinematic_utilities();
// The mode change is relevant to its mass
+ mode = p_mode;
switch (p_mode) {
case PhysicsServer3D::BODY_MODE_KINEMATIC:
- mode = PhysicsServer3D::BODY_MODE_KINEMATIC;
reload_axis_lock();
_internal_set_mass(0);
init_kinematic_utilities();
break;
case PhysicsServer3D::BODY_MODE_STATIC:
- mode = PhysicsServer3D::BODY_MODE_STATIC;
reload_axis_lock();
_internal_set_mass(0);
break;
case PhysicsServer3D::BODY_MODE_DYNAMIC:
- mode = PhysicsServer3D::BODY_MODE_DYNAMIC;
reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
break;
- case PhysicsServer3D::MODE_DYNAMIC_LOCKED:
- mode = PhysicsServer3D::MODE_DYNAMIC_LOCKED;
+ case PhysicsServer3D::MODE_DYNAMIC_LINEAR:
reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
@@ -722,7 +719,7 @@ bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
void RigidBodyBullet::reload_axis_lock() {
btBody->setLinearFactor(btVector3(btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z))));
- if (PhysicsServer3D::MODE_DYNAMIC_LOCKED == mode) {
+ if (PhysicsServer3D::MODE_DYNAMIC_LINEAR == mode) {
/// When character angular is always locked
btBody->setAngularFactor(btVector3(0., 0., 0.));
} else {
@@ -1017,7 +1014,7 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
// Rigidbody is dynamic if and only if mass is non Zero, otherwise static
const bool isDynamic = p_mass != 0.f;
if (isDynamic) {
- if (PhysicsServer3D::BODY_MODE_DYNAMIC != mode && PhysicsServer3D::MODE_DYNAMIC_LOCKED != mode) {
+ if (PhysicsServer3D::BODY_MODE_DYNAMIC != mode && PhysicsServer3D::MODE_DYNAMIC_LINEAR != mode) {
return;
}
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index f7e92aaa90..229e1e2724 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -37,16 +37,16 @@
// Static helper functions.
inline static bool is_snapable(const Vector3 &p_point1, const Vector3 &p_point2, real_t p_distance) {
- return (p_point1 - p_point2).length_squared() < p_distance * p_distance;
+ return p_point2.distance_squared_to(p_point1) < p_distance * p_distance;
}
inline static Vector2 interpolate_segment_uv(const Vector2 p_segment_points[2], const Vector2 p_uvs[2], const Vector2 &p_interpolation_point) {
- float segment_length = (p_segment_points[1] - p_segment_points[0]).length();
if (p_segment_points[0].is_equal_approx(p_segment_points[1])) {
return p_uvs[0];
}
- float distance = (p_interpolation_point - p_segment_points[0]).length();
+ float segment_length = p_segment_points[0].distance_to(p_segment_points[1]);
+ float distance = p_segment_points[0].distance_to(p_interpolation_point);
float fraction = distance / segment_length;
return p_uvs[0].lerp(p_uvs[1], fraction);
@@ -596,7 +596,7 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de
_add_distance(intersectionsA, intersectionsB, current_face.from_b, 0);
}
} else if (ray_intersects_triangle(face_center, face_normal, current_points, CMP_EPSILON, intersection_point)) {
- real_t distance = (intersection_point - face_center).length();
+ real_t distance = face_center.distance_to(intersection_point);
_add_distance(intersectionsA, intersectionsB, current_face.from_b, distance);
}
}
@@ -781,7 +781,7 @@ void CSGBrushOperation::MeshMerge::add_face(const Vector3 p_points[], const Vect
int CSGBrushOperation::Build2DFaces::_get_point_idx(const Vector2 &p_point) {
for (int vertex_idx = 0; vertex_idx < vertices.size(); ++vertex_idx) {
- if ((p_point - vertices[vertex_idx].point).length_squared() < vertex_snap2) {
+ if (vertices[vertex_idx].point.distance_squared_to(p_point) < vertex_snap2) {
return vertex_idx;
}
}
@@ -961,7 +961,7 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_
// Check if point is existing face vertex.
bool existing = false;
for (int i = 0; i < 3; ++i) {
- if ((point_2D - face_vertices[i].point).length_squared() < vertex_snap2) {
+ if (face_vertices[i].point.distance_squared_to(point_2D) < vertex_snap2) {
existing = true;
break;
}
@@ -978,7 +978,7 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_
};
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(point_2D, edge_points);
- if ((closest_point - point_2D).length_squared() < vertex_snap2) {
+ if (point_2D.distance_squared_to(closest_point) < vertex_snap2) {
int opposite_vertex_idx = face.vertex_idx[(face_edge_idx + 2) % 3];
// If new vertex snaps to degenerate vertex, just delete this face.
@@ -1041,7 +1041,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
bool on_edge = false;
for (int edge_point_idx = 0; edge_point_idx < 2; ++edge_point_idx) {
intersection_point = Geometry2D::get_closest_point_to_segment(p_segment_points[edge_point_idx], edge_points);
- if ((intersection_point - p_segment_points[edge_point_idx]).length_squared() < vertex_snap2) {
+ if (p_segment_points[edge_point_idx].distance_squared_to(intersection_point) < vertex_snap2) {
on_edge = true;
break;
}
@@ -1050,8 +1050,8 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
// Else check if the segment intersects the edge.
if (on_edge || Geometry2D::segment_intersects_segment(p_segment_points[0], p_segment_points[1], edge_points[0], edge_points[1], &intersection_point)) {
// Check if intersection point is an edge point.
- if ((intersection_point - edge_points[0]).length_squared() < vertex_snap2 ||
- (intersection_point - edge_points[1]).length_squared() < vertex_snap2) {
+ if ((edge_points[0].distance_squared_to(intersection_point) < vertex_snap2) ||
+ (edge_points[1].distance_squared_to(intersection_point) < vertex_snap2)) {
continue;
}
@@ -1078,7 +1078,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
// If opposite point is on the segment, add its index to segment indices too.
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(vertices[opposite_vertex_idx].point, p_segment_points);
- if ((closest_point - vertices[opposite_vertex_idx].point).length_squared() < vertex_snap2) {
+ if (vertices[opposite_vertex_idx].point.distance_squared_to(closest_point) < vertex_snap2) {
_add_vertex_idx_sorted(r_segment_indices, opposite_vertex_idx);
}
@@ -1132,7 +1132,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) {
// Check if point is existing face vertex.
for (int i = 0; i < 3; ++i) {
- if ((p_point - face_vertices[i].point).length_squared() < vertex_snap2) {
+ if (face_vertices[i].point.distance_squared_to(p_point) < vertex_snap2) {
return face.vertex_idx[i];
}
}
@@ -1150,7 +1150,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) {
};
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, edge_points);
- if ((closest_point - p_point).length_squared() < vertex_snap2) {
+ if (p_point.distance_squared_to(closest_point) < vertex_snap2) {
on_edge = true;
// Add the point as a new vertex.
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 2f8a054b2a..044ac4b661 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -637,7 +637,7 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String
}
static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, Map<String, ScriptCodeCompletionOption> &r_result) {
- if (p_annotation->name == "@export_range" || p_annotation->name == "@export_exp_range") {
+ if (p_annotation->name == "@export_range") {
if (p_argument == 3 || p_argument == 4) {
// Slider hint.
ScriptCodeCompletionOption slider1("or_greater", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 97367b15df..a92eb88edb 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -3757,10 +3757,7 @@ void GLTFDocument::spec_gloss_to_metal_base_color(const Color &p_specular_factor
r_base_color.g = Math::lerp(base_color_from_diffuse.g, base_color_from_specular.g, r_metallic * r_metallic);
r_base_color.b = Math::lerp(base_color_from_diffuse.b, base_color_from_specular.b, r_metallic * r_metallic);
r_base_color.a = p_diffuse.a;
- r_base_color.r = CLAMP(r_base_color.r, 0.0f, 1.0f);
- r_base_color.g = CLAMP(r_base_color.g, 0.0f, 1.0f);
- r_base_color.b = CLAMP(r_base_color.b, 0.0f, 1.0f);
- r_base_color.a = CLAMP(r_base_color.a, 0.0f, 1.0f);
+ r_base_color = r_base_color.clamp();
}
GLTFNodeIndex GLTFDocument::_find_highest_node(Ref<GLTFState> state, const Vector<GLTFNodeIndex> &subset) {
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 487e6deac0..116c0e00f9 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -377,10 +377,7 @@ int GridMap::get_cell_item_orientation(const Vector3i &p_position) const {
}
Vector3i GridMap::world_to_map(const Vector3 &p_world_position) const {
- Vector3 map_position = p_world_position / cell_size;
- map_position.x = floor(map_position.x);
- map_position.y = floor(map_position.y);
- map_position.z = floor(map_position.z);
+ Vector3 map_position = (p_world_position / cell_size).floor();
return Vector3i(map_position);
}
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 6cc7ddb424..af7c54dd5b 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -3511,10 +3511,10 @@ int CSharpScript::get_member_line(const StringName &p_member) const {
}
Multiplayer::RPCMode CSharpScript::_member_get_rpc_mode(IMonoClassMember *p_member) const {
- if (p_member->has_attribute(CACHED_CLASS(RemoteAttribute))) {
+ if (p_member->has_attribute(CACHED_CLASS(AnyAttribute))) {
return Multiplayer::RPC_MODE_ANY;
}
- if (p_member->has_attribute(CACHED_CLASS(PuppetAttribute))) {
+ if (p_member->has_attribute(CACHED_CLASS(AuthorityAttribute))) {
return Multiplayer::RPC_MODE_AUTHORITY;
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs
index 2dedba2be3..1da91ea867 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs
@@ -3,8 +3,8 @@ using System;
namespace Godot
{
[AttributeUsage(AttributeTargets.Method)]
- public class RemoteAttribute : Attribute { }
+ public class AnyAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Method)]
- public class PuppetAttribute : Attribute { }
+ public class AuthorityAttribute : Attribute { }
}
diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp
index 8b215a66c2..34e845a589 100644
--- a/modules/mono/mono_gd/gd_mono_cache.cpp
+++ b/modules/mono/mono_gd/gd_mono_cache.cpp
@@ -140,8 +140,8 @@ void CachedData::clear_godot_api_cache() {
field_ExportAttribute_hintString = nullptr;
class_SignalAttribute = nullptr;
class_ToolAttribute = nullptr;
- class_RemoteAttribute = nullptr;
- class_PuppetAttribute = nullptr;
+ class_AnyAttribute = nullptr;
+ class_AuthorityAttribute = nullptr;
class_GodotMethodAttribute = nullptr;
field_GodotMethodAttribute_methodName = nullptr;
class_ScriptPathAttribute = nullptr;
@@ -265,8 +265,8 @@ void update_godot_api_cache() {
CACHE_FIELD_AND_CHECK(ExportAttribute, hintString, CACHED_CLASS(ExportAttribute)->get_field("hintString"));
CACHE_CLASS_AND_CHECK(SignalAttribute, GODOT_API_CLASS(SignalAttribute));
CACHE_CLASS_AND_CHECK(ToolAttribute, GODOT_API_CLASS(ToolAttribute));
- CACHE_CLASS_AND_CHECK(RemoteAttribute, GODOT_API_CLASS(RemoteAttribute));
- CACHE_CLASS_AND_CHECK(PuppetAttribute, GODOT_API_CLASS(PuppetAttribute));
+ CACHE_CLASS_AND_CHECK(AnyAttribute, GODOT_API_CLASS(AnyAttribute));
+ CACHE_CLASS_AND_CHECK(AuthorityAttribute, GODOT_API_CLASS(AuthorityAttribute));
CACHE_CLASS_AND_CHECK(GodotMethodAttribute, GODOT_API_CLASS(GodotMethodAttribute));
CACHE_FIELD_AND_CHECK(GodotMethodAttribute, methodName, CACHED_CLASS(GodotMethodAttribute)->get_field("methodName"));
CACHE_CLASS_AND_CHECK(ScriptPathAttribute, GODOT_API_CLASS(ScriptPathAttribute));
diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h
index fd28bbda14..e60a4d5279 100644
--- a/modules/mono/mono_gd/gd_mono_cache.h
+++ b/modules/mono/mono_gd/gd_mono_cache.h
@@ -111,8 +111,8 @@ struct CachedData {
GDMonoField *field_ExportAttribute_hintString;
GDMonoClass *class_SignalAttribute;
GDMonoClass *class_ToolAttribute;
- GDMonoClass *class_RemoteAttribute;
- GDMonoClass *class_PuppetAttribute;
+ GDMonoClass *class_AnyAttribute;
+ GDMonoClass *class_AuthorityAttribute;
GDMonoClass *class_GodotMethodAttribute;
GDMonoField *field_GodotMethodAttribute_methodName;
GDMonoClass *class_ScriptPathAttribute;
diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp
index 3150ca0bc8..962bf79150 100644
--- a/modules/navigation/nav_map.cpp
+++ b/modules/navigation/nav_map.cpp
@@ -664,7 +664,7 @@ void NavMap::sync() {
} else {
other1 = other_edge_p1.lerp(other_edge_p2, (1.0 - projected_p1_ratio) / (projected_p2_ratio - projected_p1_ratio));
}
- if ((self1 - other1).length() > edge_connection_margin) {
+ if (other1.distance_to(self1) > edge_connection_margin) {
continue;
}
@@ -675,7 +675,7 @@ void NavMap::sync() {
} else {
other2 = other_edge_p1.lerp(other_edge_p2, (0.0 - projected_p1_ratio) / (projected_p2_ratio - projected_p1_ratio));
}
- if ((self2 - other2).length() > edge_connection_margin) {
+ if (other2.distance_to(self2) > edge_connection_margin) {
continue;
}