Merge pull request #29974 from clayjohn/particles_restart
Properly set emitting when particles restart
This commit is contained in:
commit
25022a1d89
13 changed files with 40 additions and 7 deletions
|
@ -6074,10 +6074,7 @@ void RasterizerStorageGLES3::particles_set_emitting(RID p_particles, bool p_emit
|
||||||
|
|
||||||
Particles *particles = particles_owner.getornull(p_particles);
|
Particles *particles = particles_owner.getornull(p_particles);
|
||||||
ERR_FAIL_COND(!particles);
|
ERR_FAIL_COND(!particles);
|
||||||
if (p_emitting != particles->emitting) {
|
|
||||||
// Restart is overridden by set_emitting
|
|
||||||
particles->restart_request = false;
|
|
||||||
}
|
|
||||||
particles->emitting = p_emitting;
|
particles->emitting = p_emitting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6475,7 +6472,6 @@ void RasterizerStorageGLES3::update_particles() {
|
||||||
Particles *particles = particle_update_list.first()->self();
|
Particles *particles = particle_update_list.first()->self();
|
||||||
|
|
||||||
if (particles->restart_request) {
|
if (particles->restart_request) {
|
||||||
particles->emitting = true; //restart from zero
|
|
||||||
particles->prev_ticks = 0;
|
particles->prev_ticks = 0;
|
||||||
particles->phase = 0;
|
particles->phase = 0;
|
||||||
particles->prev_phase = 0;
|
particles->prev_phase = 0;
|
||||||
|
|
|
@ -75,6 +75,10 @@ void CPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
|
||||||
|
|
||||||
emission_mask->popup_centered_minsize();
|
emission_mask->popup_centered_minsize();
|
||||||
} break;
|
} break;
|
||||||
|
case MENU_RESTART: {
|
||||||
|
|
||||||
|
particles->restart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,6 +269,8 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) {
|
||||||
|
|
||||||
menu = memnew(MenuButton);
|
menu = memnew(MenuButton);
|
||||||
menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
|
menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
|
||||||
|
menu->get_popup()->add_separator();
|
||||||
|
menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART);
|
||||||
// menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
|
// menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
|
||||||
menu->set_text(TTR("Particles"));
|
menu->set_text(TTR("Particles"));
|
||||||
menu->set_switch_on_hover(true);
|
menu->set_switch_on_hover(true);
|
||||||
|
|
|
@ -44,7 +44,8 @@ class CPUParticles2DEditorPlugin : public EditorPlugin {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MENU_LOAD_EMISSION_MASK,
|
MENU_LOAD_EMISSION_MASK,
|
||||||
MENU_CLEAR_EMISSION_MASK
|
MENU_CLEAR_EMISSION_MASK,
|
||||||
|
MENU_RESTART
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EmissionMode {
|
enum EmissionMode {
|
||||||
|
|
|
@ -62,6 +62,12 @@ void CPUParticlesEditor::_menu_option(int p_option) {
|
||||||
emission_tree_dialog->popup_centered_ratio();
|
emission_tree_dialog->popup_centered_ratio();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case MENU_OPTION_RESTART: {
|
||||||
|
|
||||||
|
node->restart();
|
||||||
|
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +114,8 @@ CPUParticlesEditor::CPUParticlesEditor() {
|
||||||
options->set_text(TTR("CPUParticles"));
|
options->set_text(TTR("CPUParticles"));
|
||||||
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 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_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("Restart"), MENU_OPTION_RESTART);
|
||||||
options->get_popup()->connect("id_pressed", this, "_menu_option");
|
options->get_popup()->connect("id_pressed", this, "_menu_option");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ class CPUParticlesEditor : public ParticlesEditorBase {
|
||||||
MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE,
|
MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE,
|
||||||
MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH,
|
MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH,
|
||||||
MENU_OPTION_CLEAR_EMISSION_VOLUME,
|
MENU_OPTION_CLEAR_EMISSION_VOLUME,
|
||||||
|
MENU_OPTION_RESTART
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,10 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
|
||||||
ur->commit_action();
|
ur->commit_action();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
case MENU_RESTART: {
|
||||||
|
|
||||||
|
particles->restart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,6 +384,8 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
|
||||||
// menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
|
// menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
|
||||||
menu->get_popup()->add_separator();
|
menu->get_popup()->add_separator();
|
||||||
menu->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
|
menu->get_popup()->add_item(TTR("Convert to CPUParticles"), 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("Particles"));
|
||||||
menu->set_switch_on_hover(true);
|
menu->set_switch_on_hover(true);
|
||||||
toolbar->add_child(menu);
|
toolbar->add_child(menu);
|
||||||
|
|
|
@ -47,7 +47,8 @@ class Particles2DEditorPlugin : public EditorPlugin {
|
||||||
MENU_GENERATE_VISIBILITY_RECT,
|
MENU_GENERATE_VISIBILITY_RECT,
|
||||||
MENU_LOAD_EMISSION_MASK,
|
MENU_LOAD_EMISSION_MASK,
|
||||||
MENU_CLEAR_EMISSION_MASK,
|
MENU_CLEAR_EMISSION_MASK,
|
||||||
MENU_OPTION_CONVERT_TO_CPU_PARTICLES
|
MENU_OPTION_CONVERT_TO_CPU_PARTICLES,
|
||||||
|
MENU_RESTART
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EmissionMode {
|
enum EmissionMode {
|
||||||
|
|
|
@ -321,6 +321,11 @@ void ParticlesEditor::_menu_option(int p_option) {
|
||||||
ur->commit_action();
|
ur->commit_action();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
case MENU_OPTION_RESTART: {
|
||||||
|
|
||||||
|
node->restart();
|
||||||
|
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,6 +476,8 @@ ParticlesEditor::ParticlesEditor() {
|
||||||
options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
|
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_separator();
|
||||||
options->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
|
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");
|
options->get_popup()->connect("id_pressed", this, "_menu_option");
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ class ParticlesEditor : public ParticlesEditorBase {
|
||||||
MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH,
|
MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH,
|
||||||
MENU_OPTION_CLEAR_EMISSION_VOLUME,
|
MENU_OPTION_CLEAR_EMISSION_VOLUME,
|
||||||
MENU_OPTION_CONVERT_TO_CPU_PARTICLES,
|
MENU_OPTION_CONVERT_TO_CPU_PARTICLES,
|
||||||
|
MENU_OPTION_RESTART,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -250,6 +250,8 @@ void CPUParticles2D::restart() {
|
||||||
frame_remainder = 0;
|
frame_remainder = 0;
|
||||||
cycle = 0;
|
cycle = 0;
|
||||||
|
|
||||||
|
set_emitting(true);
|
||||||
|
|
||||||
{
|
{
|
||||||
int pc = particles.size();
|
int pc = particles.size();
|
||||||
PoolVector<Particle>::Write w = particles.write();
|
PoolVector<Particle>::Write w = particles.write();
|
||||||
|
|
|
@ -278,6 +278,7 @@ void Particles2D::_validate_property(PropertyInfo &property) const {
|
||||||
|
|
||||||
void Particles2D::restart() {
|
void Particles2D::restart() {
|
||||||
VS::get_singleton()->particles_restart(particles);
|
VS::get_singleton()->particles_restart(particles);
|
||||||
|
VS::get_singleton()->particles_set_emitting(particles, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Particles2D::_notification(int p_what) {
|
void Particles2D::_notification(int p_what) {
|
||||||
|
|
|
@ -225,6 +225,8 @@ void CPUParticles::restart() {
|
||||||
frame_remainder = 0;
|
frame_remainder = 0;
|
||||||
cycle = 0;
|
cycle = 0;
|
||||||
|
|
||||||
|
set_emitting(true);
|
||||||
|
|
||||||
{
|
{
|
||||||
int pc = particles.size();
|
int pc = particles.size();
|
||||||
PoolVector<Particle>::Write w = particles.write();
|
PoolVector<Particle>::Write w = particles.write();
|
||||||
|
|
|
@ -278,6 +278,7 @@ String Particles::get_configuration_warning() const {
|
||||||
void Particles::restart() {
|
void Particles::restart() {
|
||||||
|
|
||||||
VisualServer::get_singleton()->particles_restart(particles);
|
VisualServer::get_singleton()->particles_restart(particles);
|
||||||
|
VisualServer::get_singleton()->particles_set_emitting(particles, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
AABB Particles::capture_aabb() const {
|
AABB Particles::capture_aabb() const {
|
||||||
|
|
Loading…
Reference in a new issue