diff options
Diffstat (limited to 'scene')
66 files changed, 424 insertions, 640 deletions
diff --git a/scene/2d/SCsub b/scene/2d/SCsub index bf9125be7f..b01e2fd54d 100644 --- a/scene/2d/SCsub +++ b/scene/2d/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.scene_sources, "*.cpp") - -Export('env') diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index a8e0f0d07f..d29c6b37d5 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -507,10 +507,6 @@ static float rand_from_seed(uint32_t &seed) { return float(seed % uint32_t(65536)) / 65535.0; } -static float rand_from_seed_m1_p1(uint32_t &seed) { - return rand_from_seed(seed) * 2.0 - 1.0; -} - void CPUParticles2D::_particles_process(float p_delta) { p_delta *= speed_scale; diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index 9eec8e6cc3..1b789bab9d 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -388,10 +388,34 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect Polygon *p = E->get(); float cost = p->distance; - cost += p->center.distance_to(end_point); - if (cost < least_cost) { +#ifdef USE_ENTRY_POINT + int es = p->edges.size(); + float shortest_distance = 1e30; + + for (int i = 0; i < es; i++) { + Polygon::Edge &e = p->edges.write[i]; + + if (!e.C) + continue; + + Vector2 edge[2] = { + _get_vertex(p->edges[i].point), + _get_vertex(p->edges[(i + 1) % es].point) + }; + + Vector2 edge_point = Geometry::get_closest_point_to_segment_2d(p->entry, edge); + float dist = p->entry.distance_to(edge_point); + if (dist < shortest_distance) + shortest_distance = dist; + } + + cost += shortest_distance; +#else + cost += p->center.distance_to(end_point); +#endif + if (cost < least_cost) { least_cost_poly = E; least_cost = cost; } diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 71bd51507e..5b8d10ea85 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -257,7 +257,6 @@ void TileMap::update_dirty_quadrants() { VisualServer *vs = VisualServer::get_singleton(); Physics2DServer *ps = Physics2DServer::get_singleton(); Vector2 tofs = get_cell_draw_offset(); - Vector2 tcenter = cell_size / 2; Transform2D nav_rel; if (navigation) nav_rel = get_relative_transform_to_parent(navigation); diff --git a/scene/3d/SCsub b/scene/3d/SCsub index 4008f4f196..35cc7479d8 100644 --- a/scene/3d/SCsub +++ b/scene/3d/SCsub @@ -2,9 +2,7 @@ Import('env') - if env['disable_3d']: - env.scene_sources.append("3d/spatial.cpp") env.scene_sources.append("3d/skeleton.cpp") env.scene_sources.append("3d/particles.cpp") @@ -12,5 +10,3 @@ if env['disable_3d']: env.scene_sources.append("3d/scenario_fx.cpp") else: env.add_source_files(env.scene_sources, "*.cpp") - -Export('env') diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 386f2a4348..b1f90b72e7 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -417,7 +417,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { } } - for (int k = 0; k < cc; k++) { + for (unsigned int k = 0; k < cc; k++) { output.vol[k] *= multiplier; } diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index 712f0ba78b..ec51c31674 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -471,10 +471,6 @@ static float rand_from_seed(uint32_t &seed) { return float(seed % uint32_t(65536)) / 65535.0; } -static float rand_from_seed_m1_p1(uint32_t &seed) { - return rand_from_seed(seed) * 2.0 - 1.0; -} - void CPUParticles::_particles_process(float p_delta) { p_delta *= speed_scale; diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index d674958d33..7e1d60ab8e 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -163,6 +163,11 @@ void Light::_update_visibility() { if (!is_inside_tree()) return; + // FIXME: Since the call to VS::instance_light_set_enabled was disabled below, + // the whole logic became pointless so editor_ok triggers unused variable warnings. + // Commenting out for now but this should be fixed/reimplemented so that editor_only + // works as expected (GH-17989). + /* bool editor_ok = true; #ifdef TOOLS_ENABLED @@ -180,6 +185,7 @@ void Light::_update_visibility() { #endif //VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible_in_tree() && editor_ok); + */ _change_notify("geometry/visible"); } diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp index 8d84d2408c..6e7b372647 100644 --- a/scene/3d/navigation.cpp +++ b/scene/3d/navigation.cpp @@ -30,6 +30,8 @@ #include "navigation.h" +#define USE_ENTRY_POINT + void Navigation::_navmesh_link(int p_id) { ERR_FAIL_COND(!navmesh_map.has(p_id)); @@ -331,7 +333,18 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3 &p_start, const Vector if (begin_poly->edges[i].C) { begin_poly->edges[i].C->prev_edge = begin_poly->edges[i].C_edge; +#ifdef USE_ENTRY_POINT + Vector3 edge[2] = { + _get_vertex(begin_poly->edges[i].point), + _get_vertex(begin_poly->edges[(i + 1) % begin_poly->edges.size()].point) + }; + + Vector3 entry = Geometry::get_closest_point_to_segment(begin_poly->entry, edge); + begin_poly->edges[i].C->distance = begin_poly->entry.distance_to(entry); + begin_poly->edges[i].C->entry = entry; +#else begin_poly->edges[i].C->distance = begin_poly->center.distance_to(begin_poly->edges[i].C->center); +#endif open_list.push_back(begin_poly->edges[i].C); if (begin_poly->edges[i].C == end_poly) { @@ -356,10 +369,33 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3 &p_start, const Vector Polygon *p = E->get(); float cost = p->distance; - cost += p->center.distance_to(end_point); +#ifdef USE_ENTRY_POINT + int es = p->edges.size(); - if (cost < least_cost) { + float shortest_distance = 1e30; + + for (int i = 0; i < es; i++) { + Polygon::Edge &e = p->edges.write[i]; + + if (!e.C) + continue; + Vector3 edge[2] = { + _get_vertex(p->edges[i].point), + _get_vertex(p->edges[(i + 1) % es].point) + }; + + Vector3 edge_point = Geometry::get_closest_point_to_segment(p->entry, edge); + float dist = p->entry.distance_to(edge_point); + if (dist < shortest_distance) + shortest_distance = dist; + } + + cost += shortest_distance; +#else + cost += p->center.distance_to(end_point); +#endif + if (cost < least_cost) { least_cost_poly = E; least_cost = cost; } @@ -527,7 +563,6 @@ Vector3 Navigation::get_closest_point_to_segment(const Vector3 &p_from, const Ve bool use_collision = p_use_collision; Vector3 closest_point; float closest_point_d = 1e20; - NavMesh *closest_navmesh = NULL; for (Map<int, NavMesh>::Element *E = navmesh_map.front(); E; E = E->next()) { @@ -546,12 +581,10 @@ Vector3 Navigation::get_closest_point_to_segment(const Vector3 &p_from, const Ve closest_point = inters; use_collision = true; closest_point_d = p_from.distance_to(inters); - closest_navmesh = p.owner; } else if (closest_point_d > inters.distance_to(p_from)) { closest_point = inters; closest_point_d = p_from.distance_to(inters); - closest_navmesh = p.owner; } } } @@ -569,7 +602,6 @@ Vector3 Navigation::get_closest_point_to_segment(const Vector3 &p_from, const Ve closest_point_d = d; closest_point = b; - closest_navmesh = p.owner; } } } diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h index 5a501039c8..8f200997cd 100644 --- a/scene/3d/navigation.h +++ b/scene/3d/navigation.h @@ -94,6 +94,7 @@ class Navigation : public Spatial { Vector<Edge> edges; Vector3 center; + Vector3 entry; float distance; int prev_edge; diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index d7bd89625f..0fb0869979 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -2287,6 +2287,8 @@ void PhysicalBone::_reload_joint() { } } break; + case JOINT_TYPE_NONE: { + } break; } } @@ -2342,6 +2344,8 @@ void PhysicalBone::set_joint_type(JointType p_joint_type) { case JOINT_TYPE_6DOF: joint_data = memnew(SixDOFJointData); break; + case JOINT_TYPE_NONE: + break; } _reload_joint(); @@ -2505,12 +2509,12 @@ PhysicalBone::PhysicalBone() : gizmo_move_joint(false), #endif joint_data(NULL), + parent_skeleton(NULL), static_body(false), - simulate_physics(false), _internal_static_body(false), + simulate_physics(false), _internal_simulate_physics(false), bone_id(-1), - parent_skeleton(NULL), bone_name(""), bounce(0), mass(1), diff --git a/scene/3d/spring_arm.cpp b/scene/3d/spring_arm.cpp index 818e7f9217..f74784c2f9 100644 --- a/scene/3d/spring_arm.cpp +++ b/scene/3d/spring_arm.cpp @@ -36,8 +36,9 @@ SpringArm::SpringArm() : spring_length(1), - mask(1), current_spring_length(0), + keep_child_basis(false), + mask(1), margin(0.01) {} void SpringArm::_notification(int p_what) { diff --git a/scene/3d/spring_arm.h b/scene/3d/spring_arm.h index 24d912d371..e0c3f2992d 100644 --- a/scene/3d/spring_arm.h +++ b/scene/3d/spring_arm.h @@ -39,8 +39,8 @@ class SpringArm : public Spatial { Ref<Shape> shape; Set<RID> excluded_objects; float spring_length; - bool keep_child_basis; float current_spring_length; + bool keep_child_basis; uint32_t mask; float margin; diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp index 767518dc83..6dc821c3f5 100644 --- a/scene/3d/visual_instance.cpp +++ b/scene/3d/visual_instance.cpp @@ -294,7 +294,7 @@ void GeometryInstance::_bind_methods() { ADD_GROUP("Geometry", ""); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial"), "set_material_override", "get_material_override"); 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_PROPERTY(PropertyInfo(Variant::REAL, "extra_cull_margin", PROPERTY_HINT_RANGE, "0,16384,0"), "set_extra_cull_margin", "get_extra_cull_margin"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "extra_cull_margin", PROPERTY_HINT_RANGE, "0,16384,0.01"), "set_extra_cull_margin", "get_extra_cull_margin"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "use_in_baked_light"), "set_flag", "get_flag", FLAG_USE_BAKED_LIGHT); ADD_GROUP("LOD", "lod_"); diff --git a/scene/SCsub b/scene/SCsub index 5d81e818ba..d8839ce3a8 100644 --- a/scene/SCsub +++ b/scene/SCsub @@ -4,16 +4,19 @@ Import('env') env.scene_sources = [] - # Thirdparty code thirdparty_dir = "#thirdparty/misc/" thirdparty_sources = [ + # C++ sources + "easing_equations.cpp", # C sources "mikktspace.c", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] -env.add_source_files(env.scene_sources, thirdparty_sources) +env_thirdparty = env.Clone() +env_thirdparty.disable_warnings() +env_thirdparty.add_source_files(env.scene_sources, thirdparty_sources) # Godot's own sources env.add_source_files(env.scene_sources, "*.cpp") @@ -32,5 +35,3 @@ SConscript('resources/SCsub') # Build it all as a library lib = env.add_library("scene", env.scene_sources) env.Prepend(LIBS=[lib]) - -Export('env') diff --git a/scene/animation/SCsub b/scene/animation/SCsub index bf9125be7f..b01e2fd54d 100644 --- a/scene/animation/SCsub +++ b/scene/animation/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.scene_sources, "*.cpp") - -Export('env') diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 7d91703cf8..102f05a146 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1451,6 +1451,7 @@ void AnimationPlayer::_set_process(bool p_process, bool p_force) { case ANIMATION_PROCESS_PHYSICS: set_physics_process_internal(p_process && active); break; case ANIMATION_PROCESS_IDLE: set_process_internal(p_process && active); break; + case ANIMATION_PROCESS_MANUAL: break; } processing = p_process; diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 179f5d9698..524784df53 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -877,6 +877,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) { tr.track->object->call(method, args[0], args[1], args[2], args[3], args[4]); } } break; + default: {} } } } diff --git a/scene/animation/skeleton_ik.cpp b/scene/animation/skeleton_ik.cpp index 69975e6195..83f45afac8 100644 --- a/scene/animation/skeleton_ik.cpp +++ b/scene/animation/skeleton_ik.cpp @@ -418,11 +418,11 @@ void SkeletonIK::_notification(int p_what) { SkeletonIK::SkeletonIK() : Node(), interpolation(1), - skeleton(NULL), - target_node_override(NULL), use_magnet(false), min_distance(0.01), max_iterations(10), + skeleton(NULL), + target_node_override(NULL), task(NULL) { set_process_priority(1); diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 82e2bb93e2..3521782417 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -277,7 +277,10 @@ Variant &Tween::_get_initial_val(InterpolateData &p_data) { ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK, p_data.initial_val); } return initial_val; - } break; + } + + case INTER_CALLBACK: + break; } return p_data.delta_val; } @@ -313,7 +316,7 @@ Variant &Tween::_get_delta_val(InterpolateData &p_data) { if (final_val.get_type() == Variant::INT) final_val = final_val.operator real_t(); _calc_delta_val(p_data.initial_val, final_val, p_data.delta_val); return p_data.delta_val; - } break; + } case TARGETING_PROPERTY: case TARGETING_METHOD: { @@ -325,7 +328,10 @@ Variant &Tween::_get_delta_val(InterpolateData &p_data) { //_calc_delta_val(p_data.initial_val, p_data.final_val, p_data.delta_val); _calc_delta_val(initial_val, p_data.final_val, p_data.delta_val); return p_data.delta_val; - } break; + } + + case INTER_CALLBACK: + break; } return p_data.initial_val; } @@ -857,12 +863,8 @@ bool Tween::seek(real_t p_time) { data.finish = false; } - switch (data.type) { - case INTER_PROPERTY: - case INTER_METHOD: - break; - case INTER_CALLBACK: - continue; + if (data.type == INTER_CALLBACK) { + continue; } Variant result = _run_equation(data); diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp deleted file mode 100644 index 52aa7403c0..0000000000 --- a/scene/animation/tween_interpolaters.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/*************************************************************************/ -/* tween_interpolaters.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -/** - * Adapted from Penner Easing equations' C++ port. - * Source: https://github.com/jesusgollonet/ofpennereasing - * License: BSD-3-clause - */ - -#include "tween.h" - -const real_t pi = 3.1415926535898; - -/////////////////////////////////////////////////////////////////////////// -// linear -/////////////////////////////////////////////////////////////////////////// -namespace linear { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c * t / d + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - return c * t / d + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - return c * t / d + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return c * t / d + b; -} -}; // namespace linear -/////////////////////////////////////////////////////////////////////////// -// sine -/////////////////////////////////////////////////////////////////////////// -namespace sine { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return -c * cos(t / d * (pi / 2)) + c + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - return c * sin(t / d * (pi / 2)) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - return -c / 2 * (cos(pi * t / d) - 1) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace sine -/////////////////////////////////////////////////////////////////////////// -// quint -/////////////////////////////////////////////////////////////////////////// -namespace quint { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c * pow(t / d, 5) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - return c * (pow(t / d - 1, 5) + 1) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - t = t / d * 2; - if (t < 1) return c / 2 * pow(t, 5) + b; - return c / 2 * (pow(t - 2, 5) + 2) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace quint -/////////////////////////////////////////////////////////////////////////// -// quart -/////////////////////////////////////////////////////////////////////////// -namespace quart { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c * pow(t / d, 4) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - return -c * (pow(t / d - 1, 4) - 1) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - t = t / d * 2; - if (t < 1) return c / 2 * pow(t, 4) + b; - return -c / 2 * (pow(t - 2, 4) - 2) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace quart -/////////////////////////////////////////////////////////////////////////// -// quad -/////////////////////////////////////////////////////////////////////////// -namespace quad { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c * pow(t / d, 2) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - t = t / d; - return -c * t * (t - 2) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - t = t / d * 2; - if (t < 1) return c / 2 * pow(t, 2) + b; - return -c / 2 * ((t - 1) * (t - 3) - 1) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace quad -/////////////////////////////////////////////////////////////////////////// -// expo -/////////////////////////////////////////////////////////////////////////// -namespace expo { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - return c * pow(2, 10 * (t / d - 1)) + b - c * 0.001; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - if (t == d) return b + c; - return c * 1.001 * (-pow(2, -10 * t / d) + 1) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - if (t == d) return b + c; - t = t / d * 2; - if (t < 1) return c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005; - return c / 2 * 1.0005 * (-pow(2, -10 * (t - 1)) + 2) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace expo -/////////////////////////////////////////////////////////////////////////// -// elastic -/////////////////////////////////////////////////////////////////////////// -namespace elastic { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - if ((t /= d) == 1) return b + c; - float p = d * 0.3f; - float a = c; - float s = p / 4; - float postFix = a * pow(2, 10 * (t -= 1)); // this is a fix, again, with post-increment operators - return -(postFix * sin((t * d - s) * (2 * pi) / p)) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - if ((t /= d) == 1) return b + c; - float p = d * 0.3f; - float a = c; - float s = p / 4; - return (a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b); -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - if ((t /= d / 2) == 2) return b + c; - float p = d * (0.3f * 1.5f); - float a = c; - float s = p / 4; - - if (t < 1) { - float postFix = a * pow(2, 10 * (t -= 1)); // postIncrement is evil - return -0.5f * (postFix * sin((t * d - s) * (2 * pi) / p)) + b; - } - float postFix = a * pow(2, -10 * (t -= 1)); // postIncrement is evil - return postFix * sin((t * d - s) * (2 * pi) / p) * 0.5f + c + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace elastic -/////////////////////////////////////////////////////////////////////////// -// cubic -/////////////////////////////////////////////////////////////////////////// -namespace cubic { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c * (t /= d) * t * t + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - t = t / d - 1; - return c * (t * t * t + 1) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - if ((t /= d / 2) < 1) return c / 2 * t * t * t + b; - return c / 2 * ((t -= 2) * t * t + 2) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace cubic -/////////////////////////////////////////////////////////////////////////// -// circ -/////////////////////////////////////////////////////////////////////////// -namespace circ { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return -c * (sqrt(1 - (t /= d) * t) - 1) + b; // TODO: ehrich: operation with t is undefined -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - return c * sqrt(1 - (t = t / d - 1) * t) + b; // TODO: ehrich: operation with t is undefined -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - if ((t /= d / 2) < 1) return -c / 2 * (sqrt(1 - t * t) - 1) + b; - return c / 2 * (sqrt(1 - t * (t -= 2)) + 1) + b; // TODO: ehrich: operation with t is undefined -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace circ -/////////////////////////////////////////////////////////////////////////// -// bounce -/////////////////////////////////////////////////////////////////////////// -namespace bounce { -static real_t out(real_t t, real_t b, real_t c, real_t d); - -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c - out(d - t, 0, c, d) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - if ((t /= d) < (1 / 2.75f)) { - return c * (7.5625f * t * t) + b; - } else if (t < (2 / 2.75f)) { - float postFix = t -= (1.5f / 2.75f); - return c * (7.5625f * (postFix)*t + .75f) + b; - } else if (t < (2.5 / 2.75)) { - float postFix = t -= (2.25f / 2.75f); - return c * (7.5625f * (postFix)*t + .9375f) + b; - } else { - float postFix = t -= (2.625f / 2.75f); - return c * (7.5625f * (postFix)*t + .984375f) + b; - } -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? in(t * 2, b, c / 2, d) : out((t * 2) - d, b + c / 2, c / 2, d); -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace bounce -/////////////////////////////////////////////////////////////////////////// -// back -/////////////////////////////////////////////////////////////////////////// -namespace back { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - float s = 1.70158f; - float postFix = t /= d; - return c * (postFix)*t * ((s + 1) * t - s) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - float s = 1.70158f; - return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; // TODO: ehrich: operation with t is undefined -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - float s = 1.70158f; - if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525f)) + 1) * t - s)) + b; // TODO: ehrich: operation with s is undefined - float postFix = t -= 2; - return c / 2 * ((postFix)*t * (((s *= (1.525f)) + 1) * t + s) + 2) + b; // TODO: ehrich: operation with s is undefined -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace back - -Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT] = { - { &linear::in, &linear::out, &linear::in_out, &linear::out_in }, - { &sine::in, &sine::out, &sine::in_out, &sine::out_in }, - { &quint::in, &quint::out, &quint::in_out, &quint::out_in }, - { &quart::in, &quart::out, &quart::in_out, &quart::out_in }, - { &quad::in, &quad::out, &quad::in_out, &quad::out_in }, - { &expo::in, &expo::out, &expo::in_out, &expo::out_in }, - { &elastic::in, &elastic::out, &elastic::in_out, &elastic::out_in }, - { &cubic::in, &cubic::out, &cubic::in_out, &cubic::out_in }, - { &circ::in, &circ::out, &circ::in_out, &circ::out_in }, - { &bounce::in, &bounce::out, &bounce::in_out, &bounce::out_in }, - { &back::in, &back::out, &back::in_out, &back::out_in }, -}; - -real_t Tween::_run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) { - - interpolater cb = interpolaters[p_trans_type][p_ease_type]; - ERR_FAIL_COND_V(cb == NULL, b); - return cb(t, b, c, d); -} diff --git a/scene/audio/SCsub b/scene/audio/SCsub index bf9125be7f..b01e2fd54d 100644 --- a/scene/audio/SCsub +++ b/scene/audio/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.scene_sources, "*.cpp") - -Export('env') diff --git a/scene/gui/SCsub b/scene/gui/SCsub index bf9125be7f..b01e2fd54d 100644 --- a/scene/gui/SCsub +++ b/scene/gui/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.scene_sources, "*.cpp") - -Export('env') diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 59590ea67b..895e76d516 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -360,7 +360,9 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const { return DRAW_DISABLED; }; - if (status.press_attempt == false && status.hovering && !status.pressed) { + if (status.press_attempt == false && status.hovering) { + if (status.pressed) + return DRAW_HOVER_PRESSED; return DRAW_HOVER; } else { @@ -536,6 +538,7 @@ void BaseButton::_bind_methods() { BIND_ENUM_CONSTANT(DRAW_PRESSED); BIND_ENUM_CONSTANT(DRAW_HOVER); BIND_ENUM_CONSTANT(DRAW_DISABLED); + BIND_ENUM_CONSTANT(DRAW_HOVER_PRESSED); BIND_ENUM_CONSTANT(ACTION_MODE_BUTTON_PRESS); BIND_ENUM_CONSTANT(ACTION_MODE_BUTTON_RELEASE); diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h index 79638bbcce..176d9fc213 100644 --- a/scene/gui/base_button.h +++ b/scene/gui/base_button.h @@ -85,6 +85,7 @@ public: DRAW_PRESSED, DRAW_HOVER, DRAW_DISABLED, + DRAW_HOVER_PRESSED, }; DrawMode get_draw_mode() const; diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index dd6d66ac62..2d17fb1391 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -88,6 +88,21 @@ void Button::_notification(int p_what) { if (has_color("icon_color_normal")) color_icon = get_color("icon_color_normal"); } break; + case DRAW_HOVER_PRESSED: { + if (has_stylebox("hover_pressed") && has_stylebox_override("hover_pressed")) { + style = get_stylebox("hover_pressed"); + if (!flat) + style->draw(ci, Rect2(Point2(0, 0), size)); + if (has_color("font_color_hover_pressed")) + color = get_color("font_color_hover_pressed"); + else + color = get_color("font_color"); + if (has_color("icon_color_hover_pressed")) + color_icon = get_color("icon_color_hover_pressed"); + + break; + } + } case DRAW_PRESSED: { style = get_stylebox("pressed"); diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 537a16fbc3..03eee9c6d8 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -33,6 +33,11 @@ #include "core/os/input.h" #include "core/os/keyboard.h" #include "core/os/os.h" + +#ifdef TOOLS_ENABLED +#include "editor_settings.h" +#endif + #include "scene/gui/separator.h" #include "scene/main/viewport.h" @@ -52,6 +57,16 @@ void ColorPicker::_notification(int p_what) { bt_add_preset->set_icon(get_icon("add_preset")); _update_color(); + +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + PoolColorArray saved_presets = EditorSettings::get_singleton()->get_project_metadata("color_picker", "presets", PoolColorArray()); + + for (int i = 0; i < saved_presets.size(); i++) { + add_preset(saved_presets[i]); + } + } +#endif } break; case NOTIFICATION_PARENTED: { @@ -186,9 +201,22 @@ void ColorPicker::_update_presets() { preset->draw_texture_rect(get_icon("preset_bg", "ColorPicker"), Rect2(Point2(), preset_size), true); +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + PoolColorArray arr_to_save = PoolColorArray(); + + for (int i = 0; i < presets.size(); i++) { + preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]); + arr_to_save.insert(i, presets[i]); + } + + EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save); + } +#else for (int i = 0; i < presets.size(); i++) { preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]); } +#endif } void ColorPicker::_text_type_toggled() { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 12349e0983..dc18895298 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1993,7 +1993,7 @@ Control *Control::find_prev_valid_focus() const { if (!from) { - ERR_EXPLAIN("Prev focus node is not a control: " + n->get_name()); + ERR_EXPLAIN("Previous focus node is not a control: " + n->get_name()); ERR_FAIL_V(NULL); } } else { diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 5f162a3652..1e9f4df4a3 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -330,6 +330,10 @@ void FileDialog::deselect_items() { case MODE_OPEN_DIR: get_ok()->set_text(RTR("Select Current Folder")); break; + case MODE_OPEN_ANY: + case MODE_SAVE_FILE: + // FIXME: Implement, or refactor to avoid duplication with set_mode + break; } } } @@ -349,7 +353,7 @@ void FileDialog::_tree_selected() { file->set_text(d["name"]); } else if (mode == MODE_OPEN_DIR) { - get_ok()->set_text(RTR("Select this Folder")); + get_ok()->set_text(RTR("Select This Folder")); } get_ok()->set_disabled(_is_open_should_be_disabled()); diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index 8560efdde5..d38a067fef 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -91,6 +91,7 @@ void LinkButton::_notification(int p_what) { do_underline = underline_mode != UNDERLINE_MODE_NEVER; } break; + case DRAW_HOVER_PRESSED: break; // Not used in this class case DRAW_DISABLED: { color = get_color("font_color_disabled"); diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 09d8664240..e862743934 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -30,6 +30,19 @@ #include "range.h" +String Range::get_configuration_warning() const { + String warning = Control::get_configuration_warning(); + + if (shared->exp_ratio && shared->min <= 0) { + if (warning != String()) { + warning += "\n"; + } + warning += TTR("If exp_edit is true min_value must be > 0."); + } + + return warning; +} + void Range::_value_changed_notify() { _value_changed(shared->val); @@ -66,10 +79,11 @@ void Range::Shared::emit_changed(const char *p_what) { } void Range::set_value(double p_val) { + if (shared->step > 0) + p_val = Math::round(p_val / shared->step) * shared->step; - if (_rounded_values) { + if (_rounded_values) p_val = Math::round(p_val); - } if (!shared->allow_greater && p_val > shared->max - shared->page) p_val = shared->max - shared->page; @@ -90,6 +104,8 @@ void Range::set_min(double p_min) { set_value(shared->val); shared->emit_changed("min"); + + update_configuration_warning(); } void Range::set_max(double p_max) { @@ -277,6 +293,8 @@ bool Range::is_using_rounded_values() const { void Range::set_exp_ratio(bool p_enable) { shared->exp_ratio = p_enable; + + update_configuration_warning(); } bool Range::is_ratio_exp() const { diff --git a/scene/gui/range.h b/scene/gui/range.h index 125f559248..58f15c8aa8 100644 --- a/scene/gui/range.h +++ b/scene/gui/range.h @@ -97,6 +97,8 @@ public: void share(Range *p_range); void unshare(); + virtual String get_configuration_warning() const; + Range(); ~Range(); }; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index fa5019a6f7..bb36852cf9 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -320,14 +320,17 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & Color color; Color font_color_shadow; bool underline = false; + bool strikethrough = false; if (p_mode == PROCESS_DRAW) { color = _find_color(text, p_base_color); font_color_shadow = _find_color(text, p_font_color_shadow); - underline = _find_underline(text); - if (_find_meta(text, &meta) && underline_meta) { + if (_find_underline(text) || (_find_meta(text, &meta) && underline_meta)) { underline = true; + } else if (_find_strikethrough(text)) { + + strikethrough = true; } } else if (p_mode == PROCESS_CACHE) { @@ -418,7 +421,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & int cw = 0; - bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - line_descent - line_ascent, line_ascent + line_descent); + bool visible = visible_characters < 0 || (p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - line_descent - line_ascent, line_ascent + line_descent)); if (visible) line_is_blank = false; @@ -469,6 +472,15 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & underline_width *= EDSCALE; #endif VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, underline_width); + } else if (strikethrough) { + Color uc = color; + uc.a *= 0.5; + int uy = y + lh / 2 - line_descent + 2; + float strikethrough_width = 1.0; +#ifdef TOOLS_ENABLED + strikethrough_width *= EDSCALE; +#endif + VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, strikethrough_width); } } @@ -497,7 +509,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & ENSURE_WIDTH(img->image->get_width()); - bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->image->get_height(), img->image->get_height()); + bool visible = visible_characters < 0 || (p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->image->get_height(), img->image->get_height())); if (visible) line_is_blank = false; @@ -835,8 +847,6 @@ void RichTextLabel::_notification(int p_what) { bool use_outline = get_constant("shadow_as_outline"); Point2 shadow_ofs(get_constant("shadow_offset_x"), get_constant("shadow_offset_y")); - float x_ofs = 0; - visible_line_count = 0; while (y < size.height && from_line < main->lines.size()) { @@ -854,7 +864,6 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item if (r_click_item) *r_click_item = NULL; - Size2 size = get_size(); Rect2 text_rect = _get_text_rect(); int ofs = vscroll->get_value(); Color font_color_shadow = get_color("font_color_shadow"); @@ -1227,6 +1236,23 @@ bool RichTextLabel::_find_underline(Item *p_item) { return false; } +bool RichTextLabel::_find_strikethrough(Item *p_item) { + + Item *item = p_item; + + while (item) { + + if (item->type == ITEM_STRIKETHROUGH) { + + return true; + } + + item = item->parent; + } + + return false; +} + bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta) { Item *item = p_item; @@ -1458,6 +1484,7 @@ void RichTextLabel::push_font(const Ref<Font> &p_font) { item->font = p_font; _add_item(item, true); } + void RichTextLabel::push_color(const Color &p_color) { ERR_FAIL_COND(current->type == ITEM_TABLE); @@ -1466,6 +1493,7 @@ void RichTextLabel::push_color(const Color &p_color) { item->color = p_color; _add_item(item, true); } + void RichTextLabel::push_underline() { ERR_FAIL_COND(current->type == ITEM_TABLE); @@ -1474,6 +1502,14 @@ void RichTextLabel::push_underline() { _add_item(item, true); } +void RichTextLabel::push_strikethrough() { + + ERR_FAIL_COND(current->type == ITEM_TABLE); + ItemStrikethrough *item = memnew(ItemStrikethrough); + + _add_item(item, true); +} + void RichTextLabel::push_align(Align p_align) { ERR_FAIL_COND(current->type == ITEM_TABLE); @@ -1683,7 +1719,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { } if (brk_pos == p_bbcode.length()) - break; //nothing else o add + break; //nothing else to add int brk_end = p_bbcode.find("]", brk_pos + 1); @@ -1749,7 +1785,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { int columns = tag.substr(6, tag.length()).to_int(); if (columns < 1) columns = 1; - //use monospace font + push_table(columns); pos = brk_end + 1; tag_stack.push_front("table"); @@ -1763,7 +1799,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { int ratio = tag.substr(5, tag.length()).to_int(); if (ratio < 1) ratio = 1; - //use monospace font + set_table_column_expand(get_current_table_column(), true, ratio); push_cell(); pos = brk_end + 1; @@ -1776,43 +1812,37 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { tag_stack.push_front(tag); } else if (tag == "s") { - //use strikethrough (not supported underline instead) - push_underline(); + //use strikethrough + push_strikethrough(); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "center") { - //use underline push_align(ALIGN_CENTER); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "fill") { - //use underline push_align(ALIGN_FILL); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "right") { - //use underline push_align(ALIGN_RIGHT); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "ul") { - //use underline push_list(LIST_DOTS); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "ol") { - //use underline push_list(LIST_NUMBERS); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "indent") { - //use underline indent_level++; push_indent(indent_level); pos = brk_end + 1; @@ -1820,7 +1850,6 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { } else if (tag == "url") { - //use strikethrough (not supported underline instead) int end = p_bbcode.find("[", brk_end); if (end == -1) end = p_bbcode.length(); @@ -1838,7 +1867,6 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { tag_stack.push_front("url"); } else if (tag == "img") { - //use strikethrough (not supported underline instead) int end = p_bbcode.find("[", brk_end); if (end == -1) end = p_bbcode.length(); @@ -2145,6 +2173,7 @@ void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("push_list", "type"), &RichTextLabel::push_list); ClassDB::bind_method(D_METHOD("push_meta", "data"), &RichTextLabel::push_meta); ClassDB::bind_method(D_METHOD("push_underline"), &RichTextLabel::push_underline); + ClassDB::bind_method(D_METHOD("push_strikethrough"), &RichTextLabel::push_strikethrough); ClassDB::bind_method(D_METHOD("push_table", "columns"), &RichTextLabel::push_table); ClassDB::bind_method(D_METHOD("set_table_column_expand", "column", "expand", "ratio"), &RichTextLabel::set_table_column_expand); ClassDB::bind_method(D_METHOD("push_cell"), &RichTextLabel::push_cell); @@ -2205,7 +2234,7 @@ void RichTextLabel::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meta_underlined"), "set_meta_underline", "is_meta_underlined"); ADD_PROPERTY(PropertyInfo(Variant::INT, "tab_size", PROPERTY_HINT_RANGE, "0,24,1"), "set_tab_size", "get_tab_size"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "text"), "set_text", "get_text"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT), "set_text", "get_text"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_active"), "set_scroll_active", "is_scroll_active"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_following"), "set_scroll_follow", "is_scroll_following"); @@ -2233,6 +2262,7 @@ void RichTextLabel::_bind_methods() { BIND_ENUM_CONSTANT(ITEM_FONT); BIND_ENUM_CONSTANT(ITEM_COLOR); BIND_ENUM_CONSTANT(ITEM_UNDERLINE); + BIND_ENUM_CONSTANT(ITEM_STRIKETHROUGH); BIND_ENUM_CONSTANT(ITEM_ALIGN); BIND_ENUM_CONSTANT(ITEM_INDENT); BIND_ENUM_CONSTANT(ITEM_LIST); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 06e9b8efe3..c2e5712b9d 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -62,6 +62,7 @@ public: ITEM_FONT, ITEM_COLOR, ITEM_UNDERLINE, + ITEM_STRIKETHROUGH, ITEM_ALIGN, ITEM_INDENT, ITEM_LIST, @@ -164,6 +165,11 @@ private: ItemUnderline() { type = ITEM_UNDERLINE; } }; + struct ItemStrikethrough : public Item { + + ItemStrikethrough() { type = ITEM_STRIKETHROUGH; } + }; + struct ItemMeta : public Item { Variant meta; @@ -277,6 +283,7 @@ private: Align _find_align(Item *p_item); Color _find_color(Item *p_item, const Color &p_default_color); bool _find_underline(Item *p_item); + bool _find_strikethrough(Item *p_item); bool _find_meta(Item *p_item, Variant *r_meta); void _update_scroll(); @@ -307,6 +314,7 @@ public: void push_font(const Ref<Font> &p_font); void push_color(const Color &p_color); void push_underline(); + void push_strikethrough(); void push_align(Align p_align); void push_indent(int p_level); void push_list(ListType p_list); diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index e3fb602065..26da16569a 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -30,6 +30,7 @@ #include "scroll_container.h" #include "core/os/os.h" + bool ScrollContainer::clips_input() const { return true; @@ -170,7 +171,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { Vector2 motion = Vector2(mm->get_relative().x, mm->get_relative().y); drag_accum -= motion; - if (beyond_deadzone || scroll_h && Math::abs(drag_accum.x) > deadzone || scroll_v && Math::abs(drag_accum.y) > deadzone) { + if (beyond_deadzone || (scroll_h && Math::abs(drag_accum.x) > deadzone) || (scroll_v && Math::abs(drag_accum.y) > deadzone)) { if (!beyond_deadzone) { propagate_notification(NOTIFICATION_SCROLL_BEGIN); emit_signal("scroll_started"); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index a9566d9387..c390c60a8c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -650,8 +650,6 @@ void TextEdit::_notification(int p_what) { int visible_rows = get_visible_rows() + 1; - int tab_w = cache.font->get_char_size(' ').width * indent_size; - Color color = cache.font_color; color.a *= readonly_alpha; @@ -3796,7 +3794,7 @@ Vector<String> TextEdit::get_wrap_rows_text(int p_line) const { int tab_offset_px = get_indent_level(p_line) * cache.font->get_char_size(' ').width; while (col < line_text.length()) { - char c = line_text[col]; + CharType c = line_text[col]; int w = text.get_char_width(c, line_text[col + 1], px + word_px); int indent_ofs = (cur_wrap_index != 0 ? tab_offset_px : 0); @@ -4402,7 +4400,7 @@ int TextEdit::_is_line_in_region(int p_line) { // if not find the closest line we have int previous_line = p_line - 1; - for (previous_line; previous_line > -1; previous_line--) { + for (; previous_line > -1; previous_line--) { if (color_region_cache.has(p_line)) { break; } @@ -4547,9 +4545,13 @@ void TextEdit::cut() { void TextEdit::copy() { if (!selection.active) { - String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length()); - OS::get_singleton()->set_clipboard(clipboard); - cut_copy_line = clipboard; + + if (text[cursor.line].length() != 0) { + + String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length()); + OS::get_singleton()->set_clipboard(clipboard); + cut_copy_line = clipboard; + } } else { String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); OS::get_singleton()->set_clipboard(clipboard); @@ -5152,7 +5154,7 @@ bool TextEdit::can_fold(int p_line) const { return false; if (p_line + 1 >= text.size()) return false; - if (text[p_line].size() == 0) + if (text[p_line].strip_edges().size() == 0) return false; if (is_folded(p_line)) return false; @@ -5164,7 +5166,7 @@ bool TextEdit::can_fold(int p_line) const { int start_indent = get_indent_level(p_line); for (int i = p_line + 1; i < text.size(); i++) { - if (text[i].size() == 0) + if (text[i].strip_edges().size() == 0) continue; int next_indent = get_indent_level(i); if (is_line_comment(i)) { @@ -5866,7 +5868,7 @@ String TextEdit::get_word_at_pos(const Vector2 &p_pos) const { if (select_word(s, col, beg, end)) { bool inside_quotes = false; - char selected_quote = '\0'; + CharType selected_quote = '\0'; int qbegin = 0, qend = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == '"' || s[i] == '\'') { diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 6bd3b26280..413f9dbbe6 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -88,6 +88,9 @@ bool TextureButton::has_point(const Point2 &p_point) const { scale.y = min; ofs -= _texture_region.position / min; } break; + default: { + // FIXME: Why a switch if we only handle one enum value? + } } // offset and scale the new point position to adjust it to the bitmask size @@ -147,6 +150,7 @@ void TextureButton::_notification(int p_what) { } else texdraw = hover; } break; + case DRAW_HOVER_PRESSED: break; // Not used in this class case DRAW_DISABLED: { if (disabled.is_null()) { diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp index 8188d1dcf8..d28b4065fb 100644 --- a/scene/gui/texture_progress.cpp +++ b/scene/gui/texture_progress.cpp @@ -229,6 +229,17 @@ void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, F first_section_size = topleft.y; last_section_size = bottomright.y; } break; + case FILL_BILINEAR_LEFT_AND_RIGHT: { + // TODO: Implement + } break; + case FILL_BILINEAR_TOP_AND_BOTTOM: { + // TODO: Implement + } break; + case FILL_CLOCKWISE: + case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: + case FILL_COUNTER_CLOCKWISE: { + // Those modes are circular, not relevant for nine patch + } break; } double width_filled = width_total * p_ratio; @@ -263,6 +274,17 @@ void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, F dst_rect.size.y = width_filled; topleft.y = last_section_size; } break; + case FILL_BILINEAR_LEFT_AND_RIGHT: { + // TODO: Implement + } break; + case FILL_BILINEAR_TOP_AND_BOTTOM: { + // TODO: Implement + } break; + case FILL_CLOCKWISE: + case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: + case FILL_COUNTER_CLOCKWISE: { + // Those modes are circular, not relevant for nine patch + } break; } } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 24b9083964..3a540d187b 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -159,7 +159,7 @@ void TreeItem::set_text(int p_column, String p_text) { ERR_FAIL_INDEX(p_column, cells.size()); cells.write[p_column].text = p_text; - if (cells[p_column].mode == TreeItem::CELL_MODE_RANGE || cells[p_column].mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) { + if (cells[p_column].mode == TreeItem::CELL_MODE_RANGE) { Vector<String> strings = p_text.split(","); cells.write[p_column].min = INT_MAX; @@ -791,7 +791,6 @@ void TreeItem::_bind_methods() { BIND_ENUM_CONSTANT(CELL_MODE_STRING); BIND_ENUM_CONSTANT(CELL_MODE_CHECK); BIND_ENUM_CONSTANT(CELL_MODE_RANGE); - BIND_ENUM_CONSTANT(CELL_MODE_RANGE_EXPRESSION); BIND_ENUM_CONSTANT(CELL_MODE_ICON); BIND_ENUM_CONSTANT(CELL_MODE_CUSTOM); @@ -1245,9 +1244,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 //font->draw( ci, text_pos, p_item->cells[i].text, col,item_rect.size.x-check_w ); } break; - case TreeItem::CELL_MODE_RANGE: - case TreeItem::CELL_MODE_RANGE_EXPRESSION: { - + case TreeItem::CELL_MODE_RANGE: { if (p_item->cells[i].text != "") { if (!p_item->cells[i].editable) @@ -1257,13 +1254,13 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 String s = RTR("(Other)"); Vector<String> strings = p_item->cells[i].text.split(","); - for (int i = 0; i < strings.size(); i++) { - int value = i; - if (!strings[i].get_slicec(':', 1).empty()) { - value = strings[i].get_slicec(':', 1).to_int(); + for (int j = 0; j < strings.size(); j++) { + int value = j; + if (!strings[j].get_slicec(':', 1).empty()) { + value = strings[j].get_slicec(':', 1).to_int(); } if (option == value) { - s = strings[i].get_slicec(':', 0); + s = strings[j].get_slicec(':', 0); break; } } @@ -1419,7 +1416,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 while (c) { - if (cache.draw_relationship_lines == 1 && (c->get_parent() != root || c->get_parent() == root && !hide_root)) { + if (cache.draw_relationship_lines == 1 && (c->get_parent() != root || !hide_root)) { int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin); int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin); Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs; @@ -1821,9 +1818,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool //p_item->edited_signal.call(col); } break; - case TreeItem::CELL_MODE_RANGE: - case TreeItem::CELL_MODE_RANGE_EXPRESSION: { - + case TreeItem::CELL_MODE_RANGE: { if (c.text != "") { //if (x >= (get_column_width(col)-item_h/2)) { @@ -2010,21 +2005,6 @@ void Tree::text_editor_enter(String p_text) { //popup_edited_item->edited_signal.call( popup_edited_item_col ); } break; - case TreeItem::CELL_MODE_RANGE_EXPRESSION: { - - if (evaluator) - c.val = evaluator->eval(p_text); - else - c.val = p_text.to_double(); - - if (c.step > 0) - c.val = Math::stepify(c.val, c.step); - if (c.val < c.min) - c.val = c.min; - else if (c.val > c.max) - c.val = c.max; - - } break; default: { ERR_FAIL(); } } @@ -2453,7 +2433,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { update(); } - if (pressing_for_editor && popup_edited_item && (popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE || popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE_EXPRESSION)) { + if (pressing_for_editor && popup_edited_item && (popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE)) { //range drag if (!range_drag_enabled) { @@ -2697,7 +2677,7 @@ bool Tree::edit_selected() { item_edited(col, s); return true; - } else if ((c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) && c.text != "") { + } else if (c.mode == TreeItem::CELL_MODE_RANGE && c.text != "") { popup_menu->clear(); for (int i = 0; i < c.text.get_slice_count(","); i++) { @@ -2713,7 +2693,7 @@ bool Tree::edit_selected() { popup_edited_item_col = col; return true; - } else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) { + } else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE) { Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2); Point2i textedpos = get_global_position() + rect.position - ofs; @@ -2723,7 +2703,7 @@ bool Tree::edit_selected() { text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::step_decimals(c.step))); text_editor->select_all(); - if (c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) { + if (c.mode == TreeItem::CELL_MODE_RANGE) { value_editor->set_position(textedpos + Point2i(0, text_editor->get_size().height)); value_editor->set_size(Size2(rect.size.width, 1)); @@ -3713,10 +3693,6 @@ bool Tree::is_folding_hidden() const { return hide_folding; } -void Tree::set_value_evaluator(ValueEvaluator *p_evaluator) { - evaluator = p_evaluator; -} - void Tree::set_drop_mode_flags(int p_flags) { if (drop_mode_flags == p_flags) return; @@ -3934,8 +3910,6 @@ Tree::Tree() { hide_folding = false; - evaluator = NULL; - drop_mode_flags = 0; drop_mode_over = NULL; drop_mode_section = 0; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 205cdbfb7e..34138acb85 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -31,7 +31,6 @@ #ifndef TREE_H #define TREE_H -#include "core/helper/value_evaluator.h" #include "scene/gui/control.h" #include "scene/gui/line_edit.h" #include "scene/gui/popup_menu.h" @@ -54,7 +53,6 @@ public: CELL_MODE_STRING, ///< just a string CELL_MODE_CHECK, ///< string + check CELL_MODE_RANGE, ///< Contains a range - CELL_MODE_RANGE_EXPRESSION, ///< Contains a range CELL_MODE_ICON, ///< Contains an icon, not editable CELL_MODE_CUSTOM, ///< Contains a custom value, show a string, and an edit button }; @@ -504,8 +502,6 @@ private: bool hide_folding; - ValueEvaluator *evaluator; - int _count_selected_items(TreeItem *p_from) const; void _go_left(); void _go_right(); @@ -601,8 +597,6 @@ public: void set_allow_reselect(bool p_allow); bool get_allow_reselect() const; - void set_value_evaluator(ValueEvaluator *p_evaluator); - Tree(); ~Tree(); }; diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 17ab234551..39e7c73390 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -102,6 +102,10 @@ void VideoPlayer::_mix_audio() { } } break; + case AudioServer::SPEAKER_SURROUND_31: { + + // FIXME: Implement + } break; case AudioServer::SPEAKER_SURROUND_51: { AudioFrame *targets[2] = { diff --git a/scene/main/SCsub b/scene/main/SCsub index bf9125be7f..b01e2fd54d 100644 --- a/scene/main/SCsub +++ b/scene/main/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.scene_sources, "*.cpp") - -Export('env') diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 06bc12d774..d3282c6ada 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1348,6 +1348,19 @@ Node *Node::get_parent() const { return data.parent; } +Node *Node::find_parent(const String &p_mask) const { + + Node *p = data.parent; + while (p) { + + if (p->data.name.operator String().match(p_mask)) + return p; + p = p->data.parent; + } + + return NULL; +} + bool Node::is_a_parent_of(const Node *p_node) const { ERR_FAIL_NULL_V(p_node, false); @@ -2629,6 +2642,7 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("get_node", "path"), &Node::get_node); ClassDB::bind_method(D_METHOD("get_parent"), &Node::get_parent); ClassDB::bind_method(D_METHOD("find_node", "mask", "recursive", "owned"), &Node::find_node, DEFVAL(true), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("find_parent", "mask"), &Node::find_parent); ClassDB::bind_method(D_METHOD("has_node_and_resource", "path"), &Node::has_node_and_resource); ClassDB::bind_method(D_METHOD("get_node_and_resource", "path"), &Node::_get_node_and_resource); diff --git a/scene/main/node.h b/scene/main/node.h index 8d6c558e93..a7baebc9c2 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -257,6 +257,8 @@ public: Node *get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<StringName> &r_leftover_subpath, bool p_last_is_property = true) const; Node *get_parent() const; + Node *find_parent(const String &p_mask) const; + _FORCE_INLINE_ SceneTree *get_tree() const { ERR_FAIL_COND_V(!data.tree, NULL); return data.tree; diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 16be6dad7d..fdbe3b57f0 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1197,6 +1197,9 @@ void SceneTree::_update_root_rect() { } switch (stretch_mode) { + case STRETCH_MODE_DISABLED: { + // Already handled above + } break; case STRETCH_MODE_2D: { root->set_size((screen_size / stretch_shrink).floor()); @@ -1602,7 +1605,7 @@ void SceneTree::_live_edit_duplicate_node_func(const NodePath &p_at, const Strin continue; Node *n2 = n->get_node(p_at); - Node *dup = n2->duplicate(true); + Node *dup = n2->duplicate(Node::DUPLICATE_SIGNALS | Node::DUPLICATE_GROUPS | Node::DUPLICATE_SCRIPTS); if (!dup) continue; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 487ca2b009..bb379ff4af 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -701,15 +701,6 @@ void Viewport::set_canvas_transform(const Transform2D &p_transform) { canvas_transform = p_transform; VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform); - - Transform2D xform = (global_canvas_transform * canvas_transform).affine_inverse(); - Size2 ss = get_visible_rect().size; - /*SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5))); - Vector2 ss2 = ss*xform.get_scale(); - float panrange = MAX(ss2.x,ss2.y); - - SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange); -*/ } Transform2D Viewport::get_canvas_transform() const { @@ -722,15 +713,6 @@ void Viewport::_update_global_transform() { Transform2D sxform = stretch_transform * global_canvas_transform; VisualServer::get_singleton()->viewport_set_global_canvas_transform(viewport, sxform); - - Transform2D xform = (sxform * canvas_transform).affine_inverse(); - Size2 ss = get_visible_rect().size; - /*SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5))); - Vector2 ss2 = ss*xform.get_scale(); - float panrange = MAX(ss2.x,ss2.y); - - SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange); -*/ } void Viewport::set_global_canvas_transform(const Transform2D &p_transform) { diff --git a/scene/resources/SCsub b/scene/resources/SCsub index 2ad90247a7..5e5b6f8fd5 100644 --- a/scene/resources/SCsub +++ b/scene/resources/SCsub @@ -4,6 +4,4 @@ Import('env') env.add_source_files(env.scene_sources, "*.cpp") -Export('env') - SConscript("default_theme/SCsub") diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index 57d0deeb78..9ee85b64b6 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -562,13 +562,13 @@ void AudioStreamSample::save_to_wav(String p_path) { PoolVector<uint8_t>::Read read_data = get_data().read(); switch (format) { case AudioStreamSample::FORMAT_8_BITS: - for (int i = 0; i < data_bytes; i++) { + for (unsigned int i = 0; i < data_bytes; i++) { uint8_t data_point = (read_data[i] + 128); file->store_8(data_point); } break; case AudioStreamSample::FORMAT_16_BITS: - for (int i = 0; i < data_bytes / 2; i++) { + for (unsigned int i = 0; i < data_bytes / 2; i++) { uint16_t data_point = decode_uint16(&read_data[i * 2]); file->store_16(data_point); } diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp index d670161afd..56b236d03b 100644 --- a/scene/resources/bit_mask.cpp +++ b/scene/resources/bit_mask.cpp @@ -183,7 +183,6 @@ Vector<Vector2> BitMap::_march_square(const Rect2i &rect, const Point2i &start) unsigned int count = 0; Set<Point2i> case9s; Set<Point2i> case6s; - int i; Vector<Vector2> _points; do { int sv = 0; diff --git a/scene/resources/default_theme/SCsub b/scene/resources/default_theme/SCsub index bf9125be7f..b01e2fd54d 100644 --- a/scene/resources/default_theme/SCsub +++ b/scene/resources/default_theme/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.scene_sources, "*.cpp") - -Export('env') diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 20fa1d6e2b..4de47b2cb0 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -120,41 +120,7 @@ static Ref<Texture> make_icon(T p_src) { return texture; } -static Ref<Shader> make_shader(const char *vertex_code, const char *fragment_code, const char *lighting_code) { - Ref<Shader> shader = (memnew(Shader())); - //shader->set_code(vertex_code, fragment_code, lighting_code); - - return shader; -} - -static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p_charcount, const int *p_chars, const Ref<Texture> &p_texture) { - - Ref<BitmapFont> font(memnew(BitmapFont)); - font->add_texture(p_texture); - - for (int i = 0; i < p_charcount; i++) { - - const int *c = &p_chars[i * 8]; - - int chr = c[0]; - Rect2 frect; - frect.position.x = c[1]; - frect.position.y = c[2]; - frect.size.x = c[3]; - frect.size.y = c[4]; - Point2 align(c[5], c[6] + p_valign); - int advance = c[7]; - - font->add_char(chr, 0, frect, align, advance); - } - - font->set_height(p_height); - font->set_ascent(p_ascent); - - return font; -} - -static Ref<BitmapFont> make_font2(int p_height, int p_ascent, int p_charcount, const int *p_char_rects, int p_kerning_count, const int *p_kernings, int p_w, int p_h, const unsigned char *p_img) { +static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_charcount, const int *p_char_rects, int p_kerning_count, const int *p_kernings, int p_w, int p_h, const unsigned char *p_img) { Ref<BitmapFont> font(memnew(BitmapFont)); @@ -209,8 +175,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const tex_cache = memnew(TexCacheMap); - //Ref<BitmapFont> default_font = make_font(_bi_font_normal_height,_bi_font_normal_ascent,_bi_font_normal_valign,_bi_font_normal_charcount,_bi_font_normal_characters,make_icon(font_normal_png)); - // Font Colors Color control_font_color = Color::html("e0e0e0"); @@ -364,6 +328,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_stylebox("pressed", "CheckBox", cbx_empty); theme->set_stylebox("disabled", "CheckBox", cbx_empty); theme->set_stylebox("hover", "CheckBox", cbx_empty); + theme->set_stylebox("hover_pressed", "CheckBox", cbx_empty); theme->set_stylebox("focus", "CheckBox", cbx_focus); theme->set_icon("checked", "CheckBox", make_icon(checked_png)); @@ -376,6 +341,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_color("font_color", "CheckBox", control_font_color); theme->set_color("font_color_pressed", "CheckBox", control_font_color_pressed); theme->set_color("font_color_hover", "CheckBox", control_font_color_hover); + theme->set_color("font_color_hover_pressed", "CheckBox", control_font_color_pressed); theme->set_color("font_color_disabled", "CheckBox", control_font_color_disabled); theme->set_constant("hseparation", "CheckBox", 4 * scale); @@ -393,6 +359,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_stylebox("pressed", "CheckButton", cb_empty); theme->set_stylebox("disabled", "CheckButton", cb_empty); theme->set_stylebox("hover", "CheckButton", cb_empty); + theme->set_stylebox("hover_pressed", "CheckButton", cb_empty); theme->set_stylebox("focus", "CheckButton", focus); theme->set_icon("on", "CheckButton", make_icon(toggle_on_png)); @@ -403,6 +370,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_color("font_color", "CheckButton", control_font_color); theme->set_color("font_color_pressed", "CheckButton", control_font_color_pressed); theme->set_color("font_color_hover", "CheckButton", control_font_color_hover); + theme->set_color("font_color_hover_pressed", "CheckButton", control_font_color_pressed); theme->set_color("font_color_disabled", "CheckButton", control_font_color_disabled); theme->set_constant("hseparation", "CheckButton", 4 * scale); @@ -909,9 +877,9 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) { if (p_font.is_valid()) { default_font = p_font; } else if (p_hidpi) { - default_font = make_font2(_hidpi_font_height, _hidpi_font_ascent, _hidpi_font_charcount, &_hidpi_font_charrects[0][0], _hidpi_font_kerning_pair_count, &_hidpi_font_kerning_pairs[0][0], _hidpi_font_img_width, _hidpi_font_img_height, _hidpi_font_img_data); + default_font = make_font(_hidpi_font_height, _hidpi_font_ascent, _hidpi_font_charcount, &_hidpi_font_charrects[0][0], _hidpi_font_kerning_pair_count, &_hidpi_font_kerning_pairs[0][0], _hidpi_font_img_width, _hidpi_font_img_height, _hidpi_font_img_data); } else { - default_font = make_font2(_lodpi_font_height, _lodpi_font_ascent, _lodpi_font_charcount, &_lodpi_font_charrects[0][0], _lodpi_font_kerning_pair_count, &_lodpi_font_kerning_pairs[0][0], _lodpi_font_img_width, _lodpi_font_img_height, _lodpi_font_img_data); + default_font = make_font(_lodpi_font_height, _lodpi_font_ascent, _lodpi_font_charcount, &_lodpi_font_charrects[0][0], _lodpi_font_kerning_pair_count, &_lodpi_font_kerning_pairs[0][0], _lodpi_font_img_width, _lodpi_font_img_height, _lodpi_font_img_data); } Ref<Font> large_font = default_font; fill_default_theme(t, default_font, large_font, default_icon, default_style, p_hidpi ? 2.0 : 1.0); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 50bf8f38f7..b78b3a6ffb 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -178,6 +178,7 @@ PoolVector<int> BitmapFont::_get_kernings() const { void BitmapFont::_set_textures(const Vector<Variant> &p_textures) { + textures.clear(); for (int i = 0; i < p_textures.size(); i++) { Ref<Texture> tex = p_textures[i]; ERR_CONTINUE(!tex.is_valid()); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 2cf802a2da..274c74a9a2 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -427,10 +427,8 @@ void SpatialMaterial::_update_shader() { if (flags[FLAG_USE_VERTEX_LIGHTING]) { code += ",vertex_lighting"; } - bool using_world = false; if (flags[FLAG_TRIPLANAR_USE_WORLD] && (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR])) { code += ",world_vertex_coords"; - using_world = true; } if (flags[FLAG_DONT_RECEIVE_SHADOWS]) { code += ",shadows_disabled"; @@ -562,7 +560,9 @@ void SpatialMaterial::_update_shader() { if (flags[FLAG_SRGB_VERTEX_COLOR]) { - code += "\tCOLOR.rgb = mix( pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb* (1.0 / 12.92), lessThan(COLOR.rgb,vec3(0.04045)) );\n"; + code += "\tif (!OUTPUT_IS_SRGB) {\n"; + code += "\t\tCOLOR.rgb = mix( pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb* (1.0 / 12.92), lessThan(COLOR.rgb,vec3(0.04045)) );\n"; + code += "\t}\n"; } if (flags[FLAG_USE_POINT_SIZE]) { @@ -610,11 +610,11 @@ void SpatialMaterial::_update_shader() { code += "\tMODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat_world;\n"; //handle animation - code += "\tint particle_total_frames = particles_anim_h_frames * particles_anim_v_frames;\n"; - code += "\tint particle_frame = int(INSTANCE_CUSTOM.z * float(particle_total_frames));\n"; - code += "\tif (particles_anim_loop) particle_frame=clamp(particle_frame,0,particle_total_frames-1); else particle_frame=abs(particle_frame)%particle_total_frames;\n"; + code += "\tfloat particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);\n"; + code += "\tfloat particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));\n"; + code += "\tif (particles_anim_loop) particle_frame=clamp(particle_frame,0.0,particle_total_frames-1.0); else particle_frame=mod(particle_frame,float(particle_total_frames));\n"; code += "\tUV /= vec2(float(particles_anim_h_frames),float(particles_anim_v_frames));\n"; - code += "\tUV += vec2(float(particle_frame % particles_anim_h_frames) / float(particles_anim_h_frames),float(particle_frame / particles_anim_h_frames) / float(particles_anim_v_frames));\n"; + code += "\tUV += vec2(mod(particle_frame,float(particles_anim_h_frames)) / float(particles_anim_h_frames),particle_frame / float(particles_anim_h_frames) / float(particles_anim_v_frames));\n"; } break; } @@ -817,7 +817,7 @@ void SpatialMaterial::_update_shader() { code += "\tALPHA = albedo.a * albedo_tex.a;\n"; } - if (proximity_fade_enabled) { + if (!VisualServer::get_singleton()->is_low_end() && proximity_fade_enabled) { code += "\tfloat depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV,0.0).r;\n"; code += "\tvec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV*2.0-1.0,depth_tex*2.0-1.0,1.0);\n"; code += "\tworld_pos.xyz/=world_pos.w;\n"; @@ -825,43 +825,45 @@ void SpatialMaterial::_update_shader() { } if (distance_fade != DISTANCE_FADE_DISABLED) { - if (distance_fade == DISTANCE_FADE_OBJECT_DITHER || distance_fade == DISTANCE_FADE_PIXEL_DITHER) { - - code += "\t{\n"; - if (distance_fade == DISTANCE_FADE_OBJECT_DITHER) { - code += "\t\tfloat fade_distance = abs((INV_CAMERA_MATRIX * WORLD_MATRIX[3]).z);\n"; - - } else { - code += "\t\tfloat fade_distance=-VERTEX.z;\n"; + if ((distance_fade == DISTANCE_FADE_OBJECT_DITHER || distance_fade == DISTANCE_FADE_PIXEL_DITHER)) { + + if (!VisualServer::get_singleton()->is_low_end()) { + code += "\t{\n"; + if (distance_fade == DISTANCE_FADE_OBJECT_DITHER) { + code += "\t\tfloat fade_distance = abs((INV_CAMERA_MATRIX * WORLD_MATRIX[3]).z);\n"; + + } else { + code += "\t\tfloat fade_distance=-VERTEX.z;\n"; + } + + code += "\t\tfloat fade=clamp(smoothstep(distance_fade_min,distance_fade_max,fade_distance),0.0,1.0);\n"; + code += "\t\tint x = int(FRAGCOORD.x) % 4;\n"; + code += "\t\tint y = int(FRAGCOORD.y) % 4;\n"; + code += "\t\tint index = x + y * 4;\n"; + code += "\t\tfloat limit = 0.0;\n\n"; + code += "\t\tif (x < 8) {\n"; + code += "\t\t\tif (index == 0) limit = 0.0625;\n"; + code += "\t\t\tif (index == 1) limit = 0.5625;\n"; + code += "\t\t\tif (index == 2) limit = 0.1875;\n"; + code += "\t\t\tif (index == 3) limit = 0.6875;\n"; + code += "\t\t\tif (index == 4) limit = 0.8125;\n"; + code += "\t\t\tif (index == 5) limit = 0.3125;\n"; + code += "\t\t\tif (index == 6) limit = 0.9375;\n"; + code += "\t\t\tif (index == 7) limit = 0.4375;\n"; + code += "\t\t\tif (index == 8) limit = 0.25;\n"; + code += "\t\t\tif (index == 9) limit = 0.75;\n"; + code += "\t\t\tif (index == 10) limit = 0.125;\n"; + code += "\t\t\tif (index == 11) limit = 0.625;\n"; + code += "\t\t\tif (index == 12) limit = 1.0;\n"; + code += "\t\t\tif (index == 13) limit = 0.5;\n"; + code += "\t\t\tif (index == 14) limit = 0.875;\n"; + code += "\t\t\tif (index == 15) limit = 0.375;\n"; + code += "\t\t}\n\n"; + code += "\tif (fade < limit)\n"; + code += "\t\tdiscard;\n"; + code += "\t}\n\n"; } - code += "\t\tfloat fade=clamp(smoothstep(distance_fade_min,distance_fade_max,fade_distance),0.0,1.0);\n"; - code += "\t\tint x = int(FRAGCOORD.x) % 4;\n"; - code += "\t\tint y = int(FRAGCOORD.y) % 4;\n"; - code += "\t\tint index = x + y * 4;\n"; - code += "\t\tfloat limit = 0.0;\n\n"; - code += "\t\tif (x < 8) {\n"; - code += "\t\t\tif (index == 0) limit = 0.0625;\n"; - code += "\t\t\tif (index == 1) limit = 0.5625;\n"; - code += "\t\t\tif (index == 2) limit = 0.1875;\n"; - code += "\t\t\tif (index == 3) limit = 0.6875;\n"; - code += "\t\t\tif (index == 4) limit = 0.8125;\n"; - code += "\t\t\tif (index == 5) limit = 0.3125;\n"; - code += "\t\t\tif (index == 6) limit = 0.9375;\n"; - code += "\t\t\tif (index == 7) limit = 0.4375;\n"; - code += "\t\t\tif (index == 8) limit = 0.25;\n"; - code += "\t\t\tif (index == 9) limit = 0.75;\n"; - code += "\t\t\tif (index == 10) limit = 0.125;\n"; - code += "\t\t\tif (index == 11) limit = 0.625;\n"; - code += "\t\t\tif (index == 12) limit = 1.0;\n"; - code += "\t\t\tif (index == 13) limit = 0.5;\n"; - code += "\t\t\tif (index == 14) limit = 0.875;\n"; - code += "\t\t\tif (index == 15) limit = 0.375;\n"; - code += "\t\t}\n\n"; - code += "\tif (fade < limit)\n"; - code += "\t\tdiscard;\n"; - code += "\t}\n\n"; - } else { code += "\tALPHA*=clamp(smoothstep(distance_fade_min,distance_fade_max,-VERTEX.z),0.0,1.0);\n"; } @@ -1369,6 +1371,12 @@ void SpatialMaterial::_validate_feature(const String &text, Feature feature, Pro } } +void SpatialMaterial::_validate_high_end(const String &text, PropertyInfo &property) const { + if (property.name.begins_with(text)) { + property.usage |= PROPERTY_USAGE_HIGH_END_GFX; + } +} + void SpatialMaterial::_validate_property(PropertyInfo &property) const { _validate_feature("normal", FEATURE_NORMAL_MAPPING, property); _validate_feature("emission", FEATURE_EMISSION, property); @@ -1382,6 +1390,12 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { _validate_feature("refraction", FEATURE_REFRACTION, property); _validate_feature("detail", FEATURE_DETAIL, property); + _validate_high_end("refraction", property); + _validate_high_end("subsurf_scatter", property); + _validate_high_end("anisotropy", property); + _validate_high_end("clearcoat", property); + _validate_high_end("depth", property); + if (property.name.begins_with("particles_anim_") && billboard_mode != BILLBOARD_PARTICLES) { property.usage = 0; } diff --git a/scene/resources/material.h b/scene/resources/material.h index 4a2a813341..0154874ae4 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -442,6 +442,8 @@ private: static Ref<SpatialMaterial> materials_for_2d[MAX_MATERIALS_FOR_2D]; //used by Sprite3D and other stuff + void _validate_high_end(const String &text, PropertyInfo &property) const; + protected: static void _bind_methods(); void _validate_property(PropertyInfo &property) const; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 6426689397..6cd701eb9a 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -546,46 +546,6 @@ void Mesh::clear_cache() const { Mesh::Mesh() { } -static const char *_array_name[] = { - "vertex_array", - "normal_array", - "tangent_array", - "color_array", - "tex_uv_array", - "tex_uv2_array", - "bone_array", - "weights_array", - "index_array", - NULL -}; - -static const ArrayMesh::ArrayType _array_types[] = { - - ArrayMesh::ARRAY_VERTEX, - ArrayMesh::ARRAY_NORMAL, - ArrayMesh::ARRAY_TANGENT, - ArrayMesh::ARRAY_COLOR, - ArrayMesh::ARRAY_TEX_UV, - ArrayMesh::ARRAY_TEX_UV2, - ArrayMesh::ARRAY_BONES, - ArrayMesh::ARRAY_WEIGHTS, - ArrayMesh::ARRAY_INDEX -}; - -/* compatibility */ -static const int _format_translate[] = { - - ArrayMesh::ARRAY_FORMAT_VERTEX, - ArrayMesh::ARRAY_FORMAT_NORMAL, - ArrayMesh::ARRAY_FORMAT_TANGENT, - ArrayMesh::ARRAY_FORMAT_COLOR, - ArrayMesh::ARRAY_FORMAT_TEX_UV, - ArrayMesh::ARRAY_FORMAT_TEX_UV2, - ArrayMesh::ARRAY_FORMAT_BONES, - ArrayMesh::ARRAY_FORMAT_WEIGHTS, - ArrayMesh::ARRAY_FORMAT_INDEX, -}; - bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { String sname = p_name; diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp index 6732303925..a5449e1fe8 100644 --- a/scene/resources/mesh_data_tool.cpp +++ b/scene/resources/mesh_data_tool.cpp @@ -79,9 +79,9 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL) col = arrays[Mesh::ARRAY_COLOR].operator PoolVector<Color>().read(); - PoolVector<real_t>::Read bo; + PoolVector<int>::Read bo; if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL) - bo = arrays[Mesh::ARRAY_BONES].operator PoolVector<real_t>().read(); + bo = arrays[Mesh::ARRAY_BONES].operator PoolVector<int>().read(); PoolVector<real_t>::Read we; if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL) @@ -194,7 +194,7 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { PoolVector<Vector2> u; PoolVector<Vector2> u2; PoolVector<Color> c; - PoolVector<real_t> b; + PoolVector<int> b; PoolVector<real_t> w; PoolVector<int> in; @@ -233,7 +233,7 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { col = c.write(); } - PoolVector<real_t>::Write bo; + PoolVector<int>::Write bo; if (format & Mesh::ARRAY_FORMAT_BONES) { b.resize(vcount * 4); bo = b.write(); diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index 364ec9bb19..6f67ba8af1 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -691,6 +691,7 @@ void ParticlesMaterial::set_param(Parameter p_param, float p_value) { case PARAM_ANIM_OFFSET: { VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset, p_value); } break; + case PARAM_MAX: break; // Can't happen, but silences warning } } float ParticlesMaterial::get_param(Parameter p_param) const { @@ -743,6 +744,7 @@ void ParticlesMaterial::set_param_randomness(Parameter p_param, float p_value) { case PARAM_ANIM_OFFSET: { VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_random, p_value); } break; + case PARAM_MAX: break; // Can't happen, but silences warning } } float ParticlesMaterial::get_param_randomness(Parameter p_param) const { @@ -819,6 +821,7 @@ void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture> case PARAM_ANIM_OFFSET: { VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_texture, p_texture); } break; + case PARAM_MAX: break; // Can't happen, but silences warning } _queue_shader_change(); diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 1bfc41bd92..66bf3b4991 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -126,6 +126,11 @@ void Shader::get_default_texture_param_list(List<StringName> *r_textures) const r_textures->push_back(E->key()); } } + +bool Shader::is_text_shader() const { + return true; +} + bool Shader::has_param(const StringName &p_param) const { return params_cache.has(p_param); @@ -235,8 +240,10 @@ Error ResourceFormatSaverShader::save(const String &p_path, const RES &p_resourc void ResourceFormatSaverShader::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { - if (Object::cast_to<Shader>(*p_resource)) { - p_extensions->push_back("shader"); + if (const Shader *shader = Object::cast_to<Shader>(*p_resource)) { + if (shader->is_text_shader()) { + p_extensions->push_back("shader"); + } } } bool ResourceFormatSaverShader::recognize(const RES &p_resource) const { diff --git a/scene/resources/shader.h b/scene/resources/shader.h index 6c91205c0c..c2c205237f 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -79,6 +79,8 @@ public: Ref<Texture> get_default_texture_param(const StringName &p_param) const; void get_default_texture_param_list(List<StringName> *r_textures) const; + virtual bool is_text_shader() const; + _FORCE_INLINE_ StringName remap_param(const StringName &p_param) const { if (params_cache_dirty) get_param_list(NULL); diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 16b4ed31df..f0e3979f13 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -207,6 +207,9 @@ void ImageTexture::set_flags(uint32_t p_flags) { flags=p_flags|cube; */ flags = p_flags; + if (w == 0 || h == 0) { + return; //uninitialized, do not set to texture + } VisualServer::get_singleton()->texture_set_flags(texture, p_flags); } diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index 74dcd47c48..1802bf12b6 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -80,8 +80,8 @@ public: struct AutotileData { BitmaskMode bitmask_mode; - int spacing; Size2 size; + int spacing; Vector2 icon_coord; Map<Vector2, uint16_t> flags; Map<Vector2, Ref<OccluderPolygon2D> > occluder_map; @@ -90,11 +90,10 @@ public: // Default size to prevent invalid value explicit AutotileData() : + bitmask_mode(BITMASK_2X2), size(64, 64), spacing(0), - icon_coord(0, 0) { - bitmask_mode = BITMASK_2X2; - } + icon_coord(0, 0) {} }; private: @@ -111,8 +110,8 @@ private: Vector2 navigation_polygon_offset; Ref<NavigationPolygon> navigation_polygon; Ref<ShaderMaterial> material; - Color modulate; TileMode tile_mode; + Color modulate; AutotileData autotile_data; int z_index; diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 6bfb6ec5bf..96b9cfa137 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -414,6 +414,10 @@ Shader::Mode VisualShader::get_mode() const { return shader_mode; } +bool VisualShader::is_text_shader() const { + return false; +} + String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port, Vector<DefaultTextureParam> &default_tex_params) const { Ref<VisualShaderNode> node = get_node(p_type, p_node); @@ -792,10 +796,10 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui val.basis.transpose(); inputs[i] = "n_in" + itos(node) + "p" + itos(i); Array values; - for (int i = 0; i < 3; i++) { - values.push_back(val.basis[i].x); - values.push_back(val.basis[i].y); - values.push_back(val.basis[i].z); + for (int j = 0; j < 3; j++) { + values.push_back(val.basis[j].x); + values.push_back(val.basis[j].y); + values.push_back(val.basis[j].z); } values.push_back(val.origin.x); values.push_back(val.origin.y); diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 70d2425304..2867daac3a 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -141,6 +141,8 @@ public: void set_mode(Mode p_mode); virtual Mode get_mode() const; + virtual bool is_text_shader() const; + void set_graph_offset(const Vector2 &p_offset); Vector2 get_graph_offset() const; diff --git a/scene/resources/world.h b/scene/resources/world.h index 4c517323f3..4ba6b13476 100644 --- a/scene/resources/world.h +++ b/scene/resources/world.h @@ -36,9 +36,9 @@ #include "servers/physics_server.h" #include "servers/visual_server.h" -class SpatialIndexer; class Camera; class VisibilityNotifier; +struct SpatialIndexer; class World : public Resource { GDCLASS(World, Resource); diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index b390e74073..dd78d04104 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -29,13 +29,13 @@ /*************************************************************************/ #include "world_2d.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" -//#include "servers/spatial_sound_2d_server.h" + #include "core/project_settings.h" #include "scene/2d/camera_2d.h" #include "scene/2d/visibility_notifier_2d.h" #include "scene/main/viewport.h" +#include "servers/physics_2d_server.h" +#include "servers/visual_server.h" struct SpatialIndexer2D { diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h index 856e9dbf01..88ad392f85 100644 --- a/scene/resources/world_2d.h +++ b/scene/resources/world_2d.h @@ -35,9 +35,9 @@ #include "core/resource.h" #include "servers/physics_2d_server.h" -class SpatialIndexer2D; class VisibilityNotifier2D; class Viewport; +struct SpatialIndexer2D; class World2D : public Resource { |