1
0
Fork 0

Fix emission_shape_changed signal error when using ShaderMaterial with 3DGPUParticles

This commit is contained in:
Patrick Exner 2025-01-16 01:18:43 +01:00
parent 4ce466d7fa
commit 484d6d4aa1
2 changed files with 14 additions and 4 deletions

View File

@ -418,6 +418,7 @@
<signal name="emission_shape_changed"> <signal name="emission_shape_changed">
<description> <description>
Emitted when this material's emission shape is changed in any way. This includes changes to [member emission_shape], [member emission_shape_scale], or [member emission_sphere_radius], and any other property that affects the emission shape's offset, size, scale, or orientation. Emitted when this material's emission shape is changed in any way. This includes changes to [member emission_shape], [member emission_shape_scale], or [member emission_sphere_radius], and any other property that affects the emission shape's offset, size, scale, or orientation.
[b]Note:[/b] This signal is only emitted inside the editor for performance reasons.
</description> </description>
</signal> </signal>
</signals> </signals>

View File

@ -145,11 +145,23 @@ void GPUParticles3D::set_use_local_coordinates(bool p_enable) {
} }
void GPUParticles3D::set_process_material(const Ref<Material> &p_material) { void GPUParticles3D::set_process_material(const Ref<Material> &p_material) {
#ifdef TOOLS_ENABLED
if (process_material.is_valid()) {
if (Ref<ParticleProcessMaterial>(process_material).is_valid()) {
process_material->disconnect("emission_shape_changed", callable_mp((Node3D *)this, &GPUParticles3D::update_gizmos));
}
}
#endif
process_material = p_material; process_material = p_material;
RID material_rid; RID material_rid;
if (process_material.is_valid()) { if (process_material.is_valid()) {
material_rid = process_material->get_rid(); material_rid = process_material->get_rid();
process_material->connect("emission_shape_changed", callable_mp((Node3D *)this, &GPUParticles3D::update_gizmos)); #ifdef TOOLS_ENABLED
if (Ref<ParticleProcessMaterial>(process_material).is_valid()) {
process_material->connect("emission_shape_changed", callable_mp((Node3D *)this, &GPUParticles3D::update_gizmos));
}
#endif
} }
RS::get_singleton()->particles_set_process_material(particles, material_rid); RS::get_singleton()->particles_set_process_material(particles, material_rid);
@ -554,9 +566,6 @@ void GPUParticles3D::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
RS::get_singleton()->particles_set_subemitter(particles, RID()); RS::get_singleton()->particles_set_subemitter(particles, RID());
Ref<ParticleProcessMaterial> material = get_process_material();
ERR_FAIL_COND(material.is_null());
} break; } break;
case NOTIFICATION_SUSPENDED: case NOTIFICATION_SUSPENDED: