diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index da0f794a9..27c74a45f 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -44,15 +44,15 @@ #include "scene/gui/popup_menu.h" #include "scene/gui/spin_box.h" -void Particles2DEditorPlugin::edit(Object *p_object) { - particles = Object::cast_to(p_object); +void GPUParticles2DEditorPlugin::edit(Object *p_object) { + particles = Object::cast_to(p_object); } -bool Particles2DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Particles2D"); +bool GPUParticles2DEditorPlugin::handles(Object *p_object) const { + return p_object->is_class("GPUParticles2D"); } -void Particles2DEditorPlugin::make_visible(bool p_visible) { +void GPUParticles2DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { toolbar->show(); } else { @@ -60,12 +60,12 @@ void Particles2DEditorPlugin::make_visible(bool p_visible) { } } -void Particles2DEditorPlugin::_file_selected(const String &p_file) { +void GPUParticles2DEditorPlugin::_file_selected(const String &p_file) { source_emission_file = p_file; emission_mask->popup_centered_minsize(); } -void Particles2DEditorPlugin::_selection_changed() { +void GPUParticles2DEditorPlugin::_selection_changed() { List selected_nodes = editor->get_editor_selection()->get_selected_node_list(); if (selected_particles.empty() && selected_nodes.empty()) { @@ -79,7 +79,7 @@ void Particles2DEditorPlugin::_selection_changed() { selected_particles.clear(); for (int i = 0; i < selected_nodes.size(); i++) { - Particles2D *selected_particle = Object::cast_to(selected_nodes[i]); + GPUParticles2D *selected_particle = Object::cast_to(selected_nodes[i]); if (selected_particle != nullptr) { selected_particle->set_show_visibility_rect(true); selected_particles.push_back(selected_particle); @@ -87,7 +87,7 @@ void Particles2DEditorPlugin::_selection_changed() { } } -void Particles2DEditorPlugin::_menu_callback(int p_idx) { +void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) { switch (p_idx) { case MENU_GENERATE_VISIBILITY_RECT: { // Add one second to the default generation lifetime, since the progress is updated every second. @@ -133,7 +133,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) { } } -void Particles2DEditorPlugin::_generate_visibility_rect() { +void GPUParticles2DEditorPlugin::_generate_visibility_rect() { float time = generate_seconds->get_value(); float running = 0.0; @@ -172,7 +172,7 @@ void Particles2DEditorPlugin::_generate_visibility_rect() { undo_redo->commit_action(); } -void Particles2DEditorPlugin::_generate_emission_mask() { +void GPUParticles2DEditorPlugin::_generate_emission_mask() { Ref pm = particles->get_process_material(); if (!pm.is_valid()) { EditorNode::get_singleton()->show_warning(TTR("Can only set point into a ParticlesMaterial process material")); @@ -360,24 +360,24 @@ void Particles2DEditorPlugin::_generate_emission_mask() { } } -void Particles2DEditorPlugin::_notification(int p_what) { +void GPUParticles2DEditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { menu->get_popup()->connect("id_pressed", this, "_menu_callback"); - menu->set_icon(menu->get_popup()->get_theme_icon("Particles2D", "EditorIcons")); + menu->set_icon(menu->get_popup()->get_theme_icon("GPUParticles2D", "EditorIcons")); file->connect("file_selected", this, "_file_selected"); EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", this, "_selection_changed"); } } -void Particles2DEditorPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("_menu_callback"), &Particles2DEditorPlugin::_menu_callback); - ClassDB::bind_method(D_METHOD("_file_selected"), &Particles2DEditorPlugin::_file_selected); - ClassDB::bind_method(D_METHOD("_selection_changed"), &Particles2DEditorPlugin::_selection_changed); - ClassDB::bind_method(D_METHOD("_generate_visibility_rect"), &Particles2DEditorPlugin::_generate_visibility_rect); - ClassDB::bind_method(D_METHOD("_generate_emission_mask"), &Particles2DEditorPlugin::_generate_emission_mask); +void GPUParticles2DEditorPlugin::_bind_methods() { + ClassDB::bind_method(D_METHOD("_menu_callback"), &GPUParticles2DEditorPlugin::_menu_callback); + ClassDB::bind_method(D_METHOD("_file_selected"), &GPUParticles2DEditorPlugin::_file_selected); + ClassDB::bind_method(D_METHOD("_selection_changed"), &GPUParticles2DEditorPlugin::_selection_changed); + ClassDB::bind_method(D_METHOD("_generate_visibility_rect"), &GPUParticles2DEditorPlugin::_generate_visibility_rect); + ClassDB::bind_method(D_METHOD("_generate_emission_mask"), &GPUParticles2DEditorPlugin::_generate_emission_mask); } -Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { +GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) { particles = nullptr; editor = p_node; undo_redo = editor->get_undo_redo(); @@ -397,7 +397,7 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { 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_text(TTR("GPUParticles")); menu->set_switch_on_hover(true); toolbar->add_child(menu); @@ -449,5 +449,5 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { emission_mask->connect("confirmed", this, "_generate_emission_mask"); } -Particles2DEditorPlugin::~Particles2DEditorPlugin() { +GPUParticles2DEditorPlugin::~GPUParticles2DEditorPlugin() { } diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h index c4eca4099..2a10f64b3 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.h +++ b/editor/plugins/gpu_particles_2d_editor_plugin.h @@ -37,10 +37,10 @@ class SpinBox; class EditorFileDialog; -class Particles2D; +class GPUParticles2D; -class Particles2DEditorPlugin : public EditorPlugin { - GDCLASS(Particles2DEditorPlugin, EditorPlugin); +class GPUParticles2DEditorPlugin : public EditorPlugin { + GDCLASS(GPUParticles2DEditorPlugin, EditorPlugin); enum { @@ -57,8 +57,8 @@ class Particles2DEditorPlugin : public EditorPlugin { EMISSION_MODE_BORDER_DIRECTED }; - Particles2D *particles; - List selected_particles; + GPUParticles2D *particles; + List selected_particles; EditorFileDialog *file; EditorNode *editor; @@ -89,14 +89,14 @@ protected: static void _bind_methods(); public: - virtual String get_name() const { return "Particles2D"; } + virtual String get_name() const { return "GPUParticles2D"; } 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); - Particles2DEditorPlugin(EditorNode *p_node); - ~Particles2DEditorPlugin(); + GPUParticles2DEditorPlugin(EditorNode *p_node); + ~GPUParticles2DEditorPlugin(); }; #endif // PARTICLES_2D_EDITOR_PLUGIN_H diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index 38cdbd387..ef2c25566 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -38,7 +38,7 @@ #include "core/config/engine.h" #endif -void Particles2D::set_emitting(bool p_emitting) { +void GPUParticles2D::set_emitting(bool p_emitting) { // Do not return even if `p_emitting == emitting` because `emitting` is just an approximation. if (p_emitting && one_shot) { @@ -65,18 +65,18 @@ void Particles2D::set_emitting(bool p_emitting) { RS::get_singleton()->particles_set_emitting(particles, p_emitting); } -void Particles2D::set_amount(int p_amount) { +void GPUParticles2D::set_amount(int p_amount) { ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles cannot be smaller than 1."); amount = p_amount; RS::get_singleton()->particles_set_amount(particles, amount); } -void Particles2D::set_lifetime(float p_lifetime) { - ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); +void GPUParticles2D::set_lifetime(float p_lifetime) { + ERR_FAIL_COND_MSG(p_lifetime <= 0, "GPUParticles lifetime must be greater than 0."); lifetime = p_lifetime; RS::get_singleton()->particles_set_lifetime(particles, lifetime); } -void Particles2D::set_one_shot(bool p_enable) { +void GPUParticles2D::set_one_shot(bool p_enable) { one_shot = p_enable; RS::get_singleton()->particles_set_one_shot(particles, one_shot); @@ -91,19 +91,19 @@ void Particles2D::set_one_shot(bool p_enable) { set_process_internal(false); } } -void Particles2D::set_pre_process_time(float p_time) { +void GPUParticles2D::set_pre_process_time(float p_time) { pre_process_time = p_time; RS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time); } -void Particles2D::set_explosiveness_ratio(float p_ratio) { +void GPUParticles2D::set_explosiveness_ratio(float p_ratio) { explosiveness_ratio = p_ratio; RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio); } -void Particles2D::set_randomness_ratio(float p_ratio) { +void GPUParticles2D::set_randomness_ratio(float p_ratio) { randomness_ratio = p_ratio; RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); } -void Particles2D::set_visibility_rect(const Rect2 &p_visibility_rect) { +void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) { visibility_rect = p_visibility_rect; AABB aabb; aabb.position.x = p_visibility_rect.position.x; @@ -116,7 +116,7 @@ void Particles2D::set_visibility_rect(const Rect2 &p_visibility_rect) { _change_notify("visibility_rect"); update(); } -void Particles2D::set_use_local_coordinates(bool p_enable) { +void GPUParticles2D::set_use_local_coordinates(bool p_enable) { local_coords = p_enable; RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords); set_notify_transform(!p_enable); @@ -125,7 +125,7 @@ void Particles2D::set_use_local_coordinates(bool p_enable) { } } -void Particles2D::_update_particle_emission_transform() { +void GPUParticles2D::_update_particle_emission_transform() { Transform2D xf2d = get_global_transform(); Transform xf; xf.basis.set_axis(0, Vector3(xf2d.get_axis(0).x, xf2d.get_axis(0).y, 0)); @@ -135,7 +135,7 @@ void Particles2D::_update_particle_emission_transform() { RS::get_singleton()->particles_set_emission_transform(particles, xf); } -void Particles2D::set_process_material(const Ref &p_material) { +void GPUParticles2D::set_process_material(const Ref &p_material) { process_material = p_material; Ref pm = p_material; if (pm.is_valid() && !pm->get_flag(ParticlesMaterial::FLAG_DISABLE_Z) && pm->get_gravity() == Vector3(0, -9.8, 0)) { @@ -152,82 +152,82 @@ void Particles2D::set_process_material(const Ref &p_material) { update_configuration_warning(); } -void Particles2D::set_speed_scale(float p_scale) { +void GPUParticles2D::set_speed_scale(float p_scale) { speed_scale = p_scale; RS::get_singleton()->particles_set_speed_scale(particles, p_scale); } #ifdef TOOLS_ENABLED -void Particles2D::set_show_visibility_rect(bool p_show_visibility_rect) { +void GPUParticles2D::set_show_visibility_rect(bool p_show_visibility_rect) { show_visibility_rect = p_show_visibility_rect; update(); } #endif -bool Particles2D::is_emitting() const { +bool GPUParticles2D::is_emitting() const { return emitting; } -int Particles2D::get_amount() const { +int GPUParticles2D::get_amount() const { return amount; } -float Particles2D::get_lifetime() const { +float GPUParticles2D::get_lifetime() const { return lifetime; } -bool Particles2D::get_one_shot() const { +bool GPUParticles2D::get_one_shot() const { return one_shot; } -float Particles2D::get_pre_process_time() const { +float GPUParticles2D::get_pre_process_time() const { return pre_process_time; } -float Particles2D::get_explosiveness_ratio() const { +float GPUParticles2D::get_explosiveness_ratio() const { return explosiveness_ratio; } -float Particles2D::get_randomness_ratio() const { +float GPUParticles2D::get_randomness_ratio() const { return randomness_ratio; } -Rect2 Particles2D::get_visibility_rect() const { +Rect2 GPUParticles2D::get_visibility_rect() const { return visibility_rect; } -bool Particles2D::get_use_local_coordinates() const { +bool GPUParticles2D::get_use_local_coordinates() const { return local_coords; } -Ref Particles2D::get_process_material() const { +Ref GPUParticles2D::get_process_material() const { return process_material; } -float Particles2D::get_speed_scale() const { +float GPUParticles2D::get_speed_scale() const { return speed_scale; } -void Particles2D::set_draw_order(DrawOrder p_order) { +void GPUParticles2D::set_draw_order(DrawOrder p_order) { draw_order = p_order; RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order)); } -Particles2D::DrawOrder Particles2D::get_draw_order() const { +GPUParticles2D::DrawOrder GPUParticles2D::get_draw_order() const { return draw_order; } -void Particles2D::set_fixed_fps(int p_count) { +void GPUParticles2D::set_fixed_fps(int p_count) { fixed_fps = p_count; RS::get_singleton()->particles_set_fixed_fps(particles, p_count); } -int Particles2D::get_fixed_fps() const { +int GPUParticles2D::get_fixed_fps() const { return fixed_fps; } -void Particles2D::set_fractional_delta(bool p_enable) { +void GPUParticles2D::set_fractional_delta(bool p_enable) { fractional_delta = p_enable; RS::get_singleton()->particles_set_fractional_delta(particles, p_enable); } -bool Particles2D::get_fractional_delta() const { +bool GPUParticles2D::get_fractional_delta() const { return fractional_delta; } -String Particles2D::get_configuration_warning() const { +String GPUParticles2D::get_configuration_warning() const { String warning = Node2D::get_configuration_warning(); if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) { @@ -243,7 +243,7 @@ String Particles2D::get_configuration_warning() const { warning += "\n\n"; } - warning += "- " + TTR("On macOS, Particles2D rendering is much slower than CPUParticles2D due to transform feedback being implemented on the CPU instead of the GPU.\nConsider using CPUParticles2D instead when targeting macOS.\nYou can use the \"Convert to CPUParticles2D\" toolbar option for this purpose."); + warning += "- " + TTR("On macOS, GPUParticles2D rendering is much slower than CPUParticles2D due to transform feedback being implemented on the CPU instead of the GPU.\nConsider using CPUParticles2D instead when targeting macOS.\nYou can use the \"Convert to CPUParticles2D\" toolbar option for this purpose."); #endif if (process_material.is_null()) { @@ -262,7 +262,7 @@ String Particles2D::get_configuration_warning() const { if (warning != String()) { warning += "\n\n"; } - warning += "- " + TTR("Particles2D animation requires the usage of a CanvasItemMaterial with \"Particles Animation\" enabled."); + warning += "- " + TTR("GPUParticles2D animation requires the usage of a CanvasItemMaterial with \"GPUParticles Animation\" enabled."); } } } @@ -270,7 +270,7 @@ String Particles2D::get_configuration_warning() const { return warning; } -Rect2 Particles2D::capture_rect() const { +Rect2 GPUParticles2D::capture_rect() const { AABB aabb = RS::get_singleton()->particles_get_current_aabb(particles); Rect2 r; r.position.x = aabb.position.x; @@ -280,28 +280,28 @@ Rect2 Particles2D::capture_rect() const { return r; } -void Particles2D::set_texture(const Ref &p_texture) { +void GPUParticles2D::set_texture(const Ref &p_texture) { texture = p_texture; update(); } -Ref Particles2D::get_texture() const { +Ref GPUParticles2D::get_texture() const { return texture; } -void Particles2D::set_normal_map(const Ref &p_normal_map) { +void GPUParticles2D::set_normal_map(const Ref &p_normal_map) { normal_map = p_normal_map; update(); } -Ref Particles2D::get_normal_map() const { +Ref GPUParticles2D::get_normal_map() const { return normal_map; } -void Particles2D::_validate_property(PropertyInfo &property) const { +void GPUParticles2D::_validate_property(PropertyInfo &property) const { } -void Particles2D::restart() { +void GPUParticles2D::restart() { RS::get_singleton()->particles_restart(particles); RS::get_singleton()->particles_set_emitting(particles, true); @@ -316,7 +316,7 @@ void Particles2D::restart() { } } -void Particles2D::_notification(int p_what) { +void GPUParticles2D::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { RID texture_rid; if (texture.is_valid()) { @@ -370,47 +370,47 @@ void Particles2D::_notification(int p_what) { } } -void Particles2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &Particles2D::set_emitting); - ClassDB::bind_method(D_METHOD("set_amount", "amount"), &Particles2D::set_amount); - ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &Particles2D::set_lifetime); - ClassDB::bind_method(D_METHOD("set_one_shot", "secs"), &Particles2D::set_one_shot); - ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &Particles2D::set_pre_process_time); - ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &Particles2D::set_explosiveness_ratio); - ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &Particles2D::set_randomness_ratio); - ClassDB::bind_method(D_METHOD("set_visibility_rect", "visibility_rect"), &Particles2D::set_visibility_rect); - ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &Particles2D::set_use_local_coordinates); - ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &Particles2D::set_fixed_fps); - ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &Particles2D::set_fractional_delta); - ClassDB::bind_method(D_METHOD("set_process_material", "material"), &Particles2D::set_process_material); - ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &Particles2D::set_speed_scale); +void GPUParticles2D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &GPUParticles2D::set_emitting); + ClassDB::bind_method(D_METHOD("set_amount", "amount"), &GPUParticles2D::set_amount); + ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &GPUParticles2D::set_lifetime); + ClassDB::bind_method(D_METHOD("set_one_shot", "secs"), &GPUParticles2D::set_one_shot); + ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &GPUParticles2D::set_pre_process_time); + ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &GPUParticles2D::set_explosiveness_ratio); + ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &GPUParticles2D::set_randomness_ratio); + ClassDB::bind_method(D_METHOD("set_visibility_rect", "visibility_rect"), &GPUParticles2D::set_visibility_rect); + ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &GPUParticles2D::set_use_local_coordinates); + ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &GPUParticles2D::set_fixed_fps); + ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &GPUParticles2D::set_fractional_delta); + ClassDB::bind_method(D_METHOD("set_process_material", "material"), &GPUParticles2D::set_process_material); + ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &GPUParticles2D::set_speed_scale); - ClassDB::bind_method(D_METHOD("is_emitting"), &Particles2D::is_emitting); - ClassDB::bind_method(D_METHOD("get_amount"), &Particles2D::get_amount); - ClassDB::bind_method(D_METHOD("get_lifetime"), &Particles2D::get_lifetime); - ClassDB::bind_method(D_METHOD("get_one_shot"), &Particles2D::get_one_shot); - ClassDB::bind_method(D_METHOD("get_pre_process_time"), &Particles2D::get_pre_process_time); - ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &Particles2D::get_explosiveness_ratio); - ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &Particles2D::get_randomness_ratio); - ClassDB::bind_method(D_METHOD("get_visibility_rect"), &Particles2D::get_visibility_rect); - ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &Particles2D::get_use_local_coordinates); - ClassDB::bind_method(D_METHOD("get_fixed_fps"), &Particles2D::get_fixed_fps); - ClassDB::bind_method(D_METHOD("get_fractional_delta"), &Particles2D::get_fractional_delta); - ClassDB::bind_method(D_METHOD("get_process_material"), &Particles2D::get_process_material); - ClassDB::bind_method(D_METHOD("get_speed_scale"), &Particles2D::get_speed_scale); + ClassDB::bind_method(D_METHOD("is_emitting"), &GPUParticles2D::is_emitting); + ClassDB::bind_method(D_METHOD("get_amount"), &GPUParticles2D::get_amount); + ClassDB::bind_method(D_METHOD("get_lifetime"), &GPUParticles2D::get_lifetime); + ClassDB::bind_method(D_METHOD("get_one_shot"), &GPUParticles2D::get_one_shot); + ClassDB::bind_method(D_METHOD("get_pre_process_time"), &GPUParticles2D::get_pre_process_time); + ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &GPUParticles2D::get_explosiveness_ratio); + ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &GPUParticles2D::get_randomness_ratio); + ClassDB::bind_method(D_METHOD("get_visibility_rect"), &GPUParticles2D::get_visibility_rect); + ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &GPUParticles2D::get_use_local_coordinates); + ClassDB::bind_method(D_METHOD("get_fixed_fps"), &GPUParticles2D::get_fixed_fps); + ClassDB::bind_method(D_METHOD("get_fractional_delta"), &GPUParticles2D::get_fractional_delta); + ClassDB::bind_method(D_METHOD("get_process_material"), &GPUParticles2D::get_process_material); + ClassDB::bind_method(D_METHOD("get_speed_scale"), &GPUParticles2D::get_speed_scale); - ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &Particles2D::set_draw_order); - ClassDB::bind_method(D_METHOD("get_draw_order"), &Particles2D::get_draw_order); + ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &GPUParticles2D::set_draw_order); + ClassDB::bind_method(D_METHOD("get_draw_order"), &GPUParticles2D::get_draw_order); - ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Particles2D::set_texture); - ClassDB::bind_method(D_METHOD("get_texture"), &Particles2D::get_texture); + ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticles2D::set_texture); + ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticles2D::get_texture); - ClassDB::bind_method(D_METHOD("set_normal_map", "texture"), &Particles2D::set_normal_map); - ClassDB::bind_method(D_METHOD("get_normal_map"), &Particles2D::get_normal_map); + ClassDB::bind_method(D_METHOD("set_normal_map", "texture"), &GPUParticles2D::set_normal_map); + ClassDB::bind_method(D_METHOD("get_normal_map"), &GPUParticles2D::get_normal_map); - ClassDB::bind_method(D_METHOD("capture_rect"), &Particles2D::capture_rect); + ClassDB::bind_method(D_METHOD("capture_rect"), &GPUParticles2D::capture_rect); - ClassDB::bind_method(D_METHOD("restart"), &Particles2D::restart); + ClassDB::bind_method(D_METHOD("restart"), &GPUParticles2D::restart); ADD_SIGNAL(MethodInfo("finished")); @@ -439,7 +439,7 @@ void Particles2D::_bind_methods() { BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME); } -Particles2D::Particles2D() { +GPUParticles2D::GPUParticles2D() { particles = RID_PRIME(RS::get_singleton()->particles_create()); one_shot = false; // Needed so that set_emitting doesn't access uninitialized values @@ -461,7 +461,7 @@ Particles2D::Particles2D() { #endif } -Particles2D::~Particles2D() { +GPUParticles2D::~GPUParticles2D() { if (particles.is_valid()) { RS::get_singleton()->free(particles); } diff --git a/scene/2d/gpu_particles_2d.h b/scene/2d/gpu_particles_2d.h index a6eab09eb..a79dcb05a 100644 --- a/scene/2d/gpu_particles_2d.h +++ b/scene/2d/gpu_particles_2d.h @@ -35,9 +35,9 @@ #include "scene/main/node_2d.h" #include "scene/resources/texture.h" -class Particles2D : public Node2D { +class GPUParticles2D : public Node2D { private: - GDCLASS(Particles2D, Node2D); + GDCLASS(GPUParticles2D, Node2D); public: enum DrawOrder { @@ -133,10 +133,10 @@ public: void restart(); Rect2 capture_rect() const; - Particles2D(); - ~Particles2D(); + GPUParticles2D(); + ~GPUParticles2D(); }; -VARIANT_ENUM_CAST(Particles2D::DrawOrder) +VARIANT_ENUM_CAST(GPUParticles2D::DrawOrder) #endif // PARTICLES_2D_H diff --git a/scene/3d/gpu_particles.cpp b/scene/3d/gpu_particles.cpp index da63a03fb..e0af7aca3 100644 --- a/scene/3d/gpu_particles.cpp +++ b/scene/3d/gpu_particles.cpp @@ -39,14 +39,14 @@ #include "servers/rendering_server.h" -AABB Particles::get_aabb() const { +AABB GPUParticles::get_aabb() const { return AABB(); } -PoolVector Particles::get_faces(uint32_t p_usage_flags) const { +PoolVector GPUParticles::get_faces(uint32_t p_usage_flags) const { return PoolVector(); } -void Particles::set_emitting(bool p_emitting) { +void GPUParticles::set_emitting(bool p_emitting) { // Do not return even if `p_emitting == emitting` because `emitting` is just an approximation. if (p_emitting && one_shot) { @@ -74,18 +74,18 @@ void Particles::set_emitting(bool p_emitting) { RS::get_singleton()->particles_set_emitting(particles, p_emitting); } -void Particles::set_amount(int p_amount) { +void GPUParticles::set_amount(int p_amount) { ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles cannot be smaller than 1."); amount = p_amount; RS::get_singleton()->particles_set_amount(particles, amount); } -void Particles::set_lifetime(float p_lifetime) { - ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); +void GPUParticles::set_lifetime(float p_lifetime) { + ERR_FAIL_COND_MSG(p_lifetime <= 0, "GPUParticles lifetime must be greater than 0."); lifetime = p_lifetime; RS::get_singleton()->particles_set_lifetime(particles, lifetime); } -void Particles::set_one_shot(bool p_one_shot) { +void GPUParticles::set_one_shot(bool p_one_shot) { one_shot = p_one_shot; RS::get_singleton()->particles_set_one_shot(particles, one_shot); @@ -101,29 +101,29 @@ void Particles::set_one_shot(bool p_one_shot) { } } -void Particles::set_pre_process_time(float p_time) { +void GPUParticles::set_pre_process_time(float p_time) { pre_process_time = p_time; RS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time); } -void Particles::set_explosiveness_ratio(float p_ratio) { +void GPUParticles::set_explosiveness_ratio(float p_ratio) { explosiveness_ratio = p_ratio; RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio); } -void Particles::set_randomness_ratio(float p_ratio) { +void GPUParticles::set_randomness_ratio(float p_ratio) { randomness_ratio = p_ratio; RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); } -void Particles::set_visibility_aabb(const AABB &p_aabb) { +void GPUParticles::set_visibility_aabb(const AABB &p_aabb) { visibility_aabb = p_aabb; RS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb); update_gizmos(); _change_notify("visibility_aabb"); } -void Particles::set_use_local_coordinates(bool p_enable) { +void GPUParticles::set_use_local_coordinates(bool p_enable) { local_coords = p_enable; RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords); } -void Particles::set_process_material(const Ref &p_material) { +void GPUParticles::set_process_material(const Ref &p_material) { process_material = p_material; RID material_rid; if (process_material.is_valid()) { @@ -134,67 +134,67 @@ void Particles::set_process_material(const Ref &p_material) { update_configuration_warning(); } -void Particles::set_speed_scale(float p_scale) { +void GPUParticles::set_speed_scale(float p_scale) { speed_scale = p_scale; RS::get_singleton()->particles_set_speed_scale(particles, p_scale); } -bool Particles::is_emitting() const { +bool GPUParticles::is_emitting() const { return emitting; } -int Particles::get_amount() const { +int GPUParticles::get_amount() const { return amount; } -float Particles::get_lifetime() const { +float GPUParticles::get_lifetime() const { return lifetime; } -bool Particles::get_one_shot() const { +bool GPUParticles::get_one_shot() const { return one_shot; } -float Particles::get_pre_process_time() const { +float GPUParticles::get_pre_process_time() const { return pre_process_time; } -float Particles::get_explosiveness_ratio() const { +float GPUParticles::get_explosiveness_ratio() const { return explosiveness_ratio; } -float Particles::get_randomness_ratio() const { +float GPUParticles::get_randomness_ratio() const { return randomness_ratio; } -AABB Particles::get_visibility_aabb() const { +AABB GPUParticles::get_visibility_aabb() const { return visibility_aabb; } -bool Particles::get_use_local_coordinates() const { +bool GPUParticles::get_use_local_coordinates() const { return local_coords; } -Ref Particles::get_process_material() const { +Ref GPUParticles::get_process_material() const { return process_material; } -float Particles::get_speed_scale() const { +float GPUParticles::get_speed_scale() const { return speed_scale; } -void Particles::set_draw_order(DrawOrder p_order) { +void GPUParticles::set_draw_order(DrawOrder p_order) { draw_order = p_order; RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order)); } -Particles::DrawOrder Particles::get_draw_order() const { +GPUParticles::DrawOrder GPUParticles::get_draw_order() const { return draw_order; } -void Particles::set_draw_passes(int p_count) { +void GPUParticles::set_draw_passes(int p_count) { ERR_FAIL_COND(p_count < 1); draw_passes.resize(p_count); RS::get_singleton()->particles_set_draw_passes(particles, p_count); _change_notify(); } -int Particles::get_draw_passes() const { +int GPUParticles::get_draw_passes() const { return draw_passes.size(); } -void Particles::set_draw_pass_mesh(int p_pass, const Ref &p_mesh) { +void GPUParticles::set_draw_pass_mesh(int p_pass, const Ref &p_mesh) { ERR_FAIL_INDEX(p_pass, draw_passes.size()); draw_passes.write[p_pass] = p_mesh; @@ -209,31 +209,31 @@ void Particles::set_draw_pass_mesh(int p_pass, const Ref &p_mesh) { update_configuration_warning(); } -Ref Particles::get_draw_pass_mesh(int p_pass) const { +Ref GPUParticles::get_draw_pass_mesh(int p_pass) const { ERR_FAIL_INDEX_V(p_pass, draw_passes.size(), Ref()); return draw_passes[p_pass]; } -void Particles::set_fixed_fps(int p_count) { +void GPUParticles::set_fixed_fps(int p_count) { fixed_fps = p_count; RS::get_singleton()->particles_set_fixed_fps(particles, p_count); } -int Particles::get_fixed_fps() const { +int GPUParticles::get_fixed_fps() const { return fixed_fps; } -void Particles::set_fractional_delta(bool p_enable) { +void GPUParticles::set_fractional_delta(bool p_enable) { fractional_delta = p_enable; RS::get_singleton()->particles_set_fractional_delta(particles, p_enable); } -bool Particles::get_fractional_delta() const { +bool GPUParticles::get_fractional_delta() const { return fractional_delta; } -String Particles::get_configuration_warning() const { +String GPUParticles::get_configuration_warning() const { String warnings = GeometryInstance::get_configuration_warning(); if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) { @@ -249,7 +249,7 @@ String Particles::get_configuration_warning() const { warnings += "\n\n"; } - warnings += "- " + TTR("On macOS, Particles rendering is much slower than CPUParticles due to transform feedback being implemented on the CPU instead of the GPU.\nConsider using CPUParticles instead when targeting macOS.\nYou can use the \"Convert to CPUParticles\" toolbar option for this purpose."); + warnings += "- " + TTR("On macOS, GPUParticles rendering is much slower than CPUParticles due to transform feedback being implemented on the CPU instead of the GPU.\nConsider using CPUParticles instead when targeting macOS.\nYou can use the \"Convert to CPUParticles\" toolbar option for this purpose."); #endif bool meshes_found = false; @@ -293,14 +293,14 @@ String Particles::get_configuration_warning() const { if (warnings != String()) { warnings += "\n"; } - warnings += "- " + TTR("Particles animation requires the usage of a SpatialMaterial whose Billboard Mode is set to \"Particle Billboard\"."); + warnings += "- " + TTR("GPUParticles animation requires the usage of a SpatialMaterial whose Billboard Mode is set to \"Particle Billboard\"."); } } return warnings; } -void Particles::restart() { +void GPUParticles::restart() { RenderingServer::get_singleton()->particles_restart(particles); RenderingServer::get_singleton()->particles_set_emitting(particles, true); @@ -315,11 +315,11 @@ void Particles::restart() { } } -AABB Particles::capture_aabb() const { +AABB GPUParticles::capture_aabb() const { return RS::get_singleton()->particles_get_current_aabb(particles); } -void Particles::_validate_property(PropertyInfo &property) const { +void GPUParticles::_validate_property(PropertyInfo &property) const { if (property.name.begins_with("draw_pass_")) { int index = property.name.get_slicec('_', 2).to_int() - 1; if (index >= draw_passes.size()) { @@ -329,7 +329,7 @@ void Particles::_validate_property(PropertyInfo &property) const { } } -void Particles::_notification(int p_what) { +void GPUParticles::_notification(int p_what) { if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) { if (can_process()) { RS::get_singleton()->particles_set_speed_scale(particles, speed_scale); @@ -369,47 +369,47 @@ void Particles::_notification(int p_what) { } } -void Particles::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &Particles::set_emitting); - ClassDB::bind_method(D_METHOD("set_amount", "amount"), &Particles::set_amount); - ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &Particles::set_lifetime); - ClassDB::bind_method(D_METHOD("set_one_shot", "enable"), &Particles::set_one_shot); - ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &Particles::set_pre_process_time); - ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &Particles::set_explosiveness_ratio); - ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &Particles::set_randomness_ratio); - ClassDB::bind_method(D_METHOD("set_visibility_aabb", "aabb"), &Particles::set_visibility_aabb); - ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &Particles::set_use_local_coordinates); - ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &Particles::set_fixed_fps); - ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &Particles::set_fractional_delta); - ClassDB::bind_method(D_METHOD("set_process_material", "material"), &Particles::set_process_material); - ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &Particles::set_speed_scale); +void GPUParticles::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &GPUParticles::set_emitting); + ClassDB::bind_method(D_METHOD("set_amount", "amount"), &GPUParticles::set_amount); + ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &GPUParticles::set_lifetime); + ClassDB::bind_method(D_METHOD("set_one_shot", "enable"), &GPUParticles::set_one_shot); + ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &GPUParticles::set_pre_process_time); + ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &GPUParticles::set_explosiveness_ratio); + ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &GPUParticles::set_randomness_ratio); + ClassDB::bind_method(D_METHOD("set_visibility_aabb", "aabb"), &GPUParticles::set_visibility_aabb); + ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &GPUParticles::set_use_local_coordinates); + ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &GPUParticles::set_fixed_fps); + ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &GPUParticles::set_fractional_delta); + ClassDB::bind_method(D_METHOD("set_process_material", "material"), &GPUParticles::set_process_material); + ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &GPUParticles::set_speed_scale); - ClassDB::bind_method(D_METHOD("is_emitting"), &Particles::is_emitting); - ClassDB::bind_method(D_METHOD("get_amount"), &Particles::get_amount); - ClassDB::bind_method(D_METHOD("get_lifetime"), &Particles::get_lifetime); - ClassDB::bind_method(D_METHOD("get_one_shot"), &Particles::get_one_shot); - ClassDB::bind_method(D_METHOD("get_pre_process_time"), &Particles::get_pre_process_time); - ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &Particles::get_explosiveness_ratio); - ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &Particles::get_randomness_ratio); - ClassDB::bind_method(D_METHOD("get_visibility_aabb"), &Particles::get_visibility_aabb); - ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &Particles::get_use_local_coordinates); - ClassDB::bind_method(D_METHOD("get_fixed_fps"), &Particles::get_fixed_fps); - ClassDB::bind_method(D_METHOD("get_fractional_delta"), &Particles::get_fractional_delta); - ClassDB::bind_method(D_METHOD("get_process_material"), &Particles::get_process_material); - ClassDB::bind_method(D_METHOD("get_speed_scale"), &Particles::get_speed_scale); + ClassDB::bind_method(D_METHOD("is_emitting"), &GPUParticles::is_emitting); + ClassDB::bind_method(D_METHOD("get_amount"), &GPUParticles::get_amount); + ClassDB::bind_method(D_METHOD("get_lifetime"), &GPUParticles::get_lifetime); + ClassDB::bind_method(D_METHOD("get_one_shot"), &GPUParticles::get_one_shot); + ClassDB::bind_method(D_METHOD("get_pre_process_time"), &GPUParticles::get_pre_process_time); + ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &GPUParticles::get_explosiveness_ratio); + ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &GPUParticles::get_randomness_ratio); + ClassDB::bind_method(D_METHOD("get_visibility_aabb"), &GPUParticles::get_visibility_aabb); + ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &GPUParticles::get_use_local_coordinates); + ClassDB::bind_method(D_METHOD("get_fixed_fps"), &GPUParticles::get_fixed_fps); + ClassDB::bind_method(D_METHOD("get_fractional_delta"), &GPUParticles::get_fractional_delta); + ClassDB::bind_method(D_METHOD("get_process_material"), &GPUParticles::get_process_material); + ClassDB::bind_method(D_METHOD("get_speed_scale"), &GPUParticles::get_speed_scale); - ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &Particles::set_draw_order); + ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &GPUParticles::set_draw_order); - ClassDB::bind_method(D_METHOD("get_draw_order"), &Particles::get_draw_order); + ClassDB::bind_method(D_METHOD("get_draw_order"), &GPUParticles::get_draw_order); - ClassDB::bind_method(D_METHOD("set_draw_passes", "passes"), &Particles::set_draw_passes); - ClassDB::bind_method(D_METHOD("set_draw_pass_mesh", "pass", "mesh"), &Particles::set_draw_pass_mesh); + ClassDB::bind_method(D_METHOD("set_draw_passes", "passes"), &GPUParticles::set_draw_passes); + ClassDB::bind_method(D_METHOD("set_draw_pass_mesh", "pass", "mesh"), &GPUParticles::set_draw_pass_mesh); - ClassDB::bind_method(D_METHOD("get_draw_passes"), &Particles::get_draw_passes); - ClassDB::bind_method(D_METHOD("get_draw_pass_mesh", "pass"), &Particles::get_draw_pass_mesh); + ClassDB::bind_method(D_METHOD("get_draw_passes"), &GPUParticles::get_draw_passes); + ClassDB::bind_method(D_METHOD("get_draw_pass_mesh", "pass"), &GPUParticles::get_draw_pass_mesh); - ClassDB::bind_method(D_METHOD("restart"), &Particles::restart); - ClassDB::bind_method(D_METHOD("capture_aabb"), &Particles::capture_aabb); + ClassDB::bind_method(D_METHOD("restart"), &GPUParticles::restart); + ClassDB::bind_method(D_METHOD("capture_aabb"), &GPUParticles::capture_aabb); ADD_SIGNAL(MethodInfo("finished")); @@ -443,7 +443,7 @@ void Particles::_bind_methods() { BIND_CONSTANT(MAX_DRAW_PASSES); } -Particles::Particles() { +GPUParticles::GPUParticles() { particles = RID_PRIME(RS::get_singleton()->particles_create()); set_base(particles); one_shot = false; // Needed so that set_emitting doesn't access uninitialized values @@ -463,7 +463,7 @@ Particles::Particles() { set_speed_scale(1); } -Particles::~Particles() { +GPUParticles::~GPUParticles() { if (particles.is_valid()) { RS::get_singleton()->free(particles); } diff --git a/scene/3d/gpu_particles.h b/scene/3d/gpu_particles.h index 301e68d19..817bb427e 100644 --- a/scene/3d/gpu_particles.h +++ b/scene/3d/gpu_particles.h @@ -35,9 +35,9 @@ #include "scene/3d/visual_instance.h" #include "scene/resources/material/material.h" -class Particles : public GeometryInstance { +class GPUParticles : public GeometryInstance { private: - GDCLASS(Particles, GeometryInstance); + GDCLASS(GPUParticles, GeometryInstance); public: enum DrawOrder { @@ -131,10 +131,10 @@ public: void restart(); AABB capture_aabb() const; - Particles(); - ~Particles(); + GPUParticles(); + ~GPUParticles(); }; -VARIANT_ENUM_CAST(Particles::DrawOrder) +VARIANT_ENUM_CAST(GPUParticles::DrawOrder) #endif // PARTICLES_H