diff options
Diffstat (limited to 'scene')
31 files changed, 396 insertions, 72 deletions
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index fb3b199638..3ba81dba88 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -483,16 +483,16 @@ void Node2D::_bind_methods() { ADD_GROUP("Transform", ""); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_RANGE, "-99999,99999,0.001,or_less,or_greater,hide_slider,suffix:px"), "set_position", "get_position"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_rotation", "get_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians_as_degrees"), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale", PROPERTY_HINT_LINK), "set_scale", "get_scale"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew", PROPERTY_HINT_RANGE, "-89.9,89.9,0.1,radians"), "set_skew", "get_skew"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew", PROPERTY_HINT_RANGE, "-89.9,89.9,0.1,radians_as_degrees"), "set_skew", "get_skew"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_transform", "get_transform"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_global_position", "get_global_position"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation", PROPERTY_HINT_NONE, "radians", PROPERTY_USAGE_NONE), "set_global_rotation", "get_global_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation", PROPERTY_HINT_NONE, "radians_as_degrees", PROPERTY_USAGE_NONE), "set_global_rotation", "get_global_rotation"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation_degrees", "get_global_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_scale", "get_global_scale"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_skew", PROPERTY_HINT_NONE, "radians", PROPERTY_USAGE_NONE), "set_global_skew", "get_global_skew"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_skew", PROPERTY_HINT_NONE, "radians_as_degrees", PROPERTY_USAGE_NONE), "set_global_skew", "get_global_skew"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform"); } diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 6653bb1757..b6a36b2391 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -220,7 +220,7 @@ void StaticBody2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "constant_linear_velocity", PROPERTY_HINT_NONE, "suffix:px/s"), "set_constant_linear_velocity", "get_constant_linear_velocity"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "constant_angular_velocity", PROPERTY_HINT_NONE, U"radians,suffix:\u00B0/s"), "set_constant_angular_velocity", "get_constant_angular_velocity"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "constant_angular_velocity", PROPERTY_HINT_NONE, U"radians_as_degrees,suffix:\u00B0/s"), "set_constant_angular_velocity", "get_constant_angular_velocity"); } StaticBody2D::StaticBody2D(PhysicsServer2D::BodyMode p_mode) : @@ -1036,7 +1036,7 @@ void RigidBody2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "linear_damp_mode", PROPERTY_HINT_ENUM, "Combine,Replace"), "set_linear_damp_mode", "get_linear_damp_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp"); ADD_GROUP("Angular", "angular_"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_velocity", PROPERTY_HINT_NONE, U"radians,suffix:\u00B0/s"), "set_angular_velocity", "get_angular_velocity"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_velocity", PROPERTY_HINT_NONE, U"radians_as_degrees,suffix:\u00B0/s"), "set_angular_velocity", "get_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::INT, "angular_damp_mode", PROPERTY_HINT_ENUM, "Combine,Replace"), "set_angular_damp_mode", "get_angular_damp_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp"); ADD_GROUP("Constant Forces", "constant_"); @@ -1769,13 +1769,13 @@ void CharacterBody2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "velocity", PROPERTY_HINT_NONE, "suffix:px/s", PROPERTY_USAGE_NO_EDITOR), "set_velocity", "get_velocity"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slide_on_ceiling"), "set_slide_on_ceiling_enabled", "is_slide_on_ceiling_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_slides", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_max_slides", "get_max_slides"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wall_min_slide_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians", PROPERTY_USAGE_DEFAULT), "set_wall_min_slide_angle", "get_wall_min_slide_angle"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wall_min_slide_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians_as_degrees", PROPERTY_USAGE_DEFAULT), "set_wall_min_slide_angle", "get_wall_min_slide_angle"); ADD_GROUP("Floor", "floor_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "floor_stop_on_slope"), "set_floor_stop_on_slope_enabled", "is_floor_stop_on_slope_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "floor_constant_speed"), "set_floor_constant_speed_enabled", "is_floor_constant_speed_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "floor_block_on_wall"), "set_floor_block_on_wall_enabled", "is_floor_block_on_wall_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "floor_max_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians"), "set_floor_max_angle", "get_floor_max_angle"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "floor_max_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians_as_degrees"), "set_floor_max_angle", "get_floor_max_angle"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "floor_snap_length", PROPERTY_HINT_RANGE, "0,32,0.1,or_greater,suffix:px"), "set_floor_snap_length", "get_floor_snap_length"); ADD_GROUP("Moving Platform", "platform_"); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index ebd83da377..bda7b495e1 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -640,7 +640,7 @@ void Polygon2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_offset", PROPERTY_HINT_NONE, "suffix:px"), "set_texture_offset", "get_texture_offset"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale", PROPERTY_HINT_LINK), "set_texture_scale", "get_texture_scale"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_texture_rotation", "get_texture_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians_as_degrees"), "set_texture_rotation", "get_texture_rotation"); ADD_GROUP("Skeleton", ""); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton2D"), "set_skeleton", "get_skeleton"); diff --git a/scene/3d/importer_mesh_instance_3d.cpp b/scene/3d/importer_mesh_instance_3d.cpp index d7cbe6d87c..2216b3818d 100644 --- a/scene/3d/importer_mesh_instance_3d.cpp +++ b/scene/3d/importer_mesh_instance_3d.cpp @@ -69,6 +69,67 @@ NodePath ImporterMeshInstance3D::get_skeleton_path() const { return skeleton_path; } +uint32_t ImporterMeshInstance3D::get_layer_mask() const { + return layer_mask; +} + +void ImporterMeshInstance3D::set_layer_mask(const uint32_t p_layer_mask) { + layer_mask = p_layer_mask; +} + +void ImporterMeshInstance3D::set_cast_shadows_setting(GeometryInstance3D::ShadowCastingSetting p_shadow_casting_setting) { + shadow_casting_setting = p_shadow_casting_setting; +} + +GeometryInstance3D::ShadowCastingSetting ImporterMeshInstance3D::get_cast_shadows_setting() const { + return shadow_casting_setting; +} + +void ImporterMeshInstance3D::set_visibility_range_begin(float p_dist) { + visibility_range_begin = p_dist; + update_configuration_warnings(); +} + +float ImporterMeshInstance3D::get_visibility_range_begin() const { + return visibility_range_begin; +} + +void ImporterMeshInstance3D::set_visibility_range_end(float p_dist) { + visibility_range_end = p_dist; + update_configuration_warnings(); +} + +float ImporterMeshInstance3D::get_visibility_range_end() const { + return visibility_range_end; +} + +void ImporterMeshInstance3D::set_visibility_range_begin_margin(float p_dist) { + visibility_range_begin_margin = p_dist; + update_configuration_warnings(); +} + +float ImporterMeshInstance3D::get_visibility_range_begin_margin() const { + return visibility_range_begin_margin; +} + +void ImporterMeshInstance3D::set_visibility_range_end_margin(float p_dist) { + visibility_range_end_margin = p_dist; + update_configuration_warnings(); +} + +float ImporterMeshInstance3D::get_visibility_range_end_margin() const { + return visibility_range_end_margin; +} + +void ImporterMeshInstance3D::set_visibility_range_fade_mode(GeometryInstance3D::VisibilityRangeFadeMode p_mode) { + visibility_range_fade_mode = p_mode; + update_configuration_warnings(); +} + +GeometryInstance3D::VisibilityRangeFadeMode ImporterMeshInstance3D::get_visibility_range_fade_mode() const { + return visibility_range_fade_mode; +} + void ImporterMeshInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &ImporterMeshInstance3D::set_mesh); ClassDB::bind_method(D_METHOD("get_mesh"), &ImporterMeshInstance3D::get_mesh); @@ -79,7 +140,38 @@ void ImporterMeshInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &ImporterMeshInstance3D::set_skeleton_path); ClassDB::bind_method(D_METHOD("get_skeleton_path"), &ImporterMeshInstance3D::get_skeleton_path); + ClassDB::bind_method(D_METHOD("set_layer_mask", "layer_mask"), &ImporterMeshInstance3D::set_layer_mask); + ClassDB::bind_method(D_METHOD("get_layer_mask"), &ImporterMeshInstance3D::get_layer_mask); + + ClassDB::bind_method(D_METHOD("set_cast_shadows_setting", "shadow_casting_setting"), &ImporterMeshInstance3D::set_cast_shadows_setting); + ClassDB::bind_method(D_METHOD("get_cast_shadows_setting"), &ImporterMeshInstance3D::get_cast_shadows_setting); + + ClassDB::bind_method(D_METHOD("set_visibility_range_end_margin", "distance"), &ImporterMeshInstance3D::set_visibility_range_end_margin); + ClassDB::bind_method(D_METHOD("get_visibility_range_end_margin"), &ImporterMeshInstance3D::get_visibility_range_end_margin); + + ClassDB::bind_method(D_METHOD("set_visibility_range_end", "distance"), &ImporterMeshInstance3D::set_visibility_range_end); + ClassDB::bind_method(D_METHOD("get_visibility_range_end"), &ImporterMeshInstance3D::get_visibility_range_end); + + ClassDB::bind_method(D_METHOD("set_visibility_range_begin_margin", "distance"), &ImporterMeshInstance3D::set_visibility_range_begin_margin); + ClassDB::bind_method(D_METHOD("get_visibility_range_begin_margin"), &ImporterMeshInstance3D::get_visibility_range_begin_margin); + + ClassDB::bind_method(D_METHOD("set_visibility_range_begin", "distance"), &ImporterMeshInstance3D::set_visibility_range_begin); + ClassDB::bind_method(D_METHOD("get_visibility_range_begin"), &ImporterMeshInstance3D::get_visibility_range_begin); + + ClassDB::bind_method(D_METHOD("set_visibility_range_fade_mode", "mode"), &ImporterMeshInstance3D::set_visibility_range_fade_mode); + ClassDB::bind_method(D_METHOD("get_visibility_range_fade_mode"), &ImporterMeshInstance3D::get_visibility_range_fade_mode); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "ImporterMesh"), "set_mesh", "get_mesh"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skin", PROPERTY_HINT_RESOURCE_TYPE, "Skin"), "set_skin", "get_skin"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton"), "set_skeleton_path", "get_skeleton_path"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "layer_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_layer_mask", "get_layer_mask"); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), "set_cast_shadows_setting", "get_cast_shadows_setting"); + + ADD_GROUP("Visibility Range", "visibility_range_"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "visibility_range_begin", PROPERTY_HINT_RANGE, "0.0,4096.0,0.01,or_greater,suffix:m"), "set_visibility_range_begin", "get_visibility_range_begin"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "visibility_range_begin_margin", PROPERTY_HINT_RANGE, "0.0,4096.0,0.01,or_greater,suffix:m"), "set_visibility_range_begin_margin", "get_visibility_range_begin_margin"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "visibility_range_end", PROPERTY_HINT_RANGE, "0.0,4096.0,0.01,or_greater,suffix:m"), "set_visibility_range_end", "get_visibility_range_end"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "visibility_range_end_margin", PROPERTY_HINT_RANGE, "0.0,4096.0,0.01,or_greater,suffix:m"), "set_visibility_range_end_margin", "get_visibility_range_end_margin"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "visibility_range_fade_mode", PROPERTY_HINT_ENUM, "Disabled,Self,Dependencies"), "set_visibility_range_fade_mode", "get_visibility_range_fade_mode"); } diff --git a/scene/3d/importer_mesh_instance_3d.h b/scene/3d/importer_mesh_instance_3d.h index ea2a6cadbd..d48721383f 100644 --- a/scene/3d/importer_mesh_instance_3d.h +++ b/scene/3d/importer_mesh_instance_3d.h @@ -32,6 +32,7 @@ #define IMPORTER_MESH_INSTANCE_3D_H #include "scene/3d/node_3d.h" +#include "scene/3d/visual_instance_3d.h" #include "scene/resources/immediate_mesh.h" #include "scene/resources/skin.h" @@ -44,6 +45,13 @@ class ImporterMeshInstance3D : public Node3D { Ref<Skin> skin; NodePath skeleton_path; Vector<Ref<Material>> surface_materials; + uint32_t layer_mask = 1; + GeometryInstance3D::ShadowCastingSetting shadow_casting_setting = GeometryInstance3D::SHADOW_CASTING_SETTING_ON; + float visibility_range_begin = 0.0; + float visibility_range_end = 0.0; + float visibility_range_begin_margin = 0.0; + float visibility_range_end_margin = 0.0; + GeometryInstance3D::VisibilityRangeFadeMode visibility_range_fade_mode = GeometryInstance3D::VISIBILITY_RANGE_FADE_DISABLED; protected: static void _bind_methods(); @@ -60,6 +68,27 @@ public: void set_skeleton_path(const NodePath &p_path); NodePath get_skeleton_path() const; + + void set_layer_mask(const uint32_t p_layer_mask); + uint32_t get_layer_mask() const; + + void set_cast_shadows_setting(GeometryInstance3D::ShadowCastingSetting p_shadow_casting_setting); + GeometryInstance3D::ShadowCastingSetting get_cast_shadows_setting() const; + + void set_visibility_range_begin(float p_dist); + float get_visibility_range_begin() const; + + void set_visibility_range_end(float p_dist); + float get_visibility_range_end() const; + + void set_visibility_range_begin_margin(float p_dist); + float get_visibility_range_begin_margin() const; + + void set_visibility_range_end_margin(float p_dist); + float get_visibility_range_end_margin() const; + + void set_visibility_range_fade_mode(GeometryInstance3D::VisibilityRangeFadeMode p_mode); + GeometryInstance3D::VisibilityRangeFadeMode get_visibility_range_fade_mode() const; }; #endif // IMPORTER_MESH_INSTANCE_3D_H diff --git a/scene/3d/joint_3d.cpp b/scene/3d/joint_3d.cpp index f1361ab1bb..e7a42857c9 100644 --- a/scene/3d/joint_3d.cpp +++ b/scene/3d/joint_3d.cpp @@ -305,8 +305,8 @@ void HingeJoint3D::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "params/bias", PROPERTY_HINT_RANGE, "0.00,0.99,0.01"), "set_param", "get_param", PARAM_BIAS); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit/enable"), "set_flag", "get_flag", FLAG_USE_LIMIT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/upper", PROPERTY_HINT_RANGE, "-180,180,0.1,radians"), "set_param", "get_param", PARAM_LIMIT_UPPER); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/lower", PROPERTY_HINT_RANGE, "-180,180,0.1,radians"), "set_param", "get_param", PARAM_LIMIT_LOWER); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/upper", PROPERTY_HINT_RANGE, "-180,180,0.1,radians_as_degrees"), "set_param", "get_param", PARAM_LIMIT_UPPER); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/lower", PROPERTY_HINT_RANGE, "-180,180,0.1,radians_as_degrees"), "set_param", "get_param", PARAM_LIMIT_LOWER); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"), "set_param", "get_param", PARAM_LIMIT_BIAS); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param", "get_param", PARAM_LIMIT_SOFTNESS); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/relaxation", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param", "get_param", PARAM_LIMIT_RELAXATION); @@ -417,8 +417,8 @@ void SliderJoint3D::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_ortho/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_ORTHOGONAL_RESTITUTION); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_ortho/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_ORTHOGONAL_DAMPING); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.1,radians"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_UPPER); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.1,radians"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_LOWER); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.1,radians_as_degrees"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_UPPER); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.1,radians_as_degrees"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_LOWER); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_SOFTNESS); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_RESTITUTION); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_DAMPING); @@ -523,8 +523,8 @@ void ConeTwistJoint3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &ConeTwistJoint3D::set_param); ClassDB::bind_method(D_METHOD("get_param", "param"), &ConeTwistJoint3D::get_param); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "swing_span", PROPERTY_HINT_RANGE, "-180,180,0.1,radians"), "set_param", "get_param", PARAM_SWING_SPAN); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "twist_span", PROPERTY_HINT_RANGE, "-40000,40000,0.1,radians"), "set_param", "get_param", PARAM_TWIST_SPAN); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "swing_span", PROPERTY_HINT_RANGE, "-180,180,0.1,radians_as_degrees"), "set_param", "get_param", PARAM_SWING_SPAN); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "twist_span", PROPERTY_HINT_RANGE, "-40000,40000,0.1,radians_as_degrees"), "set_param", "get_param", PARAM_TWIST_SPAN); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "bias", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_BIAS); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_SOFTNESS); @@ -661,8 +661,8 @@ void Generic6DOFJoint3D::_bind_methods() { ADD_GROUP("Angular Limit", "angular_limit_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit_x/enabled"), "set_flag_x", "get_flag_x", FLAG_ENABLE_ANGULAR_LIMIT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians"), "set_param_x", "get_param_x", PARAM_ANGULAR_UPPER_LIMIT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians"), "set_param_x", "get_param_x", PARAM_ANGULAR_LOWER_LIMIT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians_as_degrees"), "set_param_x", "get_param_x", PARAM_ANGULAR_UPPER_LIMIT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians_as_degrees"), "set_param_x", "get_param_x", PARAM_ANGULAR_LOWER_LIMIT); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_x", "get_param_x", PARAM_ANGULAR_LIMIT_SOFTNESS); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_x", "get_param_x", PARAM_ANGULAR_RESTITUTION); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_x", "get_param_x", PARAM_ANGULAR_DAMPING); @@ -670,8 +670,8 @@ void Generic6DOFJoint3D::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/erp"), "set_param_x", "get_param_x", PARAM_ANGULAR_ERP); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit_y/enabled"), "set_flag_y", "get_flag_y", FLAG_ENABLE_ANGULAR_LIMIT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians"), "set_param_y", "get_param_y", PARAM_ANGULAR_UPPER_LIMIT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians"), "set_param_y", "get_param_y", PARAM_ANGULAR_LOWER_LIMIT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians_as_degrees"), "set_param_y", "get_param_y", PARAM_ANGULAR_UPPER_LIMIT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians_as_degrees"), "set_param_y", "get_param_y", PARAM_ANGULAR_LOWER_LIMIT); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_y", "get_param_y", PARAM_ANGULAR_LIMIT_SOFTNESS); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_y", "get_param_y", PARAM_ANGULAR_RESTITUTION); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_y", "get_param_y", PARAM_ANGULAR_DAMPING); @@ -679,8 +679,8 @@ void Generic6DOFJoint3D::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/erp"), "set_param_y", "get_param_y", PARAM_ANGULAR_ERP); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit_z/enabled"), "set_flag_z", "get_flag_z", FLAG_ENABLE_ANGULAR_LIMIT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians"), "set_param_z", "get_param_z", PARAM_ANGULAR_UPPER_LIMIT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians"), "set_param_z", "get_param_z", PARAM_ANGULAR_LOWER_LIMIT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians_as_degrees"), "set_param_z", "get_param_z", PARAM_ANGULAR_UPPER_LIMIT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01,radians_as_degrees"), "set_param_z", "get_param_z", PARAM_ANGULAR_LOWER_LIMIT); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_z", "get_param_z", PARAM_ANGULAR_LIMIT_SOFTNESS); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_z", "get_param_z", PARAM_ANGULAR_RESTITUTION); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_z", "get_param_z", PARAM_ANGULAR_DAMPING); diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 594d108a41..07d84eebde 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -1195,7 +1195,7 @@ void Node3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform", PROPERTY_HINT_NONE, "suffix:m", PROPERTY_USAGE_NO_EDITOR), "set_transform", "get_transform"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "global_transform", PROPERTY_HINT_NONE, "suffix:m", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position", PROPERTY_HINT_RANGE, "-99999,99999,0.001,or_greater,or_less,hide_slider,suffix:m", PROPERTY_USAGE_EDITOR), "set_position", "get_position"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians", PROPERTY_USAGE_EDITOR), "set_rotation", "get_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians_as_degrees", PROPERTY_USAGE_EDITOR), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "quaternion", PROPERTY_HINT_HIDE_QUATERNION_EDIT, "", PROPERTY_USAGE_EDITOR), "set_quaternion", "get_quaternion"); ADD_PROPERTY(PropertyInfo(Variant::BASIS, "basis", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_basis", "get_basis"); diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 71ab96f6e7..66895afb27 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -259,7 +259,7 @@ void StaticBody3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_linear_velocity", PROPERTY_HINT_NONE, "suffix:m/s"), "set_constant_linear_velocity", "get_constant_linear_velocity"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity", PROPERTY_HINT_NONE, U"radians,suffix:\u00B0/s"), "set_constant_angular_velocity", "get_constant_angular_velocity"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity", PROPERTY_HINT_NONE, U"radians_as_degrees,suffix:\u00B0/s"), "set_constant_angular_velocity", "get_constant_angular_velocity"); } StaticBody3D::StaticBody3D(PhysicsServer3D::BodyMode p_mode) : @@ -1104,7 +1104,7 @@ void RigidBody3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "linear_damp_mode", PROPERTY_HINT_ENUM, "Combine,Replace"), "set_linear_damp_mode", "get_linear_damp_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp"); ADD_GROUP("Angular", "angular_"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity", PROPERTY_HINT_NONE, U"radians,suffix:\u00B0/s"), "set_angular_velocity", "get_angular_velocity"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity", PROPERTY_HINT_NONE, U"radians_as_degrees,suffix:\u00B0/s"), "set_angular_velocity", "get_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::INT, "angular_damp_mode", PROPERTY_HINT_ENUM, "Combine,Replace"), "set_angular_damp_mode", "get_angular_damp_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp"); ADD_GROUP("Constant Forces", "constant_"); @@ -2021,13 +2021,13 @@ void CharacterBody3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slide_on_ceiling"), "set_slide_on_ceiling_enabled", "is_slide_on_ceiling_enabled"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "velocity", PROPERTY_HINT_NONE, "suffix:m/s", PROPERTY_USAGE_NO_EDITOR), "set_velocity", "get_velocity"); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_slides", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_max_slides", "get_max_slides"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wall_min_slide_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians", PROPERTY_USAGE_DEFAULT), "set_wall_min_slide_angle", "get_wall_min_slide_angle"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wall_min_slide_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians_as_degrees", PROPERTY_USAGE_DEFAULT), "set_wall_min_slide_angle", "get_wall_min_slide_angle"); ADD_GROUP("Floor", "floor_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "floor_stop_on_slope"), "set_floor_stop_on_slope_enabled", "is_floor_stop_on_slope_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "floor_constant_speed"), "set_floor_constant_speed_enabled", "is_floor_constant_speed_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "floor_block_on_wall"), "set_floor_block_on_wall_enabled", "is_floor_block_on_wall_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "floor_max_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians"), "set_floor_max_angle", "get_floor_max_angle"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "floor_max_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians_as_degrees"), "set_floor_max_angle", "get_floor_max_angle"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "floor_snap_length", PROPERTY_HINT_RANGE, "0,1,0.01,or_greater,suffix:m"), "set_floor_snap_length", "get_floor_snap_length"); ADD_GROUP("Moving Platform", "platform_"); @@ -3015,7 +3015,7 @@ void PhysicalBone3D::_bind_methods() { ADD_GROUP("Joint", "joint_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "joint_type", PROPERTY_HINT_ENUM, "None,PinJoint,ConeJoint,HingeJoint,SliderJoint,6DOFJoint"), "set_joint_type", "get_joint_type"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "joint_offset", PROPERTY_HINT_NONE, "suffix:m"), "set_joint_offset", "get_joint_offset"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "joint_rotation", PROPERTY_HINT_RANGE, "-360,360,0.01,or_less,or_greater,radians"), "set_joint_rotation", "get_joint_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "joint_rotation", PROPERTY_HINT_RANGE, "-360,360,0.01,or_less,or_greater,radians_as_degrees"), "set_joint_rotation", "get_joint_rotation"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "body_offset", PROPERTY_HINT_NONE, "suffix:m"), "set_body_offset", "get_body_offset"); @@ -3029,7 +3029,7 @@ void PhysicalBone3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "angular_damp_mode", PROPERTY_HINT_ENUM, "Combine,Replace"), "set_angular_damp_mode", "get_angular_damp_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity", PROPERTY_HINT_NONE, "suffix:m/s"), "set_linear_velocity", "get_linear_velocity"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity", PROPERTY_HINT_NONE, U"radians,suffix:\u00B0/s"), "set_angular_velocity", "get_angular_velocity"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity", PROPERTY_HINT_NONE, U"radians_as_degrees,suffix:\u00B0/s"), "set_angular_velocity", "get_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "can_sleep"), "set_can_sleep", "is_able_to_sleep"); BIND_ENUM_CONSTANT(DAMP_MODE_COMBINE); diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index e23703a6dc..c23032d3b9 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -276,7 +276,7 @@ void VehicleWheel3D::_bind_methods() { ADD_GROUP("Per-Wheel Motion", ""); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "engine_force", PROPERTY_HINT_RANGE, U"-1024,1024,0.01,or_less,or_greater,suffix:kg\u22C5m/s\u00B2 (N)"), "set_engine_force", "get_engine_force"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "brake", PROPERTY_HINT_RANGE, U"-128,128,0.01,or_less,or_greater,suffix:kg\u22C5m/s\u00B2 (N)"), "set_brake", "get_brake"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "steering", PROPERTY_HINT_RANGE, "-180,180,0.01,radians"), "set_steering", "get_steering"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "steering", PROPERTY_HINT_RANGE, "-180,180,0.01,radians_as_degrees"), "set_steering", "get_steering"); ADD_GROUP("VehicleBody3D Motion", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_traction"), "set_use_as_traction", "is_used_as_traction"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_steering"), "set_use_as_steering", "is_used_as_steering"); @@ -920,7 +920,7 @@ void VehicleBody3D::_bind_methods() { ADD_GROUP("Motion", ""); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "engine_force", PROPERTY_HINT_RANGE, U"-1024,1024,0.01,or_less,or_greater,suffix:kg\u22C5m/s\u00B2 (N)"), "set_engine_force", "get_engine_force"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "brake", PROPERTY_HINT_RANGE, U"-128,128,0.01,or_less,or_greater,suffix:kg\u22C5m/s\u00B2 (N)"), "set_brake", "get_brake"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "steering", PROPERTY_HINT_RANGE, "-180,180,0.01,radians"), "set_steering", "get_steering"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "steering", PROPERTY_HINT_RANGE, "-180,180,0.01,radians_as_degrees"), "set_steering", "get_steering"); } VehicleBody3D::VehicleBody3D() { diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp index f53be5b8f9..1e0584e1db 100644 --- a/scene/animation/animation_blend_space_1d.cpp +++ b/scene/animation/animation_blend_space_1d.cpp @@ -177,12 +177,12 @@ void AnimationNodeBlendSpace1D::set_blend_point_node(int p_point, const Ref<Anim } float AnimationNodeBlendSpace1D::get_blend_point_position(int p_point) const { - ERR_FAIL_INDEX_V(p_point, blend_points_used, 0); + ERR_FAIL_INDEX_V(p_point, MAX_BLEND_POINTS, 0); return blend_points[p_point].position; } Ref<AnimationRootNode> AnimationNodeBlendSpace1D::get_blend_point_node(int p_point) const { - ERR_FAIL_INDEX_V(p_point, blend_points_used, Ref<AnimationRootNode>()); + ERR_FAIL_INDEX_V(p_point, MAX_BLEND_POINTS, Ref<AnimationRootNode>()); return blend_points[p_point].node; } diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index 5715516a7f..ff0be091ac 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -114,12 +114,12 @@ void AnimationNodeBlendSpace2D::set_blend_point_node(int p_point, const Ref<Anim } Vector2 AnimationNodeBlendSpace2D::get_blend_point_position(int p_point) const { - ERR_FAIL_INDEX_V(p_point, blend_points_used, Vector2()); + ERR_FAIL_INDEX_V(p_point, MAX_BLEND_POINTS, Vector2()); return blend_points[p_point].position; } Ref<AnimationRootNode> AnimationNodeBlendSpace2D::get_blend_point_node(int p_point) const { - ERR_FAIL_INDEX_V(p_point, blend_points_used, Ref<AnimationRootNode>()); + ERR_FAIL_INDEX_V(p_point, MAX_BLEND_POINTS, Ref<AnimationRootNode>()); return blend_points[p_point].node; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 4510de32a0..53e8945933 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2307,6 +2307,10 @@ Control *Control::_get_focus_neighbor(Side p_side, int p_count) { return result; } +Control *Control::find_valid_focus_neighbor(Side p_side) const { + return const_cast<Control *>(this)->_get_focus_neighbor(p_side); +} + void Control::_window_find_focus_neighbor(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, real_t p_min, real_t &r_closest_dist, Control **r_closest) { if (Object::cast_to<Viewport>(p_at)) { return; //bye @@ -3366,6 +3370,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("release_focus"), &Control::release_focus); ClassDB::bind_method(D_METHOD("find_prev_valid_focus"), &Control::find_prev_valid_focus); ClassDB::bind_method(D_METHOD("find_next_valid_focus"), &Control::find_next_valid_focus); + ClassDB::bind_method(D_METHOD("find_valid_focus_neighbor", "side"), &Control::find_valid_focus_neighbor); ClassDB::bind_method(D_METHOD("set_h_size_flags", "flags"), &Control::set_h_size_flags); ClassDB::bind_method(D_METHOD("get_h_size_flags"), &Control::get_h_size_flags); @@ -3518,7 +3523,7 @@ void Control::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_EDITOR), "_set_size", "get_size"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_EDITOR), "_set_position", "get_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "_set_global_position", "get_global_position"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_rotation", "get_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians_as_degrees"), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "pivot_offset", PROPERTY_HINT_NONE, "suffix:px"), "set_pivot_offset", "get_pivot_offset"); diff --git a/scene/gui/control.h b/scene/gui/control.h index e5ed076abf..abbdc42fa4 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -527,6 +527,7 @@ public: Control *find_next_valid_focus() const; Control *find_prev_valid_focus() const; + Control *find_valid_focus_neighbor(Side p_size) const; void set_focus_neighbor(Side p_side, const NodePath &p_neighbor); NodePath get_focus_neighbor(Side p_side) const; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index d27a40779e..7af7b2cf7e 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -1084,13 +1084,13 @@ FileDialog::FileDialog() { HBoxContainer *hbc = memnew(HBoxContainer); dir_prev = memnew(Button); - dir_prev->set_flat(true); + dir_prev->set_theme_type_variation("FlatButton"); dir_prev->set_tooltip_text(RTR("Go to previous folder.")); dir_next = memnew(Button); - dir_next->set_flat(true); + dir_next->set_theme_type_variation("FlatButton"); dir_next->set_tooltip_text(RTR("Go to next folder.")); dir_up = memnew(Button); - dir_up->set_flat(true); + dir_up->set_theme_type_variation("FlatButton"); dir_up->set_tooltip_text(RTR("Go to parent folder.")); hbc->add_child(dir_prev); hbc->add_child(dir_next); @@ -1114,13 +1114,13 @@ FileDialog::FileDialog() { dir->set_h_size_flags(Control::SIZE_EXPAND_FILL); refresh = memnew(Button); - refresh->set_flat(true); + refresh->set_theme_type_variation("FlatButton"); refresh->set_tooltip_text(RTR("Refresh files.")); refresh->connect("pressed", callable_mp(this, &FileDialog::update_file_list)); hbc->add_child(refresh); show_hidden = memnew(Button); - show_hidden->set_flat(true); + show_hidden->set_theme_type_variation("FlatButton"); show_hidden->set_toggle_mode(true); show_hidden->set_pressed(is_showing_hidden_files()); show_hidden->set_tooltip_text(RTR("Toggle the visibility of hidden files.")); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index e37a3671f3..6e12e7f196 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -1988,28 +1988,28 @@ GraphEdit::GraphEdit() { _update_zoom_label(); zoom_minus_button = memnew(Button); - zoom_minus_button->set_flat(true); + zoom_minus_button->set_theme_type_variation("FlatButton"); menu_hbox->add_child(zoom_minus_button); zoom_minus_button->set_tooltip_text(RTR("Zoom Out")); zoom_minus_button->connect("pressed", callable_mp(this, &GraphEdit::_zoom_minus)); zoom_minus_button->set_focus_mode(FOCUS_NONE); zoom_reset_button = memnew(Button); - zoom_reset_button->set_flat(true); + zoom_reset_button->set_theme_type_variation("FlatButton"); menu_hbox->add_child(zoom_reset_button); zoom_reset_button->set_tooltip_text(RTR("Zoom Reset")); zoom_reset_button->connect("pressed", callable_mp(this, &GraphEdit::_zoom_reset)); zoom_reset_button->set_focus_mode(FOCUS_NONE); zoom_plus_button = memnew(Button); - zoom_plus_button->set_flat(true); + zoom_plus_button->set_theme_type_variation("FlatButton"); menu_hbox->add_child(zoom_plus_button); zoom_plus_button->set_tooltip_text(RTR("Zoom In")); zoom_plus_button->connect("pressed", callable_mp(this, &GraphEdit::_zoom_plus)); zoom_plus_button->set_focus_mode(FOCUS_NONE); show_grid_button = memnew(Button); - show_grid_button->set_flat(true); + show_grid_button->set_theme_type_variation("FlatButton"); show_grid_button->set_toggle_mode(true); show_grid_button->set_tooltip_text(RTR("Toggle the visual grid.")); show_grid_button->connect("pressed", callable_mp(this, &GraphEdit::_show_grid_toggled)); @@ -2018,7 +2018,7 @@ GraphEdit::GraphEdit() { menu_hbox->add_child(show_grid_button); toggle_snapping_button = memnew(Button); - toggle_snapping_button->set_flat(true); + toggle_snapping_button->set_theme_type_variation("FlatButton"); toggle_snapping_button->set_toggle_mode(true); toggle_snapping_button->set_tooltip_text(RTR("Toggle snapping to the grid.")); toggle_snapping_button->connect("pressed", callable_mp(this, &GraphEdit::_snapping_toggled)); @@ -2036,7 +2036,7 @@ GraphEdit::GraphEdit() { menu_hbox->add_child(snapping_distance_spinbox); minimap_button = memnew(Button); - minimap_button->set_flat(true); + minimap_button->set_theme_type_variation("FlatButton"); minimap_button->set_toggle_mode(true); minimap_button->set_tooltip_text(RTR("Toggle the graph minimap.")); minimap_button->connect("pressed", callable_mp(this, &GraphEdit::_minimap_toggled)); @@ -2045,7 +2045,7 @@ GraphEdit::GraphEdit() { menu_hbox->add_child(minimap_button); layout_button = memnew(Button); - layout_button->set_flat(true); + layout_button->set_theme_type_variation("FlatButton"); menu_hbox->add_child(layout_button); layout_button->set_tooltip_text(RTR("Automatically arrange selected nodes.")); layout_button->connect("pressed", callable_mp(this, &GraphEdit::arrange_nodes)); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index e1fc7d7cd4..343301e9c4 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1082,14 +1082,16 @@ void ItemList::_notification(int p_what) { first_visible_separator = lo; } - // Draw visible separators. - for (int i = first_visible_separator; i < separators.size(); i++) { - if (separators[i] > clip.position.y + clip.size.y) { - break; // done - } + // If not in thumbnails mode, draw visible separators. + if (icon_mode != ICON_MODE_TOP) { + for (int i = first_visible_separator; i < separators.size(); i++) { + if (separators[i] > clip.position.y + clip.size.y) { + break; // done + } - const int y = base_ofs.y + separators[i]; - draw_line(Vector2(theme_cache.panel_style->get_margin(SIDE_LEFT), y), Vector2(width, y), theme_cache.guide_color); + const int y = base_ofs.y + separators[i]; + draw_line(Vector2(theme_cache.panel_style->get_margin(SIDE_LEFT), y), Vector2(width, y), theme_cache.guide_color); + } } // Do a binary search to find the first item whose rect reaches below clip.position.y. diff --git a/scene/gui/popup_menu.compat.inc b/scene/gui/popup_menu.compat.inc index ef74a17228..012d6a1334 100644 --- a/scene/gui/popup_menu.compat.inc +++ b/scene/gui/popup_menu.compat.inc @@ -31,16 +31,21 @@ #ifndef DISABLE_DEPRECATED void PopupMenu::_add_shortcut_bind_compat_36493(const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) { - return add_shortcut(p_shortcut, p_id, p_global, false); + add_shortcut(p_shortcut, p_id, p_global, false); } void PopupMenu::_add_icon_shortcut_bind_compat_36493(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) { - return add_icon_shortcut(p_icon, p_shortcut, p_id, p_global, false); + add_icon_shortcut(p_icon, p_shortcut, p_id, p_global, false); +} + +void PopupMenu::_clear_bind_compat_79965() { + clear(false); } void PopupMenu::_bind_compatibility_methods() { ClassDB::bind_compatibility_method(D_METHOD("add_shortcut", "shortcut", "id", "global"), &PopupMenu::_add_shortcut_bind_compat_36493, DEFVAL(-1), DEFVAL(false)); ClassDB::bind_compatibility_method(D_METHOD("add_icon_shortcut", "texture", "shortcut", "id", "global"), &PopupMenu::_add_icon_shortcut_bind_compat_36493, DEFVAL(-1), DEFVAL(false)); + ClassDB::bind_compatibility_method(D_METHOD("clear"), &PopupMenu::_clear_bind_compat_79965); } #endif diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index d64136a682..54fd8b8745 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -1908,10 +1908,18 @@ void PopupMenu::add_separator(const String &p_text, int p_id) { _menu_changed(); } -void PopupMenu::clear() { - for (int i = 0; i < items.size(); i++) { - if (items[i].shortcut.is_valid()) { - _unref_shortcut(items[i].shortcut); +void PopupMenu::clear(bool p_free_submenus) { + for (const Item &I : items) { + if (I.shortcut.is_valid()) { + _unref_shortcut(I.shortcut); + } + + if (p_free_submenus && !I.submenu.is_empty()) { + Node *submenu = get_node_or_null(I.submenu); + if (submenu) { + remove_child(submenu); + submenu->queue_free(); + } } } items.clear(); @@ -2236,7 +2244,7 @@ void PopupMenu::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_item", "index"), &PopupMenu::remove_item); ClassDB::bind_method(D_METHOD("add_separator", "label", "id"), &PopupMenu::add_separator, DEFVAL(String()), DEFVAL(-1)); - ClassDB::bind_method(D_METHOD("clear"), &PopupMenu::clear); + ClassDB::bind_method(D_METHOD("clear", "free_submenus"), &PopupMenu::clear, DEFVAL(false)); ClassDB::bind_method(D_METHOD("set_hide_on_item_selection", "enable"), &PopupMenu::set_hide_on_item_selection); ClassDB::bind_method(D_METHOD("is_hide_on_item_selection"), &PopupMenu::is_hide_on_item_selection); diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index 72a579b90a..f123d08400 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -202,6 +202,7 @@ protected: #ifndef DISABLE_DEPRECATED void _add_shortcut_bind_compat_36493(const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false); void _add_icon_shortcut_bind_compat_36493(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false); + void _clear_bind_compat_79965(); static void _bind_compatibility_methods(); #endif @@ -296,7 +297,7 @@ public: void add_separator(const String &p_text = String(), int p_id = -1); - void clear(); + void clear(bool p_free_submenus = true); virtual String get_tooltip(const Point2 &p_pos) const; diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index a9c16a9942..14eed4c7a2 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -290,6 +290,34 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { } } } + + if (p_event->is_pressed()) { + Input *input = Input::get_singleton(); + Ref<InputEventJoypadMotion> joypadmotion_event = p_event; + Ref<InputEventJoypadButton> joypadbutton_event = p_event; + bool is_joypad_event = (joypadmotion_event.is_valid() || joypadbutton_event.is_valid()); + if (p_event->is_action("ui_right", true)) { + if (is_joypad_event) { + if (!input->is_action_just_pressed("ui_right", true)) { + return; + } + set_process_internal(true); + } + if (is_layout_rtl() ? select_previous_available() : select_next_available()) { + accept_event(); + } + } else if (p_event->is_action("ui_left", true)) { + if (is_joypad_event) { + if (!input->is_action_just_pressed("ui_left", true)) { + return; + } + set_process_internal(true); + } + if (is_layout_rtl() ? select_next_available() : select_previous_available()) { + accept_event(); + } + } + } } void TabBar::_shape(int p_tab) { @@ -307,6 +335,28 @@ void TabBar::_shape(int p_tab) { void TabBar::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_INTERNAL_PROCESS: { + Input *input = Input::get_singleton(); + + if (input->is_action_just_released("ui_left") || input->is_action_just_released("ui_right")) { + gamepad_event_delay_ms = DEFAULT_GAMEPAD_EVENT_DELAY_MS; + set_process_internal(false); + return; + } + + gamepad_event_delay_ms -= get_process_delta_time(); + if (gamepad_event_delay_ms <= 0) { + gamepad_event_delay_ms = GAMEPAD_EVENT_REPEAT_RATE_MS + gamepad_event_delay_ms; + if (input->is_action_pressed("ui_right")) { + is_layout_rtl() ? select_previous_available() : select_next_available(); + } + + if (input->is_action_pressed("ui_left")) { + is_layout_rtl() ? select_next_available() : select_previous_available(); + } + } + } break; + case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { queue_redraw(); } break; @@ -379,7 +429,7 @@ void TabBar::_notification(int p_what) { col = theme_cache.font_unselected_color; } - _draw_tab(sb, col, i, rtl ? size.width - ofs - tabs[i].size_cache : ofs); + _draw_tab(sb, col, i, rtl ? size.width - ofs - tabs[i].size_cache : ofs, false); } ofs += tabs[i].size_cache; @@ -390,7 +440,7 @@ void TabBar::_notification(int p_what) { Ref<StyleBox> sb = tabs[current].disabled ? theme_cache.tab_disabled_style : theme_cache.tab_selected_style; float x = rtl ? size.width - tabs[current].ofs_cache - tabs[current].size_cache : tabs[current].ofs_cache; - _draw_tab(sb, theme_cache.font_selected_color, current, x); + _draw_tab(sb, theme_cache.font_selected_color, current, x, has_focus()); } if (buttons_visible) { @@ -456,12 +506,16 @@ void TabBar::_notification(int p_what) { } } -void TabBar::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, int p_index, float p_x) { +void TabBar::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, int p_index, float p_x, bool p_focus) { RID ci = get_canvas_item(); bool rtl = is_layout_rtl(); Rect2 sb_rect = Rect2(p_x, 0, tabs[p_index].size_cache, get_size().height); p_tab_style->draw(ci, sb_rect); + if (p_focus) { + Ref<StyleBox> focus_style = theme_cache.tab_focus_style; + focus_style->draw(ci, sb_rect); + } p_x += rtl ? tabs[p_index].size_cache - p_tab_style->get_margin(SIDE_LEFT) : p_tab_style->get_margin(SIDE_LEFT); @@ -607,6 +661,33 @@ int TabBar::get_hovered_tab() const { return hover; } +bool TabBar::select_previous_available() { + const int offset_end = (get_current_tab() + 1); + for (int i = 1; i < offset_end; i++) { + int target_tab = get_current_tab() - i; + if (target_tab < 0) { + target_tab += get_tab_count(); + } + if (!is_tab_disabled(target_tab)) { + set_current_tab(target_tab); + return true; + } + } + return false; +} + +bool TabBar::select_next_available() { + const int offset_end = (get_tab_count() - get_current_tab()); + for (int i = 1; i < offset_end; i++) { + int target_tab = (get_current_tab() + i) % get_tab_count(); + if (!is_tab_disabled(target_tab)) { + set_current_tab(target_tab); + return true; + } + } + return false; +} + int TabBar::get_tab_offset() const { return offset; } @@ -1589,6 +1670,8 @@ void TabBar::_bind_methods() { ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &TabBar::set_current_tab); ClassDB::bind_method(D_METHOD("get_current_tab"), &TabBar::get_current_tab); ClassDB::bind_method(D_METHOD("get_previous_tab"), &TabBar::get_previous_tab); + ClassDB::bind_method(D_METHOD("select_previous_available"), &TabBar::select_previous_available); + ClassDB::bind_method(D_METHOD("select_next_available"), &TabBar::select_next_available); ClassDB::bind_method(D_METHOD("set_tab_title", "tab_idx", "title"), &TabBar::set_tab_title); ClassDB::bind_method(D_METHOD("get_tab_title", "tab_idx"), &TabBar::get_tab_title); ClassDB::bind_method(D_METHOD("set_tab_text_direction", "tab_idx", "direction"), &TabBar::set_tab_text_direction); @@ -1674,6 +1757,7 @@ void TabBar::_bind_methods() { BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabBar, tab_hovered_style, "tab_hovered"); BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabBar, tab_selected_style, "tab_selected"); BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabBar, tab_disabled_style, "tab_disabled"); + BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabBar, tab_focus_style, "tab_focus"); BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, TabBar, increment_icon, "increment"); BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, TabBar, increment_hl_icon, "increment_highlight"); @@ -1699,5 +1783,6 @@ void TabBar::_bind_methods() { TabBar::TabBar() { set_size(Size2(get_size().width, get_minimum_size().height)); + set_focus_mode(FOCUS_ALL); connect("mouse_exited", callable_mp(this, &TabBar::_on_mouse_exited)); } diff --git a/scene/gui/tab_bar.h b/scene/gui/tab_bar.h index d89b1866bf..b79c170a7b 100644 --- a/scene/gui/tab_bar.h +++ b/scene/gui/tab_bar.h @@ -107,6 +107,10 @@ private: bool scroll_to_selected = true; int tabs_rearrange_group = -1; + const float DEFAULT_GAMEPAD_EVENT_DELAY_MS = 0.5; + const float GAMEPAD_EVENT_REPEAT_RATE_MS = 1.0 / 20; + float gamepad_event_delay_ms = DEFAULT_GAMEPAD_EVENT_DELAY_MS; + struct ThemeCache { int h_separation = 0; int icon_max_width = 0; @@ -115,6 +119,7 @@ private: Ref<StyleBox> tab_hovered_style; Ref<StyleBox> tab_selected_style; Ref<StyleBox> tab_disabled_style; + Ref<StyleBox> tab_focus_style; Ref<Texture2D> increment_icon; Ref<Texture2D> increment_hl_icon; @@ -148,7 +153,7 @@ private: void _on_mouse_exited(); void _shape(int p_tab); - void _draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, int p_index, float p_x); + void _draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, int p_index, float p_x, bool p_focus); protected: virtual void gui_input(const Ref<InputEvent> &p_event) override; @@ -214,6 +219,9 @@ public: int get_previous_tab() const; int get_hovered_tab() const; + bool select_previous_available(); + bool select_next_available(); + int get_tab_offset() const; bool get_offset_buttons_visible() const; diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 14bc87ad40..b757b516d1 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -195,6 +195,7 @@ void TabContainer::_on_theme_changed() { tab_bar->add_theme_style_override(SNAME("tab_hovered"), theme_cache.tab_hovered_style); tab_bar->add_theme_style_override(SNAME("tab_selected"), theme_cache.tab_selected_style); tab_bar->add_theme_style_override(SNAME("tab_disabled"), theme_cache.tab_disabled_style); + tab_bar->add_theme_style_override(SNAME("tab_focus"), theme_cache.tab_focus_style); tab_bar->add_theme_icon_override(SNAME("increment"), theme_cache.increment_icon); tab_bar->add_theme_icon_override(SNAME("increment_highlight"), theme_cache.increment_hl_icon); @@ -585,6 +586,10 @@ void TabContainer::remove_child_notify(Node *p_child) { } } +TabBar *TabContainer::get_tab_bar() const { + return tab_bar; +} + int TabContainer::get_tab_count() const { return tab_bar->get_tab_count(); } @@ -601,6 +606,14 @@ int TabContainer::get_previous_tab() const { return tab_bar->get_previous_tab(); } +bool TabContainer::select_previous_available() { + return tab_bar->select_previous_available(); +} + +bool TabContainer::select_next_available() { + return tab_bar->select_next_available(); +} + Control *TabContainer::get_tab_control(int p_idx) const { Vector<Control *> controls = _get_tab_controls(); if (p_idx >= 0 && p_idx < controls.size()) { @@ -645,6 +658,14 @@ TabBar::AlignmentMode TabContainer::get_tab_alignment() const { return tab_bar->get_tab_alignment(); } +void TabContainer::set_tab_focus_mode(Control::FocusMode p_focus_mode) { + tab_bar->set_focus_mode(p_focus_mode); +} + +Control::FocusMode TabContainer::get_tab_focus_mode() const { + return tab_bar->get_focus_mode(); +} + void TabContainer::set_clip_tabs(bool p_clip_tabs) { tab_bar->set_clip_tabs(p_clip_tabs); } @@ -911,7 +932,10 @@ void TabContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &TabContainer::set_current_tab); ClassDB::bind_method(D_METHOD("get_current_tab"), &TabContainer::get_current_tab); ClassDB::bind_method(D_METHOD("get_previous_tab"), &TabContainer::get_previous_tab); + ClassDB::bind_method(D_METHOD("select_previous_available"), &TabContainer::select_previous_available); + ClassDB::bind_method(D_METHOD("select_next_available"), &TabContainer::select_next_available); ClassDB::bind_method(D_METHOD("get_current_tab_control"), &TabContainer::get_current_tab_control); + ClassDB::bind_method(D_METHOD("get_tab_bar"), &TabContainer::get_tab_bar); ClassDB::bind_method(D_METHOD("get_tab_control", "tab_idx"), &TabContainer::get_tab_control); ClassDB::bind_method(D_METHOD("set_tab_alignment", "alignment"), &TabContainer::set_tab_alignment); ClassDB::bind_method(D_METHOD("get_tab_alignment"), &TabContainer::get_tab_alignment); @@ -943,6 +967,8 @@ void TabContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_tabs_rearrange_group"), &TabContainer::get_tabs_rearrange_group); ClassDB::bind_method(D_METHOD("set_use_hidden_tabs_for_min_size", "enabled"), &TabContainer::set_use_hidden_tabs_for_min_size); ClassDB::bind_method(D_METHOD("get_use_hidden_tabs_for_min_size"), &TabContainer::get_use_hidden_tabs_for_min_size); + ClassDB::bind_method(D_METHOD("set_tab_focus_mode", "focus_mode"), &TabContainer::set_tab_focus_mode); + ClassDB::bind_method(D_METHOD("get_tab_focus_mode"), &TabContainer::get_tab_focus_mode); ADD_SIGNAL(MethodInfo("active_tab_rearranged", PropertyInfo(Variant::INT, "idx_to"))); ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab"))); @@ -960,6 +986,7 @@ void TabContainer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_to_rearrange_enabled"), "set_drag_to_rearrange_enabled", "get_drag_to_rearrange_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "tabs_rearrange_group"), "set_tabs_rearrange_group", "get_tabs_rearrange_group"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_hidden_tabs_for_min_size"), "set_use_hidden_tabs_for_min_size", "get_use_hidden_tabs_for_min_size"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "tab_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_tab_focus_mode", "get_tab_focus_mode"); BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, TabContainer, side_margin); @@ -977,6 +1004,7 @@ void TabContainer::_bind_methods() { BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabContainer, tab_hovered_style, "tab_hovered"); BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabContainer, tab_selected_style, "tab_selected"); BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabContainer, tab_disabled_style, "tab_disabled"); + BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabContainer, tab_focus_style, "tab_focus"); BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, TabContainer, increment_icon, "increment"); BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, TabContainer, increment_hl_icon, "increment_highlight"); diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index 2bcc640d05..a831416612 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -66,6 +66,7 @@ class TabContainer : public Container { Ref<StyleBox> tab_hovered_style; Ref<StyleBox> tab_selected_style; Ref<StyleBox> tab_disabled_style; + Ref<StyleBox> tab_focus_style; Ref<Texture2D> increment_icon; Ref<Texture2D> increment_hl_icon; @@ -111,12 +112,17 @@ protected: static void _bind_methods(); public: + TabBar *get_tab_bar() const; + int get_tab_idx_at_point(const Point2 &p_point) const; int get_tab_idx_from_control(Control *p_child) const; void set_tab_alignment(TabBar::AlignmentMode p_alignment); TabBar::AlignmentMode get_tab_alignment() const; + void set_tab_focus_mode(FocusMode p_focus_mode); + FocusMode get_tab_focus_mode() const; + void set_clip_tabs(bool p_clip_tabs); bool get_clip_tabs() const; @@ -149,6 +155,9 @@ public: int get_current_tab() const; int get_previous_tab() const; + bool select_previous_available(); + bool select_next_available(); + Control *get_tab_control(int p_idx) const; Control *get_current_tab_control() const; diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index 274bd1ad68..c9cca76dea 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -348,7 +348,7 @@ void CanvasLayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible"); ADD_GROUP("Transform", ""); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset", PROPERTY_HINT_NONE, "suffix:px"), "set_offset", "get_offset"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.1,or_less,or_greater,radians"), "set_rotation", "get_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.1,or_less,or_greater,radians_as_degrees"), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale", PROPERTY_HINT_LINK), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "suffix:px"), "set_transform", "get_transform"); ADD_GROUP("", ""); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index ad11c80c42..3a4fe9a059 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -4505,7 +4505,7 @@ void Viewport::_bind_methods() { #ifndef _3D_DISABLED ADD_GROUP("Scaling 3D", ""); - ADD_PROPERTY(PropertyInfo(Variant::INT, "scaling_3d_mode", PROPERTY_HINT_ENUM, "Bilinear (Fastest),FSR 1.0 (Fast)"), "set_scaling_3d_mode", "get_scaling_3d_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "scaling_3d_mode", PROPERTY_HINT_ENUM, "Bilinear (Fastest),FSR 1.0 (Fast),FSR 2.2 (Slow)"), "set_scaling_3d_mode", "get_scaling_3d_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scaling_3d_scale", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), "set_scaling_3d_scale", "get_scaling_3d_scale"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.001"), "set_texture_mipmap_bias", "get_texture_mipmap_bias"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fsr_sharpness", PROPERTY_HINT_RANGE, "0,2,0.1"), "set_fsr_sharpness", "get_fsr_sharpness"); @@ -4556,6 +4556,7 @@ void Viewport::_bind_methods() { BIND_ENUM_CONSTANT(SCALING_3D_MODE_BILINEAR); BIND_ENUM_CONSTANT(SCALING_3D_MODE_FSR); + BIND_ENUM_CONSTANT(SCALING_3D_MODE_FSR2); BIND_ENUM_CONSTANT(SCALING_3D_MODE_MAX); BIND_ENUM_CONSTANT(MSAA_DISABLED); @@ -4603,6 +4604,7 @@ void Viewport::_bind_methods() { BIND_ENUM_CONSTANT(DEBUG_DRAW_CLUSTER_REFLECTION_PROBES); BIND_ENUM_CONSTANT(DEBUG_DRAW_OCCLUDERS) BIND_ENUM_CONSTANT(DEBUG_DRAW_MOTION_VECTORS) + BIND_ENUM_CONSTANT(DEBUG_DRAW_INTERNAL_BUFFER); BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST); BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 68084fc35f..a32077a489 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -98,6 +98,7 @@ public: enum Scaling3DMode { SCALING_3D_MODE_BILINEAR, SCALING_3D_MODE_FSR, + SCALING_3D_MODE_FSR2, SCALING_3D_MODE_MAX }; @@ -167,6 +168,7 @@ public: DEBUG_DRAW_CLUSTER_REFLECTION_PROBES, DEBUG_DRAW_OCCLUDERS, DEBUG_DRAW_MOTION_VECTORS, + DEBUG_DRAW_INTERNAL_BUFFER, }; enum DefaultCanvasItemTextureFilter { diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index abe1561310..b936c2decf 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -1172,7 +1172,7 @@ void Environment::_bind_methods() { ADD_GROUP("Sky", "sky_"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sky_custom_fov", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), "set_sky_custom_fov", "get_sky_custom_fov"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "sky_rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_sky_rotation", "get_sky_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "sky_rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians_as_degrees"), "set_sky_rotation", "get_sky_rotation"); // Ambient light diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h index b88399117d..0c996e2de9 100644 --- a/scene/resources/gradient.h +++ b/scene/resources/gradient.h @@ -55,8 +55,8 @@ public: struct Point { float offset = 0.0; Color color; - bool operator<(const Point &p_ponit) const { - return offset < p_ponit.offset; + bool operator<(const Point &p_point) const { + return offset < p_point.offset; } }; diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp index f479ae1e1b..092ba84aa5 100644 --- a/scene/resources/importer_mesh.cpp +++ b/scene/resources/importer_mesh.cpp @@ -514,6 +514,10 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli const Vector3 &v2 = vertices_ptr[new_indices_ptr[j + 2]]; Vector3 face_normal = vec3_cross(v0 - v2, v0 - v1); float face_area = face_normal.length(); // Actually twice the face area, since it's the same error_factor on all faces, we don't care + if (!Math::is_finite(face_area) || face_area == 0) { + WARN_PRINT_ONCE("Ignoring face with non-finite normal in LOD generation."); + continue; + } Vector3 dir = face_normal / face_area; int ray_count = CLAMP(5.0 * face_area * error_factor, 16, 64); diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp index 7efbc74bf3..b65c372fab 100644 --- a/scene/theme/default_theme.cpp +++ b/scene/theme/default_theme.cpp @@ -360,6 +360,28 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_constant("check_v_offset", "CheckButton", 0); theme->set_constant("outline_size", "CheckButton", 0); + // Button variations + + theme->set_type_variation("FlatButton", "Button"); + theme->set_type_variation("FlatMenuButton", "MenuButton"); + + Ref<StyleBoxEmpty> flat_button_normal = make_empty_stylebox(); + for (int i = 0; i < 4; i++) { + flat_button_normal->set_content_margin((Side)i, button_normal->get_margin((Side)i) + button_normal->get_border_width((Side)i)); + } + Ref<StyleBoxFlat> flat_button_pressed = button_pressed->duplicate(); + flat_button_pressed->set_bg_color(style_pressed_color * Color(1, 1, 1, 0.85)); + + theme->set_stylebox("normal", "FlatButton", flat_button_normal); + theme->set_stylebox("hover", "FlatButton", flat_button_normal); + theme->set_stylebox("pressed", "FlatButton", flat_button_pressed); + theme->set_stylebox("disabled", "FlatButton", flat_button_normal); + + theme->set_stylebox("normal", "FlatMenuButton", flat_button_normal); + theme->set_stylebox("hover", "FlatMenuButton", flat_button_normal); + theme->set_stylebox("pressed", "FlatMenuButton", flat_button_pressed); + theme->set_stylebox("disabled", "FlatMenuButton", flat_button_normal); + // Label theme->set_stylebox("normal", "Label", memnew(StyleBoxEmpty)); @@ -845,11 +867,13 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const style_tab_disabled->set_bg_color(style_disabled_color); Ref<StyleBoxFlat> style_tab_hovered = style_tab_unselected->duplicate(); style_tab_hovered->set_bg_color(Color(0.1, 0.1, 0.1, 0.3)); + Ref<StyleBoxFlat> style_tab_focus = focus->duplicate(); theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected); theme->set_stylebox("tab_hovered", "TabContainer", style_tab_hovered); theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected); theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled); + theme->set_stylebox("tab_focus", "TabContainer", style_tab_focus); theme->set_stylebox("panel", "TabContainer", make_flat_stylebox(style_normal_color, 0, 0, 0, 0)); theme->set_stylebox("tabbar_background", "TabContainer", make_empty_stylebox(0, 0, 0, 0)); @@ -882,6 +906,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_stylebox("tab_hovered", "TabBar", style_tab_hovered); theme->set_stylebox("tab_unselected", "TabBar", style_tab_unselected); theme->set_stylebox("tab_disabled", "TabBar", style_tab_disabled); + theme->set_stylebox("tab_focus", "TabBar", style_tab_focus); theme->set_stylebox("button_pressed", "TabBar", button_pressed); theme->set_stylebox("button_highlight", "TabBar", button_normal); diff --git a/scene/theme/theme_owner.cpp b/scene/theme/theme_owner.cpp index 92cffeb228..2852a64e39 100644 --- a/scene/theme/theme_owner.cpp +++ b/scene/theme/theme_owner.cpp @@ -212,8 +212,26 @@ void ThemeOwner::get_theme_type_dependencies(const Node *p_for_node, const Strin type_variation = for_w->get_theme_type_variation(); } - // If we are looking for dependencies of the current class (or a variation of it), check themes from the context. + // If we are looking for dependencies of the current class (or a variation of it), check relevant themes. if (p_theme_type == StringName() || p_theme_type == type_name || p_theme_type == type_variation) { + // We need one theme that can give us a valid dependency chain. It must be complete + // (i.e. variations can depend on other variations, but only within the same theme, + // and eventually the chain must lead to native types). + + // First, look through themes owned by nodes in the tree. + Node *owner_node = get_owner_node(); + + while (owner_node) { + Ref<Theme> owner_theme = _get_owner_node_theme(owner_node); + if (owner_theme.is_valid() && owner_theme->get_type_variation_base(type_variation) != StringName()) { + owner_theme->get_type_dependencies(type_name, type_variation, r_list); + return; + } + + owner_node = _get_next_owner_node(owner_node); + } + + // Second, check global contexts. ThemeContext *global_context = _get_active_owner_context(); for (const Ref<Theme> &theme : global_context->get_themes()) { if (theme.is_valid() && theme->get_type_variation_base(type_variation) != StringName()) { |
