diff options
Diffstat (limited to 'scene')
40 files changed, 243 insertions, 195 deletions
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 1afbd150a2..cb8ee761e6 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -248,7 +248,7 @@ public: void draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color); void draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1), const Ref<Texture> &p_normal_map = Ref<Texture>()); void draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()); - void draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true); + void draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = false); void draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect); void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture = Ref<Texture>(), float p_width = 1, const Ref<Texture> &p_normal_map = Ref<Texture>()); void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false); diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index e62b59dd4d..c562a4652d 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -65,7 +65,7 @@ void Node2D::edit_set_state(const Variant &p_state) { _scale = state[2]; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); _change_notify("scale"); _change_notify("position"); } @@ -106,7 +106,7 @@ void Node2D::edit_rotate(float p_rot) { angle += p_rot; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); } void Node2D::_update_xform_values() { @@ -147,22 +147,14 @@ void Node2D::set_rotation(float p_radians) { angle = p_radians; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); } -void Node2D::set_rotation_in_degrees(float p_degrees) { +void Node2D::set_rotation_degrees(float p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } -// Kept for compatibility after rename to set_rotd. -// Could be removed after a couple releases. -void Node2D::_set_rotd(float p_degrees) { - - WARN_PRINT("Deprecated method Node2D._set_rotd(): This method was renamed to set_rotd. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotation_in_degrees(p_degrees); -} - void Node2D::set_scale(const Size2 &p_scale) { if (_xform_dirty) @@ -182,23 +174,19 @@ Point2 Node2D::get_position() const { ((Node2D *)this)->_update_xform_values(); return pos; } + float Node2D::get_rotation() const { if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); return angle; } -float Node2D::get_rotation_in_degrees() const { + +float Node2D::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } -// Kept for compatibility after rename to get_rotd. -// Could be removed after a couple releases. -float Node2D::_get_rotd() const { - WARN_PRINT("Deprecated method Node2D._get_rotd(): This method was renamed to get_rotd. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotation_in_degrees(); -} Size2 Node2D::get_scale() const { if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); @@ -299,12 +287,12 @@ void Node2D::set_global_rotation(float p_radians) { } } -float Node2D::get_global_rotation_in_degrees() const { +float Node2D::get_global_rotation_degrees() const { return Math::rad2deg(get_global_rotation()); } -void Node2D::set_global_rotation_in_degrees(float p_degrees) { +void Node2D::set_global_rotation_degrees(float p_degrees) { set_global_rotation(Math::deg2rad(p_degrees)); } @@ -410,18 +398,14 @@ Point2 Node2D::to_global(Point2 p_local) const { void Node2D::_bind_methods() { - // TODO: Obsolete those two methods (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_get_rotd"), &Node2D::_get_rotd); - ClassDB::bind_method(D_METHOD("_set_rotd", "degrees"), &Node2D::_set_rotd); - ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_in_degrees", "degrees"), &Node2D::set_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Node2D::set_scale); ClassDB::bind_method(D_METHOD("get_position"), &Node2D::get_position); ClassDB::bind_method(D_METHOD("get_rotation"), &Node2D::get_rotation); - ClassDB::bind_method(D_METHOD("get_rotation_in_degrees"), &Node2D::get_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Node2D::get_rotation_degrees); ClassDB::bind_method(D_METHOD("get_scale"), &Node2D::get_scale); ClassDB::bind_method(D_METHOD("rotate", "radians"), &Node2D::rotate); @@ -435,8 +419,8 @@ void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_global_position"), &Node2D::get_global_position); ClassDB::bind_method(D_METHOD("set_global_rotation", "radians"), &Node2D::set_global_rotation); ClassDB::bind_method(D_METHOD("get_global_rotation"), &Node2D::get_global_rotation); - ClassDB::bind_method(D_METHOD("set_global_rotation_in_degrees", "degrees"), &Node2D::set_global_rotation_in_degrees); - ClassDB::bind_method(D_METHOD("get_global_rotation_in_degrees"), &Node2D::get_global_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_global_rotation_degrees", "degrees"), &Node2D::set_global_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_global_rotation_degrees"), &Node2D::get_global_rotation_degrees); ClassDB::bind_method(D_METHOD("set_global_scale", "scale"), &Node2D::set_global_scale); ClassDB::bind_method(D_METHOD("get_global_scale"), &Node2D::get_global_scale); @@ -462,13 +446,13 @@ void Node2D::_bind_methods() { ADD_GROUP("Transform", ""); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position"); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation"); - ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation_deg", PROPERTY_HINT_RANGE, "-1440,1440,0.1", PROPERTY_USAGE_EDITOR), "set_rotation_in_degrees", "get_rotation_in_degrees"); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation_degrees", PROPERTY_HINT_RANGE, "-1440,1440,0.1", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", 0), "set_transform", "get_transform"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_position", PROPERTY_HINT_NONE, "", 0), "set_global_position", "get_global_position"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation", PROPERTY_HINT_NONE, "", 0), "set_global_rotation", "get_global_rotation"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation_deg", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_in_degrees", "get_global_rotation_in_degrees"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation_degrees", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_degrees", "get_global_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_scale", PROPERTY_HINT_NONE, "", 0), "set_global_scale", "get_global_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index 19aafc81ff..eca1e96c82 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -48,10 +48,6 @@ class Node2D : public CanvasItem { void _update_transform(); - // Deprecated, should be removed in a future version. - void _set_rotd(float p_degrees); - float _get_rotd() const; - void _update_xform_values(); protected: @@ -70,7 +66,7 @@ public: void set_position(const Point2 &p_pos); void set_rotation(float p_radians); - void set_rotation_in_degrees(float p_degrees); + void set_rotation_degrees(float p_degrees); void set_scale(const Size2 &p_scale); void rotate(float p_radians); @@ -82,12 +78,12 @@ public: Point2 get_position() const; float get_rotation() const; - float get_rotation_in_degrees() const; + float get_rotation_degrees() const; Size2 get_scale() const; Point2 get_global_position() const; float get_global_rotation() const; - float get_global_rotation_in_degrees() const; + float get_global_rotation_degrees() const; Size2 get_global_scale() const; virtual Rect2 get_item_rect() const; @@ -95,7 +91,7 @@ public: void set_global_transform(const Transform2D &p_transform); void set_global_position(const Point2 &p_pos); void set_global_rotation(float p_radians); - void set_global_rotation_in_degrees(float p_degrees); + void set_global_rotation_degrees(float p_degrees); void set_global_scale(const Size2 &p_scale); void set_z(int p_z); diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index f0ee64a53f..1287a800e3 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -133,8 +133,9 @@ bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const { } PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) - : CollisionObject2D(Physics2DServer::get_singleton()->body_create(p_mode), false) { + : CollisionObject2D(Physics2DServer::get_singleton()->body_create(), false) { + Physics2DServer::get_singleton()->body_set_mode(get_rid(), p_mode); collision_layer = 1; collision_mask = 1; set_pickable(false); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 197c74352e..b5b5445684 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -264,11 +264,11 @@ float Polygon2D::get_texture_rotation() const { return tex_rot; } -void Polygon2D::_set_texture_rotationd(float p_rot) { +void Polygon2D::set_texture_rotation_degrees(float p_rot) { set_texture_rotation(Math::deg2rad(p_rot)); } -float Polygon2D::_get_texture_rotationd() const { +float Polygon2D::get_texture_rotation_degrees() const { return Math::rad2deg(get_texture_rotation()); } @@ -348,8 +348,8 @@ void Polygon2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture_rotation", "texture_rotation"), &Polygon2D::set_texture_rotation); ClassDB::bind_method(D_METHOD("get_texture_rotation"), &Polygon2D::get_texture_rotation); - ClassDB::bind_method(D_METHOD("_set_texture_rotationd", "texture_rotation"), &Polygon2D::_set_texture_rotationd); - ClassDB::bind_method(D_METHOD("_get_texture_rotationd"), &Polygon2D::_get_texture_rotationd); + ClassDB::bind_method(D_METHOD("set_texture_rotation_degrees", "texture_rotation"), &Polygon2D::set_texture_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_texture_rotation_degrees"), &Polygon2D::get_texture_rotation_degrees); ClassDB::bind_method(D_METHOD("set_texture_scale", "texture_scale"), &Polygon2D::set_texture_scale); ClassDB::bind_method(D_METHOD("get_texture_scale"), &Polygon2D::get_texture_scale); @@ -377,7 +377,7 @@ void Polygon2D::_bind_methods() { ADD_GROUP("Texture", "texture_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_offset"), "set_texture_offset", "get_texture_offset"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale"), "set_texture_scale", "get_texture_scale"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), "_set_texture_rotationd", "_get_texture_rotationd"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), "set_texture_rotation_degrees", "get_texture_rotation_degrees"); ADD_GROUP("Invert", "invert_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert_enable"), "set_invert", "get_invert"); diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index 20c3324a50..0c2c049c18 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -53,9 +53,6 @@ class Polygon2D : public Node2D { mutable bool rect_cache_dirty; mutable Rect2 item_rect; - void _set_texture_rotationd(float p_rot); - float _get_texture_rotationd() const; - protected: void _notification(int p_what); static void _bind_methods(); @@ -82,6 +79,9 @@ public: void set_texture_rotation(float p_rot); float get_texture_rotation() const; + void set_texture_rotation_degrees(float p_rot); + float get_texture_rotation_degrees() const; + void set_texture_scale(const Size2 &p_scale); Size2 get_texture_scale() const; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 4286d88ab1..5fb9e3f527 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -448,13 +448,12 @@ void TileMap::_update_dirty_quadrants() { if (r == Rect2()) { tex->draw_rect(canvas_item, rect, false, modulate, c.transpose, normal_map); } else { - tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map); + tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map, clip_uv); } Vector<TileSet::ShapeData> shapes = tile_set->tile_get_shapes(c.id); for (int i = 0; i < shapes.size(); i++) { - Ref<Shape2D> shape = shapes[i].shape; if (shape.is_valid()) { Transform2D xform; @@ -587,7 +586,9 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons xform.set_origin(q.pos); //q.canvas_item = VisualServer::get_singleton()->canvas_item_create(); - q.body = Physics2DServer::get_singleton()->body_create(use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC); + q.body = Physics2DServer::get_singleton()->body_create(); + Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC); + Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id()); Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer); Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask); @@ -1234,6 +1235,21 @@ void TileMap::set_light_mask(int p_light_mask) { } } +void TileMap::set_clip_uv(bool p_enable) { + + if (clip_uv == p_enable) + return; + + _clear_quadrants(); + clip_uv = p_enable; + _recreate_quadrants(); +} + +bool TileMap::get_clip_uv() const { + + return clip_uv; +} + void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_tileset", "tileset"), &TileMap::set_tileset); @@ -1266,6 +1282,9 @@ void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_center_y", "enable"), &TileMap::set_center_y); ClassDB::bind_method(D_METHOD("get_center_y"), &TileMap::get_center_y); + ClassDB::bind_method(D_METHOD("set_clip_uv", "enable"), &TileMap::set_clip_uv); + ClassDB::bind_method(D_METHOD("get_clip_uv"), &TileMap::get_clip_uv); + ClassDB::bind_method(D_METHOD("set_y_sort_mode", "enable"), &TileMap::set_y_sort_mode); ClassDB::bind_method(D_METHOD("is_y_sort_mode_enabled"), &TileMap::is_y_sort_mode_enabled); @@ -1327,6 +1346,7 @@ void TileMap::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_half_offset", PROPERTY_HINT_ENUM, "Offset X,Offset Y,Disabled"), "set_half_offset", "get_half_offset"); ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_tile_origin", PROPERTY_HINT_ENUM, "Top Left,Center,Bottom Left"), "set_tile_origin", "get_tile_origin"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_y_sort"), "set_y_sort_mode", "is_y_sort_mode_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_clip_uv"), "set_clip_uv", "get_clip_uv"); ADD_GROUP("Collision", "collision_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision_use_kinematic", PROPERTY_HINT_NONE, ""), "set_collision_use_kinematic", "get_collision_use_kinematic"); @@ -1377,6 +1397,7 @@ TileMap::TileMap() { navigation = NULL; y_sort_mode = false; occluder_light_mask = 1; + clip_uv = false; fp_adjust = 0.00001; tile_origin = TILE_ORIGIN_TOP_LEFT; diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index c9d14e09d1..706b87cec3 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -161,6 +161,7 @@ private: bool used_size_cache_dirty; bool quadrant_order_dirty; bool y_sort_mode; + bool clip_uv; float fp_adjust; float friction; float bounce; @@ -285,6 +286,9 @@ public: virtual void set_use_parent_material(bool p_use_parent_material); + void set_clip_uv(bool p_enable); + bool get_clip_uv() const; + void clear(); TileMap(); diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 02d10523e7..389d87cd90 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -255,7 +255,13 @@ void Light::_bind_methods() { Light::Light(VisualServer::LightType p_type) { type = p_type; - light = VisualServer::get_singleton()->light_create(p_type); + switch (p_type) { + case VS::LIGHT_DIRECTIONAL: light = VisualServer::get_singleton()->directional_light_create(); break; + case VS::LIGHT_OMNI: light = VisualServer::get_singleton()->omni_light_create(); break; + case VS::LIGHT_SPOT: light = VisualServer::get_singleton()->spot_light_create(); break; + default: {}; + } + VS::get_singleton()->instance_set_base(get_instance(), light); reverse_cull = false; diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 4e19214c59..6ac6e52367 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -642,7 +642,7 @@ void ParticlesMaterial::_update_shader() { code += " float angle1 = (rand_from_seed(alt_seed)*2.0-1.0)*spread/180.0*3.1416;\n"; code += " vec3 rot = vec3( cos(angle1), sin(angle1),0.0 );\n"; - code += " VELOCITY = (rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n"; + code += " VELOCITY = rot*initial_linear_velocity*mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n"; } else { //initiate velocity spread in 3D @@ -650,7 +650,7 @@ void ParticlesMaterial::_update_shader() { code += " float angle2 = rand_from_seed(alt_seed)*20.0*3.1416; // make it more random like\n"; code += " vec3 rot_xz = vec3( sin(angle1), 0.0, cos(angle1) );\n"; code += " vec3 rot = vec3( cos(angle2)*rot_xz.x,sin(angle2)*rot_xz.x, rot_xz.z);\n"; - code += " VELOCITY = (rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n"; + code += " VELOCITY = rot*initial_linear_velocity*mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n"; } code += " float base_angle = (initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n"; @@ -761,11 +761,11 @@ void ParticlesMaterial::_update_shader() { code += " force += length(diff) > 0.0 ? normalize(diff) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random) : vec3(0.0);\n"; code += " //apply tangential acceleration;\n"; if (flags[FLAG_DISABLE_Z]) { - code += " force += length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; + code += " force += length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),tangent_accel_random)) : vec3(0.0);\n"; } else { code += " vec3 crossDiff = cross(normalize(diff),normalize(gravity));\n"; - code += " force += length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; + code += " force += length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),tangent_accel_random)) : vec3(0.0);\n"; } code += " //apply attractor forces\n"; code += " VELOCITY += force * DELTA;\n"; diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 4c661e6a88..4e06b272e2 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -938,7 +938,7 @@ bool KinematicBody::move_and_collide(const Vector3 &p_motion, Collision &r_colli Transform gt = get_global_transform(); PhysicsServer::MotionResult result; - bool colliding = PhysicsServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, margin, &result); + bool colliding = PhysicsServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, &result); if (colliding) { r_collision.collider_metadata = result.collider_metadata; @@ -988,12 +988,15 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve on_floor = true; floor_velocity = collision.collider_vel; - /*if (collision.travel.length() < 0.01 && ABS((lv.x - floor_velocity.x)) < p_slope_stop_min_velocity) { + Vector3 rel_v = lv - floor_velocity; + Vector3 hv = rel_v - p_floor_direction * p_floor_direction.dot(rel_v); + + if (collision.travel.length() < 0.05 && hv.length() < p_slope_stop_min_velocity) { Transform gt = get_global_transform(); - gt.elements[2] -= collision.travel; + gt.origin -= collision.travel; set_global_transform(gt); - return Vector3(); - }*/ + return floor_velocity - p_floor_direction * p_floor_direction.dot(floor_velocity); + } } else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle)) { //ceiling on_ceiling = true; } else { @@ -1041,12 +1044,13 @@ bool KinematicBody::test_move(const Transform &p_from, const Vector3 &p_motion) ERR_FAIL_COND_V(!is_inside_tree(), false); - return PhysicsServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, margin); + return PhysicsServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion); } void KinematicBody::set_safe_margin(float p_margin) { margin = p_margin; + PhysicsServer::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin); } float KinematicBody::get_safe_margin() const { diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 0dfd80ca90..588aa2881a 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -233,7 +233,7 @@ void Spatial::set_transform(const Transform &p_transform) { data.dirty |= DIRTY_VECTORS; _change_notify("translation"); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); _change_notify("scale"); _propagate_transform_changed(this); if (data.notify_local_transform) { @@ -327,17 +327,11 @@ void Spatial::set_rotation(const Vector3 &p_euler_rad) { } } -void Spatial::set_rotation_in_degrees(const Vector3 &p_euler_deg) { +void Spatial::set_rotation_degrees(const Vector3 &p_euler_deg) { set_rotation(p_euler_deg * Math_PI / 180.0); } -void Spatial::_set_rotation_deg(const Vector3 &p_euler_deg) { - - WARN_PRINT("Deprecated method Spatial._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotation_in_degrees(p_euler_deg); -} - void Spatial::set_scale(const Vector3 &p_scale) { if (data.dirty & DIRTY_VECTORS) { @@ -370,19 +364,11 @@ Vector3 Spatial::get_rotation() const { return data.rotation; } -Vector3 Spatial::get_rotation_in_degrees() const { +Vector3 Spatial::get_rotation_degrees() const { return get_rotation() * 180.0 / Math_PI; } -// Kept for compatibility after rename to set_rotd. -// Could be removed after a couple releases. -Vector3 Spatial::_get_rotation_deg() const { - - WARN_PRINT("Deprecated method Spatial._get_rotation_deg(): This method was renamed to get_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotation_in_degrees(); -} - Vector3 Spatial::get_scale() const { if (data.dirty & DIRTY_VECTORS) { @@ -691,10 +677,10 @@ void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("get_transform"), &Spatial::get_transform); ClassDB::bind_method(D_METHOD("set_translation", "translation"), &Spatial::set_translation); ClassDB::bind_method(D_METHOD("get_translation"), &Spatial::get_translation); - ClassDB::bind_method(D_METHOD("set_rotation", "rotation_rad"), &Spatial::set_rotation); + ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Spatial::set_rotation); ClassDB::bind_method(D_METHOD("get_rotation"), &Spatial::get_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_deg", "rotation_deg"), &Spatial::set_rotation_in_degrees); - ClassDB::bind_method(D_METHOD("get_rotation_deg"), &Spatial::get_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Spatial::set_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Spatial::get_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Spatial::set_scale); ClassDB::bind_method(D_METHOD("get_scale"), &Spatial::get_scale); ClassDB::bind_method(D_METHOD("set_global_transform", "global"), &Spatial::set_global_transform); @@ -705,10 +691,6 @@ void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel); ClassDB::bind_method(D_METHOD("get_world"), &Spatial::get_world); - // TODO: Obsolete those two methods (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_set_rotation_deg", "rotation_deg"), &Spatial::_set_rotation_deg); - ClassDB::bind_method(D_METHOD("_get_rotation_deg"), &Spatial::_get_rotation_deg); - #ifdef TOOLS_ENABLED ClassDB::bind_method(D_METHOD("_update_gizmo"), &Spatial::_update_gizmo); #endif @@ -764,7 +746,7 @@ void Spatial::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::TRANSFORM, "transform", PROPERTY_HINT_NONE, ""), "set_transform", "get_transform"); ADD_PROPERTYNZ(PropertyInfo(Variant::TRANSFORM, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_translation", "get_translation"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_deg", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_deg", "get_rotation_deg"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", 0), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale"); ADD_GROUP("Visibility", ""); diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index b912d1f906..8f53b4a066 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -106,10 +106,6 @@ class Spatial : public Node { void _notify_dirty(); void _propagate_transform_changed(Spatial *p_origin); - // Deprecated, should be removed in a future version. - void _set_rotation_deg(const Vector3 &p_euler_deg); - Vector3 _get_rotation_deg() const; - void _propagate_visibility_changed(); protected: @@ -136,12 +132,12 @@ public: void set_translation(const Vector3 &p_translation); void set_rotation(const Vector3 &p_euler_rad); - void set_rotation_in_degrees(const Vector3 &p_euler_deg); + void set_rotation_degrees(const Vector3 &p_euler_deg); void set_scale(const Vector3 &p_scale); Vector3 get_translation() const; Vector3 get_rotation() const; - Vector3 get_rotation_in_degrees() const; + Vector3 get_rotation_degrees() const; Vector3 get_scale() const; void set_transform(const Transform &p_transform); diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 058b162e83..08b01c6a4c 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -31,20 +31,7 @@ #include "engine.h" -void AudioStreamPlayer::_mix_audio() { - - if (!stream_playback.is_valid()) { - return; - } - - if (!active) { - return; - } - - if (setseek >= 0.0) { - stream_playback->start(setseek); - setseek = -1.0; //reset seek - } +void AudioStreamPlayer::_mix_internal(bool p_fadeout) { int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus); @@ -52,19 +39,24 @@ void AudioStreamPlayer::_mix_audio() { AudioFrame *buffer = mix_buffer.ptr(); int buffer_size = mix_buffer.size(); + if (p_fadeout) { + buffer_size = MIN(buffer_size, 16); //short fadeout ramp + } + //mix stream_playback->mix(buffer, 1.0, buffer_size); //multiply volume interpolating to avoid clicks if this changes + float target_volume = p_fadeout ? -80.0 : volume_db; float vol = Math::db2linear(mix_volume_db); - float vol_inc = (Math::db2linear(volume_db) - vol) / float(buffer_size); + float vol_inc = (Math::db2linear(target_volume) - vol) / float(buffer_size); for (int i = 0; i < buffer_size; i++) { buffer[i] *= vol; vol += vol_inc; } //set volume for next mix - mix_volume_db = volume_db; + mix_volume_db = target_volume; AudioFrame *targets[4] = { NULL, NULL, NULL, NULL }; @@ -95,6 +87,30 @@ void AudioStreamPlayer::_mix_audio() { } } +void AudioStreamPlayer::_mix_audio() { + + if (!stream_playback.is_valid()) { + return; + } + + if (!active) { + return; + } + + if (setseek >= 0.0) { + if (stream_playback->is_playing()) { + + //fade out to avoid pops + _mix_internal(true); + } + stream_playback->start(setseek); + setseek = -1.0; //reset seek + mix_volume_db = volume_db; //reset ramp + } + + _mix_internal(false); +} + void AudioStreamPlayer::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { @@ -163,7 +179,7 @@ float AudioStreamPlayer::get_volume_db() const { void AudioStreamPlayer::play(float p_from_pos) { if (stream_playback.is_valid()) { - mix_volume_db = volume_db; //reset volume ramp + //mix_volume_db = volume_db; do not reset volume ramp here, can cause clicks setseek = p_from_pos; active = true; set_process_internal(true); diff --git a/scene/audio/audio_player.h b/scene/audio/audio_player.h index 4bfc44730d..6e9d623433 100644 --- a/scene/audio/audio_player.h +++ b/scene/audio/audio_player.h @@ -59,6 +59,7 @@ private: MixTarget mix_target; + void _mix_internal(bool p_fadeout); void _mix_audio(); static void _mix_audios(void *self) { reinterpret_cast<AudioStreamPlayer *>(self)->_mix_audio(); } diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index e68159e27f..77fdedd5e5 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -32,6 +32,23 @@ #include "print_string.h" #include "servers/visual_server.h" +Size2 CheckButton::get_minimum_size() const { + + Size2 minsize = Button::get_minimum_size(); + + Ref<Texture> on = Control::get_icon("on"); + Ref<Texture> off = Control::get_icon("off"); + Size2 tex_size = Size2(0, 0); + if (!on.is_null()) + tex_size = Size2(on->get_width(), on->get_height()); + if (!off.is_null()) + tex_size = Size2(MAX(tex_size.width, off->get_width()), MAX(tex_size.height, off->get_height())); + minsize += Size2(tex_size.width + get_constant("hseparation"), 0); + minsize.height = MAX(minsize.height, tex_size.height); + + return get_stylebox("normal")->get_minimum_size() + minsize; +} + void CheckButton::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { @@ -41,9 +58,11 @@ void CheckButton::_notification(int p_what) { Ref<Texture> on = Control::get_icon("on"); Ref<Texture> off = Control::get_icon("off"); + Ref<StyleBox> sb = get_stylebox("normal"); + Size2 sb_ofs = Size2(sb->get_margin(MARGIN_RIGHT), sb->get_margin(MARGIN_TOP)); Vector2 ofs; - ofs.x = get_size().width - on->get_width(); - ofs.y = int((get_size().height - on->get_height()) / 2); + ofs.x = get_minimum_size().width - (on->get_width() + sb_ofs.width); + ofs.y = sb_ofs.height; if (is_pressed()) on->draw(ci, ofs); diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h index af3b80fe04..eb68943fe7 100644 --- a/scene/gui/check_button.h +++ b/scene/gui/check_button.h @@ -39,6 +39,7 @@ class CheckButton : public Button { GDCLASS(CheckButton, Button); protected: + virtual Size2 get_minimum_size() const; void _notification(int p_what); public: diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 54a58159ac..e73ada9f31 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2416,24 +2416,14 @@ float Control::get_rotation() const { return data.rotation; } -void Control::set_rotation_deg(float p_degrees) { +void Control::set_rotation_degrees(float p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } -float Control::get_rotation_deg() const { +float Control::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } -// Kept for compatibility after rename to {s,g}et_rotation_deg. -// Could be removed after a couple releases. -void Control::_set_rotation_deg(float p_degrees) { - WARN_PRINT("Deprecated method Control._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotation_deg(p_degrees); -} -float Control::_get_rotation_deg() const { - WARN_PRINT("Deprecated method Control._get_rotation_deg(): This method was renamed to get_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotation_deg(); -} //needed to update the control if the font changes.. void Control::_ref_font(Ref<Font> p_sc) { @@ -2606,9 +2596,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_custom_minimum_size", "size"), &Control::set_custom_minimum_size); ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Control::set_global_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Control::set_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_deg", "degrees"), &Control::set_rotation_deg); - // TODO: Obsolete this method (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_set_rotation_deg", "degrees"), &Control::_set_rotation_deg); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Control::set_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Control::set_scale); ClassDB::bind_method(D_METHOD("set_pivot_offset", "pivot_offset"), &Control::set_pivot_offset); ClassDB::bind_method(D_METHOD("get_margin", "margin"), &Control::get_margin); @@ -2617,9 +2605,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("get_position"), &Control::get_position); ClassDB::bind_method(D_METHOD("get_size"), &Control::get_size); ClassDB::bind_method(D_METHOD("get_rotation"), &Control::get_rotation); - ClassDB::bind_method(D_METHOD("get_rotation_deg"), &Control::get_rotation_deg); - // TODO: Obsolete this method (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_get_rotation_deg"), &Control::_get_rotation_deg); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Control::get_rotation_degrees); ClassDB::bind_method(D_METHOD("get_scale"), &Control::get_scale); ClassDB::bind_method(D_METHOD("get_pivot_offset"), &Control::get_pivot_offset); ClassDB::bind_method(D_METHOD("get_custom_minimum_size"), &Control::get_custom_minimum_size); @@ -2738,7 +2724,7 @@ void Control::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_position", "get_position"); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_size", "get_size"); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_min_size"), "set_custom_minimum_size", "get_custom_minimum_size"); - ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rect_rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.01"), "set_rotation_deg", "get_rotation_deg"); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rect_rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.01"), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "rect_scale"), "set_scale", "get_scale"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "rect_pivot_offset"), "set_pivot_offset", "get_pivot_offset"); ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "rect_clip_content"), "set_clip_contents", "is_clipping_contents"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 5b146b4454..4d0e3934ad 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -226,10 +226,6 @@ private: void _size_changed(); String _get_tooltip() const; - // Deprecated, should be removed in a future version. - void _set_rotation_deg(float p_degrees); - float _get_rotation_deg() const; - void _ref_font(Ref<Font> p_sc); void _unref_font(Ref<Font> p_sc); void _font_changed(); @@ -332,9 +328,9 @@ public: Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the visual server void set_rotation(float p_radians); - void set_rotation_deg(float p_degrees); + void set_rotation_degrees(float p_degrees); float get_rotation() const; - float get_rotation_deg() const; + float get_rotation_degrees() const; void set_h_grow_direction(GrowDirection p_direction); GrowDirection get_h_grow_direction() const; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 40e2dba6c2..5d3e5ec0e8 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -48,7 +48,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { if (b.is_valid()) { - if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT) { + if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && context_menu_enabled) { menu->set_position(get_global_transform().xform(get_local_mouse_position())); menu->set_size(Vector2(1, 1)); menu->popup(); @@ -1286,6 +1286,14 @@ void LineEdit::menu_option(int p_option) { } } +void LineEdit::set_context_menu_enabled(bool p_enable) { + context_menu_enabled = p_enable; +} + +bool LineEdit::is_context_menu_enabled() { + return context_menu_enabled; +} + PopupMenu *LineEdit::get_menu() const { return menu; } @@ -1395,6 +1403,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("select", "from", "to"), &LineEdit::select, DEFVAL(0), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("menu_option", "option"), &LineEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &LineEdit::get_menu); + ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled); + ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_enabled); ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "text"))); ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "text"))); @@ -1426,6 +1436,7 @@ void LineEdit::_bind_methods() { ADD_GROUP("Caret", "caret_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), "cursor_set_blink_enabled", "cursor_get_blink_enabled"); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed", PROPERTY_HINT_RANGE, "0.1,10,0.1"), "cursor_set_blink_speed", "cursor_get_blink_speed"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled"); } LineEdit::LineEdit() { @@ -1455,6 +1466,7 @@ LineEdit::LineEdit() { caret_blink_timer->connect("timeout", this, "_toggle_draw_caret"); cursor_set_blink_enabled(false); + context_menu_enabled = true; menu = memnew(PopupMenu); add_child(menu); menu->add_item(TTR("Cut"), MENU_CUT, KEY_MASK_CMD | KEY_X); diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index bece29a37d..c3a299c2f5 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -74,6 +74,7 @@ private: String ime_text; Point2 ime_selection; + bool context_menu_enabled; PopupMenu *menu; int cursor_pos; @@ -150,6 +151,8 @@ public: virtual void drop_data(const Point2 &p_point, const Variant &p_data); void menu_option(int p_option); + void set_context_menu_enabled(bool p_enable); + bool is_context_menu_enabled(); PopupMenu *get_menu() const; void select_all(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 7d200a799b..02b203b5e3 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3668,6 +3668,11 @@ void TextEdit::set_readonly(bool p_readonly) { readonly = p_readonly; } +bool TextEdit::is_readonly() const { + + return readonly; +} + void TextEdit::set_wrap(bool p_wrap) { wrap = p_wrap; @@ -4866,6 +4871,10 @@ void TextEdit::set_context_menu_enabled(bool p_enable) { context_menu_enabled = p_enable; } +bool TextEdit::is_context_menu_enabled() { + return context_menu_enabled; +} + PopupMenu *TextEdit::get_menu() const { return menu; } @@ -4910,8 +4919,12 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode); ClassDB::bind_method(D_METHOD("set_readonly", "enable"), &TextEdit::set_readonly); + ClassDB::bind_method(D_METHOD("is_readonly"), &TextEdit::is_readonly); + ClassDB::bind_method(D_METHOD("set_wrap", "enable"), &TextEdit::set_wrap); ClassDB::bind_method(D_METHOD("set_max_chars", "amount"), &TextEdit::set_max_chars); + ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &TextEdit::set_context_menu_enabled); + ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &TextEdit::is_context_menu_enabled); ClassDB::bind_method(D_METHOD("cut"), &TextEdit::cut); ClassDB::bind_method(D_METHOD("copy"), &TextEdit::copy); @@ -4958,11 +4971,14 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("menu_option", "option"), &TextEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &TextEdit::get_menu); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT), "set_text", "get_text"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "readonly"), "set_readonly", "is_readonly"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_current_line"), "set_highlight_current_line", "is_highlight_current_line_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "override_selected_font_color"), "set_override_selected_font_color", "is_overriding_selected_font_color"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_scroll_speed"), "set_v_scroll_speed", "get_v_scroll_speed"); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 81310b7c10..b90571e0ab 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -448,6 +448,7 @@ public: bool cursor_is_block_mode() const; void set_readonly(bool p_readonly); + bool is_readonly() const; void set_max_chars(int p_max_chars); void set_wrap(bool p_wrap); @@ -547,6 +548,8 @@ public: bool is_selecting_identifiers_on_hover_enabled() const; void set_context_menu_enabled(bool p_enable); + bool is_context_menu_enabled(); + PopupMenu *get_menu() const; String get_text_for_completion(); diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index ce8714e574..5a3814ef35 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -105,30 +105,16 @@ real_t CanvasLayer::get_rotation() const { return rot; } -void CanvasLayer::set_rotationd(real_t p_degrees) { +void CanvasLayer::set_rotation_degrees(real_t p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } -real_t CanvasLayer::get_rotationd() const { +real_t CanvasLayer::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } -// Kept for compatibility after rename to {s,g}et_rotationd. -// Could be removed after a couple releases. -void CanvasLayer::_set_rotationd(real_t p_degrees) { - - WARN_PRINT("Deprecated method CanvasLayer._set_rotationd(): This method was renamed to set_rotationd. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotationd(p_degrees); -} - -real_t CanvasLayer::_get_rotationd() const { - - WARN_PRINT("Deprecated method CanvasLayer._get_rotationd(): This method was renamed to get_rotationd. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotationd(); -} - void CanvasLayer::set_scale(const Vector2 &p_scale) { if (locrotscale_dirty) @@ -252,12 +238,8 @@ void CanvasLayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &CanvasLayer::set_rotation); ClassDB::bind_method(D_METHOD("get_rotation"), &CanvasLayer::get_rotation); - ClassDB::bind_method(D_METHOD("set_rotationd", "degrees"), &CanvasLayer::set_rotationd); - ClassDB::bind_method(D_METHOD("get_rotationd"), &CanvasLayer::get_rotationd); - - // TODO: Obsolete those two methods (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_set_rotationd", "degrees"), &CanvasLayer::_set_rotationd); - ClassDB::bind_method(D_METHOD("_get_rotationd"), &CanvasLayer::_get_rotationd); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &CanvasLayer::set_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &CanvasLayer::get_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &CanvasLayer::set_scale); ClassDB::bind_method(D_METHOD("get_scale"), &CanvasLayer::get_scale); @@ -271,7 +253,7 @@ void CanvasLayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "layer", PROPERTY_HINT_RANGE, "-128,128,1"), "set_layer", "get_layer"); //ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_RANGE),"set_transform","get_transform") ; ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation"), "set_rotationd", "get_rotationd"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation"), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); } diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h index fbee87f487..db2c8e1273 100644 --- a/scene/main/canvas_layer.h +++ b/scene/main/canvas_layer.h @@ -54,10 +54,6 @@ class CanvasLayer : public Node { int sort_index; - // Deprecated, should be removed in a future version. - void _set_rotationd(real_t p_degrees); - real_t _get_rotationd() const; - void _update_xform(); void _update_locrotscale(); @@ -78,8 +74,8 @@ public: void set_rotation(real_t p_radians); real_t get_rotation() const; - void set_rotationd(real_t p_degrees); - real_t get_rotationd() const; + void set_rotation_degrees(real_t p_degrees); + real_t get_rotation_degrees() const; void set_scale(const Size2 &p_scale); Size2 get_scale() const; diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index eaa16069cf..c99bc3c9ef 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -83,10 +83,10 @@ #include "scene/gui/link_button.h" #include "scene/gui/margin_container.h" #include "scene/gui/menu_button.h" +#include "scene/gui/nine_patch_rect.h" #include "scene/gui/option_button.h" #include "scene/gui/panel.h" #include "scene/gui/panel_container.h" -#include "scene/gui/nine_patch_rect.h" #include "scene/gui/popup_menu.h" #include "scene/gui/progress_bar.h" #include "scene/gui/reference_rect.h" diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index fdc3b79db6..f81f460521 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -31,17 +31,23 @@ void AudioStreamPlaybackSample::start(float p_from_pos) { - for (int i = 0; i < 2; i++) { - ima_adpcm[i].step_index = 0; - ima_adpcm[i].predictor = 0; - ima_adpcm[i].loop_step_index = 0; - ima_adpcm[i].loop_predictor = 0; - ima_adpcm[i].last_nibble = -1; - ima_adpcm[i].loop_pos = 0x7FFFFFFF; - ima_adpcm[i].window_ofs = 0; + if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM) { + //no seeking in IMA_ADPCM + for (int i = 0; i < 2; i++) { + ima_adpcm[i].step_index = 0; + ima_adpcm[i].predictor = 0; + ima_adpcm[i].loop_step_index = 0; + ima_adpcm[i].loop_predictor = 0; + ima_adpcm[i].last_nibble = -1; + ima_adpcm[i].loop_pos = 0x7FFFFFFF; + ima_adpcm[i].window_ofs = 0; + } + + offset = 0; + } else { + seek(p_from_pos); } - seek(p_from_pos); sign = 1; active = true; } @@ -373,6 +379,14 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in dst_buff += target; } + + if (todo) { + //bit was missing from mix + int todo_ofs = p_frames - todo; + for (int i = todo_ofs; i < p_frames; i++) { + p_buffer[i] = AudioFrame(0, 0); + } + } } float AudioStreamPlaybackSample::get_length() const { diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp index 56a09bc3bf..912150b939 100644 --- a/scene/resources/capsule_shape_2d.cpp +++ b/scene/resources/capsule_shape_2d.cpp @@ -98,7 +98,7 @@ void CapsuleShape2D::_bind_methods() { } CapsuleShape2D::CapsuleShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CAPSULE)) { + : Shape2D(Physics2DServer::get_singleton()->capsule_shape_create()) { radius = 10; height = 20; diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp index ecfc98ea60..287bde4bfb 100644 --- a/scene/resources/circle_shape_2d.cpp +++ b/scene/resources/circle_shape_2d.cpp @@ -77,7 +77,7 @@ void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) { } CircleShape2D::CircleShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CIRCLE)) { + : Shape2D(Physics2DServer::get_singleton()->circle_shape_create()) { radius = 10; _update_shape(); diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp index 7f4abf7ae0..bb91e33ec2 100644 --- a/scene/resources/concave_polygon_shape_2d.cpp +++ b/scene/resources/concave_polygon_shape_2d.cpp @@ -85,5 +85,5 @@ void ConcavePolygonShape2D::_bind_methods() { } ConcavePolygonShape2D::ConcavePolygonShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON)) { + : Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) { } diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index 7588909d90..a76b6a7cf4 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -87,7 +87,7 @@ Rect2 ConvexPolygonShape2D::get_rect() const { } ConvexPolygonShape2D::ConvexPolygonShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON)) { + : Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) { int pcount = 3; for (int i = 0; i < pcount; i++) diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 1ee76a4216..48c6add586 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -571,7 +571,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { wr[ofs + 0] = 255; //grayscale as 1 wr[ofs + 1] = slot->bitmap.buffer[i * slot->bitmap.pitch + j]; break; - // TODO: FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_BGRA + // TODO: FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_BGRA default: ERR_EXPLAIN("Font uses unsupported pixel format: " + itos(slot->bitmap.pixel_mode)); ERR_FAIL(); diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp index 91263fb125..4aa47cb664 100644 --- a/scene/resources/dynamic_font_stb.cpp +++ b/scene/resources/dynamic_font_stb.cpp @@ -333,8 +333,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { //blit to image and texture { - - Image img(tex.texture_size, tex.texture_size, 0, Image::FORMAT_LA8, tex.imgdata); + Ref<Image> img = memnew(Image(tex.texture_size, tex.texture_size, 0, Image::FORMAT_LA8, tex.imgdata)); if (tex.texture.is_null()) { tex.texture.instance(); @@ -518,7 +517,7 @@ bool ResourceFormatLoaderDynamicFont::handles_type(const String &p_type) const { String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path) const { - String el = p_path.extension().to_lower(); + String el = p_path.get_extension().to_lower(); if (el == "ttf") return "DynamicFontData"; return ""; diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 232f690074..fe59450f2e 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -1184,7 +1184,8 @@ Environment::Environment() { bg_energy = 1.0; bg_canvas_max_layer = 0; ambient_energy = 1.0; - ambient_sky_contribution = 1.0; + //ambient_sky_contribution = 1.0; + set_ambient_light_sky_contribution(1.0); tone_mapper = TONE_MAPPER_LINEAR; tonemap_exposure = 1.0; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index db5d87d703..26f5deae1d 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -574,7 +574,6 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { ERR_FAIL_COND_V(!d.has("format"), false); uint32_t format = d["format"]; - ERR_FAIL_COND_V(!d.has("primitive"), false); uint32_t primitive = d["primitive"]; ERR_FAIL_COND_V(!d.has("vertex_count"), false); @@ -598,8 +597,8 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { Rect3 aabb = d["aabb"]; Vector<Rect3> bone_aabb; - if (d.has("bone_aabb")) { - Array baabb = d["bone_aabb"]; + if (d.has("skeleton_aabb")) { + Array baabb = d["skeleton_aabb"]; bone_aabb.resize(baabb.size()); for (int i = 0; i < baabb.size(); i++) { @@ -1090,6 +1089,14 @@ void ArrayMesh::_bind_methods() { BIND_ENUM_CONSTANT(ARRAY_FORMAT_INDEX); } +void ArrayMesh::reload_from_file() { + for (int i = 0; i < get_surface_count(); i++) { + surface_remove(i); + } + Resource::reload_from_file(); + String path = get_path(); +} + ArrayMesh::ArrayMesh() { mesh = VisualServer::get_singleton()->mesh_create(); diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index f4edb258b6..b11adf50b9 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -213,6 +213,8 @@ public: void center_geometry(); void regen_normalmaps(); + virtual void reload_from_file(); + ArrayMesh(); ~ArrayMesh(); diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp index 507dbce861..69dbb76744 100644 --- a/scene/resources/rectangle_shape_2d.cpp +++ b/scene/resources/rectangle_shape_2d.cpp @@ -67,7 +67,7 @@ void RectangleShape2D::_bind_methods() { } RectangleShape2D::RectangleShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RECTANGLE)) { + : Shape2D(Physics2DServer::get_singleton()->rectangle_shape_create()) { extents = Vector2(10, 10); _update_shape(); diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp index 1171db5c02..7c7ec0d112 100644 --- a/scene/resources/segment_shape_2d.cpp +++ b/scene/resources/segment_shape_2d.cpp @@ -87,7 +87,7 @@ void SegmentShape2D::_bind_methods() { } SegmentShape2D::SegmentShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_SEGMENT)) { + : Shape2D(Physics2DServer::get_singleton()->segment_shape_create()) { a = Vector2(); b = Vector2(0, 10); @@ -146,7 +146,7 @@ real_t RayShape2D::get_length() const { } RayShape2D::RayShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RAY)) { + : Shape2D(Physics2DServer::get_singleton()->ray_shape_create()) { length = 20; _update_shape(); diff --git a/scene/resources/shape_line_2d.cpp b/scene/resources/shape_line_2d.cpp index 4dcc5ac981..d046ce876c 100644 --- a/scene/resources/shape_line_2d.cpp +++ b/scene/resources/shape_line_2d.cpp @@ -96,7 +96,7 @@ void LineShape2D::_bind_methods() { } LineShape2D::LineShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_LINE)) { + : Shape2D(Physics2DServer::get_singleton()->line_shape_create()) { normal = Vector2(0, -1); d = 0; diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index d9770ec3f3..52b8e35d5e 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -143,7 +143,7 @@ SceneStringNames::SceneStringNames() { v_offset = StaticCString::create("v_offset"); transform_pos = StaticCString::create("position"); - transform_rot = StaticCString::create("rotation_deg"); + transform_rot = StaticCString::create("rotation_degrees"); transform_scale = StaticCString::create("scale"); _update_remote = StaticCString::create("_update_remote"); |