summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/collision_object_2d.cpp4
-rw-r--r--scene/2d/collision_object_2d.h6
-rw-r--r--scene/2d/collision_polygon_2d.cpp6
-rw-r--r--scene/2d/collision_polygon_2d.h6
-rw-r--r--scene/2d/collision_shape_2d.cpp6
-rw-r--r--scene/2d/collision_shape_2d.h6
-rw-r--r--scene/2d/cpu_particles_2d.cpp8
-rw-r--r--scene/2d/line_builder.cpp2
-rw-r--r--scene/2d/physics_body_2d.cpp24
-rw-r--r--scene/2d/physics_body_2d.h20
-rw-r--r--scene/3d/collision_polygon_3d.cpp4
-rw-r--r--scene/3d/collision_polygon_3d.h6
-rw-r--r--scene/3d/cpu_particles_3d.cpp15
-rw-r--r--scene/3d/immediate_geometry_3d.cpp11
-rw-r--r--scene/3d/navigation_region_3d.cpp7
-rw-r--r--scene/3d/navigation_region_3d.h2
-rw-r--r--scene/3d/node_3d.cpp4
-rw-r--r--scene/3d/physics_body_3d.cpp20
-rw-r--r--scene/3d/physics_body_3d.h14
-rw-r--r--scene/3d/physics_joint_3d.cpp76
-rw-r--r--scene/3d/physics_joint_3d.h90
-rw-r--r--scene/3d/spring_arm_3d.cpp12
-rw-r--r--scene/3d/spring_arm_3d.h16
-rw-r--r--scene/3d/vehicle_body_3d.cpp72
-rw-r--r--scene/3d/vehicle_body_3d.h68
-rw-r--r--scene/gui/button.cpp4
-rw-r--r--scene/gui/graph_node.cpp16
-rw-r--r--scene/gui/item_list.cpp2
-rw-r--r--scene/gui/text_edit.cpp106
-rw-r--r--scene/main/http_request.cpp8
-rw-r--r--scene/main/http_request.h2
-rw-r--r--scene/main/node.cpp29
-rw-r--r--scene/register_scene_types.cpp24
-rw-r--r--scene/resources/capsule_shape_2d.cpp5
-rw-r--r--scene/resources/circle_shape_2d.cpp3
-rw-r--r--scene/resources/primitive_meshes.cpp28
-rw-r--r--scene/resources/style_box.cpp4
-rw-r--r--scene/resources/visual_shader_nodes.cpp761
-rw-r--r--scene/resources/visual_shader_nodes.h212
39 files changed, 918 insertions, 791 deletions
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index f0b007f843..c83ed36917 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -165,7 +165,7 @@ bool CollisionObject2D::is_shape_owner_one_way_collision_enabled(uint32_t p_owne
return shapes[p_owner].one_way_collision;
}
-void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owner, float p_margin) {
+void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owner, real_t p_margin) {
if (area) {
return; //not for areas
}
@@ -179,7 +179,7 @@ void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owne
}
}
-float CollisionObject2D::get_shape_owner_one_way_collision_margin(uint32_t p_owner) const {
+real_t CollisionObject2D::get_shape_owner_one_way_collision_margin(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), 0);
return shapes[p_owner].one_way_collision_margin;
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index a2112c27f4..1cfaeaf649 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -52,7 +52,7 @@ class CollisionObject2D : public Node2D {
Vector<Shape> shapes;
bool disabled;
bool one_way_collision;
- float one_way_collision_margin;
+ real_t one_way_collision_margin;
ShapeData() {
disabled = false;
@@ -97,8 +97,8 @@ public:
void shape_owner_set_one_way_collision(uint32_t p_owner, bool p_enable);
bool is_shape_owner_one_way_collision_enabled(uint32_t p_owner) const;
- void shape_owner_set_one_way_collision_margin(uint32_t p_owner, float p_margin);
- float get_shape_owner_one_way_collision_margin(uint32_t p_owner) const;
+ void shape_owner_set_one_way_collision_margin(uint32_t p_owner, real_t p_margin);
+ real_t get_shape_owner_one_way_collision_margin(uint32_t p_owner) const;
void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2D> &p_shape);
int shape_owner_get_shape_count(uint32_t p_owner) const;
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 851e40cda6..505c0beb45 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -158,7 +158,7 @@ void CollisionPolygon2D::_notification(int p_what) {
Vector2 line_to(0, 20);
draw_line(Vector2(), line_to, dcol, 3);
Vector<Vector2> pts;
- float tsize = 8;
+ real_t tsize = 8;
pts.push_back(line_to + (Vector2(0, tsize)));
pts.push_back(line_to + (Vector2(Math_SQRT12 * tsize, 0)));
pts.push_back(line_to + (Vector2(-Math_SQRT12 * tsize, 0)));
@@ -275,14 +275,14 @@ bool CollisionPolygon2D::is_one_way_collision_enabled() const {
return one_way_collision;
}
-void CollisionPolygon2D::set_one_way_collision_margin(float p_margin) {
+void CollisionPolygon2D::set_one_way_collision_margin(real_t p_margin) {
one_way_collision_margin = p_margin;
if (parent) {
parent->shape_owner_set_one_way_collision_margin(owner_id, one_way_collision_margin);
}
}
-float CollisionPolygon2D::get_one_way_collision_margin() const {
+real_t CollisionPolygon2D::get_one_way_collision_margin() const {
return one_way_collision_margin;
}
diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h
index caa5b2c3ec..9c9e6f8f62 100644
--- a/scene/2d/collision_polygon_2d.h
+++ b/scene/2d/collision_polygon_2d.h
@@ -53,7 +53,7 @@ protected:
CollisionObject2D *parent;
bool disabled;
bool one_way_collision;
- float one_way_collision_margin;
+ real_t one_way_collision_margin;
Vector<Vector<Vector2>> _decompose_in_convex();
@@ -86,8 +86,8 @@ public:
void set_one_way_collision(bool p_enable);
bool is_one_way_collision_enabled() const;
- void set_one_way_collision_margin(float p_margin);
- float get_one_way_collision_margin() const;
+ void set_one_way_collision_margin(real_t p_margin);
+ real_t get_one_way_collision_margin() const;
CollisionPolygon2D();
};
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index 37bed577ac..381c2ad29a 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -125,7 +125,7 @@ void CollisionShape2D::_notification(int p_what) {
Vector2 line_to(0, 20);
draw_line(Vector2(), line_to, draw_col, 2);
Vector<Vector2> pts;
- float tsize = 8;
+ real_t tsize = 8;
pts.push_back(line_to + (Vector2(0, tsize)));
pts.push_back(line_to + (Vector2(Math_SQRT12 * tsize, 0)));
pts.push_back(line_to + (Vector2(-Math_SQRT12 * tsize, 0)));
@@ -215,14 +215,14 @@ bool CollisionShape2D::is_one_way_collision_enabled() const {
return one_way_collision;
}
-void CollisionShape2D::set_one_way_collision_margin(float p_margin) {
+void CollisionShape2D::set_one_way_collision_margin(real_t p_margin) {
one_way_collision_margin = p_margin;
if (parent) {
parent->shape_owner_set_one_way_collision_margin(owner_id, one_way_collision_margin);
}
}
-float CollisionShape2D::get_one_way_collision_margin() const {
+real_t CollisionShape2D::get_one_way_collision_margin() const {
return one_way_collision_margin;
}
diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h
index 8a4d885393..17cc4187c9 100644
--- a/scene/2d/collision_shape_2d.h
+++ b/scene/2d/collision_shape_2d.h
@@ -45,7 +45,7 @@ class CollisionShape2D : public Node2D {
void _shape_changed();
bool disabled;
bool one_way_collision;
- float one_way_collision_margin;
+ real_t one_way_collision_margin;
void _update_in_shape_owner(bool p_xform_only = false);
@@ -69,8 +69,8 @@ public:
void set_one_way_collision(bool p_enable);
bool is_one_way_collision_enabled() const;
- void set_one_way_collision_margin(float p_margin);
- float get_one_way_collision_margin() const;
+ void set_one_way_collision_margin(real_t p_margin);
+ real_t get_one_way_collision_margin() const;
virtual String get_configuration_warning() const override;
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index 7c9bd118d8..a19347caa8 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -700,7 +700,7 @@ void CPUParticles2D::_particles_process(float p_delta) {
p.hue_rot_rand = Math::randf();
p.anim_offset_rand = Math::randf();
- float angle1_rad = Math::atan2(direction.y, direction.x) + (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
+ float angle1_rad = Math::atan2(direction.y, direction.x) + Math::deg2rad((Math::randf() * 2.0 - 1.0) * spread);
Vector2 rot = Vector2(Math::cos(angle1_rad), Math::sin(angle1_rad));
p.velocity = rot * parameters[PARAM_INITIAL_LINEAR_VELOCITY] * Math::lerp(1.0f, float(Math::randf()), randomness[PARAM_INITIAL_LINEAR_VELOCITY]);
@@ -721,7 +721,7 @@ void CPUParticles2D::_particles_process(float p_delta) {
//do none
} break;
case EMISSION_SHAPE_SPHERE: {
- float s = Math::randf(), t = 2.0 * Math_PI * Math::randf();
+ float s = Math::randf(), t = Math_TAU * Math::randf();
float radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
p.transform[2] = Vector2(Math::cos(t), Math::sin(t)) * radius;
} break;
@@ -837,7 +837,7 @@ void CPUParticles2D::_particles_process(float p_delta) {
//orbit velocity
float orbit_amount = (parameters[PARAM_ORBIT_VELOCITY] + tex_orbit_velocity) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_ORBIT_VELOCITY]);
if (orbit_amount != 0.0) {
- float ang = orbit_amount * local_delta * Math_PI * 2.0;
+ float ang = orbit_amount * local_delta * Math_TAU;
// Not sure why the ParticlesMaterial code uses a clockwise rotation matrix,
// but we use -ang here to reproduce its behavior.
Transform2D rot = Transform2D(-ang, Vector2());
@@ -877,7 +877,7 @@ void CPUParticles2D::_particles_process(float p_delta) {
tex_hue_variation = curve_parameters[PARAM_HUE_VARIATION]->interpolate(p.custom[1]);
}
- float hue_rot_angle = (parameters[PARAM_HUE_VARIATION] + tex_hue_variation) * Math_PI * 2.0 * Math::lerp(1.0f, p.hue_rot_rand * 2.0f - 1.0f, randomness[PARAM_HUE_VARIATION]);
+ float hue_rot_angle = (parameters[PARAM_HUE_VARIATION] + tex_hue_variation) * Math_TAU * Math::lerp(1.0f, p.hue_rot_rand * 2.0f - 1.0f, randomness[PARAM_HUE_VARIATION]);
float hue_rot_c = Math::cos(hue_rot_angle);
float hue_rot_s = Math::sin(hue_rot_angle);
diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp
index 2f4459785b..5e48a61ff7 100644
--- a/scene/2d/line_builder.cpp
+++ b/scene/2d/line_builder.cpp
@@ -554,7 +554,7 @@ void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Col
float t = Vector2(1, 0).angle_to(vbegin);
float end_angle = t + angle_delta;
Vector2 rpos(0, 0);
- float tt_begin = -Math_PI / 2.f;
+ float tt_begin = -Math_PI / 2.0f;
float tt = tt_begin;
// Center vertice
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index a65009d072..ee625fb6f9 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -324,7 +324,7 @@ struct _RigidBody2DInOut {
int local_shape;
};
-bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
+bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
PhysicsServer2D::MotionResult *r = nullptr;
if (p_result.is_valid()) {
r = p_result->get_result_ptr();
@@ -611,7 +611,7 @@ void RigidBody2D::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_posit
PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_impulse, p_position);
}
-void RigidBody2D::apply_torque_impulse(float p_torque) {
+void RigidBody2D::apply_torque_impulse(real_t p_torque) {
PhysicsServer2D::get_singleton()->body_apply_torque_impulse(get_rid(), p_torque);
}
@@ -623,11 +623,11 @@ Vector2 RigidBody2D::get_applied_force() const {
return PhysicsServer2D::get_singleton()->body_get_applied_force(get_rid());
};
-void RigidBody2D::set_applied_torque(const float p_torque) {
+void RigidBody2D::set_applied_torque(const real_t p_torque) {
PhysicsServer2D::get_singleton()->body_set_applied_torque(get_rid(), p_torque);
};
-float RigidBody2D::get_applied_torque() const {
+real_t RigidBody2D::get_applied_torque() const {
return PhysicsServer2D::get_singleton()->body_get_applied_torque(get_rid());
};
@@ -639,7 +639,7 @@ void RigidBody2D::add_force(const Vector2 &p_force, const Vector2 &p_position) {
PhysicsServer2D::get_singleton()->body_add_force(get_rid(), p_force, p_position);
}
-void RigidBody2D::add_torque(const float p_torque) {
+void RigidBody2D::add_torque(const real_t p_torque) {
PhysicsServer2D::get_singleton()->body_add_torque(get_rid(), p_torque);
}
@@ -906,7 +906,7 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision
Vector2 recover;
int hits = PhysicsServer2D::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin);
int deepest = -1;
- float deepest_depth;
+ real_t deepest_depth;
for (int i = 0; i < hits; i++) {
if (deepest == -1 || sep_res[i].collision_depth > deepest_depth) {
deepest = i;
@@ -966,7 +966,7 @@ bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_
//so, if you pass 45 as limit, avoid numerical precision errors when angle is 45.
#define FLOOR_ANGLE_THRESHOLD 0.01
-Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, real_t p_floor_max_angle, bool p_infinite_inertia) {
Vector2 body_velocity = p_linear_velocity;
Vector2 body_velocity_normal = body_velocity.normalized();
Vector2 up_direction = p_up_direction.normalized();
@@ -1057,7 +1057,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
return body_velocity;
}
-Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, real_t p_floor_max_angle, bool p_infinite_inertia) {
Vector2 up_direction = p_up_direction.normalized();
bool was_on_floor = on_floor;
@@ -1123,11 +1123,11 @@ bool KinematicBody2D::test_move(const Transform2D &p_from, const Vector2 &p_moti
return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia, margin);
}
-void KinematicBody2D::set_safe_margin(float p_margin) {
+void KinematicBody2D::set_safe_margin(real_t p_margin) {
margin = p_margin;
}
-float KinematicBody2D::get_safe_margin() const {
+real_t KinematicBody2D::get_safe_margin() const {
return margin;
}
@@ -1219,8 +1219,8 @@ void KinematicBody2D::_notification(int p_what) {
void KinematicBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody2D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((real_t)45.0)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((real_t)45.0)), DEFVAL(true));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody2D::test_move, DEFVAL(true));
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 159f73b269..b2a4aed019 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -176,7 +176,7 @@ private:
void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape);
void _direct_state_changed(Object *p_state);
- bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, float p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
+ bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, real_t p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
protected:
void _notification(int p_what);
@@ -232,17 +232,17 @@ public:
void apply_central_impulse(const Vector2 &p_impulse);
void apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position = Vector2());
- void apply_torque_impulse(float p_torque);
+ void apply_torque_impulse(real_t p_torque);
void set_applied_force(const Vector2 &p_force);
Vector2 get_applied_force() const;
- void set_applied_torque(const float p_torque);
- float get_applied_torque() const;
+ void set_applied_torque(const real_t p_torque);
+ real_t get_applied_torque() const;
void add_central_force(const Vector2 &p_force);
void add_force(const Vector2 &p_force, const Vector2 &p_position = Vector2());
- void add_torque(float p_torque);
+ void add_torque(real_t p_torque);
TypedArray<Node2D> get_colliding_bodies() const; //function for script
@@ -276,7 +276,7 @@ public:
};
private:
- float margin;
+ real_t margin;
Vector2 floor_normal;
Vector2 floor_velocity;
@@ -309,11 +309,11 @@ public:
bool separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision);
- void set_safe_margin(float p_margin);
- float get_safe_margin() const;
+ void set_safe_margin(real_t p_margin);
+ real_t get_safe_margin() const;
- Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
- Vector2 move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
+ Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, real_t p_floor_max_angle = Math::deg2rad((real_t)45.0), bool p_infinite_inertia = true);
+ Vector2 move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, real_t p_floor_max_angle = Math::deg2rad((real_t)45.0), bool p_infinite_inertia = true);
bool is_on_floor() const;
bool is_on_wall() const;
bool is_on_ceiling() const;
diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp
index 5e77937533..742387b32d 100644
--- a/scene/3d/collision_polygon_3d.cpp
+++ b/scene/3d/collision_polygon_3d.cpp
@@ -132,13 +132,13 @@ AABB CollisionPolygon3D::get_item_rect() const {
return aabb;
}
-void CollisionPolygon3D::set_depth(float p_depth) {
+void CollisionPolygon3D::set_depth(real_t p_depth) {
depth = p_depth;
_build_polygon();
update_gizmo();
}
-float CollisionPolygon3D::get_depth() const {
+real_t CollisionPolygon3D::get_depth() const {
return depth;
}
diff --git a/scene/3d/collision_polygon_3d.h b/scene/3d/collision_polygon_3d.h
index ec13b9af6d..ba6ad2a3f0 100644
--- a/scene/3d/collision_polygon_3d.h
+++ b/scene/3d/collision_polygon_3d.h
@@ -39,7 +39,7 @@ class CollisionPolygon3D : public Node3D {
GDCLASS(CollisionPolygon3D, Node3D);
protected:
- float depth;
+ real_t depth;
AABB aabb;
Vector<Point2> polygon;
@@ -59,8 +59,8 @@ protected:
static void _bind_methods();
public:
- void set_depth(float p_depth);
- float get_depth() const;
+ void set_depth(real_t p_depth);
+ real_t get_depth() const;
void set_polygon(const Vector<Point2> &p_polygon);
Vector<Point2> get_polygon() const;
diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp
index 3562f7b778..c36c135fe6 100644
--- a/scene/3d/cpu_particles_3d.cpp
+++ b/scene/3d/cpu_particles_3d.cpp
@@ -676,13 +676,13 @@ void CPUParticles3D::_particles_process(float p_delta) {
p.anim_offset_rand = Math::randf();
if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) {
- float angle1_rad = Math::atan2(direction.y, direction.x) + (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
+ float angle1_rad = Math::atan2(direction.y, direction.x) + Math::deg2rad((Math::randf() * 2.0 - 1.0) * spread);
Vector3 rot = Vector3(Math::cos(angle1_rad), Math::sin(angle1_rad), 0.0);
p.velocity = rot * parameters[PARAM_INITIAL_LINEAR_VELOCITY] * Math::lerp(1.0f, float(Math::randf()), randomness[PARAM_INITIAL_LINEAR_VELOCITY]);
} else {
//initiate velocity spread in 3D
- float angle1_rad = Math::atan2(direction.x, direction.z) + (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
- float angle2_rad = Math::atan2(direction.y, Math::abs(direction.z)) + (Math::randf() * 2.0 - 1.0) * (1.0 - flatness) * Math_PI * spread / 180.0;
+ float angle1_rad = Math::atan2(direction.x, direction.z) + Math::deg2rad((Math::randf() * 2.0 - 1.0) * spread);
+ float angle2_rad = Math::atan2(direction.y, Math::abs(direction.z)) + Math::deg2rad((Math::randf() * 2.0 - 1.0) * (1.0 - flatness) * spread);
Vector3 direction_xz = Vector3(Math::sin(angle1_rad), 0, Math::cos(angle1_rad));
Vector3 direction_yz = Vector3(0, Math::sin(angle2_rad), Math::cos(angle2_rad));
@@ -706,8 +706,9 @@ void CPUParticles3D::_particles_process(float p_delta) {
//do none
} break;
case EMISSION_SHAPE_SPHERE: {
- float s = 2.0 * Math::randf() - 1.0, t = 2.0 * Math_PI * Math::randf();
- float radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
+ real_t s = 2.0 * Math::randf() - 1.0;
+ real_t t = Math_TAU * Math::randf();
+ real_t radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
p.transform.origin = Vector3(radius * Math::cos(t), radius * Math::sin(t), emission_sphere_radius * s);
} break;
case EMISSION_SHAPE_BOX: {
@@ -855,7 +856,7 @@ void CPUParticles3D::_particles_process(float p_delta) {
if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) {
float orbit_amount = (parameters[PARAM_ORBIT_VELOCITY] + tex_orbit_velocity) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_ORBIT_VELOCITY]);
if (orbit_amount != 0.0) {
- float ang = orbit_amount * local_delta * Math_PI * 2.0;
+ float ang = orbit_amount * local_delta * Math_TAU;
// Not sure why the ParticlesMaterial code uses a clockwise rotation matrix,
// but we use -ang here to reproduce its behavior.
Transform2D rot = Transform2D(-ang, Vector2());
@@ -895,7 +896,7 @@ void CPUParticles3D::_particles_process(float p_delta) {
tex_hue_variation = curve_parameters[PARAM_HUE_VARIATION]->interpolate(p.custom[1]);
}
- float hue_rot_angle = (parameters[PARAM_HUE_VARIATION] + tex_hue_variation) * Math_PI * 2.0 * Math::lerp(1.0f, p.hue_rot_rand * 2.0f - 1.0f, randomness[PARAM_HUE_VARIATION]);
+ float hue_rot_angle = (parameters[PARAM_HUE_VARIATION] + tex_hue_variation) * Math_TAU * Math::lerp(1.0f, p.hue_rot_rand * 2.0f - 1.0f, randomness[PARAM_HUE_VARIATION]);
float hue_rot_c = Math::cos(hue_rot_angle);
float hue_rot_s = Math::sin(hue_rot_angle);
diff --git a/scene/3d/immediate_geometry_3d.cpp b/scene/3d/immediate_geometry_3d.cpp
index 17410d5870..47242cf196 100644
--- a/scene/3d/immediate_geometry_3d.cpp
+++ b/scene/3d/immediate_geometry_3d.cpp
@@ -87,21 +87,24 @@ Vector<Face3> ImmediateGeometry3D::get_faces(uint32_t p_usage_flags) const {
}
void ImmediateGeometry3D::add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv) {
+ const double lat_step = Math_TAU / p_lats;
+ const double lon_step = Math_TAU / p_lons;
+
for (int i = 1; i <= p_lats; i++) {
- double lat0 = Math_PI * (-0.5 + (double)(i - 1) / p_lats);
+ double lat0 = lat_step * (i - 1) - Math_TAU / 4;
double z0 = Math::sin(lat0);
double zr0 = Math::cos(lat0);
- double lat1 = Math_PI * (-0.5 + (double)i / p_lats);
+ double lat1 = lat_step * i - Math_TAU / 4;
double z1 = Math::sin(lat1);
double zr1 = Math::cos(lat1);
for (int j = p_lons; j >= 1; j--) {
- double lng0 = 2 * Math_PI * (double)(j - 1) / p_lons;
+ double lng0 = lon_step * (j - 1);
double x0 = Math::cos(lng0);
double y0 = Math::sin(lng0);
- double lng1 = 2 * Math_PI * (double)(j) / p_lons;
+ double lng1 = lon_step * j;
double x1 = Math::cos(lng1);
double y1 = Math::sin(lng1);
diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp
index b7b1415091..e8cfa05a4b 100644
--- a/scene/3d/navigation_region_3d.cpp
+++ b/scene/3d/navigation_region_3d.cpp
@@ -170,18 +170,17 @@ void _bake_navigation_mesh(void *p_user_data) {
}
void NavigationRegion3D::bake_navigation_mesh() {
- ERR_FAIL_COND(bake_thread != nullptr);
+ ERR_FAIL_COND(bake_thread.is_started());
BakeThreadsArgs *args = memnew(BakeThreadsArgs);
args->nav_region = this;
- bake_thread = Thread::create(_bake_navigation_mesh, args);
- ERR_FAIL_COND(bake_thread == nullptr);
+ bake_thread.start(_bake_navigation_mesh, args);
}
void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
set_navigation_mesh(p_nav_mesh);
- bake_thread = nullptr;
+ bake_thread.wait_to_finish();
emit_signal("bake_finished");
}
diff --git a/scene/3d/navigation_region_3d.h b/scene/3d/navigation_region_3d.h
index a5b8c2cd5e..e966523b64 100644
--- a/scene/3d/navigation_region_3d.h
+++ b/scene/3d/navigation_region_3d.h
@@ -46,7 +46,7 @@ class NavigationRegion3D : public Node3D {
Navigation3D *navigation = nullptr;
Node *debug_view = nullptr;
- Thread *bake_thread = nullptr;
+ Thread bake_thread;
protected:
void _notification(int p_what);
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp
index 2a49e60669..57bead022b 100644
--- a/scene/3d/node_3d.cpp
+++ b/scene/3d/node_3d.cpp
@@ -330,7 +330,7 @@ void Node3D::set_rotation(const Vector3 &p_euler_rad) {
}
void Node3D::set_rotation_degrees(const Vector3 &p_euler_deg) {
- set_rotation(p_euler_deg * Math_PI / 180.0);
+ set_rotation(p_euler_deg * (Math_PI / 180.0));
}
void Node3D::set_scale(const Vector3 &p_scale) {
@@ -364,7 +364,7 @@ Vector3 Node3D::get_rotation() const {
}
Vector3 Node3D::get_rotation_degrees() const {
- return get_rotation() * 180.0 / Math_PI;
+ return get_rotation() * (180.0 / Math_PI);
}
Vector3 Node3D::get_scale() const {
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index 4d712069ec..71be943232 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -51,7 +51,7 @@ Vector3 PhysicsBody3D::get_angular_velocity() const {
return Vector3();
}
-float PhysicsBody3D::get_inverse_mass() const {
+real_t PhysicsBody3D::get_inverse_mass() const {
return 0;
}
@@ -924,7 +924,7 @@ bool KinematicBody3D::move_and_collide(const Vector3 &p_motion, bool p_infinite_
//so, if you pass 45 as limit, avoid numerical precision errors when angle is 45.
#define FLOOR_ANGLE_THRESHOLD 0.01
-Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, real_t p_floor_max_angle, bool p_infinite_inertia) {
Vector3 body_velocity = p_linear_velocity;
Vector3 body_velocity_normal = body_velocity.normalized();
Vector3 up_direction = p_up_direction.normalized();
@@ -1018,7 +1018,7 @@ Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const
return body_velocity;
}
-Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, real_t p_floor_max_angle, bool p_infinite_inertia) {
Vector3 up_direction = p_up_direction.normalized();
bool was_on_floor = on_floor;
@@ -1090,7 +1090,7 @@ bool KinematicBody3D::separate_raycast_shapes(bool p_infinite_inertia, Collision
Vector3 recover;
int hits = PhysicsServer3D::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin);
int deepest = -1;
- float deepest_depth;
+ real_t deepest_depth;
for (int i = 0; i < hits; i++) {
if (deepest == -1 || sep_res[i].collision_depth > deepest_depth) {
deepest = i;
@@ -1131,12 +1131,12 @@ bool KinematicBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const {
return PhysicsServer3D::get_singleton()->body_is_axis_locked(get_rid(), p_axis);
}
-void KinematicBody3D::set_safe_margin(float p_margin) {
+void KinematicBody3D::set_safe_margin(real_t p_margin) {
margin = p_margin;
PhysicsServer3D::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin);
}
-float KinematicBody3D::get_safe_margin() const {
+real_t KinematicBody3D::get_safe_margin() const {
return margin;
}
@@ -1180,8 +1180,8 @@ void KinematicBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("_direct_state_changed"), &KinematicBody3D::_direct_state_changed);
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody3D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody3D::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody3D::move_and_slide_with_snap, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody3D::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((real_t)45.0)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody3D::move_and_slide_with_snap, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((real_t)45.0)), DEFVAL(true));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody3D::test_move, DEFVAL(true));
@@ -2389,11 +2389,11 @@ Vector3 PhysicalBone3D::get_joint_rotation() const {
}
void PhysicalBone3D::set_joint_rotation_degrees(const Vector3 &p_euler_deg) {
- set_joint_rotation(p_euler_deg * Math_PI / 180.0);
+ set_joint_rotation(p_euler_deg * (Math_PI / 180.0));
}
Vector3 PhysicalBone3D::get_joint_rotation_degrees() const {
- return get_joint_rotation() * 180.0 / Math_PI;
+ return get_joint_rotation() * (180.0 / Math_PI);
}
const Transform &PhysicalBone3D::get_body_offset() const {
diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h
index d9b95e6551..469c6b222c 100644
--- a/scene/3d/physics_body_3d.h
+++ b/scene/3d/physics_body_3d.h
@@ -50,7 +50,7 @@ protected:
public:
virtual Vector3 get_linear_velocity() const;
virtual Vector3 get_angular_velocity() const;
- virtual float get_inverse_mass() const;
+ virtual real_t get_inverse_mass() const;
void set_collision_layer(uint32_t p_layer);
uint32_t get_collision_layer() const;
@@ -183,7 +183,7 @@ public:
void set_mass(real_t p_mass);
real_t get_mass() const;
- virtual float get_inverse_mass() const override { return 1.0 / mass; }
+ virtual real_t get_inverse_mass() const override { return 1.0 / mass; }
void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override);
Ref<PhysicsMaterial> get_physics_material_override() const;
@@ -274,7 +274,7 @@ private:
uint16_t locked_axis;
- float margin;
+ real_t margin;
Vector3 floor_normal;
Vector3 floor_velocity;
@@ -309,11 +309,11 @@ public:
void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock);
bool get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const;
- void set_safe_margin(float p_margin);
- float get_safe_margin() const;
+ void set_safe_margin(real_t p_margin);
+ real_t get_safe_margin() const;
- Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction = Vector3(0, 0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
- Vector3 move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction = Vector3(0, 0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
+ Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction = Vector3(0, 0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, real_t p_floor_max_angle = Math::deg2rad((real_t)45.0), bool p_infinite_inertia = true);
+ Vector3 move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction = Vector3(0, 0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, real_t p_floor_max_angle = Math::deg2rad((real_t)45.0), bool p_infinite_inertia = true);
bool is_on_floor() const;
bool is_on_wall() const;
bool is_on_ceiling() const;
diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp
index 326b91b6ed..b8d8af2385 100644
--- a/scene/3d/physics_joint_3d.cpp
+++ b/scene/3d/physics_joint_3d.cpp
@@ -265,7 +265,7 @@ void PinJoint3D::_bind_methods() {
BIND_ENUM_CONSTANT(PARAM_IMPULSE_CLAMP);
}
-void PinJoint3D::set_param(Param p_param, float p_value) {
+void PinJoint3D::set_param(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, 3);
params[p_param] = p_value;
if (get_joint().is_valid()) {
@@ -273,7 +273,7 @@ void PinJoint3D::set_param(Param p_param, float p_value) {
}
}
-float PinJoint3D::get_param(Param p_param) const {
+real_t PinJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, 3, 0);
return params[p_param];
}
@@ -306,19 +306,19 @@ PinJoint3D::PinJoint3D() {
///////////////////////////////////
-void HingeJoint3D::_set_upper_limit(float p_limit) {
+void HingeJoint3D::_set_upper_limit(real_t p_limit) {
set_param(PARAM_LIMIT_UPPER, Math::deg2rad(p_limit));
}
-float HingeJoint3D::_get_upper_limit() const {
+real_t HingeJoint3D::_get_upper_limit() const {
return Math::rad2deg(get_param(PARAM_LIMIT_UPPER));
}
-void HingeJoint3D::_set_lower_limit(float p_limit) {
+void HingeJoint3D::_set_lower_limit(real_t p_limit) {
set_param(PARAM_LIMIT_LOWER, Math::deg2rad(p_limit));
}
-float HingeJoint3D::_get_lower_limit() const {
+real_t HingeJoint3D::_get_lower_limit() const {
return Math::rad2deg(get_param(PARAM_LIMIT_LOWER));
}
@@ -363,7 +363,7 @@ void HingeJoint3D::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_MAX);
}
-void HingeJoint3D::set_param(Param p_param, float p_value) {
+void HingeJoint3D::set_param(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
if (get_joint().is_valid()) {
@@ -373,7 +373,7 @@ void HingeJoint3D::set_param(Param p_param, float p_value) {
update_gizmo();
}
-float HingeJoint3D::get_param(Param p_param) const {
+real_t HingeJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
@@ -437,19 +437,19 @@ HingeJoint3D::HingeJoint3D() {
//////////////////////////////////
-void SliderJoint3D::_set_upper_limit_angular(float p_limit_angular) {
+void SliderJoint3D::_set_upper_limit_angular(real_t p_limit_angular) {
set_param(PARAM_ANGULAR_LIMIT_UPPER, Math::deg2rad(p_limit_angular));
}
-float SliderJoint3D::_get_upper_limit_angular() const {
+real_t SliderJoint3D::_get_upper_limit_angular() const {
return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_UPPER));
}
-void SliderJoint3D::_set_lower_limit_angular(float p_limit_angular) {
+void SliderJoint3D::_set_lower_limit_angular(real_t p_limit_angular) {
set_param(PARAM_ANGULAR_LIMIT_LOWER, Math::deg2rad(p_limit_angular));
}
-float SliderJoint3D::_get_lower_limit_angular() const {
+real_t SliderJoint3D::_get_lower_limit_angular() const {
return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_LOWER));
}
@@ -514,7 +514,7 @@ void SliderJoint3D::_bind_methods() {
BIND_ENUM_CONSTANT(PARAM_MAX);
}
-void SliderJoint3D::set_param(Param p_param, float p_value) {
+void SliderJoint3D::set_param(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
if (get_joint().is_valid()) {
@@ -523,7 +523,7 @@ void SliderJoint3D::set_param(Param p_param, float p_value) {
update_gizmo();
}
-float SliderJoint3D::get_param(Param p_param) const {
+real_t SliderJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
@@ -579,19 +579,19 @@ SliderJoint3D::SliderJoint3D() {
//////////////////////////////////
-void ConeTwistJoint3D::_set_swing_span(float p_limit_angular) {
+void ConeTwistJoint3D::_set_swing_span(real_t p_limit_angular) {
set_param(PARAM_SWING_SPAN, Math::deg2rad(p_limit_angular));
}
-float ConeTwistJoint3D::_get_swing_span() const {
+real_t ConeTwistJoint3D::_get_swing_span() const {
return Math::rad2deg(get_param(PARAM_SWING_SPAN));
}
-void ConeTwistJoint3D::_set_twist_span(float p_limit_angular) {
+void ConeTwistJoint3D::_set_twist_span(real_t p_limit_angular) {
set_param(PARAM_TWIST_SPAN, Math::deg2rad(p_limit_angular));
}
-float ConeTwistJoint3D::_get_twist_span() const {
+real_t ConeTwistJoint3D::_get_twist_span() const {
return Math::rad2deg(get_param(PARAM_TWIST_SPAN));
}
@@ -620,7 +620,7 @@ void ConeTwistJoint3D::_bind_methods() {
BIND_ENUM_CONSTANT(PARAM_MAX);
}
-void ConeTwistJoint3D::set_param(Param p_param, float p_value) {
+void ConeTwistJoint3D::set_param(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
if (get_joint().is_valid()) {
@@ -630,7 +630,7 @@ void ConeTwistJoint3D::set_param(Param p_param, float p_value) {
update_gizmo();
}
-float ConeTwistJoint3D::get_param(Param p_param) const {
+real_t ConeTwistJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
@@ -671,51 +671,51 @@ ConeTwistJoint3D::ConeTwistJoint3D() {
/////////////////////////////////////////////////////////////////////
-void Generic6DOFJoint3D::_set_angular_hi_limit_x(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_hi_limit_x(real_t p_limit_angular) {
set_param_x(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint3D::_get_angular_hi_limit_x() const {
+real_t Generic6DOFJoint3D::_get_angular_hi_limit_x() const {
return Math::rad2deg(get_param_x(PARAM_ANGULAR_UPPER_LIMIT));
}
-void Generic6DOFJoint3D::_set_angular_lo_limit_x(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_lo_limit_x(real_t p_limit_angular) {
set_param_x(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint3D::_get_angular_lo_limit_x() const {
+real_t Generic6DOFJoint3D::_get_angular_lo_limit_x() const {
return Math::rad2deg(get_param_x(PARAM_ANGULAR_LOWER_LIMIT));
}
-void Generic6DOFJoint3D::_set_angular_hi_limit_y(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_hi_limit_y(real_t p_limit_angular) {
set_param_y(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint3D::_get_angular_hi_limit_y() const {
+real_t Generic6DOFJoint3D::_get_angular_hi_limit_y() const {
return Math::rad2deg(get_param_y(PARAM_ANGULAR_UPPER_LIMIT));
}
-void Generic6DOFJoint3D::_set_angular_lo_limit_y(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_lo_limit_y(real_t p_limit_angular) {
set_param_y(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint3D::_get_angular_lo_limit_y() const {
+real_t Generic6DOFJoint3D::_get_angular_lo_limit_y() const {
return Math::rad2deg(get_param_y(PARAM_ANGULAR_LOWER_LIMIT));
}
-void Generic6DOFJoint3D::_set_angular_hi_limit_z(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_hi_limit_z(real_t p_limit_angular) {
set_param_z(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint3D::_get_angular_hi_limit_z() const {
+real_t Generic6DOFJoint3D::_get_angular_hi_limit_z() const {
return Math::rad2deg(get_param_z(PARAM_ANGULAR_UPPER_LIMIT));
}
-void Generic6DOFJoint3D::_set_angular_lo_limit_z(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_lo_limit_z(real_t p_limit_angular) {
set_param_z(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint3D::_get_angular_lo_limit_z() const {
+real_t Generic6DOFJoint3D::_get_angular_lo_limit_z() const {
return Math::rad2deg(get_param_z(PARAM_ANGULAR_LOWER_LIMIT));
}
@@ -877,7 +877,7 @@ void Generic6DOFJoint3D::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_MAX);
}
-void Generic6DOFJoint3D::set_param_x(Param p_param, float p_value) {
+void Generic6DOFJoint3D::set_param_x(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_x[p_param] = p_value;
if (get_joint().is_valid()) {
@@ -887,12 +887,12 @@ void Generic6DOFJoint3D::set_param_x(Param p_param, float p_value) {
update_gizmo();
}
-float Generic6DOFJoint3D::get_param_x(Param p_param) const {
+real_t Generic6DOFJoint3D::get_param_x(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_x[p_param];
}
-void Generic6DOFJoint3D::set_param_y(Param p_param, float p_value) {
+void Generic6DOFJoint3D::set_param_y(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_y[p_param] = p_value;
if (get_joint().is_valid()) {
@@ -901,12 +901,12 @@ void Generic6DOFJoint3D::set_param_y(Param p_param, float p_value) {
update_gizmo();
}
-float Generic6DOFJoint3D::get_param_y(Param p_param) const {
+real_t Generic6DOFJoint3D::get_param_y(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_y[p_param];
}
-void Generic6DOFJoint3D::set_param_z(Param p_param, float p_value) {
+void Generic6DOFJoint3D::set_param_z(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_z[p_param] = p_value;
if (get_joint().is_valid()) {
@@ -915,7 +915,7 @@ void Generic6DOFJoint3D::set_param_z(Param p_param, float p_value) {
update_gizmo();
}
-float Generic6DOFJoint3D::get_param_z(Param p_param) const {
+real_t Generic6DOFJoint3D::get_param_z(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_z[p_param];
}
diff --git a/scene/3d/physics_joint_3d.h b/scene/3d/physics_joint_3d.h
index 9702076318..e5fd6e6c87 100644
--- a/scene/3d/physics_joint_3d.h
+++ b/scene/3d/physics_joint_3d.h
@@ -91,13 +91,13 @@ public:
};
protected:
- float params[3];
+ real_t params[3];
virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) override;
static void _bind_methods();
public:
- void set_param(Param p_param, float p_value);
- float get_param(Param p_param) const;
+ void set_param(Param p_param, real_t p_value);
+ real_t get_param(Param p_param) const;
PinJoint3D();
};
@@ -127,20 +127,20 @@ public:
};
protected:
- float params[PARAM_MAX];
+ real_t params[PARAM_MAX];
bool flags[FLAG_MAX];
virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) override;
static void _bind_methods();
- void _set_upper_limit(float p_limit);
- float _get_upper_limit() const;
+ void _set_upper_limit(real_t p_limit);
+ real_t _get_upper_limit() const;
- void _set_lower_limit(float p_limit);
- float _get_lower_limit() const;
+ void _set_lower_limit(real_t p_limit);
+ real_t _get_lower_limit() const;
public:
- void set_param(Param p_param, float p_value);
- float get_param(Param p_param) const;
+ void set_param(Param p_param, real_t p_value);
+ real_t get_param(Param p_param) const;
void set_flag(Flag p_flag, bool p_value);
bool get_flag(Flag p_flag) const;
@@ -184,19 +184,19 @@ public:
};
protected:
- void _set_upper_limit_angular(float p_limit_angular);
- float _get_upper_limit_angular() const;
+ void _set_upper_limit_angular(real_t p_limit_angular);
+ real_t _get_upper_limit_angular() const;
- void _set_lower_limit_angular(float p_limit_angular);
- float _get_lower_limit_angular() const;
+ void _set_lower_limit_angular(real_t p_limit_angular);
+ real_t _get_lower_limit_angular() const;
- float params[PARAM_MAX];
+ real_t params[PARAM_MAX];
virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) override;
static void _bind_methods();
public:
- void set_param(Param p_param, float p_value);
- float get_param(Param p_param) const;
+ void set_param(Param p_param, real_t p_value);
+ real_t get_param(Param p_param) const;
SliderJoint3D();
};
@@ -217,19 +217,19 @@ public:
};
protected:
- void _set_swing_span(float p_limit_angular);
- float _get_swing_span() const;
+ void _set_swing_span(real_t p_limit_angular);
+ real_t _get_swing_span() const;
- void _set_twist_span(float p_limit_angular);
- float _get_twist_span() const;
+ void _set_twist_span(real_t p_limit_angular);
+ real_t _get_twist_span() const;
- float params[PARAM_MAX];
+ real_t params[PARAM_MAX];
virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) override;
static void _bind_methods();
public:
- void set_param(Param p_param, float p_value);
- float get_param(Param p_param) const;
+ void set_param(Param p_param, real_t p_value);
+ real_t get_param(Param p_param) const;
ConeTwistJoint3D();
};
@@ -277,43 +277,43 @@ public:
};
protected:
- void _set_angular_hi_limit_x(float p_limit_angular);
- float _get_angular_hi_limit_x() const;
+ void _set_angular_hi_limit_x(real_t p_limit_angular);
+ real_t _get_angular_hi_limit_x() const;
- void _set_angular_hi_limit_y(float p_limit_angular);
- float _get_angular_hi_limit_y() const;
+ void _set_angular_hi_limit_y(real_t p_limit_angular);
+ real_t _get_angular_hi_limit_y() const;
- void _set_angular_hi_limit_z(float p_limit_angular);
- float _get_angular_hi_limit_z() const;
+ void _set_angular_hi_limit_z(real_t p_limit_angular);
+ real_t _get_angular_hi_limit_z() const;
- void _set_angular_lo_limit_x(float p_limit_angular);
- float _get_angular_lo_limit_x() const;
+ void _set_angular_lo_limit_x(real_t p_limit_angular);
+ real_t _get_angular_lo_limit_x() const;
- void _set_angular_lo_limit_y(float p_limit_angular);
- float _get_angular_lo_limit_y() const;
+ void _set_angular_lo_limit_y(real_t p_limit_angular);
+ real_t _get_angular_lo_limit_y() const;
- void _set_angular_lo_limit_z(float p_limit_angular);
- float _get_angular_lo_limit_z() const;
+ void _set_angular_lo_limit_z(real_t p_limit_angular);
+ real_t _get_angular_lo_limit_z() const;
- float params_x[PARAM_MAX];
+ real_t params_x[PARAM_MAX];
bool flags_x[FLAG_MAX];
- float params_y[PARAM_MAX];
+ real_t params_y[PARAM_MAX];
bool flags_y[FLAG_MAX];
- float params_z[PARAM_MAX];
+ real_t params_z[PARAM_MAX];
bool flags_z[FLAG_MAX];
virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) override;
static void _bind_methods();
public:
- void set_param_x(Param p_param, float p_value);
- float get_param_x(Param p_param) const;
+ void set_param_x(Param p_param, real_t p_value);
+ real_t get_param_x(Param p_param) const;
- void set_param_y(Param p_param, float p_value);
- float get_param_y(Param p_param) const;
+ void set_param_y(Param p_param, real_t p_value);
+ real_t get_param_y(Param p_param) const;
- void set_param_z(Param p_param, float p_value);
- float get_param_z(Param p_param) const;
+ void set_param_z(Param p_param, real_t p_value);
+ real_t get_param_z(Param p_param) const;
void set_flag_x(Flag p_flag, bool p_enabled);
bool get_flag_x(Flag p_flag) const;
diff --git a/scene/3d/spring_arm_3d.cpp b/scene/3d/spring_arm_3d.cpp
index 6812282844..9518b47696 100644
--- a/scene/3d/spring_arm_3d.cpp
+++ b/scene/3d/spring_arm_3d.cpp
@@ -78,11 +78,11 @@ void SpringArm3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin"), "set_margin", "get_margin");
}
-float SpringArm3D::get_length() const {
+real_t SpringArm3D::get_length() const {
return spring_length;
}
-void SpringArm3D::set_length(float p_length) {
+void SpringArm3D::set_length(real_t p_length) {
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) {
update_gizmo();
}
@@ -106,11 +106,11 @@ uint32_t SpringArm3D::get_mask() {
return mask;
}
-float SpringArm3D::get_margin() {
+real_t SpringArm3D::get_margin() {
return margin;
}
-void SpringArm3D::set_margin(float p_margin) {
+void SpringArm3D::set_margin(real_t p_margin) {
margin = p_margin;
}
@@ -126,7 +126,7 @@ void SpringArm3D::clear_excluded_objects() {
excluded_objects.clear();
}
-float SpringArm3D::get_hit_length() {
+real_t SpringArm3D::get_hit_length() {
return current_spring_length;
}
@@ -143,7 +143,7 @@ void SpringArm3D::process_spring() {
PhysicsDirectSpaceState3D::RayResult r;
bool intersected = get_world_3d()->get_direct_space_state()->intersect_ray(get_global_transform().origin, get_global_transform().origin + motion, r, excluded_objects, mask);
if (intersected) {
- float dist = get_global_transform().origin.distance_to(r.position);
+ real_t dist = get_global_transform().origin.distance_to(r.position);
dist -= margin;
motion_delta = dist / (spring_length);
}
diff --git a/scene/3d/spring_arm_3d.h b/scene/3d/spring_arm_3d.h
index 4c2d2a54ff..864919c631 100644
--- a/scene/3d/spring_arm_3d.h
+++ b/scene/3d/spring_arm_3d.h
@@ -38,19 +38,19 @@ class SpringArm3D : public Node3D {
Ref<Shape3D> shape;
Set<RID> excluded_objects;
- float spring_length = 1;
- float current_spring_length = 0;
+ real_t spring_length = 1;
+ real_t current_spring_length = 0;
bool keep_child_basis = false;
uint32_t mask = 1;
- float margin = 0.01;
+ real_t margin = 0.01;
protected:
void _notification(int p_what);
static void _bind_methods();
public:
- void set_length(float p_length);
- float get_length() const;
+ void set_length(real_t p_length);
+ real_t get_length() const;
void set_shape(Ref<Shape3D> p_shape);
Ref<Shape3D> get_shape() const;
void set_mask(uint32_t p_mask);
@@ -58,9 +58,9 @@ public:
void add_excluded_object(RID p_rid);
bool remove_excluded_object(RID p_rid);
void clear_excluded_objects();
- float get_hit_length();
- void set_margin(float p_margin);
- float get_margin();
+ real_t get_hit_length();
+ void set_margin(real_t p_margin);
+ real_t get_margin();
SpringArm3D() {}
diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp
index 120bbbae43..ec8a300653 100644
--- a/scene/3d/vehicle_body_3d.cpp
+++ b/scene/3d/vehicle_body_3d.cpp
@@ -147,77 +147,77 @@ void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) {
}
}
-void VehicleWheel3D::set_radius(float p_radius) {
+void VehicleWheel3D::set_radius(real_t p_radius) {
m_wheelRadius = p_radius;
update_gizmo();
}
-float VehicleWheel3D::get_radius() const {
+real_t VehicleWheel3D::get_radius() const {
return m_wheelRadius;
}
-void VehicleWheel3D::set_suspension_rest_length(float p_length) {
+void VehicleWheel3D::set_suspension_rest_length(real_t p_length) {
m_suspensionRestLength = p_length;
update_gizmo();
}
-float VehicleWheel3D::get_suspension_rest_length() const {
+real_t VehicleWheel3D::get_suspension_rest_length() const {
return m_suspensionRestLength;
}
-void VehicleWheel3D::set_suspension_travel(float p_length) {
+void VehicleWheel3D::set_suspension_travel(real_t p_length) {
m_maxSuspensionTravelCm = p_length / 0.01;
}
-float VehicleWheel3D::get_suspension_travel() const {
+real_t VehicleWheel3D::get_suspension_travel() const {
return m_maxSuspensionTravelCm * 0.01;
}
-void VehicleWheel3D::set_suspension_stiffness(float p_value) {
+void VehicleWheel3D::set_suspension_stiffness(real_t p_value) {
m_suspensionStiffness = p_value;
}
-float VehicleWheel3D::get_suspension_stiffness() const {
+real_t VehicleWheel3D::get_suspension_stiffness() const {
return m_suspensionStiffness;
}
-void VehicleWheel3D::set_suspension_max_force(float p_value) {
+void VehicleWheel3D::set_suspension_max_force(real_t p_value) {
m_maxSuspensionForce = p_value;
}
-float VehicleWheel3D::get_suspension_max_force() const {
+real_t VehicleWheel3D::get_suspension_max_force() const {
return m_maxSuspensionForce;
}
-void VehicleWheel3D::set_damping_compression(float p_value) {
+void VehicleWheel3D::set_damping_compression(real_t p_value) {
m_wheelsDampingCompression = p_value;
}
-float VehicleWheel3D::get_damping_compression() const {
+real_t VehicleWheel3D::get_damping_compression() const {
return m_wheelsDampingCompression;
}
-void VehicleWheel3D::set_damping_relaxation(float p_value) {
+void VehicleWheel3D::set_damping_relaxation(real_t p_value) {
m_wheelsDampingRelaxation = p_value;
}
-float VehicleWheel3D::get_damping_relaxation() const {
+real_t VehicleWheel3D::get_damping_relaxation() const {
return m_wheelsDampingRelaxation;
}
-void VehicleWheel3D::set_friction_slip(float p_value) {
+void VehicleWheel3D::set_friction_slip(real_t p_value) {
m_frictionSlip = p_value;
}
-float VehicleWheel3D::get_friction_slip() const {
+real_t VehicleWheel3D::get_friction_slip() const {
return m_frictionSlip;
}
-void VehicleWheel3D::set_roll_influence(float p_value) {
+void VehicleWheel3D::set_roll_influence(real_t p_value) {
m_rollInfluence = p_value;
}
-float VehicleWheel3D::get_roll_influence() const {
+real_t VehicleWheel3D::get_roll_influence() const {
return m_rollInfluence;
}
@@ -295,27 +295,27 @@ void VehicleWheel3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "damping_relaxation"), "set_damping_relaxation", "get_damping_relaxation");
}
-void VehicleWheel3D::set_engine_force(float p_engine_force) {
+void VehicleWheel3D::set_engine_force(real_t p_engine_force) {
m_engineForce = p_engine_force;
}
-float VehicleWheel3D::get_engine_force() const {
+real_t VehicleWheel3D::get_engine_force() const {
return m_engineForce;
}
-void VehicleWheel3D::set_brake(float p_brake) {
+void VehicleWheel3D::set_brake(real_t p_brake) {
m_brake = p_brake;
}
-float VehicleWheel3D::get_brake() const {
+real_t VehicleWheel3D::get_brake() const {
return m_brake;
}
-void VehicleWheel3D::set_steering(float p_steering) {
+void VehicleWheel3D::set_steering(real_t p_steering) {
m_steering = p_steering;
}
-float VehicleWheel3D::get_steering() const {
+real_t VehicleWheel3D::get_steering() const {
return m_steering;
}
@@ -335,11 +335,11 @@ bool VehicleWheel3D::is_used_as_steering() const {
return steers;
}
-float VehicleWheel3D::get_skidinfo() const {
+real_t VehicleWheel3D::get_skidinfo() const {
return m_skidInfo;
}
-float VehicleWheel3D::get_rpm() const {
+real_t VehicleWheel3D::get_rpm() const {
return m_rpm;
}
@@ -564,7 +564,7 @@ void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState3D *s, const
Vector3 vel = vel1 - vel2;
Basis b2trans;
- float b2invmass = 0;
+ real_t b2invmass = 0;
Vector3 b2lv;
Vector3 b2av;
Vector3 b2invinertia; //todo
@@ -622,8 +622,8 @@ VehicleBody3D::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDir
m_frictionPositionWorld(frictionPosWorld),
m_frictionDirectionWorld(frictionDirectionWorld),
m_maxImpulse(maxImpulse) {
- float denom0 = 0;
- float denom1 = 0;
+ real_t denom0 = 0;
+ real_t denom1 = 0;
{
Vector3 r0 = frictionPosWorld - s->get_transform().origin;
@@ -831,7 +831,7 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) {
state = Object::cast_to<PhysicsDirectBodyState3D>(p_state);
- float step = state->get_step();
+ real_t step = state->get_step();
for (int i = 0; i < wheels.size(); i++) {
_update_wheel(i, state);
@@ -891,7 +891,7 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) {
state = nullptr;
}
-void VehicleBody3D::set_engine_force(float p_engine_force) {
+void VehicleBody3D::set_engine_force(real_t p_engine_force) {
engine_force = p_engine_force;
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel3D &wheelInfo = *wheels[i];
@@ -901,11 +901,11 @@ void VehicleBody3D::set_engine_force(float p_engine_force) {
}
}
-float VehicleBody3D::get_engine_force() const {
+real_t VehicleBody3D::get_engine_force() const {
return engine_force;
}
-void VehicleBody3D::set_brake(float p_brake) {
+void VehicleBody3D::set_brake(real_t p_brake) {
brake = p_brake;
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel3D &wheelInfo = *wheels[i];
@@ -913,11 +913,11 @@ void VehicleBody3D::set_brake(float p_brake) {
}
}
-float VehicleBody3D::get_brake() const {
+real_t VehicleBody3D::get_brake() const {
return brake;
}
-void VehicleBody3D::set_steering(float p_steering) {
+void VehicleBody3D::set_steering(real_t p_steering) {
m_steeringValue = p_steering;
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel3D &wheelInfo = *wheels[i];
@@ -927,7 +927,7 @@ void VehicleBody3D::set_steering(float p_steering) {
}
}
-float VehicleBody3D::get_steering() const {
+real_t VehicleBody3D::get_steering() const {
return m_steeringValue;
}
diff --git a/scene/3d/vehicle_body_3d.h b/scene/3d/vehicle_body_3d.h
index ca7ea6574d..790179a8f0 100644
--- a/scene/3d/vehicle_body_3d.h
+++ b/scene/3d/vehicle_body_3d.h
@@ -97,29 +97,29 @@ protected:
static void _bind_methods();
public:
- void set_radius(float p_radius);
- float get_radius() const;
+ void set_radius(real_t p_radius);
+ real_t get_radius() const;
- void set_suspension_rest_length(float p_length);
- float get_suspension_rest_length() const;
+ void set_suspension_rest_length(real_t p_length);
+ real_t get_suspension_rest_length() const;
- void set_suspension_travel(float p_length);
- float get_suspension_travel() const;
+ void set_suspension_travel(real_t p_length);
+ real_t get_suspension_travel() const;
- void set_suspension_stiffness(float p_value);
- float get_suspension_stiffness() const;
+ void set_suspension_stiffness(real_t p_value);
+ real_t get_suspension_stiffness() const;
- void set_suspension_max_force(float p_value);
- float get_suspension_max_force() const;
+ void set_suspension_max_force(real_t p_value);
+ real_t get_suspension_max_force() const;
- void set_damping_compression(float p_value);
- float get_damping_compression() const;
+ void set_damping_compression(real_t p_value);
+ real_t get_damping_compression() const;
- void set_damping_relaxation(float p_value);
- float get_damping_relaxation() const;
+ void set_damping_relaxation(real_t p_value);
+ real_t get_damping_relaxation() const;
- void set_friction_slip(float p_value);
- float get_friction_slip() const;
+ void set_friction_slip(real_t p_value);
+ real_t get_friction_slip() const;
void set_use_as_traction(bool p_enable);
bool is_used_as_traction() const;
@@ -129,21 +129,21 @@ public:
bool is_in_contact() const;
- void set_roll_influence(float p_value);
- float get_roll_influence() const;
+ void set_roll_influence(real_t p_value);
+ real_t get_roll_influence() const;
- float get_skidinfo() const;
+ real_t get_skidinfo() const;
- float get_rpm() const;
+ real_t get_rpm() const;
- void set_engine_force(float p_engine_force);
- float get_engine_force() const;
+ void set_engine_force(real_t p_engine_force);
+ real_t get_engine_force() const;
- void set_brake(float p_brake);
- float get_brake() const;
+ void set_brake(real_t p_brake);
+ real_t get_brake() const;
- void set_steering(float p_steering);
- float get_steering() const;
+ void set_steering(real_t p_steering);
+ real_t get_steering() const;
String get_configuration_warning() const override;
@@ -153,8 +153,8 @@ public:
class VehicleBody3D : public RigidBody3D {
GDCLASS(VehicleBody3D, RigidBody3D);
- float engine_force;
- float brake;
+ real_t engine_force;
+ real_t brake;
real_t m_pitchControl;
real_t m_steeringValue;
@@ -195,14 +195,14 @@ class VehicleBody3D : public RigidBody3D {
void _direct_state_changed(Object *p_state) override;
public:
- void set_engine_force(float p_engine_force);
- float get_engine_force() const;
+ void set_engine_force(real_t p_engine_force);
+ real_t get_engine_force() const;
- void set_brake(float p_brake);
- float get_brake() const;
+ void set_brake(real_t p_brake);
+ real_t get_brake() const;
- void set_steering(float p_steering);
- float get_steering() const;
+ void set_steering(real_t p_steering);
+ real_t get_steering() const;
VehicleBody3D();
};
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index f7c9583fbf..8b3daf79a8 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -306,10 +306,10 @@ void Button::_notification(int p_what) {
Color font_outline_color = get_theme_color("font_outline_color");
int outline_size = get_theme_constant("outline_size");
if (outline_size > 0 && font_outline_color.a > 0) {
- text_buf->draw_outline(ci, text_ofs.floor(), outline_size, font_outline_color);
+ text_buf->draw_outline(ci, text_ofs, outline_size, font_outline_color);
}
- text_buf->draw(ci, text_ofs.floor(), color);
+ text_buf->draw(ci, text_ofs, color);
if (!_icon.is_null() && icon_region.size.width > 0) {
draw_texture_rect_region(_icon, icon_region, Rect2(Point2(), _icon->get_size()), color_icon);
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 9f5c87377f..6a83042b00 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -71,6 +71,8 @@ bool GraphNode::_set(const StringName &p_name, const Variant &p_value) {
si.enable_left = p_value;
} else if (what == "left_type") {
si.type_left = p_value;
+ } else if (what == "left_icon") {
+ si.custom_slot_left = p_value;
} else if (what == "left_color") {
si.color_left = p_value;
} else if (what == "right_enabled") {
@@ -79,11 +81,13 @@ bool GraphNode::_set(const StringName &p_name, const Variant &p_value) {
si.type_right = p_value;
} else if (what == "right_color") {
si.color_right = p_value;
+ } else if (what == "right_icon") {
+ si.custom_slot_right = p_value;
} else {
return false;
}
- set_slot(idx, si.enable_left, si.type_left, si.color_left, si.enable_right, si.type_right, si.color_right);
+ set_slot(idx, si.enable_left, si.type_left, si.color_left, si.enable_right, si.type_right, si.color_right, si.custom_slot_left, si.custom_slot_right);
update();
return true;
}
@@ -120,12 +124,16 @@ bool GraphNode::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = si.type_left;
} else if (what == "left_color") {
r_ret = si.color_left;
+ } else if (what == "left_icon") {
+ r_ret = si.custom_slot_left;
} else if (what == "right_enabled") {
r_ret = si.enable_right;
} else if (what == "right_type") {
r_ret = si.type_right;
} else if (what == "right_color") {
r_ret = si.color_right;
+ } else if (what == "right_icon") {
+ r_ret = si.custom_slot_right;
} else {
return false;
}
@@ -152,9 +160,11 @@ void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::BOOL, base + "left_enabled"));
p_list->push_back(PropertyInfo(Variant::INT, base + "left_type"));
p_list->push_back(PropertyInfo(Variant::COLOR, base + "left_color"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, base + "left_icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
p_list->push_back(PropertyInfo(Variant::BOOL, base + "right_enabled"));
p_list->push_back(PropertyInfo(Variant::INT, base + "right_type"));
p_list->push_back(PropertyInfo(Variant::COLOR, base + "right_color"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, base + "right_icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
idx++;
}
@@ -355,7 +365,9 @@ void GraphNode::_shape() {
void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture2D> &p_custom_left, const Ref<Texture2D> &p_custom_right) {
ERR_FAIL_COND(p_idx < 0);
- if (!p_enable_left && p_type_left == 0 && p_color_left == Color(1, 1, 1, 1) && !p_enable_right && p_type_right == 0 && p_color_right == Color(1, 1, 1, 1)) {
+ if (!p_enable_left && p_type_left == 0 && p_color_left == Color(1, 1, 1, 1) &&
+ !p_enable_right && p_type_right == 0 && p_color_right == Color(1, 1, 1, 1) &&
+ !p_custom_left.is_valid() && !p_custom_right.is_valid()) {
slot_info.erase(p_idx);
return;
}
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 799b0ed612..bd57817bd3 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1194,7 +1194,6 @@ void ItemList::_notification(int p_what) {
}
if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) {
- text_ofs = text_ofs.floor();
text_ofs += base_ofs;
text_ofs += items[i].rect_cache.position;
@@ -1217,7 +1216,6 @@ void ItemList::_notification(int p_what) {
text_ofs.y += (items[i].rect_cache.size.height - size2.y) / 2;
}
- text_ofs = text_ofs.floor();
text_ofs += base_ofs;
text_ofs += items[i].rect_cache.position;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index d5249e9ee5..81c53708ab 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -810,8 +810,8 @@ void TextEdit::_notification(int p_what) {
}
}
+ bool is_cursor_line_visible = false;
Point2 cursor_pos;
- int cursor_insert_offset_y = 0;
// Get the highlighted words.
String highlighted_text = get_selection_text();
@@ -1238,6 +1238,7 @@ void TextEdit::_notification(int p_what) {
}
}
+ const int line_top_offset_y = ofs_y;
ofs_y += (row_height - text_height) / 2;
const Vector<TextServer::Glyph> visual = TS->shaped_text_get_glyphs(rid);
@@ -1327,7 +1328,9 @@ void TextEdit::_notification(int p_what) {
int caret_width = 1;
#endif
if (cursor.line == line && ((line_wrap_index == line_wrap_amount) || (cursor.column != TS->shaped_text_get_range(rid).y))) {
- cursor_pos.y = ofs_y + ldata->get_line_descent(line_wrap_index);
+ is_cursor_line_visible = true;
+ cursor_pos.y = line_top_offset_y;
+
if (ime_text.length() == 0) {
Rect2 l_caret, t_caret;
TextServer::Direction l_dir, t_dir;
@@ -1446,78 +1449,97 @@ void TextEdit::_notification(int p_what) {
}
bool completion_below = false;
- if (completion_active && completion_options.size() > 0) {
- // Code completion box.
- Ref<StyleBox> csb = get_theme_stylebox("completion");
- int maxlines = get_theme_constant("completion_lines");
- int cmax_width = get_theme_constant("completion_max_width") * cache.font->get_char_size('x', 0, cache.font_size).x;
- int scrollw = get_theme_constant("completion_scroll_width");
- Color scrollc = get_theme_color("completion_scroll_color");
+ if (completion_active && is_cursor_line_visible && completion_options.size() > 0) {
+ // Completion panel
+
+ const Ref<StyleBox> csb = get_theme_stylebox("completion");
+ const int maxlines = get_theme_constant("completion_lines");
+ const int cmax_width = get_theme_constant("completion_max_width") * cache.font->get_char_size('x', 0, cache.font_size).x;
+ const Color scrollc = get_theme_color("completion_scroll_color");
const int completion_options_size = completion_options.size();
- int lines = MIN(completion_options_size, maxlines);
- int w = 0;
- int h = lines * row_height;
- int nofs = cache.font->get_string_size(completion_base, cache.font_size).width;
+ const int row_count = MIN(completion_options_size, maxlines);
+ const int completion_rows_height = row_count * row_height;
+ const int completion_base_width = cache.font->get_string_size(completion_base, cache.font_size).width;
+
+ int scroll_rectangle_width = get_theme_constant("completion_scroll_width");
+ int width = 0;
+ // Compute max width of the panel based on the longest completion option
if (completion_options_size < 50) {
for (int i = 0; i < completion_options_size; i++) {
- int w2 = MIN(cache.font->get_string_size(completion_options[i].display, cache.font_size).x, cmax_width);
- if (w2 > w) {
- w = w2;
+ int line_width = MIN(cache.font->get_string_size(completion_options[i].display, cache.font_size).x, cmax_width);
+ if (line_width > width) {
+ width = line_width;
}
}
} else {
- w = cmax_width;
+ width = cmax_width;
}
// Add space for completion icons.
const int icon_hsep = get_theme_constant("hseparation", "ItemList");
- Size2 icon_area_size(row_height, row_height);
- w += icon_area_size.width + icon_hsep;
+ const Size2 icon_area_size(row_height, row_height);
+ const int icon_area_width = icon_area_size.width + icon_hsep;
+ width += icon_area_width;
- int line_from = CLAMP(completion_index - lines / 2, 0, completion_options_size - lines);
+ const int line_from = CLAMP(completion_index - row_count / 2, 0, completion_options_size - row_count);
- for (int i = 0; i < lines; i++) {
+ for (int i = 0; i < row_count; i++) {
int l = line_from + i;
ERR_CONTINUE(l < 0 || l >= completion_options_size);
if (completion_options[l].default_value.get_type() == Variant::COLOR) {
- w += icon_area_size.width;
+ width += icon_area_size.width;
break;
}
}
- int th = h + csb->get_minimum_size().y;
+ // Position completion panel
+ completion_rect.size.width = width + 2;
+ completion_rect.size.height = completion_rows_height;
- if (cursor_pos.y + row_height + th > get_size().height) {
- completion_rect.position.y = cursor_pos.y - th - (cache.line_spacing / 2.0f) - cursor_insert_offset_y;
- } else {
- completion_rect.position.y = cursor_pos.y + cache.font->get_height(cache.font_size) + (cache.line_spacing / 2.0f) + csb->get_offset().y - cursor_insert_offset_y;
- completion_below = true;
+ if (completion_options_size <= maxlines) {
+ scroll_rectangle_width = 0;
}
- if (cursor_pos.x - nofs + w + scrollw > get_size().width) {
- completion_rect.position.x = get_size().width - w - scrollw;
+ const Point2 csb_offset = csb->get_offset();
+
+ const int total_width = completion_rect.size.width + csb->get_minimum_size().x + scroll_rectangle_width;
+ const int total_height = completion_rect.size.height + csb->get_minimum_size().y;
+
+ const int rect_left_border_x = cursor_pos.x - completion_base_width - icon_area_width - csb_offset.x;
+ const int rect_right_border_x = rect_left_border_x + total_width;
+
+ if (rect_left_border_x < 0) {
+ // Anchor the completion panel to the left
+ completion_rect.position.x = 0;
+ } else if (rect_right_border_x > get_size().width) {
+ // Anchor the completion panel to the right
+ completion_rect.position.x = get_size().width - total_width;
} else {
- completion_rect.position.x = cursor_pos.x - nofs;
+ // Let the completion panel float with the cursor
+ completion_rect.position.x = rect_left_border_x;
}
- completion_rect.size.width = w + 2;
- completion_rect.size.height = h;
- if (completion_options_size <= maxlines) {
- scrollw = 0;
+ if (cursor_pos.y + row_height + total_height > get_size().height) {
+ // Completion panel above the cursor line
+ completion_rect.position.y = cursor_pos.y - total_height;
+ } else {
+ // Completion panel below the cursor line
+ completion_rect.position.y = cursor_pos.y + row_height;
+ completion_below = true;
}
- draw_style_box(csb, Rect2(completion_rect.position - csb->get_offset(), completion_rect.size + csb->get_minimum_size() + Size2(scrollw, 0)));
+ draw_style_box(csb, Rect2(completion_rect.position - csb_offset, completion_rect.size + csb->get_minimum_size() + Size2(scroll_rectangle_width, 0)));
if (cache.completion_background_color.a > 0.01) {
- RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.position, completion_rect.size + Size2(scrollw, 0)), cache.completion_background_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.position, completion_rect.size + Size2(scroll_rectangle_width, 0)), cache.completion_background_color);
}
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.position.x, completion_rect.position.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color);
- draw_rect(Rect2(completion_rect.position + Vector2(icon_area_size.x + icon_hsep, 0), Size2(MIN(nofs, completion_rect.size.width - (icon_area_size.x + icon_hsep)), completion_rect.size.height)), cache.completion_existing_color);
+ draw_rect(Rect2(completion_rect.position + Vector2(icon_area_size.x + icon_hsep, 0), Size2(MIN(completion_base_width, completion_rect.size.width - (icon_area_size.x + icon_hsep)), completion_rect.size.height)), cache.completion_existing_color);
- for (int i = 0; i < lines; i++) {
+ for (int i = 0; i < row_count; i++) {
int l = line_from + i;
ERR_CONTINUE(l < 0 || l >= completion_options_size);
@@ -1557,11 +1579,11 @@ void TextEdit::_notification(int p_what) {
tl->draw(ci, title_pos, completion_options[l].font_color);
}
- if (scrollw) {
+ if (scroll_rectangle_width) {
// Draw a small scroll rectangle to show a position in the options.
float r = (float)maxlines / completion_options_size;
float o = (float)line_from / completion_options_size;
- draw_rect(Rect2(completion_rect.position.x + completion_rect.size.width, completion_rect.position.y + o * completion_rect.size.y, scrollw, completion_rect.size.y * r), scrollc);
+ draw_rect(Rect2(completion_rect.position.x + completion_rect.size.width, completion_rect.position.y + o * completion_rect.size.y, scroll_rectangle_width, completion_rect.size.y * r), scrollc);
}
completion_line_ofs = line_from;
@@ -1569,7 +1591,7 @@ void TextEdit::_notification(int p_what) {
// Check to see if the hint should be drawn.
bool show_hint = false;
- if (completion_hint != "") {
+ if (is_cursor_line_visible && completion_hint != "") {
if (completion_active) {
if (completion_below && !callhint_below) {
show_hint = true;
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index ddcf07c8e9..4c6b85d78b 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -163,7 +163,7 @@ Error HTTPRequest::request_raw(const String &p_url, const Vector<String> &p_cust
thread_done = false;
thread_request_quit = false;
client->set_blocking_mode(true);
- thread = Thread::create(_thread_func, this);
+ thread.start(_thread_func, this);
} else {
client->set_blocking_mode(false);
err = _request();
@@ -209,9 +209,7 @@ void HTTPRequest::cancel_request() {
set_process_internal(false);
} else {
thread_request_quit = true;
- Thread::wait_to_finish(thread);
- memdelete(thread);
- thread = nullptr;
+ thread.wait_to_finish();
}
if (file) {
@@ -640,8 +638,6 @@ void HTTPRequest::_bind_methods() {
}
HTTPRequest::HTTPRequest() {
- thread = nullptr;
-
port = 80;
redirections = 0;
max_redirects = 8;
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 6f606296e4..9dbf561cd4 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -110,7 +110,7 @@ private:
volatile bool thread_done;
volatile bool thread_request_quit;
- Thread *thread;
+ Thread thread;
void _request_done(int p_status, int p_code, const PackedStringArray &p_headers, const PackedByteArray &p_data);
static void _thread_func(void *p_userdata);
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 6a1b896b04..0c01516032 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2332,12 +2332,7 @@ static void find_owned_by(Node *p_by, Node *p_node, List<Node *> *p_owned) {
}
}
-struct _NodeReplaceByPair {
- String name;
- Variant value;
-};
-
-void Node::replace_by(Node *p_node, bool p_keep_data) {
+void Node::replace_by(Node *p_node, bool p_keep_groups) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_COND(p_node->data.parent);
@@ -2345,21 +2340,7 @@ void Node::replace_by(Node *p_node, bool p_keep_data) {
List<Node *> owned_by_owner;
Node *owner = (data.owner == this) ? p_node : data.owner;
- List<_NodeReplaceByPair> replace_data;
-
- if (p_keep_data) {
- List<PropertyInfo> plist;
- get_property_list(&plist);
-
- for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
- _NodeReplaceByPair rd;
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
- continue;
- }
- rd.name = E->get().name;
- rd.value = get(rd.name);
- }
-
+ if (p_keep_groups) {
List<GroupInfo> groups;
get_groups(&groups);
@@ -2404,10 +2385,6 @@ void Node::replace_by(Node *p_node, bool p_keep_data) {
}
p_node->set_filename(get_filename());
-
- for (List<_NodeReplaceByPair>::Element *E = replace_data.front(); E; E = E->next()) {
- p_node->set(E->get().name, E->get().value);
- }
}
void Node::_replace_connections_target(Node *p_new_target) {
@@ -2774,7 +2751,7 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_tree"), &Node::get_tree);
ClassDB::bind_method(D_METHOD("duplicate", "flags"), &Node::duplicate, DEFVAL(DUPLICATE_USE_INSTANCING | DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS));
- ClassDB::bind_method(D_METHOD("replace_by", "node", "keep_data"), &Node::replace_by, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("replace_by", "node", "keep_groups"), &Node::replace_by, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_scene_instance_load_placeholder", "load_placeholder"), &Node::set_scene_instance_load_placeholder);
ClassDB::bind_method(D_METHOD("get_scene_instance_load_placeholder"), &Node::get_scene_instance_load_placeholder);
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index c349d090d8..b14c44689e 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -557,19 +557,14 @@ void register_scene_types() {
ClassDB::register_class<VisualShaderNodeDeterminant>();
ClassDB::register_class<VisualShaderNodeScalarDerivativeFunc>();
ClassDB::register_class<VisualShaderNodeVectorDerivativeFunc>();
- ClassDB::register_class<VisualShaderNodeScalarClamp>();
- ClassDB::register_class<VisualShaderNodeVectorClamp>();
+ ClassDB::register_class<VisualShaderNodeClamp>();
ClassDB::register_class<VisualShaderNodeFaceForward>();
ClassDB::register_class<VisualShaderNodeOuterProduct>();
- ClassDB::register_class<VisualShaderNodeVectorScalarStep>();
- ClassDB::register_class<VisualShaderNodeScalarSmoothStep>();
- ClassDB::register_class<VisualShaderNodeVectorSmoothStep>();
- ClassDB::register_class<VisualShaderNodeVectorScalarSmoothStep>();
+ ClassDB::register_class<VisualShaderNodeSmoothStep>();
+ ClassDB::register_class<VisualShaderNodeStep>();
ClassDB::register_class<VisualShaderNodeVectorDistance>();
ClassDB::register_class<VisualShaderNodeVectorRefract>();
- ClassDB::register_class<VisualShaderNodeScalarInterp>();
- ClassDB::register_class<VisualShaderNodeVectorInterp>();
- ClassDB::register_class<VisualShaderNodeVectorScalarMix>();
+ ClassDB::register_class<VisualShaderNodeMix>();
ClassDB::register_class<VisualShaderNodeVectorCompose>();
ClassDB::register_class<VisualShaderNodeTransformCompose>();
ClassDB::register_class<VisualShaderNodeVectorDecompose>();
@@ -595,7 +590,6 @@ void register_scene_types() {
ClassDB::register_class<VisualShaderNodeCubemapUniform>();
ClassDB::register_class<VisualShaderNodeIf>();
ClassDB::register_class<VisualShaderNodeSwitch>();
- ClassDB::register_class<VisualShaderNodeScalarSwitch>();
ClassDB::register_class<VisualShaderNodeFresnel>();
ClassDB::register_class<VisualShaderNodeExpression>();
ClassDB::register_class<VisualShaderNodeGlobalExpression>();
@@ -935,6 +929,16 @@ void register_scene_types() {
ClassDB::add_compatibility_class("VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc");
ClassDB::add_compatibility_class("VisualShaderNodeScalarOp", "VisualShaderNodeFloatOp");
ClassDB::add_compatibility_class("VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform");
+ ClassDB::add_compatibility_class("VisualShaderNodeScalarClamp", "VisualShaderNodeClamp");
+ ClassDB::add_compatibility_class("VisualShaderNodeVectorClamp", "VisualShaderNodeClamp");
+ ClassDB::add_compatibility_class("VisualShaderNodeScalarInterp", "VisualShaderNodeMix");
+ ClassDB::add_compatibility_class("VisualShaderNodeVectorInterp", "VisualShaderNodeMix");
+ ClassDB::add_compatibility_class("VisualShaderNodeVectorScalarMix", "VisualShaderNodeMix");
+ ClassDB::add_compatibility_class("VisualShaderNodeScalarSmoothStep", "VisualShaderNodeSmoothStep");
+ ClassDB::add_compatibility_class("VisualShaderNodeVectorSmoothStep", "VisualShaderNodeSmoothStep");
+ ClassDB::add_compatibility_class("VisualShaderNodeVectorScalarSmoothStep", "VisualShaderNodeSmoothStep");
+ ClassDB::add_compatibility_class("VisualShaderNodeVectorScalarStep", "VisualShaderNodeStep");
+ ClassDB::add_compatibility_class("VisualShaderNodeScalarSwitch", "VisualShaderNodeSwitch");
ClassDB::add_compatibility_class("World", "World3D");
ClassDB::add_compatibility_class("StreamTexture", "StreamTexture2D");
ClassDB::add_compatibility_class("Light2D", "PointLight2D");
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp
index 6041f4a8b0..63d90a8364 100644
--- a/scene/resources/capsule_shape_2d.cpp
+++ b/scene/resources/capsule_shape_2d.cpp
@@ -36,12 +36,13 @@
Vector<Vector2> CapsuleShape2D::_get_points() const {
Vector<Vector2> points;
+ const real_t turn_step = Math_TAU / 24.0;
for (int i = 0; i < 24; i++) {
Vector2 ofs = Vector2(0, (i > 6 && i <= 18) ? -get_height() * 0.5 : get_height() * 0.5);
- points.push_back(Vector2(Math::sin(i * Math_PI * 2 / 24.0), Math::cos(i * Math_PI * 2 / 24.0)) * get_radius() + ofs);
+ points.push_back(Vector2(Math::sin(i * turn_step), Math::cos(i * turn_step)) * get_radius() + ofs);
if (i == 6 || i == 18) {
- points.push_back(Vector2(Math::sin(i * Math_PI * 2 / 24.0), Math::cos(i * Math_PI * 2 / 24.0)) * get_radius() - ofs);
+ points.push_back(Vector2(Math::sin(i * turn_step), Math::cos(i * turn_step)) * get_radius() - ofs);
}
}
diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp
index ba49587d9d..a44c1b68bf 100644
--- a/scene/resources/circle_shape_2d.cpp
+++ b/scene/resources/circle_shape_2d.cpp
@@ -71,8 +71,9 @@ real_t CircleShape2D::get_enclosing_radius() const {
void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector<Vector2> points;
+ const real_t turn_step = Math_TAU / 24.0;
for (int i = 0; i < 24; i++) {
- points.push_back(Vector2(Math::cos(i * Math_PI * 2 / 24.0), Math::sin(i * Math_PI * 2 / 24.0)) * get_radius());
+ points.push_back(Vector2(Math::cos(i * turn_step), Math::sin(i * turn_step)) * get_radius());
}
Vector<Color> col;
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index a6e9e7b5d2..398bce0602 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -304,8 +304,8 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
u = i;
u /= radial_segments;
- x = -sin(u * (Math_PI * 2.0));
- z = cos(u * (Math_PI * 2.0));
+ x = -sin(u * Math_TAU);
+ z = cos(u * Math_TAU);
Vector3 p = Vector3(x * radius * w, y, -z * radius * w);
points.push_back(p + Vector3(0.0, 0.5 * mid_height, 0.0));
@@ -343,8 +343,8 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
u = i;
u /= radial_segments;
- x = -sin(u * (Math_PI * 2.0));
- z = cos(u * (Math_PI * 2.0));
+ x = -sin(u * Math_TAU);
+ z = cos(u * Math_TAU);
Vector3 p = Vector3(x * radius, y, -z * radius);
points.push_back(p);
@@ -383,8 +383,8 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
float u2 = i;
u2 /= radial_segments;
- x = -sin(u2 * (Math_PI * 2.0));
- z = cos(u2 * (Math_PI * 2.0));
+ x = -sin(u2 * Math_TAU);
+ z = cos(u2 * Math_TAU);
Vector3 p = Vector3(x * radius * w, y, -z * radius * w);
points.push_back(p + Vector3(0.0, -0.5 * mid_height, 0.0));
@@ -769,8 +769,8 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
u = i;
u /= radial_segments;
- x = sin(u * (Math_PI * 2.0));
- z = cos(u * (Math_PI * 2.0));
+ x = sin(u * Math_TAU);
+ z = cos(u * Math_TAU);
Vector3 p = Vector3(x * radius, y, z * radius);
points.push_back(p);
@@ -809,8 +809,8 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
float r = i;
r /= radial_segments;
- x = sin(r * (Math_PI * 2.0));
- z = cos(r * (Math_PI * 2.0));
+ x = sin(r * Math_TAU);
+ z = cos(r * Math_TAU);
u = ((x + 1.0) * 0.25);
v = 0.5 + ((z + 1.0) * 0.25);
@@ -845,8 +845,8 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
float r = i;
r /= radial_segments;
- x = sin(r * (Math_PI * 2.0));
- z = cos(r * (Math_PI * 2.0));
+ x = sin(r * Math_TAU);
+ z = cos(r * Math_TAU);
u = 0.5 + ((x + 1.0) * 0.25);
v = 1.0 - ((z + 1.0) * 0.25);
@@ -1458,8 +1458,8 @@ void SphereMesh::_create_mesh_array(Array &p_arr) const {
float u = i;
u /= radial_segments;
- x = sin(u * (Math_PI * 2.0));
- z = cos(u * (Math_PI * 2.0));
+ x = sin(u * Math_TAU);
+ z = cos(u * Math_TAU);
if (is_hemisphere && y < 0.0) {
points.push_back(Vector3(x * radius * w, 0.0, z * radius * w));
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index a9d8eeef1c..7504a05a49 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -576,8 +576,8 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
color = outer_color;
corner_point = outer_points[corner_index];
}
- float x = radius * (float)cos((double)corner_index * Math_PI / 2.0 + (double)detail / (double)adapted_corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.x;
- float y = radius * (float)sin((double)corner_index * Math_PI / 2.0 + (double)detail / (double)adapted_corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.y;
+ real_t x = radius * (real_t)cos((corner_index + detail / (double)adapted_corner_detail) * (Math_TAU / 4.0) + Math_PI) + corner_point.x;
+ real_t y = radius * (real_t)sin((corner_index + detail / (double)adapted_corner_detail) * (Math_TAU / 4.0) + Math_PI) + corner_point.y;
verts.push_back(Vector2(x, y));
colors.push_back(color);
}
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index 8b60c0a979..d6200059f6 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -2086,9 +2086,6 @@ String VisualShaderNodeIntFunc::get_caption() const {
}
int VisualShaderNodeIntFunc::get_input_port_count() const {
- if (func == FUNC_CLAMP) {
- return 3;
- }
return 1;
}
@@ -2097,15 +2094,6 @@ VisualShaderNodeIntFunc::PortType VisualShaderNodeIntFunc::get_input_port_type(i
}
String VisualShaderNodeIntFunc::get_input_port_name(int p_port) const {
- if (func == FUNC_CLAMP) {
- if (p_port == 0) {
- return "";
- } else if (p_port == 1) {
- return "min";
- } else if (p_port == 2) {
- return "max";
- }
- }
return "";
}
@@ -2122,13 +2110,8 @@ String VisualShaderNodeIntFunc::get_output_port_name(int p_port) const {
}
String VisualShaderNodeIntFunc::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
- if (func == FUNC_CLAMP) {
- return "\t" + p_output_vars[0] + " = clamp(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
- }
-
static const char *int_func_id[FUNC_SIGN + 1] = {
"abs($)",
- "",
"-($)",
"sign($)"
};
@@ -2137,12 +2120,6 @@ String VisualShaderNodeIntFunc::generate_code(Shader::Mode p_mode, VisualShader:
}
void VisualShaderNodeIntFunc::set_function(Function p_func) {
- if (func != p_func) {
- if (p_func == FUNC_CLAMP) {
- set_input_port_default_value(1, 0);
- set_input_port_default_value(2, 0);
- }
- }
func = p_func;
emit_changed();
}
@@ -2161,10 +2138,9 @@ void VisualShaderNodeIntFunc::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeIntFunc::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeIntFunc::get_function);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, "Abs,Clamp,Negate,Sign"), "set_function", "get_function");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, "Abs,Negate,Sign"), "set_function", "get_function");
BIND_ENUM_CONSTANT(FUNC_ABS);
- BIND_ENUM_CONSTANT(FUNC_CLAMP);
BIND_ENUM_CONSTANT(FUNC_NEGATE);
BIND_ENUM_CONSTANT(FUNC_SIGN);
}
@@ -2754,21 +2730,31 @@ VisualShaderNodeVectorDerivativeFunc::VisualShaderNodeVectorDerivativeFunc() {
set_input_port_default_value(0, Vector3());
}
-////////////// Scalar Clamp
+////////////// Clamp
-String VisualShaderNodeScalarClamp::get_caption() const {
- return "ScalarClamp";
+String VisualShaderNodeClamp::get_caption() const {
+ return "Clamp";
}
-int VisualShaderNodeScalarClamp::get_input_port_count() const {
+int VisualShaderNodeClamp::get_input_port_count() const {
return 3;
}
-VisualShaderNodeScalarClamp::PortType VisualShaderNodeScalarClamp::get_input_port_type(int p_port) const {
+VisualShaderNodeClamp::PortType VisualShaderNodeClamp::get_input_port_type(int p_port) const {
+ switch (op_type) {
+ case OP_TYPE_FLOAT:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_INT:
+ return PORT_TYPE_SCALAR_INT;
+ case OP_TYPE_VECTOR:
+ return PORT_TYPE_VECTOR;
+ default:
+ break;
+ }
return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeScalarClamp::get_input_port_name(int p_port) const {
+String VisualShaderNodeClamp::get_input_port_name(int p_port) const {
if (p_port == 0) {
return "";
} else if (p_port == 1) {
@@ -2779,73 +2765,86 @@ String VisualShaderNodeScalarClamp::get_input_port_name(int p_port) const {
return "";
}
-int VisualShaderNodeScalarClamp::get_output_port_count() const {
+int VisualShaderNodeClamp::get_output_port_count() const {
return 1;
}
-VisualShaderNodeScalarClamp::PortType VisualShaderNodeScalarClamp::get_output_port_type(int p_port) const {
+VisualShaderNodeClamp::PortType VisualShaderNodeClamp::get_output_port_type(int p_port) const {
+ switch (op_type) {
+ case OP_TYPE_FLOAT:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_INT:
+ return PORT_TYPE_SCALAR_INT;
+ case OP_TYPE_VECTOR:
+ return PORT_TYPE_VECTOR;
+ default:
+ break;
+ }
return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeScalarClamp::get_output_port_name(int p_port) const {
+String VisualShaderNodeClamp::get_output_port_name(int p_port) const {
return "";
}
-String VisualShaderNodeScalarClamp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
+String VisualShaderNodeClamp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
return "\t" + p_output_vars[0] + " = clamp(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
}
-VisualShaderNodeScalarClamp::VisualShaderNodeScalarClamp() {
- set_input_port_default_value(0, 0.0);
- set_input_port_default_value(1, 0.0);
- set_input_port_default_value(2, 1.0);
-}
-
-////////////// Vector Clamp
-
-String VisualShaderNodeVectorClamp::get_caption() const {
- return "VectorClamp";
-}
-
-int VisualShaderNodeVectorClamp::get_input_port_count() const {
- return 3;
-}
-
-VisualShaderNodeVectorClamp::PortType VisualShaderNodeVectorClamp::get_input_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
-}
-
-String VisualShaderNodeVectorClamp::get_input_port_name(int p_port) const {
- if (p_port == 0) {
- return "";
- } else if (p_port == 1) {
- return "min";
- } else if (p_port == 2) {
- return "max";
+void VisualShaderNodeClamp::set_op_type(OpType p_op_type) {
+ ERR_FAIL_INDEX((int)p_op_type, OP_TYPE_MAX);
+ if (op_type == p_op_type) {
+ return;
}
- return "";
+ switch (p_op_type) {
+ case OP_TYPE_FLOAT:
+ set_input_port_default_value(0, 0.0);
+ set_input_port_default_value(1, 0.0);
+ set_input_port_default_value(2, 0.0);
+ break;
+ case OP_TYPE_INT:
+ set_input_port_default_value(0, 0);
+ set_input_port_default_value(1, 0);
+ set_input_port_default_value(2, 0);
+ break;
+ case OP_TYPE_VECTOR:
+ set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0));
+ set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0));
+ set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0));
+ break;
+ default:
+ break;
+ }
+ op_type = p_op_type;
+ emit_changed();
}
-int VisualShaderNodeVectorClamp::get_output_port_count() const {
- return 1;
+VisualShaderNodeClamp::OpType VisualShaderNodeClamp::get_op_type() const {
+ return op_type;
}
-VisualShaderNodeVectorClamp::PortType VisualShaderNodeVectorClamp::get_output_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
+Vector<StringName> VisualShaderNodeClamp::get_editable_properties() const {
+ Vector<StringName> props;
+ props.push_back("op_type");
+ return props;
}
-String VisualShaderNodeVectorClamp::get_output_port_name(int p_port) const {
- return "";
-}
+void VisualShaderNodeClamp::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_op_type", "type"), &VisualShaderNodeClamp::set_op_type);
+ ClassDB::bind_method(D_METHOD("get_op_type"), &VisualShaderNodeClamp::get_op_type);
-String VisualShaderNodeVectorClamp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
- return "\t" + p_output_vars[0] + " = clamp(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "op_type", PROPERTY_HINT_ENUM, "Float,Int,Vector"), "set_op_type", "get_op_type");
+
+ BIND_ENUM_CONSTANT(OP_TYPE_FLOAT);
+ BIND_ENUM_CONSTANT(OP_TYPE_INT);
+ BIND_ENUM_CONSTANT(OP_TYPE_VECTOR);
+ BIND_ENUM_CONSTANT(OP_TYPE_MAX);
}
-VisualShaderNodeVectorClamp::VisualShaderNodeVectorClamp() {
- set_input_port_default_value(0, Vector3(0, 0, 0));
- set_input_port_default_value(1, Vector3(0, 0, 0));
- set_input_port_default_value(2, Vector3(1, 1, 1));
+VisualShaderNodeClamp::VisualShaderNodeClamp() {
+ set_input_port_default_value(0, 0.0);
+ set_input_port_default_value(1, 0.0);
+ set_input_port_default_value(2, 1.0);
}
////////////// FaceForward
@@ -2943,24 +2942,39 @@ VisualShaderNodeOuterProduct::VisualShaderNodeOuterProduct() {
set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0));
}
-////////////// Vector-Scalar Step
+////////////// Step
-String VisualShaderNodeVectorScalarStep::get_caption() const {
- return "VectorScalarStep";
+String VisualShaderNodeStep::get_caption() const {
+ return "Step";
}
-int VisualShaderNodeVectorScalarStep::get_input_port_count() const {
+int VisualShaderNodeStep::get_input_port_count() const {
return 2;
}
-VisualShaderNodeVectorScalarStep::PortType VisualShaderNodeVectorScalarStep::get_input_port_type(int p_port) const {
- if (p_port == 0) {
- return PORT_TYPE_SCALAR;
+VisualShaderNodeStep::PortType VisualShaderNodeStep::get_input_port_type(int p_port) const {
+ switch (op_type) {
+ case OP_TYPE_SCALAR:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_VECTOR:
+ return PORT_TYPE_VECTOR;
+ case OP_TYPE_VECTOR_SCALAR:
+ switch (p_port) {
+ case 0:
+ return PORT_TYPE_SCALAR;
+ case 1:
+ return PORT_TYPE_VECTOR;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
}
- return PORT_TYPE_VECTOR;
+ return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeVectorScalarStep::get_input_port_name(int p_port) const {
+String VisualShaderNodeStep::get_input_port_name(int p_port) const {
if (p_port == 0) {
return "edge";
} else if (p_port == 1) {
@@ -2969,89 +2983,131 @@ String VisualShaderNodeVectorScalarStep::get_input_port_name(int p_port) const {
return "";
}
-int VisualShaderNodeVectorScalarStep::get_output_port_count() const {
+int VisualShaderNodeStep::get_output_port_count() const {
return 1;
}
-VisualShaderNodeVectorScalarStep::PortType VisualShaderNodeVectorScalarStep::get_output_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
+VisualShaderNodeStep::PortType VisualShaderNodeStep::get_output_port_type(int p_port) const {
+ switch (op_type) {
+ case OP_TYPE_SCALAR:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_VECTOR:
+ return PORT_TYPE_VECTOR;
+ case OP_TYPE_VECTOR_SCALAR:
+ return PORT_TYPE_VECTOR;
+ default:
+ break;
+ }
+ return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeVectorScalarStep::get_output_port_name(int p_port) const {
+String VisualShaderNodeStep::get_output_port_name(int p_port) const {
return "";
}
-String VisualShaderNodeVectorScalarStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
- return "\t" + p_output_vars[0] + " = step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
-}
-
-VisualShaderNodeVectorScalarStep::VisualShaderNodeVectorScalarStep() {
- set_input_port_default_value(0, 0.0);
- set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0));
-}
-
-////////////// Scalar SmoothStep
-
-String VisualShaderNodeScalarSmoothStep::get_caption() const {
- return "ScalarSmoothStep";
-}
-
-int VisualShaderNodeScalarSmoothStep::get_input_port_count() const {
- return 3;
+void VisualShaderNodeStep::set_op_type(OpType p_op_type) {
+ ERR_FAIL_INDEX((int)p_op_type, OP_TYPE_MAX);
+ if (op_type == p_op_type) {
+ return;
+ }
+ switch (p_op_type) {
+ case OP_TYPE_SCALAR:
+ if (op_type == OP_TYPE_VECTOR) {
+ set_input_port_default_value(0, 0.0); // edge
+ }
+ if (op_type == OP_TYPE_VECTOR || op_type == OP_TYPE_VECTOR_SCALAR) {
+ set_input_port_default_value(1, 0.0); // x
+ }
+ break;
+ case OP_TYPE_VECTOR:
+ if (op_type == OP_TYPE_SCALAR || op_type == OP_TYPE_VECTOR_SCALAR) {
+ set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0)); // edge
+ }
+ if (op_type == OP_TYPE_SCALAR) {
+ set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0)); // x
+ }
+ break;
+ case OP_TYPE_VECTOR_SCALAR:
+ if (op_type == OP_TYPE_VECTOR) {
+ set_input_port_default_value(0, 0.0); // edge
+ }
+ if (op_type == OP_TYPE_SCALAR) {
+ set_input_port_default_value(1, 0.0); // x
+ }
+ break;
+ default:
+ break;
+ }
+ op_type = p_op_type;
+ emit_changed();
}
-VisualShaderNodeScalarSmoothStep::PortType VisualShaderNodeScalarSmoothStep::get_input_port_type(int p_port) const {
- return PORT_TYPE_SCALAR;
+VisualShaderNodeStep::OpType VisualShaderNodeStep::get_op_type() const {
+ return op_type;
}
-String VisualShaderNodeScalarSmoothStep::get_input_port_name(int p_port) const {
- if (p_port == 0) {
- return "edge0";
- } else if (p_port == 1) {
- return "edge1";
- } else if (p_port == 2) {
- return "x";
- }
- return "";
+String VisualShaderNodeStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
+ return "\t" + p_output_vars[0] + " = step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
}
-int VisualShaderNodeScalarSmoothStep::get_output_port_count() const {
- return 1;
+Vector<StringName> VisualShaderNodeStep::get_editable_properties() const {
+ Vector<StringName> props;
+ props.push_back("op_type");
+ return props;
}
-VisualShaderNodeScalarSmoothStep::PortType VisualShaderNodeScalarSmoothStep::get_output_port_type(int p_port) const {
- return PORT_TYPE_SCALAR;
-}
+void VisualShaderNodeStep::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_op_type", "type"), &VisualShaderNodeStep::set_op_type);
+ ClassDB::bind_method(D_METHOD("get_op_type"), &VisualShaderNodeStep::get_op_type);
-String VisualShaderNodeScalarSmoothStep::get_output_port_name(int p_port) const {
- return "";
-}
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "op_type", PROPERTY_HINT_ENUM, "Scalar,Vector,VectorScalar"), "set_op_type", "get_op_type");
-String VisualShaderNodeScalarSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
- return "\t" + p_output_vars[0] + " = smoothstep(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
+ BIND_ENUM_CONSTANT(OP_TYPE_SCALAR);
+ BIND_ENUM_CONSTANT(OP_TYPE_VECTOR);
+ BIND_ENUM_CONSTANT(OP_TYPE_VECTOR_SCALAR);
+ BIND_ENUM_CONSTANT(OP_TYPE_MAX);
}
-VisualShaderNodeScalarSmoothStep::VisualShaderNodeScalarSmoothStep() {
+VisualShaderNodeStep::VisualShaderNodeStep() {
set_input_port_default_value(0, 0.0);
set_input_port_default_value(1, 0.0);
- set_input_port_default_value(2, 0.0);
}
-////////////// Vector SmoothStep
+////////////// SmoothStep
-String VisualShaderNodeVectorSmoothStep::get_caption() const {
- return "VectorSmoothStep";
+String VisualShaderNodeSmoothStep::get_caption() const {
+ return "SmoothStep";
}
-int VisualShaderNodeVectorSmoothStep::get_input_port_count() const {
+int VisualShaderNodeSmoothStep::get_input_port_count() const {
return 3;
}
-VisualShaderNodeVectorSmoothStep::PortType VisualShaderNodeVectorSmoothStep::get_input_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
+VisualShaderNodeSmoothStep::PortType VisualShaderNodeSmoothStep::get_input_port_type(int p_port) const {
+ switch (op_type) {
+ case OP_TYPE_SCALAR:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_VECTOR:
+ return PORT_TYPE_VECTOR;
+ case OP_TYPE_VECTOR_SCALAR:
+ switch (p_port) {
+ case 0:
+ return PORT_TYPE_SCALAR; // edge0
+ case 1:
+ return PORT_TYPE_SCALAR; // edge1
+ case 2:
+ return PORT_TYPE_VECTOR; // x
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeVectorSmoothStep::get_input_port_name(int p_port) const {
+String VisualShaderNodeSmoothStep::get_input_port_name(int p_port) const {
if (p_port == 0) {
return "edge0";
} else if (p_port == 1) {
@@ -3062,78 +3118,98 @@ String VisualShaderNodeVectorSmoothStep::get_input_port_name(int p_port) const {
return "";
}
-int VisualShaderNodeVectorSmoothStep::get_output_port_count() const {
+int VisualShaderNodeSmoothStep::get_output_port_count() const {
return 1;
}
-VisualShaderNodeVectorSmoothStep::PortType VisualShaderNodeVectorSmoothStep::get_output_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
+VisualShaderNodeSmoothStep::PortType VisualShaderNodeSmoothStep::get_output_port_type(int p_port) const {
+ switch (op_type) {
+ case OP_TYPE_SCALAR:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_VECTOR:
+ return PORT_TYPE_VECTOR;
+ case OP_TYPE_VECTOR_SCALAR:
+ return PORT_TYPE_VECTOR;
+ default:
+ break;
+ }
+ return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeVectorSmoothStep::get_output_port_name(int p_port) const {
+String VisualShaderNodeSmoothStep::get_output_port_name(int p_port) const {
return "";
}
-String VisualShaderNodeVectorSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
- return "\t" + p_output_vars[0] + " = smoothstep(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
-}
-
-VisualShaderNodeVectorSmoothStep::VisualShaderNodeVectorSmoothStep() {
- set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0));
- set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0));
- set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0));
-}
-
-////////////// Vector-Scalar SmoothStep
-
-String VisualShaderNodeVectorScalarSmoothStep::get_caption() const {
- return "VectorScalarSmoothStep";
-}
-
-int VisualShaderNodeVectorScalarSmoothStep::get_input_port_count() const {
- return 3;
-}
-
-VisualShaderNodeVectorScalarSmoothStep::PortType VisualShaderNodeVectorScalarSmoothStep::get_input_port_type(int p_port) const {
- if (p_port == 0) {
- return PORT_TYPE_SCALAR;
- } else if (p_port == 1) {
- return PORT_TYPE_SCALAR;
+void VisualShaderNodeSmoothStep::set_op_type(OpType p_op_type) {
+ ERR_FAIL_INDEX((int)p_op_type, OP_TYPE_MAX);
+ if (op_type == p_op_type) {
+ return;
+ }
+ switch (p_op_type) {
+ case OP_TYPE_SCALAR:
+ if (op_type == OP_TYPE_VECTOR) {
+ set_input_port_default_value(0, 0.0); // edge0
+ set_input_port_default_value(1, 0.0); // edge1
+ }
+ if (op_type == OP_TYPE_VECTOR || op_type == OP_TYPE_VECTOR_SCALAR) {
+ set_input_port_default_value(2, 0.0); // x
+ }
+ break;
+ case OP_TYPE_VECTOR:
+ if (op_type == OP_TYPE_SCALAR || op_type == OP_TYPE_VECTOR_SCALAR) {
+ set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0)); // edge0
+ set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0)); // edge1
+ }
+ if (op_type == OP_TYPE_SCALAR) {
+ set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0)); // x
+ }
+ break;
+ case OP_TYPE_VECTOR_SCALAR:
+ if (op_type == OP_TYPE_VECTOR) {
+ set_input_port_default_value(0, 0.0); // edge0
+ set_input_port_default_value(1, 0.0); // edge1
+ }
+ if (op_type == OP_TYPE_SCALAR) {
+ set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0)); // x
+ }
+ break;
+ default:
+ break;
}
- return PORT_TYPE_VECTOR;
+ op_type = p_op_type;
+ emit_changed();
}
-String VisualShaderNodeVectorScalarSmoothStep::get_input_port_name(int p_port) const {
- if (p_port == 0) {
- return "edge0";
- } else if (p_port == 1) {
- return "edge1";
- } else if (p_port == 2) {
- return "x";
- }
- return "";
+VisualShaderNodeSmoothStep::OpType VisualShaderNodeSmoothStep::get_op_type() const {
+ return op_type;
}
-int VisualShaderNodeVectorScalarSmoothStep::get_output_port_count() const {
- return 1;
+String VisualShaderNodeSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
+ return "\t" + p_output_vars[0] + " = smoothstep(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
}
-VisualShaderNodeVectorScalarSmoothStep::PortType VisualShaderNodeVectorScalarSmoothStep::get_output_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
+Vector<StringName> VisualShaderNodeSmoothStep::get_editable_properties() const {
+ Vector<StringName> props;
+ props.push_back("op_type");
+ return props;
}
-String VisualShaderNodeVectorScalarSmoothStep::get_output_port_name(int p_port) const {
- return "";
-}
+void VisualShaderNodeSmoothStep::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_op_type", "type"), &VisualShaderNodeSmoothStep::set_op_type);
+ ClassDB::bind_method(D_METHOD("get_op_type"), &VisualShaderNodeSmoothStep::get_op_type);
-String VisualShaderNodeVectorScalarSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
- return "\t" + p_output_vars[0] + " = smoothstep(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "op_type", PROPERTY_HINT_ENUM, "Scalar,Vector,VectorScalar"), "set_op_type", "get_op_type");
+
+ BIND_ENUM_CONSTANT(OP_TYPE_SCALAR);
+ BIND_ENUM_CONSTANT(OP_TYPE_VECTOR);
+ BIND_ENUM_CONSTANT(OP_TYPE_VECTOR_SCALAR);
+ BIND_ENUM_CONSTANT(OP_TYPE_MAX);
}
-VisualShaderNodeVectorScalarSmoothStep::VisualShaderNodeVectorScalarSmoothStep() {
+VisualShaderNodeSmoothStep::VisualShaderNodeSmoothStep() {
set_input_port_default_value(0, 0.0);
set_input_port_default_value(1, 0.0);
- set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0));
+ set_input_port_default_value(2, 0.0);
}
////////////// Distance
@@ -3231,21 +3307,37 @@ VisualShaderNodeVectorRefract::VisualShaderNodeVectorRefract() {
set_input_port_default_value(2, 0.0);
}
-////////////// Scalar Mix
+////////////// Mix
-String VisualShaderNodeScalarInterp::get_caption() const {
- return "ScalarMix";
+String VisualShaderNodeMix::get_caption() const {
+ return "Mix";
}
-int VisualShaderNodeScalarInterp::get_input_port_count() const {
+int VisualShaderNodeMix::get_input_port_count() const {
return 3;
}
-VisualShaderNodeScalarInterp::PortType VisualShaderNodeScalarInterp::get_input_port_type(int p_port) const {
+VisualShaderNodeMix::PortType VisualShaderNodeMix::get_input_port_type(int p_port) const {
+ switch (op_type) {
+ case OP_TYPE_SCALAR:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_VECTOR:
+ if (p_port == 2) {
+ return PORT_TYPE_VECTOR;
+ }
+ return PORT_TYPE_VECTOR;
+ case OP_TYPE_VECTOR_SCALAR:
+ if (p_port == 2) {
+ return PORT_TYPE_SCALAR;
+ }
+ return PORT_TYPE_VECTOR;
+ default:
+ break;
+ }
return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeScalarInterp::get_input_port_name(int p_port) const {
+String VisualShaderNodeMix::get_input_port_name(int p_port) const {
if (p_port == 0) {
return "a";
} else if (p_port == 1) {
@@ -3255,121 +3347,92 @@ String VisualShaderNodeScalarInterp::get_input_port_name(int p_port) const {
}
}
-int VisualShaderNodeScalarInterp::get_output_port_count() const {
+int VisualShaderNodeMix::get_output_port_count() const {
return 1;
}
-VisualShaderNodeScalarInterp::PortType VisualShaderNodeScalarInterp::get_output_port_type(int p_port) const {
+VisualShaderNodeMix::PortType VisualShaderNodeMix::get_output_port_type(int p_port) const {
+ switch (op_type) {
+ case OP_TYPE_SCALAR:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_VECTOR:
+ return PORT_TYPE_VECTOR;
+ case OP_TYPE_VECTOR_SCALAR:
+ return PORT_TYPE_VECTOR;
+ default:
+ break;
+ }
return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeScalarInterp::get_output_port_name(int p_port) const {
+String VisualShaderNodeMix::get_output_port_name(int p_port) const {
return "mix";
}
-String VisualShaderNodeScalarInterp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
- return "\t" + p_output_vars[0] + " = mix(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
-}
-
-VisualShaderNodeScalarInterp::VisualShaderNodeScalarInterp() {
- set_input_port_default_value(0, 0.0);
- set_input_port_default_value(1, 1.0);
- set_input_port_default_value(2, 0.5);
-}
-
-////////////// Vector Mix
-
-String VisualShaderNodeVectorInterp::get_caption() const {
- return "VectorMix";
-}
-
-int VisualShaderNodeVectorInterp::get_input_port_count() const {
- return 3;
-}
-
-VisualShaderNodeVectorInterp::PortType VisualShaderNodeVectorInterp::get_input_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
-}
-
-String VisualShaderNodeVectorInterp::get_input_port_name(int p_port) const {
- if (p_port == 0) {
- return "a";
- } else if (p_port == 1) {
- return "b";
- } else {
- return "weight";
+void VisualShaderNodeMix::set_op_type(OpType p_op_type) {
+ ERR_FAIL_INDEX((int)p_op_type, OP_TYPE_MAX);
+ if (op_type == p_op_type) {
+ return;
+ }
+ switch (p_op_type) {
+ case OP_TYPE_SCALAR:
+ set_input_port_default_value(0, 0.0); // a
+ set_input_port_default_value(1, 1.0); // b
+ if (op_type == OP_TYPE_VECTOR) {
+ set_input_port_default_value(2, 0.5); // weight
+ }
+ break;
+ case OP_TYPE_VECTOR:
+ set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0)); // a
+ set_input_port_default_value(1, Vector3(1.0, 1.0, 1.0)); // b
+ if (op_type == OP_TYPE_SCALAR || op_type == OP_TYPE_VECTOR_SCALAR) {
+ set_input_port_default_value(2, Vector3(0.5, 0.5, 0.5)); // weight
+ }
+ break;
+ case OP_TYPE_VECTOR_SCALAR:
+ set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0)); // a
+ set_input_port_default_value(1, Vector3(1.0, 1.0, 1.0)); // b
+ if (op_type == OP_TYPE_VECTOR) {
+ set_input_port_default_value(2, 0.5); // weight
+ }
+ break;
+ default:
+ break;
}
+ op_type = p_op_type;
+ emit_changed();
}
-int VisualShaderNodeVectorInterp::get_output_port_count() const {
- return 1;
-}
-
-VisualShaderNodeVectorInterp::PortType VisualShaderNodeVectorInterp::get_output_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
-}
-
-String VisualShaderNodeVectorInterp::get_output_port_name(int p_port) const {
- return "mix";
+VisualShaderNodeMix::OpType VisualShaderNodeMix::get_op_type() const {
+ return op_type;
}
-String VisualShaderNodeVectorInterp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
+String VisualShaderNodeMix::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
return "\t" + p_output_vars[0] + " = mix(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
}
-VisualShaderNodeVectorInterp::VisualShaderNodeVectorInterp() {
- set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0));
- set_input_port_default_value(1, Vector3(1.0, 1.0, 1.0));
- set_input_port_default_value(2, Vector3(0.5, 0.5, 0.5));
-}
-
-////////////// Vector Mix (by scalar)
-
-String VisualShaderNodeVectorScalarMix::get_caption() const {
- return "VectorScalarMix";
-}
-
-int VisualShaderNodeVectorScalarMix::get_input_port_count() const {
- return 3;
-}
-
-VisualShaderNodeVectorScalarMix::PortType VisualShaderNodeVectorScalarMix::get_input_port_type(int p_port) const {
- if (p_port == 2) {
- return PORT_TYPE_SCALAR;
- }
- return PORT_TYPE_VECTOR;
-}
-
-String VisualShaderNodeVectorScalarMix::get_input_port_name(int p_port) const {
- if (p_port == 0) {
- return "a";
- } else if (p_port == 1) {
- return "b";
- } else {
- return "weight";
- }
-}
-
-int VisualShaderNodeVectorScalarMix::get_output_port_count() const {
- return 1;
+Vector<StringName> VisualShaderNodeMix::get_editable_properties() const {
+ Vector<StringName> props;
+ props.push_back("op_type");
+ return props;
}
-VisualShaderNodeVectorScalarMix::PortType VisualShaderNodeVectorScalarMix::get_output_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
-}
+void VisualShaderNodeMix::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_op_type", "type"), &VisualShaderNodeMix::set_op_type);
+ ClassDB::bind_method(D_METHOD("get_op_type"), &VisualShaderNodeMix::get_op_type);
-String VisualShaderNodeVectorScalarMix::get_output_port_name(int p_port) const {
- return "mix";
-}
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "op_type", PROPERTY_HINT_ENUM, "Scalar,Vector,VectorScalar"), "set_op_type", "get_op_type");
-String VisualShaderNodeVectorScalarMix::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
- return "\t" + p_output_vars[0] + " = mix(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
+ BIND_ENUM_CONSTANT(OP_TYPE_SCALAR);
+ BIND_ENUM_CONSTANT(OP_TYPE_VECTOR);
+ BIND_ENUM_CONSTANT(OP_TYPE_VECTOR_SCALAR);
+ BIND_ENUM_CONSTANT(OP_TYPE_MAX);
}
-VisualShaderNodeVectorScalarMix::VisualShaderNodeVectorScalarMix() {
- set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0));
- set_input_port_default_value(1, Vector3(1.0, 1.0, 1.0));
- set_input_port_default_value(2, 0.5);
+VisualShaderNodeMix::VisualShaderNodeMix() {
+ set_input_port_default_value(0, 0.0); // a
+ set_input_port_default_value(1, 1.0); // b
+ set_input_port_default_value(2, 0.5); // weight
}
////////////// Vector Compose
@@ -4847,7 +4910,7 @@ VisualShaderNodeIf::VisualShaderNodeIf() {
////////////// Switch
String VisualShaderNodeSwitch::get_caption() const {
- return "VectorSwitch";
+ return "Switch";
}
int VisualShaderNodeSwitch::get_input_port_count() const {
@@ -4858,7 +4921,23 @@ VisualShaderNodeSwitch::PortType VisualShaderNodeSwitch::get_input_port_type(int
if (p_port == 0) {
return PORT_TYPE_BOOLEAN;
}
- return PORT_TYPE_VECTOR;
+ if (p_port == 1 || p_port == 2) {
+ switch (op_type) {
+ case OP_TYPE_FLOAT:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_INT:
+ return PORT_TYPE_SCALAR_INT;
+ case OP_TYPE_VECTOR:
+ return PORT_TYPE_VECTOR;
+ case OP_TYPE_BOOLEAN:
+ return PORT_TYPE_BOOLEAN;
+ case OP_TYPE_TRANSFORM:
+ return PORT_TYPE_TRANSFORM;
+ default:
+ break;
+ }
+ }
+ return PORT_TYPE_SCALAR;
}
String VisualShaderNodeSwitch::get_input_port_name(int p_port) const {
@@ -4879,13 +4958,84 @@ int VisualShaderNodeSwitch::get_output_port_count() const {
}
VisualShaderNodeSwitch::PortType VisualShaderNodeSwitch::get_output_port_type(int p_port) const {
- return PORT_TYPE_VECTOR;
+ switch (op_type) {
+ case OP_TYPE_FLOAT:
+ return PORT_TYPE_SCALAR;
+ case OP_TYPE_INT:
+ return PORT_TYPE_SCALAR_INT;
+ case OP_TYPE_VECTOR:
+ return PORT_TYPE_VECTOR;
+ case OP_TYPE_BOOLEAN:
+ return PORT_TYPE_BOOLEAN;
+ case OP_TYPE_TRANSFORM:
+ return PORT_TYPE_TRANSFORM;
+ default:
+ break;
+ }
+ return PORT_TYPE_SCALAR;
}
String VisualShaderNodeSwitch::get_output_port_name(int p_port) const {
return "result";
}
+void VisualShaderNodeSwitch::set_op_type(OpType p_op_type) {
+ ERR_FAIL_INDEX((int)p_op_type, OP_TYPE_MAX);
+ if (op_type == p_op_type) {
+ return;
+ }
+ switch (p_op_type) {
+ case OP_TYPE_FLOAT:
+ set_input_port_default_value(1, 1.0);
+ set_input_port_default_value(2, 0.0);
+ break;
+ case OP_TYPE_INT:
+ set_input_port_default_value(1, 1);
+ set_input_port_default_value(2, 0);
+ break;
+ case OP_TYPE_VECTOR:
+ set_input_port_default_value(1, Vector3(1.0, 1.0, 1.0));
+ set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0));
+ break;
+ case OP_TYPE_BOOLEAN:
+ set_input_port_default_value(1, true);
+ set_input_port_default_value(2, false);
+ break;
+ case OP_TYPE_TRANSFORM:
+ set_input_port_default_value(1, Transform());
+ set_input_port_default_value(2, Transform());
+ break;
+ default:
+ break;
+ }
+ op_type = p_op_type;
+ emit_changed();
+}
+
+VisualShaderNodeSwitch::OpType VisualShaderNodeSwitch::get_op_type() const {
+ return op_type;
+}
+
+Vector<StringName> VisualShaderNodeSwitch::get_editable_properties() const {
+ Vector<StringName> props;
+ props.push_back("op_type");
+ return props;
+}
+
+void VisualShaderNodeSwitch::_bind_methods() { // static
+ ClassDB::bind_method(D_METHOD("set_op_type", "type"), &VisualShaderNodeSwitch::set_op_type);
+ ClassDB::bind_method(D_METHOD("get_op_type"), &VisualShaderNodeSwitch::get_op_type);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "op_type", PROPERTY_HINT_ENUM, "Float,Int,Vector,Boolean,Transform"), "set_op_type", "get_op_type");
+
+ BIND_ENUM_CONSTANT(OP_TYPE_FLOAT);
+ BIND_ENUM_CONSTANT(OP_TYPE_INT);
+ BIND_ENUM_CONSTANT(OP_TYPE_VECTOR);
+ BIND_ENUM_CONSTANT(OP_TYPE_BOOLEAN);
+ BIND_ENUM_CONSTANT(OP_TYPE_TRANSFORM);
+ BIND_ENUM_CONSTANT(OP_TYPE_MAX);
+}
+
String VisualShaderNodeSwitch::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
String code;
code += "\tif(" + p_input_vars[0] + ")\n";
@@ -4902,29 +5052,6 @@ String VisualShaderNodeSwitch::generate_code(Shader::Mode p_mode, VisualShader::
VisualShaderNodeSwitch::VisualShaderNodeSwitch() {
simple_decl = false;
set_input_port_default_value(0, false);
- set_input_port_default_value(1, Vector3(1.0, 1.0, 1.0));
- set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0));
-}
-
-////////////// Switch(scalar)
-
-String VisualShaderNodeScalarSwitch::get_caption() const {
- return "ScalarSwitch";
-}
-
-VisualShaderNodeScalarSwitch::PortType VisualShaderNodeScalarSwitch::get_input_port_type(int p_port) const {
- if (p_port == 0) {
- return PORT_TYPE_BOOLEAN;
- }
- return PORT_TYPE_SCALAR;
-}
-
-VisualShaderNodeScalarSwitch::PortType VisualShaderNodeScalarSwitch::get_output_port_type(int p_port) const {
- return PORT_TYPE_SCALAR;
-}
-
-VisualShaderNodeScalarSwitch::VisualShaderNodeScalarSwitch() {
- set_input_port_default_value(0, false);
set_input_port_default_value(1, 1.0);
set_input_port_default_value(2, 0.0);
}
@@ -5384,16 +5511,22 @@ String VisualShaderNodeMultiplyAdd::generate_code(Shader::Mode p_mode, VisualSha
void VisualShaderNodeMultiplyAdd::set_op_type(OpType p_op_type) {
ERR_FAIL_INDEX((int)p_op_type, OP_TYPE_MAX);
- if (p_op_type != op_type) {
- if (p_op_type == OP_TYPE_SCALAR) {
+ if (op_type == p_op_type) {
+ return;
+ }
+ switch (p_op_type) {
+ case OP_TYPE_SCALAR:
set_input_port_default_value(0, 0.0);
set_input_port_default_value(1, 0.0);
set_input_port_default_value(2, 0.0);
- } else {
+ break;
+ case OP_TYPE_VECTOR:
set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0));
set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0));
set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0));
- }
+ break;
+ default:
+ break;
}
op_type = p_op_type;
emit_changed();
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index e968bbae25..a5d0fe4649 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -826,7 +826,6 @@ class VisualShaderNodeIntFunc : public VisualShaderNode {
public:
enum Function {
FUNC_ABS,
- FUNC_CLAMP,
FUNC_NEGATE,
FUNC_SIGN,
};
@@ -1088,29 +1087,20 @@ public:
/// CLAMP
///////////////////////////////////////
-class VisualShaderNodeScalarClamp : public VisualShaderNode {
- GDCLASS(VisualShaderNodeScalarClamp, VisualShaderNode);
+class VisualShaderNodeClamp : public VisualShaderNode {
+ GDCLASS(VisualShaderNodeClamp, VisualShaderNode);
public:
- virtual String get_caption() const override;
-
- virtual int get_input_port_count() const override;
- virtual PortType get_input_port_type(int p_port) const override;
- virtual String get_input_port_name(int p_port) const override;
-
- virtual int get_output_port_count() const override;
- virtual PortType get_output_port_type(int p_port) const override;
- virtual String get_output_port_name(int p_port) const override;
-
- virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
-
- VisualShaderNodeScalarClamp();
-};
-
-///////////////////////////////////////
+ enum OpType {
+ OP_TYPE_FLOAT,
+ OP_TYPE_INT,
+ OP_TYPE_VECTOR,
+ OP_TYPE_MAX,
+ };
-class VisualShaderNodeVectorClamp : public VisualShaderNode {
- GDCLASS(VisualShaderNodeVectorClamp, VisualShaderNode);
+protected:
+ OpType op_type = OP_TYPE_FLOAT;
+ static void _bind_methods();
public:
virtual String get_caption() const override;
@@ -1123,11 +1113,18 @@ public:
virtual PortType get_output_port_type(int p_port) const override;
virtual String get_output_port_name(int p_port) const override;
+ void set_op_type(OpType p_type);
+ OpType get_op_type() const;
+
+ virtual Vector<StringName> get_editable_properties() const override;
+
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
- VisualShaderNodeVectorClamp();
+ VisualShaderNodeClamp();
};
+VARIANT_ENUM_CAST(VisualShaderNodeClamp::OpType)
+
///////////////////////////////////////
/// DERIVATIVE FUNCTIONS
///////////////////////////////////////
@@ -1260,8 +1257,20 @@ public:
/// STEP
///////////////////////////////////////
-class VisualShaderNodeVectorScalarStep : public VisualShaderNode {
- GDCLASS(VisualShaderNodeVectorScalarStep, VisualShaderNode);
+class VisualShaderNodeStep : public VisualShaderNode {
+ GDCLASS(VisualShaderNodeStep, VisualShaderNode);
+
+public:
+ enum OpType {
+ OP_TYPE_SCALAR,
+ OP_TYPE_VECTOR,
+ OP_TYPE_VECTOR_SCALAR,
+ OP_TYPE_MAX,
+ };
+
+protected:
+ OpType op_type = OP_TYPE_SCALAR;
+ static void _bind_methods();
public:
virtual String get_caption() const override;
@@ -1274,38 +1283,36 @@ public:
virtual PortType get_output_port_type(int p_port) const override;
virtual String get_output_port_name(int p_port) const override;
+ void set_op_type(OpType p_type);
+ OpType get_op_type() const;
+
+ virtual Vector<StringName> get_editable_properties() const override;
+
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
- VisualShaderNodeVectorScalarStep();
+ VisualShaderNodeStep();
};
+VARIANT_ENUM_CAST(VisualShaderNodeStep::OpType)
+
///////////////////////////////////////
/// SMOOTHSTEP
///////////////////////////////////////
-class VisualShaderNodeScalarSmoothStep : public VisualShaderNode {
- GDCLASS(VisualShaderNodeScalarSmoothStep, VisualShaderNode);
+class VisualShaderNodeSmoothStep : public VisualShaderNode {
+ GDCLASS(VisualShaderNodeSmoothStep, VisualShaderNode);
public:
- virtual String get_caption() const override;
-
- virtual int get_input_port_count() const override;
- virtual PortType get_input_port_type(int p_port) const override;
- virtual String get_input_port_name(int p_port) const override;
-
- virtual int get_output_port_count() const override;
- virtual PortType get_output_port_type(int p_port) const override;
- virtual String get_output_port_name(int p_port) const override;
-
- virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
-
- VisualShaderNodeScalarSmoothStep();
-};
-
-///////////////////////////////////////
+ enum OpType {
+ OP_TYPE_SCALAR,
+ OP_TYPE_VECTOR,
+ OP_TYPE_VECTOR_SCALAR,
+ OP_TYPE_MAX,
+ };
-class VisualShaderNodeVectorSmoothStep : public VisualShaderNode {
- GDCLASS(VisualShaderNodeVectorSmoothStep, VisualShaderNode);
+protected:
+ OpType op_type = OP_TYPE_SCALAR;
+ static void _bind_methods();
public:
virtual String get_caption() const override;
@@ -1318,32 +1325,18 @@ public:
virtual PortType get_output_port_type(int p_port) const override;
virtual String get_output_port_name(int p_port) const override;
- virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
-
- VisualShaderNodeVectorSmoothStep();
-};
-
-///////////////////////////////////////
-
-class VisualShaderNodeVectorScalarSmoothStep : public VisualShaderNode {
- GDCLASS(VisualShaderNodeVectorScalarSmoothStep, VisualShaderNode);
-
-public:
- virtual String get_caption() const override;
-
- virtual int get_input_port_count() const override;
- virtual PortType get_input_port_type(int p_port) const override;
- virtual String get_input_port_name(int p_port) const override;
+ void set_op_type(OpType p_type);
+ OpType get_op_type() const;
- virtual int get_output_port_count() const override;
- virtual PortType get_output_port_type(int p_port) const override;
- virtual String get_output_port_name(int p_port) const override;
+ virtual Vector<StringName> get_editable_properties() const override;
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
- VisualShaderNodeVectorScalarSmoothStep();
+ VisualShaderNodeSmoothStep();
};
+VARIANT_ENUM_CAST(VisualShaderNodeSmoothStep::OpType)
+
///////////////////////////////////////
/// DISTANCE
///////////////////////////////////////
@@ -1394,29 +1387,20 @@ public:
/// MIX
///////////////////////////////////////
-class VisualShaderNodeScalarInterp : public VisualShaderNode {
- GDCLASS(VisualShaderNodeScalarInterp, VisualShaderNode);
+class VisualShaderNodeMix : public VisualShaderNode {
+ GDCLASS(VisualShaderNodeMix, VisualShaderNode);
public:
- virtual String get_caption() const override;
-
- virtual int get_input_port_count() const override;
- virtual PortType get_input_port_type(int p_port) const override;
- virtual String get_input_port_name(int p_port) const override;
-
- virtual int get_output_port_count() const override;
- virtual PortType get_output_port_type(int p_port) const override;
- virtual String get_output_port_name(int p_port) const override;
-
- virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
-
- VisualShaderNodeScalarInterp();
-};
-
-///////////////////////////////////////
+ enum OpType {
+ OP_TYPE_SCALAR,
+ OP_TYPE_VECTOR,
+ OP_TYPE_VECTOR_SCALAR,
+ OP_TYPE_MAX,
+ };
-class VisualShaderNodeVectorInterp : public VisualShaderNode {
- GDCLASS(VisualShaderNodeVectorInterp, VisualShaderNode);
+protected:
+ OpType op_type = OP_TYPE_SCALAR;
+ static void _bind_methods();
public:
virtual String get_caption() const override;
@@ -1429,32 +1413,18 @@ public:
virtual PortType get_output_port_type(int p_port) const override;
virtual String get_output_port_name(int p_port) const override;
- virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
-
- VisualShaderNodeVectorInterp();
-};
-
-///////////////////////////////////////
-
-class VisualShaderNodeVectorScalarMix : public VisualShaderNode {
- GDCLASS(VisualShaderNodeVectorScalarMix, VisualShaderNode);
-
-public:
- virtual String get_caption() const override;
-
- virtual int get_input_port_count() const override;
- virtual PortType get_input_port_type(int p_port) const override;
- virtual String get_input_port_name(int p_port) const override;
+ void set_op_type(OpType p_type);
+ OpType get_op_type() const;
- virtual int get_output_port_count() const override;
- virtual PortType get_output_port_type(int p_port) const override;
- virtual String get_output_port_name(int p_port) const override;
+ virtual Vector<StringName> get_editable_properties() const override;
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
- VisualShaderNodeVectorScalarMix();
+ VisualShaderNodeMix();
};
+VARIANT_ENUM_CAST(VisualShaderNodeMix::OpType)
+
///////////////////////////////////////
/// COMPOSE
///////////////////////////////////////
@@ -2023,6 +1993,21 @@ class VisualShaderNodeSwitch : public VisualShaderNode {
GDCLASS(VisualShaderNodeSwitch, VisualShaderNode);
public:
+ enum OpType {
+ OP_TYPE_FLOAT,
+ OP_TYPE_INT,
+ OP_TYPE_VECTOR,
+ OP_TYPE_BOOLEAN,
+ OP_TYPE_TRANSFORM,
+ OP_TYPE_MAX,
+ };
+
+protected:
+ OpType op_type = OP_TYPE_FLOAT;
+
+ static void _bind_methods();
+
+public:
virtual String get_caption() const override;
virtual int get_input_port_count() const override;
@@ -2033,22 +2018,17 @@ public:
virtual PortType get_output_port_type(int p_port) const override;
virtual String get_output_port_name(int p_port) const override;
+ void set_op_type(OpType p_type);
+ OpType get_op_type() const;
+
+ virtual Vector<StringName> get_editable_properties() const override;
+
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
VisualShaderNodeSwitch();
};
-class VisualShaderNodeScalarSwitch : public VisualShaderNodeSwitch {
- GDCLASS(VisualShaderNodeScalarSwitch, VisualShaderNodeSwitch);
-
-public:
- virtual String get_caption() const override;
-
- virtual PortType get_input_port_type(int p_port) const override;
- virtual PortType get_output_port_type(int p_port) const override;
-
- VisualShaderNodeScalarSwitch();
-};
+VARIANT_ENUM_CAST(VisualShaderNodeSwitch::OpType)
///////////////////////////////////////
/// FRESNEL