summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/animated_sprite.cpp71
-rw-r--r--scene/2d/animated_sprite.h6
-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.h2
-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.cpp4
-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/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.cpp6
-rw-r--r--scene/2d/tile_map.h4
-rw-r--r--scene/2d/visibility_notifier_2d.cpp2
-rw-r--r--scene/3d/area.cpp10
-rw-r--r--scene/3d/area.h2
-rw-r--r--scene/3d/audio_stream_player_3d.cpp2
-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.cpp5
-rw-r--r--scene/3d/cpu_particles.h5
-rw-r--r--scene/3d/interpolated_camera.cpp2
-rw-r--r--scene/3d/light.cpp6
-rw-r--r--scene/3d/mesh_instance.cpp2
-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.cpp38
-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.cpp2
-rw-r--r--scene/3d/sprite_3d.cpp2
-rw-r--r--scene/3d/visibility_notifier.cpp2
-rw-r--r--scene/3d/visual_instance.h4
-rw-r--r--scene/3d/voxel_light_baker.cpp4
-rw-r--r--scene/animation/animation_blend_space_2d.cpp2
-rw-r--r--scene/animation/animation_player.cpp63
-rw-r--r--scene/animation/animation_tree.cpp3
-rw-r--r--scene/animation/tween.cpp3
-rw-r--r--scene/audio/audio_player.cpp2
-rw-r--r--scene/gui/base_button.cpp2
-rw-r--r--scene/gui/button.cpp2
-rw-r--r--scene/gui/check_button.cpp2
-rw-r--r--scene/gui/color_picker.cpp6
-rw-r--r--scene/gui/container.cpp2
-rw-r--r--scene/gui/control.cpp17
-rw-r--r--scene/gui/control.h4
-rw-r--r--scene/gui/dialogs.cpp4
-rw-r--r--scene/gui/file_dialog.cpp4
-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.cpp6
-rw-r--r--scene/gui/graph_node.cpp3
-rw-r--r--scene/gui/item_list.cpp4
-rw-r--r--scene/gui/label.cpp6
-rw-r--r--scene/gui/line_edit.cpp10
-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/reference_rect.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp4
-rw-r--r--scene/gui/scroll_bar.cpp6
-rw-r--r--scene/gui/scroll_container.cpp2
-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.cpp2
-rw-r--r--scene/gui/tab_container.cpp2
-rw-r--r--scene/gui/tabs.cpp2
-rw-r--r--scene/gui/text_edit.cpp76
-rw-r--r--scene/gui/text_edit.h1
-rw-r--r--scene/gui/texture_progress.cpp2
-rw-r--r--scene/gui/tree.cpp18
-rw-r--r--scene/gui/video_player.cpp2
-rw-r--r--scene/main/http_request.h6
-rw-r--r--scene/main/instance_placeholder.cpp2
-rw-r--r--scene/main/node.cpp22
-rw-r--r--scene/main/node.h13
-rw-r--r--scene/main/scene_tree.cpp21
-rw-r--r--scene/main/scene_tree.h8
-rwxr-xr-xscene/main/timer.cpp2
-rw-r--r--scene/main/viewport.cpp6
-rw-r--r--scene/main/viewport.h2
-rw-r--r--scene/register_scene_types.cpp5
-rw-r--r--scene/resources/animation.cpp2
-rw-r--r--scene/resources/animation.h2
-rw-r--r--scene/resources/audio_stream_sample.cpp4
-rw-r--r--scene/resources/bit_mask.cpp2
-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/default_theme.cpp2
-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.cpp2
-rw-r--r--scene/resources/font.h4
-rw-r--r--scene/resources/material.h4
-rw-r--r--scene/resources/mesh.cpp40
-rw-r--r--scene/resources/mesh.h9
-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.cpp1259
-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.cpp10
-rw-r--r--scene/resources/scene_format_text.h8
-rw-r--r--scene/resources/shader.cpp2
-rw-r--r--scene/resources/shader.h6
-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.cpp7
-rw-r--r--scene/resources/texture.h12
-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.h2
-rw-r--r--scene/resources/visual_shader.cpp2
-rw-r--r--scene/resources/visual_shader.h2
-rw-r--r--scene/resources/world.cpp4
-rw-r--r--scene/resources/world.h2
-rw-r--r--scene/resources/world_2d.cpp2
-rw-r--r--scene/resources/world_2d.h4
-rw-r--r--scene/scene_string_names.h4
180 files changed, 2267 insertions, 2017 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 85e7f8df92..790606a0b2 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"
@@ -227,65 +227,6 @@ bool SpriteFrames::get_animation_loop(const StringName &p_anim) const {
return E->get().loop;
}
-void SpriteFrames::_set_frames(const Array &p_frames) {
-
- clear_all();
- Map<StringName, Anim>::Element *E = animations.find(SceneStringNames::get_singleton()->_default);
- ERR_FAIL_COND(!E);
-
- E->get().frames.resize(p_frames.size());
- for (int i = 0; i < E->get().frames.size(); i++)
- E->get().frames.write[i] = p_frames[i];
-}
-Array SpriteFrames::_get_frames() const {
-
- return Array();
-}
-
-Array SpriteFrames::_get_animations() const {
-
- Array anims;
- for (Map<StringName, Anim>::Element *E = animations.front(); E; E = E->next()) {
- Dictionary d;
- d["name"] = E->key();
- d["speed"] = E->get().speed;
- d["loop"] = E->get().loop;
- Array frames;
- for (int i = 0; i < E->get().frames.size(); i++) {
- frames.push_back(E->get().frames[i]);
- }
- d["frames"] = frames;
- anims.push_back(d);
- }
-
- return anims;
-}
-void SpriteFrames::_set_animations(const Array &p_animations) {
-
- animations.clear();
- for (int i = 0; i < p_animations.size(); i++) {
-
- Dictionary d = p_animations[i];
-
- ERR_CONTINUE(!d.has("name"));
- ERR_CONTINUE(!d.has("speed"));
- ERR_CONTINUE(!d.has("loop"));
- ERR_CONTINUE(!d.has("frames"));
-
- Anim anim;
- anim.speed = d["speed"];
- anim.loop = d["loop"];
- Array frames = d["frames"];
- for (int i = 0; i < frames.size(); i++) {
-
- RES res = frames[i];
- anim.frames.push_back(res);
- }
-
- animations[d["name"]] = anim;
- }
-}
-
void SpriteFrames::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_animation", "anim"), &SpriteFrames::add_animation);
@@ -308,16 +249,6 @@ void SpriteFrames::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_frame", "anim", "idx"), &SpriteFrames::remove_frame);
ClassDB::bind_method(D_METHOD("clear", "anim"), &SpriteFrames::clear);
ClassDB::bind_method(D_METHOD("clear_all"), &SpriteFrames::clear_all);
-
- ClassDB::bind_method(D_METHOD("_set_frames"), &SpriteFrames::_set_frames);
- ClassDB::bind_method(D_METHOD("_get_frames"), &SpriteFrames::_get_frames);
-
- ADD_PROPERTYNZ(PropertyInfo(Variant::ARRAY, "frames", PROPERTY_HINT_NONE, "", 0), "_set_frames", "_get_frames"); //compatibility
-
- ClassDB::bind_method(D_METHOD("_set_animations"), &SpriteFrames::_set_animations);
- ClassDB::bind_method(D_METHOD("_get_animations"), &SpriteFrames::_get_animations);
-
- ADD_PROPERTYNZ(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_animations", "_get_animations"); //compatibility
}
SpriteFrames::SpriteFrames() {
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h
index cc49465403..672c9ef327 100644
--- a/scene/2d/animated_sprite.h
+++ b/scene/2d/animated_sprite.h
@@ -54,12 +54,6 @@ class SpriteFrames : public Resource {
Map<StringName, Anim> animations;
- Array _get_frames() const;
- void _set_frames(const Array &p_frames);
-
- Array _get_animations() const;
- void _set_animations(const Array &p_animations);
-
Vector<String> _get_animation_list() const;
protected:
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..6dc2e2e39d 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -346,6 +346,8 @@ public:
void set_notify_transform(bool p_enable);
bool is_transform_notification_enabled() const;
+ void force_update_transform();
+
// Used by control nodes to retreive the parent's anchorable area
virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); };
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..a8e0f0d07f 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) {
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/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..71bd51507e 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 {
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/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..386f2a4348 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"
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..712f0ba78b 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 {
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..80c2f005b6 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 {
@@ -312,7 +312,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/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..d7bd89625f 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);
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..818e7f9217 100644
--- a/scene/3d/spring_arm.cpp
+++ b/scene/3d/spring_arm.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#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"
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 036a748c83..36c0dfc18a 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() {
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.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/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_player.cpp b/scene/animation/animation_player.cpp
index d8db1973d2..2a4d526a7f 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;
}
}
}
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 9b06d538e9..7a4846e6d5 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"
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 58be636e44..074d36f6d9 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) {
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/base_button.cpp b/scene/gui/base_button.cpp
index d17ae1d84c..59590ea67b 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"
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index a34f2f1ad5..dd6d66ac62 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 {
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..537a16fbc3 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -30,9 +30,9 @@
#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"
#include "scene/gui/separator.h"
#include "scene/main/viewport.h"
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..24697e370f 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"
@@ -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);
}
@@ -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..c38cd66245 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>
*/
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..5f162a3652 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;
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..9045197333 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"));
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..ce8de38b74 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) {
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/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/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..b1c44aea3c 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#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
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index e5bd1c453d..df27fb0e6b 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;
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 495d618930..e3fb602065 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "scroll_container.h"
-#include "os/os.h"
+#include "core/os/os.h"
bool ScrollContainer::clips_input() const {
return true;
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..2221923093 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 {
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..60d5c45846 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
@@ -3119,16 +3119,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 +3206,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))
@@ -4822,28 +4838,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 +4871,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;
}
@@ -5910,6 +5929,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) {
@@ -6400,8 +6422,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..697dc3a5e0 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -373,6 +373,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_progress.cpp b/scene/gui/texture_progress.cpp
index 7923fdbaeb..8188d1dcf8 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) {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index bf473cca3b..be1870068d 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
@@ -3831,16 +3831,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")));
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 88e1847533..17ab234551 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 {
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..d4456738ae 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 {
diff --git a/scene/main/node.h b/scene/main/node.h
index f3422618ce..8d6c558e93 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);
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 1d23650a1e..16be6dad7d 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
}
}
@@ -1862,10 +1863,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..dfd9dfa52e 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"
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/animation.cpp b/scene/resources/animation.cpp
index 58e6db3f5e..694e959bcb 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
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..57d0deeb78 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) {
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index 5694099754..d670161afd 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) {
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/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 0eee2ae393..20fa1d6e2b 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"
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..50bf8f38f7 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;
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.h b/scene/resources/material.h
index f43d240a53..078649e7b0 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"
/**
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index e6ef956dc5..6426689397 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,8 +538,9 @@ 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() {
@@ -850,7 +853,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 +932,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 +1038,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 +1378,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_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..364ec9bb19
--- /dev/null
+++ b/scene/resources/particles_material.cpp
@@ -0,0 +1,1259 @@
+/*************************************************************************/
+/* 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;
+ }
+}
+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_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..02d2cf31f3 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());
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..1bfc41bd92 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"
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index efc5da7753..6c91205c0c 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 {
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..9875c7b130 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"
Size2 Texture::get_size() const {
@@ -1606,7 +1607,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) {
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 79e6d2cdf9..4865f7b507 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -31,13 +31,13 @@
#ifndef TEXTURE_H
#define TEXTURE_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 "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 "scene/resources/color_ramp.h"
#include "servers/visual_server.h"
/**
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..74dcd47c48 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"
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 46b936b731..6bfb6ec5bf 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) {
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 81dd37de3c..70d2425304 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;
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..4c517323f3 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world.h
@@ -31,7 +31,7 @@
#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"
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index bed6ffd1bd..b390e74073 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -32,7 +32,7 @@
#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"
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index 59f34e32f2..856e9dbf01 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -31,8 +31,8 @@
#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;
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();