diff options
Diffstat (limited to 'scene/3d')
33 files changed, 338 insertions, 312 deletions
diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp index 5123a6eb6c..78c968a3d4 100644 --- a/scene/3d/area_3d.cpp +++ b/scene/3d/area_3d.cpp @@ -344,10 +344,14 @@ void Area3D::_clear_monitoring() { } void Area3D::_notification(int p_what) { - if (p_what == NOTIFICATION_EXIT_TREE) { - _clear_monitoring(); - } else if (p_what == NOTIFICATION_ENTER_TREE) { - _initialize_wind(); + switch (p_what) { + case NOTIFICATION_EXIT_TREE: { + _clear_monitoring(); + } break; + + case NOTIFICATION_ENTER_TREE: { + _initialize_wind(); + } break; } } diff --git a/scene/3d/audio_listener_3d.cpp b/scene/3d/audio_listener_3d.cpp index 0eb7588958..1ead9bb384 100644 --- a/scene/3d/audio_listener_3d.cpp +++ b/scene/3d/audio_listener_3d.cpp @@ -85,9 +85,11 @@ void AudioListener3D::_notification(int p_what) { make_current(); } } break; + case NOTIFICATION_TRANSFORM_CHANGED: { _request_listener_update(); } break; + case NOTIFICATION_EXIT_WORLD: { if (!get_tree()->is_node_being_edited(this)) { if (is_current()) { @@ -100,7 +102,6 @@ void AudioListener3D::_notification(int p_what) { } get_viewport()->_audio_listener_3d_remove(this); - } break; } } diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 3b52974b8e..b17201f86b 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -239,80 +239,82 @@ float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const { } void AudioStreamPlayer3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - velocity_tracker->reset(get_global_transform().origin); - AudioServer::get_singleton()->add_listener_changed_callback(_listener_changed_cb, this); - if (autoplay && !Engine::get_singleton()->is_editor_hint()) { - play(); - } - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + velocity_tracker->reset(get_global_transform().origin); + AudioServer::get_singleton()->add_listener_changed_callback(_listener_changed_cb, this); + if (autoplay && !Engine::get_singleton()->is_editor_hint()) { + play(); + } + } break; - if (p_what == NOTIFICATION_EXIT_TREE) { - stop(); - AudioServer::get_singleton()->remove_listener_changed_callback(_listener_changed_cb, this); - } + case NOTIFICATION_EXIT_TREE: { + stop(); + AudioServer::get_singleton()->remove_listener_changed_callback(_listener_changed_cb, this); + } break; - if (p_what == NOTIFICATION_PAUSED) { - if (!can_process()) { - // Node can't process so we start fading out to silence - set_stream_paused(true); - } - } + case NOTIFICATION_PAUSED: { + if (!can_process()) { + // Node can't process so we start fading out to silence. + set_stream_paused(true); + } + } break; - if (p_what == NOTIFICATION_UNPAUSED) { - set_stream_paused(false); - } + case NOTIFICATION_UNPAUSED: { + set_stream_paused(false); + } break; - if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - if (doppler_tracking != DOPPLER_TRACKING_DISABLED) { - velocity_tracker->update_position(get_global_transform().origin); - } - } + case NOTIFICATION_TRANSFORM_CHANGED: { + if (doppler_tracking != DOPPLER_TRACKING_DISABLED) { + velocity_tracker->update_position(get_global_transform().origin); + } + } break; - if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) { - //update anything related to position first, if possible of course - Vector<AudioFrame> volume_vector; - if (setplay.get() > 0 || (active.is_set() && last_mix_count != AudioServer::get_singleton()->get_mix_count())) { - volume_vector = _update_panning(); - } + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { + // Update anything related to position first, if possible of course. + Vector<AudioFrame> volume_vector; + if (setplay.get() > 0 || (active.is_set() && last_mix_count != AudioServer::get_singleton()->get_mix_count())) { + volume_vector = _update_panning(); + } - if (setplay.get() >= 0 && stream.is_valid()) { - active.set(); - Ref<AudioStreamPlayback> new_playback = stream->instance_playback(); - ERR_FAIL_COND_MSG(new_playback.is_null(), "Failed to instantiate playback."); - Map<StringName, Vector<AudioFrame>> bus_map; - bus_map[_get_actual_bus()] = volume_vector; - AudioServer::get_singleton()->start_playback_stream(new_playback, bus_map, setplay.get(), actual_pitch_scale, linear_attenuation, attenuation_filter_cutoff_hz); - stream_playbacks.push_back(new_playback); - setplay.set(-1); - } + if (setplay.get() >= 0 && stream.is_valid()) { + active.set(); + Ref<AudioStreamPlayback> new_playback = stream->instance_playback(); + ERR_FAIL_COND_MSG(new_playback.is_null(), "Failed to instantiate playback."); + Map<StringName, Vector<AudioFrame>> bus_map; + bus_map[_get_actual_bus()] = volume_vector; + AudioServer::get_singleton()->start_playback_stream(new_playback, bus_map, setplay.get(), actual_pitch_scale, linear_attenuation, attenuation_filter_cutoff_hz); + stream_playbacks.push_back(new_playback); + setplay.set(-1); + } - if (!stream_playbacks.is_empty() && active.is_set()) { - // Stop playing if no longer active. - Vector<Ref<AudioStreamPlayback>> playbacks_to_remove; - for (Ref<AudioStreamPlayback> &playback : stream_playbacks) { - if (playback.is_valid() && !AudioServer::get_singleton()->is_playback_active(playback) && !AudioServer::get_singleton()->is_playback_paused(playback)) { - playbacks_to_remove.push_back(playback); + if (!stream_playbacks.is_empty() && active.is_set()) { + // Stop playing if no longer active. + Vector<Ref<AudioStreamPlayback>> playbacks_to_remove; + for (Ref<AudioStreamPlayback> &playback : stream_playbacks) { + if (playback.is_valid() && !AudioServer::get_singleton()->is_playback_active(playback) && !AudioServer::get_singleton()->is_playback_paused(playback)) { + playbacks_to_remove.push_back(playback); + } + } + // Now go through and remove playbacks that have finished. Removing elements from a Vector in a range based for is asking for trouble. + for (Ref<AudioStreamPlayback> &playback : playbacks_to_remove) { + stream_playbacks.erase(playback); + } + if (!playbacks_to_remove.is_empty() && stream_playbacks.is_empty()) { + // This node is no longer actively playing audio. + active.clear(); + set_physics_process_internal(false); + } + if (!playbacks_to_remove.is_empty()) { + emit_signal(SNAME("finished")); } } - // Now go through and remove playbacks that have finished. Removing elements from a Vector in a range based for is asking for trouble. - for (Ref<AudioStreamPlayback> &playback : playbacks_to_remove) { - stream_playbacks.erase(playback); - } - if (!playbacks_to_remove.is_empty() && stream_playbacks.is_empty()) { - // This node is no longer actively playing audio. - active.clear(); - set_physics_process_internal(false); - } - if (!playbacks_to_remove.is_empty()) { - emit_signal(SNAME("finished")); - } - } - while (stream_playbacks.size() > max_polyphony) { - AudioServer::get_singleton()->stop_playback_stream(stream_playbacks[0]); - stream_playbacks.remove_at(0); - } + while (stream_playbacks.size() > max_polyphony) { + AudioServer::get_singleton()->stop_playback_stream(stream_playbacks[0]); + stream_playbacks.remove_at(0); + } + } break; } } diff --git a/scene/3d/bone_attachment_3d.cpp b/scene/3d/bone_attachment_3d.cpp index 73a4dcd1f7..8623c7d8b6 100644 --- a/scene/3d/bone_attachment_3d.cpp +++ b/scene/3d/bone_attachment_3d.cpp @@ -340,17 +340,20 @@ void BoneAttachment3D::_notification(int p_what) { } _check_bind(); } break; + case NOTIFICATION_EXIT_TREE: { _check_unbind(); } break; + case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { _transform_changed(); } break; + case NOTIFICATION_INTERNAL_PROCESS: { if (_override_dirty) { _override_dirty = false; } - } + } break; } } diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 2c95010eb4..375692d049 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -108,14 +108,15 @@ void Camera3D::_notification(int p_what) { if (current || first_camera) { viewport->_camera_3d_set(this); } - } break; + case NOTIFICATION_TRANSFORM_CHANGED: { _request_camera_update(); if (doppler_tracking != DOPPLER_TRACKING_DISABLED) { velocity_tracker->update_position(get_global_transform().origin); } } break; + case NOTIFICATION_EXIT_WORLD: { if (!get_tree()->is_node_being_edited(this)) { if (is_current()) { @@ -131,13 +132,14 @@ void Camera3D::_notification(int p_what) { viewport->_camera_3d_remove(this); viewport = nullptr; } - } break; + case NOTIFICATION_BECAME_CURRENT: { if (viewport) { viewport->find_world_3d()->_register_camera(this); } } break; + case NOTIFICATION_LOST_CURRENT: { if (viewport) { viewport->find_world_3d()->_remove_camera(this); diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp index 7926175459..88ef44b71f 100644 --- a/scene/3d/collision_polygon_3d.cpp +++ b/scene/3d/collision_polygon_3d.cpp @@ -93,18 +93,19 @@ void CollisionPolygon3D::_notification(int p_what) { _update_in_shape_owner(); } } break; + case NOTIFICATION_ENTER_TREE: { if (parent) { _update_in_shape_owner(); } - } break; + case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { if (parent) { _update_in_shape_owner(true); } - } break; + case NOTIFICATION_UNPARENTED: { if (parent) { parent->remove_shape_owner(owner_id); diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index 773095b377..e1a0e1427b 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -87,16 +87,19 @@ void CollisionShape3D::_notification(int p_what) { _update_in_shape_owner(); } } break; + case NOTIFICATION_ENTER_TREE: { if (parent) { _update_in_shape_owner(); } } break; + case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { if (parent) { _update_in_shape_owner(true); } } break; + case NOTIFICATION_UNPARENTED: { if (parent) { parent->remove_shape_owner(owner_id); diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index e3d551d782..a02b5f48a1 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -1251,65 +1251,67 @@ void CPUParticles3D::_update_render_thread() { } void CPUParticles3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - set_process_internal(emitting); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + set_process_internal(emitting); - // first update before rendering to avoid one frame delay after emitting starts - if (emitting && (time == 0)) { - _update_internal(); - } - } + // first update before rendering to avoid one frame delay after emitting starts + if (emitting && (time == 0)) { + _update_internal(); + } + } break; - if (p_what == NOTIFICATION_EXIT_TREE) { - _set_redraw(false); - } + case NOTIFICATION_EXIT_TREE: { + _set_redraw(false); + } break; - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - // first update before rendering to avoid one frame delay after emitting starts - if (emitting && (time == 0)) { + case NOTIFICATION_VISIBILITY_CHANGED: { + // first update before rendering to avoid one frame delay after emitting starts + if (emitting && (time == 0)) { + _update_internal(); + } + } break; + + case NOTIFICATION_INTERNAL_PROCESS: { _update_internal(); - } - } + } break; - if (p_what == NOTIFICATION_INTERNAL_PROCESS) { - _update_internal(); - } + case NOTIFICATION_TRANSFORM_CHANGED: { + inv_emission_transform = get_global_transform().affine_inverse(); - if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - inv_emission_transform = get_global_transform().affine_inverse(); + if (!local_coords) { + int pc = particles.size(); + + float *w = particle_data.ptrw(); + const Particle *r = particles.ptr(); + float *ptr = w; + + for (int i = 0; i < pc; i++) { + Transform3D t = inv_emission_transform * r[i].transform; + + if (r[i].active) { + ptr[0] = t.basis.elements[0][0]; + ptr[1] = t.basis.elements[0][1]; + ptr[2] = t.basis.elements[0][2]; + ptr[3] = t.origin.x; + ptr[4] = t.basis.elements[1][0]; + ptr[5] = t.basis.elements[1][1]; + ptr[6] = t.basis.elements[1][2]; + ptr[7] = t.origin.y; + ptr[8] = t.basis.elements[2][0]; + ptr[9] = t.basis.elements[2][1]; + ptr[10] = t.basis.elements[2][2]; + ptr[11] = t.origin.z; + } else { + memset(ptr, 0, sizeof(float) * 12); + } - if (!local_coords) { - int pc = particles.size(); - - float *w = particle_data.ptrw(); - const Particle *r = particles.ptr(); - float *ptr = w; - - for (int i = 0; i < pc; i++) { - Transform3D t = inv_emission_transform * r[i].transform; - - if (r[i].active) { - ptr[0] = t.basis.elements[0][0]; - ptr[1] = t.basis.elements[0][1]; - ptr[2] = t.basis.elements[0][2]; - ptr[3] = t.origin.x; - ptr[4] = t.basis.elements[1][0]; - ptr[5] = t.basis.elements[1][1]; - ptr[6] = t.basis.elements[1][2]; - ptr[7] = t.origin.y; - ptr[8] = t.basis.elements[2][0]; - ptr[9] = t.basis.elements[2][1]; - ptr[10] = t.basis.elements[2][2]; - ptr[11] = t.origin.z; - } else { - memset(ptr, 0, sizeof(float) * 12); + ptr += 20; } - ptr += 20; + can_update.set(); } - - can_update.set(); - } + } break; } } diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index aaaa728838..4e35f37291 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -423,38 +423,41 @@ NodePath GPUParticles3D::get_sub_emitter() const { } void GPUParticles3D::_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); - } else { - RS::get_singleton()->particles_set_speed_scale(particles, 0); - } - } - - // Use internal process when emitting and one_shot is on so that when - // the shot ends the editor can properly update - if (p_what == NOTIFICATION_INTERNAL_PROCESS) { - if (one_shot && !is_emitting()) { - notify_property_list_changed(); - set_process_internal(false); - } - } + switch (p_what) { + case NOTIFICATION_PAUSED: + case NOTIFICATION_UNPAUSED: { + if (can_process()) { + RS::get_singleton()->particles_set_speed_scale(particles, speed_scale); + } else { + RS::get_singleton()->particles_set_speed_scale(particles, 0); + } + } break; + + // 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: { + if (one_shot && !is_emitting()) { + notify_property_list_changed(); + set_process_internal(false); + } + } break; - if (p_what == NOTIFICATION_ENTER_TREE) { - if (sub_emitter != NodePath()) { - _attach_sub_emitter(); - } - } + case NOTIFICATION_ENTER_TREE: { + if (sub_emitter != NodePath()) { + _attach_sub_emitter(); + } + } break; - if (p_what == NOTIFICATION_EXIT_TREE) { - RS::get_singleton()->particles_set_subemitter(particles, RID()); - } + case NOTIFICATION_EXIT_TREE: { + RS::get_singleton()->particles_set_subemitter(particles, RID()); + } break; - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - // make sure particles are updated before rendering occurs if they were active before - if (is_visible_in_tree() && !RS::get_singleton()->particles_is_inactive(particles)) { - RS::get_singleton()->particles_request_process(particles); - } + case NOTIFICATION_VISIBILITY_CHANGED: { + // Make sure particles are updated before rendering occurs if they were active before. + if (is_visible_in_tree() && !RS::get_singleton()->particles_is_inactive(particles)) { + RS::get_singleton()->particles_request_process(particles); + } + } break; } } diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index 54fbc720ce..6f94df284a 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -584,47 +584,49 @@ GPUParticlesCollisionSDF3D::~GPUParticlesCollisionSDF3D() { //////////////////////////// void GPUParticlesCollisionHeightField3D::_notification(int p_what) { - if (p_what == NOTIFICATION_INTERNAL_PROCESS) { - if (update_mode == UPDATE_MODE_ALWAYS) { - RS::get_singleton()->particles_collision_height_field_update(_get_collision()); - } + switch (p_what) { + case NOTIFICATION_INTERNAL_PROCESS: { + if (update_mode == UPDATE_MODE_ALWAYS) { + RS::get_singleton()->particles_collision_height_field_update(_get_collision()); + } - if (follow_camera_mode && get_viewport()) { - Camera3D *cam = get_viewport()->get_camera_3d(); - if (cam) { - Transform3D xform = get_global_transform(); - Vector3 x_axis = xform.basis.get_axis(Vector3::AXIS_X).normalized(); - Vector3 z_axis = xform.basis.get_axis(Vector3::AXIS_Z).normalized(); - float x_len = xform.basis.get_scale().x; - float z_len = xform.basis.get_scale().z; + if (follow_camera_mode && get_viewport()) { + Camera3D *cam = get_viewport()->get_camera_3d(); + if (cam) { + Transform3D xform = get_global_transform(); + Vector3 x_axis = xform.basis.get_axis(Vector3::AXIS_X).normalized(); + Vector3 z_axis = xform.basis.get_axis(Vector3::AXIS_Z).normalized(); + float x_len = xform.basis.get_scale().x; + float z_len = xform.basis.get_scale().z; - Vector3 cam_pos = cam->get_global_transform().origin; - Transform3D new_xform = xform; + Vector3 cam_pos = cam->get_global_transform().origin; + Transform3D new_xform = xform; - while (x_axis.dot(cam_pos - new_xform.origin) > x_len) { - new_xform.origin += x_axis * x_len; - } - while (x_axis.dot(cam_pos - new_xform.origin) < -x_len) { - new_xform.origin -= x_axis * x_len; - } + while (x_axis.dot(cam_pos - new_xform.origin) > x_len) { + new_xform.origin += x_axis * x_len; + } + while (x_axis.dot(cam_pos - new_xform.origin) < -x_len) { + new_xform.origin -= x_axis * x_len; + } - while (z_axis.dot(cam_pos - new_xform.origin) > z_len) { - new_xform.origin += z_axis * z_len; - } - while (z_axis.dot(cam_pos - new_xform.origin) < -z_len) { - new_xform.origin -= z_axis * z_len; - } + while (z_axis.dot(cam_pos - new_xform.origin) > z_len) { + new_xform.origin += z_axis * z_len; + } + while (z_axis.dot(cam_pos - new_xform.origin) < -z_len) { + new_xform.origin -= z_axis * z_len; + } - if (new_xform != xform) { - set_global_transform(new_xform); - RS::get_singleton()->particles_collision_height_field_update(_get_collision()); + if (new_xform != xform) { + set_global_transform(new_xform); + RS::get_singleton()->particles_collision_height_field_update(_get_collision()); + } } } - } - } + } break; - if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - RS::get_singleton()->particles_collision_height_field_update(_get_collision()); + case NOTIFICATION_TRANSFORM_CHANGED: { + RS::get_singleton()->particles_collision_height_field_update(_get_collision()); + } break; } } diff --git a/scene/3d/joint_3d.cpp b/scene/3d/joint_3d.cpp index bd47ab3462..36abd0a5c5 100644 --- a/scene/3d/joint_3d.cpp +++ b/scene/3d/joint_3d.cpp @@ -169,6 +169,7 @@ void Joint3D::_notification(int p_what) { case NOTIFICATION_READY: { _update_joint(); } break; + case NOTIFICATION_EXIT_TREE: { if (joint.is_valid()) { _disconnect_signals(); diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index d88bb815bc..b2e605a262 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -177,12 +177,11 @@ void Light3D::_update_visibility() { } void Light3D::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - _update_visibility(); - } - - if (p_what == NOTIFICATION_ENTER_TREE) { - _update_visibility(); + switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: + case NOTIFICATION_ENTER_TREE: { + _update_visibility(); + } break; } } diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp index 825742da35..68d2b91fad 100644 --- a/scene/3d/lightmap_gi.cpp +++ b/scene/3d/lightmap_gi.cpp @@ -1176,16 +1176,18 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa } void LightmapGI::_notification(int p_what) { - if (p_what == NOTIFICATION_POST_ENTER_TREE) { - if (light_data.is_valid()) { - _assign_lightmaps(); - } - } + switch (p_what) { + case NOTIFICATION_POST_ENTER_TREE: { + if (light_data.is_valid()) { + _assign_lightmaps(); + } + } break; - if (p_what == NOTIFICATION_EXIT_TREE) { - if (light_data.is_valid()) { - _clear_lightmaps(); - } + case NOTIFICATION_EXIT_TREE: { + if (light_data.is_valid()) { + _clear_lightmaps(); + } + } break; } } diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 58ff512130..fddfa17dbb 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -328,8 +328,10 @@ void MeshInstance3D::create_multiple_convex_collisions() { } void MeshInstance3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - _resolve_skeleton_path(); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + _resolve_skeleton_path(); + } break; } } diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index e90971845e..c4f062f0f9 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -103,10 +103,12 @@ void NavigationAgent3D::_notification(int p_what) { } set_physics_process_internal(true); } break; + case NOTIFICATION_EXIT_TREE: { agent_parent = nullptr; set_physics_process_internal(false); } break; + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (agent_parent) { NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin); diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp index ba6c50d98c..308545b2cc 100644 --- a/scene/3d/navigation_obstacle_3d.cpp +++ b/scene/3d/navigation_obstacle_3d.cpp @@ -63,17 +63,21 @@ void NavigationObstacle3D::_notification(int p_what) { } set_physics_process_internal(true); } break; + case NOTIFICATION_EXIT_TREE: { parent_node3d = nullptr; set_physics_process_internal(false); } break; + case NOTIFICATION_PARENTED: { parent_node3d = Object::cast_to<Node3D>(get_parent()); reevaluate_agent_radius(); } break; + case NOTIFICATION_UNPARENTED: { parent_node3d = nullptr; } break; + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (parent_node3d) { NavigationServer3D::get_singleton()->agent_set_position(agent, parent_node3d->get_global_transform().origin); diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index 1e298e0137..8f0fd8706d 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -93,12 +93,12 @@ void NavigationRegion3D::_notification(int p_what) { add_child(dm); debug_view = dm; } - } break; + case NOTIFICATION_TRANSFORM_CHANGED: { NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform()); - } break; + case NOTIFICATION_EXIT_TREE: { NavigationServer3D::get_singleton()->region_set_map(region, RID()); diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index cad1201d63..62cc7c143b 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -147,8 +147,8 @@ void Node3D::_notification(int p_what) { notification(NOTIFICATION_ENTER_WORLD); _update_visibility_parent(true); - } break; + case NOTIFICATION_EXIT_TREE: { notification(NOTIFICATION_EXIT_WORLD, true); if (xform_change.in_list()) { @@ -162,6 +162,7 @@ void Node3D::_notification(int p_what) { data.top_level_active = false; _update_visibility_parent(true); } break; + case NOTIFICATION_ENTER_WORLD: { data.inside_world = true; data.viewport = nullptr; @@ -192,6 +193,7 @@ void Node3D::_notification(int p_what) { } #endif } break; + case NOTIFICATION_EXIT_WORLD: { #ifdef TOOLS_ENABLED clear_gizmos(); @@ -203,7 +205,6 @@ void Node3D::_notification(int p_what) { data.viewport = nullptr; data.inside_world = false; - } break; case NOTIFICATION_TRANSFORM_CHANGED: { @@ -213,9 +214,6 @@ void Node3D::_notification(int p_what) { } #endif } break; - - default: { - } } } diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp index 231817526c..2488bfb8ba 100644 --- a/scene/3d/occluder_instance_3d.cpp +++ b/scene/3d/occluder_instance_3d.cpp @@ -122,8 +122,10 @@ AABB Occluder3D::get_aabb() const { } void Occluder3D::_notification(int p_what) { - if (p_what == NOTIFICATION_POSTINITIALIZE) { - _update(); + switch (p_what) { + case NOTIFICATION_POSTINITIALIZE: { + _update(); + } break; } } diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index 6e1c9ef781..5fd28a6ff3 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -30,9 +30,6 @@ #include "path_3d.h" -void Path3D::_notification(int p_what) { -} - void Path3D::_curve_changed() { if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) { update_gizmos(); @@ -223,8 +220,8 @@ void PathFollow3D::_notification(int p_what) { _update_transform(false); } } - } break; + case NOTIFICATION_EXIT_TREE: { path = nullptr; } break; diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h index 32ca5a1beb..e9ab557693 100644 --- a/scene/3d/path_3d.h +++ b/scene/3d/path_3d.h @@ -42,7 +42,6 @@ class Path3D : public Node3D { void _curve_changed(); protected: - void _notification(int p_what); static void _bind_methods(); public: diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 13a38f3b9f..c6d7e1df86 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -601,7 +601,7 @@ void RigidDynamicBody3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { if (Engine::get_singleton()->is_editor_hint()) { - set_notify_local_transform(true); //used for warnings and only in editor + set_notify_local_transform(true); // Used for warnings and only in editor. } } break; diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index b251aa38ba..f5e08b92ca 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -171,8 +171,8 @@ void RayCast3D::_notification(int p_what) { exclude.erase(Object::cast_to<CollisionObject3D>(get_parent())->get_rid()); } } - } break; + case NOTIFICATION_EXIT_TREE: { if (enabled) { set_physics_process_internal(false); @@ -181,8 +181,8 @@ void RayCast3D::_notification(int p_what) { if (debug_shape) { _clear_debug_shape(); } - } break; + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (!enabled) { break; @@ -193,7 +193,6 @@ void RayCast3D::_notification(int p_what) { if (prev_collision_state != collided && get_tree()->is_debugging_collisions_hint()) { _update_debug_shape_material(true); } - } break; } } diff --git a/scene/3d/remote_transform_3d.cpp b/scene/3d/remote_transform_3d.cpp index 2770b6f40c..8b714850d6 100644 --- a/scene/3d/remote_transform_3d.cpp +++ b/scene/3d/remote_transform_3d.cpp @@ -111,8 +111,8 @@ void RemoteTransform3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { _update_cache(); - } break; + case NOTIFICATION_TRANSFORM_CHANGED: { if (!is_inside_tree()) { break; @@ -121,7 +121,6 @@ void RemoteTransform3D::_notification(int p_what) { if (cache.is_valid()) { _update_remote(); } - } break; } } diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index b6b5920f69..598897456d 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -318,11 +318,9 @@ void Skeleton3D::_notification(int p_what) { rs->skeleton_bone_set_transform(skeleton, i, bonesptr[bone_index].pose_global * skin->get_bind_pose(i)); } } - #ifdef TOOLS_ENABLED emit_signal(SceneStringNames::get_singleton()->pose_updated); #endif // TOOLS_ENABLED - } break; #ifndef _3D_DISABLED @@ -344,19 +342,14 @@ void Skeleton3D::_notification(int p_what) { if (modification_stack.is_valid()) { execute_modifications(get_physics_process_delta_time(), SkeletonModificationStack3D::EXECUTION_MODE::execution_mode_physics_process); } - } break; -#endif // _3D_DISABLED -#ifndef _3D_DISABLED case NOTIFICATION_INTERNAL_PROCESS: { if (modification_stack.is_valid()) { execute_modifications(get_process_delta_time(), SkeletonModificationStack3D::EXECUTION_MODE::execution_mode_process); } } break; -#endif // _3D_DISABLED -#ifndef _3D_DISABLED case NOTIFICATION_READY: { set_physics_process_internal(true); set_process_internal(true); diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp index c645009c72..f29b060069 100644 --- a/scene/3d/skeleton_ik_3d.cpp +++ b/scene/3d/skeleton_ik_3d.cpp @@ -407,14 +407,14 @@ void SkeletonIK3D::_notification(int p_what) { set_process_priority(1); reload_chain(); } break; + case NOTIFICATION_INTERNAL_PROCESS: { if (target_node_override) { reload_goal(); } - _solve_chain(); - } break; + case NOTIFICATION_EXIT_TREE: { reload_chain(); } break; diff --git a/scene/3d/spring_arm_3d.cpp b/scene/3d/spring_arm_3d.cpp index 8a8964f69a..230801bd52 100644 --- a/scene/3d/spring_arm_3d.cpp +++ b/scene/3d/spring_arm_3d.cpp @@ -29,23 +29,26 @@ /*************************************************************************/ #include "spring_arm_3d.h" + #include "scene/3d/camera_3d.h" void SpringArm3D::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_ENTER_TREE: { if (!Engine::get_singleton()->is_editor_hint()) { set_physics_process_internal(true); } - break; - case NOTIFICATION_EXIT_TREE: + } break; + + case NOTIFICATION_EXIT_TREE: { if (!Engine::get_singleton()->is_editor_hint()) { set_physics_process_internal(false); } - break; - case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: + } break; + + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { process_spring(); - break; + } break; } } diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 331d58927b..68c9ff8ece 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -66,23 +66,25 @@ void SpriteBase3D::_propagate_color_changed() { } void SpriteBase3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - if (!pending_update) { - _im_update(); - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + if (!pending_update) { + _im_update(); + } - parent_sprite = Object::cast_to<SpriteBase3D>(get_parent()); - if (parent_sprite) { - pI = parent_sprite->children.push_back(this); - } - } + parent_sprite = Object::cast_to<SpriteBase3D>(get_parent()); + if (parent_sprite) { + pI = parent_sprite->children.push_back(this); + } + } break; - if (p_what == NOTIFICATION_EXIT_TREE) { - if (parent_sprite) { - parent_sprite->children.erase(pI); - pI = nullptr; - parent_sprite = nullptr; - } + case NOTIFICATION_EXIT_TREE: { + if (parent_sprite) { + parent_sprite->children.erase(pI); + pI = nullptr; + parent_sprite = nullptr; + } + } break; } } diff --git a/scene/3d/visible_on_screen_notifier_3d.cpp b/scene/3d/visible_on_screen_notifier_3d.cpp index 44d2a3e03f..11367d7ca9 100644 --- a/scene/3d/visible_on_screen_notifier_3d.cpp +++ b/scene/3d/visible_on_screen_notifier_3d.cpp @@ -71,8 +71,11 @@ bool VisibleOnScreenNotifier3D::is_on_screen() const { } void VisibleOnScreenNotifier3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_EXIT_TREE) { - on_screen = false; + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_EXIT_TREE: { + on_screen = false; + } break; } } @@ -161,21 +164,23 @@ void VisibleOnScreenEnabler3D::_update_enable_mode(bool p_enable) { } } void VisibleOnScreenEnabler3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - if (Engine::get_singleton()->is_editor_hint()) { - return; - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + if (Engine::get_singleton()->is_editor_hint()) { + return; + } - node_id = ObjectID(); - Node *node = get_node(enable_node_path); - if (node) { - node_id = node->get_instance_id(); - node->set_process_mode(PROCESS_MODE_DISABLED); - } - } + node_id = ObjectID(); + Node *node = get_node(enable_node_path); + if (node) { + node_id = node->get_instance_id(); + node->set_process_mode(PROCESS_MODE_DISABLED); + } + } break; - if (p_what == NOTIFICATION_EXIT_TREE) { - node_id = ObjectID(); + case NOTIFICATION_EXIT_TREE: { + node_id = ObjectID(); + } break; } } diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index 005bb5a737..d8dffe6c7d 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -47,27 +47,21 @@ void VisualInstance3D::_update_visibility() { void VisualInstance3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { - // CHECK SKELETON => moving skeleton attaching logic to MeshInstance - /* - Skeleton *skeleton=Object::cast_to<Skeleton>(get_parent()); - if (skeleton) - RenderingServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() ); - */ ERR_FAIL_COND(get_world_3d().is_null()); RenderingServer::get_singleton()->instance_set_scenario(instance, get_world_3d()->get_scenario()); _update_visibility(); - } break; + case NOTIFICATION_TRANSFORM_CHANGED: { Transform3D gt = get_global_transform(); RenderingServer::get_singleton()->instance_set_transform(instance, gt); } break; + case NOTIFICATION_EXIT_WORLD: { RenderingServer::get_singleton()->instance_set_scenario(instance, RID()); RenderingServer::get_singleton()->instance_attach_skeleton(instance, RID()); - //RS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() ); - } break; + case NOTIFICATION_VISIBILITY_CHANGED: { _update_visibility(); } break; @@ -220,9 +214,6 @@ GeometryInstance3D::VisibilityRangeFadeMode GeometryInstance3D::get_visibility_r return visibility_range_fade_mode; } -void GeometryInstance3D::_notification(int p_what) { -} - const StringName *GeometryInstance3D::_instance_uniform_get_remap(const StringName p_name) const { StringName *r = instance_uniform_property_remap.getptr(p_name); if (!r) { diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index be964e5080..02f62b41e5 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -137,7 +137,6 @@ protected: bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; - void _notification(int p_what); static void _bind_methods(); public: diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp index 98f28a8cff..300e761f39 100644 --- a/scene/3d/world_environment.cpp +++ b/scene/3d/world_environment.cpp @@ -34,27 +34,32 @@ #include "scene/main/window.h" void WorldEnvironment::_notification(int p_what) { - if (p_what == Node3D::NOTIFICATION_ENTER_WORLD || p_what == Node3D::NOTIFICATION_ENTER_TREE) { - if (environment.is_valid()) { - add_to_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); - _update_current_environment(); - } - - if (camera_effects.is_valid()) { - add_to_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); - _update_current_camera_effects(); - } - - } else if (p_what == Node3D::NOTIFICATION_EXIT_WORLD || p_what == Node3D::NOTIFICATION_EXIT_TREE) { - if (environment.is_valid()) { - remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); - _update_current_environment(); - } - - if (camera_effects.is_valid()) { - remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); - _update_current_camera_effects(); - } + switch (p_what) { + case Node3D::NOTIFICATION_ENTER_WORLD: + case Node3D::NOTIFICATION_ENTER_TREE: { + if (environment.is_valid()) { + add_to_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); + _update_current_environment(); + } + + if (camera_effects.is_valid()) { + add_to_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); + _update_current_camera_effects(); + } + } break; + + case Node3D::NOTIFICATION_EXIT_WORLD: + case Node3D::NOTIFICATION_EXIT_TREE: { + if (environment.is_valid()) { + remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); + _update_current_environment(); + } + + if (camera_effects.is_valid()) { + remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); + _update_current_camera_effects(); + } + } break; } } diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp index 211c39c949..b18819c920 100644 --- a/scene/3d/xr_nodes.cpp +++ b/scene/3d/xr_nodes.cpp @@ -44,16 +44,17 @@ void XRCamera3D::_notification(int p_what) { if (origin != nullptr) { origin->set_tracked_camera(this); } - }; break; + } break; + case NOTIFICATION_EXIT_TREE: { // need to find our XROrigin3D parent and let it know we're no longer its camera! XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent()); if (origin != nullptr && origin->get_tracked_camera() == this) { origin->set_tracked_camera(nullptr); } - }; break; - }; -}; + } break; + } +} void XRCamera3D::_changed_tracker(const StringName p_tracker_name, int p_tracker_type) { if (p_tracker_name == tracker_name) { @@ -657,10 +658,12 @@ void XROrigin3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { set_process_internal(true); - }; break; + } break; + case NOTIFICATION_EXIT_TREE: { set_process_internal(false); - }; break; + } break; + case NOTIFICATION_INTERNAL_PROCESS: { // set our world origin to our node transform xr_server->set_world_origin(get_global_transform()); @@ -673,11 +676,9 @@ void XROrigin3D::_notification(int p_what) { // now apply this to our camera tracked_camera->set_transform(t); - }; - }; break; - default: - break; - }; + } + } break; + } // send our notification to all active XE interfaces, they may need to react to it also for (int i = 0; i < xr_server->get_interface_count(); i++) { |