From c0dfdd77f36eeb901d57703f7ac3f775c338feeb Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 15 Mar 2022 22:09:09 +0100 Subject: [PATCH] Removed particles editor plugins. --- editor/editor_node.cpp | 4 - editor/plugins/canvas_item_editor_plugin.cpp | 3 - editor/plugins/particles_2d_editor_plugin.cpp | 20 -- editor/plugins/particles_2d_editor_plugin.h | 1 - editor/plugins/particles_editor_plugin.cpp | 259 ------------------ editor/plugins/particles_editor_plugin.h | 54 ---- editor/plugins/spatial_editor_plugin.cpp | 1 - editor/plugins/spatial_editor_plugin.cpp.orig | 1 - editor/spatial_editor_gizmos.cpp | 163 ----------- editor/spatial_editor_gizmos.h | 18 -- scene/2d/cpu_particles_2d.cpp | 83 ------ scene/2d/cpu_particles_2d.h | 2 - scene/2d/visibility_notifier_2d.cpp | 15 - scene/3d/cpu_particles.cpp | 82 ------ scene/3d/cpu_particles.h | 2 - scene/3d/room_manager.cpp | 3 +- scene/register_scene_types.cpp | 4 - 17 files changed, 2 insertions(+), 713 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 656870e1e..54da78e26 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -134,8 +134,6 @@ #include "editor/plugins/mesh_library_editor_plugin.h" #include "editor/plugins/multimesh_editor_plugin.h" #include "editor/plugins/navigation_polygon_editor_plugin.h" -#include "editor/plugins/particles_2d_editor_plugin.h" -#include "editor/plugins/particles_editor_plugin.h" #include "editor/plugins/path_2d_editor_plugin.h" #include "editor/plugins/path_editor_plugin.h" #include "editor/plugins/physical_bone_plugin.h" @@ -6929,7 +6927,6 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(StyleBoxEditorPlugin(this))); add_editor_plugin(memnew(SpriteEditorPlugin(this))); add_editor_plugin(memnew(Skeleton2DEditorPlugin(this))); - add_editor_plugin(memnew(ParticlesEditorPlugin(this))); add_editor_plugin(memnew(CPUParticles2DEditorPlugin(this))); add_editor_plugin(memnew(CPUParticlesEditorPlugin(this))); add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this))); @@ -6940,7 +6937,6 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(TileMapEditorPlugin(this))); add_editor_plugin(memnew(SpriteFramesEditorPlugin(this))); add_editor_plugin(memnew(TextureRegionEditorPlugin(this))); - add_editor_plugin(memnew(Particles2DEditorPlugin(this))); add_editor_plugin(memnew(RoomManagerEditorPlugin(this))); add_editor_plugin(memnew(RoomEditorPlugin(this))); add_editor_plugin(memnew(OccluderEditorPlugin(this))); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 348704df7..88ebc8ebe 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -41,7 +41,6 @@ #include "editor/plugins/script_editor_plugin.h" #include "editor/script_editor_debugger.h" #include "scene/2d/light_2d.h" -#include "scene/2d/particles_2d.h" #include "scene/2d/polygon_2d.h" #include "scene/2d/skeleton_2d.h" #include "scene/2d/sprite.h" @@ -6535,8 +6534,6 @@ void CanvasItemEditorViewport::_perform_drop_data() { Node *child; if (default_type == "Light2D") { child = memnew(Light2D); - } else if (default_type == "Particles2D") { - child = memnew(Particles2D); } else if (default_type == "Polygon2D") { child = memnew(Polygon2D); } else if (default_type == "TouchScreenButton") { diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp index 2ee1b704a..ed35862a1 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/particles_2d_editor_plugin.cpp @@ -97,24 +97,6 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) { case MENU_CLEAR_EMISSION_MASK: { emission_mask->popup_centered_minsize(); } break; - case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: { - CPUParticles2D *cpu_particles = memnew(CPUParticles2D); - cpu_particles->convert_from_particles(particles); - cpu_particles->set_name(particles->get_name()); - cpu_particles->set_transform(particles->get_transform()); - cpu_particles->set_visible(particles->is_visible()); - cpu_particles->set_pause_mode(particles->get_pause_mode()); - cpu_particles->set_z_index(particles->get_z_index()); - - UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action(TTR("Convert to CPUParticles")); - ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", particles, cpu_particles, true, false); - ur->add_do_reference(cpu_particles); - ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, particles, false, false); - ur->add_undo_reference(particles); - ur->commit_action(); - - } break; case MENU_RESTART: { particles->restart(); } @@ -382,8 +364,6 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK); // menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK); menu->get_popup()->add_separator(); - menu->get_popup()->add_item(TTR("Convert to CPUParticles2D"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); - menu->get_popup()->add_separator(); menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART); menu->set_text(TTR("Particles")); menu->set_switch_on_hover(true); diff --git a/editor/plugins/particles_2d_editor_plugin.h b/editor/plugins/particles_2d_editor_plugin.h index 5b79b9ca3..c52682a79 100644 --- a/editor/plugins/particles_2d_editor_plugin.h +++ b/editor/plugins/particles_2d_editor_plugin.h @@ -46,7 +46,6 @@ class Particles2DEditorPlugin : public EditorPlugin { MENU_GENERATE_VISIBILITY_RECT, MENU_LOAD_EMISSION_MASK, MENU_CLEAR_EMISSION_MASK, - MENU_OPTION_CONVERT_TO_CPU_PARTICLES, MENU_RESTART }; diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index c58fe6bd2..0c34ecb3c 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -238,262 +238,3 @@ ParticlesEditorBase::ParticlesEditorBase() { emission_file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); } -void ParticlesEditor::_node_removed(Node *p_node) { - if (p_node == node) { - node = nullptr; - hide(); - } -} - -void ParticlesEditor::_notification(int p_notification) { - if (p_notification == NOTIFICATION_ENTER_TREE) { - options->set_icon(options->get_popup()->get_icon("Particles", "EditorIcons")); - get_tree()->connect("node_removed", this, "_node_removed"); - } -} - -void ParticlesEditor::_menu_option(int p_option) { - switch (p_option) { - case MENU_OPTION_GENERATE_AABB: { - float gen_time = node->get_lifetime(); - - if (gen_time < 1.0) { - generate_seconds->set_value(1.0); - } else { - generate_seconds->set_value(trunc(gen_time) + 1.0); - } - generate_aabb->popup_centered_minsize(); - } break; - case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH: { - Ref material = node->get_process_material(); - if (material.is_null()) { - EditorNode::get_singleton()->show_warning(TTR("A processor material of type 'ParticlesMaterial' is required.")); - return; - } - emission_file_dialog->popup_centered_ratio(); - - } break; - - case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: { - Ref material = node->get_process_material(); - if (material.is_null()) { - EditorNode::get_singleton()->show_warning(TTR("A processor material of type 'ParticlesMaterial' is required.")); - return; - } - - emission_tree_dialog->popup_centered_ratio(); - - } break; - case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: { - CPUParticles *cpu_particles = memnew(CPUParticles); - cpu_particles->convert_from_particles(node); - cpu_particles->set_name(node->get_name()); - cpu_particles->set_transform(node->get_transform()); - cpu_particles->set_visible(node->is_visible()); - cpu_particles->set_pause_mode(node->get_pause_mode()); - - UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action(TTR("Convert to CPUParticles")); - ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", node, cpu_particles, true, false); - ur->add_do_reference(cpu_particles); - ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, node, false, false); - ur->add_undo_reference(node); - ur->commit_action(); - - } break; - case MENU_OPTION_RESTART: { - node->restart(); - - } break; - } -} - -void ParticlesEditor::_generate_aabb() { - float time = generate_seconds->get_value(); - - float running = 0.0; - - EditorProgress ep("gen_aabb", TTR("Generating AABB"), int(time)); - - bool was_emitting = node->is_emitting(); - if (!was_emitting) { - node->set_emitting(true); - OS::get_singleton()->delay_usec(1000); - } - - AABB rect; - - while (running < time) { - uint64_t ticks = OS::get_singleton()->get_ticks_usec(); - ep.step("Generating...", int(running), true); - OS::get_singleton()->delay_usec(1000); - - AABB capture = node->capture_aabb(); - if (rect == AABB()) { - rect = capture; - } else { - rect.merge_with(capture); - } - - running += (OS::get_singleton()->get_ticks_usec() - ticks) / 1000000.0; - } - - if (!was_emitting) { - node->set_emitting(false); - } - - UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action(TTR("Generate Visibility AABB")); - ur->add_do_method(node, "set_visibility_aabb", rect); - ur->add_undo_method(node, "set_visibility_aabb", node->get_visibility_aabb()); - ur->commit_action(); -} - -void ParticlesEditor::edit(Particles *p_particles) { - base_node = p_particles; - node = p_particles; -} - -void ParticlesEditor::_generate_emission_points() { - /// hacer codigo aca - PoolVector points; - PoolVector normals; - - if (!_generate(points, normals)) { - return; - } - - int point_count = points.size(); - - int w = 2048; - int h = (point_count / 2048) + 1; - - PoolVector point_img; - point_img.resize(w * h * 3 * sizeof(float)); - - { - PoolVector::Write iw = point_img.write(); - memset(iw.ptr(), 0, w * h * 3 * sizeof(float)); - PoolVector::Read r = points.read(); - float *wf = (float *)iw.ptr(); - for (int i = 0; i < point_count; i++) { - wf[i * 3 + 0] = r[i].x; - wf[i * 3 + 1] = r[i].y; - wf[i * 3 + 2] = r[i].z; - } - } - - Ref image = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img)); - - Ref tex; - tex.instance(); - tex->create_from_image(image, Texture::FLAG_FILTER); - - Ref material = node->get_process_material(); - ERR_FAIL_COND(material.is_null()); - - if (normals.size() > 0) { - material->set_emission_shape(ParticlesMaterial::EMISSION_SHAPE_DIRECTED_POINTS); - material->set_emission_point_count(point_count); - material->set_emission_point_texture(tex); - - PoolVector point_img2; - point_img2.resize(w * h * 3 * sizeof(float)); - - { - PoolVector::Write iw = point_img2.write(); - memset(iw.ptr(), 0, w * h * 3 * sizeof(float)); - PoolVector::Read r = normals.read(); - float *wf = (float *)iw.ptr(); - for (int i = 0; i < point_count; i++) { - wf[i * 3 + 0] = r[i].x; - wf[i * 3 + 1] = r[i].y; - wf[i * 3 + 2] = r[i].z; - } - } - - Ref image2 = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img2)); - - Ref tex2; - tex2.instance(); - tex2->create_from_image(image2, Texture::FLAG_FILTER); - - material->set_emission_normal_texture(tex2); - } else { - material->set_emission_shape(ParticlesMaterial::EMISSION_SHAPE_POINTS); - material->set_emission_point_count(point_count); - material->set_emission_point_texture(tex); - } -} - -void ParticlesEditor::_bind_methods() { - ClassDB::bind_method("_menu_option", &ParticlesEditor::_menu_option); - ClassDB::bind_method("_generate_aabb", &ParticlesEditor::_generate_aabb); - ClassDB::bind_method("_node_removed", &ParticlesEditor::_node_removed); -} - -ParticlesEditor::ParticlesEditor() { - node = nullptr; - particles_editor_hb = memnew(HBoxContainer); - SpatialEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb); - options = memnew(MenuButton); - options->set_switch_on_hover(true); - particles_editor_hb->add_child(options); - particles_editor_hb->hide(); - - options->set_text(TTR("Particles")); - options->get_popup()->add_item(TTR("Generate Visibility AABB"), MENU_OPTION_GENERATE_AABB); - options->get_popup()->add_separator(); - options->get_popup()->add_item(TTR("Create Emission Points From Mesh"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH); - options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); - options->get_popup()->add_separator(); - options->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); - options->get_popup()->add_separator(); - options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART); - - options->get_popup()->connect("id_pressed", this, "_menu_option"); - - generate_aabb = memnew(ConfirmationDialog); - generate_aabb->set_title(TTR("Generate Visibility AABB")); - VBoxContainer *genvb = memnew(VBoxContainer); - generate_aabb->add_child(genvb); - generate_seconds = memnew(SpinBox); - genvb->add_margin_child(TTR("Generation Time (sec):"), generate_seconds); - generate_seconds->set_min(0.1); - generate_seconds->set_max(25); - generate_seconds->set_value(2); - - add_child(generate_aabb); - - generate_aabb->connect("confirmed", this, "_generate_aabb"); -} - -void ParticlesEditorPlugin::edit(Object *p_object) { - particles_editor->edit(Object::cast_to(p_object)); -} - -bool ParticlesEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Particles"); -} - -void ParticlesEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - particles_editor->show(); - particles_editor->particles_editor_hb->show(); - } else { - particles_editor->particles_editor_hb->hide(); - particles_editor->hide(); - particles_editor->edit(nullptr); - } -} - -ParticlesEditorPlugin::ParticlesEditorPlugin(EditorNode *p_node) { - editor = p_node; - particles_editor = memnew(ParticlesEditor); - editor->get_viewport()->add_child(particles_editor); - - particles_editor->hide(); -} - -ParticlesEditorPlugin::~ParticlesEditorPlugin() { -} diff --git a/editor/plugins/particles_editor_plugin.h b/editor/plugins/particles_editor_plugin.h index 879c490e2..0cefdb8dd 100644 --- a/editor/plugins/particles_editor_plugin.h +++ b/editor/plugins/particles_editor_plugin.h @@ -33,7 +33,6 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/3d/particles.h" #include "scene/gui/spin_box.h" class ParticlesEditorBase : public Control { @@ -64,57 +63,4 @@ public: ParticlesEditorBase(); }; -class ParticlesEditor : public ParticlesEditorBase { - GDCLASS(ParticlesEditor, ParticlesEditorBase); - - ConfirmationDialog *generate_aabb; - SpinBox *generate_seconds; - Particles *node; - - enum Menu { - - MENU_OPTION_GENERATE_AABB, - MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE, - MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH, - MENU_OPTION_CLEAR_EMISSION_VOLUME, - MENU_OPTION_CONVERT_TO_CPU_PARTICLES, - MENU_OPTION_RESTART, - - }; - - void _generate_aabb(); - - void _menu_option(int); - - friend class ParticlesEditorPlugin; - - virtual void _generate_emission_points(); - -protected: - void _notification(int p_notification); - void _node_removed(Node *p_node); - static void _bind_methods(); - -public: - void edit(Particles *p_particles); - ParticlesEditor(); -}; - -class ParticlesEditorPlugin : public EditorPlugin { - GDCLASS(ParticlesEditorPlugin, EditorPlugin); - - ParticlesEditor *particles_editor; - EditorNode *editor; - -public: - virtual String get_name() const { return "Particles"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_object); - virtual bool handles(Object *p_object) const; - virtual void make_visible(bool p_visible); - - ParticlesEditorPlugin(EditorNode *p_node); - ~ParticlesEditorPlugin(); -}; - #endif // PARTICLES_EDITOR_PLUGIN_H diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 405163ca6..deb1d944a 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -6540,7 +6540,6 @@ void SpatialEditor::_register_all_gizmos() { add_gizmo_plugin(Ref(memnew(SpringArmSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(VehicleWheelSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(VisibilityNotifierGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(ParticlesGizmoPlugin))); add_gizmo_plugin(Ref(memnew(CPUParticlesGizmoPlugin))); add_gizmo_plugin(Ref(memnew(ReflectionProbeGizmoPlugin))); add_gizmo_plugin(Ref(memnew(CollisionObjectGizmoPlugin))); diff --git a/editor/plugins/spatial_editor_plugin.cpp.orig b/editor/plugins/spatial_editor_plugin.cpp.orig index ed2e042b0..eca82f289 100644 --- a/editor/plugins/spatial_editor_plugin.cpp.orig +++ b/editor/plugins/spatial_editor_plugin.cpp.orig @@ -6537,7 +6537,6 @@ void SpatialEditor::_register_all_gizmos() { add_gizmo_plugin(Ref(memnew(SpringArmSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(VehicleWheelSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(VisibilityNotifierGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(ParticlesGizmoPlugin))); add_gizmo_plugin(Ref(memnew(CPUParticlesGizmoPlugin))); add_gizmo_plugin(Ref(memnew(ReflectionProbeGizmoPlugin))); add_gizmo_plugin(Ref(memnew(BakedIndirectLightGizmoPlugin))); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index ad56dc3a8..32f5bbae3 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -41,7 +41,6 @@ #include "scene/3d/mesh_instance.h" #include "scene/3d/navigation_mesh_instance.h" #include "scene/3d/occluder.h" -#include "scene/3d/particles.h" #include "scene/3d/physics_joint.h" #include "scene/3d/portal.h" #include "scene/3d/position_3d.h" @@ -2342,168 +2341,6 @@ void CPUParticlesGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { //// -ParticlesGizmoPlugin::ParticlesGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/particles", Color(0.8, 0.7, 0.4)); - create_material("particles_material", gizmo_color); - gizmo_color.a = 0.1; - create_material("particles_solid_material", gizmo_color); - create_icon_material("particles_icon", SpatialEditor::get_singleton()->get_icon("GizmoParticles", "EditorIcons")); - create_handle_material("handles"); -} - -bool ParticlesGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to(p_spatial) != nullptr; -} - -String ParticlesGizmoPlugin::get_name() const { - return "Particles"; -} - -int ParticlesGizmoPlugin::get_priority() const { - return -1; -} - -bool ParticlesGizmoPlugin::is_selectable_when_hidden() const { - return true; -} - -String ParticlesGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { - case 0: - return "Size X"; - case 1: - return "Size Y"; - case 2: - return "Size Z"; - case 3: - return "Pos X"; - case 4: - return "Pos Y"; - case 5: - return "Pos Z"; - } - - return ""; -} -Variant ParticlesGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { - Particles *particles = Object::cast_to(p_gizmo->get_spatial_node()); - return particles->get_visibility_aabb(); -} -void ParticlesGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { - Particles *particles = Object::cast_to(p_gizmo->get_spatial_node()); - - Transform gt = particles->get_global_transform(); - Transform gi = gt.affine_inverse(); - - bool move = p_idx >= 3; - p_idx = p_idx % 3; - - AABB aabb = particles->get_visibility_aabb(); - Vector3 ray_from = p_camera->project_ray_origin(p_point); - Vector3 ray_dir = p_camera->project_ray_normal(p_point); - - Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; - - Vector3 ofs = aabb.position + aabb.size * 0.5; - - Vector3 axis; - axis[p_idx] = 1.0; - - if (move) { - Vector3 ra, rb; - Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); - - float d = ra[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); - } - - aabb.position[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5; - particles->set_visibility_aabb(aabb); - - } else { - Vector3 ra, rb; - Geometry::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb); - - float d = ra[p_idx] - ofs[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); - } - - if (d < 0.001) { - d = 0.001; - } - //resize - aabb.position[p_idx] = (aabb.position[p_idx] + aabb.size[p_idx] * 0.5) - d; - aabb.size[p_idx] = d * 2; - particles->set_visibility_aabb(aabb); - } -} - -void ParticlesGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Particles *particles = Object::cast_to(p_gizmo->get_spatial_node()); - - if (p_cancel) { - particles->set_visibility_aabb(p_restore); - return; - } - - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); - ur->create_action(TTR("Change Particles AABB")); - ur->add_do_method(particles, "set_visibility_aabb", particles->get_visibility_aabb()); - ur->add_undo_method(particles, "set_visibility_aabb", p_restore); - ur->commit_action(); -} - -void ParticlesGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { - Particles *particles = Object::cast_to(p_gizmo->get_spatial_node()); - - p_gizmo->clear(); - - Vector lines; - AABB aabb = particles->get_visibility_aabb(); - - for (int i = 0; i < 12; i++) { - Vector3 a, b; - aabb.get_edge(i, a, b); - lines.push_back(a); - lines.push_back(b); - } - - Vector handles; - - for (int i = 0; i < 3; i++) { - Vector3 ax; - ax[i] = aabb.position[i] + aabb.size[i]; - ax[(i + 1) % 3] = aabb.position[(i + 1) % 3] + aabb.size[(i + 1) % 3] * 0.5; - ax[(i + 2) % 3] = aabb.position[(i + 2) % 3] + aabb.size[(i + 2) % 3] * 0.5; - handles.push_back(ax); - } - - Vector3 center = aabb.position + aabb.size * 0.5; - for (int i = 0; i < 3; i++) { - Vector3 ax; - ax[i] = 1.0; - handles.push_back(center + ax); - lines.push_back(center); - lines.push_back(center + ax); - } - - Ref material = get_material("particles_material", p_gizmo); - Ref icon = get_material("particles_icon", p_gizmo); - - p_gizmo->add_lines(lines, material); - - if (p_gizmo->is_selected()) { - Ref solid_material = get_material("particles_solid_material", p_gizmo); - p_gizmo->add_solid_box(solid_material, aabb.get_size(), aabb.get_position() + aabb.get_size() / 2.0); - } - - p_gizmo->add_handles(handles, get_material("handles")); - p_gizmo->add_unscaled_billboard(icon, 0.05); -} -//// - ReflectionProbeGizmoPlugin::ReflectionProbeGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/reflection_probe", Color(0.6, 1, 0.5)); diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index 73803007c..d2248cbfc 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -248,24 +248,6 @@ public: CPUParticlesGizmoPlugin(); }; -class ParticlesGizmoPlugin : public EditorSpatialGizmoPlugin { - GDCLASS(ParticlesGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - bool is_selectable_when_hidden() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - - ParticlesGizmoPlugin(); -}; - class ReflectionProbeGizmoPlugin : public EditorSpatialGizmoPlugin { GDCLASS(ReflectionProbeGizmoPlugin, EditorSpatialGizmoPlugin); diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index e591e534d..88c2e6c61 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -32,7 +32,6 @@ #include "core/core_string_names.h" #include "core/os/os.h" #include "scene/2d/canvas_item.h" -#include "scene/2d/particles_2d.h" #include "scene/resources/particles_material.h" #include "servers/visual_server.h" @@ -1105,86 +1104,6 @@ void CPUParticles2D::_notification(int p_what) { } } -void CPUParticles2D::convert_from_particles(Node *p_particles) { - Particles2D *particles = Object::cast_to(p_particles); - ERR_FAIL_COND_MSG(!particles, "Only Particles2D nodes can be converted to CPUParticles2D."); - - set_emitting(particles->is_emitting()); - set_amount(particles->get_amount()); - set_lifetime(particles->get_lifetime()); - set_one_shot(particles->get_one_shot()); - set_pre_process_time(particles->get_pre_process_time()); - set_explosiveness_ratio(particles->get_explosiveness_ratio()); - set_randomness_ratio(particles->get_randomness_ratio()); - set_use_local_coordinates(particles->get_use_local_coordinates()); - set_fixed_fps(particles->get_fixed_fps()); - set_fractional_delta(particles->get_fractional_delta()); - set_speed_scale(particles->get_speed_scale()); - set_draw_order(DrawOrder(particles->get_draw_order())); - set_texture(particles->get_texture()); - - Ref mat = particles->get_material(); - if (mat.is_valid()) { - set_material(mat); - } - - Ref material = particles->get_process_material(); - if (material.is_null()) { - return; - } - - Vector3 dir = material->get_direction(); - set_direction(Vector2(dir.x, dir.y)); - set_spread(material->get_spread()); - - set_color(material->get_color()); - - Ref gt = material->get_color_ramp(); - if (gt.is_valid()) { - set_color_ramp(gt->get_gradient()); - } - - Ref gti = material->get_color_initial_ramp(); - if (gti.is_valid()) { - set_color_initial_ramp(gti->get_gradient()); - } - - set_particle_flag(FLAG_ALIGN_Y_TO_VELOCITY, material->get_flag(ParticlesMaterial::FLAG_ALIGN_Y_TO_VELOCITY)); - - set_emission_shape(EmissionShape(material->get_emission_shape())); - set_emission_sphere_radius(material->get_emission_sphere_radius()); - Vector2 rect_extents = Vector2(material->get_emission_box_extents().x, material->get_emission_box_extents().y); - set_emission_rect_extents(rect_extents); - - Vector2 gravity = Vector2(material->get_gravity().x, material->get_gravity().y); - set_gravity(gravity); - set_lifetime_randomness(material->get_lifetime_randomness()); - -#define CONVERT_PARAM(m_param) \ - set_param(m_param, material->get_param(ParticlesMaterial::m_param)); \ - { \ - Ref ctex = material->get_param_texture(ParticlesMaterial::m_param); \ - if (ctex.is_valid()) \ - set_param_curve(m_param, ctex->get_curve()); \ - } \ - set_param_randomness(m_param, material->get_param_randomness(ParticlesMaterial::m_param)); - - CONVERT_PARAM(PARAM_INITIAL_LINEAR_VELOCITY); - CONVERT_PARAM(PARAM_ANGULAR_VELOCITY); - CONVERT_PARAM(PARAM_ORBIT_VELOCITY); - CONVERT_PARAM(PARAM_LINEAR_ACCEL); - CONVERT_PARAM(PARAM_RADIAL_ACCEL); - CONVERT_PARAM(PARAM_TANGENTIAL_ACCEL); - CONVERT_PARAM(PARAM_DAMPING); - CONVERT_PARAM(PARAM_ANGLE); - CONVERT_PARAM(PARAM_SCALE); - CONVERT_PARAM(PARAM_HUE_VARIATION); - CONVERT_PARAM(PARAM_ANIM_SPEED); - CONVERT_PARAM(PARAM_ANIM_OFFSET); - -#undef CONVERT_PARAM -} - void CPUParticles2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &CPUParticles2D::set_emitting); ClassDB::bind_method(D_METHOD("set_amount", "amount"), &CPUParticles2D::set_amount); @@ -1296,8 +1215,6 @@ void CPUParticles2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_gravity"), &CPUParticles2D::get_gravity); ClassDB::bind_method(D_METHOD("set_gravity", "accel_vec"), &CPUParticles2D::set_gravity); - ClassDB::bind_method(D_METHOD("convert_from_particles", "particles"), &CPUParticles2D::convert_from_particles); - ClassDB::bind_method(D_METHOD("_update_render_thread"), &CPUParticles2D::_update_render_thread); ClassDB::bind_method(D_METHOD("_texture_changed"), &CPUParticles2D::_texture_changed); diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h index 4c5e6dc7e..688293f1b 100644 --- a/scene/2d/cpu_particles_2d.h +++ b/scene/2d/cpu_particles_2d.h @@ -284,8 +284,6 @@ public: void restart(); - void convert_from_particles(Node *p_particles); - CPUParticles2D(); ~CPUParticles2D(); }; diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index 5d4142048..3eaa4c071 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -198,13 +198,6 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) { } } - { - Particles2D *ps = Object::cast_to(p_node); - if (ps) { - add = true; - } - } - if (add) { p_node->connect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed", varray(p_node), CONNECT_ONESHOT); nodes[p_node] = meta; @@ -295,14 +288,6 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { } } } - - if (enabler[ENABLER_PAUSE_PARTICLES]) { - Particles2D *ps = Object::cast_to(p_node); - - if (ps) { - ps->set_emitting(p_enabled); - } - } } void VisibilityEnabler2D::_node_removed(Node *p_node) { diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index e91f41ec2..cd9c195cb 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -32,7 +32,6 @@ #include "core/os/os.h" #include "scene/3d/camera.h" -#include "scene/3d/particles.h" #include "scene/resources/particles_material.h" #include "servers/visual_server.h" @@ -1287,85 +1286,6 @@ void CPUParticles::_notification(int p_what) { } } -void CPUParticles::convert_from_particles(Node *p_particles) { - Particles *particles = Object::cast_to(p_particles); - ERR_FAIL_COND_MSG(!particles, "Only Particles nodes can be converted to CPUParticles."); - - set_emitting(particles->is_emitting()); - set_amount(particles->get_amount()); - set_lifetime(particles->get_lifetime()); - set_one_shot(particles->get_one_shot()); - set_pre_process_time(particles->get_pre_process_time()); - set_explosiveness_ratio(particles->get_explosiveness_ratio()); - set_randomness_ratio(particles->get_randomness_ratio()); - set_use_local_coordinates(particles->get_use_local_coordinates()); - set_fixed_fps(particles->get_fixed_fps()); - set_fractional_delta(particles->get_fractional_delta()); - set_speed_scale(particles->get_speed_scale()); - set_draw_order(DrawOrder(particles->get_draw_order())); - set_mesh(particles->get_draw_pass_mesh(0)); - - Ref material = particles->get_process_material(); - if (material.is_null()) { - return; - } - - set_direction(material->get_direction()); - set_spread(material->get_spread()); - set_flatness(material->get_flatness()); - - set_color(material->get_color()); - - Ref gt = material->get_color_ramp(); - if (gt.is_valid()) { - set_color_ramp(gt->get_gradient()); - } - - Ref gti = material->get_color_initial_ramp(); - if (gti.is_valid()) { - set_color_initial_ramp(gti->get_gradient()); - } - - set_particle_flag(FLAG_ALIGN_Y_TO_VELOCITY, material->get_flag(ParticlesMaterial::FLAG_ALIGN_Y_TO_VELOCITY)); - set_particle_flag(FLAG_ROTATE_Y, material->get_flag(ParticlesMaterial::FLAG_ROTATE_Y)); - set_particle_flag(FLAG_DISABLE_Z, material->get_flag(ParticlesMaterial::FLAG_DISABLE_Z)); - - set_emission_shape(EmissionShape(material->get_emission_shape())); - set_emission_sphere_radius(material->get_emission_sphere_radius()); - set_emission_box_extents(material->get_emission_box_extents()); - set_emission_ring_height(material->get_emission_ring_height()); - set_emission_ring_inner_radius(material->get_emission_ring_inner_radius()); - set_emission_ring_radius(material->get_emission_ring_radius()); - set_emission_ring_axis(material->get_emission_ring_axis()); - - set_gravity(material->get_gravity()); - set_lifetime_randomness(material->get_lifetime_randomness()); - -#define CONVERT_PARAM(m_param) \ - set_param(m_param, material->get_param(ParticlesMaterial::m_param)); \ - { \ - Ref ctex = material->get_param_texture(ParticlesMaterial::m_param); \ - if (ctex.is_valid()) \ - set_param_curve(m_param, ctex->get_curve()); \ - } \ - set_param_randomness(m_param, material->get_param_randomness(ParticlesMaterial::m_param)); - - CONVERT_PARAM(PARAM_INITIAL_LINEAR_VELOCITY); - CONVERT_PARAM(PARAM_ANGULAR_VELOCITY); - CONVERT_PARAM(PARAM_ORBIT_VELOCITY); - CONVERT_PARAM(PARAM_LINEAR_ACCEL); - CONVERT_PARAM(PARAM_RADIAL_ACCEL); - CONVERT_PARAM(PARAM_TANGENTIAL_ACCEL); - CONVERT_PARAM(PARAM_DAMPING); - CONVERT_PARAM(PARAM_ANGLE); - CONVERT_PARAM(PARAM_SCALE); - CONVERT_PARAM(PARAM_HUE_VARIATION); - CONVERT_PARAM(PARAM_ANIM_SPEED); - CONVERT_PARAM(PARAM_ANIM_OFFSET); - -#undef CONVERT_PARAM -} - void CPUParticles::_bind_methods() { ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &CPUParticles::set_emitting); ClassDB::bind_method(D_METHOD("set_amount", "amount"), &CPUParticles::set_amount); @@ -1488,8 +1408,6 @@ void CPUParticles::_bind_methods() { ClassDB::bind_method(D_METHOD("get_gravity"), &CPUParticles::get_gravity); ClassDB::bind_method(D_METHOD("set_gravity", "accel_vec"), &CPUParticles::set_gravity); - ClassDB::bind_method(D_METHOD("convert_from_particles", "particles"), &CPUParticles::convert_from_particles); - ClassDB::bind_method(D_METHOD("_update_render_thread"), &CPUParticles::_update_render_thread); ADD_GROUP("Emission Shape", "emission_"); diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h index 5a871d121..4c9e06422 100644 --- a/scene/3d/cpu_particles.h +++ b/scene/3d/cpu_particles.h @@ -351,8 +351,6 @@ public: void restart(); - void convert_from_particles(Node *p_particles); - CPUParticles(); ~CPUParticles(); }; diff --git a/scene/3d/room_manager.cpp b/scene/3d/room_manager.cpp index 0d54ab985..0c95c6056 100644 --- a/scene/3d/room_manager.cpp +++ b/scene/3d/room_manager.cpp @@ -41,7 +41,6 @@ #include "room_group.h" #include "scene/3d/camera.h" #include "scene/3d/light.h" -#include "scene/3d/particles.h" #include "scene/3d/sprite_3d.h" #include "visibility_notifier.h" @@ -1856,11 +1855,13 @@ bool RoomManager::_bound_findpoints_geom_instance(GeometryInstance *p_gi, Vector } // Particles have a "visibility aabb" we can use for this + /* Particles *particles = Object::cast_to(p_gi); if (particles) { r_aabb = particles->get_global_transform().xform(particles->get_visibility_aabb()); return true; } + */ // Fallback path for geometry that is not recognised // (including CPUParticles, which will need to rely on an expansion margin) diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 1e171c659..d5e2507aa 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -55,7 +55,6 @@ #include "scene/2d/navigation_obstacle_2d.h" #include "scene/2d/parallax_background.h" #include "scene/2d/parallax_layer.h" -#include "scene/2d/particles_2d.h" #include "scene/2d/path_2d.h" #include "scene/2d/physics_body_2d.h" #include "scene/2d/polygon_2d.h" @@ -196,7 +195,6 @@ #include "scene/3d/navigation_mesh_instance.h" #include "scene/3d/navigation_obstacle.h" #include "scene/3d/occluder.h" -#include "scene/3d/particles.h" #include "scene/3d/path.h" #include "scene/3d/physics_body.h" #include "scene/3d/physics_joint.h" @@ -437,7 +435,6 @@ void register_scene_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); @@ -575,7 +572,6 @@ void register_scene_types() { CanvasItemMaterial::init_shaders(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); //ClassDB::register_class(); ClassDB::register_class(); //ClassDB::register_type();