summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/SCsub2
-rw-r--r--scene/2d/animated_sprite.cpp2
-rw-r--r--scene/2d/area_2d.h2
-rw-r--r--scene/2d/audio_stream_player_2d.cpp2
-rw-r--r--scene/2d/canvas_item.cpp17
-rw-r--r--scene/2d/canvas_item.h4
-rw-r--r--scene/2d/collision_object_2d.cpp2
-rw-r--r--scene/2d/collision_polygon_2d.cpp2
-rw-r--r--scene/2d/collision_shape_2d.cpp2
-rw-r--r--scene/2d/cpu_particles_2d.cpp8
-rw-r--r--scene/2d/cpu_particles_2d.h6
-rw-r--r--scene/2d/joints_2d.cpp2
-rw-r--r--scene/2d/light_2d.cpp4
-rw-r--r--scene/2d/light_occluder_2d.cpp2
-rw-r--r--scene/2d/line_2d.cpp2
-rw-r--r--scene/2d/line_builder.h4
-rw-r--r--scene/2d/navigation2d.cpp28
-rw-r--r--scene/2d/navigation_polygon.cpp4
-rw-r--r--scene/2d/node_2d.cpp2
-rw-r--r--scene/2d/parallax_layer.cpp2
-rw-r--r--scene/2d/particles_2d.cpp9
-rw-r--r--scene/2d/particles_2d.h8
-rw-r--r--scene/2d/path_2d.cpp2
-rw-r--r--scene/2d/physics_body_2d.cpp37
-rw-r--r--scene/2d/physics_body_2d.h2
-rw-r--r--scene/2d/position_2d.cpp2
-rw-r--r--scene/2d/ray_cast_2d.cpp2
-rw-r--r--scene/2d/screen_button.cpp6
-rw-r--r--scene/2d/sprite.cpp2
-rw-r--r--scene/2d/tile_map.cpp7
-rw-r--r--scene/2d/tile_map.h4
-rw-r--r--scene/2d/visibility_notifier_2d.cpp2
-rw-r--r--scene/3d/SCsub4
-rw-r--r--scene/3d/area.cpp10
-rw-r--r--scene/3d/area.h2
-rw-r--r--scene/3d/audio_stream_player_3d.cpp4
-rw-r--r--scene/3d/baked_lightmap.cpp6
-rw-r--r--scene/3d/camera.cpp6
-rw-r--r--scene/3d/collision_object.cpp2
-rw-r--r--scene/3d/collision_shape.cpp2
-rw-r--r--scene/3d/cpu_particles.cpp9
-rw-r--r--scene/3d/cpu_particles.h5
-rw-r--r--scene/3d/interpolated_camera.cpp2
-rw-r--r--scene/3d/light.cpp19
-rw-r--r--scene/3d/mesh_instance.cpp2
-rw-r--r--scene/3d/navigation.cpp44
-rw-r--r--scene/3d/navigation.h1
-rw-r--r--scene/3d/particles.cpp1218
-rw-r--r--scene/3d/particles.h274
-rw-r--r--scene/3d/path.cpp2
-rw-r--r--scene/3d/physics_body.cpp46
-rw-r--r--scene/3d/physics_body.h2
-rw-r--r--scene/3d/portal.cpp2
-rw-r--r--scene/3d/proximity_group.cpp2
-rw-r--r--scene/3d/ray_cast.cpp2
-rw-r--r--scene/3d/room_instance.cpp4
-rw-r--r--scene/3d/skeleton.cpp2
-rw-r--r--scene/3d/skeleton.h2
-rw-r--r--scene/3d/soft_body.cpp2
-rw-r--r--scene/3d/spatial.cpp38
-rw-r--r--scene/3d/spatial.h3
-rw-r--r--scene/3d/spatial_velocity_tracker.cpp2
-rw-r--r--scene/3d/spring_arm.cpp5
-rw-r--r--scene/3d/spring_arm.h2
-rw-r--r--scene/3d/sprite_3d.cpp22
-rw-r--r--scene/3d/vehicle_body.cpp2
-rw-r--r--scene/3d/visibility_notifier.cpp2
-rw-r--r--scene/3d/visual_instance.cpp2
-rw-r--r--scene/3d/visual_instance.h4
-rw-r--r--scene/3d/voxel_light_baker.cpp4
-rw-r--r--scene/SCsub9
-rw-r--r--scene/animation/SCsub2
-rw-r--r--scene/animation/animation_blend_space_2d.cpp2
-rw-r--r--scene/animation/animation_node_state_machine.cpp2
-rw-r--r--scene/animation/animation_player.cpp66
-rw-r--r--scene/animation/animation_tree.cpp11
-rw-r--r--scene/animation/animation_tree_player.cpp1
-rw-r--r--scene/animation/root_motion_view.cpp2
-rw-r--r--scene/animation/skeleton_ik.cpp4
-rw-r--r--scene/animation/tween.cpp27
-rw-r--r--scene/animation/tween_interpolaters.cpp332
-rw-r--r--scene/audio/SCsub2
-rw-r--r--scene/audio/audio_player.cpp2
-rw-r--r--scene/gui/SCsub2
-rw-r--r--scene/gui/base_button.cpp15
-rw-r--r--scene/gui/base_button.h1
-rw-r--r--scene/gui/button.cpp17
-rw-r--r--scene/gui/check_button.cpp2
-rw-r--r--scene/gui/color_picker.cpp34
-rw-r--r--scene/gui/container.cpp2
-rw-r--r--scene/gui/control.cpp21
-rw-r--r--scene/gui/control.h6
-rw-r--r--scene/gui/dialogs.cpp4
-rw-r--r--scene/gui/file_dialog.cpp10
-rw-r--r--scene/gui/file_dialog.h2
-rw-r--r--scene/gui/gradient_edit.cpp66
-rw-r--r--scene/gui/gradient_edit.h2
-rw-r--r--scene/gui/graph_edit.cpp8
-rw-r--r--scene/gui/graph_node.cpp3
-rw-r--r--scene/gui/item_list.cpp4
-rw-r--r--scene/gui/label.cpp15
-rw-r--r--scene/gui/line_edit.cpp10
-rw-r--r--scene/gui/link_button.cpp1
-rw-r--r--scene/gui/menu_button.cpp2
-rw-r--r--scene/gui/option_button.cpp2
-rw-r--r--scene/gui/panel.cpp2
-rw-r--r--scene/gui/popup.cpp55
-rw-r--r--scene/gui/popup.h2
-rw-r--r--scene/gui/popup_menu.cpp8
-rw-r--r--scene/gui/range.cpp22
-rw-r--r--scene/gui/range.h2
-rw-r--r--scene/gui/reference_rect.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp103
-rw-r--r--scene/gui/rich_text_label.h8
-rw-r--r--scene/gui/scroll_bar.cpp158
-rw-r--r--scene/gui/scroll_bar.h27
-rw-r--r--scene/gui/scroll_container.cpp5
-rw-r--r--scene/gui/shortcut.cpp2
-rw-r--r--scene/gui/shortcut.h4
-rw-r--r--scene/gui/slider.cpp2
-rw-r--r--scene/gui/spin_box.cpp15
-rw-r--r--scene/gui/spin_box.h3
-rw-r--r--scene/gui/tab_container.cpp2
-rw-r--r--scene/gui/tabs.cpp2
-rw-r--r--scene/gui/text_edit.cpp126
-rw-r--r--scene/gui/text_edit.h2
-rw-r--r--scene/gui/texture_button.cpp4
-rw-r--r--scene/gui/texture_progress.cpp30
-rw-r--r--scene/gui/tree.cpp76
-rw-r--r--scene/gui/tree.h8
-rw-r--r--scene/gui/video_player.cpp6
-rw-r--r--scene/main/SCsub2
-rw-r--r--scene/main/http_request.cpp17
-rw-r--r--scene/main/http_request.h6
-rw-r--r--scene/main/instance_placeholder.cpp2
-rw-r--r--scene/main/node.cpp48
-rw-r--r--scene/main/node.h15
-rw-r--r--scene/main/scene_tree.cpp26
-rw-r--r--scene/main/scene_tree.h8
-rwxr-xr-xscene/main/timer.cpp2
-rw-r--r--scene/main/viewport.cpp26
-rw-r--r--scene/main/viewport.h2
-rw-r--r--scene/register_scene_types.cpp5
-rw-r--r--scene/resources/SCsub2
-rw-r--r--scene/resources/animation.cpp4
-rw-r--r--scene/resources/animation.h2
-rw-r--r--scene/resources/audio_stream_sample.cpp8
-rw-r--r--scene/resources/bit_mask.cpp3
-rw-r--r--scene/resources/bit_mask.h6
-rw-r--r--scene/resources/bounds.h4
-rw-r--r--scene/resources/canvas.h2
-rw-r--r--scene/resources/color_ramp.cpp2
-rw-r--r--scene/resources/color_ramp.h2
-rw-r--r--scene/resources/convex_polygon_shape.cpp2
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp2
-rw-r--r--scene/resources/curve.cpp3
-rw-r--r--scene/resources/curve.h2
-rw-r--r--scene/resources/default_theme/SCsub2
-rw-r--r--scene/resources/default_theme/default_theme.cpp48
-rw-r--r--scene/resources/dynamic_font.cpp4
-rw-r--r--scene/resources/dynamic_font.h8
-rw-r--r--scene/resources/dynamic_font_stb.cpp2
-rw-r--r--scene/resources/dynamic_font_stb.h2
-rw-r--r--scene/resources/environment.cpp2
-rw-r--r--scene/resources/environment.h2
-rw-r--r--scene/resources/font.cpp3
-rw-r--r--scene/resources/font.h4
-rw-r--r--scene/resources/material.cpp127
-rw-r--r--scene/resources/material.h8
-rw-r--r--scene/resources/mesh.cpp80
-rw-r--r--scene/resources/mesh.h9
-rw-r--r--scene/resources/mesh_data_tool.cpp8
-rw-r--r--scene/resources/mesh_library.h4
-rw-r--r--scene/resources/multimesh.cpp88
-rw-r--r--scene/resources/multimesh.h18
-rw-r--r--scene/resources/packed_scene.cpp6
-rw-r--r--scene/resources/packed_scene.h2
-rw-r--r--scene/resources/particles_material.cpp1262
-rw-r--r--scene/resources/particles_material.h302
-rw-r--r--scene/resources/physics_material.h2
-rw-r--r--scene/resources/polygon_path_finder.cpp2
-rw-r--r--scene/resources/polygon_path_finder.h2
-rw-r--r--scene/resources/primitive_meshes.cpp2
-rw-r--r--scene/resources/room.h4
-rw-r--r--scene/resources/scene_format_text.cpp20
-rw-r--r--scene/resources/scene_format_text.h8
-rw-r--r--scene/resources/shader.cpp13
-rw-r--r--scene/resources/shader.h8
-rw-r--r--scene/resources/shape.cpp2
-rw-r--r--scene/resources/shape.h2
-rw-r--r--scene/resources/shape_2d.h2
-rw-r--r--scene/resources/sky_box.cpp2
-rw-r--r--scene/resources/sky_box.h2
-rw-r--r--scene/resources/space_2d.h2
-rw-r--r--scene/resources/style_box.h2
-rw-r--r--scene/resources/surface_tool.cpp3
-rw-r--r--scene/resources/text_file.cpp2
-rw-r--r--scene/resources/text_file.h4
-rw-r--r--scene/resources/texture.cpp21
-rw-r--r--scene/resources/texture.h15
-rw-r--r--scene/resources/theme.cpp4
-rw-r--r--scene/resources/theme.h4
-rw-r--r--scene/resources/tile_set.cpp2
-rw-r--r--scene/resources/tile_set.h11
-rw-r--r--scene/resources/visual_shader.cpp14
-rw-r--r--scene/resources/visual_shader.h4
-rw-r--r--scene/resources/world.cpp4
-rw-r--r--scene/resources/world.h4
-rw-r--r--scene/resources/world_2d.cpp8
-rw-r--r--scene/resources/world_2d.h6
-rw-r--r--scene/scene_string_names.h4
211 files changed, 2939 insertions, 2751 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/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 85e7f8df92..a33fc844a5 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "animated_sprite.h"
-#include "os/os.h"
+#include "core/os/os.h"
#include "scene/scene_string_names.h"
#define NORMAL_SUFFIX "_normal"
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index 0fda9b867d..cd60b6c1e1 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -31,8 +31,8 @@
#ifndef AREA_2D_H
#define AREA_2D_H
+#include "core/vset.h"
#include "scene/2d/collision_object_2d.h"
-#include "vset.h"
class Area2D : public CollisionObject2D {
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index 559e041dbf..a1ae05d971 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -30,7 +30,7 @@
#include "audio_stream_player_2d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "scene/2d/area_2d.h"
#include "scene/main/viewport.h"
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 7f7e3542ed..fab0b7d433 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "canvas_item.h"
+#include "core/message_queue.h"
#include "core/method_bind_ext.gen.inc"
-#include "message_queue.h"
-#include "os/input.h"
+#include "core/os/input.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/viewport.h"
#include "scene/resources/font.h"
@@ -967,6 +967,17 @@ Vector2 CanvasItem::get_local_mouse_position() const {
return get_global_transform().affine_inverse().xform(get_global_mouse_position());
}
+void CanvasItem::force_update_transform() {
+ ERR_FAIL_COND(!is_inside_tree());
+ if (!xform_change.in_list()) {
+ return;
+ }
+
+ get_tree()->xform_change_list.remove(&xform_change);
+
+ notification(NOTIFICATION_TRANSFORM_CHANGED);
+}
+
void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("_toplevel_raise_self"), &CanvasItem::_toplevel_raise_self);
@@ -1061,6 +1072,8 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_notify_transform", "enable"), &CanvasItem::set_notify_transform);
ClassDB::bind_method(D_METHOD("is_transform_notification_enabled"), &CanvasItem::is_transform_notification_enabled);
+ ClassDB::bind_method(D_METHOD("force_update_transform"), &CanvasItem::force_update_transform);
+
ClassDB::bind_method(D_METHOD("make_canvas_position_local", "screen_point"), &CanvasItem::make_canvas_position_local);
ClassDB::bind_method(D_METHOD("make_input_local", "event"), &CanvasItem::make_input_local);
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 1e6a251c9c..36a0e4039a 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -346,7 +346,9 @@ public:
void set_notify_transform(bool p_enable);
bool is_transform_notification_enabled() const;
- // Used by control nodes to retreive the parent's anchorable area
+ void force_update_transform();
+
+ // Used by control nodes to retrieve the parent's anchorable area
virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); };
int get_canvas_layer() const;
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 1e2184bd41..7ade74e8a6 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -384,7 +384,7 @@ void CollisionObject2D::_bind_methods() {
BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "viewport"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::INT, "shape_idx")));
- ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "viewport"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::INT, "shape_idx")));
+ ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "viewport", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::INT, "shape_idx")));
ADD_SIGNAL(MethodInfo("mouse_entered"));
ADD_SIGNAL(MethodInfo("mouse_exited"));
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 9f19f56e75..508ceeaaf9 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -31,7 +31,7 @@
#include "collision_polygon_2d.h"
#include "collision_object_2d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index ff5f7062c4..cb9c8ecf95 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -31,7 +31,7 @@
#include "collision_shape_2d.h"
#include "collision_object_2d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index 136d41e2f9..d29c6b37d5 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -30,9 +30,7 @@
#include "cpu_particles_2d.h"
-#include "scene/3d/particles.h"
-#include "scene/main/viewport.h"
-#include "scene/resources/surface_tool.h"
+//#include "scene/resources/particles_material.h"
#include "servers/visual_server.h"
void CPUParticles2D::set_emitting(bool p_emitting) {
@@ -509,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/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h
index fa8e6b54ef..4f51eb1062 100644
--- a/scene/2d/cpu_particles_2d.h
+++ b/scene/2d/cpu_particles_2d.h
@@ -30,10 +30,10 @@
#ifndef CPU_PARTICLES_2D_H
#define CPU_PARTICLES_2D_H
-#include "rid.h"
+
+#include "core/rid.h"
#include "scene/2d/node_2d.h"
-#include "scene/main/timer.h"
-#include "scene/resources/material.h"
+#include "scene/resources/texture.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 7d5360c0e4..b9a48e1fdc 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -30,7 +30,7 @@
#include "joints_2d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "physics_body_2d.h"
#include "servers/physics_2d_server.h"
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index f93c7d1f79..e6a5a0b651 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -30,7 +30,7 @@
#include "light_2d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "servers/visual_server.h"
Dictionary Light2D::_edit_get_state() const {
@@ -431,7 +431,7 @@ void Light2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture,ImageTexture"), "set_texture", "get_texture");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_texture_offset", "get_texture_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_scale", PROPERTY_HINT_RANGE, "0.01,50,0.01"), "set_texture_scale", "get_texture_scale");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index c9e5d0f1bc..ab15b49985 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -30,7 +30,7 @@
#include "light_occluder_2d.h"
-#include "engine.h"
+#include "core/engine.h"
void OccluderPolygon2D::set_polygon(const PoolVector<Vector2> &p_polygon) {
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index ad9775c0b7..e164f0ca75 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -31,7 +31,7 @@
#include "line_2d.h"
#include "line_builder.h"
-#include "core_string_names.h"
+#include "core/core_string_names.h"
// Needed so we can bind functions
VARIANT_ENUM_CAST(Line2D::LineJointMode)
diff --git a/scene/2d/line_builder.h b/scene/2d/line_builder.h
index edfdf97c47..f9d26f12af 100644
--- a/scene/2d/line_builder.h
+++ b/scene/2d/line_builder.h
@@ -31,10 +31,10 @@
#ifndef LINE_BUILDER_H
#define LINE_BUILDER_H
-#include "color.h"
+#include "core/color.h"
+#include "core/math/vector2.h"
#include "line_2d.h"
#include "scene/resources/color_ramp.h"
-#include "vector2.h"
class LineBuilder {
public:
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/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index 84b12b0bfe..b36924e521 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -30,8 +30,8 @@
#include "navigation_polygon.h"
-#include "core_string_names.h"
-#include "engine.h"
+#include "core/core_string_names.h"
+#include "core/engine.h"
#include "navigation2d.h"
#include "thirdparty/misc/triangulator.h"
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 7de72dc41d..29065a89b3 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -30,7 +30,7 @@
#include "node_2d.h"
-#include "message_queue.h"
+#include "core/message_queue.h"
#include "scene/gui/control.h"
#include "scene/main/viewport.h"
#include "servers/visual_server.h"
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 2ac6c76032..06de723f27 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -30,7 +30,7 @@
#include "parallax_layer.h"
-#include "engine.h"
+#include "core/engine.h"
#include "parallax_background.h"
void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index a4c3057416..7e824cdf75 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -30,10 +30,13 @@
#include "particles_2d.h"
-#include "engine.h"
-#include "scene/3d/particles.h"
+#include "scene/resources/particles_material.h"
#include "scene/scene_string_names.h"
+#ifdef TOOLS_ENABLED
+#include "core/engine.h"
+#endif
+
void Particles2D::set_emitting(bool p_emitting) {
VS::get_singleton()->particles_set_emitting(particles, p_emitting);
@@ -114,7 +117,7 @@ void Particles2D::set_process_material(const Ref<Material> &p_material) {
process_material = p_material;
Ref<ParticlesMaterial> pm = p_material;
if (pm.is_valid() && !pm->get_flag(ParticlesMaterial::FLAG_DISABLE_Z) && pm->get_gravity() == Vector3(0, -9.8, 0)) {
- //likely a new material, modify it!
+ // Likely a new (3D) material, modify it to match 2D space
pm->set_flag(ParticlesMaterial::FLAG_DISABLE_Z, true);
pm->set_gravity(Vector3(0, 98, 0));
}
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index 31a66afb2a..af673841b1 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PARTICLES_FRAME_H
-#define PARTICLES_FRAME_H
+#ifndef PARTICLES_2D_H
+#define PARTICLES_2D_H
+#include "core/rid.h"
#include "scene/2d/node_2d.h"
-#include "scene/resources/color_ramp.h"
#include "scene/resources/texture.h"
class Particles2D : public Node2D {
@@ -132,4 +132,4 @@ public:
VARIANT_ENUM_CAST(Particles2D::DrawOrder)
-#endif // PARTICLES_FRAME_H
+#endif // PARTICLES_2D_H
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 658b998d17..cdb208e6cd 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -30,7 +30,7 @@
#include "path_2d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 1ac7799ec5..d0bebd3354 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -31,9 +31,9 @@
#include "physics_body_2d.h"
#include "core/core_string_names.h"
+#include "core/engine.h"
+#include "core/math/math_funcs.h"
#include "core/method_bind_ext.gen.inc"
-#include "engine.h"
-#include "math_funcs.h"
#include "scene/scene_string_names.h"
void PhysicsBody2D::_notification(int p_what) {
@@ -180,6 +180,10 @@ real_t StaticBody2D::get_constant_angular_velocity() const {
#ifndef DISABLE_DEPRECATED
void StaticBody2D::set_friction(real_t p_friction) {
+ if (p_friction == 1.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_friction has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
@@ -206,6 +210,10 @@ real_t StaticBody2D::get_friction() const {
void StaticBody2D::set_bounce(real_t p_bounce) {
+ if (p_bounce == 0.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
@@ -275,7 +283,7 @@ void StaticBody2D::_bind_methods() {
ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
}
StaticBody2D::StaticBody2D() :
@@ -396,13 +404,13 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (in_scene)
- emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exited, node);
}
contact_monitor->body_map.erase(E);
}
if (node && in_scene) {
- emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, node, p_body_shape, p_local_shape);
}
}
}
@@ -599,8 +607,13 @@ real_t RigidBody2D::get_weight() const {
#ifndef DISABLE_DEPRECATED
void RigidBody2D::set_friction(real_t p_friction) {
+ if (p_friction == 1.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_friction has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
+
ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
if (physics_material_override.is_null()) {
@@ -623,6 +636,10 @@ real_t RigidBody2D::get_friction() const {
void RigidBody2D::set_bounce(real_t p_bounce) {
+ if (p_bounce == 0.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
@@ -1028,7 +1045,7 @@ void RigidBody2D::_bind_methods() {
ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), "set_gravity_scale", "get_gravity_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), "set_use_custom_integrator", "is_using_custom_integrator");
ADD_PROPERTY(PropertyInfo(Variant::INT, "continuous_cd", PROPERTY_HINT_ENUM, "Disabled,Cast Ray,Cast Shape"), "set_continuous_collision_detection_mode", "get_continuous_collision_detection_mode");
@@ -1046,10 +1063,10 @@ void RigidBody2D::_bind_methods() {
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "applied_force"), "set_applied_force", "get_applied_force");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "applied_torque"), "set_applied_torque", "get_applied_torque");
- ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
- ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
- ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body")));
- ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body")));
+ ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
+ ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
+ ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
+ ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
BIND_ENUM_CONSTANT(MODE_RIGID);
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 852963a721..29befb0375 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -31,10 +31,10 @@
#ifndef PHYSICS_BODY_2D_H
#define PHYSICS_BODY_2D_H
+#include "core/vset.h"
#include "scene/2d/collision_object_2d.h"
#include "scene/resources/physics_material.h"
#include "servers/physics_2d_server.h"
-#include "vset.h"
class KinematicCollision2D;
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index 64d23719e7..543314eefa 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -30,7 +30,7 @@
#include "position_2d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "scene/resources/texture.h"
void Position2D::_draw_cross() {
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index d9b3cb07fc..f7c18a17df 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -31,7 +31,7 @@
#include "ray_cast_2d.h"
#include "collision_object_2d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "physics_body_2d.h"
#include "servers/physics_2d_server.h"
diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp
index 45f63fd5bf..44a41328e8 100644
--- a/scene/2d/screen_button.cpp
+++ b/scene/2d/screen_button.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "screen_button.h"
-#include "input_map.h"
-#include "os/input.h"
-#include "os/os.h"
+#include "core/input_map.h"
+#include "core/os/input.h"
+#include "core/os/os.h"
void TouchScreenButton::set_texture(const Ref<Texture> &p_texture) {
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index bb5990fa79..04e199a21b 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -30,7 +30,7 @@
#include "sprite.h"
#include "core/core_string_names.h"
-#include "os/os.h"
+#include "core/os/os.h"
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 8a2fdbacfa..5b8d10ea85 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -30,9 +30,9 @@
#include "tile_map.h"
-#include "io/marshalls.h"
-#include "method_bind_ext.gen.inc"
-#include "os/os.h"
+#include "core/io/marshalls.h"
+#include "core/method_bind_ext.gen.inc"
+#include "core/os/os.h"
#include "servers/physics_2d_server.h"
int TileMap::_get_quadrant_size() const {
@@ -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/2d/tile_map.h b/scene/2d/tile_map.h
index 55db33837f..499c79b180 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -31,11 +31,11 @@
#ifndef TILE_MAP_H
#define TILE_MAP_H
+#include "core/self_list.h"
+#include "core/vset.h"
#include "scene/2d/navigation2d.h"
#include "scene/2d/node_2d.h"
#include "scene/resources/tile_set.h"
-#include "self_list.h"
-#include "vset.h"
class TileMap : public Node2D {
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index ddca97e60a..7d7c47619a 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -30,7 +30,7 @@
#include "visibility_notifier_2d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "particles_2d.h"
#include "scene/2d/animated_sprite.h"
#include "scene/2d/physics_body_2d.h"
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/area.cpp b/scene/3d/area.cpp
index 6ea980ec97..40a1029201 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -243,7 +243,7 @@ void Area::_clear_monitoring() {
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
- emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exited, node);
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
@@ -699,10 +699,10 @@ void Area::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_reverb_uniformity", "amount"), &Area::set_reverb_uniformity);
ClassDB::bind_method(D_METHOD("get_reverb_uniformity"), &Area::get_reverb_uniformity);
- ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
- ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
- ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body")));
- ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body")));
+ ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
+ ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
+ ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
+ ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("area_shape_entered", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape")));
ADD_SIGNAL(MethodInfo("area_shape_exited", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape")));
diff --git a/scene/3d/area.h b/scene/3d/area.h
index e49b7e493b..e1ff1079e3 100644
--- a/scene/3d/area.h
+++ b/scene/3d/area.h
@@ -31,8 +31,8 @@
#ifndef AREA_H
#define AREA_H
+#include "core/vset.h"
#include "scene/3d/collision_object.h"
-#include "vset.h"
class Area : public CollisionObject {
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 8504a18f54..b1f90b72e7 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "audio_stream_player_3d.h"
-#include "engine.h"
+#include "core/engine.h"
#include "scene/3d/area.h"
#include "scene/3d/camera.h"
#include "scene/main/viewport.h"
@@ -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/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index 2cb59c871c..c58e318651 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "baked_lightmap.h"
-#include "io/resource_saver.h"
-#include "os/dir_access.h"
-#include "os/os.h"
+#include "core/io/resource_saver.h"
+#include "core/os/dir_access.h"
+#include "core/os/os.h"
#include "voxel_light_baker.h"
void BakedLightmapData::set_bounds(const AABB &p_bounds) {
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index a4582b7d7d..8ef64e2e80 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -30,9 +30,9 @@
#include "camera.h"
-#include "camera_matrix.h"
#include "collision_object.h"
-#include "engine.h"
+#include "core/engine.h"
+#include "core/math/camera_matrix.h"
#include "scene/resources/material.h"
#include "scene/resources/surface_tool.h"
void Camera::_update_audio_listener_state() {
@@ -553,11 +553,13 @@ Camera::Projection Camera::get_projection() const {
void Camera::set_fov(float p_fov) {
fov = p_fov;
_update_camera_mode();
+ _change_notify("fov");
}
void Camera::set_size(float p_size) {
size = p_size;
_update_camera_mode();
+ _change_notify("size");
}
void Camera::set_znear(float p_znear) {
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index e19e45b263..99b8ce0567 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -148,7 +148,7 @@ void CollisionObject::_bind_methods() {
BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_position"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx")));
- ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_position"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx")));
+ ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_position"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx")));
ADD_SIGNAL(MethodInfo("mouse_entered"));
ADD_SIGNAL(MethodInfo("mouse_exited"));
diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp
index 943f4158f7..4fd68fb47d 100644
--- a/scene/3d/collision_shape.cpp
+++ b/scene/3d/collision_shape.cpp
@@ -38,9 +38,9 @@
#include "scene/resources/sphere_shape.h"
#include "servers/visual_server.h"
//TODO: Implement CylinderShape and HeightMapShape?
+#include "core/math/quick_hull.h"
#include "mesh_instance.h"
#include "physics_body.h"
-#include "quick_hull.h"
void CollisionShape::make_convex_from_brothers() {
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index 3f76303ad3..ec51c31674 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -30,10 +30,9 @@
#include "cpu_particles.h"
-#include "particles.h"
#include "scene/3d/camera.h"
-#include "scene/main/viewport.h"
-#include "scene/resources/surface_tool.h"
+#include "scene/3d/particles.h"
+#include "scene/resources/particles_material.h"
#include "servers/visual_server.h"
AABB CPUParticles::get_aabb() const {
@@ -472,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/cpu_particles.h b/scene/3d/cpu_particles.h
index 85bce789f7..4e29d8d4ce 100644
--- a/scene/3d/cpu_particles.h
+++ b/scene/3d/cpu_particles.h
@@ -30,10 +30,9 @@
#ifndef CPU_PARTICLES_H
#define CPU_PARTICLES_H
-#include "rid.h"
+
+#include "core/rid.h"
#include "scene/3d/visual_instance.h"
-#include "scene/main/timer.h"
-#include "scene/resources/material.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp
index ffa283f634..93832f8e00 100644
--- a/scene/3d/interpolated_camera.cpp
+++ b/scene/3d/interpolated_camera.cpp
@@ -30,7 +30,7 @@
#include "interpolated_camera.h"
-#include "engine.h"
+#include "core/engine.h"
void InterpolatedCamera::_notification(int p_what) {
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 16164cf3bf..7e1d60ab8e 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -30,8 +30,8 @@
#include "light.h"
-#include "engine.h"
-#include "project_settings.h"
+#include "core/engine.h"
+#include "core/project_settings.h"
#include "scene/resources/surface_tool.h"
bool Light::_can_gizmo_scale() const {
@@ -48,6 +48,13 @@ void Light::set_param(Param p_param, float p_value) {
if (p_param == PARAM_SPOT_ANGLE || p_param == PARAM_RANGE) {
update_gizmo();
+
+ if (p_param == PARAM_SPOT_ANGLE) {
+ _change_notify("spot_angle");
+ } else if (p_param == PARAM_RANGE) {
+ _change_notify("omni_range");
+ _change_notify("spot_range");
+ }
}
}
@@ -156,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
@@ -173,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");
}
@@ -312,7 +325,7 @@ Light::Light(VisualServer::LightType p_type) {
Light::Light() {
type = VisualServer::LIGHT_DIRECTIONAL;
- ERR_PRINT("Light shouldn't be instanced dircetly, use the subtypes.");
+ ERR_PRINT("Light should not be instanced directly; use the DirectionalLight, OmniLight or SpotLight subtypes instead.");
}
Light::~Light() {
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index e277cae5b7..4cbf6f2de3 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -31,7 +31,7 @@
#include "mesh_instance.h"
#include "collision_shape.h"
-#include "core_string_names.h"
+#include "core/core_string_names.h"
#include "physics_body.h"
#include "scene/resources/material.h"
#include "scene/scene_string_names.h"
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/particles.cpp b/scene/3d/particles.cpp
index 6ba569ac75..10b26778ef 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "particles.h"
-#include "scene/resources/surface_tool.h"
+
#include "servers/visual_server.h"
AABB Particles::get_aabb() const {
@@ -378,1219 +378,3 @@ Particles::~Particles() {
VS::get_singleton()->free(particles);
}
-
-//////////////////////////////////////
-
-Mutex *ParticlesMaterial::material_mutex = NULL;
-SelfList<ParticlesMaterial>::List ParticlesMaterial::dirty_materials;
-Map<ParticlesMaterial::MaterialKey, ParticlesMaterial::ShaderData> ParticlesMaterial::shader_map;
-ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = NULL;
-
-void ParticlesMaterial::init_shaders() {
-
-#ifndef NO_THREADS
- material_mutex = Mutex::create();
-#endif
-
- shader_names = memnew(ShaderNames);
-
- shader_names->spread = "spread";
- shader_names->flatness = "flatness";
- shader_names->initial_linear_velocity = "initial_linear_velocity";
- shader_names->initial_angle = "initial_angle";
- shader_names->angular_velocity = "angular_velocity";
- shader_names->orbit_velocity = "orbit_velocity";
- shader_names->linear_accel = "linear_accel";
- shader_names->radial_accel = "radial_accel";
- shader_names->tangent_accel = "tangent_accel";
- shader_names->damping = "damping";
- shader_names->scale = "scale";
- shader_names->hue_variation = "hue_variation";
- shader_names->anim_speed = "anim_speed";
- shader_names->anim_offset = "anim_offset";
-
- shader_names->initial_linear_velocity_random = "initial_linear_velocity_random";
- shader_names->initial_angle_random = "initial_angle_random";
- shader_names->angular_velocity_random = "angular_velocity_random";
- shader_names->orbit_velocity_random = "orbit_velocity_random";
- shader_names->linear_accel_random = "linear_accel_random";
- shader_names->radial_accel_random = "radial_accel_random";
- shader_names->tangent_accel_random = "tangent_accel_random";
- shader_names->damping_random = "damping_random";
- shader_names->scale_random = "scale_random";
- shader_names->hue_variation_random = "hue_variation_random";
- shader_names->anim_speed_random = "anim_speed_random";
- shader_names->anim_offset_random = "anim_offset_random";
-
- shader_names->angle_texture = "angle_texture";
- shader_names->angular_velocity_texture = "angular_velocity_texture";
- shader_names->orbit_velocity_texture = "orbit_velocity_texture";
- shader_names->linear_accel_texture = "linear_accel_texture";
- shader_names->radial_accel_texture = "radial_accel_texture";
- shader_names->tangent_accel_texture = "tangent_accel_texture";
- shader_names->damping_texture = "damping_texture";
- shader_names->scale_texture = "scale_texture";
- shader_names->hue_variation_texture = "hue_variation_texture";
- shader_names->anim_speed_texture = "anim_speed_texture";
- shader_names->anim_offset_texture = "anim_offset_texture";
-
- shader_names->color = "color_value";
- shader_names->color_ramp = "color_ramp";
-
- shader_names->emission_sphere_radius = "emission_sphere_radius";
- shader_names->emission_box_extents = "emission_box_extents";
- shader_names->emission_texture_point_count = "emission_texture_point_count";
- shader_names->emission_texture_points = "emission_texture_points";
- shader_names->emission_texture_normal = "emission_texture_normal";
- shader_names->emission_texture_color = "emission_texture_color";
-
- shader_names->trail_divisor = "trail_divisor";
- shader_names->trail_size_modifier = "trail_size_modifier";
- shader_names->trail_color_modifier = "trail_color_modifier";
-
- shader_names->gravity = "gravity";
-}
-
-void ParticlesMaterial::finish_shaders() {
-
-#ifndef NO_THREADS
- memdelete(material_mutex);
-#endif
-
- memdelete(shader_names);
-}
-
-void ParticlesMaterial::_update_shader() {
-
- dirty_materials.remove(&element);
-
- MaterialKey mk = _compute_key();
- if (mk.key == current_key.key)
- return; //no update required in the end
-
- if (shader_map.has(current_key)) {
- shader_map[current_key].users--;
- if (shader_map[current_key].users == 0) {
- //deallocate shader, as it's no longer in use
- VS::get_singleton()->free(shader_map[current_key].shader);
- shader_map.erase(current_key);
- }
- }
-
- current_key = mk;
-
- if (shader_map.has(mk)) {
-
- VS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
- shader_map[mk].users++;
- return;
- }
-
- //must create a shader!
-
- String code = "shader_type particles;\n";
-
- code += "uniform float spread;\n";
- code += "uniform float flatness;\n";
- code += "uniform float initial_linear_velocity;\n";
- code += "uniform float initial_angle;\n";
- code += "uniform float angular_velocity;\n";
- code += "uniform float orbit_velocity;\n";
- code += "uniform float linear_accel;\n";
- code += "uniform float radial_accel;\n";
- code += "uniform float tangent_accel;\n";
- code += "uniform float damping;\n";
- code += "uniform float scale;\n";
- code += "uniform float hue_variation;\n";
- code += "uniform float anim_speed;\n";
- code += "uniform float anim_offset;\n";
-
- code += "uniform float initial_linear_velocity_random;\n";
- code += "uniform float initial_angle_random;\n";
- code += "uniform float angular_velocity_random;\n";
- code += "uniform float orbit_velocity_random;\n";
- code += "uniform float linear_accel_random;\n";
- code += "uniform float radial_accel_random;\n";
- code += "uniform float tangent_accel_random;\n";
- code += "uniform float damping_random;\n";
- code += "uniform float scale_random;\n";
- code += "uniform float hue_variation_random;\n";
- code += "uniform float anim_speed_random;\n";
- code += "uniform float anim_offset_random;\n";
-
- switch (emission_shape) {
- case EMISSION_SHAPE_POINT: {
- //do none
- } break;
- case EMISSION_SHAPE_SPHERE: {
- code += "uniform float emission_sphere_radius;\n";
- } break;
- case EMISSION_SHAPE_BOX: {
- code += "uniform vec3 emission_box_extents;\n";
- } break;
- case EMISSION_SHAPE_DIRECTED_POINTS: {
- code += "uniform sampler2D emission_texture_normal : hint_black;\n";
- } //fallthrough
- case EMISSION_SHAPE_POINTS: {
- code += "uniform sampler2D emission_texture_points : hint_black;\n";
- code += "uniform int emission_texture_point_count;\n";
- if (emission_color_texture.is_valid()) {
- code += "uniform sampler2D emission_texture_color : hint_white;\n";
- }
- } break;
- }
-
- code += "uniform vec4 color_value : hint_color;\n";
-
- code += "uniform int trail_divisor;\n";
-
- code += "uniform vec3 gravity;\n";
-
- if (color_ramp.is_valid())
- code += "uniform sampler2D color_ramp;\n";
-
- if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
- code += "uniform sampler2D linear_velocity_texture;\n";
- if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid())
- code += "uniform sampler2D orbit_velocity_texture;\n";
- if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid())
- code += "uniform sampler2D angular_velocity_texture;\n";
- if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid())
- code += "uniform sampler2D linear_accel_texture;\n";
- if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid())
- code += "uniform sampler2D radial_accel_texture;\n";
- if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid())
- code += "uniform sampler2D tangent_accel_texture;\n";
- if (tex_parameters[PARAM_DAMPING].is_valid())
- code += "uniform sampler2D damping_texture;\n";
- if (tex_parameters[PARAM_ANGLE].is_valid())
- code += "uniform sampler2D angle_texture;\n";
- if (tex_parameters[PARAM_SCALE].is_valid())
- code += "uniform sampler2D scale_texture;\n";
- if (tex_parameters[PARAM_HUE_VARIATION].is_valid())
- code += "uniform sampler2D hue_variation_texture;\n";
- if (tex_parameters[PARAM_ANIM_SPEED].is_valid())
- code += "uniform sampler2D anim_speed_texture;\n";
- if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
- code += "uniform sampler2D anim_offset_texture;\n";
-
- if (trail_size_modifier.is_valid()) {
- code += "uniform sampler2D trail_size_modifier;\n";
- }
-
- if (trail_color_modifier.is_valid()) {
- code += "uniform sampler2D trail_color_modifier;\n";
- }
-
- //need a random function
- code += "\n\n";
- code += "float rand_from_seed(inout uint seed) {\n";
- code += " int k;\n";
- code += " int s = int(seed);\n";
- code += " if (s == 0)\n";
- code += " s = 305420679;\n";
- code += " k = s / 127773;\n";
- code += " s = 16807 * (s - k * 127773) - 2836 * k;\n";
- code += " if (s < 0)\n";
- code += " s += 2147483647;\n";
- code += " seed = uint(s);\n";
- code += " return float(seed % uint(65536))/65535.0;\n";
- code += "}\n";
- code += "\n";
-
- code += "float rand_from_seed_m1_p1(inout uint seed) {\n";
- code += " return rand_from_seed(seed)*2.0-1.0;\n";
- code += "}\n";
- code += "\n";
-
- //improve seed quality
- code += "uint hash(uint x) {\n";
- code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n";
- code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n";
- code += " x = (x >> uint(16)) ^ x;\n";
- code += " return x;\n";
- code += "}\n";
- code += "\n";
-
- code += "void vertex() {\n";
- code += " uint base_number = NUMBER/uint(trail_divisor);\n";
- code += " uint alt_seed = hash(base_number+uint(1)+RANDOM_SEED);\n";
- code += " float angle_rand = rand_from_seed(alt_seed);\n";
- code += " float scale_rand = rand_from_seed(alt_seed);\n";
- code += " float hue_rot_rand = rand_from_seed(alt_seed);\n";
- code += " float anim_offset_rand = rand_from_seed(alt_seed);\n";
- code += " float pi = 3.14159;\n";
- code += " float degree_to_rad = pi / 180.0;\n";
- code += "\n";
-
- if (emission_shape >= EMISSION_SHAPE_POINTS) {
- code += " int point = min(emission_texture_point_count-1,int(rand_from_seed(alt_seed) * float(emission_texture_point_count)));\n";
- code += " ivec2 emission_tex_size = textureSize( emission_texture_points, 0 );\n";
- code += " ivec2 emission_tex_ofs = ivec2( point % emission_tex_size.x, point / emission_tex_size.x );\n";
- }
- code += " if (RESTART) {\n";
-
- if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
- code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(0.0,0.0),0.0).r;\n";
- else
- code += " float tex_linear_velocity = 0.0;\n";
-
- if (tex_parameters[PARAM_ANGLE].is_valid())
- code += " float tex_angle = textureLod(angle_texture,vec2(0.0,0.0),0.0).r;\n";
- else
- code += " float tex_angle = 0.0;\n";
-
- if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
- code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(0.0,0.0),0.0).r;\n";
- else
- code += " float tex_anim_offset = 0.0;\n";
-
- code += " float spread_rad = spread*degree_to_rad;\n";
-
- if (flags[FLAG_DISABLE_Z]) {
-
- code += " float angle1_rad = rand_from_seed_m1_p1(alt_seed)*spread_rad;\n";
- code += " vec3 rot = vec3( cos(angle1_rad), sin(angle1_rad),0.0 );\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
- code += " float angle1_rad = rand_from_seed_m1_p1(alt_seed)*spread_rad;\n";
- code += " float angle2_rad = rand_from_seed_m1_p1(alt_seed)*spread_rad*(1.0-flatness);\n";
- code += " vec3 direction_xz = vec3( sin(angle1_rad), 0, cos(angle1_rad));\n";
- code += " vec3 direction_yz = vec3( 0, sin(angle2_rad), cos(angle2_rad));\n";
- code += " direction_yz.z = direction_yz.z / sqrt(direction_yz.z); //better uniform distribution\n";
- code += " vec3 direction = vec3(direction_xz.x * direction_yz.z, direction_yz.y, direction_xz.z * direction_yz.z);\n";
- code += " direction = normalize(direction);\n";
- code += " VELOCITY = direction*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";
- code += " CUSTOM.x = base_angle*degree_to_rad;\n"; //angle
- code += " CUSTOM.y = 0.0;\n"; //phase
- code += " CUSTOM.z = (anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random);\n"; //animation offset (0-1)
- switch (emission_shape) {
- case EMISSION_SHAPE_POINT: {
- //do none
- } break;
- case EMISSION_SHAPE_SPHERE: {
- code += " TRANSFORM[3].xyz = normalize(vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0 ))*emission_sphere_radius;\n";
- } break;
- case EMISSION_SHAPE_BOX: {
- code += " TRANSFORM[3].xyz = vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0)*emission_box_extents;\n";
- } break;
- case EMISSION_SHAPE_POINTS:
- case EMISSION_SHAPE_DIRECTED_POINTS: {
- code += " TRANSFORM[3].xyz = texelFetch(emission_texture_points, emission_tex_ofs,0).xyz;\n";
-
- if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS) {
- if (flags[FLAG_DISABLE_Z]) {
-
- code += " mat2 rotm;";
- code += " rotm[0] = texelFetch(emission_texture_normal, emission_tex_ofs,0).xy;\n";
- code += " rotm[1] = rotm[0].yx * vec2(1.0,-1.0);\n";
- code += " VELOCITY.xy = rotm * VELOCITY.xy;\n";
- } else {
- code += " vec3 normal = texelFetch(emission_texture_normal, emission_tex_ofs,0).xyz;\n";
- code += " vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0, 1.0, 0.0);\n";
- code += " vec3 tangent = normalize(cross(v0, normal));\n";
- code += " vec3 bitangent = normalize(cross(tangent, normal));\n";
- code += " VELOCITY = mat3(tangent,bitangent,normal) * VELOCITY;\n";
- }
- }
- } break;
- }
- code += " VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY,0.0)).xyz;\n";
- code += " TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n";
- if (flags[FLAG_DISABLE_Z]) {
- code += " VELOCITY.z = 0.0;\n";
- code += " TRANSFORM[3].z = 0.0;\n";
- }
-
- code += " } else {\n";
-
- code += " CUSTOM.y += DELTA/LIFETIME;\n";
- if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
- code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_linear_velocity = 0.0;\n";
-
- if (flags[FLAG_DISABLE_Z]) {
-
- if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid())
- code += " float tex_orbit_velocity = textureLod(orbit_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_orbit_velocity = 0.0;\n";
- }
-
- if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid())
- code += " float tex_angular_velocity = textureLod(angular_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_angular_velocity = 0.0;\n";
-
- if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid())
- code += " float tex_linear_accel = textureLod(linear_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_linear_accel = 0.0;\n";
-
- if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid())
- code += " float tex_radial_accel = textureLod(radial_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_radial_accel = 0.0;\n";
-
- if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid())
- code += " float tex_tangent_accel = textureLod(tangent_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_tangent_accel = 0.0;\n";
-
- if (tex_parameters[PARAM_DAMPING].is_valid())
- code += " float tex_damping = textureLod(damping_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_damping = 0.0;\n";
-
- if (tex_parameters[PARAM_ANGLE].is_valid())
- code += " float tex_angle = textureLod(angle_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_angle = 0.0;\n";
-
- if (tex_parameters[PARAM_ANIM_SPEED].is_valid())
- code += " float tex_anim_speed = textureLod(anim_speed_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_anim_speed = 0.0;\n";
-
- if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
- code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_anim_offset = 0.0;\n";
-
- code += " vec3 force = gravity; \n";
- code += " vec3 pos = TRANSFORM[3].xyz; \n";
- if (flags[FLAG_DISABLE_Z]) {
- code += " pos.z = 0.0; \n";
- }
- code += " //apply linear acceleration\n";
- code += " force += length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel+tex_linear_accel)*mix(1.0,rand_from_seed(alt_seed),linear_accel_random) : vec3(0.0);\n";
- code += " //apply radial acceleration\n";
- code += " vec3 org = EMISSION_TRANSFORM[3].xyz;\n";
- code += " vec3 diff = pos-org;\n";
- 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),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),tangent_accel_random)) : vec3(0.0);\n";
- }
- code += " //apply attractor forces\n";
- code += " VELOCITY += force * DELTA;\n";
- code += " //orbit velocity\n";
- if (flags[FLAG_DISABLE_Z]) {
-
- code += " float orbit_amount = (orbit_velocity+tex_orbit_velocity)*mix(1.0,rand_from_seed(alt_seed),orbit_velocity_random);\n";
- code += " if (orbit_amount!=0.0) {\n";
- code += " float ang = orbit_amount * DELTA * pi * 2.0;\n";
- code += " mat2 rot = mat2(vec2(cos(ang),-sin(ang)),vec2(sin(ang),cos(ang)));\n";
- code += " TRANSFORM[3].xy-=diff.xy;\n";
- code += " TRANSFORM[3].xy+=rot * diff.xy;\n";
- code += " }\n";
- }
-
- if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
- code += " VELOCITY = normalize(VELOCITY)*tex_linear_velocity;\n";
- }
- code += " if (damping + tex_damping > 0.0) {\n";
- code += " \n";
- code += " float v = length(VELOCITY);\n";
- code += " float damp = (damping+tex_damping)*mix(1.0,rand_from_seed(alt_seed),damping_random);\n";
- code += " v -= damp * DELTA;\n";
- code += " if (v < 0.0) {\n";
- code += " VELOCITY = vec3(0.0);\n";
- code += " } else {\n";
- code += " VELOCITY = normalize(VELOCITY) * v;\n";
- code += " }\n";
- code += " }\n";
- code += " float base_angle = (initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n";
- code += " base_angle += CUSTOM.y*LIFETIME*(angular_velocity+tex_angular_velocity)*mix(1.0,rand_from_seed(alt_seed)*2.0-1.0,angular_velocity_random);\n";
- code += " CUSTOM.x = base_angle*degree_to_rad;\n"; //angle
- code += " CUSTOM.z = (anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random)+CUSTOM.y*(anim_speed+tex_anim_speed)*mix(1.0,rand_from_seed(alt_seed),anim_speed_random);\n"; //angle
- if (flags[FLAG_ANIM_LOOP]) {
- code += " CUSTOM.z = mod(CUSTOM.z,1.0);\n"; //loop
-
- } else {
- code += " CUSTOM.z = clamp(CUSTOM.z,0.0,1.0);\n"; //0 to 1 only
- }
- code += " }\n";
- //apply color
- //apply hue rotation
- if (tex_parameters[PARAM_SCALE].is_valid())
- code += " float tex_scale = textureLod(scale_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_scale = 1.0;\n";
-
- if (tex_parameters[PARAM_HUE_VARIATION].is_valid())
- code += " float tex_hue_variation = textureLod(hue_variation_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
- else
- code += " float tex_hue_variation = 0.0;\n";
-
- code += " float hue_rot_angle = (hue_variation+tex_hue_variation)*pi*2.0*mix(1.0,hue_rot_rand*2.0-1.0,hue_variation_random);\n";
- code += " float hue_rot_c = cos(hue_rot_angle);\n";
- code += " float hue_rot_s = sin(hue_rot_angle);\n";
- code += " mat4 hue_rot_mat = mat4( vec4(0.299, 0.587, 0.114, 0.0),\n";
- code += " vec4(0.299, 0.587, 0.114, 0.0),\n";
- code += " vec4(0.299, 0.587, 0.114, 0.0),\n";
- code += " vec4(0.000, 0.000, 0.000, 1.0)) +\n";
- code += " mat4( vec4(0.701, -0.587, -0.114, 0.0),\n";
- code += " vec4(-0.299, 0.413, -0.114, 0.0),\n";
- code += " vec4(-0.300, -0.588, 0.886, 0.0),\n";
- code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_c +\n";
- code += " mat4( vec4(0.168, 0.330, -0.497, 0.0),\n";
- code += " vec4(-0.328, 0.035, 0.292, 0.0),\n";
- code += " vec4(1.250, -1.050, -0.203, 0.0),\n";
- code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_s;\n";
- if (color_ramp.is_valid()) {
- code += " COLOR = hue_rot_mat * textureLod(color_ramp,vec2(CUSTOM.y,0.0),0.0);\n";
- } else {
- code += " COLOR = hue_rot_mat * color_value;\n";
- }
- if (emission_color_texture.is_valid() && emission_shape >= EMISSION_SHAPE_POINTS) {
- code += " COLOR*= texelFetch(emission_texture_color,emission_tex_ofs,0);\n";
- }
- if (trail_color_modifier.is_valid()) {
- code += " if (trail_divisor > 1) { COLOR *= textureLod(trail_color_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0); }\n";
- }
- code += "\n";
-
- if (flags[FLAG_DISABLE_Z]) {
-
- if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
- code += " if (length(VELOCITY) > 0.0) { TRANSFORM[1].xyz = normalize(VELOCITY); } else { TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz); }\n";
- code += " TRANSFORM[0].xyz = normalize(cross(TRANSFORM[1].xyz,TRANSFORM[2].xyz));\n";
- code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
- } else {
- code += " TRANSFORM[0] = vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);\n";
- code += " TRANSFORM[1] = vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);\n";
- code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
- }
-
- } else {
- //orient particle Y towards velocity
- if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
- code += " if (length(VELOCITY) > 0.0) { TRANSFORM[1].xyz = normalize(VELOCITY); } else { TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz); }\n";
- code += " if (TRANSFORM[1].xyz == normalize(TRANSFORM[0].xyz)) {\n";
- code += " TRANSFORM[0].xyz = normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n";
- code += " TRANSFORM[2].xyz = normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n";
- code += " } else {\n";
- code += " TRANSFORM[2].xyz = normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n";
- code += " TRANSFORM[0].xyz = normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n";
- code += " }\n";
- } else {
- code += " TRANSFORM[0].xyz = normalize(TRANSFORM[0].xyz);\n";
- code += " TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz);\n";
- code += " TRANSFORM[2].xyz = normalize(TRANSFORM[2].xyz);\n";
- }
- //turn particle by rotation in Y
- if (flags[FLAG_ROTATE_Y]) {
- code += " TRANSFORM = TRANSFORM * mat4( vec4(cos(CUSTOM.x),0.0,-sin(CUSTOM.x),0.0), vec4(0.0,1.0,0.0,0.0),vec4(sin(CUSTOM.x),0.0,cos(CUSTOM.x),0.0),vec4(0.0,0.0,0.0,1.0));\n";
- }
- }
- //scale by scale
- code += " float base_scale = mix(scale*tex_scale,1.0,scale_random*scale_rand);\n";
- code += " if (base_scale==0.0) base_scale=0.000001;\n";
- if (trail_size_modifier.is_valid()) {
- code += " if (trail_divisor > 1) { base_scale *= textureLod(trail_size_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0).r; } \n";
- }
-
- code += " TRANSFORM[0].xyz *= base_scale;\n";
- code += " TRANSFORM[1].xyz *= base_scale;\n";
- code += " TRANSFORM[2].xyz *= base_scale;\n";
- if (flags[FLAG_DISABLE_Z]) {
- code += " VELOCITY.z = 0.0;\n";
- code += " TRANSFORM[3].z = 0.0;\n";
- }
- code += "}\n";
- code += "\n";
-
- ShaderData shader_data;
- shader_data.shader = VS::get_singleton()->shader_create();
- shader_data.users = 1;
-
- VS::get_singleton()->shader_set_code(shader_data.shader, code);
-
- shader_map[mk] = shader_data;
-
- VS::get_singleton()->material_set_shader(_get_material(), shader_data.shader);
-}
-
-void ParticlesMaterial::flush_changes() {
-
- if (material_mutex)
- material_mutex->lock();
-
- while (dirty_materials.first()) {
-
- dirty_materials.first()->self()->_update_shader();
- }
-
- if (material_mutex)
- material_mutex->unlock();
-}
-
-void ParticlesMaterial::_queue_shader_change() {
-
- if (material_mutex)
- material_mutex->lock();
-
- if (!element.in_list()) {
- dirty_materials.add(&element);
- }
-
- if (material_mutex)
- material_mutex->unlock();
-}
-
-bool ParticlesMaterial::_is_shader_dirty() const {
-
- bool dirty = false;
-
- if (material_mutex)
- material_mutex->lock();
-
- dirty = element.in_list();
-
- if (material_mutex)
- material_mutex->unlock();
-
- return dirty;
-}
-
-void ParticlesMaterial::set_spread(float p_spread) {
-
- spread = p_spread;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->spread, p_spread);
-}
-
-float ParticlesMaterial::get_spread() const {
-
- return spread;
-}
-
-void ParticlesMaterial::set_flatness(float p_flatness) {
-
- flatness = p_flatness;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->flatness, p_flatness);
-}
-float ParticlesMaterial::get_flatness() const {
-
- return flatness;
-}
-
-void ParticlesMaterial::set_param(Parameter p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param, PARAM_MAX);
-
- parameters[p_param] = p_value;
-
- switch (p_param) {
- case PARAM_INITIAL_LINEAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity, p_value);
- } break;
- case PARAM_ANGULAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity, p_value);
- } break;
- case PARAM_ORBIT_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity, p_value);
- } break;
- case PARAM_LINEAR_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel, p_value);
- } break;
- case PARAM_RADIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel, p_value);
- } break;
- case PARAM_TANGENTIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel, p_value);
- } break;
- case PARAM_DAMPING: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping, p_value);
- } break;
- case PARAM_ANGLE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle, p_value);
- } break;
- case PARAM_SCALE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale, p_value);
- } break;
- case PARAM_HUE_VARIATION: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation, p_value);
- } break;
- case PARAM_ANIM_SPEED: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed, p_value);
- } break;
- case PARAM_ANIM_OFFSET: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset, p_value);
- } break;
- }
-}
-float ParticlesMaterial::get_param(Parameter p_param) const {
-
- ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
-
- return parameters[p_param];
-}
-
-void ParticlesMaterial::set_param_randomness(Parameter p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param, PARAM_MAX);
-
- randomness[p_param] = p_value;
-
- switch (p_param) {
- case PARAM_INITIAL_LINEAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity_random, p_value);
- } break;
- case PARAM_ANGULAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_random, p_value);
- } break;
- case PARAM_ORBIT_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_random, p_value);
- } break;
- case PARAM_LINEAR_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_random, p_value);
- } break;
- case PARAM_RADIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_random, p_value);
- } break;
- case PARAM_TANGENTIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_random, p_value);
- } break;
- case PARAM_DAMPING: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_random, p_value);
- } break;
- case PARAM_ANGLE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle_random, p_value);
- } break;
- case PARAM_SCALE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_random, p_value);
- } break;
- case PARAM_HUE_VARIATION: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_random, p_value);
- } break;
- case PARAM_ANIM_SPEED: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_random, p_value);
- } break;
- case PARAM_ANIM_OFFSET: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_random, p_value);
- } break;
- }
-}
-float ParticlesMaterial::get_param_randomness(Parameter p_param) const {
-
- ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
-
- return randomness[p_param];
-}
-
-static void _adjust_curve_range(const Ref<Texture> &p_texture, float p_min, float p_max) {
-
- Ref<CurveTexture> curve_tex = p_texture;
- if (!curve_tex.is_valid())
- return;
-
- curve_tex->ensure_default_setup(p_min, p_max);
-}
-
-void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture> &p_texture) {
-
- ERR_FAIL_INDEX(p_param, PARAM_MAX);
-
- tex_parameters[p_param] = p_texture;
-
- switch (p_param) {
- case PARAM_INITIAL_LINEAR_VELOCITY: {
- //do none for this one
- } break;
- case PARAM_ANGULAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_texture, p_texture);
- _adjust_curve_range(p_texture, -360, 360);
- } break;
- case PARAM_ORBIT_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_texture, p_texture);
- _adjust_curve_range(p_texture, -500, 500);
- } break;
- case PARAM_LINEAR_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_texture, p_texture);
- _adjust_curve_range(p_texture, -200, 200);
- } break;
- case PARAM_RADIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_texture, p_texture);
- _adjust_curve_range(p_texture, -200, 200);
- } break;
- case PARAM_TANGENTIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_texture, p_texture);
- _adjust_curve_range(p_texture, -200, 200);
- } break;
- case PARAM_DAMPING: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_texture, p_texture);
- _adjust_curve_range(p_texture, 0, 100);
- } break;
- case PARAM_ANGLE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angle_texture, p_texture);
- _adjust_curve_range(p_texture, -360, 360);
- } break;
- case PARAM_SCALE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_texture, p_texture);
-
- Ref<CurveTexture> curve_tex = p_texture;
- if (curve_tex.is_valid()) {
- curve_tex->ensure_default_setup();
- }
-
- } break;
- case PARAM_HUE_VARIATION: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_texture, p_texture);
- _adjust_curve_range(p_texture, -1, 1);
- } break;
- case PARAM_ANIM_SPEED: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_texture, p_texture);
- _adjust_curve_range(p_texture, 0, 200);
- } break;
- case PARAM_ANIM_OFFSET: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_texture, p_texture);
- } break;
- }
-
- _queue_shader_change();
-}
-Ref<Texture> ParticlesMaterial::get_param_texture(Parameter p_param) const {
-
- ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Texture>());
-
- return tex_parameters[p_param];
-}
-
-void ParticlesMaterial::set_color(const Color &p_color) {
-
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color, p_color);
- color = p_color;
-}
-
-Color ParticlesMaterial::get_color() const {
-
- return color;
-}
-
-void ParticlesMaterial::set_color_ramp(const Ref<Texture> &p_texture) {
-
- color_ramp = p_texture;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color_ramp, p_texture);
- _queue_shader_change();
- _change_notify();
-}
-
-Ref<Texture> ParticlesMaterial::get_color_ramp() const {
-
- return color_ramp;
-}
-
-void ParticlesMaterial::set_flag(Flags p_flag, bool p_enable) {
- ERR_FAIL_INDEX(p_flag, FLAG_MAX);
- flags[p_flag] = p_enable;
- _queue_shader_change();
- if (p_flag == FLAG_DISABLE_Z) {
- _change_notify();
- }
-}
-
-bool ParticlesMaterial::get_flag(Flags p_flag) const {
- ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
- return flags[p_flag];
-}
-
-void ParticlesMaterial::set_emission_shape(EmissionShape p_shape) {
-
- emission_shape = p_shape;
- _change_notify();
- _queue_shader_change();
-}
-
-void ParticlesMaterial::set_emission_sphere_radius(float p_radius) {
-
- emission_sphere_radius = p_radius;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_sphere_radius, p_radius);
-}
-
-void ParticlesMaterial::set_emission_box_extents(Vector3 p_extents) {
-
- emission_box_extents = p_extents;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_box_extents, p_extents);
-}
-
-void ParticlesMaterial::set_emission_point_texture(const Ref<Texture> &p_points) {
-
- emission_point_texture = p_points;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_points, p_points);
-}
-
-void ParticlesMaterial::set_emission_normal_texture(const Ref<Texture> &p_normals) {
-
- emission_normal_texture = p_normals;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_normal, p_normals);
-}
-
-void ParticlesMaterial::set_emission_color_texture(const Ref<Texture> &p_colors) {
-
- emission_color_texture = p_colors;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_color, p_colors);
- _queue_shader_change();
-}
-
-void ParticlesMaterial::set_emission_point_count(int p_count) {
-
- emission_point_count = p_count;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_point_count, p_count);
-}
-
-ParticlesMaterial::EmissionShape ParticlesMaterial::get_emission_shape() const {
-
- return emission_shape;
-}
-
-float ParticlesMaterial::get_emission_sphere_radius() const {
-
- return emission_sphere_radius;
-}
-Vector3 ParticlesMaterial::get_emission_box_extents() const {
-
- return emission_box_extents;
-}
-Ref<Texture> ParticlesMaterial::get_emission_point_texture() const {
-
- return emission_point_texture;
-}
-Ref<Texture> ParticlesMaterial::get_emission_normal_texture() const {
-
- return emission_normal_texture;
-}
-
-Ref<Texture> ParticlesMaterial::get_emission_color_texture() const {
-
- return emission_color_texture;
-}
-
-int ParticlesMaterial::get_emission_point_count() const {
-
- return emission_point_count;
-}
-
-void ParticlesMaterial::set_trail_divisor(int p_divisor) {
-
- trail_divisor = p_divisor;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_divisor, p_divisor);
-}
-
-int ParticlesMaterial::get_trail_divisor() const {
-
- return trail_divisor;
-}
-
-void ParticlesMaterial::set_trail_size_modifier(const Ref<CurveTexture> &p_trail_size_modifier) {
-
- trail_size_modifier = p_trail_size_modifier;
-
- Ref<CurveTexture> curve = trail_size_modifier;
- if (curve.is_valid()) {
- curve->ensure_default_setup();
- }
-
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_size_modifier, curve);
- _queue_shader_change();
-}
-
-Ref<CurveTexture> ParticlesMaterial::get_trail_size_modifier() const {
-
- return trail_size_modifier;
-}
-
-void ParticlesMaterial::set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier) {
-
- trail_color_modifier = p_trail_color_modifier;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_color_modifier, p_trail_color_modifier);
- _queue_shader_change();
-}
-
-Ref<GradientTexture> ParticlesMaterial::get_trail_color_modifier() const {
-
- return trail_color_modifier;
-}
-
-void ParticlesMaterial::set_gravity(const Vector3 &p_gravity) {
-
- gravity = p_gravity;
- Vector3 gset = gravity;
- if (gset == Vector3()) {
- gset = Vector3(0, -0.000001, 0); //as gravity is used as upvector in some calculations
- }
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->gravity, gset);
-}
-
-Vector3 ParticlesMaterial::get_gravity() const {
-
- return gravity;
-}
-
-RID ParticlesMaterial::get_shader_rid() const {
-
- ERR_FAIL_COND_V(!shader_map.has(current_key), RID());
- return shader_map[current_key].shader;
-}
-
-void ParticlesMaterial::_validate_property(PropertyInfo &property) const {
-
- if (property.name == "color" && color_ramp.is_valid()) {
- property.usage = 0;
- }
-
- if (property.name == "emission_sphere_radius" && emission_shape != EMISSION_SHAPE_SPHERE) {
- property.usage = 0;
- }
-
- if (property.name == "emission_box_extents" && emission_shape != EMISSION_SHAPE_BOX) {
- property.usage = 0;
- }
-
- if ((property.name == "emission_point_texture" || property.name == "emission_color_texture") && (emission_shape < EMISSION_SHAPE_POINTS)) {
- property.usage = 0;
- }
-
- if (property.name == "emission_normal_texture" && emission_shape != EMISSION_SHAPE_DIRECTED_POINTS) {
- property.usage = 0;
- }
-
- if (property.name == "emission_point_count" && (emission_shape != EMISSION_SHAPE_POINTS && emission_shape != EMISSION_SHAPE_DIRECTED_POINTS)) {
- property.usage = 0;
- }
-
- if (property.name.begins_with("orbit_") && !flags[FLAG_DISABLE_Z]) {
- property.usage = 0;
- }
-}
-
-Shader::Mode ParticlesMaterial::get_shader_mode() const {
-
- return Shader::MODE_PARTICLES;
-}
-
-void ParticlesMaterial::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_spread", "degrees"), &ParticlesMaterial::set_spread);
- ClassDB::bind_method(D_METHOD("get_spread"), &ParticlesMaterial::get_spread);
-
- ClassDB::bind_method(D_METHOD("set_flatness", "amount"), &ParticlesMaterial::set_flatness);
- ClassDB::bind_method(D_METHOD("get_flatness"), &ParticlesMaterial::get_flatness);
-
- ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &ParticlesMaterial::set_param);
- ClassDB::bind_method(D_METHOD("get_param", "param"), &ParticlesMaterial::get_param);
-
- ClassDB::bind_method(D_METHOD("set_param_randomness", "param", "randomness"), &ParticlesMaterial::set_param_randomness);
- ClassDB::bind_method(D_METHOD("get_param_randomness", "param"), &ParticlesMaterial::get_param_randomness);
-
- ClassDB::bind_method(D_METHOD("set_param_texture", "param", "texture"), &ParticlesMaterial::set_param_texture);
- ClassDB::bind_method(D_METHOD("get_param_texture", "param"), &ParticlesMaterial::get_param_texture);
-
- ClassDB::bind_method(D_METHOD("set_color", "color"), &ParticlesMaterial::set_color);
- ClassDB::bind_method(D_METHOD("get_color"), &ParticlesMaterial::get_color);
-
- ClassDB::bind_method(D_METHOD("set_color_ramp", "ramp"), &ParticlesMaterial::set_color_ramp);
- ClassDB::bind_method(D_METHOD("get_color_ramp"), &ParticlesMaterial::get_color_ramp);
-
- ClassDB::bind_method(D_METHOD("set_flag", "flag", "enable"), &ParticlesMaterial::set_flag);
- ClassDB::bind_method(D_METHOD("get_flag", "flag"), &ParticlesMaterial::get_flag);
-
- ClassDB::bind_method(D_METHOD("set_emission_shape", "shape"), &ParticlesMaterial::set_emission_shape);
- ClassDB::bind_method(D_METHOD("get_emission_shape"), &ParticlesMaterial::get_emission_shape);
-
- ClassDB::bind_method(D_METHOD("set_emission_sphere_radius", "radius"), &ParticlesMaterial::set_emission_sphere_radius);
- ClassDB::bind_method(D_METHOD("get_emission_sphere_radius"), &ParticlesMaterial::get_emission_sphere_radius);
-
- ClassDB::bind_method(D_METHOD("set_emission_box_extents", "extents"), &ParticlesMaterial::set_emission_box_extents);
- ClassDB::bind_method(D_METHOD("get_emission_box_extents"), &ParticlesMaterial::get_emission_box_extents);
-
- ClassDB::bind_method(D_METHOD("set_emission_point_texture", "texture"), &ParticlesMaterial::set_emission_point_texture);
- ClassDB::bind_method(D_METHOD("get_emission_point_texture"), &ParticlesMaterial::get_emission_point_texture);
-
- ClassDB::bind_method(D_METHOD("set_emission_normal_texture", "texture"), &ParticlesMaterial::set_emission_normal_texture);
- ClassDB::bind_method(D_METHOD("get_emission_normal_texture"), &ParticlesMaterial::get_emission_normal_texture);
-
- ClassDB::bind_method(D_METHOD("set_emission_color_texture", "texture"), &ParticlesMaterial::set_emission_color_texture);
- ClassDB::bind_method(D_METHOD("get_emission_color_texture"), &ParticlesMaterial::get_emission_color_texture);
-
- ClassDB::bind_method(D_METHOD("set_emission_point_count", "point_count"), &ParticlesMaterial::set_emission_point_count);
- ClassDB::bind_method(D_METHOD("get_emission_point_count"), &ParticlesMaterial::get_emission_point_count);
-
- ClassDB::bind_method(D_METHOD("set_trail_divisor", "divisor"), &ParticlesMaterial::set_trail_divisor);
- ClassDB::bind_method(D_METHOD("get_trail_divisor"), &ParticlesMaterial::get_trail_divisor);
-
- ClassDB::bind_method(D_METHOD("set_trail_size_modifier", "texture"), &ParticlesMaterial::set_trail_size_modifier);
- ClassDB::bind_method(D_METHOD("get_trail_size_modifier"), &ParticlesMaterial::get_trail_size_modifier);
-
- ClassDB::bind_method(D_METHOD("set_trail_color_modifier", "texture"), &ParticlesMaterial::set_trail_color_modifier);
- ClassDB::bind_method(D_METHOD("get_trail_color_modifier"), &ParticlesMaterial::get_trail_color_modifier);
-
- ClassDB::bind_method(D_METHOD("get_gravity"), &ParticlesMaterial::get_gravity);
- ClassDB::bind_method(D_METHOD("set_gravity", "accel_vec"), &ParticlesMaterial::set_gravity);
-
- ADD_GROUP("Trail", "trail_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "trail_divisor", PROPERTY_HINT_RANGE, "1,1000000,1"), "set_trail_divisor", "get_trail_divisor");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trail_size_modifier", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_trail_size_modifier", "get_trail_size_modifier");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trail_color_modifier", PROPERTY_HINT_RESOURCE_TYPE, "GradientTexture"), "set_trail_color_modifier", "get_trail_color_modifier");
- ADD_GROUP("Emission Shape", "emission_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_shape", PROPERTY_HINT_ENUM, "Point,Sphere,Box,Points,Directed Points"), "set_emission_shape", "get_emission_shape");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_sphere_radius", PROPERTY_HINT_RANGE, "0.01,128,0.01,or_greater"), "set_emission_sphere_radius", "get_emission_sphere_radius");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_box_extents"), "set_emission_box_extents", "get_emission_box_extents");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_point_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_point_texture", "get_emission_point_texture");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_normal_texture", "get_emission_normal_texture");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_color_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_color_texture", "get_emission_color_texture");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_point_count", PROPERTY_HINT_RANGE, "0,1000000,1"), "set_emission_point_count", "get_emission_point_count");
- ADD_GROUP("Flags", "flag_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_align_y"), "set_flag", "get_flag", FLAG_ALIGN_Y_TO_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_rotate_y"), "set_flag", "get_flag", FLAG_ROTATE_Y);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_disable_z"), "set_flag", "get_flag", FLAG_DISABLE_Z);
- ADD_GROUP("Spread", "");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "spread", PROPERTY_HINT_RANGE, "0,180,0.01"), "set_spread", "get_spread");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "flatness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_flatness", "get_flatness");
- ADD_GROUP("Gravity", "");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity"), "set_gravity", "get_gravity");
- ADD_GROUP("Initial Velocity", "initial_");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "initial_velocity", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_INITIAL_LINEAR_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "initial_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_INITIAL_LINEAR_VELOCITY);
- ADD_GROUP("Angular Velocity", "angular_");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity", PROPERTY_HINT_RANGE, "-360,360,0.01"), "set_param", "get_param", PARAM_ANGULAR_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGULAR_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angular_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANGULAR_VELOCITY);
- ADD_GROUP("Orbit Velocity", "orbit_");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "orbit_velocity", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_ORBIT_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "orbit_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ORBIT_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "orbit_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ORBIT_VELOCITY);
- ADD_GROUP("Linear Accel", "linear_");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_accel", PROPERTY_HINT_RANGE, "-100,100,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_LINEAR_ACCEL);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_accel_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_LINEAR_ACCEL);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "linear_accel_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_LINEAR_ACCEL);
- ADD_GROUP("Radial Accel", "radial_");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "radial_accel", PROPERTY_HINT_RANGE, "-100,100,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_RADIAL_ACCEL);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "radial_accel_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_RADIAL_ACCEL);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "radial_accel_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_RADIAL_ACCEL);
- ADD_GROUP("Tangential Accel", "tangential_");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "tangential_accel", PROPERTY_HINT_RANGE, "-100,100,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_TANGENTIAL_ACCEL);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "tangential_accel_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_TANGENTIAL_ACCEL);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "tangential_accel_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_TANGENTIAL_ACCEL);
- ADD_GROUP("Damping", "");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "damping", PROPERTY_HINT_RANGE, "0,100,0.01,or_greater"), "set_param", "get_param", PARAM_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "damping_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "damping_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_DAMPING);
- ADD_GROUP("Angle", "");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angle", PROPERTY_HINT_RANGE, "-720,720,0.1,or_lesser,or_greater"), "set_param", "get_param", PARAM_ANGLE);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angle_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGLE);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angle_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANGLE);
- ADD_GROUP("Scale", "");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_SCALE);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_SCALE);
- ADD_GROUP("Color", "");
- ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_ramp", PROPERTY_HINT_RESOURCE_TYPE, "GradientTexture"), "set_color_ramp", "get_color_ramp");
-
- ADD_GROUP("Hue Variation", "hue_");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hue_variation", PROPERTY_HINT_RANGE, "-1,1,0.1"), "set_param", "get_param", PARAM_HUE_VARIATION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hue_variation_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_HUE_VARIATION);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "hue_variation_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_HUE_VARIATION);
- ADD_GROUP("Animation", "anim_");
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anim_speed", PROPERTY_HINT_RANGE, "0,128,0.01,or_greater"), "set_param", "get_param", PARAM_ANIM_SPEED);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anim_speed_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANIM_SPEED);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anim_speed_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANIM_SPEED);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anim_offset", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_ANIM_OFFSET);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anim_offset_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANIM_OFFSET);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anim_offset_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANIM_OFFSET);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "anim_loop"), "set_flag", "get_flag", FLAG_ANIM_LOOP);
-
- BIND_ENUM_CONSTANT(PARAM_INITIAL_LINEAR_VELOCITY);
- BIND_ENUM_CONSTANT(PARAM_ANGULAR_VELOCITY);
- BIND_ENUM_CONSTANT(PARAM_ORBIT_VELOCITY);
- BIND_ENUM_CONSTANT(PARAM_LINEAR_ACCEL);
- BIND_ENUM_CONSTANT(PARAM_RADIAL_ACCEL);
- BIND_ENUM_CONSTANT(PARAM_TANGENTIAL_ACCEL);
- BIND_ENUM_CONSTANT(PARAM_DAMPING);
- BIND_ENUM_CONSTANT(PARAM_ANGLE);
- BIND_ENUM_CONSTANT(PARAM_SCALE);
- BIND_ENUM_CONSTANT(PARAM_HUE_VARIATION);
- BIND_ENUM_CONSTANT(PARAM_ANIM_SPEED);
- BIND_ENUM_CONSTANT(PARAM_ANIM_OFFSET);
- BIND_ENUM_CONSTANT(PARAM_MAX);
-
- BIND_ENUM_CONSTANT(FLAG_ALIGN_Y_TO_VELOCITY);
- BIND_ENUM_CONSTANT(FLAG_ROTATE_Y);
- BIND_ENUM_CONSTANT(FLAG_MAX);
-
- BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINT);
- BIND_ENUM_CONSTANT(EMISSION_SHAPE_SPHERE);
- BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX);
- BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
- BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
-}
-
-ParticlesMaterial::ParticlesMaterial() :
- element(this) {
-
- set_spread(45);
- set_flatness(0);
- set_param(PARAM_INITIAL_LINEAR_VELOCITY, 1);
- set_param(PARAM_ORBIT_VELOCITY, 0);
- set_param(PARAM_LINEAR_ACCEL, 0);
- set_param(PARAM_RADIAL_ACCEL, 0);
- set_param(PARAM_TANGENTIAL_ACCEL, 0);
- set_param(PARAM_DAMPING, 0);
- set_param(PARAM_ANGLE, 0);
- set_param(PARAM_SCALE, 1);
- set_param(PARAM_HUE_VARIATION, 0);
- set_param(PARAM_ANIM_SPEED, 0);
- set_param(PARAM_ANIM_OFFSET, 0);
- set_emission_shape(EMISSION_SHAPE_POINT);
- set_emission_sphere_radius(1);
- set_emission_box_extents(Vector3(1, 1, 1));
- set_trail_divisor(1);
- set_gravity(Vector3(0, -9.8, 0));
- emission_point_count = 1;
-
- for (int i = 0; i < PARAM_MAX; i++) {
- set_param_randomness(Parameter(i), 0);
- }
-
- for (int i = 0; i < FLAG_MAX; i++) {
- flags[i] = false;
- }
-
- set_color(Color(1, 1, 1, 1));
-
- current_key.key = 0;
- current_key.invalid_key = 1;
-
- _queue_shader_change();
-}
-
-ParticlesMaterial::~ParticlesMaterial() {
-
- if (material_mutex)
- material_mutex->lock();
-
- if (shader_map.has(current_key)) {
- shader_map[current_key].users--;
- if (shader_map[current_key].users == 0) {
- //deallocate shader, as it's no longer in use
- VS::get_singleton()->free(shader_map[current_key].shader);
- shader_map.erase(current_key);
- }
-
- VS::get_singleton()->material_set_shader(_get_material(), RID());
- }
-
- if (material_mutex)
- material_mutex->unlock();
-}
diff --git a/scene/3d/particles.h b/scene/3d/particles.h
index 17e21c6cee..72241c5c89 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/particles.h
@@ -28,12 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef VISUALINSTANCEPARTICLES_H
-#define VISUALINSTANCEPARTICLES_H
+#ifndef PARTICLES_H
+#define PARTICLES_H
-#include "rid.h"
+#include "core/rid.h"
#include "scene/3d/visual_instance.h"
-#include "scene/main/timer.h"
#include "scene/resources/material.h"
/**
@@ -135,269 +134,4 @@ public:
VARIANT_ENUM_CAST(Particles::DrawOrder)
-class ParticlesMaterial : public Material {
-
- GDCLASS(ParticlesMaterial, Material)
-
-public:
- enum Parameter {
-
- PARAM_INITIAL_LINEAR_VELOCITY,
- PARAM_ANGULAR_VELOCITY,
- PARAM_ORBIT_VELOCITY,
- PARAM_LINEAR_ACCEL,
- PARAM_RADIAL_ACCEL,
- PARAM_TANGENTIAL_ACCEL,
- PARAM_DAMPING,
- PARAM_ANGLE,
- PARAM_SCALE,
- PARAM_HUE_VARIATION,
- PARAM_ANIM_SPEED,
- PARAM_ANIM_OFFSET,
- PARAM_MAX
- };
-
- enum Flags {
- FLAG_ALIGN_Y_TO_VELOCITY,
- FLAG_ROTATE_Y,
- FLAG_DISABLE_Z,
- FLAG_ANIM_LOOP,
- FLAG_MAX
- };
-
- enum EmissionShape {
- EMISSION_SHAPE_POINT,
- EMISSION_SHAPE_SPHERE,
- EMISSION_SHAPE_BOX,
- EMISSION_SHAPE_POINTS,
- EMISSION_SHAPE_DIRECTED_POINTS,
- };
-
-private:
- union MaterialKey {
-
- struct {
- uint32_t texture_mask : 16;
- uint32_t texture_color : 1;
- uint32_t flags : 4;
- uint32_t emission_shape : 2;
- uint32_t trail_size_texture : 1;
- uint32_t trail_color_texture : 1;
- uint32_t invalid_key : 1;
- uint32_t has_emission_color : 1;
- };
-
- uint32_t key;
-
- bool operator<(const MaterialKey &p_key) const {
- return key < p_key.key;
- }
- };
-
- struct ShaderData {
- RID shader;
- int users;
- };
-
- static Map<MaterialKey, ShaderData> shader_map;
-
- MaterialKey current_key;
-
- _FORCE_INLINE_ MaterialKey _compute_key() const {
-
- MaterialKey mk;
- mk.key = 0;
- for (int i = 0; i < PARAM_MAX; i++) {
- if (tex_parameters[i].is_valid()) {
- mk.texture_mask |= (1 << i);
- }
- }
- for (int i = 0; i < FLAG_MAX; i++) {
- if (flags[i]) {
- mk.flags |= (1 << i);
- }
- }
-
- mk.texture_color = color_ramp.is_valid() ? 1 : 0;
- mk.emission_shape = emission_shape;
- mk.trail_color_texture = trail_color_modifier.is_valid() ? 1 : 0;
- mk.trail_size_texture = trail_size_modifier.is_valid() ? 1 : 0;
- mk.has_emission_color = emission_shape >= EMISSION_SHAPE_POINTS && emission_color_texture.is_valid();
-
- return mk;
- }
-
- static Mutex *material_mutex;
- static SelfList<ParticlesMaterial>::List dirty_materials;
-
- struct ShaderNames {
- StringName spread;
- StringName flatness;
- StringName initial_linear_velocity;
- StringName initial_angle;
- StringName angular_velocity;
- StringName orbit_velocity;
- StringName linear_accel;
- StringName radial_accel;
- StringName tangent_accel;
- StringName damping;
- StringName scale;
- StringName hue_variation;
- StringName anim_speed;
- StringName anim_offset;
-
- StringName initial_linear_velocity_random;
- StringName initial_angle_random;
- StringName angular_velocity_random;
- StringName orbit_velocity_random;
- StringName linear_accel_random;
- StringName radial_accel_random;
- StringName tangent_accel_random;
- StringName damping_random;
- StringName scale_random;
- StringName hue_variation_random;
- StringName anim_speed_random;
- StringName anim_offset_random;
-
- StringName angle_texture;
- StringName angular_velocity_texture;
- StringName orbit_velocity_texture;
- StringName linear_accel_texture;
- StringName radial_accel_texture;
- StringName tangent_accel_texture;
- StringName damping_texture;
- StringName scale_texture;
- StringName hue_variation_texture;
- StringName anim_speed_texture;
- StringName anim_offset_texture;
-
- StringName color;
- StringName color_ramp;
-
- StringName emission_sphere_radius;
- StringName emission_box_extents;
- StringName emission_texture_point_count;
- StringName emission_texture_points;
- StringName emission_texture_normal;
- StringName emission_texture_color;
-
- StringName trail_divisor;
- StringName trail_size_modifier;
- StringName trail_color_modifier;
-
- StringName gravity;
- };
-
- static ShaderNames *shader_names;
-
- SelfList<ParticlesMaterial> element;
-
- void _update_shader();
- _FORCE_INLINE_ void _queue_shader_change();
- _FORCE_INLINE_ bool _is_shader_dirty() const;
-
- float spread;
- float flatness;
-
- float parameters[PARAM_MAX];
- float randomness[PARAM_MAX];
-
- Ref<Texture> tex_parameters[PARAM_MAX];
- Color color;
- Ref<Texture> color_ramp;
-
- bool flags[FLAG_MAX];
-
- EmissionShape emission_shape;
- float emission_sphere_radius;
- Vector3 emission_box_extents;
- Ref<Texture> emission_point_texture;
- Ref<Texture> emission_normal_texture;
- Ref<Texture> emission_color_texture;
- int emission_point_count;
-
- bool anim_loop;
-
- int trail_divisor;
-
- Ref<CurveTexture> trail_size_modifier;
- Ref<GradientTexture> trail_color_modifier;
-
- Vector3 gravity;
-
- //do not save emission points here
-
-protected:
- static void _bind_methods();
- virtual void _validate_property(PropertyInfo &property) const;
-
-public:
- void set_spread(float p_spread);
- float get_spread() const;
-
- void set_flatness(float p_flatness);
- float get_flatness() const;
-
- void set_param(Parameter p_param, float p_value);
- float get_param(Parameter p_param) const;
-
- void set_param_randomness(Parameter p_param, float p_value);
- float get_param_randomness(Parameter p_param) const;
-
- void set_param_texture(Parameter p_param, const Ref<Texture> &p_texture);
- Ref<Texture> get_param_texture(Parameter p_param) const;
-
- void set_color(const Color &p_color);
- Color get_color() const;
-
- void set_color_ramp(const Ref<Texture> &p_texture);
- Ref<Texture> get_color_ramp() const;
-
- void set_flag(Flags p_flag, bool p_enable);
- bool get_flag(Flags p_flag) const;
-
- void set_emission_shape(EmissionShape p_shape);
- void set_emission_sphere_radius(float p_radius);
- void set_emission_box_extents(Vector3 p_extents);
- void set_emission_point_texture(const Ref<Texture> &p_points);
- void set_emission_normal_texture(const Ref<Texture> &p_normals);
- void set_emission_color_texture(const Ref<Texture> &p_colors);
- void set_emission_point_count(int p_count);
-
- EmissionShape get_emission_shape() const;
- float get_emission_sphere_radius() const;
- Vector3 get_emission_box_extents() const;
- Ref<Texture> get_emission_point_texture() const;
- Ref<Texture> get_emission_normal_texture() const;
- Ref<Texture> get_emission_color_texture() const;
- int get_emission_point_count() const;
-
- void set_trail_divisor(int p_divisor);
- int get_trail_divisor() const;
-
- void set_trail_size_modifier(const Ref<CurveTexture> &p_trail_size_modifier);
- Ref<CurveTexture> get_trail_size_modifier() const;
-
- void set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier);
- Ref<GradientTexture> get_trail_color_modifier() const;
-
- void set_gravity(const Vector3 &p_gravity);
- Vector3 get_gravity() const;
-
- static void init_shaders();
- static void finish_shaders();
- static void flush_changes();
-
- RID get_shader_rid() const;
-
- virtual Shader::Mode get_shader_mode() const;
-
- ParticlesMaterial();
- ~ParticlesMaterial();
-};
-
-VARIANT_ENUM_CAST(ParticlesMaterial::Parameter)
-VARIANT_ENUM_CAST(ParticlesMaterial::Flags)
-VARIANT_ENUM_CAST(ParticlesMaterial::EmissionShape)
-
-#endif
+#endif // PARTICLES_H
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index 9acaa15641..e37efa0e8a 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -30,7 +30,7 @@
#include "path.h"
-#include "engine.h"
+#include "core/engine.h"
#include "scene/scene_string_names.h"
void Path::_notification(int p_what) {
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 441f2f2549..0fb0869979 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -31,8 +31,8 @@
#include "physics_body.h"
#include "core/core_string_names.h"
-#include "engine.h"
-#include "method_bind_ext.gen.inc"
+#include "core/engine.h"
+#include "core/method_bind_ext.gen.inc"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
@@ -171,6 +171,10 @@ PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode) :
#ifndef DISABLE_DEPRECATED
void StaticBody::set_friction(real_t p_friction) {
+ if (p_friction == 1.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_friction has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
@@ -197,6 +201,10 @@ real_t StaticBody::get_friction() const {
void StaticBody::set_bounce(real_t p_bounce) {
+ if (p_bounce == 0.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
@@ -288,7 +296,7 @@ void StaticBody::_bind_methods() {
ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_linear_velocity"), "set_constant_linear_velocity", "get_constant_linear_velocity");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity");
}
@@ -407,7 +415,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (in_tree)
- emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exited, node);
}
contact_monitor->body_map.erase(E);
@@ -606,8 +614,13 @@ real_t RigidBody::get_weight() const {
#ifndef DISABLE_DEPRECATED
void RigidBody::set_friction(real_t p_friction) {
+ if (p_friction == 1.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_friction has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
+
ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
if (physics_material_override.is_null()) {
@@ -620,6 +633,7 @@ real_t RigidBody::get_friction() const {
ERR_EXPLAIN("The method get_friction has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
+
if (physics_material_override.is_null()) {
return 1;
}
@@ -628,8 +642,14 @@ real_t RigidBody::get_friction() const {
}
void RigidBody::set_bounce(real_t p_bounce) {
+
+ if (p_bounce == 0.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
+
ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
if (physics_material_override.is_null()) {
@@ -989,7 +1009,7 @@ void RigidBody::_bind_methods() {
ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), "set_gravity_scale", "get_gravity_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), "set_use_custom_integrator", "is_using_custom_integrator");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "continuous_cd"), "set_use_continuous_collision_detection", "is_using_continuous_collision_detection");
@@ -1011,10 +1031,10 @@ void RigidBody::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "-1,128,0.01"), "set_angular_damp", "get_angular_damp");
- ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
- ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
- ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body")));
- ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body")));
+ ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
+ ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
+ ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
+ ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
BIND_ENUM_CONSTANT(MODE_RIGID);
@@ -2267,6 +2287,8 @@ void PhysicalBone::_reload_joint() {
}
} break;
+ case JOINT_TYPE_NONE: {
+ } break;
}
}
@@ -2322,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();
@@ -2485,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/physics_body.h b/scene/3d/physics_body.h
index c4db41f577..ca48b51ffb 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -31,11 +31,11 @@
#ifndef PHYSICS_BODY__H
#define PHYSICS_BODY__H
+#include "core/vset.h"
#include "scene/3d/collision_object.h"
#include "scene/resources/physics_material.h"
#include "servers/physics_server.h"
#include "skeleton.h"
-#include "vset.h"
class PhysicsBody : public CollisionObject {
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index d16d9ed7c5..137338d79e 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "portal.h"
-#include "project_settings.h"
+#include "core/project_settings.h"
#include "scene/resources/surface_tool.h"
#include "servers/visual_server.h"
diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group.cpp
index 101d9ed70c..f56f728d99 100644
--- a/scene/3d/proximity_group.cpp
+++ b/scene/3d/proximity_group.cpp
@@ -30,7 +30,7 @@
#include "proximity_group.h"
-#include "math_funcs.h"
+#include "core/math/math_funcs.h"
void ProximityGroup::clear_groups() {
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index b846a5b6c0..17f069bbc8 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -31,7 +31,7 @@
#include "ray_cast.h"
#include "collision_object.h"
-#include "engine.h"
+#include "core/engine.h"
#include "mesh_instance.h"
#include "servers/physics_server.h"
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 0d83a9942e..3914d7190e 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -34,8 +34,8 @@
// FIXME: Will be removed, kept as reference for new implementation
#if 0
-#include "geometry.h"
-#include "project_settings.h"
+#include "core/math/geometry.h"
+#include "core/project_settings.h"
#include "scene/resources/surface_tool.h"
void Room::_notification(int p_what) {
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index c796e47f25..db82ef2a5c 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -30,7 +30,7 @@
#include "skeleton.h"
-#include "message_queue.h"
+#include "core/message_queue.h"
#include "core/project_settings.h"
#include "scene/3d/physics_body.h"
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index e044e08437..07abdc1fe7 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -31,7 +31,7 @@
#ifndef SKELETON_H
#define SKELETON_H
-#include "rid.h"
+#include "core/rid.h"
#include "scene/3d/spatial.h"
/**
diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp
index 58ddb52760..4ebc941ebc 100644
--- a/scene/3d/soft_body.cpp
+++ b/scene/3d/soft_body.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "soft_body.h"
-#include "os/os.h"
+#include "core/os/os.h"
#include "scene/3d/collision_object.h"
#include "scene/3d/skeleton.h"
#include "servers/physics_server.h"
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 3f494264e7..fcc908cdc6 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -30,8 +30,8 @@
#include "spatial.h"
-#include "engine.h"
-#include "message_queue.h"
+#include "core/engine.h"
+#include "core/message_queue.h"
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
@@ -185,10 +185,8 @@ void Spatial::_notification(int p_what) {
if (data.gizmo.is_valid()) {
data.gizmo->create();
- if (data.gizmo->can_draw()) {
- if (is_visible_in_tree()) {
- data.gizmo->redraw();
- }
+ if (is_visible_in_tree()) {
+ data.gizmo->redraw();
}
data.gizmo->transform();
}
@@ -423,10 +421,8 @@ void Spatial::set_gizmo(const Ref<SpatialGizmo> &p_gizmo) {
if (data.gizmo.is_valid() && is_inside_world()) {
data.gizmo->create();
- if (data.gizmo->can_draw()) {
- if (is_visible_in_tree()) {
- data.gizmo->redraw();
- }
+ if (is_visible_in_tree()) {
+ data.gizmo->redraw();
}
data.gizmo->transform();
}
@@ -452,12 +448,10 @@ void Spatial::_update_gizmo() {
return;
data.gizmo_dirty = false;
if (data.gizmo.is_valid()) {
- if (data.gizmo->can_draw()) {
- if (is_visible_in_tree())
- data.gizmo->redraw();
- else
- data.gizmo->clear();
- }
+ if (is_visible_in_tree())
+ data.gizmo->redraw();
+ else
+ data.gizmo->clear();
}
#endif
}
@@ -727,6 +721,16 @@ bool Spatial::is_local_transform_notification_enabled() const {
return data.notify_local_transform;
}
+void Spatial::force_update_transform() {
+ ERR_FAIL_COND(!is_inside_tree());
+ if (!xform_change.in_list()) {
+ return; //nothing to update
+ }
+ get_tree()->xform_change_list.remove(&xform_change);
+
+ notification(NOTIFICATION_TRANSFORM_CHANGED);
+}
+
void Spatial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_transform", "local"), &Spatial::set_transform);
@@ -749,6 +753,8 @@ void Spatial::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_scale_disabled"), &Spatial::is_scale_disabled);
ClassDB::bind_method(D_METHOD("get_world"), &Spatial::get_world);
+ ClassDB::bind_method(D_METHOD("force_update_transform"), &Spatial::force_update_transform);
+
ClassDB::bind_method(D_METHOD("_update_gizmo"), &Spatial::_update_gizmo);
ClassDB::bind_method(D_METHOD("update_gizmo"), &Spatial::update_gizmo);
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index bc054a8763..815ca16bc5 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -48,7 +48,6 @@ public:
virtual void clear() = 0;
virtual void redraw() = 0;
virtual void free() = 0;
- virtual bool can_draw() const = 0;
SpatialGizmo();
virtual ~SpatialGizmo() {}
@@ -203,6 +202,8 @@ public:
void hide();
bool is_visible_in_tree() const;
+ void force_update_transform();
+
Spatial();
~Spatial();
};
diff --git a/scene/3d/spatial_velocity_tracker.cpp b/scene/3d/spatial_velocity_tracker.cpp
index d96b003a81..3850a0c7e6 100644
--- a/scene/3d/spatial_velocity_tracker.cpp
+++ b/scene/3d/spatial_velocity_tracker.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "spatial_velocity_tracker.h"
-#include "engine.h"
+#include "core/engine.h"
void SpatialVelocityTracker::set_track_physics_step(bool p_track_physics_step) {
diff --git a/scene/3d/spring_arm.cpp b/scene/3d/spring_arm.cpp
index 492c6b806e..f74784c2f9 100644
--- a/scene/3d/spring_arm.cpp
+++ b/scene/3d/spring_arm.cpp
@@ -29,15 +29,16 @@
/*************************************************************************/
#include "spring_arm.h"
-#include "engine.h"
+#include "core/engine.h"
#include "scene/3d/collision_object.h"
#include "scene/resources/sphere_shape.h"
#include "servers/physics_server.h"
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/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 036a748c83..774ee49af2 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "sprite_3d.h"
-#include "core_string_names.h"
+#include "core/core_string_names.h"
#include "scene/scene_string_names.h"
Color SpriteBase3D::_get_color_accum() {
@@ -431,7 +431,7 @@ void Sprite3D::_draw() {
};
- Vector2 src_tsize = Vector2(texture->get_width(), texture->get_height());
+ Vector2 src_tsize = tsize;
// Properly setup UVs for impostor textures (AtlasTexture).
Ref<AtlasTexture> atlas_tex = texture;
@@ -441,10 +441,10 @@ void Sprite3D::_draw() {
}
Vector2 uvs[4] = {
- final_src_rect.position / tsize,
- (final_src_rect.position + Vector2(final_src_rect.size.x, 0)) / tsize,
- (final_src_rect.position + final_src_rect.size) / tsize,
- (final_src_rect.position + Vector2(0, final_src_rect.size.y)) / tsize,
+ final_src_rect.position / src_tsize,
+ (final_src_rect.position + Vector2(final_src_rect.size.x, 0)) / src_tsize,
+ (final_src_rect.position + final_src_rect.size) / src_tsize,
+ (final_src_rect.position + Vector2(0, final_src_rect.size.y)) / src_tsize,
};
if (is_flipped_h()) {
@@ -731,7 +731,7 @@ void AnimatedSprite3D::_draw() {
};
- Vector2 src_tsize = Vector2(texture->get_width(), texture->get_height());
+ Vector2 src_tsize = tsize;
// Properly setup UVs for impostor textures (AtlasTexture).
Ref<AtlasTexture> atlas_tex = texture;
@@ -741,10 +741,10 @@ void AnimatedSprite3D::_draw() {
}
Vector2 uvs[4] = {
- final_src_rect.position / tsize,
- (final_src_rect.position + Vector2(final_src_rect.size.x, 0)) / tsize,
- (final_src_rect.position + final_src_rect.size) / tsize,
- (final_src_rect.position + Vector2(0, final_src_rect.size.y)) / tsize,
+ final_src_rect.position / src_tsize,
+ (final_src_rect.position + Vector2(final_src_rect.size.x, 0)) / src_tsize,
+ (final_src_rect.position + final_src_rect.size) / src_tsize,
+ (final_src_rect.position + Vector2(0, final_src_rect.size.y)) / src_tsize,
};
if (is_flipped_h()) {
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp
index f9d096633c..56a86b6a17 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body.cpp
@@ -562,7 +562,7 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
b2invmass);
// FIXME: rel_vel assignment here is overwritten by the following assignment.
- // What seemes to be intended in the next next assignment is: rel_vel = normal.dot(rel_vel);
+ // What seems to be intended in the next next assignment is: rel_vel = normal.dot(rel_vel);
// Investigate why.
real_t rel_vel = jac.getRelativeVelocity(
s->get_linear_velocity(),
diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp
index 9d6e4941f3..c69387d082 100644
--- a/scene/3d/visibility_notifier.cpp
+++ b/scene/3d/visibility_notifier.cpp
@@ -30,7 +30,7 @@
#include "visibility_notifier.h"
-#include "engine.h"
+#include "core/engine.h"
#include "scene/3d/camera.h"
#include "scene/3d/physics_body.h"
#include "scene/animation/animation_player.h"
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/3d/visual_instance.h b/scene/3d/visual_instance.h
index 9249bc04ce..784f2a358a 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -31,8 +31,8 @@
#ifndef VISUAL_INSTANCE_H
#define VISUAL_INSTANCE_H
-#include "face3.h"
-#include "rid.h"
+#include "core/math/face3.h"
+#include "core/rid.h"
#include "scene/3d/spatial.h"
#include "scene/resources/material.h"
/**
diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp
index e846e1763d..651a057392 100644
--- a/scene/3d/voxel_light_baker.cpp
+++ b/scene/3d/voxel_light_baker.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "voxel_light_baker.h"
-#include "os/os.h"
-#include "os/threaded_array_processor.h"
+#include "core/os/os.h"
+#include "core/os/threaded_array_processor.h"
#include <stdlib.h>
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_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp
index f3a76b950e..f5f899a6cd 100644
--- a/scene/animation/animation_blend_space_2d.cpp
+++ b/scene/animation/animation_blend_space_2d.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "animation_blend_space_2d.h"
-#include "math/delaunay.h"
+#include "core/math/delaunay.h"
void AnimationNodeBlendSpace2D::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::VECTOR2, blend_position));
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index 837723450c..5923ad7657 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -320,7 +320,7 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm,
}
if (!_travel(sm, start_request)) {
- //cant travel, then teleport
+ //can't travel, then teleport
path.clear();
current = start_request;
}
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index d8db1973d2..102f05a146 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -30,8 +30,8 @@
#include "animation_player.h"
-#include "engine.h"
-#include "message_queue.h"
+#include "core/engine.h"
+#include "core/message_queue.h"
#include "scene/scene_string_names.h"
#include "servers/audio/audio_stream.h"
#ifdef TOOLS_ENABLED
@@ -263,43 +263,36 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
key.id = id;
key.bone_idx = bone_idx;
- if (node_cache_map.has(key)) {
-
- p_anim->node_cache.write[i] = &node_cache_map[key];
- } else {
-
+ if (!node_cache_map.has(key))
node_cache_map[key] = TrackNodeCache();
- p_anim->node_cache.write[i] = &node_cache_map[key];
- p_anim->node_cache[i]->path = a->track_get_path(i);
- p_anim->node_cache[i]->node = child;
- p_anim->node_cache[i]->resource = resource;
- p_anim->node_cache[i]->node_2d = Object::cast_to<Node2D>(child);
- if (a->track_get_type(i) == Animation::TYPE_TRANSFORM) {
- // special cases and caches for transform tracks
-
- // cache spatial
- p_anim->node_cache[i]->spatial = Object::cast_to<Spatial>(child);
- // cache skeleton
- p_anim->node_cache[i]->skeleton = Object::cast_to<Skeleton>(child);
- if (p_anim->node_cache[i]->skeleton) {
-
- if (a->track_get_path(i).get_subname_count() == 1) {
- StringName bone_name = a->track_get_path(i).get_subname(0);
-
- p_anim->node_cache[i]->bone_idx = p_anim->node_cache[i]->skeleton->find_bone(bone_name);
- if (p_anim->node_cache[i]->bone_idx < 0) {
- // broken track (nonexistent bone)
- p_anim->node_cache[i]->skeleton = NULL;
- p_anim->node_cache[i]->spatial = NULL;
- printf("bone is %ls\n", String(bone_name).c_str());
- ERR_CONTINUE(p_anim->node_cache[i]->bone_idx < 0);
- } else {
- }
- } else {
- // no property, just use spatialnode
+ p_anim->node_cache.write[i] = &node_cache_map[key];
+ p_anim->node_cache[i]->path = a->track_get_path(i);
+ p_anim->node_cache[i]->node = child;
+ p_anim->node_cache[i]->resource = resource;
+ p_anim->node_cache[i]->node_2d = Object::cast_to<Node2D>(child);
+ if (a->track_get_type(i) == Animation::TYPE_TRANSFORM) {
+ // special cases and caches for transform tracks
+
+ // cache spatial
+ p_anim->node_cache[i]->spatial = Object::cast_to<Spatial>(child);
+ // cache skeleton
+ p_anim->node_cache[i]->skeleton = Object::cast_to<Skeleton>(child);
+ if (p_anim->node_cache[i]->skeleton) {
+ if (a->track_get_path(i).get_subname_count() == 1) {
+ StringName bone_name = a->track_get_path(i).get_subname(0);
+
+ p_anim->node_cache[i]->bone_idx = p_anim->node_cache[i]->skeleton->find_bone(bone_name);
+ if (p_anim->node_cache[i]->bone_idx < 0) {
+ // broken track (nonexistent bone)
p_anim->node_cache[i]->skeleton = NULL;
+ p_anim->node_cache[i]->spatial = NULL;
+ printf("bone is %ls\n", String(bone_name).c_str());
+ ERR_CONTINUE(p_anim->node_cache[i]->bone_idx < 0);
}
+ } else {
+ // no property, just use spatialnode
+ p_anim->node_cache[i]->skeleton = NULL;
}
}
}
@@ -426,7 +419,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
if (first_key_time == 0.0) {
//ignore, use for transition
if (key_count == 1)
- continue; //with one key we cant do anything
+ continue; //with one key we can't do anything
transition = a->track_get_key_transition(i, 0);
first_key_time = a->track_get_key_time(i, 1);
first_key = 1;
@@ -1458,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.cpp b/scene/animation/animation_tree.cpp
index 9b06d538e9..eb00f91bb3 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -29,9 +29,10 @@
/*************************************************************************/
#include "animation_tree.h"
+
#include "animation_blend_tree.h"
+#include "core/engine.h"
#include "core/method_bind_ext.gen.inc"
-#include "engine.h"
#include "scene/scene_string_names.h"
#include "servers/audio/audio_stream.h"
@@ -191,7 +192,7 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
case FILTER_IGNORE:
break; //will not happen anyway
case FILTER_PASS: {
- //values filtered pass, the rest dont
+ //values filtered pass, the rest don't
for (int i = 0; i < blend_count; i++) {
if (blendw[i] == 0) //not filtered, does not pass
continue;
@@ -205,7 +206,7 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
} break;
case FILTER_STOP: {
- //values filtered dont pass, the rest are blended
+ //values filtered don't pass, the rest are blended
for (int i = 0; i < blend_count; i++) {
if (blendw[i] > 0) //filtered, does not pass
@@ -291,7 +292,7 @@ String AnimationNode::get_caption() const {
}
void AnimationNode::add_input(const String &p_name) {
- //root nodes cant add inputs
+ //root nodes can't add inputs
ERR_FAIL_COND(Object::cast_to<AnimationRootNode>(this) != NULL)
Input input;
ERR_FAIL_COND(p_name.find(".") != -1 || p_name.find("/") != -1);
@@ -1226,7 +1227,7 @@ void AnimationTree::_process_graph(float p_delta) {
t->object->set_indexed(t->subpath, t->value);
} break;
- default: {} //the rest dont matter
+ default: {} //the rest don't matter
}
}
}
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/root_motion_view.cpp b/scene/animation/root_motion_view.cpp
index 098bd05e9a..01a10dbc2b 100644
--- a/scene/animation/root_motion_view.cpp
+++ b/scene/animation/root_motion_view.cpp
@@ -112,7 +112,7 @@ void RootMotionView::_notification(int p_what) {
first = false;
- transform.orthonormalize(); //dont want scale, too imprecise
+ transform.orthonormalize(); //don't want scale, too imprecise
transform.affine_invert();
accumulated = transform * accumulated;
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 58be636e44..3521782417 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -29,7 +29,8 @@
/*************************************************************************/
#include "tween.h"
-#include "method_bind_ext.gen.inc"
+
+#include "core/method_bind_ext.gen.inc"
void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5, const Variant &p_arg6, const Variant &p_arg7, const Variant &p_arg8, const Variant &p_arg9, const Variant &p_arg10) {
@@ -276,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;
}
@@ -312,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: {
@@ -324,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;
}
@@ -673,6 +680,10 @@ float Tween::get_speed_scale() const {
}
bool Tween::start() {
+ if (pending_update != 0) {
+ call_deferred("start");
+ return true;
+ }
set_active(true);
return true;
@@ -852,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 11f2b0c17f..0000000000
--- a/scene/animation/tween_interpolaters.cpp
+++ /dev/null
@@ -1,332 +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. */
-/*************************************************************************/
-
-#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/audio/audio_player.cpp b/scene/audio/audio_player.cpp
index 7a9f2bd8d0..64af7efb16 100644
--- a/scene/audio/audio_player.cpp
+++ b/scene/audio/audio_player.cpp
@@ -30,7 +30,7 @@
#include "audio_player.h"
-#include "engine.h"
+#include "core/engine.h"
void AudioStreamPlayer::_mix_internal(bool p_fadeout) {
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 d17ae1d84c..71fb97c2c6 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -30,7 +30,7 @@
#include "base_button.h"
-#include "os/keyboard.h"
+#include "core/os/keyboard.h"
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
@@ -315,6 +315,14 @@ void BaseButton::set_disabled(bool p_disabled) {
return;
status.disabled = p_disabled;
+ if (p_disabled) {
+ if (!toggle_mode) {
+ status.pressed = false;
+ }
+ status.press_attempt = false;
+ status.pressing_inside = false;
+ status.pressing_button = 0;
+ }
update();
_change_notify("disabled");
}
@@ -360,7 +368,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 +546,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 a34f2f1ad5..2d17fb1391 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "button.h"
+#include "core/translation.h"
#include "servers/visual_server.h"
-#include "translation.h"
Size2 Button::get_minimum_size() const {
@@ -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/check_button.cpp b/scene/gui/check_button.cpp
index f9ed0ecdbb..fa9538da28 100644
--- a/scene/gui/check_button.cpp
+++ b/scene/gui/check_button.cpp
@@ -30,7 +30,7 @@
#include "check_button.h"
-#include "print_string.h"
+#include "core/print_string.h"
#include "servers/visual_server.h"
Size2 CheckButton::get_icon_size() const {
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 8e232c6f46..03eee9c6d8 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -30,9 +30,14 @@
#include "color_picker.h"
-#include "os/input.h"
-#include "os/keyboard.h"
-#include "os/os.h"
+#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/container.cpp b/scene/gui/container.cpp
index 7df03bf7c6..d606629041 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "container.h"
-#include "message_queue.h"
+#include "core/message_queue.h"
#include "scene/scene_string_names.h"
void Container::_child_minsize_changed() {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index e094a063be..dc18895298 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -29,15 +29,15 @@
/*************************************************************************/
#include "control.h"
-#include "project_settings.h"
+#include "core/project_settings.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/viewport.h"
#include "servers/visual_server.h"
-#include "message_queue.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "print_string.h"
+#include "core/message_queue.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
#include "scene/gui/label.h"
#include "scene/gui/panel.h"
#include "scene/scene_string_names.h"
@@ -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 {
@@ -2062,8 +2062,11 @@ void Control::grab_focus() {
if (!is_inside_tree()) {
ERR_FAIL_COND(!is_inside_tree());
}
- if (data.focus_mode == FOCUS_NONE)
+
+ if (data.focus_mode == FOCUS_NONE) {
+ WARN_PRINT("This control can't grab focus. Use set_focus_mode() to allow a control to get focus.");
return;
+ }
get_viewport()->_gui_control_grab_focus(this);
}
@@ -2874,7 +2877,7 @@ void Control::_bind_methods() {
ADD_GROUP("Mouse", "mouse_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mouse_filter", PROPERTY_HINT_ENUM, "Stop,Pass,Ignore"), "set_mouse_filter", "get_mouse_filter");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "mouse_default_cursor_shape", PROPERTY_HINT_ENUM, "Arrow,Ibeam,Pointing hand,Cross,Wait,Busy,Drag,Can drop,Forbidden,Vertical resize,Horizontal resize,Secondary diagonal resize,Main diagonal resize,Move,Vertial split,Horizontal split,Help"), "set_default_cursor_shape", "get_default_cursor_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mouse_default_cursor_shape", PROPERTY_HINT_ENUM, "Arrow,Ibeam,Pointing hand,Cross,Wait,Busy,Drag,Can drop,Forbidden,Vertical resize,Horizontal resize,Secondary diagonal resize,Main diagonal resize,Move,Vertical split,Horizontal split,Help"), "set_default_cursor_shape", "get_default_cursor_shape");
ADD_GROUP("Size Flags", "size_flags_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "size_flags_horizontal", PROPERTY_HINT_FLAGS, "Fill,Expand,Shrink Center,Shrink End"), "set_h_size_flags", "get_h_size_flags");
@@ -2956,7 +2959,7 @@ void Control::_bind_methods() {
BIND_ENUM_CONSTANT(ANCHOR_END);
ADD_SIGNAL(MethodInfo("resized"));
- ADD_SIGNAL(MethodInfo("gui_input", PropertyInfo(Variant::OBJECT, "ev", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
+ ADD_SIGNAL(MethodInfo("gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ADD_SIGNAL(MethodInfo("mouse_entered"));
ADD_SIGNAL(MethodInfo("mouse_exited"));
ADD_SIGNAL(MethodInfo("focus_entered"));
diff --git a/scene/gui/control.h b/scene/gui/control.h
index c6bd2f097d..eb39d9ca0f 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -31,13 +31,13 @@
#ifndef CONTROL_H
#define CONTROL_H
-#include "rid.h"
+#include "core/math/transform_2d.h"
+#include "core/rid.h"
#include "scene/2d/canvas_item.h"
#include "scene/gui/shortcut.h"
#include "scene/main/node.h"
#include "scene/main/timer.h"
#include "scene/resources/theme.h"
-#include "transform_2d.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -76,7 +76,7 @@ public:
SIZE_EXPAND = 2,
SIZE_EXPAND_FILL = SIZE_EXPAND | SIZE_FILL,
SIZE_SHRINK_CENTER = 4, //ignored by expand or fill
- SIZE_SHRINK_END = 8, //ignored by expand or fil
+ SIZE_SHRINK_END = 8, //ignored by expand or fill
};
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index d9737fa21a..e3a21eb10d 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "dialogs.h"
+#include "core/print_string.h"
+#include "core/translation.h"
#include "line_edit.h"
-#include "print_string.h"
-#include "translation.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 9bddaa7d29..1e9f4df4a3 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "file_dialog.h"
-#include "os/keyboard.h"
-#include "print_string.h"
+#include "core/os/keyboard.h"
+#include "core/print_string.h"
#include "scene/gui/label.h"
FileDialog::GetIconFunc FileDialog::get_icon_func = NULL;
@@ -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/file_dialog.h b/scene/gui/file_dialog.h
index 3227f1c3a8..8bd15080d3 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -32,7 +32,7 @@
#define FILE_DIALOG_H
#include "box_container.h"
-#include "os/dir_access.h"
+#include "core/os/dir_access.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/option_button.h"
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index e82c0c4ad1..19ffe681ef 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -29,7 +29,10 @@
/*************************************************************************/
#include "gradient_edit.h"
-#include "os/keyboard.h"
+#include "core/os/keyboard.h"
+#include "editor/editor_scale.h"
+
+#define SPACING (3 * EDSCALE)
GradientEdit::GradientEdit() {
grabbed = -1;
@@ -49,11 +52,15 @@ GradientEdit::GradientEdit() {
int GradientEdit::_get_point_from_pos(int x) {
int result = -1;
- int total_w = get_size().width - get_size().height - 3;
+ int total_w = get_size().width - get_size().height - SPACING;
+ float min_distance = 1e20;
for (int i = 0; i < points.size(); i++) {
//Check if we clicked at point
- if (ABS(x - points[i].offset * total_w + 1) < (POINT_WIDTH / 2 + 1)) {
+ float distance = ABS(x - points[i].offset * total_w);
+ float min = (POINT_WIDTH / 2 * 1.7); //make it easier to grab
+ if (distance <= min && distance < min_distance) {
result = i;
+ min_distance = distance;
}
}
return result;
@@ -63,7 +70,16 @@ void GradientEdit::_show_color_picker() {
if (grabbed == -1)
return;
picker->set_pick_color(points[grabbed].color);
- popup->set_position(get_global_position() - popup->get_combined_minimum_size());
+ Size2 minsize = popup->get_combined_minimum_size();
+ bool show_above = false;
+ if (get_global_position().y + get_size().y + minsize.y > get_viewport_rect().size.y) {
+ show_above = true;
+ }
+ if (show_above) {
+ popup->set_position(get_global_position() - Vector2(0, minsize.y));
+ } else {
+ popup->set_position(get_global_position() + Vector2(0, get_size().y));
+ }
popup->popup();
}
@@ -112,7 +128,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
grabbed = _get_point_from_pos(x);
if (grabbed != -1) {
- int total_w = get_size().width - get_size().height - 3;
+ int total_w = get_size().width - get_size().height - SPACING;
Gradient::Point newPoint = points[grabbed];
newPoint.offset = CLAMP(x / float(total_w), 0, 1);
@@ -130,14 +146,15 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
}
+ //select
if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) {
update();
int x = mb->get_position().x;
- int total_w = get_size().width - get_size().height - 3;
+ int total_w = get_size().width - get_size().height - SPACING;
//Check if color selector was clicked.
- if (x > total_w + 3) {
+ if (x > total_w + SPACING) {
_show_color_picker();
return;
}
@@ -211,7 +228,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
if (mm.is_valid() && grabbing) {
- int total_w = get_size().width - get_size().height - 3;
+ int total_w = get_size().width - get_size().height - SPACING;
int x = mm->get_position().x;
@@ -286,7 +303,7 @@ void GradientEdit::_notification(int p_what) {
if (w == 0 || h == 0)
return; //Safety check. We have division by 'h'. And in any case there is nothing to draw with such size
- int total_w = get_size().width - get_size().height - 3;
+ int total_w = get_size().width - get_size().height - SPACING;
//Draw checker pattern for ramp
_draw_checker(0, 0, total_w, h);
@@ -335,27 +352,36 @@ void GradientEdit::_notification(int p_what) {
//Draw point markers
for (int i = 0; i < points.size(); i++) {
- Color col = i == grabbed ? Color(1, 0.0, 0.0, 0.9) : points[i].color.contrasted();
+ Color col = points[i].color.contrasted();
col.a = 0.9;
draw_line(Vector2(points[i].offset * total_w, 0), Vector2(points[i].offset * total_w, h / 2), col);
- draw_rect(Rect2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2, POINT_WIDTH, h / 2), Color(0.6, 0.6, 0.6, i == grabbed ? 0.9 : 0.4));
- draw_line(Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2), Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h - 1), col);
- draw_line(Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h / 2), Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h - 1), col);
- draw_line(Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2), Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h / 2), col);
- draw_line(Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h - 1), Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h - 1), col);
+ Rect2 rect = Rect2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2, POINT_WIDTH, h / 2);
+ draw_rect(rect, points[i].color, true);
+ draw_rect(rect, col, false);
+ if (grabbed == i) {
+ rect = rect.grow(-1);
+ if (has_focus()) {
+ draw_rect(rect, Color(1, 0, 0, 0.9), false);
+ } else {
+ draw_rect(rect, Color(0.6, 0, 0, 0.9), false);
+ }
+
+ rect = rect.grow(-1);
+ draw_rect(rect, col, false);
+ }
}
//Draw "button" for color selector
- _draw_checker(total_w + 3, 0, h, h);
+ _draw_checker(total_w + SPACING, 0, h, h);
if (grabbed != -1) {
//Draw with selection color
- draw_rect(Rect2(total_w + 3, 0, h, h), points[grabbed].color);
+ draw_rect(Rect2(total_w + SPACING, 0, h, h), points[grabbed].color);
} else {
//if no color selected draw grey color with 'X' on top.
- draw_rect(Rect2(total_w + 3, 0, h, h), Color(0.5, 0.5, 0.5, 1));
- draw_line(Vector2(total_w + 3, 0), Vector2(total_w + 3 + h, h), Color(1, 1, 1, 0.6));
- draw_line(Vector2(total_w + 3, h), Vector2(total_w + 3 + h, 0), Color(1, 1, 1, 0.6));
+ draw_rect(Rect2(total_w + SPACING, 0, h, h), Color(0.5, 0.5, 0.5, 1));
+ draw_line(Vector2(total_w + SPACING, 0), Vector2(total_w + SPACING + h, h), Color(1, 1, 1, 0.6));
+ draw_line(Vector2(total_w + SPACING, h), Vector2(total_w + SPACING + h, 0), Color(1, 1, 1, 0.6));
}
//Draw borders around color ramp if in focus
diff --git a/scene/gui/gradient_edit.h b/scene/gui/gradient_edit.h
index e7834ea0de..f6927ad0b7 100644
--- a/scene/gui/gradient_edit.h
+++ b/scene/gui/gradient_edit.h
@@ -36,7 +36,7 @@
#include "scene/resources/color_ramp.h"
#include "scene/resources/default_theme/theme_data.h"
-#define POINT_WIDTH 8
+#define POINT_WIDTH (8 * EDSCALE)
class GradientEdit : public Control {
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index a7163adbe6..0ffaac20f6 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -30,8 +30,8 @@
#include "graph_edit.h"
-#include "os/input.h"
-#include "os/keyboard.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
#include "scene/gui/box_container.h"
#define ZOOM_SCALE 1.2
@@ -1279,7 +1279,7 @@ void GraphEdit::_bind_methods() {
ADD_SIGNAL(MethodInfo("disconnection_request", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot")));
ADD_SIGNAL(MethodInfo("popup_request", PropertyInfo(Variant::VECTOR2, "p_position")));
ADD_SIGNAL(MethodInfo("duplicate_nodes_request"));
- ADD_SIGNAL(MethodInfo("node_selected", PropertyInfo(Variant::OBJECT, "node")));
+ ADD_SIGNAL(MethodInfo("node_selected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
ADD_SIGNAL(MethodInfo("delete_nodes_request"));
ADD_SIGNAL(MethodInfo("_begin_node_move"));
@@ -1304,7 +1304,7 @@ GraphEdit::GraphEdit() {
add_child(connections_layer);
connections_layer->connect("draw", this, "_connections_layer_draw");
connections_layer->set_name("CLAYER");
- connections_layer->set_disable_visibility_clip(true); // so it can draw freely and be offseted
+ connections_layer->set_disable_visibility_clip(true); // so it can draw freely and be offset
connections_layer->set_mouse_filter(MOUSE_FILTER_IGNORE);
h_scroll = memnew(HScrollBar);
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 24857d49fa..b189afd30b 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -29,7 +29,8 @@
/*************************************************************************/
#include "graph_node.h"
-#include "method_bind_ext.gen.inc"
+
+#include "core/method_bind_ext.gen.inc"
bool GraphNode::_set(const StringName &p_name, const Variant &p_value) {
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 9f5c12e87f..0d5fbee9ee 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "item_list.h"
-#include "os/os.h"
-#include "project_settings.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
void ItemList::add_item(const String &p_item, const Ref<Texture> &p_texture, bool p_selectable) {
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 0b36e1663c..91dab27930 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "label.h"
-#include "print_string.h"
-#include "project_settings.h"
-#include "translation.h"
+#include "core/print_string.h"
+#include "core/project_settings.h"
+#include "core/translation.h"
void Label::set_autowrap(bool p_autowrap) {
@@ -295,14 +295,13 @@ Size2 Label::get_minimum_size() const {
Size2 min_style = get_stylebox("normal")->get_minimum_size();
+ // don't want to mutable everything
+ if (word_cache_dirty)
+ const_cast<Label *>(this)->regenerate_word_cache();
+
if (autowrap)
return Size2(1, clip ? 1 : minsize.height) + min_style;
else {
-
- // don't want to mutable everything
- if (word_cache_dirty)
- const_cast<Label *>(this)->regenerate_word_cache();
-
Size2 ms = minsize;
if (clip)
ms.width = 1;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 1f3d5e6e13..9c43d5b308 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -29,12 +29,12 @@
/*************************************************************************/
#include "line_edit.h"
+#include "core/message_queue.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
+#include "core/translation.h"
#include "label.h"
-#include "message_queue.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "print_string.h"
-#include "translation.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
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/menu_button.cpp b/scene/gui/menu_button.cpp
index 87cf4dc334..95ec618c3b 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "menu_button.h"
-#include "os/keyboard.h"
+#include "core/os/keyboard.h"
#include "scene/main/viewport.h"
void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 2901176a69..6b847c6483 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "option_button.h"
-#include "print_string.h"
+#include "core/print_string.h"
Size2 OptionButton::get_minimum_size() const {
diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp
index 4375e03a50..d3b7b72ee1 100644
--- a/scene/gui/panel.cpp
+++ b/scene/gui/panel.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "panel.h"
-#include "print_string.h"
+#include "core/print_string.h"
void Panel::_notification(int p_what) {
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 26d01ecc09..bfbe62e1c7 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -30,8 +30,8 @@
#include "popup.h"
-#include "engine.h"
-#include "os/keyboard.h"
+#include "core/engine.h"
+#include "core/os/keyboard.h"
void Popup::_gui_input(Ref<InputEvent> p_event) {
}
@@ -234,15 +234,46 @@ String Popup::get_configuration_warning() const {
Popup::~Popup() {
}
-void PopupPanel::set_child_rect(Control *p_child) {
- ERR_FAIL_NULL(p_child);
+Size2 PopupPanel::get_minimum_size() const {
Ref<StyleBox> p = get_stylebox("panel");
- p_child->set_anchors_preset(Control::PRESET_WIDE);
- p_child->set_margin(MARGIN_LEFT, p->get_margin(MARGIN_LEFT));
- p_child->set_margin(MARGIN_RIGHT, -p->get_margin(MARGIN_RIGHT));
- p_child->set_margin(MARGIN_TOP, p->get_margin(MARGIN_TOP));
- p_child->set_margin(MARGIN_BOTTOM, -p->get_margin(MARGIN_BOTTOM));
+
+ Size2 ms;
+
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = Object::cast_to<Control>(get_child(i));
+ if (!c)
+ continue;
+
+ if (c->is_set_as_toplevel())
+ continue;
+
+ Size2 cms = c->get_combined_minimum_size();
+ ms.x = MAX(cms.x, ms.x);
+ ms.y = MAX(cms.y, ms.y);
+ }
+
+ return ms + p->get_minimum_size();
+}
+
+void PopupPanel::_update_child_rects() {
+
+ Ref<StyleBox> p = get_stylebox("panel");
+
+ Vector2 cpos(p->get_offset());
+ Vector2 csize(get_size() - p->get_minimum_size());
+
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = Object::cast_to<Control>(get_child(i));
+ if (!c)
+ continue;
+
+ if (c->is_set_as_toplevel())
+ continue;
+
+ c->set_position(cpos);
+ c->set_size(csize);
+ }
}
void PopupPanel::_notification(int p_what) {
@@ -250,6 +281,12 @@ void PopupPanel::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
get_stylebox("panel")->draw(get_canvas_item(), Rect2(Point2(), get_size()));
+ } else if (p_what == NOTIFICATION_READY) {
+
+ _update_child_rects();
+ } else if (p_what == NOTIFICATION_RESIZED) {
+
+ _update_child_rects();
}
}
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index 550e803578..5b1ef7d6ca 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -77,10 +77,12 @@ class PopupPanel : public Popup {
GDCLASS(PopupPanel, Popup);
protected:
+ void _update_child_rects();
void _notification(int p_what);
public:
void set_child_rect(Control *p_child);
+ virtual Size2 get_minimum_size() const;
PopupPanel();
};
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 436dda41a4..3239641c2f 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -29,10 +29,10 @@
/*************************************************************************/
#include "popup_menu.h"
-#include "os/input.h"
-#include "os/keyboard.h"
-#include "print_string.h"
-#include "translation.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
+#include "core/print_string.h"
+#include "core/translation.h"
String PopupMenu::_get_accel_text(int p_item) const {
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/reference_rect.cpp b/scene/gui/reference_rect.cpp
index 74e68598f4..e96e5afb2a 100644
--- a/scene/gui/reference_rect.cpp
+++ b/scene/gui/reference_rect.cpp
@@ -30,7 +30,7 @@
#include "reference_rect.h"
-#include "engine.h"
+#include "core/engine.h"
void ReferenceRect::_notification(int p_what) {
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index a5f9bea1b1..bb36852cf9 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -29,12 +29,13 @@
/*************************************************************************/
#include "rich_text_label.h"
-#include "os/keyboard.h"
-#include "os/os.h"
+
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
-#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#endif
RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) {
@@ -319,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) {
@@ -417,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;
@@ -468,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);
}
}
@@ -496,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;
@@ -834,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()) {
@@ -853,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");
@@ -1226,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;
@@ -1423,18 +1450,28 @@ bool RichTextLabel::remove_line(const int p_line) {
if (p_line >= current_frame->lines.size() || p_line < 0)
return false;
- int lines = p_line * 2;
+ int i = 0;
+ while (i < current->subitems.size() && current->subitems[i]->line < p_line) {
+ i++;
+ }
- if (current->subitems[lines]->type != ITEM_NEWLINE)
- _remove_item(current->subitems[lines], current->subitems[lines]->line, lines);
+ bool was_newline = false;
+ while (i < current->subitems.size()) {
+ was_newline = current->subitems[i]->type == ITEM_NEWLINE;
+ _remove_item(current->subitems[i], current->subitems[i]->line, p_line);
+ if (was_newline)
+ break;
+ }
- _remove_item(current->subitems[lines], current->subitems[lines]->line, lines);
+ if (!was_newline) {
+ current_frame->lines.remove(p_line);
+ }
- if (p_line == 0) {
+ if (p_line == 0 && current->subitems.size() > 0)
main->lines.write[0].from = main;
- }
main->first_invalid_line = 0;
+
return true;
}
@@ -1447,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);
@@ -1455,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);
@@ -1463,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);
@@ -1672,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);
@@ -1738,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");
@@ -1752,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;
@@ -1765,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;
@@ -1809,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();
@@ -1827,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();
@@ -2134,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);
@@ -2194,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");
@@ -2222,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);
@@ -2285,7 +2326,7 @@ RichTextLabel::RichTextLabel() {
vscroll = memnew(VScrollBar);
add_child(vscroll);
- vscroll->set_drag_slave(String(".."));
+ vscroll->set_drag_node(String(".."));
vscroll->set_step(1);
vscroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
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_bar.cpp b/scene/gui/scroll_bar.cpp
index e5bd1c453d..07380f45cc 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -30,9 +30,9 @@
#include "scroll_bar.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "print_string.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
bool ScrollBar::focus_by_default = false;
@@ -300,24 +300,24 @@ void ScrollBar::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (has_node(drag_slave_path)) {
- Node *n = get_node(drag_slave_path);
- drag_slave = Object::cast_to<Control>(n);
+ if (has_node(drag_node_path)) {
+ Node *n = get_node(drag_node_path);
+ drag_node = Object::cast_to<Control>(n);
}
- if (drag_slave) {
- drag_slave->connect("gui_input", this, "_drag_slave_input");
- drag_slave->connect("tree_exiting", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
+ if (drag_node) {
+ drag_node->connect("gui_input", this, "_drag_node_input");
+ drag_node->connect("tree_exiting", this, "_drag_node_exit", varray(), CONNECT_ONESHOT);
}
}
if (p_what == NOTIFICATION_EXIT_TREE) {
- if (drag_slave) {
- drag_slave->disconnect("gui_input", this, "_drag_slave_input");
- drag_slave->disconnect("tree_exiting", this, "_drag_slave_exit");
+ if (drag_node) {
+ drag_node->disconnect("gui_input", this, "_drag_node_input");
+ drag_node->disconnect("tree_exiting", this, "_drag_node_exit");
}
- drag_slave = NULL;
+ drag_node = NULL;
}
if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
@@ -337,12 +337,13 @@ void ScrollBar::_notification(int p_what) {
scrolling = false;
set_physics_process_internal(false);
}
- } else if (drag_slave_touching) {
- if (drag_slave_touching_deaccel) {
+ } else if (drag_node_touching) {
+
+ if (drag_node_touching_deaccel) {
Vector2 pos = Vector2(orientation == HORIZONTAL ? get_value() : 0, orientation == VERTICAL ? get_value() : 0);
- pos += drag_slave_speed * get_physics_process_delta_time();
+ pos += drag_node_speed * get_physics_process_delta_time();
bool turnoff = false;
@@ -360,15 +361,15 @@ void ScrollBar::_notification(int p_what) {
set_value(pos.x);
- float sgn_x = drag_slave_speed.x < 0 ? -1 : 1;
- float val_x = Math::abs(drag_slave_speed.x);
+ float sgn_x = drag_node_speed.x < 0 ? -1 : 1;
+ float val_x = Math::abs(drag_node_speed.x);
val_x -= 1000 * get_physics_process_delta_time();
if (val_x < 0) {
turnoff = true;
}
- drag_slave_speed.x = sgn_x * val_x;
+ drag_node_speed.x = sgn_x * val_x;
} else {
@@ -384,29 +385,29 @@ void ScrollBar::_notification(int p_what) {
set_value(pos.y);
- float sgn_y = drag_slave_speed.y < 0 ? -1 : 1;
- float val_y = Math::abs(drag_slave_speed.y);
+ float sgn_y = drag_node_speed.y < 0 ? -1 : 1;
+ float val_y = Math::abs(drag_node_speed.y);
val_y -= 1000 * get_physics_process_delta_time();
if (val_y < 0) {
turnoff = true;
}
- drag_slave_speed.y = sgn_y * val_y;
+ drag_node_speed.y = sgn_y * val_y;
}
if (turnoff) {
set_physics_process_internal(false);
- drag_slave_touching = false;
- drag_slave_touching_deaccel = false;
+ drag_node_touching = false;
+ drag_node_touching_deaccel = false;
}
} else {
if (time_since_motion == 0 || time_since_motion > 0.1) {
- Vector2 diff = drag_slave_accum - last_drag_slave_accum;
- last_drag_slave_accum = drag_slave_accum;
- drag_slave_speed = diff / get_physics_process_delta_time();
+ Vector2 diff = drag_node_accum - last_drag_node_accum;
+ last_drag_node_accum = drag_node_accum;
+ drag_node_speed = diff / get_physics_process_delta_time();
}
time_since_motion += get_physics_process_delta_time();
@@ -544,15 +545,15 @@ float ScrollBar::get_custom_step() const {
return custom_step;
}
-void ScrollBar::_drag_slave_exit() {
+void ScrollBar::_drag_node_exit() {
- if (drag_slave) {
- drag_slave->disconnect("gui_input", this, "_drag_slave_input");
+ if (drag_node) {
+ drag_node->disconnect("gui_input", this, "_drag_node_input");
}
- drag_slave = NULL;
+ drag_node = NULL;
}
-void ScrollBar::_drag_slave_input(const Ref<InputEvent> &p_input) {
+void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseButton> mb = p_input;
@@ -563,43 +564,30 @@ void ScrollBar::_drag_slave_input(const Ref<InputEvent> &p_input) {
if (mb->is_pressed()) {
- if (drag_slave_touching) {
- set_physics_process_internal(false);
- drag_slave_touching_deaccel = false;
- drag_slave_touching = false;
- drag_slave_speed = Vector2();
- drag_slave_accum = Vector2();
- last_drag_slave_accum = Vector2();
- drag_slave_from = Vector2();
- }
+ drag_node_speed = Vector2();
+ drag_node_accum = Vector2();
+ last_drag_node_accum = Vector2();
+ drag_node_from = Vector2(orientation == HORIZONTAL ? get_value() : 0, orientation == VERTICAL ? get_value() : 0);
- if (true) {
- drag_slave_speed = Vector2();
- drag_slave_accum = Vector2();
- last_drag_slave_accum = Vector2();
- //drag_slave_from=Vector2(h_scroll->get_val(),v_scroll->get_val());
- drag_slave_from = Vector2(orientation == HORIZONTAL ? get_value() : 0, orientation == VERTICAL ? get_value() : 0);
+ drag_node_touching = OS::get_singleton()->has_touchscreen_ui_hint();
+ drag_node_touching_deaccel = false;
+ time_since_motion = 0;
- drag_slave_touching = OS::get_singleton()->has_touchscreen_ui_hint();
- drag_slave_touching_deaccel = false;
+ if (drag_node_touching) {
+ set_physics_process_internal(true);
time_since_motion = 0;
- if (drag_slave_touching) {
- set_physics_process_internal(true);
- time_since_motion = 0;
- }
}
} else {
- if (drag_slave_touching) {
+ if (drag_node_touching) {
- if (drag_slave_speed == Vector2()) {
- drag_slave_touching_deaccel = false;
- drag_slave_touching = false;
+ if (drag_node_speed == Vector2()) {
+ drag_node_touching_deaccel = false;
+ drag_node_touching = false;
set_physics_process_internal(false);
} else {
-
- drag_slave_touching_deaccel = true;
+ drag_node_touching_deaccel = true;
}
}
}
@@ -609,60 +597,54 @@ void ScrollBar::_drag_slave_input(const Ref<InputEvent> &p_input) {
if (mm.is_valid()) {
- if (drag_slave_touching && !drag_slave_touching_deaccel) {
+ if (drag_node_touching && !drag_node_touching_deaccel) {
Vector2 motion = Vector2(mm->get_relative().x, mm->get_relative().y);
- drag_slave_accum -= motion;
- Vector2 diff = drag_slave_from + drag_slave_accum;
+ drag_node_accum -= motion;
+ Vector2 diff = drag_node_from + drag_node_accum;
if (orientation == HORIZONTAL)
set_value(diff.x);
- /*
- else
- drag_slave_accum.x=0;
- */
+
if (orientation == VERTICAL)
set_value(diff.y);
- /*
- else
- drag_slave_accum.y=0;
- */
+
time_since_motion = 0;
}
}
}
-void ScrollBar::set_drag_slave(const NodePath &p_path) {
+void ScrollBar::set_drag_node(const NodePath &p_path) {
if (is_inside_tree()) {
- if (drag_slave) {
- drag_slave->disconnect("gui_input", this, "_drag_slave_input");
- drag_slave->disconnect("tree_exiting", this, "_drag_slave_exit");
+ if (drag_node) {
+ drag_node->disconnect("gui_input", this, "_drag_node_input");
+ drag_node->disconnect("tree_exiting", this, "_drag_node_exit");
}
}
- drag_slave = NULL;
- drag_slave_path = p_path;
+ drag_node = NULL;
+ drag_node_path = p_path;
if (is_inside_tree()) {
if (has_node(p_path)) {
Node *n = get_node(p_path);
- drag_slave = Object::cast_to<Control>(n);
+ drag_node = Object::cast_to<Control>(n);
}
- if (drag_slave) {
- drag_slave->connect("gui_input", this, "_drag_slave_input");
- drag_slave->connect("tree_exiting", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
+ if (drag_node) {
+ drag_node->connect("gui_input", this, "_drag_node_input");
+ drag_node->connect("tree_exiting", this, "_drag_node_exit", varray(), CONNECT_ONESHOT);
}
}
}
-NodePath ScrollBar::get_drag_slave() const {
+NodePath ScrollBar::get_drag_node() const {
- return drag_slave_path;
+ return drag_node_path;
}
void ScrollBar::set_smooth_scroll_enabled(bool p_enable) {
@@ -678,8 +660,8 @@ void ScrollBar::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollBar::_gui_input);
ClassDB::bind_method(D_METHOD("set_custom_step", "step"), &ScrollBar::set_custom_step);
ClassDB::bind_method(D_METHOD("get_custom_step"), &ScrollBar::get_custom_step);
- ClassDB::bind_method(D_METHOD("_drag_slave_input"), &ScrollBar::_drag_slave_input);
- ClassDB::bind_method(D_METHOD("_drag_slave_exit"), &ScrollBar::_drag_slave_exit);
+ ClassDB::bind_method(D_METHOD("_drag_node_input"), &ScrollBar::_drag_node_input);
+ ClassDB::bind_method(D_METHOD("_drag_node_exit"), &ScrollBar::_drag_node_exit);
ADD_SIGNAL(MethodInfo("scrolling"));
@@ -691,13 +673,13 @@ ScrollBar::ScrollBar(Orientation p_orientation) {
orientation = p_orientation;
highlight = HIGHLIGHT_NONE;
custom_step = -1;
- drag_slave = NULL;
+ drag_node = NULL;
drag.active = false;
- drag_slave_speed = Vector2();
- drag_slave_touching = false;
- drag_slave_touching_deaccel = false;
+ drag_node_speed = Vector2();
+ drag_node_touching = false;
+ drag_node_touching_deaccel = false;
scrolling = false;
target_scroll = 0;
diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h
index 15e037f8bb..cde4120cdb 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -36,6 +36,7 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
+
class ScrollBar : public Range {
GDCLASS(ScrollBar, Range);
@@ -71,25 +72,25 @@ class ScrollBar : public Range {
static void set_can_focus_by_default(bool p_can_focus);
- Node *drag_slave;
- NodePath drag_slave_path;
+ Node *drag_node;
+ NodePath drag_node_path;
- Vector2 drag_slave_speed;
- Vector2 drag_slave_accum;
- Vector2 drag_slave_from;
- Vector2 last_drag_slave_accum;
- float last_drag_slave_time;
+ Vector2 drag_node_speed;
+ Vector2 drag_node_accum;
+ Vector2 drag_node_from;
+ Vector2 last_drag_node_accum;
+ float last_drag_node_time;
float time_since_motion;
- bool drag_slave_touching;
- bool drag_slave_touching_deaccel;
+ bool drag_node_touching;
+ bool drag_node_touching_deaccel;
bool click_handled;
bool scrolling;
double target_scroll;
bool smooth_scroll_enabled;
- void _drag_slave_exit();
- void _drag_slave_input(const Ref<InputEvent> &p_input);
+ void _drag_node_exit();
+ void _drag_node_input(const Ref<InputEvent> &p_input);
void _gui_input(Ref<InputEvent> p_event);
@@ -102,8 +103,8 @@ public:
void set_custom_step(float p_custom_step);
float get_custom_step() const;
- void set_drag_slave(const NodePath &p_path);
- NodePath get_drag_slave() const;
+ void set_drag_node(const NodePath &p_path);
+ NodePath get_drag_node() const;
void set_smooth_scroll_enabled(bool p_enable);
bool is_smooth_scroll_enabled() const;
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 495d618930..26da16569a 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -29,7 +29,8 @@
/*************************************************************************/
#include "scroll_container.h"
-#include "os/os.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/shortcut.cpp b/scene/gui/shortcut.cpp
index 36490cf254..6fcf96f611 100644
--- a/scene/gui/shortcut.cpp
+++ b/scene/gui/shortcut.cpp
@@ -30,7 +30,7 @@
#include "shortcut.h"
-#include "os/keyboard.h"
+#include "core/os/keyboard.h"
void ShortCut::set_shortcut(const Ref<InputEvent> &p_shortcut) {
diff --git a/scene/gui/shortcut.h b/scene/gui/shortcut.h
index f9240642bf..7613a24e43 100644
--- a/scene/gui/shortcut.h
+++ b/scene/gui/shortcut.h
@@ -31,8 +31,8 @@
#ifndef SHORTCUT_H
#define SHORTCUT_H
-#include "os/input_event.h"
-#include "resource.h"
+#include "core/os/input_event.h"
+#include "core/resource.h"
class ShortCut : public Resource {
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index b820e2eafd..147c0518ec 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "slider.h"
-#include "os/keyboard.h"
+#include "core/os/keyboard.h"
Size2 Slider::get_minimum_size() const {
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 145981d498..f766c0722d 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "spin_box.h"
-#include "os/input.h"
+#include "core/os/input.h"
Size2 SpinBox::get_minimum_size() const {
@@ -217,6 +217,16 @@ void SpinBox::_notification(int p_what) {
}
}
+void SpinBox::set_align(LineEdit::Align p_align) {
+
+ line_edit->set_align(p_align);
+}
+
+LineEdit::Align SpinBox::get_align() const {
+
+ return line_edit->get_align();
+}
+
void SpinBox::set_suffix(const String &p_suffix) {
suffix = p_suffix;
@@ -253,6 +263,8 @@ void SpinBox::_bind_methods() {
//ClassDB::bind_method(D_METHOD("_value_changed"),&SpinBox::_value_changed);
ClassDB::bind_method(D_METHOD("_gui_input"), &SpinBox::_gui_input);
ClassDB::bind_method(D_METHOD("_text_entered"), &SpinBox::_text_entered);
+ ClassDB::bind_method(D_METHOD("set_align", "align"), &SpinBox::set_align);
+ ClassDB::bind_method(D_METHOD("get_align"), &SpinBox::get_align);
ClassDB::bind_method(D_METHOD("set_suffix", "suffix"), &SpinBox::set_suffix);
ClassDB::bind_method(D_METHOD("get_suffix"), &SpinBox::get_suffix);
ClassDB::bind_method(D_METHOD("set_prefix", "prefix"), &SpinBox::set_prefix);
@@ -264,6 +276,7 @@ void SpinBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("_line_edit_input"), &SpinBox::_line_edit_input);
ClassDB::bind_method(D_METHOD("_range_click_timeout"), &SpinBox::_range_click_timeout);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), "set_align", "get_align");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "prefix"), "set_prefix", "get_prefix");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "suffix"), "set_suffix", "get_suffix");
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h
index 8863f44bef..f1ee26d9f3 100644
--- a/scene/gui/spin_box.h
+++ b/scene/gui/spin_box.h
@@ -76,6 +76,9 @@ public:
virtual Size2 get_minimum_size() const;
+ void set_align(LineEdit::Align p_align);
+ LineEdit::Align get_align() const;
+
void set_editable(bool p_editable);
bool is_editable() const;
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index c30fa96327..4c354768fe 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -30,7 +30,7 @@
#include "tab_container.h"
-#include "message_queue.h"
+#include "core/message_queue.h"
#include "scene/gui/box_container.h"
#include "scene/gui/label.h"
#include "scene/gui/texture_rect.h"
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 2075f7ce70..c56b7d0f26 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -30,7 +30,7 @@
#include "tabs.h"
-#include "message_queue.h"
+#include "core/message_queue.h"
#include "scene/gui/box_container.h"
#include "scene/gui/label.h"
#include "scene/gui/texture_rect.h"
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index ec98b01ced..c390c60a8c 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -30,11 +30,11 @@
#include "text_edit.h"
-#include "message_queue.h"
-#include "os/input.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "project_settings.h"
+#include "core/message_queue.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
#include "scene/main/viewport.h"
#ifdef TOOLS_ENABLED
@@ -556,7 +556,6 @@ void TextEdit::_notification(int p_what) {
} break;
case NOTIFICATION_RESIZED: {
- cache.size = get_size();
_update_scrollbars();
update_wrap_at();
} break;
@@ -593,6 +592,7 @@ void TextEdit::_notification(int p_what) {
}
} break;
case NOTIFICATION_DRAW: {
+ Size2 size = get_size();
if ((!has_focus() && !menu->has_focus()) || !window_has_focus) {
draw_caret = false;
}
@@ -634,24 +634,22 @@ void TextEdit::_notification(int p_what) {
RID ci = get_canvas_item();
VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width;
- int xmargin_end = cache.size.width - cache.style_normal->get_margin(MARGIN_RIGHT);
+ int xmargin_end = size.width - cache.style_normal->get_margin(MARGIN_RIGHT);
//let's do it easy for now:
- cache.style_normal->draw(ci, Rect2(Point2(), cache.size));
+ cache.style_normal->draw(ci, Rect2(Point2(), size));
float readonly_alpha = 1.0; // used to set the input text color when in read-only mode
if (readonly) {
- cache.style_readonly->draw(ci, Rect2(Point2(), cache.size));
+ cache.style_readonly->draw(ci, Rect2(Point2(), size));
readonly_alpha = .5;
draw_caret = false;
}
if (has_focus())
- cache.style_focus->draw(ci, Rect2(Point2(), cache.size));
+ cache.style_focus->draw(ci, Rect2(Point2(), size));
int ascent = cache.font->get_ascent();
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;
@@ -1261,7 +1259,7 @@ void TextEdit::_notification(int p_what) {
if (line_length_guideline) {
int x = xmargin_beg + cache.font->get_char_size('0').width * line_length_guideline_col - cursor.x_ofs;
if (x > xmargin_beg && x < xmargin_end) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(x, 0), Point2(x, cache.size.height), cache.line_length_guideline_color);
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(x, 0), Point2(x, size.height), cache.line_length_guideline_color);
}
}
@@ -1942,7 +1940,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
int to_column = get_selection_to_column();
if (row < from_line || row > to_line || (row == from_line && col < from_column) || (row == to_line && col > to_column)) {
- // Right click is outside the seleted text
+ // Right click is outside the selected text
deselect();
}
}
@@ -3119,16 +3117,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (selection.active) {
int ini = selection.from_line;
int end = selection.to_line;
+
for (int i = ini; i <= end; i++) {
- if (get_line(i).begins_with("#"))
- _remove_text(i, 0, i, 1);
+ _uncomment_line(i);
}
} else {
- if (get_line(cursor.line).begins_with("#")) {
- _remove_text(cursor.line, 0, cursor.line, 1);
- if (cursor.column >= get_line(cursor.line).length()) {
- cursor.column = MAX(0, get_line(cursor.line).length() - 1);
- }
+ _uncomment_line(cursor.line);
+ if (cursor.column >= get_line(cursor.line).length()) {
+ cursor.column = MAX(0, get_line(cursor.line).length() - 1);
}
}
update();
@@ -3208,6 +3204,24 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
+void TextEdit::_uncomment_line(int p_line) {
+ String line_text = get_line(p_line);
+ for (int i = 0; i < line_text.length(); i++) {
+ if (line_text[i] == '#') {
+ _remove_text(p_line, i, p_line, i + 1);
+ if (p_line == selection.to_line && selection.to_column > line_text.length() - 1) {
+ selection.to_column -= 1;
+ if (selection.to_column >= selection.from_column) {
+ selection.active = false;
+ }
+ }
+ return;
+ } else if (line_text[i] != '\t' && line_text[i] != ' ') {
+ return;
+ }
+ }
+}
+
void TextEdit::_scroll_up(real_t p_delta) {
if (scrolling && smooth_scroll_enabled && SGN(target_v_scroll - v_scroll->get_value()) != SGN(-p_delta))
@@ -3609,7 +3623,7 @@ Size2 TextEdit::get_minimum_size() const {
int TextEdit::get_visible_rows() const {
- int total = cache.size.height;
+ int total = get_size().height;
total -= cache.style_normal->get_minimum_size().height;
if (h_scroll->is_visible_in_tree())
total -= h_scroll->get_size().height;
@@ -3636,7 +3650,7 @@ int TextEdit::get_total_visible_rows() const {
void TextEdit::update_wrap_at() {
- wrap_at = cache.size.width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width - wrap_right_offset;
+ wrap_at = get_size().width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width - wrap_right_offset;
update_cursor_wrap_offset();
text.clear_wrap_cache();
@@ -3670,7 +3684,7 @@ void TextEdit::adjust_viewport_to_cursor() {
set_line_as_last_visible(cur_line, cur_wrap);
}
- int visible_width = cache.size.width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width;
+ int visible_width = get_size().width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width;
if (v_scroll->is_visible_in_tree())
visible_width -= v_scroll->get_combined_minimum_size().width;
visible_width -= 20; // give it a little more space
@@ -3701,7 +3715,7 @@ void TextEdit::center_viewport_to_cursor() {
unfold_line(cursor.line);
set_line_as_center_visible(cursor.line, get_cursor_wrap_index());
- int visible_width = cache.size.width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width;
+ int visible_width = get_size().width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width;
if (v_scroll->is_visible_in_tree())
visible_width -= v_scroll->get_combined_minimum_size().width;
visible_width -= 20; // give it a little more space
@@ -3780,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);
@@ -4158,7 +4172,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
}
}
- return CURSOR_IBEAM;
+ return get_default_cursor_shape();
}
void TextEdit::set_text(String p_text) {
@@ -4386,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;
}
@@ -4531,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);
@@ -4822,28 +4840,27 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
pos = -1;
- int pos_from = 0;
+ int pos_from = (p_search_flags & SEARCH_BACKWARDS) ? text_line.length() : 0;
int last_pos = -1;
while (true) {
- while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.find(p_key, pos_from) : text_line.findn(p_key, pos_from)) != -1) {
-
- if (p_search_flags & SEARCH_BACKWARDS) {
-
- if (last_pos > from_column)
+ if (p_search_flags & SEARCH_BACKWARDS) {
+ while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.rfind(p_key, pos_from) : text_line.rfindn(p_key, pos_from)) != -1) {
+ if (last_pos <= from_column) {
+ pos = last_pos;
break;
- pos = last_pos;
-
- } else {
-
+ }
+ pos_from = last_pos - p_key.length();
+ }
+ } else {
+ while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.find(p_key, pos_from) : text_line.findn(p_key, pos_from)) != -1) {
if (last_pos >= from_column) {
pos = last_pos;
break;
}
+ pos_from = last_pos + p_key.length();
}
-
- pos_from = last_pos + p_key.length();
}
bool is_match = true;
@@ -4856,11 +4873,15 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
is_match = false;
}
+ if (pos_from == -1) {
+ pos = -1;
+ }
+
if (is_match || last_pos == -1 || pos == -1) {
break;
}
- pos_from = pos + 1;
+ pos_from = (p_search_flags & SEARCH_BACKWARDS) ? pos - 1 : pos + 1;
pos = -1;
}
@@ -5133,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;
@@ -5145,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)) {
@@ -5543,7 +5564,7 @@ int TextEdit::get_last_visible_line_wrap_index() const {
double TextEdit::get_visible_rows_offset() const {
- double total = cache.size.height;
+ double total = get_size().height;
total -= cache.style_normal->get_minimum_size().height;
if (h_scroll->is_visible_in_tree())
total -= h_scroll->get_size().height;
@@ -5847,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] == '\'') {
@@ -5910,6 +5931,9 @@ void TextEdit::set_line(int line, String new_text) {
if (cursor.line == line) {
cursor.column = MIN(cursor.column, new_text.length());
}
+ if (is_selection_active() && line == selection.to_line && selection.to_column > text[line].length()) {
+ selection.to_column = text[line].length();
+ }
}
void TextEdit::insert_at(const String &p_text, int at) {
@@ -6227,7 +6251,6 @@ TextEdit::TextEdit() {
set_focus_mode(FOCUS_ALL);
syntax_highlighter = NULL;
_update_caches();
- cache.size = Size2(1, 1);
cache.row_height = 1;
cache.line_spacing = 1;
cache.line_number_w = 1;
@@ -6235,6 +6258,7 @@ TextEdit::TextEdit() {
breakpoint_gutter_width = 0;
cache.fold_gutter_width = 0;
fold_gutter_width = 0;
+ set_default_cursor_shape(CURSOR_IBEAM);
indent_size = 4;
text.set_indent_size(indent_size);
@@ -6400,8 +6424,8 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int
is_hex_notation = false;
}
- // check for dot or underscore or 'x' for hex notation in floating point number
- if ((str[j] == '.' || str[j] == 'x' || str[j] == '_' || str[j] == 'f') && !in_word && prev_is_number && !is_number) {
+ // check for dot or underscore or 'x' for hex notation in floating point number or 'e' for scientific notation
+ if ((str[j] == '.' || str[j] == 'x' || str[j] == '_' || str[j] == 'f' || str[j] == 'e') && !in_word && prev_is_number && !is_number) {
is_number = true;
is_symbol = false;
is_char = false;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 19b5d574c6..f0c18ad047 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -193,7 +193,6 @@ private:
int line_number_w;
int breakpoint_gutter_width;
int fold_gutter_width;
- Size2 size;
} cache;
Map<int, int> color_region_cache;
@@ -373,6 +372,7 @@ private:
void _update_selection_mode_word();
void _update_selection_mode_line();
+ void _uncomment_line(int p_line);
void _scroll_up(real_t p_delta);
void _scroll_down(real_t p_delta);
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 ff90576c1b..d28b4065fb 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -30,7 +30,7 @@
#include "texture_progress.h"
-#include "engine.h"
+#include "core/engine.h"
void TextureProgress::set_under_texture(const Ref<Texture> &p_texture) {
@@ -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;
}
}
@@ -466,9 +488,9 @@ void TextureProgress::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_progress", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_progress_texture", "get_progress_texture");
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "fill_mode", PROPERTY_HINT_ENUM, "Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise,Bilinear (Left and Right),Bilinear (Top and Bottom), Clockwise and Counter Clockwise"), "set_fill_mode", "get_fill_mode");
ADD_GROUP("Tint", "tint_");
- ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_under", PROPERTY_HINT_COLOR_NO_ALPHA), "set_tint_under", "get_tint_under");
- ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_over", PROPERTY_HINT_COLOR_NO_ALPHA), "set_tint_over", "get_tint_over");
- ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_progress", PROPERTY_HINT_COLOR_NO_ALPHA), "set_tint_progress", "get_tint_progress");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_under"), "set_tint_under", "get_tint_under");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_over"), "set_tint_over", "get_tint_over");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_progress"), "set_tint_progress", "get_tint_progress");
ADD_GROUP("Radial Fill", "radial_");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_initial_angle", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), "set_radial_initial_angle", "get_radial_initial_angle");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_fill_degrees", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), "set_fill_degrees", "get_fill_degrees");
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 6f09488b64..3a540d187b 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -31,12 +31,12 @@
#include "tree.h"
#include <limits.h>
-#include "math_funcs.h"
-#include "os/input.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "print_string.h"
-#include "project_settings.h"
+#include "core/math/math_funcs.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
+#include "core/project_settings.h"
#include "scene/main/viewport.h"
#ifdef TOOLS_ENABLED
@@ -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) {
+ 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;
@@ -1721,7 +1718,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
if (p_button == BUTTON_LEFT || (p_button == BUTTON_RIGHT && allow_rmb_select)) {
/* process selection */
- if (p_doubleclick && (!c.editable || c.mode == TreeItem::CELL_MODE_CUSTOM || c.mode == TreeItem::CELL_MODE_ICON /*|| c.mode==TreeItem::CELL_MODE_CHECK*/)) { //it' s confusing for check
+ if (p_doubleclick && (!c.editable || c.mode == TreeItem::CELL_MODE_CUSTOM || c.mode == TreeItem::CELL_MODE_ICON /*|| c.mode==TreeItem::CELL_MODE_CHECK*/)) { //it's confusing for check
emit_signal("item_activated");
incr_search.clear();
@@ -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(); }
}
@@ -2239,13 +2219,13 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
_go_left();
}
- } else if (p_event->is_action("ui_up") && p_event->is_pressed()) {
+ } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !k->get_command()) {
if (!cursor_can_exit_tree) accept_event();
_go_up();
- } else if (p_event->is_action("ui_down") && p_event->is_pressed()) {
+ } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !k->get_command()) {
if (!cursor_can_exit_tree) accept_event();
@@ -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;
@@ -3831,16 +3807,16 @@ void Tree::_bind_methods() {
ADD_SIGNAL(MethodInfo("item_selected"));
ADD_SIGNAL(MethodInfo("cell_selected"));
- ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::OBJECT, "item"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::BOOL, "selected")));
+ ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::BOOL, "selected")));
ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::VECTOR2, "position")));
ADD_SIGNAL(MethodInfo("empty_tree_rmb_selected", PropertyInfo(Variant::VECTOR2, "position")));
ADD_SIGNAL(MethodInfo("item_edited"));
ADD_SIGNAL(MethodInfo("item_rmb_edited"));
ADD_SIGNAL(MethodInfo("item_custom_button_pressed"));
ADD_SIGNAL(MethodInfo("item_double_clicked"));
- ADD_SIGNAL(MethodInfo("item_collapsed", PropertyInfo(Variant::OBJECT, "item")));
+ ADD_SIGNAL(MethodInfo("item_collapsed", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem")));
//ADD_SIGNAL( MethodInfo("item_doubleclicked" ) );
- ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::OBJECT, "item"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::INT, "id")));
+ ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("custom_popup_edited", PropertyInfo(Variant::BOOL, "arrow_clicked")));
ADD_SIGNAL(MethodInfo("item_activated"));
ADD_SIGNAL(MethodInfo("column_title_pressed", PropertyInfo(Variant::INT, "column")));
@@ -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 5af66c5faa..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();
@@ -516,7 +512,7 @@ protected:
static void _bind_methods();
//bind helpers
- Object *_create_item(Object *p_parent, int p_idx = -1) {
+ TreeItem *_create_item(Object *p_parent, int p_idx = -1) {
return create_item(Object::cast_to<TreeItem>(p_parent), p_idx);
}
@@ -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 88e1847533..39e7c73390 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -31,7 +31,7 @@
#include "video_player.h"
#include "scene/scene_string_names.h"
-#include "os/os.h"
+#include "core/os/os.h"
#include "servers/audio_server.h"
int VideoPlayer::sp_get_channel_count() const {
@@ -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/http_request.cpp b/scene/main/http_request.cpp
index 4750e05633..a9b7fba9c7 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -330,15 +330,13 @@ bool HTTPRequest::_update_connection() {
return true;
}
- if (client->is_response_chunked()) {
- body_len = -1; // No body len because chunked, change your webserver configuration if you want body len
- } else {
- body_len = client->get_response_body_length();
+ // No body len (-1) if chunked or no content-length header was provided.
+ // Change your webserver configuration if you want body len.
+ body_len = client->get_response_body_length();
- if (body_size_limit >= 0 && body_len > body_size_limit) {
- call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PoolByteArray());
- return true;
- }
+ if (body_size_limit >= 0 && body_len > body_size_limit) {
+ call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PoolByteArray());
+ return true;
}
if (download_to_file != String()) {
@@ -378,6 +376,9 @@ bool HTTPRequest::_update_connection() {
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body);
return true;
}
+ } else if (client->get_status() == HTTPClient::STATUS_DISCONNECTED) {
+ // We read till EOF, with no errors. Request is done.
+ call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body);
}
return false;
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index eb5d020bc5..de09d2afda 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -31,10 +31,10 @@
#ifndef HTTPREQUEST_H
#define HTTPREQUEST_H
-#include "io/http_client.h"
+#include "core/io/http_client.h"
+#include "core/os/file_access.h"
+#include "core/os/thread.h"
#include "node.h"
-#include "os/file_access.h"
-#include "os/thread.h"
class HTTPRequest : public Node {
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index 1443d5efbf..0ee5648de2 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -30,7 +30,7 @@
#include "instance_placeholder.h"
-#include "io/resource_loader.h"
+#include "core/io/resource_loader.h"
#include "scene/resources/packed_scene.h"
bool InstancePlaceholder::_set(const StringName &p_name, const Variant &p_value) {
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index e30f58e012..d3282c6ada 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -31,10 +31,10 @@
#include "node.h"
#include "core/core_string_names.h"
+#include "core/io/resource_loader.h"
+#include "core/message_queue.h"
+#include "core/print_string.h"
#include "instance_placeholder.h"
-#include "io/resource_loader.h"
-#include "message_queue.h"
-#include "print_string.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
#include "viewport.h"
@@ -238,6 +238,16 @@ void Node::_propagate_enter_tree() {
// enter groups
}
+void Node::_propagate_after_exit_tree() {
+
+ data.blocked++;
+ for (int i = 0; i < data.children.size(); i++) {
+ data.children[i]->_propagate_after_exit_tree();
+ }
+ data.blocked--;
+ emit_signal(SceneStringNames::get_singleton()->tree_exited);
+}
+
void Node::_propagate_exit_tree() {
//block while removing children
@@ -299,8 +309,6 @@ void Node::_propagate_exit_tree() {
data.ready_notified = false;
data.tree = NULL;
data.depth = -1;
-
- emit_signal(SceneStringNames::get_singleton()->tree_exited);
}
void Node::move_child(Node *p_child, int p_pos) {
@@ -1207,6 +1215,10 @@ void Node::remove_child(Node *p_child) {
// validate owner
p_child->_propagate_validate_owner();
+
+ if (data.inside_tree) {
+ p_child->_propagate_after_exit_tree();
+ }
}
int Node::get_child_count() const {
@@ -1336,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);
@@ -2104,6 +2129,12 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
node->set(name, value);
}
+ List<GroupInfo> groups;
+ get_groups(&groups);
+
+ for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next())
+ node->add_to_group(E->get().name, E->get().persistent);
+
node->set_name(get_name());
p_new_parent->add_child(node);
@@ -2198,6 +2229,12 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
node->set(name, get(name));
}
+ List<GroupInfo> groups;
+ get_groups(&groups);
+
+ for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next())
+ node->add_to_group(E->get().name, E->get().persistent);
+
for (int i = 0; i < get_child_count(); i++) {
get_child(i)->_duplicate_and_reown(node, p_reown_map);
@@ -2605,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 f3422618ce..a7baebc9c2 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -31,13 +31,13 @@
#ifndef NODE_H
#define NODE_H
-#include "class_db.h"
-#include "map.h"
-#include "node_path.h"
-#include "object.h"
-#include "project_settings.h"
+#include "core/class_db.h"
+#include "core/map.h"
+#include "core/node_path.h"
+#include "core/object.h"
+#include "core/project_settings.h"
+#include "core/script_language.h"
#include "scene/main/scene_tree.h"
-#include "script_language.h"
class Viewport;
class SceneState;
@@ -166,6 +166,7 @@ private:
void _propagate_enter_tree();
void _propagate_ready();
void _propagate_exit_tree();
+ void _propagate_after_exit_tree();
void _propagate_validate_owner();
void _print_stray_nodes();
void _propagate_pause_owner(Node *p_owner);
@@ -256,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 1d23650a1e..fdbe3b57f0 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -30,16 +30,16 @@
#include "scene_tree.h"
+#include "core/io/marshalls.h"
+#include "core/io/resource_loader.h"
+#include "core/message_queue.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
+#include "core/project_settings.h"
#include "editor/editor_node.h"
-#include "io/marshalls.h"
-#include "io/resource_loader.h"
#include "main/input_default.h"
-#include "message_queue.h"
#include "node.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "print_string.h"
-#include "project_settings.h"
#include "scene/resources/dynamic_font.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
@@ -598,6 +598,7 @@ void SceneTree::finish() {
if (root) {
root->_set_tree(NULL);
+ root->_propagate_after_exit_tree();
memdelete(root); //delete root
}
}
@@ -1196,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());
@@ -1601,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;
@@ -1862,10 +1866,10 @@ void SceneTree::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "multiplayer_poll"), "set_multiplayer_poll_enabled", "is_multiplayer_poll_enabled");
ADD_SIGNAL(MethodInfo("tree_changed"));
- ADD_SIGNAL(MethodInfo("node_added", PropertyInfo(Variant::OBJECT, "node")));
- ADD_SIGNAL(MethodInfo("node_removed", PropertyInfo(Variant::OBJECT, "node")));
+ ADD_SIGNAL(MethodInfo("node_added", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
+ ADD_SIGNAL(MethodInfo("node_removed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("screen_resized"));
- ADD_SIGNAL(MethodInfo("node_configuration_warning_changed", PropertyInfo(Variant::OBJECT, "node")));
+ ADD_SIGNAL(MethodInfo("node_configuration_warning_changed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("idle_frame"));
ADD_SIGNAL(MethodInfo("physics_frame"));
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 11201097d4..d59cbe05fb 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -31,13 +31,13 @@
#ifndef SCENE_MAIN_LOOP_H
#define SCENE_MAIN_LOOP_H
-#include "io/multiplayer_api.h"
-#include "os/main_loop.h"
-#include "os/thread_safe.h"
+#include "core/io/multiplayer_api.h"
+#include "core/os/main_loop.h"
+#include "core/os/thread_safe.h"
+#include "core/self_list.h"
#include "scene/resources/mesh.h"
#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
-#include "self_list.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index c285694dfa..227840531e 100755
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -30,7 +30,7 @@
#include "timer.h"
-#include "engine.h"
+#include "core/engine.h"
void Timer::_notification(int p_what) {
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index d1b3eb9d9a..bb379ff4af 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -30,9 +30,9 @@
#include "viewport.h"
-#include "os/input.h"
-#include "os/os.h"
-#include "project_settings.h"
+#include "core/os/input.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
#include "scene/2d/collision_object_2d.h"
#include "scene/3d/camera.h"
#include "scene/3d/collision_object.h"
@@ -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) {
@@ -2789,6 +2771,8 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("gui_get_drag_data"), &Viewport::gui_get_drag_data);
ClassDB::bind_method(D_METHOD("gui_is_dragging"), &Viewport::gui_is_dragging);
+ ClassDB::bind_method(D_METHOD("get_modal_stack_top"), &Viewport::get_modal_stack_top);
+
ClassDB::bind_method(D_METHOD("set_disable_input", "disable"), &Viewport::set_disable_input);
ClassDB::bind_method(D_METHOD("is_input_disabled"), &Viewport::is_input_disabled);
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 450f235b79..c1a4c0e3eb 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -31,11 +31,11 @@
#ifndef VIEWPORT_H
#define VIEWPORT_H
+#include "core/math/transform_2d.h"
#include "scene/main/node.h"
#include "scene/resources/texture.h"
#include "scene/resources/world_2d.h"
#include "servers/visual_server.h"
-#include "transform_2d.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index a4422af21d..97230d422b 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -144,6 +144,7 @@
#include "scene/resources/mesh_data_tool.h"
#include "scene/resources/mesh_library.h"
#include "scene/resources/packed_scene.h"
+#include "scene/resources/particles_material.h"
#include "scene/resources/plane_shape.h"
#include "scene/resources/polygon_path_finder.h"
#include "scene/resources/primitive_meshes.h"
@@ -165,8 +166,6 @@
#include "scene/resources/world_2d.h"
#include "scene/scene_string_names.h"
-#include "scene/3d/cpu_particles.h"
-#include "scene/3d/particles.h"
#include "scene/3d/scenario_fx.h"
#include "scene/3d/spatial.h"
@@ -179,6 +178,7 @@
#include "scene/3d/camera.h"
#include "scene/3d/collision_polygon.h"
#include "scene/3d/collision_shape.h"
+#include "scene/3d/cpu_particles.h"
#include "scene/3d/gi_probe.h"
#include "scene/3d/immediate_geometry.h"
#include "scene/3d/interpolated_camera.h"
@@ -188,6 +188,7 @@
#include "scene/3d/multimesh_instance.h"
#include "scene/3d/navigation.h"
#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/particles.h"
#include "scene/3d/path.h"
#include "scene/3d/physics_body.h"
#include "scene/3d/physics_joint.h"
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/animation.cpp b/scene/resources/animation.cpp
index 58e6db3f5e..80ad2ad739 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -30,7 +30,7 @@
#include "animation.h"
-#include "geometry.h"
+#include "core/math/geometry.h"
#define ANIM_MIN_LENGTH 0.001
@@ -1442,7 +1442,7 @@ void Animation::track_set_key_transition(int p_track, int p_key_idx, float p_tra
case TYPE_BEZIER:
case TYPE_AUDIO:
case TYPE_ANIMATION: {
- // they dont use transition
+ // they don't use transition
} break;
}
}
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index a41e6ea5d7..6eec2c8bc7 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -31,7 +31,7 @@
#ifndef ANIMATION_H
#define ANIMATION_H
-#include "resource.h"
+#include "core/resource.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index e6a4b01deb..9ee85b64b6 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "audio_stream_sample.h"
-#include "io/marshalls.h"
-#include "os/file_access.h"
+#include "core/io/marshalls.h"
+#include "core/os/file_access.h"
void AudioStreamPlaybackSample::start(float p_from_pos) {
@@ -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 5694099754..56b236d03b 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -30,7 +30,7 @@
#include "bit_mask.h"
-#include "io/image_loader.h"
+#include "core/io/image_loader.h"
void BitMap::create(const Size2 &p_size) {
@@ -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/bit_mask.h b/scene/resources/bit_mask.h
index 40f0bfb04a..04191a7774 100644
--- a/scene/resources/bit_mask.h
+++ b/scene/resources/bit_mask.h
@@ -31,9 +31,9 @@
#ifndef BIT_MASK_H
#define BIT_MASK_H
-#include "image.h"
-#include "io/resource_loader.h"
-#include "resource.h"
+#include "core/image.h"
+#include "core/io/resource_loader.h"
+#include "core/resource.h"
class BitMap : public Resource {
diff --git a/scene/resources/bounds.h b/scene/resources/bounds.h
index dfe2fe40c6..c86e15ae40 100644
--- a/scene/resources/bounds.h
+++ b/scene/resources/bounds.h
@@ -31,8 +31,8 @@
#ifndef BOUNDS_H
#define BOUNDS_H
-#include "bsp_tree.h"
-#include "resource.h"
+#include "core/math/bsp_tree.h"
+#include "core/resource.h"
class Bounds : public Resource {
diff --git a/scene/resources/canvas.h b/scene/resources/canvas.h
index dfdea82ca5..cd37ea3583 100644
--- a/scene/resources/canvas.h
+++ b/scene/resources/canvas.h
@@ -31,7 +31,7 @@
#ifndef CANVAS_H
#define CANVAS_H
-#include "resource.h"
+#include "core/resource.h"
class Canvas : public Resource {
diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp
index 4a43303d84..d5e8c17cbc 100644
--- a/scene/resources/color_ramp.cpp
+++ b/scene/resources/color_ramp.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "color_ramp.h"
-#include "core_string_names.h"
+#include "core/core_string_names.h"
//setter and getter names for property serialization
#define COLOR_RAMP_GET_OFFSETS "get_offsets"
diff --git a/scene/resources/color_ramp.h b/scene/resources/color_ramp.h
index 070ad7f0d3..88fa4beb7f 100644
--- a/scene/resources/color_ramp.h
+++ b/scene/resources/color_ramp.h
@@ -31,7 +31,7 @@
#ifndef SCENE_RESOURCES_COLOR_RAMP_H_
#define SCENE_RESOURCES_COLOR_RAMP_H_
-#include "resource.h"
+#include "core/resource.h"
class Gradient : public Resource {
GDCLASS(Gradient, Resource);
diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp
index fa9369d3bc..9d47bca5ed 100644
--- a/scene/resources/convex_polygon_shape.cpp
+++ b/scene/resources/convex_polygon_shape.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "convex_polygon_shape.h"
-#include "quick_hull.h"
+#include "core/math/quick_hull.h"
#include "servers/physics_server.h"
Vector<Vector3> ConvexPolygonShape::_gen_debug_mesh_lines() {
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index d061c4ea1e..f325af7ea4 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -30,7 +30,7 @@
#include "convex_polygon_shape_2d.h"
-#include "geometry.h"
+#include "core/math/geometry.h"
#include "servers/physics_2d_server.h"
#include "servers/visual_server.h"
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index d8989bf062..9188d890f7 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -30,7 +30,7 @@
#include "curve.h"
-#include "core_string_names.h"
+#include "core/core_string_names.h"
template <class T>
static _FORCE_INLINE_ T _bezier_interp(real_t t, T start, T control_1, T control_2, T end) {
@@ -491,6 +491,7 @@ void Curve::ensure_default_setup(float p_min, float p_max) {
void Curve::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_point_count"), &Curve::get_point_count);
ClassDB::bind_method(D_METHOD("add_point", "position", "left_tangent", "right_tangent", "left_mode", "right_mode"), &Curve::add_point, DEFVAL(0), DEFVAL(0), DEFVAL(TANGENT_FREE), DEFVAL(TANGENT_FREE));
ClassDB::bind_method(D_METHOD("remove_point", "index"), &Curve::remove_point);
ClassDB::bind_method(D_METHOD("clear_points"), &Curve::clear_points);
diff --git a/scene/resources/curve.h b/scene/resources/curve.h
index 058c4f1bc2..234e3a6779 100644
--- a/scene/resources/curve.h
+++ b/scene/resources/curve.h
@@ -31,7 +31,7 @@
#ifndef CURVE_H
#define CURVE_H
-#include "resource.h"
+#include "core/resource.h"
// y(x) curve
class Curve : public Resource {
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 0eee2ae393..4de47b2cb0 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -32,7 +32,7 @@
#include "scene/resources/theme.h"
-#include "os/os.h"
+#include "core/os/os.h"
#include "theme_data.h"
#include "font_hidpi.inc"
@@ -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/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 4df849df6a..0785d3bfc6 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -30,8 +30,8 @@
#ifdef FREETYPE_ENABLED
#include "dynamic_font.h"
-#include "os/file_access.h"
-#include "os/os.h"
+#include "core/os/file_access.h"
+#include "core/os/os.h"
#include FT_STROKER_H
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index f460bca2d4..afda48a566 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -32,10 +32,10 @@
#define DYNAMIC_FONT_H
#ifdef FREETYPE_ENABLED
-#include "io/resource_loader.h"
-#include "os/mutex.h"
-#include "os/thread_safe.h"
-#include "pair.h"
+#include "core/io/resource_loader.h"
+#include "core/os/mutex.h"
+#include "core/os/thread_safe.h"
+#include "core/pair.h"
#include "scene/resources/font.h"
#include <ft2build.h>
diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp
index be394e19c4..8cb2cc4983 100644
--- a/scene/resources/dynamic_font_stb.cpp
+++ b/scene/resources/dynamic_font_stb.cpp
@@ -33,7 +33,7 @@
#ifndef FREETYPE_ENABLED
#define STB_TRUETYPE_IMPLEMENTATION
-#include "os/file_access.h"
+#include "core/os/file_access.h"
void DynamicFontData::lock() {
diff --git a/scene/resources/dynamic_font_stb.h b/scene/resources/dynamic_font_stb.h
index feae29c0c2..e1ef72ea4f 100644
--- a/scene/resources/dynamic_font_stb.h
+++ b/scene/resources/dynamic_font_stb.h
@@ -33,8 +33,8 @@
#ifndef FREETYPE_ENABLED
+#include "core/io/resource_loader.h"
#include "font.h"
-#include "io/resource_loader.h"
#include "thirdparty/misc/stb_truetype.h"
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index d3da842b79..f4d5b8376b 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "environment.h"
-#include "project_settings.h"
+#include "core/project_settings.h"
#include "servers/visual_server.h"
#include "texture.h"
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index 7d66c7e60b..aab37719e0 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -31,7 +31,7 @@
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
-#include "resource.h"
+#include "core/resource.h"
#include "scene/resources/sky_box.h"
#include "scene/resources/texture.h"
#include "servers/visual_server.h"
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 3dfde01320..b78b3a6ffb 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -31,8 +31,8 @@
#include "font.h"
#include "core/io/resource_loader.h"
+#include "core/method_bind_ext.gen.inc"
#include "core/os/file_access.h"
-#include "method_bind_ext.gen.inc"
void Font::draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, float p_width, const String &p_text, const Color &p_modulate, const Color &p_outline_modulate) const {
float length = get_string_size(p_text).width;
@@ -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/font.h b/scene/resources/font.h
index 4e295b6035..39e66a822d 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -31,8 +31,8 @@
#ifndef FONT_H
#define FONT_H
-#include "map.h"
-#include "resource.h"
+#include "core/map.h"
+#include "core/resource.h"
#include "scene/resources/texture.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 4727526b68..274c74a9a2 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -145,6 +145,31 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
+bool ShaderMaterial::property_can_revert(const String &p_name) {
+ if (shader.is_valid()) {
+
+ StringName pr = shader->remap_param(p_name);
+ if (pr) {
+ Variant default_value = VisualServer::get_singleton()->material_get_param_default(_get_material(), pr);
+ Variant current_value;
+ _get(p_name, current_value);
+ return default_value.get_type() != Variant::NIL && default_value != current_value;
+ }
+ }
+ return false;
+}
+
+Variant ShaderMaterial::property_get_revert(const String &p_name) {
+ Variant r_ret;
+ if (shader.is_valid()) {
+ StringName pr = shader->remap_param(p_name);
+ if (pr) {
+ r_ret = VisualServer::get_singleton()->material_get_param_default(_get_material(), pr);
+ }
+ }
+ return r_ret;
+}
+
void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
if (shader.is_valid()) {
@@ -190,6 +215,8 @@ void ShaderMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_shader_param", "param", "value"), &ShaderMaterial::set_shader_param);
ClassDB::bind_method(D_METHOD("get_shader_param", "param"), &ShaderMaterial::get_shader_param);
ClassDB::bind_method(D_METHOD("_shader_changed"), &ShaderMaterial::_shader_changed);
+ ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ShaderMaterial::property_can_revert);
+ ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ShaderMaterial::property_get_revert);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader"), "set_shader", "get_shader");
}
@@ -400,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";
@@ -535,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]) {
@@ -583,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;
}
@@ -790,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";
@@ -798,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";
}
@@ -1342,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);
@@ -1355,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 f43d240a53..0154874ae4 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -31,10 +31,10 @@
#ifndef MATERIAL_H
#define MATERIAL_H
-#include "resource.h"
+#include "core/resource.h"
+#include "core/self_list.h"
#include "scene/resources/shader.h"
#include "scene/resources/texture.h"
-#include "self_list.h"
#include "servers/visual/shader_language.h"
#include "servers/visual_server.h"
/**
@@ -85,6 +85,8 @@ protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
+ bool property_can_revert(const String &p_name);
+ Variant property_get_revert(const String &p_name);
static void _bind_methods();
@@ -440,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 e6ef956dc5..6cd701eb9a 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -30,18 +30,13 @@
#include "mesh.h"
-#include "pair.h"
+#include "core/pair.h"
#include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/convex_polygon_shape.h"
#include "surface_tool.h"
#include <stdlib.h>
-void Mesh::_clear_triangle_mesh() const {
-
- triangle_mesh.unref();
-}
-
Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
if (triangle_mesh.is_valid())
@@ -111,6 +106,11 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
void Mesh::generate_debug_mesh_lines(Vector<Vector3> &r_lines) {
+ if (debug_lines.size() > 0) {
+ r_lines = debug_lines;
+ return;
+ }
+
Ref<TriangleMesh> tm = generate_triangle_mesh();
if (tm.is_null())
return;
@@ -120,23 +120,25 @@ void Mesh::generate_debug_mesh_lines(Vector<Vector3> &r_lines) {
const int triangles_num = tm->get_triangles().size();
PoolVector<Vector3> vertices = tm->get_vertices();
- r_lines.resize(tm->get_triangles().size() * 6); // 3 lines x 2 points each line
+ debug_lines.resize(tm->get_triangles().size() * 6); // 3 lines x 2 points each line
PoolVector<int>::Read ind_r = triangle_indices.read();
PoolVector<Vector3>::Read ver_r = vertices.read();
for (int j = 0, x = 0, i = 0; i < triangles_num; j += 6, x += 3, ++i) {
// Triangle line 1
- r_lines.write[j + 0] = ver_r[ind_r[x + 0]];
- r_lines.write[j + 1] = ver_r[ind_r[x + 1]];
+ debug_lines.write[j + 0] = ver_r[ind_r[x + 0]];
+ debug_lines.write[j + 1] = ver_r[ind_r[x + 1]];
// Triangle line 2
- r_lines.write[j + 2] = ver_r[ind_r[x + 1]];
- r_lines.write[j + 3] = ver_r[ind_r[x + 2]];
+ debug_lines.write[j + 2] = ver_r[ind_r[x + 1]];
+ debug_lines.write[j + 3] = ver_r[ind_r[x + 2]];
// Triangle line 3
- r_lines.write[j + 4] = ver_r[ind_r[x + 2]];
- r_lines.write[j + 5] = ver_r[ind_r[x + 0]];
+ debug_lines.write[j + 4] = ver_r[ind_r[x + 2]];
+ debug_lines.write[j + 5] = ver_r[ind_r[x + 0]];
}
+
+ r_lines = debug_lines;
}
void Mesh::generate_debug_mesh_indices(Vector<Vector3> &r_points) {
Ref<TriangleMesh> tm = generate_triangle_mesh();
@@ -536,53 +538,14 @@ void Mesh::_bind_methods() {
BIND_ENUM_CONSTANT(ARRAY_MAX);
}
-void Mesh::clear_cache() {
- _clear_triangle_mesh();
+void Mesh::clear_cache() const {
+ triangle_mesh.unref();
+ debug_lines.clear();
}
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;
@@ -850,7 +813,7 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array &
_recompute_aabb();
}
- _clear_triangle_mesh();
+ clear_cache();
_change_notify();
emit_changed();
}
@@ -929,7 +892,7 @@ void ArrayMesh::surface_remove(int p_idx) {
VisualServer::get_singleton()->mesh_remove_surface(mesh, p_idx);
surfaces.remove(p_idx);
- _clear_triangle_mesh();
+ clear_cache();
_recompute_aabb();
_change_notify();
emit_changed();
@@ -1035,7 +998,7 @@ void ArrayMesh::add_surface_from_mesh_data(const Geometry::MeshData &p_mesh_data
else
aabb.merge_with(s.aabb);
- _clear_triangle_mesh();
+ clear_cache();
surfaces.push_back(s);
_change_notify();
@@ -1375,6 +1338,7 @@ void ArrayMesh::reload_from_file() {
VisualServer::get_singleton()->mesh_clear(mesh);
surfaces.clear();
clear_blend_shapes();
+ clear_cache();
Resource::reload_from_file();
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index 36bfca49f8..aebba09ef8 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -31,11 +31,11 @@
#ifndef MESH_H
#define MESH_H
-#include "resource.h"
+#include "core/math/triangle_mesh.h"
+#include "core/resource.h"
#include "scene/resources/material.h"
#include "scene/resources/shape.h"
#include "servers/visual_server.h"
-#include "triangle_mesh.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -44,11 +44,10 @@ class Mesh : public Resource {
GDCLASS(Mesh, Resource);
mutable Ref<TriangleMesh> triangle_mesh; //cached
+ mutable Vector<Vector3> debug_lines;
Size2 lightmap_size_hint;
protected:
- void _clear_triangle_mesh() const;
-
static void _bind_methods();
public:
@@ -146,7 +145,7 @@ public:
void set_lightmap_size_hint(const Vector2 &p_size);
Size2 get_lightmap_size_hint() const;
- void clear_cache();
+ void clear_cache() const;
Mesh();
};
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/mesh_library.h b/scene/resources/mesh_library.h
index 69719960e2..3ce0cf9b66 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -31,9 +31,9 @@
#ifndef GRID_THEME_H
#define GRID_THEME_H
-#include "map.h"
+#include "core/map.h"
+#include "core/resource.h"
#include "mesh.h"
-#include "resource.h"
#include "scene/3d/navigation_mesh.h"
#include "shape.h"
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index 4d0a14e3aa..e8e19fdb60 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -33,8 +33,6 @@
void MultiMesh::_set_transform_array(const PoolVector<Vector3> &p_array) {
- int instance_count = get_instance_count();
-
PoolVector<Vector3> xforms = p_array;
int len = xforms.size();
ERR_FAIL_COND((len / 4) != instance_count);
@@ -57,8 +55,6 @@ void MultiMesh::_set_transform_array(const PoolVector<Vector3> &p_array) {
PoolVector<Vector3> MultiMesh::_get_transform_array() const {
- int instance_count = get_instance_count();
-
if (instance_count == 0)
return PoolVector<Vector3>();
@@ -81,13 +77,11 @@ PoolVector<Vector3> MultiMesh::_get_transform_array() const {
void MultiMesh::_set_color_array(const PoolVector<Color> &p_array) {
- int instance_count = get_instance_count();
-
PoolVector<Color> colors = p_array;
int len = colors.size();
- ERR_FAIL_COND(len != instance_count);
if (len == 0)
return;
+ ERR_FAIL_COND(len != instance_count);
PoolVector<Color>::Read r = colors.read();
@@ -99,9 +93,7 @@ void MultiMesh::_set_color_array(const PoolVector<Color> &p_array) {
PoolVector<Color> MultiMesh::_get_color_array() const {
- int instance_count = get_instance_count();
-
- if (instance_count == 0)
+ if (instance_count == 0 || color_format == COLOR_NONE)
return PoolVector<Color>();
PoolVector<Color> colors;
@@ -115,6 +107,37 @@ PoolVector<Color> MultiMesh::_get_color_array() const {
return colors;
}
+void MultiMesh::_set_custom_data_array(const PoolVector<Color> &p_array) {
+
+ PoolVector<Color> custom_datas = p_array;
+ int len = custom_datas.size();
+ if (len == 0)
+ return;
+ ERR_FAIL_COND(len != instance_count);
+
+ PoolVector<Color>::Read r = custom_datas.read();
+
+ for (int i = 0; i < len; i++) {
+
+ set_instance_custom_data(i, r[i]);
+ }
+}
+
+PoolVector<Color> MultiMesh::_get_custom_data_array() const {
+
+ if (instance_count == 0 || custom_data_format == CUSTOM_DATA_NONE)
+ return PoolVector<Color>();
+
+ PoolVector<Color> custom_datas;
+ custom_datas.resize(instance_count);
+
+ for (int i = 0; i < instance_count; i++) {
+
+ custom_datas.set(i, get_instance_custom_data(i));
+ }
+
+ return custom_datas;
+}
void MultiMesh::set_mesh(const Ref<Mesh> &p_mesh) {
mesh = p_mesh;
@@ -130,12 +153,13 @@ Ref<Mesh> MultiMesh::get_mesh() const {
}
void MultiMesh::set_instance_count(int p_count) {
-
- VisualServer::get_singleton()->multimesh_allocate(multimesh, p_count, VS::MultimeshTransformFormat(transform_format), VS::MultimeshColorFormat(color_format));
+ ERR_FAIL_COND(p_count < 0);
+ VisualServer::get_singleton()->multimesh_allocate(multimesh, p_count, VS::MultimeshTransformFormat(transform_format), VS::MultimeshColorFormat(color_format), VS::MultimeshCustomDataFormat(custom_data_format));
+ instance_count = p_count;
}
int MultiMesh::get_instance_count() const {
- return VisualServer::get_singleton()->multimesh_get_instance_count(multimesh);
+ return instance_count;
}
void MultiMesh::set_instance_transform(int p_instance, const Transform &p_transform) {
@@ -156,6 +180,15 @@ Color MultiMesh::get_instance_color(int p_instance) const {
return VisualServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance);
}
+void MultiMesh::set_instance_custom_data(int p_instance, const Color &p_custom_data) {
+
+ VisualServer::get_singleton()->multimesh_instance_set_custom_data(multimesh, p_instance, p_custom_data);
+}
+Color MultiMesh::get_instance_custom_data(int p_instance) const {
+
+ return VisualServer::get_singleton()->multimesh_instance_get_custom_data(multimesh, p_instance);
+}
+
AABB MultiMesh::get_aabb() const {
return VisualServer::get_singleton()->multimesh_get_aabb(multimesh);
@@ -168,6 +201,7 @@ RID MultiMesh::get_rid() const {
void MultiMesh::set_color_format(ColorFormat p_color_format) {
+ ERR_FAIL_COND(instance_count > 0);
color_format = p_color_format;
}
@@ -176,8 +210,20 @@ MultiMesh::ColorFormat MultiMesh::get_color_format() const {
return color_format;
}
+void MultiMesh::set_custom_data_format(CustomDataFormat p_custom_data_format) {
+
+ ERR_FAIL_COND(instance_count > 0);
+ custom_data_format = p_custom_data_format;
+}
+
+MultiMesh::CustomDataFormat MultiMesh::get_custom_data_format() const {
+
+ return custom_data_format;
+}
+
void MultiMesh::set_transform_format(TransformFormat p_transform_format) {
+ ERR_FAIL_COND(instance_count > 0);
transform_format = p_transform_format;
}
MultiMesh::TransformFormat MultiMesh::get_transform_format() const {
@@ -191,6 +237,8 @@ void MultiMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_mesh"), &MultiMesh::get_mesh);
ClassDB::bind_method(D_METHOD("set_color_format", "format"), &MultiMesh::set_color_format);
ClassDB::bind_method(D_METHOD("get_color_format"), &MultiMesh::get_color_format);
+ ClassDB::bind_method(D_METHOD("set_custom_data_format", "format"), &MultiMesh::set_custom_data_format);
+ ClassDB::bind_method(D_METHOD("get_custom_data_format"), &MultiMesh::get_custom_data_format);
ClassDB::bind_method(D_METHOD("set_transform_format", "format"), &MultiMesh::set_transform_format);
ClassDB::bind_method(D_METHOD("get_transform_format"), &MultiMesh::get_transform_format);
@@ -200,19 +248,25 @@ void MultiMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_instance_transform", "instance"), &MultiMesh::get_instance_transform);
ClassDB::bind_method(D_METHOD("set_instance_color", "instance", "color"), &MultiMesh::set_instance_color);
ClassDB::bind_method(D_METHOD("get_instance_color", "instance"), &MultiMesh::get_instance_color);
+ ClassDB::bind_method(D_METHOD("set_instance_custom_data", "instance", "custom_data"), &MultiMesh::set_instance_custom_data);
+ ClassDB::bind_method(D_METHOD("get_instance_custom_data", "instance"), &MultiMesh::get_instance_custom_data);
ClassDB::bind_method(D_METHOD("get_aabb"), &MultiMesh::get_aabb);
ClassDB::bind_method(D_METHOD("_set_transform_array"), &MultiMesh::_set_transform_array);
ClassDB::bind_method(D_METHOD("_get_transform_array"), &MultiMesh::_get_transform_array);
ClassDB::bind_method(D_METHOD("_set_color_array"), &MultiMesh::_set_color_array);
ClassDB::bind_method(D_METHOD("_get_color_array"), &MultiMesh::_get_color_array);
+ ClassDB::bind_method(D_METHOD("_set_custom_data_array"), &MultiMesh::_set_custom_data_array);
+ ClassDB::bind_method(D_METHOD("_get_custom_data_array"), &MultiMesh::_get_custom_data_array);
ADD_PROPERTY(PropertyInfo(Variant::INT, "color_format", PROPERTY_HINT_ENUM, "None,Byte,Float"), "set_color_format", "get_color_format");
ADD_PROPERTY(PropertyInfo(Variant::INT, "transform_format", PROPERTY_HINT_ENUM, "2D,3D"), "set_transform_format", "get_transform_format");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "instance_count", PROPERTY_HINT_RANGE, "0,16384,1"), "set_instance_count", "get_instance_count");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "custom_data_format", PROPERTY_HINT_ENUM, "None,Byte,Float"), "set_custom_data_format", "get_custom_data_format");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "instance_count", PROPERTY_HINT_RANGE, "0,16384,1,or_greater"), "set_instance_count", "get_instance_count");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh");
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY, "transform_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_transform_array", "_get_transform_array");
ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY, "color_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_color_array", "_get_color_array");
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY, "custom_data_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_custom_data_array", "_get_custom_data_array");
BIND_ENUM_CONSTANT(TRANSFORM_2D);
BIND_ENUM_CONSTANT(TRANSFORM_3D);
@@ -220,13 +274,19 @@ void MultiMesh::_bind_methods() {
BIND_ENUM_CONSTANT(COLOR_NONE);
BIND_ENUM_CONSTANT(COLOR_8BIT);
BIND_ENUM_CONSTANT(COLOR_FLOAT);
+
+ BIND_ENUM_CONSTANT(CUSTOM_DATA_NONE);
+ BIND_ENUM_CONSTANT(CUSTOM_DATA_8BIT);
+ BIND_ENUM_CONSTANT(CUSTOM_DATA_FLOAT);
}
MultiMesh::MultiMesh() {
multimesh = VisualServer::get_singleton()->multimesh_create();
color_format = COLOR_NONE;
+ custom_data_format = CUSTOM_DATA_NONE;
transform_format = TRANSFORM_2D;
+ instance_count = 0;
}
MultiMesh::~MultiMesh() {
diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h
index 0875d6d06d..ec5a5ca4d5 100644
--- a/scene/resources/multimesh.h
+++ b/scene/resources/multimesh.h
@@ -51,11 +51,19 @@ public:
COLOR_FLOAT = VS::MULTIMESH_COLOR_FLOAT,
};
+ enum CustomDataFormat {
+ CUSTOM_DATA_NONE,
+ CUSTOM_DATA_8BIT,
+ CUSTOM_DATA_FLOAT,
+ };
+
private:
Ref<Mesh> mesh;
RID multimesh;
TransformFormat transform_format;
ColorFormat color_format;
+ CustomDataFormat custom_data_format;
+ int instance_count;
protected:
static void _bind_methods();
@@ -66,6 +74,9 @@ protected:
void _set_color_array(const PoolVector<Color> &p_array);
PoolVector<Color> _get_color_array() const;
+ void _set_custom_data_array(const PoolVector<Color> &p_array);
+ PoolVector<Color> _get_custom_data_array() const;
+
public:
void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const;
@@ -73,6 +84,9 @@ public:
void set_color_format(ColorFormat p_color_format);
ColorFormat get_color_format() const;
+ void set_custom_data_format(CustomDataFormat p_custom_data_format);
+ CustomDataFormat get_custom_data_format() const;
+
void set_transform_format(TransformFormat p_transform_format);
TransformFormat get_transform_format() const;
@@ -85,6 +99,9 @@ public:
void set_instance_color(int p_instance, const Color &p_color);
Color get_instance_color(int p_instance) const;
+ void set_instance_custom_data(int p_instance, const Color &p_custom_data);
+ Color get_instance_custom_data(int p_instance) const;
+
virtual AABB get_aabb() const;
virtual RID get_rid() const;
@@ -95,5 +112,6 @@ public:
VARIANT_ENUM_CAST(MultiMesh::TransformFormat);
VARIANT_ENUM_CAST(MultiMesh::ColorFormat);
+VARIANT_ENUM_CAST(MultiMesh::CustomDataFormat);
#endif // MULTI_MESH_H
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index f034e07ff9..086fb83af9 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -31,9 +31,9 @@
#include "packed_scene.h"
#include "core/core_string_names.h"
-#include "engine.h"
-#include "io/resource_loader.h"
-#include "project_settings.h"
+#include "core/engine.h"
+#include "core/io/resource_loader.h"
+#include "core/project_settings.h"
#include "scene/2d/node_2d.h"
#include "scene/3d/spatial.h"
#include "scene/gui/control.h"
diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h
index 278986eb62..e5f22f5e3b 100644
--- a/scene/resources/packed_scene.h
+++ b/scene/resources/packed_scene.h
@@ -31,7 +31,7 @@
#ifndef PACKED_SCENE_H
#define PACKED_SCENE_H
-#include "resource.h"
+#include "core/resource.h"
#include "scene/main/node.h"
class SceneState : public Reference {
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
new file mode 100644
index 0000000000..6f67ba8af1
--- /dev/null
+++ b/scene/resources/particles_material.cpp
@@ -0,0 +1,1262 @@
+/*************************************************************************/
+/* particles_material.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. */
+/*************************************************************************/
+
+#include "particles_material.h"
+
+Mutex *ParticlesMaterial::material_mutex = NULL;
+SelfList<ParticlesMaterial>::List ParticlesMaterial::dirty_materials;
+Map<ParticlesMaterial::MaterialKey, ParticlesMaterial::ShaderData> ParticlesMaterial::shader_map;
+ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = NULL;
+
+void ParticlesMaterial::init_shaders() {
+
+#ifndef NO_THREADS
+ material_mutex = Mutex::create();
+#endif
+
+ shader_names = memnew(ShaderNames);
+
+ shader_names->spread = "spread";
+ shader_names->flatness = "flatness";
+ shader_names->initial_linear_velocity = "initial_linear_velocity";
+ shader_names->initial_angle = "initial_angle";
+ shader_names->angular_velocity = "angular_velocity";
+ shader_names->orbit_velocity = "orbit_velocity";
+ shader_names->linear_accel = "linear_accel";
+ shader_names->radial_accel = "radial_accel";
+ shader_names->tangent_accel = "tangent_accel";
+ shader_names->damping = "damping";
+ shader_names->scale = "scale";
+ shader_names->hue_variation = "hue_variation";
+ shader_names->anim_speed = "anim_speed";
+ shader_names->anim_offset = "anim_offset";
+
+ shader_names->initial_linear_velocity_random = "initial_linear_velocity_random";
+ shader_names->initial_angle_random = "initial_angle_random";
+ shader_names->angular_velocity_random = "angular_velocity_random";
+ shader_names->orbit_velocity_random = "orbit_velocity_random";
+ shader_names->linear_accel_random = "linear_accel_random";
+ shader_names->radial_accel_random = "radial_accel_random";
+ shader_names->tangent_accel_random = "tangent_accel_random";
+ shader_names->damping_random = "damping_random";
+ shader_names->scale_random = "scale_random";
+ shader_names->hue_variation_random = "hue_variation_random";
+ shader_names->anim_speed_random = "anim_speed_random";
+ shader_names->anim_offset_random = "anim_offset_random";
+
+ shader_names->angle_texture = "angle_texture";
+ shader_names->angular_velocity_texture = "angular_velocity_texture";
+ shader_names->orbit_velocity_texture = "orbit_velocity_texture";
+ shader_names->linear_accel_texture = "linear_accel_texture";
+ shader_names->radial_accel_texture = "radial_accel_texture";
+ shader_names->tangent_accel_texture = "tangent_accel_texture";
+ shader_names->damping_texture = "damping_texture";
+ shader_names->scale_texture = "scale_texture";
+ shader_names->hue_variation_texture = "hue_variation_texture";
+ shader_names->anim_speed_texture = "anim_speed_texture";
+ shader_names->anim_offset_texture = "anim_offset_texture";
+
+ shader_names->color = "color_value";
+ shader_names->color_ramp = "color_ramp";
+
+ shader_names->emission_sphere_radius = "emission_sphere_radius";
+ shader_names->emission_box_extents = "emission_box_extents";
+ shader_names->emission_texture_point_count = "emission_texture_point_count";
+ shader_names->emission_texture_points = "emission_texture_points";
+ shader_names->emission_texture_normal = "emission_texture_normal";
+ shader_names->emission_texture_color = "emission_texture_color";
+
+ shader_names->trail_divisor = "trail_divisor";
+ shader_names->trail_size_modifier = "trail_size_modifier";
+ shader_names->trail_color_modifier = "trail_color_modifier";
+
+ shader_names->gravity = "gravity";
+}
+
+void ParticlesMaterial::finish_shaders() {
+
+#ifndef NO_THREADS
+ memdelete(material_mutex);
+#endif
+
+ memdelete(shader_names);
+}
+
+void ParticlesMaterial::_update_shader() {
+
+ dirty_materials.remove(&element);
+
+ MaterialKey mk = _compute_key();
+ if (mk.key == current_key.key)
+ return; //no update required in the end
+
+ if (shader_map.has(current_key)) {
+ shader_map[current_key].users--;
+ if (shader_map[current_key].users == 0) {
+ //deallocate shader, as it's no longer in use
+ VS::get_singleton()->free(shader_map[current_key].shader);
+ shader_map.erase(current_key);
+ }
+ }
+
+ current_key = mk;
+
+ if (shader_map.has(mk)) {
+
+ VS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
+ shader_map[mk].users++;
+ return;
+ }
+
+ //must create a shader!
+
+ String code = "shader_type particles;\n";
+
+ code += "uniform float spread;\n";
+ code += "uniform float flatness;\n";
+ code += "uniform float initial_linear_velocity;\n";
+ code += "uniform float initial_angle;\n";
+ code += "uniform float angular_velocity;\n";
+ code += "uniform float orbit_velocity;\n";
+ code += "uniform float linear_accel;\n";
+ code += "uniform float radial_accel;\n";
+ code += "uniform float tangent_accel;\n";
+ code += "uniform float damping;\n";
+ code += "uniform float scale;\n";
+ code += "uniform float hue_variation;\n";
+ code += "uniform float anim_speed;\n";
+ code += "uniform float anim_offset;\n";
+
+ code += "uniform float initial_linear_velocity_random;\n";
+ code += "uniform float initial_angle_random;\n";
+ code += "uniform float angular_velocity_random;\n";
+ code += "uniform float orbit_velocity_random;\n";
+ code += "uniform float linear_accel_random;\n";
+ code += "uniform float radial_accel_random;\n";
+ code += "uniform float tangent_accel_random;\n";
+ code += "uniform float damping_random;\n";
+ code += "uniform float scale_random;\n";
+ code += "uniform float hue_variation_random;\n";
+ code += "uniform float anim_speed_random;\n";
+ code += "uniform float anim_offset_random;\n";
+
+ switch (emission_shape) {
+ case EMISSION_SHAPE_POINT: {
+ //do none
+ } break;
+ case EMISSION_SHAPE_SPHERE: {
+ code += "uniform float emission_sphere_radius;\n";
+ } break;
+ case EMISSION_SHAPE_BOX: {
+ code += "uniform vec3 emission_box_extents;\n";
+ } break;
+ case EMISSION_SHAPE_DIRECTED_POINTS: {
+ code += "uniform sampler2D emission_texture_normal : hint_black;\n";
+ } //fallthrough
+ case EMISSION_SHAPE_POINTS: {
+ code += "uniform sampler2D emission_texture_points : hint_black;\n";
+ code += "uniform int emission_texture_point_count;\n";
+ if (emission_color_texture.is_valid()) {
+ code += "uniform sampler2D emission_texture_color : hint_white;\n";
+ }
+ } break;
+ }
+
+ code += "uniform vec4 color_value : hint_color;\n";
+
+ code += "uniform int trail_divisor;\n";
+
+ code += "uniform vec3 gravity;\n";
+
+ if (color_ramp.is_valid())
+ code += "uniform sampler2D color_ramp;\n";
+
+ if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
+ code += "uniform sampler2D linear_velocity_texture;\n";
+ if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid())
+ code += "uniform sampler2D orbit_velocity_texture;\n";
+ if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid())
+ code += "uniform sampler2D angular_velocity_texture;\n";
+ if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid())
+ code += "uniform sampler2D linear_accel_texture;\n";
+ if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid())
+ code += "uniform sampler2D radial_accel_texture;\n";
+ if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid())
+ code += "uniform sampler2D tangent_accel_texture;\n";
+ if (tex_parameters[PARAM_DAMPING].is_valid())
+ code += "uniform sampler2D damping_texture;\n";
+ if (tex_parameters[PARAM_ANGLE].is_valid())
+ code += "uniform sampler2D angle_texture;\n";
+ if (tex_parameters[PARAM_SCALE].is_valid())
+ code += "uniform sampler2D scale_texture;\n";
+ if (tex_parameters[PARAM_HUE_VARIATION].is_valid())
+ code += "uniform sampler2D hue_variation_texture;\n";
+ if (tex_parameters[PARAM_ANIM_SPEED].is_valid())
+ code += "uniform sampler2D anim_speed_texture;\n";
+ if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
+ code += "uniform sampler2D anim_offset_texture;\n";
+
+ if (trail_size_modifier.is_valid()) {
+ code += "uniform sampler2D trail_size_modifier;\n";
+ }
+
+ if (trail_color_modifier.is_valid()) {
+ code += "uniform sampler2D trail_color_modifier;\n";
+ }
+
+ //need a random function
+ code += "\n\n";
+ code += "float rand_from_seed(inout uint seed) {\n";
+ code += " int k;\n";
+ code += " int s = int(seed);\n";
+ code += " if (s == 0)\n";
+ code += " s = 305420679;\n";
+ code += " k = s / 127773;\n";
+ code += " s = 16807 * (s - k * 127773) - 2836 * k;\n";
+ code += " if (s < 0)\n";
+ code += " s += 2147483647;\n";
+ code += " seed = uint(s);\n";
+ code += " return float(seed % uint(65536)) / 65535.0;\n";
+ code += "}\n";
+ code += "\n";
+
+ code += "float rand_from_seed_m1_p1(inout uint seed) {\n";
+ code += " return rand_from_seed(seed) * 2.0 - 1.0;\n";
+ code += "}\n";
+ code += "\n";
+
+ //improve seed quality
+ code += "uint hash(uint x) {\n";
+ code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n";
+ code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n";
+ code += " x = (x >> uint(16)) ^ x;\n";
+ code += " return x;\n";
+ code += "}\n";
+ code += "\n";
+
+ code += "void vertex() {\n";
+ code += " uint base_number = NUMBER / uint(trail_divisor);\n";
+ code += " uint alt_seed = hash(base_number + uint(1) + RANDOM_SEED);\n";
+ code += " float angle_rand = rand_from_seed(alt_seed);\n";
+ code += " float scale_rand = rand_from_seed(alt_seed);\n";
+ code += " float hue_rot_rand = rand_from_seed(alt_seed);\n";
+ code += " float anim_offset_rand = rand_from_seed(alt_seed);\n";
+ code += " float pi = 3.14159;\n";
+ code += " float degree_to_rad = pi / 180.0;\n";
+ code += "\n";
+
+ if (emission_shape >= EMISSION_SHAPE_POINTS) {
+ code += " int point = min(emission_texture_point_count - 1, int(rand_from_seed(alt_seed) * float(emission_texture_point_count)));\n";
+ code += " ivec2 emission_tex_size = textureSize(emission_texture_points, 0);\n";
+ code += " ivec2 emission_tex_ofs = ivec2(point % emission_tex_size.x, point / emission_tex_size.x);\n";
+ }
+ code += " if (RESTART) {\n";
+
+ if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
+ code += " float tex_linear_velocity = textureLod(linear_velocity_texture, vec2(0.0, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_linear_velocity = 0.0;\n";
+
+ if (tex_parameters[PARAM_ANGLE].is_valid())
+ code += " float tex_angle = textureLod(angle_texture, vec2(0.0, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_angle = 0.0;\n";
+
+ if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
+ code += " float tex_anim_offset = textureLod(anim_offset_texture, vec2(0.0, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_anim_offset = 0.0;\n";
+
+ code += " float spread_rad = spread * degree_to_rad;\n";
+
+ if (flags[FLAG_DISABLE_Z]) {
+
+ code += " float angle1_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad;\n";
+ code += " vec3 rot = vec3(cos(angle1_rad), sin(angle1_rad), 0.0);\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
+ code += " float angle1_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad;\n";
+ code += " float angle2_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad * (1.0 - flatness);\n";
+ code += " vec3 direction_xz = vec3(sin(angle1_rad), 0, cos(angle1_rad));\n";
+ code += " vec3 direction_yz = vec3(0, sin(angle2_rad), cos(angle2_rad));\n";
+ code += " direction_yz.z = direction_yz.z / sqrt(direction_yz.z); // better uniform distribution\n";
+ code += " vec3 direction = vec3(direction_xz.x * direction_yz.z, direction_yz.y, direction_xz.z * direction_yz.z);\n";
+ code += " direction = normalize(direction);\n";
+ code += " VELOCITY = direction * 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";
+ code += " CUSTOM.x = base_angle * degree_to_rad;\n"; // angle
+ code += " CUSTOM.y = 0.0;\n"; // phase
+ code += " CUSTOM.z = (anim_offset + tex_anim_offset) * mix(1.0, anim_offset_rand, anim_offset_random);\n"; // animation offset (0-1)
+
+ switch (emission_shape) {
+ case EMISSION_SHAPE_POINT: {
+ //do none
+ } break;
+ case EMISSION_SHAPE_SPHERE: {
+ code += " TRANSFORM[3].xyz = normalize(vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0)) * emission_sphere_radius;\n";
+ } break;
+ case EMISSION_SHAPE_BOX: {
+ code += " TRANSFORM[3].xyz = vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0) * emission_box_extents;\n";
+ } break;
+ case EMISSION_SHAPE_POINTS:
+ case EMISSION_SHAPE_DIRECTED_POINTS: {
+ code += " TRANSFORM[3].xyz = texelFetch(emission_texture_points, emission_tex_ofs, 0).xyz;\n";
+
+ if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS) {
+ if (flags[FLAG_DISABLE_Z]) {
+
+ code += " mat2 rotm;";
+ code += " rotm[0] = texelFetch(emission_texture_normal, emission_tex_ofs, 0).xy;\n";
+ code += " rotm[1] = rotm[0].yx * vec2(1.0, -1.0);\n";
+ code += " VELOCITY.xy = rotm * VELOCITY.xy;\n";
+ } else {
+ code += " vec3 normal = texelFetch(emission_texture_normal, emission_tex_ofs, 0).xyz;\n";
+ code += " vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0, 1.0, 0.0);\n";
+ code += " vec3 tangent = normalize(cross(v0, normal));\n";
+ code += " vec3 bitangent = normalize(cross(tangent, normal));\n";
+ code += " VELOCITY = mat3(tangent, bitangent, normal) * VELOCITY;\n";
+ }
+ }
+ } break;
+ }
+ code += " VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY, 0.0)).xyz;\n";
+ code += " TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n";
+ if (flags[FLAG_DISABLE_Z]) {
+ code += " VELOCITY.z = 0.0;\n";
+ code += " TRANSFORM[3].z = 0.0;\n";
+ }
+
+ code += " } else {\n";
+
+ code += " CUSTOM.y += DELTA / LIFETIME;\n";
+ if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
+ code += " float tex_linear_velocity = textureLod(linear_velocity_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_linear_velocity = 0.0;\n";
+
+ if (flags[FLAG_DISABLE_Z]) {
+
+ if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid())
+ code += " float tex_orbit_velocity = textureLod(orbit_velocity_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_orbit_velocity = 0.0;\n";
+ }
+
+ if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid())
+ code += " float tex_angular_velocity = textureLod(angular_velocity_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_angular_velocity = 0.0;\n";
+
+ if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid())
+ code += " float tex_linear_accel = textureLod(linear_accel_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_linear_accel = 0.0;\n";
+
+ if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid())
+ code += " float tex_radial_accel = textureLod(radial_accel_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_radial_accel = 0.0;\n";
+
+ if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid())
+ code += " float tex_tangent_accel = textureLod(tangent_accel_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_tangent_accel = 0.0;\n";
+
+ if (tex_parameters[PARAM_DAMPING].is_valid())
+ code += " float tex_damping = textureLod(damping_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_damping = 0.0;\n";
+
+ if (tex_parameters[PARAM_ANGLE].is_valid())
+ code += " float tex_angle = textureLod(angle_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_angle = 0.0;\n";
+
+ if (tex_parameters[PARAM_ANIM_SPEED].is_valid())
+ code += " float tex_anim_speed = textureLod(anim_speed_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_anim_speed = 0.0;\n";
+
+ if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
+ code += " float tex_anim_offset = textureLod(anim_offset_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_anim_offset = 0.0;\n";
+
+ code += " vec3 force = gravity;\n";
+ code += " vec3 pos = TRANSFORM[3].xyz;\n";
+ if (flags[FLAG_DISABLE_Z]) {
+ code += " pos.z = 0.0;\n";
+ }
+ code += " // apply linear acceleration\n";
+ code += " force += length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel + tex_linear_accel) * mix(1.0, rand_from_seed(alt_seed), linear_accel_random) : vec3(0.0);\n";
+ code += " // apply radial acceleration\n";
+ code += " vec3 org = EMISSION_TRANSFORM[3].xyz;\n";
+ code += " vec3 diff = pos - org;\n";
+ 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), 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), tangent_accel_random)) : vec3(0.0);\n";
+ }
+ code += " // apply attractor forces\n";
+ code += " VELOCITY += force * DELTA;\n";
+ code += " // orbit velocity\n";
+ if (flags[FLAG_DISABLE_Z]) {
+
+ code += " float orbit_amount = (orbit_velocity + tex_orbit_velocity) * mix(1.0, rand_from_seed(alt_seed), orbit_velocity_random);\n";
+ code += " if (orbit_amount != 0.0) {\n";
+ code += " float ang = orbit_amount * DELTA * pi * 2.0;\n";
+ code += " mat2 rot = mat2(vec2(cos(ang), -sin(ang)), vec2(sin(ang), cos(ang)));\n";
+ code += " TRANSFORM[3].xy -= diff.xy;\n";
+ code += " TRANSFORM[3].xy += rot * diff.xy;\n";
+ code += " }\n";
+ }
+
+ if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
+ code += " VELOCITY = normalize(VELOCITY) * tex_linear_velocity;\n";
+ }
+ code += " if (damping + tex_damping > 0.0) {\n";
+ code += " float v = length(VELOCITY);\n";
+ code += " float damp = (damping + tex_damping) * mix(1.0, rand_from_seed(alt_seed), damping_random);\n";
+ code += " v -= damp * DELTA;\n";
+ code += " if (v < 0.0) {\n";
+ code += " VELOCITY = vec3(0.0);\n";
+ code += " } else {\n";
+ code += " VELOCITY = normalize(VELOCITY) * v;\n";
+ code += " }\n";
+ code += " }\n";
+ code += " float base_angle = (initial_angle + tex_angle) * mix(1.0, angle_rand, initial_angle_random);\n";
+ code += " base_angle += CUSTOM.y * LIFETIME * (angular_velocity + tex_angular_velocity) * mix(1.0, rand_from_seed(alt_seed) * 2.0 - 1.0, angular_velocity_random);\n";
+ code += " CUSTOM.x = base_angle * degree_to_rad;\n"; // angle
+ code += " CUSTOM.z = (anim_offset + tex_anim_offset) * mix(1.0, anim_offset_rand, anim_offset_random) + CUSTOM.y * (anim_speed + tex_anim_speed) * mix(1.0, rand_from_seed(alt_seed), anim_speed_random);\n"; // angle
+ if (flags[FLAG_ANIM_LOOP]) {
+ code += " CUSTOM.z = mod(CUSTOM.z, 1.0);\n"; // loop
+
+ } else {
+ code += " CUSTOM.z = clamp(CUSTOM.z, 0.0, 1.0);\n"; // 0 to 1 only
+ }
+ code += " }\n";
+ // apply color
+ // apply hue rotation
+ if (tex_parameters[PARAM_SCALE].is_valid())
+ code += " float tex_scale = textureLod(scale_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_scale = 1.0;\n";
+
+ if (tex_parameters[PARAM_HUE_VARIATION].is_valid())
+ code += " float tex_hue_variation = textureLod(hue_variation_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
+ else
+ code += " float tex_hue_variation = 0.0;\n";
+
+ code += " float hue_rot_angle = (hue_variation + tex_hue_variation) * pi * 2.0 * mix(1.0, hue_rot_rand * 2.0 - 1.0, hue_variation_random);\n";
+ code += " float hue_rot_c = cos(hue_rot_angle);\n";
+ code += " float hue_rot_s = sin(hue_rot_angle);\n";
+ code += " mat4 hue_rot_mat = mat4(vec4(0.299, 0.587, 0.114, 0.0),\n";
+ code += " vec4(0.299, 0.587, 0.114, 0.0),\n";
+ code += " vec4(0.299, 0.587, 0.114, 0.0),\n";
+ code += " vec4(0.000, 0.000, 0.000, 1.0)) +\n";
+ code += " mat4(vec4(0.701, -0.587, -0.114, 0.0),\n";
+ code += " vec4(-0.299, 0.413, -0.114, 0.0),\n";
+ code += " vec4(-0.300, -0.588, 0.886, 0.0),\n";
+ code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_c +\n";
+ code += " mat4(vec4(0.168, 0.330, -0.497, 0.0),\n";
+ code += " vec4(-0.328, 0.035, 0.292, 0.0),\n";
+ code += " vec4(1.250, -1.050, -0.203, 0.0),\n";
+ code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_s;\n";
+ if (color_ramp.is_valid()) {
+ code += " COLOR = hue_rot_mat * textureLod(color_ramp, vec2(CUSTOM.y, 0.0), 0.0);\n";
+ } else {
+ code += " COLOR = hue_rot_mat * color_value;\n";
+ }
+ if (emission_color_texture.is_valid() && emission_shape >= EMISSION_SHAPE_POINTS) {
+ code += " COLOR *= texelFetch(emission_texture_color, emission_tex_ofs, 0);\n";
+ }
+ if (trail_color_modifier.is_valid()) {
+ code += " if (trail_divisor > 1) {\n";
+ code += " COLOR *= textureLod(trail_color_modifier, vec2(float(int(NUMBER) % trail_divisor) / float(trail_divisor - 1), 0.0), 0.0);\n";
+ code += " }\n";
+ }
+ code += "\n";
+
+ if (flags[FLAG_DISABLE_Z]) {
+
+ if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
+ code += " if (length(VELOCITY) > 0.0) {\n";
+ code += " TRANSFORM[1].xyz = normalize(VELOCITY);\n";
+ code += " } else {\n";
+ code += " TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz);\n";
+ code += " }\n";
+ code += " TRANSFORM[0].xyz = normalize(cross(TRANSFORM[1].xyz, TRANSFORM[2].xyz));\n";
+ code += " TRANSFORM[2] = vec4(0.0, 0.0, 1.0, 0.0);\n";
+ } else {
+ code += " TRANSFORM[0] = vec4(cos(CUSTOM.x), -sin(CUSTOM.x), 0.0, 0.0);\n";
+ code += " TRANSFORM[1] = vec4(sin(CUSTOM.x), cos(CUSTOM.x), 0.0, 0.0);\n";
+ code += " TRANSFORM[2] = vec4(0.0, 0.0, 1.0, 0.0);\n";
+ }
+
+ } else {
+ // orient particle Y towards velocity
+ if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
+ code += " if (length(VELOCITY) > 0.0) {\n";
+ code += " TRANSFORM[1].xyz = normalize(VELOCITY);\n";
+ code += " } else {\n";
+ code += " TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz);\n";
+ code += " }\n";
+ code += " if (TRANSFORM[1].xyz == normalize(TRANSFORM[0].xyz)) {\n";
+ code += " TRANSFORM[0].xyz = normalize(cross(normalize(TRANSFORM[1].xyz), normalize(TRANSFORM[2].xyz)));\n";
+ code += " TRANSFORM[2].xyz = normalize(cross(normalize(TRANSFORM[0].xyz), normalize(TRANSFORM[1].xyz)));\n";
+ code += " } else {\n";
+ code += " TRANSFORM[2].xyz = normalize(cross(normalize(TRANSFORM[0].xyz), normalize(TRANSFORM[1].xyz)));\n";
+ code += " TRANSFORM[0].xyz = normalize(cross(normalize(TRANSFORM[1].xyz), normalize(TRANSFORM[2].xyz)));\n";
+ code += " }\n";
+ } else {
+ code += " TRANSFORM[0].xyz = normalize(TRANSFORM[0].xyz);\n";
+ code += " TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz);\n";
+ code += " TRANSFORM[2].xyz = normalize(TRANSFORM[2].xyz);\n";
+ }
+ // turn particle by rotation in Y
+ if (flags[FLAG_ROTATE_Y]) {
+ code += " TRANSFORM = TRANSFORM * mat4(vec4(cos(CUSTOM.x), 0.0, -sin(CUSTOM.x), 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(sin(CUSTOM.x), 0.0, cos(CUSTOM.x), 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n";
+ }
+ }
+ //scale by scale
+ code += " float base_scale = mix(scale * tex_scale, 1.0, scale_random * scale_rand);\n";
+ code += " if (base_scale == 0.0) {\n";
+ code += " base_scale = 0.000001;\n";
+ code += " }\n";
+ if (trail_size_modifier.is_valid()) {
+ code += " if (trail_divisor > 1) {\n";
+ code += " base_scale *= textureLod(trail_size_modifier, vec2(float(int(NUMBER) % trail_divisor) / float(trail_divisor - 1), 0.0), 0.0).r;\n";
+ code += " }\n";
+ }
+
+ code += " TRANSFORM[0].xyz *= base_scale;\n";
+ code += " TRANSFORM[1].xyz *= base_scale;\n";
+ code += " TRANSFORM[2].xyz *= base_scale;\n";
+ if (flags[FLAG_DISABLE_Z]) {
+ code += " VELOCITY.z = 0.0;\n";
+ code += " TRANSFORM[3].z = 0.0;\n";
+ }
+ code += "}\n";
+ code += "\n";
+
+ ShaderData shader_data;
+ shader_data.shader = VS::get_singleton()->shader_create();
+ shader_data.users = 1;
+
+ VS::get_singleton()->shader_set_code(shader_data.shader, code);
+
+ shader_map[mk] = shader_data;
+
+ VS::get_singleton()->material_set_shader(_get_material(), shader_data.shader);
+}
+
+void ParticlesMaterial::flush_changes() {
+
+ if (material_mutex)
+ material_mutex->lock();
+
+ while (dirty_materials.first()) {
+
+ dirty_materials.first()->self()->_update_shader();
+ }
+
+ if (material_mutex)
+ material_mutex->unlock();
+}
+
+void ParticlesMaterial::_queue_shader_change() {
+
+ if (material_mutex)
+ material_mutex->lock();
+
+ if (!element.in_list()) {
+ dirty_materials.add(&element);
+ }
+
+ if (material_mutex)
+ material_mutex->unlock();
+}
+
+bool ParticlesMaterial::_is_shader_dirty() const {
+
+ bool dirty = false;
+
+ if (material_mutex)
+ material_mutex->lock();
+
+ dirty = element.in_list();
+
+ if (material_mutex)
+ material_mutex->unlock();
+
+ return dirty;
+}
+
+void ParticlesMaterial::set_spread(float p_spread) {
+
+ spread = p_spread;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->spread, p_spread);
+}
+
+float ParticlesMaterial::get_spread() const {
+
+ return spread;
+}
+
+void ParticlesMaterial::set_flatness(float p_flatness) {
+
+ flatness = p_flatness;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->flatness, p_flatness);
+}
+float ParticlesMaterial::get_flatness() const {
+
+ return flatness;
+}
+
+void ParticlesMaterial::set_param(Parameter p_param, float p_value) {
+
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+
+ parameters[p_param] = p_value;
+
+ switch (p_param) {
+ case PARAM_INITIAL_LINEAR_VELOCITY: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity, p_value);
+ } break;
+ case PARAM_ANGULAR_VELOCITY: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity, p_value);
+ } break;
+ case PARAM_ORBIT_VELOCITY: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity, p_value);
+ } break;
+ case PARAM_LINEAR_ACCEL: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel, p_value);
+ } break;
+ case PARAM_RADIAL_ACCEL: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel, p_value);
+ } break;
+ case PARAM_TANGENTIAL_ACCEL: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel, p_value);
+ } break;
+ case PARAM_DAMPING: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping, p_value);
+ } break;
+ case PARAM_ANGLE: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle, p_value);
+ } break;
+ case PARAM_SCALE: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale, p_value);
+ } break;
+ case PARAM_HUE_VARIATION: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation, p_value);
+ } break;
+ case PARAM_ANIM_SPEED: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed, p_value);
+ } break;
+ 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 {
+
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
+
+ return parameters[p_param];
+}
+
+void ParticlesMaterial::set_param_randomness(Parameter p_param, float p_value) {
+
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+
+ randomness[p_param] = p_value;
+
+ switch (p_param) {
+ case PARAM_INITIAL_LINEAR_VELOCITY: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity_random, p_value);
+ } break;
+ case PARAM_ANGULAR_VELOCITY: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_random, p_value);
+ } break;
+ case PARAM_ORBIT_VELOCITY: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_random, p_value);
+ } break;
+ case PARAM_LINEAR_ACCEL: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_random, p_value);
+ } break;
+ case PARAM_RADIAL_ACCEL: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_random, p_value);
+ } break;
+ case PARAM_TANGENTIAL_ACCEL: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_random, p_value);
+ } break;
+ case PARAM_DAMPING: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_random, p_value);
+ } break;
+ case PARAM_ANGLE: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle_random, p_value);
+ } break;
+ case PARAM_SCALE: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_random, p_value);
+ } break;
+ case PARAM_HUE_VARIATION: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_random, p_value);
+ } break;
+ case PARAM_ANIM_SPEED: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_random, p_value);
+ } break;
+ 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 {
+
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
+
+ return randomness[p_param];
+}
+
+static void _adjust_curve_range(const Ref<Texture> &p_texture, float p_min, float p_max) {
+
+ Ref<CurveTexture> curve_tex = p_texture;
+ if (!curve_tex.is_valid())
+ return;
+
+ curve_tex->ensure_default_setup(p_min, p_max);
+}
+
+void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture> &p_texture) {
+
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+
+ tex_parameters[p_param] = p_texture;
+
+ switch (p_param) {
+ case PARAM_INITIAL_LINEAR_VELOCITY: {
+ //do none for this one
+ } break;
+ case PARAM_ANGULAR_VELOCITY: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_texture, p_texture);
+ _adjust_curve_range(p_texture, -360, 360);
+ } break;
+ case PARAM_ORBIT_VELOCITY: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_texture, p_texture);
+ _adjust_curve_range(p_texture, -500, 500);
+ } break;
+ case PARAM_LINEAR_ACCEL: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_texture, p_texture);
+ _adjust_curve_range(p_texture, -200, 200);
+ } break;
+ case PARAM_RADIAL_ACCEL: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_texture, p_texture);
+ _adjust_curve_range(p_texture, -200, 200);
+ } break;
+ case PARAM_TANGENTIAL_ACCEL: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_texture, p_texture);
+ _adjust_curve_range(p_texture, -200, 200);
+ } break;
+ case PARAM_DAMPING: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_texture, p_texture);
+ _adjust_curve_range(p_texture, 0, 100);
+ } break;
+ case PARAM_ANGLE: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angle_texture, p_texture);
+ _adjust_curve_range(p_texture, -360, 360);
+ } break;
+ case PARAM_SCALE: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_texture, p_texture);
+
+ Ref<CurveTexture> curve_tex = p_texture;
+ if (curve_tex.is_valid()) {
+ curve_tex->ensure_default_setup();
+ }
+
+ } break;
+ case PARAM_HUE_VARIATION: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_texture, p_texture);
+ _adjust_curve_range(p_texture, -1, 1);
+ } break;
+ case PARAM_ANIM_SPEED: {
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_texture, p_texture);
+ _adjust_curve_range(p_texture, 0, 200);
+ } break;
+ 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();
+}
+Ref<Texture> ParticlesMaterial::get_param_texture(Parameter p_param) const {
+
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Texture>());
+
+ return tex_parameters[p_param];
+}
+
+void ParticlesMaterial::set_color(const Color &p_color) {
+
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color, p_color);
+ color = p_color;
+}
+
+Color ParticlesMaterial::get_color() const {
+
+ return color;
+}
+
+void ParticlesMaterial::set_color_ramp(const Ref<Texture> &p_texture) {
+
+ color_ramp = p_texture;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color_ramp, p_texture);
+ _queue_shader_change();
+ _change_notify();
+}
+
+Ref<Texture> ParticlesMaterial::get_color_ramp() const {
+
+ return color_ramp;
+}
+
+void ParticlesMaterial::set_flag(Flags p_flag, bool p_enable) {
+ ERR_FAIL_INDEX(p_flag, FLAG_MAX);
+ flags[p_flag] = p_enable;
+ _queue_shader_change();
+ if (p_flag == FLAG_DISABLE_Z) {
+ _change_notify();
+ }
+}
+
+bool ParticlesMaterial::get_flag(Flags p_flag) const {
+ ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
+ return flags[p_flag];
+}
+
+void ParticlesMaterial::set_emission_shape(EmissionShape p_shape) {
+
+ emission_shape = p_shape;
+ _change_notify();
+ _queue_shader_change();
+}
+
+void ParticlesMaterial::set_emission_sphere_radius(float p_radius) {
+
+ emission_sphere_radius = p_radius;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_sphere_radius, p_radius);
+}
+
+void ParticlesMaterial::set_emission_box_extents(Vector3 p_extents) {
+
+ emission_box_extents = p_extents;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_box_extents, p_extents);
+}
+
+void ParticlesMaterial::set_emission_point_texture(const Ref<Texture> &p_points) {
+
+ emission_point_texture = p_points;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_points, p_points);
+}
+
+void ParticlesMaterial::set_emission_normal_texture(const Ref<Texture> &p_normals) {
+
+ emission_normal_texture = p_normals;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_normal, p_normals);
+}
+
+void ParticlesMaterial::set_emission_color_texture(const Ref<Texture> &p_colors) {
+
+ emission_color_texture = p_colors;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_color, p_colors);
+ _queue_shader_change();
+}
+
+void ParticlesMaterial::set_emission_point_count(int p_count) {
+
+ emission_point_count = p_count;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_point_count, p_count);
+}
+
+ParticlesMaterial::EmissionShape ParticlesMaterial::get_emission_shape() const {
+
+ return emission_shape;
+}
+
+float ParticlesMaterial::get_emission_sphere_radius() const {
+
+ return emission_sphere_radius;
+}
+Vector3 ParticlesMaterial::get_emission_box_extents() const {
+
+ return emission_box_extents;
+}
+Ref<Texture> ParticlesMaterial::get_emission_point_texture() const {
+
+ return emission_point_texture;
+}
+Ref<Texture> ParticlesMaterial::get_emission_normal_texture() const {
+
+ return emission_normal_texture;
+}
+
+Ref<Texture> ParticlesMaterial::get_emission_color_texture() const {
+
+ return emission_color_texture;
+}
+
+int ParticlesMaterial::get_emission_point_count() const {
+
+ return emission_point_count;
+}
+
+void ParticlesMaterial::set_trail_divisor(int p_divisor) {
+
+ trail_divisor = p_divisor;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_divisor, p_divisor);
+}
+
+int ParticlesMaterial::get_trail_divisor() const {
+
+ return trail_divisor;
+}
+
+void ParticlesMaterial::set_trail_size_modifier(const Ref<CurveTexture> &p_trail_size_modifier) {
+
+ trail_size_modifier = p_trail_size_modifier;
+
+ Ref<CurveTexture> curve = trail_size_modifier;
+ if (curve.is_valid()) {
+ curve->ensure_default_setup();
+ }
+
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_size_modifier, curve);
+ _queue_shader_change();
+}
+
+Ref<CurveTexture> ParticlesMaterial::get_trail_size_modifier() const {
+
+ return trail_size_modifier;
+}
+
+void ParticlesMaterial::set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier) {
+
+ trail_color_modifier = p_trail_color_modifier;
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_color_modifier, p_trail_color_modifier);
+ _queue_shader_change();
+}
+
+Ref<GradientTexture> ParticlesMaterial::get_trail_color_modifier() const {
+
+ return trail_color_modifier;
+}
+
+void ParticlesMaterial::set_gravity(const Vector3 &p_gravity) {
+
+ gravity = p_gravity;
+ Vector3 gset = gravity;
+ if (gset == Vector3()) {
+ gset = Vector3(0, -0.000001, 0); //as gravity is used as upvector in some calculations
+ }
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->gravity, gset);
+}
+
+Vector3 ParticlesMaterial::get_gravity() const {
+
+ return gravity;
+}
+
+RID ParticlesMaterial::get_shader_rid() const {
+
+ ERR_FAIL_COND_V(!shader_map.has(current_key), RID());
+ return shader_map[current_key].shader;
+}
+
+void ParticlesMaterial::_validate_property(PropertyInfo &property) const {
+
+ if (property.name == "color" && color_ramp.is_valid()) {
+ property.usage = 0;
+ }
+
+ if (property.name == "emission_sphere_radius" && emission_shape != EMISSION_SHAPE_SPHERE) {
+ property.usage = 0;
+ }
+
+ if (property.name == "emission_box_extents" && emission_shape != EMISSION_SHAPE_BOX) {
+ property.usage = 0;
+ }
+
+ if ((property.name == "emission_point_texture" || property.name == "emission_color_texture") && (emission_shape < EMISSION_SHAPE_POINTS)) {
+ property.usage = 0;
+ }
+
+ if (property.name == "emission_normal_texture" && emission_shape != EMISSION_SHAPE_DIRECTED_POINTS) {
+ property.usage = 0;
+ }
+
+ if (property.name == "emission_point_count" && (emission_shape != EMISSION_SHAPE_POINTS && emission_shape != EMISSION_SHAPE_DIRECTED_POINTS)) {
+ property.usage = 0;
+ }
+
+ if (property.name.begins_with("orbit_") && !flags[FLAG_DISABLE_Z]) {
+ property.usage = 0;
+ }
+}
+
+Shader::Mode ParticlesMaterial::get_shader_mode() const {
+
+ return Shader::MODE_PARTICLES;
+}
+
+void ParticlesMaterial::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_spread", "degrees"), &ParticlesMaterial::set_spread);
+ ClassDB::bind_method(D_METHOD("get_spread"), &ParticlesMaterial::get_spread);
+
+ ClassDB::bind_method(D_METHOD("set_flatness", "amount"), &ParticlesMaterial::set_flatness);
+ ClassDB::bind_method(D_METHOD("get_flatness"), &ParticlesMaterial::get_flatness);
+
+ ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &ParticlesMaterial::set_param);
+ ClassDB::bind_method(D_METHOD("get_param", "param"), &ParticlesMaterial::get_param);
+
+ ClassDB::bind_method(D_METHOD("set_param_randomness", "param", "randomness"), &ParticlesMaterial::set_param_randomness);
+ ClassDB::bind_method(D_METHOD("get_param_randomness", "param"), &ParticlesMaterial::get_param_randomness);
+
+ ClassDB::bind_method(D_METHOD("set_param_texture", "param", "texture"), &ParticlesMaterial::set_param_texture);
+ ClassDB::bind_method(D_METHOD("get_param_texture", "param"), &ParticlesMaterial::get_param_texture);
+
+ ClassDB::bind_method(D_METHOD("set_color", "color"), &ParticlesMaterial::set_color);
+ ClassDB::bind_method(D_METHOD("get_color"), &ParticlesMaterial::get_color);
+
+ ClassDB::bind_method(D_METHOD("set_color_ramp", "ramp"), &ParticlesMaterial::set_color_ramp);
+ ClassDB::bind_method(D_METHOD("get_color_ramp"), &ParticlesMaterial::get_color_ramp);
+
+ ClassDB::bind_method(D_METHOD("set_flag", "flag", "enable"), &ParticlesMaterial::set_flag);
+ ClassDB::bind_method(D_METHOD("get_flag", "flag"), &ParticlesMaterial::get_flag);
+
+ ClassDB::bind_method(D_METHOD("set_emission_shape", "shape"), &ParticlesMaterial::set_emission_shape);
+ ClassDB::bind_method(D_METHOD("get_emission_shape"), &ParticlesMaterial::get_emission_shape);
+
+ ClassDB::bind_method(D_METHOD("set_emission_sphere_radius", "radius"), &ParticlesMaterial::set_emission_sphere_radius);
+ ClassDB::bind_method(D_METHOD("get_emission_sphere_radius"), &ParticlesMaterial::get_emission_sphere_radius);
+
+ ClassDB::bind_method(D_METHOD("set_emission_box_extents", "extents"), &ParticlesMaterial::set_emission_box_extents);
+ ClassDB::bind_method(D_METHOD("get_emission_box_extents"), &ParticlesMaterial::get_emission_box_extents);
+
+ ClassDB::bind_method(D_METHOD("set_emission_point_texture", "texture"), &ParticlesMaterial::set_emission_point_texture);
+ ClassDB::bind_method(D_METHOD("get_emission_point_texture"), &ParticlesMaterial::get_emission_point_texture);
+
+ ClassDB::bind_method(D_METHOD("set_emission_normal_texture", "texture"), &ParticlesMaterial::set_emission_normal_texture);
+ ClassDB::bind_method(D_METHOD("get_emission_normal_texture"), &ParticlesMaterial::get_emission_normal_texture);
+
+ ClassDB::bind_method(D_METHOD("set_emission_color_texture", "texture"), &ParticlesMaterial::set_emission_color_texture);
+ ClassDB::bind_method(D_METHOD("get_emission_color_texture"), &ParticlesMaterial::get_emission_color_texture);
+
+ ClassDB::bind_method(D_METHOD("set_emission_point_count", "point_count"), &ParticlesMaterial::set_emission_point_count);
+ ClassDB::bind_method(D_METHOD("get_emission_point_count"), &ParticlesMaterial::get_emission_point_count);
+
+ ClassDB::bind_method(D_METHOD("set_trail_divisor", "divisor"), &ParticlesMaterial::set_trail_divisor);
+ ClassDB::bind_method(D_METHOD("get_trail_divisor"), &ParticlesMaterial::get_trail_divisor);
+
+ ClassDB::bind_method(D_METHOD("set_trail_size_modifier", "texture"), &ParticlesMaterial::set_trail_size_modifier);
+ ClassDB::bind_method(D_METHOD("get_trail_size_modifier"), &ParticlesMaterial::get_trail_size_modifier);
+
+ ClassDB::bind_method(D_METHOD("set_trail_color_modifier", "texture"), &ParticlesMaterial::set_trail_color_modifier);
+ ClassDB::bind_method(D_METHOD("get_trail_color_modifier"), &ParticlesMaterial::get_trail_color_modifier);
+
+ ClassDB::bind_method(D_METHOD("get_gravity"), &ParticlesMaterial::get_gravity);
+ ClassDB::bind_method(D_METHOD("set_gravity", "accel_vec"), &ParticlesMaterial::set_gravity);
+
+ ADD_GROUP("Trail", "trail_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "trail_divisor", PROPERTY_HINT_RANGE, "1,1000000,1"), "set_trail_divisor", "get_trail_divisor");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trail_size_modifier", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_trail_size_modifier", "get_trail_size_modifier");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trail_color_modifier", PROPERTY_HINT_RESOURCE_TYPE, "GradientTexture"), "set_trail_color_modifier", "get_trail_color_modifier");
+ ADD_GROUP("Emission Shape", "emission_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_shape", PROPERTY_HINT_ENUM, "Point,Sphere,Box,Points,Directed Points"), "set_emission_shape", "get_emission_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_sphere_radius", PROPERTY_HINT_RANGE, "0.01,128,0.01,or_greater"), "set_emission_sphere_radius", "get_emission_sphere_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_box_extents"), "set_emission_box_extents", "get_emission_box_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_point_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_point_texture", "get_emission_point_texture");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_normal_texture", "get_emission_normal_texture");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_color_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_color_texture", "get_emission_color_texture");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_point_count", PROPERTY_HINT_RANGE, "0,1000000,1"), "set_emission_point_count", "get_emission_point_count");
+ ADD_GROUP("Flags", "flag_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_align_y"), "set_flag", "get_flag", FLAG_ALIGN_Y_TO_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_rotate_y"), "set_flag", "get_flag", FLAG_ROTATE_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_disable_z"), "set_flag", "get_flag", FLAG_DISABLE_Z);
+ ADD_GROUP("Spread", "");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "spread", PROPERTY_HINT_RANGE, "0,180,0.01"), "set_spread", "get_spread");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "flatness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_flatness", "get_flatness");
+ ADD_GROUP("Gravity", "");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity"), "set_gravity", "get_gravity");
+ ADD_GROUP("Initial Velocity", "initial_");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "initial_velocity", PROPERTY_HINT_RANGE, "0,1000,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_INITIAL_LINEAR_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "initial_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_INITIAL_LINEAR_VELOCITY);
+ ADD_GROUP("Angular Velocity", "angular_");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity", PROPERTY_HINT_RANGE, "-360,360,0.01"), "set_param", "get_param", PARAM_ANGULAR_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGULAR_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angular_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANGULAR_VELOCITY);
+ ADD_GROUP("Orbit Velocity", "orbit_");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "orbit_velocity", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_ORBIT_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "orbit_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ORBIT_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "orbit_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ORBIT_VELOCITY);
+ ADD_GROUP("Linear Accel", "linear_");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_accel", PROPERTY_HINT_RANGE, "-100,100,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_LINEAR_ACCEL);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_accel_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_LINEAR_ACCEL);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "linear_accel_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_LINEAR_ACCEL);
+ ADD_GROUP("Radial Accel", "radial_");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "radial_accel", PROPERTY_HINT_RANGE, "-100,100,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_RADIAL_ACCEL);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "radial_accel_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_RADIAL_ACCEL);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "radial_accel_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_RADIAL_ACCEL);
+ ADD_GROUP("Tangential Accel", "tangential_");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "tangential_accel", PROPERTY_HINT_RANGE, "-100,100,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_TANGENTIAL_ACCEL);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "tangential_accel_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_TANGENTIAL_ACCEL);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "tangential_accel_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_TANGENTIAL_ACCEL);
+ ADD_GROUP("Damping", "");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "damping", PROPERTY_HINT_RANGE, "0,100,0.01,or_greater"), "set_param", "get_param", PARAM_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "damping_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "damping_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_DAMPING);
+ ADD_GROUP("Angle", "");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angle", PROPERTY_HINT_RANGE, "-720,720,0.1,or_lesser,or_greater"), "set_param", "get_param", PARAM_ANGLE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angle_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGLE);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angle_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANGLE);
+ ADD_GROUP("Scale", "");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_SCALE);
+ ADD_GROUP("Color", "");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_ramp", PROPERTY_HINT_RESOURCE_TYPE, "GradientTexture"), "set_color_ramp", "get_color_ramp");
+
+ ADD_GROUP("Hue Variation", "hue_");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hue_variation", PROPERTY_HINT_RANGE, "-1,1,0.1"), "set_param", "get_param", PARAM_HUE_VARIATION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hue_variation_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_HUE_VARIATION);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "hue_variation_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_HUE_VARIATION);
+ ADD_GROUP("Animation", "anim_");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anim_speed", PROPERTY_HINT_RANGE, "0,128,0.01,or_greater"), "set_param", "get_param", PARAM_ANIM_SPEED);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anim_speed_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANIM_SPEED);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anim_speed_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANIM_SPEED);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anim_offset", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_ANIM_OFFSET);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anim_offset_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANIM_OFFSET);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anim_offset_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANIM_OFFSET);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "anim_loop"), "set_flag", "get_flag", FLAG_ANIM_LOOP);
+
+ BIND_ENUM_CONSTANT(PARAM_INITIAL_LINEAR_VELOCITY);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_VELOCITY);
+ BIND_ENUM_CONSTANT(PARAM_ORBIT_VELOCITY);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_ACCEL);
+ BIND_ENUM_CONSTANT(PARAM_RADIAL_ACCEL);
+ BIND_ENUM_CONSTANT(PARAM_TANGENTIAL_ACCEL);
+ BIND_ENUM_CONSTANT(PARAM_DAMPING);
+ BIND_ENUM_CONSTANT(PARAM_ANGLE);
+ BIND_ENUM_CONSTANT(PARAM_SCALE);
+ BIND_ENUM_CONSTANT(PARAM_HUE_VARIATION);
+ BIND_ENUM_CONSTANT(PARAM_ANIM_SPEED);
+ BIND_ENUM_CONSTANT(PARAM_ANIM_OFFSET);
+ BIND_ENUM_CONSTANT(PARAM_MAX);
+
+ BIND_ENUM_CONSTANT(FLAG_ALIGN_Y_TO_VELOCITY);
+ BIND_ENUM_CONSTANT(FLAG_ROTATE_Y);
+ BIND_ENUM_CONSTANT(FLAG_MAX);
+
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINT);
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_SPHERE);
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX);
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
+}
+
+ParticlesMaterial::ParticlesMaterial() :
+ element(this) {
+
+ set_spread(45);
+ set_flatness(0);
+ set_param(PARAM_INITIAL_LINEAR_VELOCITY, 0);
+ set_param(PARAM_ORBIT_VELOCITY, 0);
+ set_param(PARAM_LINEAR_ACCEL, 0);
+ set_param(PARAM_RADIAL_ACCEL, 0);
+ set_param(PARAM_TANGENTIAL_ACCEL, 0);
+ set_param(PARAM_DAMPING, 0);
+ set_param(PARAM_ANGLE, 0);
+ set_param(PARAM_SCALE, 1);
+ set_param(PARAM_HUE_VARIATION, 0);
+ set_param(PARAM_ANIM_SPEED, 0);
+ set_param(PARAM_ANIM_OFFSET, 0);
+ set_emission_shape(EMISSION_SHAPE_POINT);
+ set_emission_sphere_radius(1);
+ set_emission_box_extents(Vector3(1, 1, 1));
+ set_trail_divisor(1);
+ set_gravity(Vector3(0, -9.8, 0));
+ emission_point_count = 1;
+
+ for (int i = 0; i < PARAM_MAX; i++) {
+ set_param_randomness(Parameter(i), 0);
+ }
+
+ for (int i = 0; i < FLAG_MAX; i++) {
+ flags[i] = false;
+ }
+
+ set_color(Color(1, 1, 1, 1));
+
+ current_key.key = 0;
+ current_key.invalid_key = 1;
+
+ _queue_shader_change();
+}
+
+ParticlesMaterial::~ParticlesMaterial() {
+
+ if (material_mutex)
+ material_mutex->lock();
+
+ if (shader_map.has(current_key)) {
+ shader_map[current_key].users--;
+ if (shader_map[current_key].users == 0) {
+ //deallocate shader, as it's no longer in use
+ VS::get_singleton()->free(shader_map[current_key].shader);
+ shader_map.erase(current_key);
+ }
+
+ VS::get_singleton()->material_set_shader(_get_material(), RID());
+ }
+
+ if (material_mutex)
+ material_mutex->unlock();
+}
diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h
new file mode 100644
index 0000000000..91fdcc0346
--- /dev/null
+++ b/scene/resources/particles_material.h
@@ -0,0 +1,302 @@
+/*************************************************************************/
+/* particles_material.h */
+/*************************************************************************/
+/* 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. */
+/*************************************************************************/
+
+#include "core/rid.h"
+#include "scene/resources/material.h"
+
+#ifndef PARTICLES_MATERIAL_H
+#define PARTICLES_MATERIAL_H
+
+class ParticlesMaterial : public Material {
+
+ GDCLASS(ParticlesMaterial, Material)
+
+public:
+ enum Parameter {
+
+ PARAM_INITIAL_LINEAR_VELOCITY,
+ PARAM_ANGULAR_VELOCITY,
+ PARAM_ORBIT_VELOCITY,
+ PARAM_LINEAR_ACCEL,
+ PARAM_RADIAL_ACCEL,
+ PARAM_TANGENTIAL_ACCEL,
+ PARAM_DAMPING,
+ PARAM_ANGLE,
+ PARAM_SCALE,
+ PARAM_HUE_VARIATION,
+ PARAM_ANIM_SPEED,
+ PARAM_ANIM_OFFSET,
+ PARAM_MAX
+ };
+
+ enum Flags {
+ FLAG_ALIGN_Y_TO_VELOCITY,
+ FLAG_ROTATE_Y,
+ FLAG_DISABLE_Z,
+ FLAG_ANIM_LOOP,
+ FLAG_MAX
+ };
+
+ enum EmissionShape {
+ EMISSION_SHAPE_POINT,
+ EMISSION_SHAPE_SPHERE,
+ EMISSION_SHAPE_BOX,
+ EMISSION_SHAPE_POINTS,
+ EMISSION_SHAPE_DIRECTED_POINTS,
+ };
+
+private:
+ union MaterialKey {
+
+ struct {
+ uint32_t texture_mask : 16;
+ uint32_t texture_color : 1;
+ uint32_t flags : 4;
+ uint32_t emission_shape : 2;
+ uint32_t trail_size_texture : 1;
+ uint32_t trail_color_texture : 1;
+ uint32_t invalid_key : 1;
+ uint32_t has_emission_color : 1;
+ };
+
+ uint32_t key;
+
+ bool operator<(const MaterialKey &p_key) const {
+ return key < p_key.key;
+ }
+ };
+
+ struct ShaderData {
+ RID shader;
+ int users;
+ };
+
+ static Map<MaterialKey, ShaderData> shader_map;
+
+ MaterialKey current_key;
+
+ _FORCE_INLINE_ MaterialKey _compute_key() const {
+
+ MaterialKey mk;
+ mk.key = 0;
+ for (int i = 0; i < PARAM_MAX; i++) {
+ if (tex_parameters[i].is_valid()) {
+ mk.texture_mask |= (1 << i);
+ }
+ }
+ for (int i = 0; i < FLAG_MAX; i++) {
+ if (flags[i]) {
+ mk.flags |= (1 << i);
+ }
+ }
+
+ mk.texture_color = color_ramp.is_valid() ? 1 : 0;
+ mk.emission_shape = emission_shape;
+ mk.trail_color_texture = trail_color_modifier.is_valid() ? 1 : 0;
+ mk.trail_size_texture = trail_size_modifier.is_valid() ? 1 : 0;
+ mk.has_emission_color = emission_shape >= EMISSION_SHAPE_POINTS && emission_color_texture.is_valid();
+
+ return mk;
+ }
+
+ static Mutex *material_mutex;
+ static SelfList<ParticlesMaterial>::List dirty_materials;
+
+ struct ShaderNames {
+ StringName spread;
+ StringName flatness;
+ StringName initial_linear_velocity;
+ StringName initial_angle;
+ StringName angular_velocity;
+ StringName orbit_velocity;
+ StringName linear_accel;
+ StringName radial_accel;
+ StringName tangent_accel;
+ StringName damping;
+ StringName scale;
+ StringName hue_variation;
+ StringName anim_speed;
+ StringName anim_offset;
+
+ StringName initial_linear_velocity_random;
+ StringName initial_angle_random;
+ StringName angular_velocity_random;
+ StringName orbit_velocity_random;
+ StringName linear_accel_random;
+ StringName radial_accel_random;
+ StringName tangent_accel_random;
+ StringName damping_random;
+ StringName scale_random;
+ StringName hue_variation_random;
+ StringName anim_speed_random;
+ StringName anim_offset_random;
+
+ StringName angle_texture;
+ StringName angular_velocity_texture;
+ StringName orbit_velocity_texture;
+ StringName linear_accel_texture;
+ StringName radial_accel_texture;
+ StringName tangent_accel_texture;
+ StringName damping_texture;
+ StringName scale_texture;
+ StringName hue_variation_texture;
+ StringName anim_speed_texture;
+ StringName anim_offset_texture;
+
+ StringName color;
+ StringName color_ramp;
+
+ StringName emission_sphere_radius;
+ StringName emission_box_extents;
+ StringName emission_texture_point_count;
+ StringName emission_texture_points;
+ StringName emission_texture_normal;
+ StringName emission_texture_color;
+
+ StringName trail_divisor;
+ StringName trail_size_modifier;
+ StringName trail_color_modifier;
+
+ StringName gravity;
+ };
+
+ static ShaderNames *shader_names;
+
+ SelfList<ParticlesMaterial> element;
+
+ void _update_shader();
+ _FORCE_INLINE_ void _queue_shader_change();
+ _FORCE_INLINE_ bool _is_shader_dirty() const;
+
+ float spread;
+ float flatness;
+
+ float parameters[PARAM_MAX];
+ float randomness[PARAM_MAX];
+
+ Ref<Texture> tex_parameters[PARAM_MAX];
+ Color color;
+ Ref<Texture> color_ramp;
+
+ bool flags[FLAG_MAX];
+
+ EmissionShape emission_shape;
+ float emission_sphere_radius;
+ Vector3 emission_box_extents;
+ Ref<Texture> emission_point_texture;
+ Ref<Texture> emission_normal_texture;
+ Ref<Texture> emission_color_texture;
+ int emission_point_count;
+
+ bool anim_loop;
+
+ int trail_divisor;
+
+ Ref<CurveTexture> trail_size_modifier;
+ Ref<GradientTexture> trail_color_modifier;
+
+ Vector3 gravity;
+
+ //do not save emission points here
+
+protected:
+ static void _bind_methods();
+ virtual void _validate_property(PropertyInfo &property) const;
+
+public:
+ void set_spread(float p_spread);
+ float get_spread() const;
+
+ void set_flatness(float p_flatness);
+ float get_flatness() const;
+
+ void set_param(Parameter p_param, float p_value);
+ float get_param(Parameter p_param) const;
+
+ void set_param_randomness(Parameter p_param, float p_value);
+ float get_param_randomness(Parameter p_param) const;
+
+ void set_param_texture(Parameter p_param, const Ref<Texture> &p_texture);
+ Ref<Texture> get_param_texture(Parameter p_param) const;
+
+ void set_color(const Color &p_color);
+ Color get_color() const;
+
+ void set_color_ramp(const Ref<Texture> &p_texture);
+ Ref<Texture> get_color_ramp() const;
+
+ void set_flag(Flags p_flag, bool p_enable);
+ bool get_flag(Flags p_flag) const;
+
+ void set_emission_shape(EmissionShape p_shape);
+ void set_emission_sphere_radius(float p_radius);
+ void set_emission_box_extents(Vector3 p_extents);
+ void set_emission_point_texture(const Ref<Texture> &p_points);
+ void set_emission_normal_texture(const Ref<Texture> &p_normals);
+ void set_emission_color_texture(const Ref<Texture> &p_colors);
+ void set_emission_point_count(int p_count);
+
+ EmissionShape get_emission_shape() const;
+ float get_emission_sphere_radius() const;
+ Vector3 get_emission_box_extents() const;
+ Ref<Texture> get_emission_point_texture() const;
+ Ref<Texture> get_emission_normal_texture() const;
+ Ref<Texture> get_emission_color_texture() const;
+ int get_emission_point_count() const;
+
+ void set_trail_divisor(int p_divisor);
+ int get_trail_divisor() const;
+
+ void set_trail_size_modifier(const Ref<CurveTexture> &p_trail_size_modifier);
+ Ref<CurveTexture> get_trail_size_modifier() const;
+
+ void set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier);
+ Ref<GradientTexture> get_trail_color_modifier() const;
+
+ void set_gravity(const Vector3 &p_gravity);
+ Vector3 get_gravity() const;
+
+ static void init_shaders();
+ static void finish_shaders();
+ static void flush_changes();
+
+ RID get_shader_rid() const;
+
+ virtual Shader::Mode get_shader_mode() const;
+
+ ParticlesMaterial();
+ ~ParticlesMaterial();
+};
+
+VARIANT_ENUM_CAST(ParticlesMaterial::Parameter)
+VARIANT_ENUM_CAST(ParticlesMaterial::Flags)
+VARIANT_ENUM_CAST(ParticlesMaterial::EmissionShape)
+
+#endif // PARTICLES_MATERIAL_H
diff --git a/scene/resources/physics_material.h b/scene/resources/physics_material.h
index c882e2081a..bf11bf0ac1 100644
--- a/scene/resources/physics_material.h
+++ b/scene/resources/physics_material.h
@@ -31,7 +31,7 @@
#ifndef physics_material_override_H
#define physics_material_override_H
-#include "resource.h"
+#include "core/resource.h"
#include "servers/physics_server.h"
class PhysicsMaterial : public Resource {
diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp
index 44f9ebaf33..bd03930c9e 100644
--- a/scene/resources/polygon_path_finder.cpp
+++ b/scene/resources/polygon_path_finder.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "polygon_path_finder.h"
-#include "geometry.h"
+#include "core/math/geometry.h"
bool PolygonPathFinder::_is_point_inside(const Vector2 &p_point) const {
diff --git a/scene/resources/polygon_path_finder.h b/scene/resources/polygon_path_finder.h
index 19761c274c..66282458af 100644
--- a/scene/resources/polygon_path_finder.h
+++ b/scene/resources/polygon_path_finder.h
@@ -31,7 +31,7 @@
#ifndef POLYGON_PATH_FINDER_H
#define POLYGON_PATH_FINDER_H
-#include "resource.h"
+#include "core/resource.h"
class PolygonPathFinder : public Resource {
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 28aa6f1aa7..63aa44e1d8 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -89,7 +89,7 @@ void PrimitiveMesh::_update() const {
pending_request = false;
- _clear_triangle_mesh();
+ clear_cache();
const_cast<PrimitiveMesh *>(this)->emit_changed();
}
diff --git a/scene/resources/room.h b/scene/resources/room.h
index 359d918665..d5ad847516 100644
--- a/scene/resources/room.h
+++ b/scene/resources/room.h
@@ -31,8 +31,8 @@
#ifndef ROOM_BOUNDS_H
#define ROOM_BOUNDS_H
-#include "bsp_tree.h"
-#include "resource.h"
+#include "core/math/bsp_tree.h"
+#include "core/resource.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index fd9989fe72..597ffe49ae 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -30,15 +30,15 @@
#include "scene_format_text.h"
#include "core/io/resource_format_binary.h"
-#include "os/dir_access.h"
-#include "project_settings.h"
-#include "version.h"
+#include "core/os/dir_access.h"
+#include "core/project_settings.h"
+#include "core/version.h"
//version 2: changed names for basis, aabb, poolvectors, etc.
#define FORMAT_VERSION 2
-#include "os/dir_access.h"
-#include "version.h"
+#include "core/os/dir_access.h"
+#include "core/version.h"
#define _printerr() ERR_PRINT(String(res_path + ":" + itos(lines) + " - Parse Error: " + error_text).utf8().get_data());
@@ -294,25 +294,25 @@ Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::R
if (!next_tag.fields.has("from")) {
error = ERR_FILE_CORRUPT;
- error_text = "missing 'from' field fron connection tag";
+ error_text = "missing 'from' field from connection tag";
return Ref<PackedScene>();
}
if (!next_tag.fields.has("to")) {
error = ERR_FILE_CORRUPT;
- error_text = "missing 'to' field fron connection tag";
+ error_text = "missing 'to' field from connection tag";
return Ref<PackedScene>();
}
if (!next_tag.fields.has("signal")) {
error = ERR_FILE_CORRUPT;
- error_text = "missing 'signal' field fron connection tag";
+ error_text = "missing 'signal' field from connection tag";
return Ref<PackedScene>();
}
if (!next_tag.fields.has("method")) {
error = ERR_FILE_CORRUPT;
- error_text = "missing 'method' field fron connection tag";
+ error_text = "missing 'method' field from connection tag";
return Ref<PackedScene>();
}
@@ -358,7 +358,7 @@ Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::R
if (!next_tag.fields.has("path")) {
error = ERR_FILE_CORRUPT;
- error_text = "missing 'path' field fron connection tag";
+ error_text = "missing 'path' field from connection tag";
_printerr();
return Ref<PackedScene>();
}
diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h
index c28ded3d77..8d1af2bbb2 100644
--- a/scene/resources/scene_format_text.h
+++ b/scene/resources/scene_format_text.h
@@ -31,11 +31,11 @@
#ifndef SCENE_FORMAT_TEXT_H
#define SCENE_FORMAT_TEXT_H
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-#include "os/file_access.h"
+#include "core/io/resource_loader.h"
+#include "core/io/resource_saver.h"
+#include "core/os/file_access.h"
+#include "core/variant_parser.h"
#include "scene/resources/packed_scene.h"
-#include "variant_parser.h"
class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index f53f03c1c8..66bf3b4991 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "shader.h"
-#include "os/file_access.h"
+#include "core/os/file_access.h"
#include "scene/scene_string_names.h"
#include "servers/visual/shader_language.h"
#include "servers/visual_server.h"
@@ -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 efc5da7753..c2c205237f 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -31,9 +31,9 @@
#ifndef SHADER_H
#define SHADER_H
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-#include "resource.h"
+#include "core/io/resource_loader.h"
+#include "core/io/resource_saver.h"
+#include "core/resource.h"
#include "scene/resources/texture.h"
class Shader : public Resource {
@@ -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/shape.cpp b/scene/resources/shape.cpp
index a48ce0564b..8ccca81acd 100644
--- a/scene/resources/shape.cpp
+++ b/scene/resources/shape.cpp
@@ -30,7 +30,7 @@
#include "shape.h"
-#include "os/os.h"
+#include "core/os/os.h"
#include "scene/main/scene_tree.h"
#include "scene/resources/mesh.h"
#include "servers/physics_server.h"
diff --git a/scene/resources/shape.h b/scene/resources/shape.h
index 0c44b86e92..6643f4ee44 100644
--- a/scene/resources/shape.h
+++ b/scene/resources/shape.h
@@ -31,7 +31,7 @@
#ifndef SHAPE_H
#define SHAPE_H
-#include "resource.h"
+#include "core/resource.h"
class ArrayMesh;
class Shape : public Resource {
diff --git a/scene/resources/shape_2d.h b/scene/resources/shape_2d.h
index 7eb0406bd8..fa39daa565 100644
--- a/scene/resources/shape_2d.h
+++ b/scene/resources/shape_2d.h
@@ -31,7 +31,7 @@
#ifndef SHAPE_2D_H
#define SHAPE_2D_H
-#include "resource.h"
+#include "core/resource.h"
class Shape2D : public Resource {
GDCLASS(Shape2D, Resource);
diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp
index 4176aed4d8..a6a52c7bba 100644
--- a/scene/resources/sky_box.cpp
+++ b/scene/resources/sky_box.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "sky_box.h"
-#include "io/image_loader.h"
+#include "core/io/image_loader.h"
void Sky::set_radiance_size(RadianceSize p_size) {
ERR_FAIL_INDEX(p_size, RADIANCE_SIZE_MAX);
diff --git a/scene/resources/sky_box.h b/scene/resources/sky_box.h
index e561653a9e..bbb852822d 100644
--- a/scene/resources/sky_box.h
+++ b/scene/resources/sky_box.h
@@ -31,7 +31,7 @@
#ifndef SKY_BOX_H
#define SKY_BOX_H
-#include "os/thread.h"
+#include "core/os/thread.h"
#include "scene/resources/texture.h"
class Sky : public Resource {
GDCLASS(Sky, Resource);
diff --git a/scene/resources/space_2d.h b/scene/resources/space_2d.h
index 148285ac6d..1143ad2bd5 100644
--- a/scene/resources/space_2d.h
+++ b/scene/resources/space_2d.h
@@ -31,7 +31,7 @@
#ifndef SPACE_2D_H
#define SPACE_2D_H
-#include "resource.h"
+#include "core/resource.h"
#include "servers/physics_2d_server.h"
class Space2D : public Resource {
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index ed193a1ab4..df3ebe1c36 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -31,7 +31,7 @@
#ifndef STYLE_BOX_H
#define STYLE_BOX_H
-#include "resource.h"
+#include "core/resource.h"
#include "scene/resources/texture.h"
#include "servers/visual_server.h"
/**
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 81fabf40fe..5d4c7861e3 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -29,7 +29,8 @@
/*************************************************************************/
#include "surface_tool.h"
-#include "method_bind_ext.gen.inc"
+
+#include "core/method_bind_ext.gen.inc"
#define _VERTEX_SNAP 0.0001
#define EQ_VERTEX_DIST 0.00001
diff --git a/scene/resources/text_file.cpp b/scene/resources/text_file.cpp
index e2fe0adfc5..2af24ad2d5 100644
--- a/scene/resources/text_file.cpp
+++ b/scene/resources/text_file.cpp
@@ -30,7 +30,7 @@
#include "text_file.h"
-#include "os/file_access.h"
+#include "core/os/file_access.h"
bool TextFile::has_text() const {
return text != "";
diff --git a/scene/resources/text_file.h b/scene/resources/text_file.h
index 40b648eebb..3abc769dc6 100644
--- a/scene/resources/text_file.h
+++ b/scene/resources/text_file.h
@@ -31,8 +31,8 @@
#ifndef TEXTFILE_H
#define TEXTFILE_H
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
+#include "core/io/resource_loader.h"
+#include "core/io/resource_saver.h"
class TextFile : public Resource {
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 811e5c3d2c..f0e3979f13 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -29,11 +29,12 @@
/*************************************************************************/
#include "texture.h"
-#include "bit_mask.h"
+
+#include "core/core_string_names.h"
+#include "core/io/image_loader.h"
#include "core/method_bind_ext.gen.inc"
#include "core/os/os.h"
-#include "core_string_names.h"
-#include "io/image_loader.h"
+#include "scene/resources/bit_mask.h"
Size2 Texture::get_size() const {
@@ -206,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);
}
@@ -1606,7 +1610,7 @@ void GradientTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update"), &GradientTexture::_update);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gradient", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_gradient", "get_gradient");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "width"), "set_width", "get_width");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_width", "get_width");
}
void GradientTexture::set_gradient(Ref<Gradient> p_gradient) {
@@ -1632,16 +1636,17 @@ void GradientTexture::_queue_update() {
if (update_pending)
return;
+ update_pending = true;
call_deferred("_update");
}
void GradientTexture::_update() {
+ update_pending = false;
+
if (gradient.is_null())
return;
- update_pending = false;
-
PoolVector<uint8_t> data;
data.resize(width * 4);
{
@@ -1944,8 +1949,8 @@ void AnimatedTexture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fps", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_fps", "get_fps");
for (int i = 0; i < MAX_FRAMES; i++) {
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "frame_" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_frame_texture", "get_frame_texture", i);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "frame_" + itos(i) + "/delay_sec", PROPERTY_HINT_RANGE, "0.0,16.0,0.01"), "set_frame_delay", "get_frame_delay", i);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "frame_" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_frame_texture", "get_frame_texture", i);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "frame_" + itos(i) + "/delay_sec", PROPERTY_HINT_RANGE, "0.0,16.0,0.01", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_frame_delay", "get_frame_delay", i);
}
}
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 79e6d2cdf9..cb759c63da 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -31,15 +31,16 @@
#ifndef TEXTURE_H
#define TEXTURE_H
-#include "curve.h"
-#include "io/resource_loader.h"
-#include "os/mutex.h"
-#include "os/rw_lock.h"
-#include "os/thread_safe.h"
-#include "rect2.h"
-#include "resource.h"
+#include "core/io/resource_loader.h"
+#include "core/math/rect2.h"
+#include "core/os/mutex.h"
+#include "core/os/rw_lock.h"
+#include "core/os/thread_safe.h"
+#include "core/resource.h"
#include "scene/resources/color_ramp.h"
+#include "scene/resources/curve.h"
#include "servers/visual_server.h"
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index f903669fc7..b102d477f2 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "theme.h"
-#include "os/file_access.h"
-#include "print_string.h"
+#include "core/os/file_access.h"
+#include "core/print_string.h"
Ref<Theme> Theme::default_theme;
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index e0d4038e7e..0b76e95f18 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -31,8 +31,8 @@
#ifndef THEME_H
#define THEME_H
-#include "io/resource_loader.h"
-#include "resource.h"
+#include "core/io/resource_loader.h"
+#include "core/resource.h"
#include "scene/resources/font.h"
#include "scene/resources/shader.h"
#include "scene/resources/style_box.h"
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 23074b4bae..f852ecd7eb 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "tile_set.h"
-#include "array.h"
+#include "core/array.h"
bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index 40eee2700d..1802bf12b6 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -32,7 +32,7 @@
#define TILE_SET_H
#include "core/array.h"
-#include "resource.h"
+#include "core/resource.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/navigation_polygon.h"
#include "scene/resources/shape_2d.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 46b936b731..96b9cfa137 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "visual_shader.h"
+#include "core/vmap.h"
#include "servers/visual/shader_types.h"
-#include "vmap.h"
void VisualShaderNode::set_output_port_for_preview(int p_index) {
@@ -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 81dd37de3c..2867daac3a 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -31,8 +31,8 @@
#ifndef VISUAL_SHADER_H
#define VISUAL_SHADER_H
+#include "core/string_builder.h"
#include "scene/resources/shader.h"
-#include "string_builder.h"
class VisualShaderNodeUniform;
class VisualShaderNode;
@@ -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.cpp b/scene/resources/world.cpp
index 82183d24e7..b4588cd87c 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -30,8 +30,8 @@
#include "world.h"
-#include "camera_matrix.h"
-#include "octree.h"
+#include "core/math/camera_matrix.h"
+#include "core/math/octree.h"
#include "scene/3d/camera.h"
#include "scene/3d/visibility_notifier.h"
#include "scene/scene_string_names.h"
diff --git a/scene/resources/world.h b/scene/resources/world.h
index 54bdf25784..4ba6b13476 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world.h
@@ -31,14 +31,14 @@
#ifndef WORLD_H
#define WORLD_H
-#include "resource.h"
+#include "core/resource.h"
#include "scene/resources/environment.h"
#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 bed6ffd1bd..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 "project_settings.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 59f34e32f2..88ad392f85 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -31,13 +31,13 @@
#ifndef WORLD_2D_H
#define WORLD_2D_H
-#include "project_settings.h"
-#include "resource.h"
+#include "core/project_settings.h"
+#include "core/resource.h"
#include "servers/physics_2d_server.h"
-class SpatialIndexer2D;
class VisibilityNotifier2D;
class Viewport;
+struct SpatialIndexer2D;
class World2D : public Resource {
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index dbbcf79b9f..25e2c5d4a6 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -31,8 +31,8 @@
#ifndef SCENE_STRING_NAMES_H
#define SCENE_STRING_NAMES_H
-#include "node_path.h"
-#include "string_db.h"
+#include "core/node_path.h"
+#include "core/string_db.h"
class SceneStringNames {
friend void register_scene_types();