You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Add visualization of 3D particle emission shapes
Co-authored-by: Kasper Arnklit Frandsen <kasper.arnklit@gmail.com>
This commit is contained in:
@@ -127,6 +127,7 @@ void GPUParticles3D::set_process_material(const Ref<Material> &p_material) {
|
||||
RID material_rid;
|
||||
if (process_material.is_valid()) {
|
||||
material_rid = process_material->get_rid();
|
||||
process_material->connect("emission_shape_changed", callable_mp((Node3D *)this, &GPUParticles3D::update_gizmos));
|
||||
}
|
||||
RS::get_singleton()->particles_set_process_material(particles, material_rid);
|
||||
|
||||
@@ -463,6 +464,14 @@ void GPUParticles3D::_notification(int p_what) {
|
||||
// Use internal process when emitting and one_shot is on so that when
|
||||
// the shot ends the editor can properly update.
|
||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||
const Vector3 velocity = (get_global_position() - previous_position) / get_process_delta_time();
|
||||
|
||||
if (velocity != previous_velocity) {
|
||||
RS::get_singleton()->particles_set_emitter_velocity(particles, velocity);
|
||||
previous_velocity = velocity;
|
||||
}
|
||||
previous_position = get_global_position();
|
||||
|
||||
if (one_shot) {
|
||||
time += get_process_delta_time();
|
||||
if (time > emission_time) {
|
||||
@@ -513,6 +522,10 @@ void GPUParticles3D::_notification(int p_what) {
|
||||
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
RS::get_singleton()->particles_set_subemitter(particles, RID());
|
||||
|
||||
Ref<ParticleProcessMaterial> material = get_process_material();
|
||||
ERR_FAIL_COND(material.is_null());
|
||||
material->disconnect("emission_shape_changed", callable_mp((Node3D *)this, &GPUParticles3D::update_gizmos));
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_SUSPENDED:
|
||||
|
||||
Reference in New Issue
Block a user