From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- scene/2d/animated_sprite_2d.cpp | 55 ---- scene/2d/animated_sprite_2d.h | 6 - scene/2d/area_2d.cpp | 64 ----- scene/2d/area_2d.h | 5 - scene/2d/audio_stream_player_2d.cpp | 39 --- scene/2d/audio_stream_player_2d.h | 2 - scene/2d/back_buffer_copy.cpp | 12 - scene/2d/camera_2d.cpp | 63 ----- scene/2d/camera_2d.h | 1 - scene/2d/canvas_modulate.cpp | 8 - scene/2d/canvas_modulate.h | 1 - scene/2d/collision_object_2d.cpp | 38 --- scene/2d/collision_object_2d.h | 2 - scene/2d/collision_polygon_2d.cpp | 22 -- scene/2d/collision_polygon_2d.h | 1 - scene/2d/collision_shape_2d.cpp | 15 - scene/2d/collision_shape_2d.h | 1 - scene/2d/cpu_particles_2d.cpp | 79 ------ scene/2d/cpu_particles_2d.h | 1 - scene/2d/gpu_particles_2d.cpp | 38 --- scene/2d/joints_2d.cpp | 41 --- scene/2d/joints_2d.h | 4 - scene/2d/light_2d.cpp | 47 --- scene/2d/light_2d.h | 1 - scene/2d/light_occluder_2d.cpp | 33 --- scene/2d/light_occluder_2d.h | 1 - scene/2d/line_2d.cpp | 4 - scene/2d/line_2d.h | 1 - scene/2d/line_builder.cpp | 5 - scene/2d/mesh_instance_2d.cpp | 9 - scene/2d/multimesh_instance_2d.cpp | 9 - scene/2d/navigation_2d.cpp | 2 - scene/2d/navigation_2d.h | 1 - scene/2d/navigation_agent_2d.cpp | 4 - scene/2d/navigation_obstacle_2d.cpp | 2 - scene/2d/navigation_region_2d.cpp | 50 ---- scene/2d/navigation_region_2d.h | 2 - scene/2d/node_2d.cpp | 41 --- scene/2d/node_2d.h | 1 - scene/2d/parallax_background.cpp | 26 -- scene/2d/parallax_background.h | 1 - scene/2d/parallax_layer.cpp | 14 - scene/2d/parallax_layer.h | 1 - scene/2d/path_2d.cpp | 38 --- scene/2d/path_2d.h | 2 - scene/2d/physics_body_2d.cpp | 121 -------- scene/2d/physics_body_2d.h | 9 - scene/2d/polygon_2d.cpp | 44 --- scene/2d/polygon_2d.h | 1 - scene/2d/position_2d.cpp | 6 - scene/2d/position_2d.h | 1 - scene/2d/ray_cast_2d.cpp | 33 --- scene/2d/ray_cast_2d.h | 1 - scene/2d/remote_transform_2d.cpp | 13 - scene/2d/remote_transform_2d.h | 1 - scene/2d/skeleton_2d.cpp | 17 -- scene/2d/sprite_2d.cpp | 35 --- scene/2d/sprite_2d.h | 1 - scene/2d/tile_map.cpp | 142 ---------- scene/2d/tile_map.h | 4 - scene/2d/touch_screen_button.cpp | 40 --- scene/2d/touch_screen_button.h | 1 - scene/2d/visibility_notifier_2d.cpp | 34 --- scene/2d/visibility_notifier_2d.h | 2 - scene/2d/y_sort.cpp | 4 - scene/3d/area_3d.cpp | 70 ----- scene/3d/area_3d.h | 5 - scene/3d/audio_stream_player_3d.cpp | 70 ----- scene/3d/audio_stream_player_3d.h | 2 - scene/3d/baked_lightmap.cpp | 49 ---- scene/3d/baked_lightmap.h | 1 - scene/3d/bone_attachment_3d.cpp | 14 - scene/3d/bone_attachment_3d.h | 1 - scene/3d/camera_3d.cpp | 65 ----- scene/3d/camera_3d.h | 2 - scene/3d/collision_object_3d.cpp | 33 --- scene/3d/collision_object_3d.h | 2 - scene/3d/collision_polygon_3d.cpp | 15 - scene/3d/collision_polygon_3d.h | 1 - scene/3d/collision_shape_3d.cpp | 14 - scene/3d/collision_shape_3d.h | 1 - scene/3d/cpu_particles_3d.cpp | 80 ------ scene/3d/cpu_particles_3d.h | 1 - scene/3d/decal.cpp | 5 - scene/3d/gi_probe.cpp | 24 -- scene/3d/gi_probe.h | 1 - scene/3d/gpu_particles_3d.cpp | 42 --- scene/3d/immediate_geometry_3d.cpp | 16 -- scene/3d/immediate_geometry_3d.h | 1 - scene/3d/light_3d.cpp | 42 --- scene/3d/light_3d.h | 4 - scene/3d/listener_3d.cpp | 16 -- scene/3d/listener_3d.h | 1 - scene/3d/mesh_instance_3d.cpp | 26 -- scene/3d/mesh_instance_3d.h | 2 - scene/3d/multimesh_instance_3d.cpp | 5 - scene/3d/navigation_3d.cpp | 6 - scene/3d/navigation_3d.h | 1 - scene/3d/navigation_agent_3d.cpp | 4 - scene/3d/navigation_obstacle_3d.cpp | 4 - scene/3d/navigation_region_3d.cpp | 20 -- scene/3d/navigation_region_3d.h | 1 - scene/3d/node_3d.cpp | 66 ----- scene/3d/node_3d.h | 3 - scene/3d/path_3d.cpp | 29 -- scene/3d/path_3d.h | 2 - scene/3d/physics_body_3d.cpp | 137 --------- scene/3d/physics_body_3d.h | 10 - scene/3d/physics_joint_3d.cpp | 74 ----- scene/3d/physics_joint_3d.h | 6 - scene/3d/position_3d.h | 1 - scene/3d/proximity_group_3d.cpp | 23 -- scene/3d/proximity_group_3d.h | 1 - scene/3d/ray_cast_3d.cpp | 35 --- scene/3d/ray_cast_3d.h | 1 - scene/3d/reflection_probe.cpp | 27 -- scene/3d/remote_transform_3d.cpp | 11 - scene/3d/skeleton_3d.cpp | 65 ----- scene/3d/skeleton_3d.h | 4 - scene/3d/skeleton_ik_3d.cpp | 24 -- scene/3d/skeleton_ik_3d.h | 2 - scene/3d/soft_body_3d.cpp | 26 -- scene/3d/soft_body_3d.h | 1 - scene/3d/spring_arm_3d.cpp | 2 - scene/3d/sprite_3d.cpp | 81 ------ scene/3d/sprite_3d.h | 3 - scene/3d/vehicle_body_3d.cpp | 56 ---- scene/3d/vehicle_body_3d.h | 2 - scene/3d/velocity_tracker_3d.cpp | 6 - scene/3d/visibility_notifier_3d.cpp | 29 -- scene/3d/visibility_notifier_3d.h | 2 - scene/3d/visual_instance_3d.cpp | 36 --- scene/3d/visual_instance_3d.h | 2 - scene/3d/voxelizer.cpp | 42 --- scene/3d/voxelizer.h | 1 - scene/3d/world_environment.cpp | 9 - scene/3d/world_environment.h | 1 - scene/3d/xr_nodes.cpp | 1 - scene/3d/xr_nodes.h | 3 - scene/animation/animation_blend_space_1d.cpp | 5 - scene/animation/animation_blend_space_2d.cpp | 23 -- scene/animation/animation_blend_tree.cpp | 79 ------ scene/animation/animation_blend_tree.h | 2 - scene/animation/animation_cache.cpp | 34 --- scene/animation/animation_cache.h | 2 - scene/animation/animation_node_state_machine.cpp | 48 ---- scene/animation/animation_node_state_machine.h | 2 - scene/animation/animation_player.cpp | 133 --------- scene/animation/animation_player.h | 13 - scene/animation/animation_tree.cpp | 75 ----- scene/animation/animation_tree.h | 9 - scene/animation/root_motion_view.cpp | 6 - scene/animation/tween.cpp | 17 -- scene/animation/tween.h | 1 - scene/audio/audio_stream_player.cpp | 32 --- scene/audio/audio_stream_player.h | 1 - scene/debugger/scene_debugger.cpp | 20 -- scene/debugger/scene_debugger.h | 4 - scene/gui/base_button.cpp | 45 --- scene/gui/base_button.h | 3 - scene/gui/box_container.cpp | 15 - scene/gui/box_container.h | 3 - scene/gui/button.cpp | 27 -- scene/gui/button.h | 1 - scene/gui/center_container.cpp | 9 - scene/gui/center_container.h | 1 - scene/gui/check_box.cpp | 5 - scene/gui/check_box.h | 1 - scene/gui/check_button.cpp | 6 - scene/gui/check_button.h | 1 - scene/gui/color_picker.cpp | 53 ---- scene/gui/color_picker.h | 2 - scene/gui/color_rect.cpp | 5 - scene/gui/container.cpp | 15 - scene/gui/container.h | 1 - scene/gui/control.cpp | 212 -------------- scene/gui/control.h | 3 - scene/gui/dialogs.cpp | 24 -- scene/gui/dialogs.h | 2 - scene/gui/file_dialog.cpp | 78 ----- scene/gui/file_dialog.h | 1 - scene/gui/gradient_edit.cpp | 18 -- scene/gui/gradient_edit.h | 1 - scene/gui/graph_edit.cpp | 104 ------- scene/gui/graph_edit.h | 3 - scene/gui/graph_node.cpp | 52 ---- scene/gui/graph_node.h | 1 - scene/gui/grid_container.cpp | 9 - scene/gui/grid_container.h | 1 - scene/gui/item_list.cpp | 126 --------- scene/gui/item_list.h | 2 - scene/gui/label.cpp | 58 ---- scene/gui/label.h | 2 - scene/gui/line_edit.cpp | 101 ------- scene/gui/line_edit.h | 2 - scene/gui/link_button.cpp | 14 - scene/gui/link_button.h | 1 - scene/gui/margin_container.cpp | 6 - scene/gui/menu_button.cpp | 14 - scene/gui/menu_button.h | 1 - scene/gui/nine_patch_rect.cpp | 15 - scene/gui/nine_patch_rect.h | 1 - scene/gui/option_button.cpp | 39 --- scene/gui/option_button.h | 1 - scene/gui/panel.cpp | 2 - scene/gui/panel.h | 1 - scene/gui/panel_container.cpp | 6 - scene/gui/panel_container.h | 1 - scene/gui/popup.cpp | 12 - scene/gui/popup.h | 2 - scene/gui/popup_menu.cpp | 131 --------- scene/gui/popup_menu.h | 1 - scene/gui/progress_bar.cpp | 8 - scene/gui/progress_bar.h | 1 - scene/gui/range.cpp | 34 --- scene/gui/range.h | 1 - scene/gui/reference_rect.cpp | 2 - scene/gui/reference_rect.h | 1 - scene/gui/rich_text_effect.cpp | 1 - scene/gui/rich_text_label.cpp | 175 ------------ scene/gui/rich_text_label.h | 3 - scene/gui/scroll_bar.cpp | 64 ----- scene/gui/scroll_bar.h | 4 - scene/gui/scroll_container.cpp | 42 --- scene/gui/scroll_container.h | 1 - scene/gui/separator.cpp | 8 - scene/gui/separator.h | 3 - scene/gui/shortcut.cpp | 6 - scene/gui/shortcut.h | 1 - scene/gui/slider.cpp | 27 -- scene/gui/slider.h | 3 - scene/gui/spin_box.cpp | 33 --- scene/gui/spin_box.h | 1 - scene/gui/split_container.cpp | 35 --- scene/gui/split_container.h | 3 - scene/gui/subviewport_container.cpp | 20 -- scene/gui/subviewport_container.h | 1 - scene/gui/tab_container.cpp | 56 ---- scene/gui/tab_container.h | 1 - scene/gui/tabs.cpp | 58 ---- scene/gui/tabs.h | 2 - scene/gui/text_edit.cpp | 321 --------------------- scene/gui/text_edit.h | 7 - scene/gui/texture_button.cpp | 22 -- scene/gui/texture_button.h | 1 - scene/gui/texture_progress.cpp | 10 - scene/gui/texture_progress.h | 1 - scene/gui/texture_rect.cpp | 16 -- scene/gui/texture_rect.h | 1 - scene/gui/tree.cpp | 345 ----------------------- scene/gui/tree.h | 6 - scene/gui/video_player.cpp | 43 --- scene/gui/video_player.h | 2 - scene/main/canvas_item.cpp | 104 ------- scene/main/canvas_item.h | 4 - scene/main/canvas_layer.cpp | 30 -- scene/main/canvas_layer.h | 1 - scene/main/http_request.cpp | 38 --- scene/main/http_request.h | 1 - scene/main/instance_placeholder.cpp | 8 - scene/main/instance_placeholder.h | 1 - scene/main/node.cpp | 227 --------------- scene/main/node.h | 6 - scene/main/resource_preloader.cpp | 16 -- scene/main/resource_preloader.h | 1 - scene/main/scene_tree.cpp | 102 ------- scene/main/scene_tree.h | 3 - scene/main/shader_globals_override.cpp | 11 - scene/main/shader_globals_override.h | 1 - scene/main/timer.cpp | 13 - scene/main/timer.h | 1 - scene/main/viewport.cpp | 239 ---------------- scene/main/viewport.h | 4 - scene/main/window.cpp | 48 ---- scene/register_scene_types.cpp | 2 - scene/resources/animation.cpp | 278 ------------------ scene/resources/animation.h | 16 -- scene/resources/audio_stream_sample.cpp | 39 --- scene/resources/audio_stream_sample.h | 2 - scene/resources/bit_map.cpp | 29 -- scene/resources/bit_map.h | 1 - scene/resources/box_shape_3d.cpp | 6 - scene/resources/box_shape_3d.h | 1 - scene/resources/capsule_shape_2d.cpp | 11 - scene/resources/capsule_shape_3d.cpp | 10 - scene/resources/capsule_shape_3d.h | 1 - scene/resources/circle_shape_2d.cpp | 8 - scene/resources/concave_polygon_shape_2d.cpp | 6 - scene/resources/concave_polygon_shape_3d.cpp | 8 - scene/resources/concave_polygon_shape_3d.h | 2 - scene/resources/convex_polygon_shape_2d.cpp | 8 - scene/resources/convex_polygon_shape_3d.cpp | 6 - scene/resources/convex_polygon_shape_3d.h | 1 - scene/resources/curve.cpp | 90 ------ scene/resources/curve.h | 7 - scene/resources/cylinder_shape_3d.cpp | 10 - scene/resources/cylinder_shape_3d.h | 1 - scene/resources/default_theme/default_theme.cpp | 11 - scene/resources/dynamic_font.cpp | 64 ----- scene/resources/dynamic_font.h | 5 - scene/resources/environment.cpp | 144 ---------- scene/resources/environment.h | 2 - scene/resources/font.cpp | 60 ---- scene/resources/font.h | 4 - scene/resources/gradient.cpp | 4 - scene/resources/gradient.h | 2 - scene/resources/height_map_shape_3d.cpp | 3 - scene/resources/line_shape_2d.cpp | 10 - scene/resources/material.cpp | 167 ----------- scene/resources/material.h | 5 - scene/resources/mesh.cpp | 89 ------ scene/resources/mesh.h | 1 - scene/resources/mesh_data_tool.cpp | 50 ---- scene/resources/mesh_data_tool.h | 3 - scene/resources/mesh_library.cpp | 29 -- scene/resources/mesh_library.h | 1 - scene/resources/multimesh.cpp | 34 --- scene/resources/multimesh.h | 1 - scene/resources/navigation_mesh.cpp | 20 -- scene/resources/navigation_mesh.h | 2 - scene/resources/packed_scene.cpp | 112 -------- scene/resources/packed_scene.h | 5 - scene/resources/particles_material.cpp | 59 ---- scene/resources/particles_material.h | 3 - scene/resources/physics_material.cpp | 1 - scene/resources/physics_material.h | 1 - scene/resources/polygon_path_finder.cpp | 42 --- scene/resources/polygon_path_finder.h | 4 - scene/resources/primitive_meshes.cpp | 9 - scene/resources/primitive_meshes.h | 8 - scene/resources/ray_shape_3d.cpp | 7 - scene/resources/ray_shape_3d.h | 1 - scene/resources/rectangle_shape_2d.cpp | 7 - scene/resources/resource_format_text.cpp | 98 ------- scene/resources/resource_format_text.h | 3 - scene/resources/segment_shape_2d.cpp | 18 -- scene/resources/shader.cpp | 22 -- scene/resources/shader.h | 1 - scene/resources/shape_2d.cpp | 8 - scene/resources/shape_3d.cpp | 5 - scene/resources/shape_3d.h | 1 - scene/resources/skin.cpp | 3 - scene/resources/sky.cpp | 4 - scene/resources/sky_material.cpp | 51 ---- scene/resources/sky_material.h | 1 - scene/resources/sphere_shape_3d.cpp | 7 - scene/resources/sphere_shape_3d.h | 1 - scene/resources/style_box.cpp | 59 ---- scene/resources/style_box.h | 5 - scene/resources/surface_tool.cpp | 68 ----- scene/resources/surface_tool.h | 2 - scene/resources/text_file.cpp | 1 - scene/resources/text_file.h | 1 - scene/resources/texture.cpp | 153 ---------- scene/resources/texture.h | 18 -- scene/resources/theme.cpp | 87 ------ scene/resources/theme.h | 1 - scene/resources/tile_set.cpp | 79 ------ scene/resources/tile_set.h | 2 - scene/resources/video_stream.h | 2 - scene/resources/visual_shader.cpp | 75 ----- scene/resources/visual_shader.h | 1 - scene/resources/visual_shader_nodes.cpp | 138 --------- scene/resources/world_2d.cpp | 46 --- scene/resources/world_2d.h | 1 - scene/resources/world_3d.cpp | 35 --- scene/resources/world_margin_shape_3d.cpp | 6 - scene/resources/world_margin_shape_3d.h | 1 - scene/scene_string_names.cpp | 2 - scene/scene_string_names.h | 1 - 370 files changed, 9270 deletions(-) (limited to 'scene') diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index fc34f967ce..842740aa5e 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -103,7 +103,6 @@ Rect2 AnimatedSprite2D::_get_rect() const { } void SpriteFrames::add_frame(const StringName &p_anim, const Ref &p_frame, int p_at_pos) { - Map::Element *E = animations.find(p_anim); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist."); @@ -123,7 +122,6 @@ int SpriteFrames::get_frame_count(const StringName &p_anim) const { } void SpriteFrames::remove_frame(const StringName &p_anim, int p_idx) { - Map::Element *E = animations.find(p_anim); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist."); @@ -131,7 +129,6 @@ void SpriteFrames::remove_frame(const StringName &p_anim, int p_idx) { emit_changed(); } void SpriteFrames::clear(const StringName &p_anim) { - Map::Element *E = animations.find(p_anim); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist."); @@ -140,13 +137,11 @@ void SpriteFrames::clear(const StringName &p_anim) { } void SpriteFrames::clear_all() { - animations.clear(); add_animation("default"); } void SpriteFrames::add_animation(const StringName &p_anim) { - ERR_FAIL_COND_MSG(animations.has(p_anim), "SpriteFrames already has animation '" + p_anim + "'."); animations[p_anim] = Anim(); @@ -155,16 +150,13 @@ void SpriteFrames::add_animation(const StringName &p_anim) { } bool SpriteFrames::has_animation(const StringName &p_anim) const { - return animations.has(p_anim); } void SpriteFrames::remove_animation(const StringName &p_anim) { - animations.erase(p_anim); } void SpriteFrames::rename_animation(const StringName &p_prev, const StringName &p_next) { - ERR_FAIL_COND_MSG(!animations.has(p_prev), "SpriteFrames doesn't have animation '" + String(p_prev) + "'."); ERR_FAIL_COND_MSG(animations.has(p_next), "Animation '" + String(p_next) + "' already exists."); @@ -176,12 +168,10 @@ void SpriteFrames::rename_animation(const StringName &p_prev, const StringName & } Vector SpriteFrames::_get_animation_list() const { - Vector ret; List al; get_animation_list(&al); for (List::Element *E = al.front(); E; E = E->next()) { - ret.push_back(E->get()); } @@ -189,14 +179,12 @@ Vector SpriteFrames::_get_animation_list() const { } void SpriteFrames::get_animation_list(List *r_animations) const { - for (const Map::Element *E = animations.front(); E; E = E->next()) { r_animations->push_back(E->key()); } } Vector SpriteFrames::get_animation_names() const { - Vector names; for (const Map::Element *E = animations.front(); E; E = E->next()) { names.push_back(E->key()); @@ -206,14 +194,12 @@ Vector SpriteFrames::get_animation_names() const { } void SpriteFrames::set_animation_speed(const StringName &p_anim, float p_fps) { - ERR_FAIL_COND_MSG(p_fps < 0, "Animation speed cannot be negative (" + itos(p_fps) + ")."); Map::Element *E = animations.find(p_anim); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist."); E->get().speed = p_fps; } float SpriteFrames::get_animation_speed(const StringName &p_anim) const { - const Map::Element *E = animations.find(p_anim); ERR_FAIL_COND_V_MSG(!E, 0, "Animation '" + String(p_anim) + "' doesn't exist."); return E->get().speed; @@ -231,7 +217,6 @@ bool SpriteFrames::get_animation_loop(const StringName &p_anim) const { } void SpriteFrames::_set_frames(const Array &p_frames) { - clear_all(); Map::Element *E = animations.find(SceneStringNames::get_singleton()->_default); ERR_FAIL_COND(!E); @@ -241,12 +226,10 @@ void SpriteFrames::_set_frames(const Array &p_frames) { E->get().frames.write[i] = p_frames[i]; } Array SpriteFrames::_get_frames() const { - return Array(); } Array SpriteFrames::_get_animations() const { - Array anims; for (Map::Element *E = animations.front(); E; E = E->next()) { Dictionary d; @@ -264,10 +247,8 @@ Array SpriteFrames::_get_animations() const { return anims; } void SpriteFrames::_set_animations(const Array &p_animations) { - animations.clear(); for (int i = 0; i < p_animations.size(); i++) { - Dictionary d = p_animations[i]; ERR_CONTINUE(!d.has("name")); @@ -280,7 +261,6 @@ void SpriteFrames::_set_animations(const Array &p_animations) { anim.loop = d["loop"]; Array frames = d["frames"]; for (int j = 0; j < frames.size(); j++) { - RES res = frames[j]; anim.frames.push_back(res); } @@ -290,7 +270,6 @@ void SpriteFrames::_set_animations(const Array &p_animations) { } void SpriteFrames::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_animation", "anim"), &SpriteFrames::add_animation); ClassDB::bind_method(D_METHOD("has_animation", "anim"), &SpriteFrames::has_animation); ClassDB::bind_method(D_METHOD("remove_animation", "anim"), &SpriteFrames::remove_animation); @@ -324,16 +303,13 @@ void SpriteFrames::_bind_methods() { } SpriteFrames::SpriteFrames() { - add_animation(SceneStringNames::get_singleton()->_default); } void AnimatedSprite2D::_validate_property(PropertyInfo &property) const { - if (!frames.is_valid()) return; if (property.name == "animation") { - property.hint = PROPERTY_HINT_ENUM; List names; frames->get_animation_list(&names); @@ -371,10 +347,8 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &property) const { } void AnimatedSprite2D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_INTERNAL_PROCESS: { - if (frames.is_null()) return; if (!frames->has_animation(animation)) @@ -389,9 +363,7 @@ void AnimatedSprite2D::_notification(int p_what) { float remaining = get_process_delta_time(); while (remaining) { - if (timeout <= 0) { - timeout = _get_frame_duration(); int fc = frames->get_frame_count(animation); @@ -433,7 +405,6 @@ void AnimatedSprite2D::_notification(int p_what) { } break; case NOTIFICATION_DRAW: { - if (frames.is_null()) return; if (frame < 0) @@ -473,7 +444,6 @@ void AnimatedSprite2D::_notification(int p_what) { } void AnimatedSprite2D::set_sprite_frames(const Ref &p_frames) { - if (frames.is_valid()) frames->disconnect("changed", callable_mp(this, &AnimatedSprite2D::_res_changed)); frames = p_frames; @@ -493,12 +463,10 @@ void AnimatedSprite2D::set_sprite_frames(const Ref &p_frames) { } Ref AnimatedSprite2D::get_sprite_frames() const { - return frames; } void AnimatedSprite2D::set_frame(int p_frame) { - if (!frames.is_valid()) { return; } @@ -522,12 +490,10 @@ void AnimatedSprite2D::set_frame(int p_frame) { emit_signal(SceneStringNames::get_singleton()->frame_changed); } int AnimatedSprite2D::get_frame() const { - return frame; } void AnimatedSprite2D::set_speed_scale(float p_speed_scale) { - float elapsed = _get_frame_duration() - timeout; speed_scale = MAX(p_speed_scale, 0.0f); @@ -538,56 +504,46 @@ void AnimatedSprite2D::set_speed_scale(float p_speed_scale) { } float AnimatedSprite2D::get_speed_scale() const { - return speed_scale; } void AnimatedSprite2D::set_centered(bool p_center) { - centered = p_center; update(); item_rect_changed(); } bool AnimatedSprite2D::is_centered() const { - return centered; } void AnimatedSprite2D::set_offset(const Point2 &p_offset) { - offset = p_offset; update(); item_rect_changed(); _change_notify("offset"); } Point2 AnimatedSprite2D::get_offset() const { - return offset; } void AnimatedSprite2D::set_flip_h(bool p_flip) { - hflip = p_flip; update(); } bool AnimatedSprite2D::is_flipped_h() const { - return hflip; } void AnimatedSprite2D::set_flip_v(bool p_flip) { - vflip = p_flip; update(); } bool AnimatedSprite2D::is_flipped_v() const { - return vflip; } void AnimatedSprite2D::_res_changed() { - set_frame(frame); _change_notify("frame"); _change_notify("animation"); @@ -595,7 +551,6 @@ void AnimatedSprite2D::_res_changed() { } void AnimatedSprite2D::_set_playing(bool p_playing) { - if (playing == p_playing) return; playing = p_playing; @@ -604,12 +559,10 @@ void AnimatedSprite2D::_set_playing(bool p_playing) { } bool AnimatedSprite2D::_is_playing() const { - return playing; } void AnimatedSprite2D::play(const StringName &p_animation, const bool p_backwards) { - backwards = p_backwards; if (p_animation) { @@ -622,12 +575,10 @@ void AnimatedSprite2D::play(const StringName &p_animation, const bool p_backward } void AnimatedSprite2D::stop() { - _set_playing(false); } bool AnimatedSprite2D::is_playing() const { - return playing; } @@ -642,7 +593,6 @@ float AnimatedSprite2D::_get_frame_duration() { } void AnimatedSprite2D::_reset_timeout() { - if (!playing) return; @@ -651,7 +601,6 @@ void AnimatedSprite2D::_reset_timeout() { } void AnimatedSprite2D::set_animation(const StringName &p_animation) { - ERR_FAIL_COND_MSG(frames == nullptr, vformat("There is no animation with name '%s'.", p_animation)); ERR_FAIL_COND_MSG(frames->get_animation_names().find(p_animation) == -1, vformat("There is no animation with name '%s'.", p_animation)); @@ -665,12 +614,10 @@ void AnimatedSprite2D::set_animation(const StringName &p_animation) { update(); } StringName AnimatedSprite2D::get_animation() const { - return animation; } String AnimatedSprite2D::get_configuration_warning() const { - if (frames.is_null()) { return TTR("A SpriteFrames resource must be created or set in the \"Frames\" property in order for AnimatedSprite to display frames."); } @@ -697,7 +644,6 @@ float AnimatedSprite2D::get_shininess() const { } void AnimatedSprite2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite2D::set_sprite_frames); ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite2D::get_sprite_frames); @@ -755,7 +701,6 @@ void AnimatedSprite2D::_bind_methods() { } AnimatedSprite2D::AnimatedSprite2D() { - centered = true; hflip = false; vflip = false; diff --git a/scene/2d/animated_sprite_2d.h b/scene/2d/animated_sprite_2d.h index 726ecefd32..fae334498d 100644 --- a/scene/2d/animated_sprite_2d.h +++ b/scene/2d/animated_sprite_2d.h @@ -35,11 +35,9 @@ #include "scene/resources/texture.h" class SpriteFrames : public Resource { - GDCLASS(SpriteFrames, Resource); struct Anim { - float speed; bool loop; Vector> frames; @@ -87,7 +85,6 @@ public: void add_frame(const StringName &p_anim, const Ref &p_frame, int p_at_pos = -1); int get_frame_count(const StringName &p_anim) const; _FORCE_INLINE_ Ref get_frame(const StringName &p_anim, int p_idx) const { - const Map::Element *E = animations.find(p_anim); ERR_FAIL_COND_V_MSG(!E, Ref(), "Animation '" + String(p_anim) + "' doesn't exist."); ERR_FAIL_COND_V(p_idx < 0, Ref()); @@ -98,7 +95,6 @@ public: } _FORCE_INLINE_ Ref get_normal_frame(const StringName &p_anim, int p_idx) const { - const Map::Element *E = animations.find(p_anim); ERR_FAIL_COND_V_MSG(!E, Ref(), "Animation '" + String(p_anim) + "' doesn't exist."); ERR_FAIL_COND_V(p_idx < 0, Ref()); @@ -112,7 +108,6 @@ public: } _FORCE_INLINE_ Ref get_specular_frame(const StringName &p_anim, int p_idx) const { - const Map::Element *E = animations.find(p_anim); ERR_FAIL_COND_V(!E, Ref()); ERR_FAIL_COND_V(p_idx < 0, Ref()); @@ -141,7 +136,6 @@ public: }; class AnimatedSprite2D : public Node2D { - GDCLASS(AnimatedSprite2D, Node2D); Ref frames; diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 8ba334bc67..90af1ff274 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -35,27 +35,22 @@ #include "servers/physics_server_2d.h" void Area2D::set_space_override_mode(SpaceOverride p_mode) { - space_override = p_mode; PhysicsServer2D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer2D::AreaSpaceOverrideMode(p_mode)); } Area2D::SpaceOverride Area2D::get_space_override_mode() const { - return space_override; } void Area2D::set_gravity_is_point(bool p_enabled) { - gravity_is_point = p_enabled; PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled); } bool Area2D::is_gravity_a_point() const { - return gravity_is_point; } void Area2D::set_gravity_distance_scale(real_t p_scale) { - gravity_distance_scale = p_scale; PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale); } @@ -65,58 +60,47 @@ real_t Area2D::get_gravity_distance_scale() const { } void Area2D::set_gravity_vector(const Vector2 &p_vec) { - gravity_vec = p_vec; PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, p_vec); } Vector2 Area2D::get_gravity_vector() const { - return gravity_vec; } void Area2D::set_gravity(real_t p_gravity) { - gravity = p_gravity; PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY, p_gravity); } real_t Area2D::get_gravity() const { - return gravity; } void Area2D::set_linear_damp(real_t p_linear_damp) { - linear_damp = p_linear_damp; PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, p_linear_damp); } real_t Area2D::get_linear_damp() const { - return linear_damp; } void Area2D::set_angular_damp(real_t p_angular_damp) { - angular_damp = p_angular_damp; PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp); } real_t Area2D::get_angular_damp() const { - return angular_damp; } void Area2D::set_priority(real_t p_priority) { - priority = p_priority; PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_PRIORITY, p_priority); } real_t Area2D::get_priority() const { - return priority; } void Area2D::_body_enter_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -128,13 +112,11 @@ void Area2D::_body_enter_tree(ObjectID p_id) { E->get().in_tree = true; emit_signal(SceneStringNames::get_singleton()->body_entered, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape); } } void Area2D::_body_exit_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -144,13 +126,11 @@ void Area2D::_body_exit_tree(ObjectID p_id) { E->get().in_tree = false; emit_signal(SceneStringNames::get_singleton()->body_exited, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape); } } void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) { - bool body_in = p_status == PhysicsServer2D::AREA_BODY_ADDED; ObjectID objid = p_instance; @@ -167,7 +147,6 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i if (body_in) { if (!E) { - E = body_map.insert(objid, BodyState()); E->get().rc = 0; E->get().in_tree = node && node->is_inside_tree(); @@ -188,7 +167,6 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i } } else { - E->get().rc--; if (node) @@ -197,7 +175,6 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i bool eraseit = false; if (E->get().rc == 0) { - if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area2D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area2D::_body_exit_tree)); @@ -219,7 +196,6 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i } void Area2D::_area_enter_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -231,13 +207,11 @@ void Area2D::_area_enter_tree(ObjectID p_id) { E->get().in_tree = true; emit_signal(SceneStringNames::get_singleton()->area_entered, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape); } } void Area2D::_area_exit_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -247,13 +221,11 @@ void Area2D::_area_exit_tree(ObjectID p_id) { E->get().in_tree = false; emit_signal(SceneStringNames::get_singleton()->area_exited, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape); } } void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) { - bool area_in = p_status == PhysicsServer2D::AREA_BODY_ADDED; ObjectID objid = p_instance; @@ -269,7 +241,6 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i if (area_in) { if (!E) { - E = area_map.insert(objid, AreaState()); E->get().rc = 0; E->get().in_tree = node && node->is_inside_tree(); @@ -290,7 +261,6 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i } } else { - E->get().rc--; if (node) @@ -299,7 +269,6 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i bool eraseit = false; if (E->get().rc == 0) { - if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area2D::_area_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area2D::_area_exit_tree)); @@ -321,7 +290,6 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i } void Area2D::_clear_monitoring() { - ERR_FAIL_COND_MSG(locked, "This function can't be used during the in/out signal."); { @@ -330,7 +298,6 @@ void Area2D::_clear_monitoring() { //disconnect all monitored stuff for (Map::Element *E = bmcopy.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->key()); Node *node = Object::cast_to(obj); @@ -344,7 +311,6 @@ void Area2D::_clear_monitoring() { continue; for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape); } @@ -353,13 +319,11 @@ void Area2D::_clear_monitoring() { } { - Map bmcopy = area_map; area_map.clear(); //disconnect all monitored stuff for (Map::Element *E = bmcopy.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->key()); Node *node = Object::cast_to(obj); @@ -373,7 +337,6 @@ void Area2D::_clear_monitoring() { continue; for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape); } @@ -383,18 +346,14 @@ void Area2D::_clear_monitoring() { } void Area2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_EXIT_TREE: { - _clear_monitoring(); } break; } } void Area2D::set_monitoring(bool p_enable) { - if (p_enable == monitoring) return; ERR_FAIL_COND_MSG(locked, "Function blocked during in/out signal. Use set_deferred(\"monitoring\", true/false)."); @@ -402,7 +361,6 @@ void Area2D::set_monitoring(bool p_enable) { monitoring = p_enable; if (monitoring) { - PhysicsServer2D::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout); PhysicsServer2D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout); @@ -414,12 +372,10 @@ void Area2D::set_monitoring(bool p_enable) { } bool Area2D::is_monitoring() const { - return monitoring; } void Area2D::set_monitorable(bool p_enable) { - ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer2D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false)."); if (p_enable == monitorable) @@ -431,12 +387,10 @@ void Area2D::set_monitorable(bool p_enable) { } bool Area2D::is_monitorable() const { - return monitorable; } TypedArray Area2D::get_overlapping_bodies() const { - ERR_FAIL_COND_V_MSG(!monitoring, Array(), "Can't find overlapping bodies when monitoring is off."); TypedArray ret; ret.resize(body_map.size()); @@ -454,7 +408,6 @@ TypedArray Area2D::get_overlapping_bodies() const { } TypedArray Area2D::get_overlapping_areas() const { - ERR_FAIL_COND_V_MSG(!monitoring, Array(), "Can't find overlapping bodies when monitoring is off."); TypedArray ret; ret.resize(area_map.size()); @@ -472,7 +425,6 @@ TypedArray Area2D::get_overlapping_areas() const { } bool Area2D::overlaps_area(Node *p_area) const { - ERR_FAIL_NULL_V(p_area, false); const Map::Element *E = area_map.find(p_area->get_instance_id()); if (!E) @@ -481,7 +433,6 @@ bool Area2D::overlaps_area(Node *p_area) const { } bool Area2D::overlaps_body(Node *p_body) const { - ERR_FAIL_NULL_V(p_body, false); const Map::Element *E = body_map.find(p_body->get_instance_id()); if (!E) @@ -490,29 +441,24 @@ bool Area2D::overlaps_body(Node *p_body) const { } void Area2D::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; PhysicsServer2D::get_singleton()->area_set_collision_mask(get_rid(), p_mask); } uint32_t Area2D::get_collision_mask() const { - return collision_mask; } void Area2D::set_collision_layer(uint32_t p_layer) { - collision_layer = p_layer; PhysicsServer2D::get_singleton()->area_set_collision_layer(get_rid(), p_layer); } uint32_t Area2D::get_collision_layer() const { - return collision_layer; } void Area2D::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -522,12 +468,10 @@ void Area2D::set_collision_mask_bit(int p_bit, bool p_value) { } bool Area2D::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } void Area2D::set_collision_layer_bit(int p_bit, bool p_value) { - uint32_t layer = get_collision_layer(); if (p_value) layer |= 1 << p_bit; @@ -537,27 +481,22 @@ void Area2D::set_collision_layer_bit(int p_bit, bool p_value) { } bool Area2D::get_collision_layer_bit(int p_bit) const { - return get_collision_layer() & (1 << p_bit); } void Area2D::set_audio_bus_override(bool p_override) { - audio_bus_override = p_override; } bool Area2D::is_overriding_audio_bus() const { - return audio_bus_override; } void Area2D::set_audio_bus_name(const StringName &p_audio_bus) { - audio_bus = p_audio_bus; } StringName Area2D::get_audio_bus_name() const { - for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (AudioServer::get_singleton()->get_bus_name(i) == audio_bus) { return audio_bus; @@ -567,9 +506,7 @@ StringName Area2D::get_audio_bus_name() const { } void Area2D::_validate_property(PropertyInfo &property) const { - if (property.name == "audio_bus_name") { - String options; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (i > 0) @@ -677,7 +614,6 @@ void Area2D::_bind_methods() { Area2D::Area2D() : CollisionObject2D(PhysicsServer2D::get_singleton()->area_create(), true) { - space_override = SPACE_OVERRIDE_DISABLED; set_gravity(98); set_gravity_vector(Vector2(0, 1)); diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index 0e2c0ac672..3b9b57cab4 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -35,7 +35,6 @@ #include "scene/2d/collision_object_2d.h" class Area2D : public CollisionObject2D { - GDCLASS(Area2D, CollisionObject2D); public: @@ -68,7 +67,6 @@ private: void _body_exit_tree(ObjectID p_id); struct ShapePair { - int body_shape; int area_shape; bool operator<(const ShapePair &p_sp) const { @@ -86,7 +84,6 @@ private: }; struct BodyState { - int rc; bool in_tree; VSet shapes; @@ -100,7 +97,6 @@ private: void _area_exit_tree(ObjectID p_id); struct AreaShapePair { - int area_shape; int self_shape; bool operator<(const AreaShapePair &p_sp) const { @@ -118,7 +114,6 @@ private: }; struct AreaState { - int rc; bool in_tree; VSet shapes; diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 55d111439a..b1ca2912e9 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -35,7 +35,6 @@ #include "scene/main/window.h" void AudioStreamPlayer2D::_mix_audio() { - if (!stream_playback.is_valid() || !active || (stream_paused && !stream_paused_fade_out)) { return; @@ -59,7 +58,6 @@ void AudioStreamPlayer2D::_mix_audio() { //write all outputs for (int i = 0; i < output_count; i++) { - Output current = outputs[i]; //see if current output exists, to keep volume ramp @@ -98,7 +96,6 @@ void AudioStreamPlayer2D::_mix_audio() { AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, 0); for (int j = 0; j < buffer_size; j++) { - target[j] += buffer[j] * vol; vol += vol_inc; } @@ -120,7 +117,6 @@ void AudioStreamPlayer2D::_mix_audio() { continue; for (int j = 0; j < buffer_size; j++) { - AudioFrame frame = buffer[j] * vol; for (int k = 0; k < cc; k++) { targets[k][j] += frame; @@ -145,9 +141,7 @@ void AudioStreamPlayer2D::_mix_audio() { } void AudioStreamPlayer2D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - AudioServer::get_singleton()->add_callback(_mix_audios, this); if (autoplay && !Engine::get_singleton()->is_editor_hint()) { play(); @@ -155,7 +149,6 @@ void AudioStreamPlayer2D::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE) { - AudioServer::get_singleton()->remove_callback(_mix_audios, this); } @@ -171,7 +164,6 @@ void AudioStreamPlayer2D::_notification(int p_what) { } if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) { - //update anything related to position first, if possible of course if (!output_ready) { @@ -194,7 +186,6 @@ void AudioStreamPlayer2D::_notification(int p_what) { int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set(), area_mask, false, true); for (int i = 0; i < areas; i++) { - Area2D *area2d = Object::cast_to(sr[i].collider); if (!area2d) continue; @@ -209,10 +200,8 @@ void AudioStreamPlayer2D::_notification(int p_what) { world_2d->get_viewport_list(&viewports); for (List::Element *E = viewports.front(); E; E = E->next()) { - Viewport *vp = E->get(); if (vp->is_audio_listener_2d()) { - //compute matrix to convert to screen Transform2D to_screen = vp->get_global_canvas_transform() * vp->get_canvas_transform(); Vector2 screen_size = vp->get_visible_rect().size; @@ -269,7 +258,6 @@ void AudioStreamPlayer2D::_notification(int p_what) { } void AudioStreamPlayer2D::set_stream(Ref p_stream) { - AudioServer::get_singleton()->lock(); mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size()); @@ -294,16 +282,13 @@ void AudioStreamPlayer2D::set_stream(Ref p_stream) { } Ref AudioStreamPlayer2D::get_stream() const { - return stream; } void AudioStreamPlayer2D::set_volume_db(float p_volume) { - volume_db = p_volume; } float AudioStreamPlayer2D::get_volume_db() const { - return volume_db; } @@ -316,7 +301,6 @@ float AudioStreamPlayer2D::get_pitch_scale() const { } void AudioStreamPlayer2D::play(float p_from_pos) { - if (!is_playing()) { // Reset the prev_output_count if the stream is stopped prev_output_count = 0; @@ -331,14 +315,12 @@ void AudioStreamPlayer2D::play(float p_from_pos) { } void AudioStreamPlayer2D::seek(float p_seconds) { - if (stream_playback.is_valid()) { setseek = p_seconds; } } void AudioStreamPlayer2D::stop() { - if (stream_playback.is_valid()) { active = false; set_physics_process_internal(false); @@ -347,7 +329,6 @@ void AudioStreamPlayer2D::stop() { } bool AudioStreamPlayer2D::is_playing() const { - if (stream_playback.is_valid()) { return active; // && stream_playback->is_playing(); } @@ -356,7 +337,6 @@ bool AudioStreamPlayer2D::is_playing() const { } float AudioStreamPlayer2D::get_playback_position() { - if (stream_playback.is_valid()) { return stream_playback->get_playback_position(); } @@ -365,14 +345,12 @@ float AudioStreamPlayer2D::get_playback_position() { } void AudioStreamPlayer2D::set_bus(const StringName &p_bus) { - //if audio is active, must lock this AudioServer::get_singleton()->lock(); bus = p_bus; AudioServer::get_singleton()->unlock(); } StringName AudioStreamPlayer2D::get_bus() const { - for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (AudioServer::get_singleton()->get_bus_name(i) == bus) { return bus; @@ -382,30 +360,24 @@ StringName AudioStreamPlayer2D::get_bus() const { } void AudioStreamPlayer2D::set_autoplay(bool p_enable) { - autoplay = p_enable; } bool AudioStreamPlayer2D::is_autoplay_enabled() { - return autoplay; } void AudioStreamPlayer2D::_set_playing(bool p_enable) { - if (p_enable) play(); else stop(); } bool AudioStreamPlayer2D::_is_active() const { - return active; } void AudioStreamPlayer2D::_validate_property(PropertyInfo &property) const { - if (property.name == "bus") { - String options; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (i > 0) @@ -419,42 +391,34 @@ void AudioStreamPlayer2D::_validate_property(PropertyInfo &property) const { } void AudioStreamPlayer2D::_bus_layout_changed() { - _change_notify(); } void AudioStreamPlayer2D::set_max_distance(float p_pixels) { - ERR_FAIL_COND(p_pixels <= 0.0); max_distance = p_pixels; } float AudioStreamPlayer2D::get_max_distance() const { - return max_distance; } void AudioStreamPlayer2D::set_attenuation(float p_curve) { - attenuation = p_curve; } float AudioStreamPlayer2D::get_attenuation() const { - return attenuation; } void AudioStreamPlayer2D::set_area_mask(uint32_t p_mask) { - area_mask = p_mask; } uint32_t AudioStreamPlayer2D::get_area_mask() const { - return area_mask; } void AudioStreamPlayer2D::set_stream_paused(bool p_pause) { - if (p_pause != stream_paused) { stream_paused = p_pause; stream_paused_fade_in = !p_pause; @@ -463,7 +427,6 @@ void AudioStreamPlayer2D::set_stream_paused(bool p_pause) { } bool AudioStreamPlayer2D::get_stream_paused() const { - return stream_paused; } @@ -472,7 +435,6 @@ Ref AudioStreamPlayer2D::get_stream_playback() { } void AudioStreamPlayer2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_stream", "stream"), &AudioStreamPlayer2D::set_stream); ClassDB::bind_method(D_METHOD("get_stream"), &AudioStreamPlayer2D::get_stream); @@ -527,7 +489,6 @@ void AudioStreamPlayer2D::_bind_methods() { } AudioStreamPlayer2D::AudioStreamPlayer2D() { - volume_db = 0; pitch_scale = 1.0; autoplay = false; diff --git a/scene/2d/audio_stream_player_2d.h b/scene/2d/audio_stream_player_2d.h index 86e931b3c6..7f0b6f5897 100644 --- a/scene/2d/audio_stream_player_2d.h +++ b/scene/2d/audio_stream_player_2d.h @@ -36,7 +36,6 @@ #include "servers/audio_server.h" class AudioStreamPlayer2D : public Node2D { - GDCLASS(AudioStreamPlayer2D, Node2D); private: @@ -47,7 +46,6 @@ private: }; struct Output { - AudioFrame vol; int bus_index; Viewport *viewport; //pointer only used for reference to previous mix diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp index 4c952b7ca6..0bcb42e563 100644 --- a/scene/2d/back_buffer_copy.cpp +++ b/scene/2d/back_buffer_copy.cpp @@ -31,19 +31,14 @@ #include "back_buffer_copy.h" void BackBufferCopy::_update_copy_mode() { - switch (copy_mode) { - case COPY_MODE_DISABLED: { - RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), false, Rect2()); } break; case COPY_MODE_RECT: { - RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, rect); } break; case COPY_MODE_VIEWPORT: { - RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, Rect2()); } break; @@ -52,7 +47,6 @@ void BackBufferCopy::_update_copy_mode() { #ifdef TOOLS_ENABLED Rect2 BackBufferCopy::_edit_get_rect() const { - return rect; } @@ -62,12 +56,10 @@ bool BackBufferCopy::_edit_use_rect() const { #endif Rect2 BackBufferCopy::get_anchorable_rect() const { - return rect; } void BackBufferCopy::set_rect(const Rect2 &p_rect) { - rect = p_rect; _update_copy_mode(); } @@ -77,17 +69,14 @@ Rect2 BackBufferCopy::get_rect() const { } void BackBufferCopy::set_copy_mode(CopyMode p_mode) { - copy_mode = p_mode; _update_copy_mode(); } BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const { - return copy_mode; } void BackBufferCopy::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_rect", "rect"), &BackBufferCopy::set_rect); ClassDB::bind_method(D_METHOD("get_rect"), &BackBufferCopy::get_rect); @@ -103,7 +92,6 @@ void BackBufferCopy::_bind_methods() { } BackBufferCopy::BackBufferCopy() { - rect = Rect2(-100, -100, 200, 200); copy_mode = COPY_MODE_RECT; _update_copy_mode(); diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index d8af14a3fb..eeb87a7396 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -36,7 +36,6 @@ #include "servers/rendering_server.h" void Camera2D::_update_scroll() { - if (!is_inside_tree()) return; @@ -49,7 +48,6 @@ void Camera2D::_update_scroll() { return; if (current) { - ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id)); Transform2D xform = get_camera_transform(); @@ -64,7 +62,6 @@ void Camera2D::_update_scroll() { } void Camera2D::_update_process_mode() { - if (Engine::get_singleton()->is_editor_hint()) { set_process_internal(false); set_physics_process_internal(false); @@ -78,7 +75,6 @@ void Camera2D::_update_process_mode() { } void Camera2D::set_zoom(const Vector2 &p_zoom) { - zoom = p_zoom; Point2 old_smoothed_camera_pos = smoothed_camera_pos; _update_scroll(); @@ -86,12 +82,10 @@ void Camera2D::set_zoom(const Vector2 &p_zoom) { }; Vector2 Camera2D::get_zoom() const { - return zoom; }; Transform2D Camera2D::get_camera_transform() { - if (!get_tree()) return Transform2D(); @@ -103,14 +97,11 @@ Transform2D Camera2D::get_camera_transform() { Point2 ret_camera_pos; if (!first) { - if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) { - if (h_drag_enabled && !Engine::get_singleton()->is_editor_hint() && !h_offset_changed) { camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * zoom.x * drag_margin[MARGIN_LEFT])); camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * zoom.x * drag_margin[MARGIN_RIGHT])); } else { - if (h_ofs < 0) { camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT] * h_ofs; } else { @@ -121,12 +112,10 @@ Transform2D Camera2D::get_camera_transform() { } if (v_drag_enabled && !Engine::get_singleton()->is_editor_hint() && !v_offset_changed) { - camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * zoom.y * drag_margin[MARGIN_TOP])); camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * zoom.y * drag_margin[MARGIN_BOTTOM])); } else { - if (v_ofs < 0) { camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs; } else { @@ -137,7 +126,6 @@ Transform2D Camera2D::get_camera_transform() { } } else if (anchor_mode == ANCHOR_MODE_FIXED_TOP_LEFT) { - camera_pos = new_camera_pos; } @@ -159,13 +147,11 @@ Transform2D Camera2D::get_camera_transform() { } if (smoothing_enabled && !Engine::get_singleton()->is_editor_hint()) { - float c = smoothing * (process_mode == CAMERA2D_PROCESS_PHYSICS ? get_physics_process_delta_time() : get_process_delta_time()); smoothed_camera_pos = ((camera_pos - smoothed_camera_pos) * c) + smoothed_camera_pos; ret_camera_pos = smoothed_camera_pos; //camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing; } else { - ret_camera_pos = smoothed_camera_pos = camera_pos; } @@ -218,23 +204,18 @@ Transform2D Camera2D::get_camera_transform() { } void Camera2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_INTERNAL_PROCESS: case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - _update_scroll(); } break; case NOTIFICATION_TRANSFORM_CHANGED: { - if (!is_processing_internal() && !is_physics_processing_internal()) _update_scroll(); } break; case NOTIFICATION_ENTER_TREE: { - if (custom_viewport && ObjectDB::get_instance(custom_viewport_id)) { viewport = custom_viewport; } else { @@ -256,7 +237,6 @@ void Camera2D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - if (is_current()) { if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) { viewport->set_canvas_transform(Transform2D()); @@ -268,7 +248,6 @@ void Camera2D::_notification(int p_what) { } break; case NOTIFICATION_DRAW: { - if (!is_inside_tree() || !Engine::get_singleton()->is_editor_hint()) break; @@ -349,40 +328,33 @@ void Camera2D::_notification(int p_what) { } void Camera2D::set_offset(const Vector2 &p_offset) { - offset = p_offset; _update_scroll(); } Vector2 Camera2D::get_offset() const { - return offset; } void Camera2D::set_anchor_mode(AnchorMode p_anchor_mode) { - anchor_mode = p_anchor_mode; _update_scroll(); } Camera2D::AnchorMode Camera2D::get_anchor_mode() const { - return anchor_mode; } void Camera2D::set_rotating(bool p_rotating) { - rotating = p_rotating; _update_scroll(); } bool Camera2D::is_rotating() const { - return rotating; } void Camera2D::set_process_mode(Camera2DProcessMode p_mode) { - if (process_mode == p_mode) return; @@ -391,14 +363,11 @@ void Camera2D::set_process_mode(Camera2DProcessMode p_mode) { } Camera2D::Camera2DProcessMode Camera2D::get_process_mode() const { - return process_mode; } void Camera2D::_make_current(Object *p_which) { - if (p_which == this) { - current = true; } else { current = false; @@ -406,7 +375,6 @@ void Camera2D::_make_current(Object *p_which) { } void Camera2D::_set_current(bool p_current) { - if (p_current) make_current(); @@ -415,12 +383,10 @@ void Camera2D::_set_current(bool p_current) { } bool Camera2D::is_current() const { - return current; } void Camera2D::make_current() { - if (!is_inside_tree()) { current = true; } else { @@ -430,7 +396,6 @@ void Camera2D::make_current() { } void Camera2D::clear_current() { - current = false; if (is_inside_tree()) { get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", (Object *)nullptr); @@ -438,60 +403,50 @@ void Camera2D::clear_current() { } void Camera2D::set_limit(Margin p_margin, int p_limit) { - ERR_FAIL_INDEX((int)p_margin, 4); limit[p_margin] = p_limit; update(); } int Camera2D::get_limit(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); return limit[p_margin]; } void Camera2D::set_limit_smoothing_enabled(bool enable) { - limit_smoothing_enabled = enable; _update_scroll(); } bool Camera2D::is_limit_smoothing_enabled() const { - return limit_smoothing_enabled; } void Camera2D::set_drag_margin(Margin p_margin, float p_drag_margin) { - ERR_FAIL_INDEX((int)p_margin, 4); drag_margin[p_margin] = p_drag_margin; update(); } float Camera2D::get_drag_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); return drag_margin[p_margin]; } Vector2 Camera2D::get_camera_position() const { - return camera_pos; } void Camera2D::force_update_scroll() { - _update_scroll(); } void Camera2D::reset_smoothing() { - smoothed_camera_pos = camera_pos; _update_scroll(); } void Camera2D::align() { - ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id)); Size2 screen_size = viewport->get_visible_rect().size; @@ -509,7 +464,6 @@ void Camera2D::align() { camera_pos.y = current_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs; } } else if (anchor_mode == ANCHOR_MODE_FIXED_TOP_LEFT) { - camera_pos = current_camera_pos; } @@ -517,7 +471,6 @@ void Camera2D::align() { } void Camera2D::set_follow_smoothing(float p_speed) { - smoothing = p_speed; if (smoothing > 0 && !(is_inside_tree() && Engine::get_singleton()->is_editor_hint())) set_process_internal(true); @@ -526,55 +479,45 @@ void Camera2D::set_follow_smoothing(float p_speed) { } float Camera2D::get_follow_smoothing() const { - return smoothing; } Point2 Camera2D::get_camera_screen_center() const { - return camera_screen_center; } void Camera2D::set_h_drag_enabled(bool p_enabled) { - h_drag_enabled = p_enabled; } bool Camera2D::is_h_drag_enabled() const { - return h_drag_enabled; } void Camera2D::set_v_drag_enabled(bool p_enabled) { - v_drag_enabled = p_enabled; } bool Camera2D::is_v_drag_enabled() const { - return v_drag_enabled; } void Camera2D::set_v_offset(float p_offset) { - v_ofs = p_offset; v_offset_changed = true; _update_scroll(); } float Camera2D::get_v_offset() const { - return v_ofs; } void Camera2D::set_h_offset(float p_offset) { - h_ofs = p_offset; h_offset_changed = true; _update_scroll(); } float Camera2D::get_h_offset() const { - return h_ofs; } @@ -587,12 +530,10 @@ void Camera2D::_set_old_smoothing(float p_enable) { } void Camera2D::set_enable_follow_smoothing(bool p_enabled) { - smoothing_enabled = p_enabled; } bool Camera2D::is_follow_smoothing_enabled() const { - return smoothing_enabled; } @@ -612,7 +553,6 @@ void Camera2D::set_custom_viewport(Node *p_viewport) { } if (is_inside_tree()) { - if (custom_viewport) viewport = custom_viewport; else @@ -627,7 +567,6 @@ void Camera2D::set_custom_viewport(Node *p_viewport) { } Node *Camera2D::get_custom_viewport() const { - return custom_viewport; } @@ -659,7 +598,6 @@ bool Camera2D::is_margin_drawing_enabled() const { } void Camera2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_offset", "offset"), &Camera2D::set_offset); ClassDB::bind_method(D_METHOD("get_offset"), &Camera2D::get_offset); @@ -777,7 +715,6 @@ void Camera2D::_bind_methods() { } Camera2D::Camera2D() { - anchor_mode = ANCHOR_MODE_DRAG_CENTER; rotating = false; current = false; diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 7a106ef79a..0a4e269c40 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -35,7 +35,6 @@ #include "scene/main/window.h" class Camera2D : public Node2D { - GDCLASS(Camera2D, Node2D); public: diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp index 05f8804e2a..2ed2eaef42 100644 --- a/scene/2d/canvas_modulate.cpp +++ b/scene/2d/canvas_modulate.cpp @@ -31,22 +31,18 @@ #include "canvas_modulate.h" void CanvasModulate::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_CANVAS) { - if (is_visible_in_tree()) { RS::get_singleton()->canvas_set_modulate(get_canvas(), color); add_to_group("_canvas_modulate_" + itos(get_canvas().get_id())); } } else if (p_what == NOTIFICATION_EXIT_CANVAS) { - if (is_visible_in_tree()) { RS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1)); remove_from_group("_canvas_modulate_" + itos(get_canvas().get_id())); } } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (is_visible_in_tree()) { RS::get_singleton()->canvas_set_modulate(get_canvas(), color); add_to_group("_canvas_modulate_" + itos(get_canvas().get_id())); @@ -60,7 +56,6 @@ void CanvasModulate::_notification(int p_what) { } void CanvasModulate::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_color", "color"), &CanvasModulate::set_color); ClassDB::bind_method(D_METHOD("get_color"), &CanvasModulate::get_color); @@ -68,19 +63,16 @@ void CanvasModulate::_bind_methods() { } void CanvasModulate::set_color(const Color &p_color) { - color = p_color; if (is_visible_in_tree()) { RS::get_singleton()->canvas_set_modulate(get_canvas(), color); } } Color CanvasModulate::get_color() const { - return color; } String CanvasModulate::get_configuration_warning() const { - if (!is_visible_in_tree() || !is_inside_tree()) return String(); diff --git a/scene/2d/canvas_modulate.h b/scene/2d/canvas_modulate.h index ada6e27760..a0b61f43ba 100644 --- a/scene/2d/canvas_modulate.h +++ b/scene/2d/canvas_modulate.h @@ -34,7 +34,6 @@ #include "scene/2d/node_2d.h" class CanvasModulate : public Node2D { - GDCLASS(CanvasModulate, Node2D); Color color; diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index d82f4a2f2b..2f20a48139 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -34,11 +34,8 @@ #include "servers/physics_server_2d.h" void CollisionObject2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - Transform2D global_transform = get_global_transform(); if (area) @@ -58,7 +55,6 @@ void CollisionObject2D::_notification(int p_what) { } break; case NOTIFICATION_ENTER_CANVAS: { - if (area) PhysicsServer2D::get_singleton()->area_attach_canvas_instance_id(rid, get_canvas_layer_instance_id()); else @@ -66,11 +62,9 @@ void CollisionObject2D::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { - _update_pickable(); } break; case NOTIFICATION_TRANSFORM_CHANGED: { - if (only_update_transform_changes) { return; } @@ -84,7 +78,6 @@ void CollisionObject2D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - if (area) { PhysicsServer2D::get_singleton()->area_set_space(rid, RID()); } else @@ -93,7 +86,6 @@ void CollisionObject2D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_CANVAS: { - if (area) PhysicsServer2D::get_singleton()->area_attach_canvas_instance_id(rid, ObjectID()); else @@ -103,7 +95,6 @@ void CollisionObject2D::_notification(int p_what) { } uint32_t CollisionObject2D::create_shape_owner(Object *p_owner) { - ShapeData sd; uint32_t id; @@ -121,7 +112,6 @@ uint32_t CollisionObject2D::create_shape_owner(Object *p_owner) { } void CollisionObject2D::remove_shape_owner(uint32_t owner) { - ERR_FAIL_COND(!shapes.has(owner)); shape_owner_clear_shapes(owner); @@ -144,14 +134,12 @@ void CollisionObject2D::shape_owner_set_disabled(uint32_t p_owner, bool p_disabl } bool CollisionObject2D::is_shape_owner_disabled(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), false); return shapes[p_owner].disabled; } void CollisionObject2D::shape_owner_set_one_way_collision(uint32_t p_owner, bool p_enable) { - if (area) return; //not for areas @@ -165,14 +153,12 @@ void CollisionObject2D::shape_owner_set_one_way_collision(uint32_t p_owner, bool } bool CollisionObject2D::is_shape_owner_one_way_collision_enabled(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), false); return shapes[p_owner].one_way_collision; } void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owner, float p_margin) { - if (area) return; //not for areas @@ -186,21 +172,18 @@ void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owne } float CollisionObject2D::get_shape_owner_one_way_collision_margin(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), 0); return shapes[p_owner].one_way_collision_margin; } void CollisionObject2D::get_shape_owners(List *r_owners) { - for (Map::Element *E = shapes.front(); E; E = E->next()) { r_owners->push_back(E->key()); } } Array CollisionObject2D::_get_shape_owners() { - Array ret; for (Map::Element *E = shapes.front(); E; E = E->next()) { ret.push_back(E->key()); @@ -210,7 +193,6 @@ Array CollisionObject2D::_get_shape_owners() { } void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transform2D &p_transform) { - ERR_FAIL_COND(!shapes.has(p_owner)); ShapeData &sd = shapes[p_owner]; @@ -225,21 +207,18 @@ void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transf } } Transform2D CollisionObject2D::shape_owner_get_transform(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), Transform2D()); return shapes[p_owner].xform; } Object *CollisionObject2D::shape_owner_get_owner(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr); return shapes[p_owner].owner; } void CollisionObject2D::shape_owner_add_shape(uint32_t p_owner, const Ref &p_shape) { - ERR_FAIL_COND(!shapes.has(p_owner)); ERR_FAIL_COND(p_shape.is_null()); @@ -257,20 +236,17 @@ void CollisionObject2D::shape_owner_add_shape(uint32_t p_owner, const Ref CollisionObject2D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), Ref()); ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref()); return shapes[p_owner].shapes[p_shape].shape; } int CollisionObject2D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), -1); ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), -1); @@ -278,7 +254,6 @@ int CollisionObject2D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape } void CollisionObject2D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) { - ERR_FAIL_COND(!shapes.has(p_owner)); ERR_FAIL_INDEX(p_shape, shapes[p_owner].shapes.size()); @@ -303,7 +278,6 @@ void CollisionObject2D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) } void CollisionObject2D::shape_owner_clear_shapes(uint32_t p_owner) { - ERR_FAIL_COND(!shapes.has(p_owner)); while (shape_owner_get_shape_count(p_owner) > 0) { @@ -312,7 +286,6 @@ void CollisionObject2D::shape_owner_clear_shapes(uint32_t p_owner) { } uint32_t CollisionObject2D::shape_find_owner(int p_shape_index) const { - ERR_FAIL_INDEX_V(p_shape_index, total_subshapes, 0); for (const Map::Element *E = shapes.front(); E; E = E->next()) { @@ -328,7 +301,6 @@ uint32_t CollisionObject2D::shape_find_owner(int p_shape_index) const { } void CollisionObject2D::set_pickable(bool p_enabled) { - if (pickable == p_enabled) return; @@ -337,12 +309,10 @@ void CollisionObject2D::set_pickable(bool p_enabled) { } bool CollisionObject2D::is_pickable() const { - return pickable; } void CollisionObject2D::_input_event(Node *p_viewport, const Ref &p_input_event, int p_shape) { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_input_event, p_viewport, p_input_event, p_shape); } @@ -350,7 +320,6 @@ void CollisionObject2D::_input_event(Node *p_viewport, const Ref &p_ } void CollisionObject2D::_mouse_enter() { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter); } @@ -358,7 +327,6 @@ void CollisionObject2D::_mouse_enter() { } void CollisionObject2D::_mouse_exit() { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit); } @@ -381,7 +349,6 @@ void CollisionObject2D::_update_pickable() { } String CollisionObject2D::get_configuration_warning() const { - String warning = Node2D::get_configuration_warning(); if (shapes.empty()) { @@ -395,7 +362,6 @@ String CollisionObject2D::get_configuration_warning() const { } void CollisionObject2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_rid"), &CollisionObject2D::get_rid); ClassDB::bind_method(D_METHOD("set_pickable", "enabled"), &CollisionObject2D::set_pickable); @@ -432,7 +398,6 @@ void CollisionObject2D::_bind_methods() { } CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) { - rid = p_rid; area = p_area; pickable = true; @@ -441,7 +406,6 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) { only_update_transform_changes = false; if (p_area) { - PhysicsServer2D::get_singleton()->area_attach_object_instance_id(rid, get_instance_id()); } else { PhysicsServer2D::get_singleton()->body_attach_object_instance_id(rid, get_instance_id()); @@ -449,13 +413,11 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) { } CollisionObject2D::CollisionObject2D() { - //owner= set_notify_transform(true); } CollisionObject2D::~CollisionObject2D() { - PhysicsServer2D::get_singleton()->free(rid); } diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index e931f20f40..d7af2f3a2a 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -35,7 +35,6 @@ #include "scene/resources/shape_2d.h" class CollisionObject2D : public Node2D { - GDCLASS(CollisionObject2D, Node2D); bool area; @@ -43,7 +42,6 @@ class CollisionObject2D : public Node2D { bool pickable; struct ShapeData { - Object *owner; Transform2D xform; struct Shape { diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 1e48b2d67f..e5acfafa21 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -38,7 +38,6 @@ #include "thirdparty/misc/triangulator.h" void CollisionPolygon2D::_build_polygon() { - parent->shape_owner_clear_shapes(owner_id); if (polygon.size() == 0) @@ -47,7 +46,6 @@ void CollisionPolygon2D::_build_polygon() { bool solids = build_mode == BUILD_SOLIDS; if (solids) { - //here comes the sun, lalalala //decompose concave into multiple convex polygons and add them Vector> decomp = _decompose_in_convex(); @@ -58,7 +56,6 @@ void CollisionPolygon2D::_build_polygon() { } } else { - Ref concave = memnew(ConcavePolygonShape2D); Vector segments; @@ -82,7 +79,6 @@ Vector> CollisionPolygon2D::_decompose_in_convex() { } void CollisionPolygon2D::_update_in_shape_owner(bool p_xform_only) { - parent->shape_owner_set_transform(owner_id, get_transform()); if (p_xform_only) return; @@ -92,10 +88,8 @@ void CollisionPolygon2D::_update_in_shape_owner(bool p_xform_only) { } void CollisionPolygon2D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_PARENTED: { - parent = Object::cast_to(get_parent()); if (parent) { owner_id = parent->create_shape_owner(this); @@ -111,14 +105,12 @@ void CollisionPolygon2D::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { - if (parent) { _update_in_shape_owner(); } } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (parent) { _update_in_shape_owner(true); } @@ -133,13 +125,11 @@ void CollisionPolygon2D::_notification(int p_what) { } break; case NOTIFICATION_DRAW: { - if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) { break; } for (int i = 0; i < polygon.size(); i++) { - Vector2 p = polygon[i]; Vector2 n = polygon[(i + 1) % polygon.size()]; // draw line with width <= 1, so it does not scale with zoom and break pixel exact editing @@ -152,7 +142,6 @@ void CollisionPolygon2D::_notification(int p_what) { Color c(0.4, 0.9, 0.1); for (int i = 0; i < decomp.size(); i++) { - c.set_hsv(Math::fmod(c.get_h() + 0.738, 1), c.get_s(), c.get_v(), 0.5); draw_colored_polygon(decomp[i], c); } @@ -181,7 +170,6 @@ void CollisionPolygon2D::_notification(int p_what) { } void CollisionPolygon2D::set_polygon(const Vector &p_polygon) { - polygon = p_polygon; { @@ -192,7 +180,6 @@ void CollisionPolygon2D::set_polygon(const Vector &p_polygon) { aabb.expand_to(polygon[i]); } if (aabb == Rect2()) { - aabb = Rect2(-10, -10, 20, 20); } else { aabb.position -= aabb.size * 0.3; @@ -208,12 +195,10 @@ void CollisionPolygon2D::set_polygon(const Vector &p_polygon) { } Vector CollisionPolygon2D::get_polygon() const { - return polygon; } void CollisionPolygon2D::set_build_mode(BuildMode p_mode) { - ERR_FAIL_INDEX((int)p_mode, 2); build_mode = p_mode; if (parent) { @@ -222,13 +207,11 @@ void CollisionPolygon2D::set_build_mode(BuildMode p_mode) { } CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const { - return build_mode; } #ifdef TOOLS_ENABLED Rect2 CollisionPolygon2D::_edit_get_rect() const { - return aabb; } @@ -237,13 +220,11 @@ bool CollisionPolygon2D::_edit_use_rect() const { } bool CollisionPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - return Geometry::is_point_in_polygon(p_point, Variant(polygon)); } #endif String CollisionPolygon2D::get_configuration_warning() const { - if (!Object::cast_to(get_parent())) { return TTR("CollisionPolygon2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."); } @@ -276,7 +257,6 @@ void CollisionPolygon2D::set_one_way_collision(bool p_enable) { } bool CollisionPolygon2D::is_one_way_collision_enabled() const { - return one_way_collision; } @@ -291,7 +271,6 @@ float CollisionPolygon2D::get_one_way_collision_margin() const { return one_way_collision_margin; } void CollisionPolygon2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &CollisionPolygon2D::set_polygon); ClassDB::bind_method(D_METHOD("get_polygon"), &CollisionPolygon2D::get_polygon); @@ -315,7 +294,6 @@ void CollisionPolygon2D::_bind_methods() { } CollisionPolygon2D::CollisionPolygon2D() { - aabb = Rect2(-10, -10, 20, 20); build_mode = BUILD_SOLIDS; set_notify_local_transform(true); diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h index 92a2758813..bf3e560a93 100644 --- a/scene/2d/collision_polygon_2d.h +++ b/scene/2d/collision_polygon_2d.h @@ -37,7 +37,6 @@ class CollisionObject2D; class CollisionPolygon2D : public Node2D { - GDCLASS(CollisionPolygon2D, Node2D); public: diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index b1dbc57c94..43c8db18be 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -41,12 +41,10 @@ #include "scene/resources/segment_shape_2d.h" void CollisionShape2D::_shape_changed() { - update(); } void CollisionShape2D::_update_in_shape_owner(bool p_xform_only) { - parent->shape_owner_set_transform(owner_id, get_transform()); if (p_xform_only) return; @@ -56,11 +54,8 @@ void CollisionShape2D::_update_in_shape_owner(bool p_xform_only) { } void CollisionShape2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_PARENTED: { - parent = Object::cast_to(get_parent()); if (parent) { owner_id = parent->create_shape_owner(this); @@ -78,14 +73,12 @@ void CollisionShape2D::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { - if (parent) { _update_in_shape_owner(); } } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (parent) { _update_in_shape_owner(true); } @@ -100,7 +93,6 @@ void CollisionShape2D::_notification(int p_what) { } break; case NOTIFICATION_DRAW: { - if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) { break; } @@ -147,7 +139,6 @@ void CollisionShape2D::_notification(int p_what) { } void CollisionShape2D::set_shape(const Ref &p_shape) { - if (shape.is_valid()) shape->disconnect("changed", callable_mp(this, &CollisionShape2D::_shape_changed)); shape = p_shape; @@ -166,12 +157,10 @@ void CollisionShape2D::set_shape(const Ref &p_shape) { } Ref CollisionShape2D::get_shape() const { - return shape; } bool CollisionShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - if (!shape.is_valid()) return false; @@ -179,7 +168,6 @@ bool CollisionShape2D::_edit_is_selected_on_click(const Point2 &p_point, double } String CollisionShape2D::get_configuration_warning() const { - if (!Object::cast_to(get_parent())) { return TTR("CollisionShape2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."); } @@ -212,7 +200,6 @@ void CollisionShape2D::set_one_way_collision(bool p_enable) { } bool CollisionShape2D::is_one_way_collision_enabled() const { - return one_way_collision; } @@ -228,7 +215,6 @@ float CollisionShape2D::get_one_way_collision_margin() const { } void CollisionShape2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_shape", "shape"), &CollisionShape2D::set_shape); ClassDB::bind_method(D_METHOD("get_shape"), &CollisionShape2D::get_shape); ClassDB::bind_method(D_METHOD("set_disabled", "disabled"), &CollisionShape2D::set_disabled); @@ -245,7 +231,6 @@ void CollisionShape2D::_bind_methods() { } CollisionShape2D::CollisionShape2D() { - rect = Rect2(-Point2(10, 10), Point2(20, 20)); set_notify_local_transform(true); owner_id = 0; diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h index 80bea0a979..ec7808ee7c 100644 --- a/scene/2d/collision_shape_2d.h +++ b/scene/2d/collision_shape_2d.h @@ -37,7 +37,6 @@ class CollisionObject2D; class CollisionShape2D : public Node2D { - GDCLASS(CollisionShape2D, Node2D); Ref shape; Rect2 rect; diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index c37cd398c4..ecc78809e7 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -37,7 +37,6 @@ #include "servers/rendering_server.h" void CPUParticles2D::set_emitting(bool p_emitting) { - if (emitting == p_emitting) return; @@ -47,7 +46,6 @@ void CPUParticles2D::set_emitting(bool p_emitting) { } void CPUParticles2D::set_amount(int p_amount) { - ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles must be greater than 0."); particles.resize(p_amount); @@ -65,99 +63,78 @@ void CPUParticles2D::set_amount(int p_amount) { particle_order.resize(p_amount); } void CPUParticles2D::set_lifetime(float p_lifetime) { - ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); lifetime = p_lifetime; } void CPUParticles2D::set_one_shot(bool p_one_shot) { - one_shot = p_one_shot; } void CPUParticles2D::set_pre_process_time(float p_time) { - pre_process_time = p_time; } void CPUParticles2D::set_explosiveness_ratio(float p_ratio) { - explosiveness_ratio = p_ratio; } void CPUParticles2D::set_randomness_ratio(float p_ratio) { - randomness_ratio = p_ratio; } void CPUParticles2D::set_lifetime_randomness(float p_random) { - lifetime_randomness = p_random; } void CPUParticles2D::set_use_local_coordinates(bool p_enable) { - local_coords = p_enable; set_notify_transform(!p_enable); } void CPUParticles2D::set_speed_scale(float p_scale) { - speed_scale = p_scale; } bool CPUParticles2D::is_emitting() const { - return emitting; } int CPUParticles2D::get_amount() const { - return particles.size(); } float CPUParticles2D::get_lifetime() const { - return lifetime; } bool CPUParticles2D::get_one_shot() const { - return one_shot; } float CPUParticles2D::get_pre_process_time() const { - return pre_process_time; } float CPUParticles2D::get_explosiveness_ratio() const { - return explosiveness_ratio; } float CPUParticles2D::get_randomness_ratio() const { - return randomness_ratio; } float CPUParticles2D::get_lifetime_randomness() const { - return lifetime_randomness; } bool CPUParticles2D::get_use_local_coordinates() const { - return local_coords; } float CPUParticles2D::get_speed_scale() const { - return speed_scale; } void CPUParticles2D::set_draw_order(DrawOrder p_order) { - draw_order = p_order; } CPUParticles2D::DrawOrder CPUParticles2D::get_draw_order() const { - return draw_order; } void CPUParticles2D::_update_mesh_texture() { - Size2 tex_size; if (texture.is_valid()) { tex_size = texture->get_size(); @@ -225,7 +202,6 @@ void CPUParticles2D::set_texture(const Ref &p_texture) { } void CPUParticles2D::_texture_changed() { - if (texture.is_valid()) { update(); _update_mesh_texture(); @@ -233,18 +209,15 @@ void CPUParticles2D::_texture_changed() { } Ref CPUParticles2D::get_texture() const { - return texture; } void CPUParticles2D::set_normalmap(const Ref &p_normalmap) { - normalmap = p_normalmap; update(); } Ref CPUParticles2D::get_normalmap() const { - return normalmap; } @@ -265,7 +238,6 @@ bool CPUParticles2D::get_fractional_delta() const { } String CPUParticles2D::get_configuration_warning() const { - String warnings; CanvasItemMaterial *mat = Object::cast_to(get_material().ptr()); @@ -283,7 +255,6 @@ String CPUParticles2D::get_configuration_warning() const { } void CPUParticles2D::restart() { - time = 0; inactive_time = 0; frame_remainder = 0; @@ -303,53 +274,44 @@ void CPUParticles2D::restart() { } void CPUParticles2D::set_direction(Vector2 p_direction) { - direction = p_direction; } Vector2 CPUParticles2D::get_direction() const { - return direction; } void CPUParticles2D::set_spread(float p_spread) { - spread = p_spread; } float CPUParticles2D::get_spread() const { - return spread; } void CPUParticles2D::set_param(Parameter p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); parameters[p_param] = p_value; } float CPUParticles2D::get_param(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return parameters[p_param]; } void CPUParticles2D::set_param_randomness(Parameter p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); randomness[p_param] = p_value; } float CPUParticles2D::get_param_randomness(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return randomness[p_param]; } static void _adjust_curve_range(const Ref &p_curve, float p_min, float p_max) { - Ref curve = p_curve; if (!curve.is_valid()) return; @@ -358,7 +320,6 @@ static void _adjust_curve_range(const Ref &p_curve, float p_min, float p_ } void CPUParticles2D::set_param_curve(Parameter p_param, const Ref &p_curve) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); curve_parameters[p_param] = p_curve; @@ -389,7 +350,6 @@ void CPUParticles2D::set_param_curve(Parameter p_param, const Ref &p_curv _adjust_curve_range(p_curve, -360, 360); } break; case PARAM_SCALE: { - } break; case PARAM_HUE_VARIATION: { _adjust_curve_range(p_curve, -1, 1); @@ -404,29 +364,24 @@ void CPUParticles2D::set_param_curve(Parameter p_param, const Ref &p_curv } } Ref CPUParticles2D::get_param_curve(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref()); return curve_parameters[p_param]; } void CPUParticles2D::set_color(const Color &p_color) { - color = p_color; } Color CPUParticles2D::get_color() const { - return color; } void CPUParticles2D::set_color_ramp(const Ref &p_ramp) { - color_ramp = p_ramp; } Ref CPUParticles2D::get_color_ramp() const { - return color_ramp; } @@ -447,49 +402,39 @@ void CPUParticles2D::set_emission_shape(EmissionShape p_shape) { } void CPUParticles2D::set_emission_sphere_radius(float p_radius) { - emission_sphere_radius = p_radius; } void CPUParticles2D::set_emission_rect_extents(Vector2 p_extents) { - emission_rect_extents = p_extents; } void CPUParticles2D::set_emission_points(const Vector &p_points) { - emission_points = p_points; } void CPUParticles2D::set_emission_normals(const Vector &p_normals) { - emission_normals = p_normals; } void CPUParticles2D::set_emission_colors(const Vector &p_colors) { - emission_colors = p_colors; } float CPUParticles2D::get_emission_sphere_radius() const { - return emission_sphere_radius; } Vector2 CPUParticles2D::get_emission_rect_extents() const { - return emission_rect_extents; } Vector CPUParticles2D::get_emission_points() const { - return emission_points; } Vector CPUParticles2D::get_emission_normals() const { - return emission_normals; } Vector CPUParticles2D::get_emission_colors() const { - return emission_colors; } @@ -497,17 +442,14 @@ CPUParticles2D::EmissionShape CPUParticles2D::get_emission_shape() const { return emission_shape; } void CPUParticles2D::set_gravity(const Vector2 &p_gravity) { - gravity = p_gravity; } Vector2 CPUParticles2D::get_gravity() const { - return gravity; } void CPUParticles2D::_validate_property(PropertyInfo &property) const { - if (property.name == "color" && color_ramp.is_valid()) { property.usage = 0; } @@ -538,7 +480,6 @@ void CPUParticles2D::_validate_property(PropertyInfo &property) const { } static uint32_t idhash(uint32_t x) { - x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b); x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b); x = (x >> uint32_t(16)) ^ x; @@ -559,7 +500,6 @@ static float rand_from_seed(uint32_t &seed) { } void CPUParticles2D::_update_internal() { - if (particles.size() == 0 || !is_visible_in_tree()) { _set_redraw(false); return; @@ -585,7 +525,6 @@ void CPUParticles2D::_update_internal() { _set_redraw(true); if (time == 0 && pre_process_time > 0.0) { - float frame_time; if (fixed_fps > 0) frame_time = 1.0 / fixed_fps; @@ -627,7 +566,6 @@ void CPUParticles2D::_update_internal() { } void CPUParticles2D::_particles_process(float p_delta) { - p_delta *= speed_scale; int pcount = particles.size(); @@ -657,7 +595,6 @@ void CPUParticles2D::_particles_process(float p_delta) { float system_phase = time / lifetime; for (int i = 0; i < pcount; i++) { - Particle &p = parray[i]; if (!emitting && !p.active) @@ -715,7 +652,6 @@ void CPUParticles2D::_particles_process(float p_delta) { } if (restart) { - if (!emitting) { p.active = false; continue; @@ -774,7 +710,6 @@ void CPUParticles2D::_particles_process(float p_delta) { } break; case EMISSION_SHAPE_POINTS: case EMISSION_SHAPE_DIRECTED_POINTS: { - int pc = emission_points.size(); if (pc == 0) break; @@ -806,7 +741,6 @@ void CPUParticles2D::_particles_process(float p_delta) { } else if (p.time > p.lifetime) { p.active = false; } else { - uint32_t alt_seed = p.seed; p.time += local_delta; @@ -890,7 +824,6 @@ void CPUParticles2D::_particles_process(float p_delta) { } if (parameters[PARAM_DAMPING] + tex_damping > 0.0) { - float v = p.velocity.length(); float damp = (parameters[PARAM_DAMPING] + tex_damping) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_DAMPING]); v -= damp * local_delta; @@ -949,7 +882,6 @@ void CPUParticles2D::_particles_process(float p_delta) { if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) { if (p.velocity.length() > 0.0) { - p.transform.elements[1] = p.velocity.normalized(); p.transform.elements[0] = p.transform.elements[1].tangent(); } @@ -998,7 +930,6 @@ void CPUParticles2D::_update_particle_data_buffer() { } for (int i = 0; i < pc; i++) { - int idx = order ? order[i] : i; Transform2D t = r[idx].transform; @@ -1008,7 +939,6 @@ void CPUParticles2D::_update_particle_data_buffer() { } if (r[idx].active) { - ptr[0] = t.elements[0][0]; ptr[1] = t.elements[1][0]; ptr[2] = 0; @@ -1065,14 +995,12 @@ void CPUParticles2D::_set_redraw(bool p_redraw) { } void CPUParticles2D::_update_render_thread() { - MutexLock lock(update_mutex); RS::get_singleton()->multimesh_set_buffer(multimesh, particle_data); } void CPUParticles2D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { set_process_internal(emitting); } @@ -1107,11 +1035,9 @@ void CPUParticles2D::_notification(int p_what) { } 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(); @@ -1119,11 +1045,9 @@ void CPUParticles2D::_notification(int p_what) { float *ptr = w; for (int i = 0; i < pc; i++) { - Transform2D t = inv_emission_transform * r[i].transform; if (r[i].active) { - ptr[0] = t.elements[0][0]; ptr[1] = t.elements[1][0]; ptr[2] = 0; @@ -1144,7 +1068,6 @@ void CPUParticles2D::_notification(int p_what) { } void CPUParticles2D::convert_from_particles(Node *p_particles) { - GPUParticles2D *particles = Object::cast_to(p_particles); ERR_FAIL_COND_MSG(!particles, "Only GPUParticles2D nodes can be converted to CPUParticles2D."); @@ -1219,7 +1142,6 @@ void CPUParticles2D::convert_from_particles(Node *p_particles) { } void CPUParticles2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &CPUParticles2D::set_emitting); ClassDB::bind_method(D_METHOD("set_amount", "amount"), &CPUParticles2D::set_amount); ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &CPUParticles2D::set_lifetime); @@ -1422,7 +1344,6 @@ void CPUParticles2D::_bind_methods() { } CPUParticles2D::CPUParticles2D() { - time = 0; inactive_time = 0; frame_remainder = 0; diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h index 18d0caceed..747f06b90d 100644 --- a/scene/2d/cpu_particles_2d.h +++ b/scene/2d/cpu_particles_2d.h @@ -124,7 +124,6 @@ private: const Particle *particles; Vector2 axis; bool operator()(int p_a, int p_b) const { - return axis.dot(particles[p_a].transform[2]) < axis.dot(particles[p_b].transform[2]); } }; diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index de3f8fa09e..a76114a6c3 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -39,7 +39,6 @@ #endif void GPUParticles2D::set_emitting(bool p_emitting) { - RS::get_singleton()->particles_set_emitting(particles, p_emitting); if (p_emitting && one_shot) { @@ -50,25 +49,21 @@ void GPUParticles2D::set_emitting(bool p_emitting) { } 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 GPUParticles2D::set_lifetime(float p_lifetime) { - ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); lifetime = p_lifetime; RS::get_singleton()->particles_set_lifetime(particles, lifetime); } void GPUParticles2D::set_one_shot(bool p_enable) { - one_shot = p_enable; RS::get_singleton()->particles_set_one_shot(particles, one_shot); if (is_emitting()) { - set_process_internal(true); if (!one_shot) RenderingServer::get_singleton()->particles_restart(particles); @@ -78,22 +73,18 @@ void GPUParticles2D::set_one_shot(bool p_enable) { set_process_internal(false); } 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 GPUParticles2D::set_explosiveness_ratio(float p_ratio) { - explosiveness_ratio = p_ratio; RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio); } void GPUParticles2D::set_randomness_ratio(float p_ratio) { - randomness_ratio = p_ratio; RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); } 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; @@ -107,7 +98,6 @@ void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) { update(); } 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); @@ -117,7 +107,6 @@ void GPUParticles2D::set_use_local_coordinates(bool p_enable) { } 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)); @@ -128,7 +117,6 @@ void GPUParticles2D::_update_particle_emission_transform() { } 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)) { @@ -145,66 +133,52 @@ void GPUParticles2D::set_process_material(const Ref &p_material) { } void GPUParticles2D::set_speed_scale(float p_scale) { - speed_scale = p_scale; RS::get_singleton()->particles_set_speed_scale(particles, p_scale); } bool GPUParticles2D::is_emitting() const { - return RS::get_singleton()->particles_get_emitting(particles); } int GPUParticles2D::get_amount() const { - return amount; } float GPUParticles2D::get_lifetime() const { - return lifetime; } bool GPUParticles2D::get_one_shot() const { - return one_shot; } float GPUParticles2D::get_pre_process_time() const { - return pre_process_time; } float GPUParticles2D::get_explosiveness_ratio() const { - return explosiveness_ratio; } float GPUParticles2D::get_randomness_ratio() const { - return randomness_ratio; } Rect2 GPUParticles2D::get_visibility_rect() const { - return visibility_rect; } bool GPUParticles2D::get_use_local_coordinates() const { - return local_coords; } Ref GPUParticles2D::get_process_material() const { - return process_material; } float GPUParticles2D::get_speed_scale() const { - return speed_scale; } void GPUParticles2D::set_draw_order(DrawOrder p_order) { - draw_order = p_order; RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order)); } GPUParticles2D::DrawOrder GPUParticles2D::get_draw_order() const { - return draw_order; } @@ -227,7 +201,6 @@ bool GPUParticles2D::get_fractional_delta() const { } String GPUParticles2D::get_configuration_warning() const { - if (RenderingServer::get_singleton()->is_low_end()) { return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles2D node instead. You can use the \"Convert to CPUParticles2D\" option for this purpose."); } @@ -239,7 +212,6 @@ String GPUParticles2D::get_configuration_warning() const { warnings += "\n"; warnings += "- " + TTR("A material to process the particles is not assigned, so no behavior is imprinted."); } else { - CanvasItemMaterial *mat = Object::cast_to(get_material().ptr()); if (get_material().is_null() || (mat && !mat->get_particles_animation())) { @@ -258,7 +230,6 @@ String GPUParticles2D::get_configuration_warning() const { } Rect2 GPUParticles2D::capture_rect() const { - AABB aabb = RS::get_singleton()->particles_get_current_aabb(particles); Rect2 r; r.position.x = aabb.position.x; @@ -278,7 +249,6 @@ Ref GPUParticles2D::get_texture() const { } void GPUParticles2D::set_normal_map(const Ref &p_normal_map) { - normal_map = p_normal_map; update(); } @@ -296,9 +266,7 @@ void GPUParticles2D::restart() { } void GPUParticles2D::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - RID texture_rid; if (texture.is_valid()) texture_rid = texture->get_rid(); @@ -310,7 +278,6 @@ void GPUParticles2D::_notification(int p_what) { #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) { - draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false); } #endif @@ -320,7 +287,6 @@ void GPUParticles2D::_notification(int p_what) { if (can_process()) { RS::get_singleton()->particles_set_speed_scale(particles, speed_scale); } else { - RS::get_singleton()->particles_set_speed_scale(particles, 0); } } @@ -330,7 +296,6 @@ void GPUParticles2D::_notification(int p_what) { } if (p_what == NOTIFICATION_INTERNAL_PROCESS) { - if (one_shot && !is_emitting()) { _change_notify(); set_process_internal(false); @@ -339,7 +304,6 @@ void GPUParticles2D::_notification(int p_what) { } 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); @@ -407,7 +371,6 @@ void GPUParticles2D::_bind_methods() { } GPUParticles2D::GPUParticles2D() { - particles = RS::get_singleton()->particles_create(); one_shot = false; // Needed so that set_emitting doesn't access uninitialized values @@ -427,6 +390,5 @@ GPUParticles2D::GPUParticles2D() { } GPUParticles2D::~GPUParticles2D() { - RS::get_singleton()->free(particles); } diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 4d49f4762f..07a6926d4f 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -35,7 +35,6 @@ #include "servers/physics_server_2d.h" void Joint2D::_update_joint(bool p_only_free) { - if (joint.is_valid()) { if (ba.is_valid() && bb.is_valid() && exclude_from_collision) PhysicsServer2D::get_singleton()->joint_disable_collisions_between_bodies(joint, false); @@ -75,7 +74,6 @@ void Joint2D::_update_joint(bool p_only_free) { } void Joint2D::set_node_a(const NodePath &p_node_a) { - if (a == p_node_a) return; @@ -84,26 +82,21 @@ void Joint2D::set_node_a(const NodePath &p_node_a) { } NodePath Joint2D::get_node_a() const { - return a; } void Joint2D::set_node_b(const NodePath &p_node_b) { - if (b == p_node_b) return; b = p_node_b; _update_joint(); } NodePath Joint2D::get_node_b() const { - return b; } void Joint2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_READY: { _update_joint(); } break; @@ -116,19 +109,16 @@ void Joint2D::_notification(int p_what) { } void Joint2D::set_bias(real_t p_bias) { - bias = p_bias; if (joint.is_valid()) PhysicsServer2D::get_singleton()->get_singleton()->joint_set_param(joint, PhysicsServer2D::JOINT_PARAM_BIAS, bias); } real_t Joint2D::get_bias() const { - return bias; } void Joint2D::set_exclude_nodes_from_collision(bool p_enable) { - if (exclude_from_collision == p_enable) return; @@ -138,12 +128,10 @@ void Joint2D::set_exclude_nodes_from_collision(bool p_enable) { } bool Joint2D::get_exclude_nodes_from_collision() const { - return exclude_from_collision; } void Joint2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_node_a", "node"), &Joint2D::set_node_a); ClassDB::bind_method(D_METHOD("get_node_a"), &Joint2D::get_node_a); @@ -163,7 +151,6 @@ void Joint2D::_bind_methods() { } Joint2D::Joint2D() { - bias = 0; exclude_from_collision = true; } @@ -173,10 +160,8 @@ Joint2D::Joint2D() { /////////////////////////////////////////////////////////////////////////////// void PinJoint2D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_DRAW: { - if (!is_inside_tree()) break; @@ -191,14 +176,12 @@ void PinJoint2D::_notification(int p_what) { } RID PinJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) { - RID pj = PhysicsServer2D::get_singleton()->pin_joint_create(get_global_transform().get_origin(), body_a->get_rid(), body_b ? body_b->get_rid() : RID()); PhysicsServer2D::get_singleton()->pin_joint_set_param(pj, PhysicsServer2D::PIN_JOINT_SOFTNESS, softness); return pj; } void PinJoint2D::set_softness(real_t p_softness) { - softness = p_softness; update(); if (get_joint().is_valid()) @@ -206,12 +189,10 @@ void PinJoint2D::set_softness(real_t p_softness) { } real_t PinJoint2D::get_softness() const { - return softness; } void PinJoint2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_softness", "softness"), &PinJoint2D::set_softness); ClassDB::bind_method(D_METHOD("get_softness"), &PinJoint2D::get_softness); @@ -219,7 +200,6 @@ void PinJoint2D::_bind_methods() { } PinJoint2D::PinJoint2D() { - softness = 0; } @@ -228,7 +208,6 @@ PinJoint2D::PinJoint2D() { /////////////////////////////////////////////////////////////////////////////// void GrooveJoint2D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_DRAW: { if (!is_inside_tree()) @@ -247,7 +226,6 @@ void GrooveJoint2D::_notification(int p_what) { } RID GrooveJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) { - Transform2D gt = get_global_transform(); Vector2 groove_A1 = gt.get_origin(); Vector2 groove_A2 = gt.xform(Vector2(0, length)); @@ -257,29 +235,24 @@ RID GrooveJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b } void GrooveJoint2D::set_length(real_t p_length) { - length = p_length; update(); } real_t GrooveJoint2D::get_length() const { - return length; } void GrooveJoint2D::set_initial_offset(real_t p_initial_offset) { - initial_offset = p_initial_offset; update(); } real_t GrooveJoint2D::get_initial_offset() const { - return initial_offset; } void GrooveJoint2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_length", "length"), &GrooveJoint2D::set_length); ClassDB::bind_method(D_METHOD("get_length"), &GrooveJoint2D::get_length); ClassDB::bind_method(D_METHOD("set_initial_offset", "offset"), &GrooveJoint2D::set_initial_offset); @@ -290,7 +263,6 @@ void GrooveJoint2D::_bind_methods() { } GrooveJoint2D::GrooveJoint2D() { - length = 50; initial_offset = 25; } @@ -300,10 +272,8 @@ GrooveJoint2D::GrooveJoint2D() { /////////////////////////////////////////////////////////////////////////////// void DampedSpringJoint2D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_DRAW: { - if (!is_inside_tree()) break; @@ -319,7 +289,6 @@ void DampedSpringJoint2D::_notification(int p_what) { } RID DampedSpringJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) { - Transform2D gt = get_global_transform(); Vector2 anchor_A = gt.get_origin(); Vector2 anchor_B = gt.xform(Vector2(0, length)); @@ -334,18 +303,15 @@ RID DampedSpringJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D * } void DampedSpringJoint2D::set_length(real_t p_length) { - length = p_length; update(); } real_t DampedSpringJoint2D::get_length() const { - return length; } void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) { - rest_length = p_rest_length; update(); if (get_joint().is_valid()) @@ -353,12 +319,10 @@ void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) { } real_t DampedSpringJoint2D::get_rest_length() const { - return rest_length; } void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) { - stiffness = p_stiffness; update(); if (get_joint().is_valid()) @@ -366,12 +330,10 @@ void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) { } real_t DampedSpringJoint2D::get_stiffness() const { - return stiffness; } void DampedSpringJoint2D::set_damping(real_t p_damping) { - damping = p_damping; update(); if (get_joint().is_valid()) @@ -379,12 +341,10 @@ void DampedSpringJoint2D::set_damping(real_t p_damping) { } real_t DampedSpringJoint2D::get_damping() const { - return damping; } void DampedSpringJoint2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_length", "length"), &DampedSpringJoint2D::set_length); ClassDB::bind_method(D_METHOD("get_length"), &DampedSpringJoint2D::get_length); ClassDB::bind_method(D_METHOD("set_rest_length", "rest_length"), &DampedSpringJoint2D::set_rest_length); @@ -401,7 +361,6 @@ void DampedSpringJoint2D::_bind_methods() { } DampedSpringJoint2D::DampedSpringJoint2D() { - length = 50; rest_length = 0; stiffness = 20; diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h index f1750e56b6..9a3bea4407 100644 --- a/scene/2d/joints_2d.h +++ b/scene/2d/joints_2d.h @@ -36,7 +36,6 @@ class PhysicsBody2D; class Joint2D : public Node2D { - GDCLASS(Joint2D, Node2D); RID joint; @@ -74,7 +73,6 @@ public: }; class PinJoint2D : public Joint2D { - GDCLASS(PinJoint2D, Joint2D); real_t softness; @@ -92,7 +90,6 @@ public: }; class GrooveJoint2D : public Joint2D { - GDCLASS(GrooveJoint2D, Joint2D); real_t length; @@ -114,7 +111,6 @@ public: }; class DampedSpringJoint2D : public Joint2D { - GDCLASS(DampedSpringJoint2D, Joint2D); real_t stiffness; diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index b3d54b81f8..ed69a4544e 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -80,7 +80,6 @@ Rect2 Light2D::get_anchorable_rect() const { } void Light2D::_update_light_visibility() { - if (!is_inside_tree()) return; @@ -104,29 +103,24 @@ void Light2D::_update_light_visibility() { } void Light2D::set_enabled(bool p_enabled) { - enabled = p_enabled; _update_light_visibility(); } bool Light2D::is_enabled() const { - return enabled; } void Light2D::set_editor_only(bool p_editor_only) { - editor_only = p_editor_only; _update_light_visibility(); } bool Light2D::is_editor_only() const { - return editor_only; } void Light2D::set_texture(const Ref &p_texture) { - texture = p_texture; if (texture.is_valid()) RS::get_singleton()->canvas_light_set_texture(canvas_light, texture->get_rid()); @@ -137,12 +131,10 @@ void Light2D::set_texture(const Ref &p_texture) { } Ref Light2D::get_texture() const { - return texture; } void Light2D::set_texture_offset(const Vector2 &p_offset) { - texture_offset = p_offset; RS::get_singleton()->canvas_light_set_texture_offset(canvas_light, texture_offset); item_rect_changed(); @@ -150,44 +142,36 @@ void Light2D::set_texture_offset(const Vector2 &p_offset) { } Vector2 Light2D::get_texture_offset() const { - return texture_offset; } void Light2D::set_color(const Color &p_color) { - color = p_color; RS::get_singleton()->canvas_light_set_color(canvas_light, color); } Color Light2D::get_color() const { - return color; } void Light2D::set_height(float p_height) { - height = p_height; RS::get_singleton()->canvas_light_set_height(canvas_light, height); } float Light2D::get_height() const { - return height; } void Light2D::set_energy(float p_energy) { - energy = p_energy; RS::get_singleton()->canvas_light_set_energy(canvas_light, energy); } float Light2D::get_energy() const { - return energy; } void Light2D::set_texture_scale(float p_scale) { - _scale = p_scale; // Avoid having 0 scale values, can lead to errors in physics and rendering. if (_scale == 0) { @@ -198,101 +182,82 @@ void Light2D::set_texture_scale(float p_scale) { } float Light2D::get_texture_scale() const { - return _scale; } void Light2D::set_z_range_min(int p_min_z) { - z_min = p_min_z; RS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max); } int Light2D::get_z_range_min() const { - return z_min; } void Light2D::set_z_range_max(int p_max_z) { - z_max = p_max_z; RS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max); } int Light2D::get_z_range_max() const { - return z_max; } void Light2D::set_layer_range_min(int p_min_layer) { - layer_min = p_min_layer; RS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max); } int Light2D::get_layer_range_min() const { - return layer_min; } void Light2D::set_layer_range_max(int p_max_layer) { - layer_max = p_max_layer; RS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max); } int Light2D::get_layer_range_max() const { - return layer_max; } void Light2D::set_item_cull_mask(int p_mask) { - item_mask = p_mask; RS::get_singleton()->canvas_light_set_item_cull_mask(canvas_light, item_mask); } int Light2D::get_item_cull_mask() const { - return item_mask; } void Light2D::set_item_shadow_cull_mask(int p_mask) { - item_shadow_mask = p_mask; RS::get_singleton()->canvas_light_set_item_shadow_cull_mask(canvas_light, item_shadow_mask); } int Light2D::get_item_shadow_cull_mask() const { - return item_shadow_mask; } void Light2D::set_mode(Mode p_mode) { - mode = p_mode; RS::get_singleton()->canvas_light_set_mode(canvas_light, RS::CanvasLightMode(p_mode)); } Light2D::Mode Light2D::get_mode() const { - return mode; } void Light2D::set_shadow_enabled(bool p_enabled) { - shadow = p_enabled; RS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light, shadow); } bool Light2D::is_shadow_enabled() const { - return shadow; } void Light2D::set_shadow_buffer_size(int p_size) { - shadow_buffer_size = p_size; RS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light, shadow_buffer_size); } int Light2D::get_shadow_buffer_size() const { - return shadow_buffer_size; } @@ -303,7 +268,6 @@ void Light2D::set_shadow_filter(ShadowFilter p_filter) { } Light2D::ShadowFilter Light2D::get_shadow_filter() const { - return shadow_filter; } @@ -317,31 +281,25 @@ Color Light2D::get_shadow_color() const { } void Light2D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - RS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, get_canvas()); _update_light_visibility(); } if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - RS::get_singleton()->canvas_light_set_transform(canvas_light, get_global_transform()); } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - _update_light_visibility(); } if (p_what == NOTIFICATION_EXIT_TREE) { - RS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, RID()); _update_light_visibility(); } } String Light2D::get_configuration_warning() const { - if (!texture.is_valid()) { return TTR("A texture with the shape of the light must be supplied to the \"Texture\" property."); } @@ -350,18 +308,15 @@ String Light2D::get_configuration_warning() const { } void Light2D::set_shadow_smooth(float p_amount) { - shadow_smooth = p_amount; RS::get_singleton()->canvas_light_set_shadow_smooth(canvas_light, shadow_smooth); } float Light2D::get_shadow_smooth() const { - return shadow_smooth; } void Light2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &Light2D::set_enabled); ClassDB::bind_method(D_METHOD("is_enabled"), &Light2D::is_enabled); @@ -457,7 +412,6 @@ void Light2D::_bind_methods() { } Light2D::Light2D() { - canvas_light = RenderingServer::get_singleton()->canvas_light_create(); enabled = true; editor_only = false; @@ -482,6 +436,5 @@ Light2D::Light2D() { } Light2D::~Light2D() { - RenderingServer::get_singleton()->free(canvas_light); } diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index 7134029441..0d5e8d674a 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -34,7 +34,6 @@ #include "scene/2d/node_2d.h" class Light2D : public Node2D { - GDCLASS(Light2D, Node2D); public: diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index bd1a820aec..80a0c0c40a 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -36,7 +36,6 @@ #ifdef TOOLS_ENABLED Rect2 OccluderPolygon2D::_edit_get_rect() const { - if (rect_cache_dirty) { if (closed) { const Vector2 *r = polygon.ptr(); @@ -67,7 +66,6 @@ Rect2 OccluderPolygon2D::_edit_get_rect() const { } bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - if (closed) { return Geometry::is_point_in_polygon(p_point, Variant(polygon)); } else { @@ -85,7 +83,6 @@ bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double #endif void OccluderPolygon2D::set_polygon(const Vector &p_polygon) { - polygon = p_polygon; rect_cache_dirty = true; RS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, p_polygon, closed); @@ -93,12 +90,10 @@ void OccluderPolygon2D::set_polygon(const Vector &p_polygon) { } Vector OccluderPolygon2D::get_polygon() const { - return polygon; } void OccluderPolygon2D::set_closed(bool p_closed) { - if (closed == p_closed) return; closed = p_closed; @@ -108,28 +103,23 @@ void OccluderPolygon2D::set_closed(bool p_closed) { } bool OccluderPolygon2D::is_closed() const { - return closed; } void OccluderPolygon2D::set_cull_mode(CullMode p_mode) { - cull = p_mode; RS::get_singleton()->canvas_occluder_polygon_set_cull_mode(occ_polygon, RS::CanvasOccluderPolygonCullMode(p_mode)); } OccluderPolygon2D::CullMode OccluderPolygon2D::get_cull_mode() const { - return cull; } RID OccluderPolygon2D::get_rid() const { - return occ_polygon; } void OccluderPolygon2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_closed", "closed"), &OccluderPolygon2D::set_closed); ClassDB::bind_method(D_METHOD("is_closed"), &OccluderPolygon2D::is_closed); @@ -149,7 +139,6 @@ void OccluderPolygon2D::_bind_methods() { } OccluderPolygon2D::OccluderPolygon2D() { - occ_polygon = RS::get_singleton()->canvas_occluder_polygon_create(); closed = true; cull = CULL_DISABLED; @@ -157,40 +146,31 @@ OccluderPolygon2D::OccluderPolygon2D() { } OccluderPolygon2D::~OccluderPolygon2D() { - RS::get_singleton()->free(occ_polygon); } void LightOccluder2D::_poly_changed() { - #ifdef DEBUG_ENABLED update(); #endif } void LightOccluder2D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_CANVAS) { - RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, get_canvas()); RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform()); RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree()); } if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform()); } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree()); } if (p_what == NOTIFICATION_DRAW) { - if (Engine::get_singleton()->is_editor_hint()) { - if (occluder_polygon.is_valid()) { - Vector poly = occluder_polygon->get_polygon(); if (poly.size()) { @@ -199,11 +179,9 @@ void LightOccluder2D::_notification(int p_what) { color.push_back(Color(0, 0, 0, 0.6)); draw_polygon(Variant(poly), color); } else { - int ps = poly.size(); const Vector2 *r = poly.ptr(); for (int i = 0; i < ps - 1; i++) { - draw_line(r[i], r[i + 1], Color(0, 0, 0, 0.6), 3); } } @@ -213,25 +191,21 @@ void LightOccluder2D::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_CANVAS) { - RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, RID()); } } #ifdef TOOLS_ENABLED Rect2 LightOccluder2D::_edit_get_rect() const { - return occluder_polygon.is_valid() ? occluder_polygon->_edit_get_rect() : Rect2(); } bool LightOccluder2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - return occluder_polygon.is_valid() ? occluder_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false; } #endif void LightOccluder2D::set_occluder_polygon(const Ref &p_polygon) { - #ifdef DEBUG_ENABLED if (occluder_polygon.is_valid()) occluder_polygon->disconnect("changed", callable_mp(this, &LightOccluder2D::_poly_changed)); @@ -251,23 +225,19 @@ void LightOccluder2D::set_occluder_polygon(const Ref &p_polyg } Ref LightOccluder2D::get_occluder_polygon() const { - return occluder_polygon; } void LightOccluder2D::set_occluder_light_mask(int p_mask) { - mask = p_mask; RS::get_singleton()->canvas_light_occluder_set_light_mask(occluder, mask); } int LightOccluder2D::get_occluder_light_mask() const { - return mask; } String LightOccluder2D::get_configuration_warning() const { - if (!occluder_polygon.is_valid()) { return TTR("An occluder polygon must be set (or drawn) for this occluder to take effect."); } @@ -280,7 +250,6 @@ String LightOccluder2D::get_configuration_warning() const { } void LightOccluder2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_occluder_polygon", "polygon"), &LightOccluder2D::set_occluder_polygon); ClassDB::bind_method(D_METHOD("get_occluder_polygon"), &LightOccluder2D::get_occluder_polygon); @@ -292,13 +261,11 @@ void LightOccluder2D::_bind_methods() { } LightOccluder2D::LightOccluder2D() { - occluder = RS::get_singleton()->canvas_light_occluder_create(); mask = 1; set_notify_transform(true); } LightOccluder2D::~LightOccluder2D() { - RS::get_singleton()->free(occluder); } diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h index 83702f2875..eba67edfe4 100644 --- a/scene/2d/light_occluder_2d.h +++ b/scene/2d/light_occluder_2d.h @@ -34,7 +34,6 @@ #include "scene/2d/node_2d.h" class OccluderPolygon2D : public Resource { - GDCLASS(OccluderPolygon2D, Resource); public: diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 43c54ffd17..0ec58ec176 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -52,7 +52,6 @@ Line2D::Line2D() { #ifdef TOOLS_ENABLED Rect2 Line2D::_edit_get_rect() const { - if (_points.size() == 0) return Rect2(0, 0, 0, 0); Vector2 d = Vector2(_width, _width); @@ -69,7 +68,6 @@ bool Line2D::_edit_use_rect() const { } bool Line2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - const real_t d = _width / 2 + p_tolerance; const Vector2 *points = _points.ptr(); for (int i = 0; i < _points.size() - 1; i++) { @@ -168,7 +166,6 @@ Color Line2D::get_default_color() const { } void Line2D::set_gradient(const Ref &p_gradient) { - // Cleanup previous connection if any if (_gradient.is_valid()) { _gradient->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Line2D::_gradient_changed)); @@ -350,7 +347,6 @@ void Line2D::_curve_changed() { // static void Line2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_points", "points"), &Line2D::set_points); ClassDB::bind_method(D_METHOD("get_points"), &Line2D::get_points); diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h index 51706befdb..bccbcbdcb9 100644 --- a/scene/2d/line_2d.h +++ b/scene/2d/line_2d.h @@ -34,7 +34,6 @@ #include "node_2d.h" class Line2D : public Node2D { - GDCLASS(Line2D, Node2D); public: diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp index 6b06f2227a..56293a7b8d 100644 --- a/scene/2d/line_builder.cpp +++ b/scene/2d/line_builder.cpp @@ -117,7 +117,6 @@ void LineBuilder::clear_output() { } void LineBuilder::build() { - // Need at least 2 points to draw a line if (points.size() < 2) { clear_output(); @@ -220,7 +219,6 @@ void LineBuilder::build() { // For each additional segment for (int i = 1; i < len - 1; ++i) { - pos1 = points[i]; Vector2 pos2 = points[i + 1]; @@ -359,7 +357,6 @@ void LineBuilder::build() { // Add joint geometry if (current_joint_mode != Line2D::LINE_JOINT_SHARP) { - /* ________________ cbegin * / \ * / \ @@ -541,7 +538,6 @@ void LineBuilder::strip_add_tri(Vector2 up, Orientation orientation) { } void LineBuilder::strip_add_arc(Vector2 center, float angle_delta, Orientation orientation) { - // Take the two last vertices and extrude an arc made of triangles // that all share one of the initial vertices @@ -570,7 +566,6 @@ void LineBuilder::strip_add_arc(Vector2 center, float angle_delta, Orientation o } void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Color color, Rect2 uv_rect) { - // Make a standalone arc that doesn't use existing vertices, // with undistorted UVs from within a square section diff --git a/scene/2d/mesh_instance_2d.cpp b/scene/2d/mesh_instance_2d.cpp index 5e258be700..b4dd09c513 100644 --- a/scene/2d/mesh_instance_2d.cpp +++ b/scene/2d/mesh_instance_2d.cpp @@ -31,7 +31,6 @@ #include "mesh_instance_2d.h" void MeshInstance2D::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { if (mesh.is_valid()) { draw_mesh(mesh, texture, normal_map); @@ -40,7 +39,6 @@ void MeshInstance2D::_notification(int p_what) { } void MeshInstance2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MeshInstance2D::set_mesh); ClassDB::bind_method(D_METHOD("get_mesh"), &MeshInstance2D::get_mesh); @@ -58,18 +56,15 @@ void MeshInstance2D::_bind_methods() { } void MeshInstance2D::set_mesh(const Ref &p_mesh) { - mesh = p_mesh; update(); } Ref MeshInstance2D::get_mesh() const { - return mesh; } void MeshInstance2D::set_texture(const Ref &p_texture) { - if (p_texture == texture) return; texture = p_texture; @@ -79,24 +74,20 @@ void MeshInstance2D::set_texture(const Ref &p_texture) { } void MeshInstance2D::set_normal_map(const Ref &p_texture) { - normal_map = p_texture; update(); } Ref MeshInstance2D::get_normal_map() const { - return normal_map; } Ref MeshInstance2D::get_texture() const { - return texture; } #ifdef TOOLS_ENABLED Rect2 MeshInstance2D::_edit_get_rect() const { - if (mesh.is_valid()) { AABB aabb = mesh->get_aabb(); return Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); diff --git a/scene/2d/multimesh_instance_2d.cpp b/scene/2d/multimesh_instance_2d.cpp index 6620027020..d99d5b9b30 100644 --- a/scene/2d/multimesh_instance_2d.cpp +++ b/scene/2d/multimesh_instance_2d.cpp @@ -31,7 +31,6 @@ #include "multimesh_instance_2d.h" void MultiMeshInstance2D::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { if (multimesh.is_valid()) { draw_multimesh(multimesh, texture, normal_map); @@ -40,7 +39,6 @@ void MultiMeshInstance2D::_notification(int p_what) { } void MultiMeshInstance2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_multimesh", "multimesh"), &MultiMeshInstance2D::set_multimesh); ClassDB::bind_method(D_METHOD("get_multimesh"), &MultiMeshInstance2D::get_multimesh); @@ -58,18 +56,15 @@ void MultiMeshInstance2D::_bind_methods() { } void MultiMeshInstance2D::set_multimesh(const Ref &p_multimesh) { - multimesh = p_multimesh; update(); } Ref MultiMeshInstance2D::get_multimesh() const { - return multimesh; } void MultiMeshInstance2D::set_texture(const Ref &p_texture) { - if (p_texture == texture) return; texture = p_texture; @@ -79,24 +74,20 @@ void MultiMeshInstance2D::set_texture(const Ref &p_texture) { } Ref MultiMeshInstance2D::get_texture() const { - return texture; } void MultiMeshInstance2D::set_normal_map(const Ref &p_texture) { - normal_map = p_texture; update(); } Ref MultiMeshInstance2D::get_normal_map() const { - return normal_map; } #ifdef TOOLS_ENABLED Rect2 MultiMeshInstance2D::_edit_get_rect() const { - if (multimesh.is_valid()) { AABB aabb = multimesh->get_aabb(); return Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); diff --git a/scene/2d/navigation_2d.cpp b/scene/2d/navigation_2d.cpp index ae9fc0f32c..039c6f2e53 100644 --- a/scene/2d/navigation_2d.cpp +++ b/scene/2d/navigation_2d.cpp @@ -54,7 +54,6 @@ void Navigation2D::_notification(int p_what) { NavigationServer2D::get_singleton()->map_set_active(map, true); } break; case NOTIFICATION_EXIT_TREE: { - NavigationServer2D::get_singleton()->map_set_active(map, false); } break; } @@ -83,7 +82,6 @@ RID Navigation2D::get_closest_point_owner(const Vector2 &p_point) const { } Navigation2D::Navigation2D() { - map = NavigationServer2D::get_singleton()->map_create(); set_cell_size(10); // Ten pixels set_edge_connection_margin(100); diff --git a/scene/2d/navigation_2d.h b/scene/2d/navigation_2d.h index 1da13fc78a..6046bddb32 100644 --- a/scene/2d/navigation_2d.h +++ b/scene/2d/navigation_2d.h @@ -35,7 +35,6 @@ #include "scene/2d/node_2d.h" class Navigation2D : public Node2D { - GDCLASS(Navigation2D, Node2D); RID map; diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index dfeb5eea45..42dabeb488 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -35,7 +35,6 @@ #include "servers/navigation_server_2d.h" void NavigationAgent2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent2D::set_target_desired_distance); ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent2D::get_target_desired_distance); @@ -91,7 +90,6 @@ void NavigationAgent2D::_bind_methods() { void NavigationAgent2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - agent_parent = Object::cast_to(get_parent()); NavigationServer2D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); @@ -120,7 +118,6 @@ void NavigationAgent2D::_notification(int p_what) { } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (agent_parent) { - NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().get_origin()); if (!target_reached) { if (distance_to_target() < target_desired_distance) { @@ -279,7 +276,6 @@ String NavigationAgent2D::get_configuration_warning() const { } void NavigationAgent2D::update_navigation() { - if (agent_parent == nullptr) return; if (navigation == nullptr) diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp index 3eb3ef332f..2352064ae6 100644 --- a/scene/2d/navigation_obstacle_2d.cpp +++ b/scene/2d/navigation_obstacle_2d.cpp @@ -36,7 +36,6 @@ #include "servers/navigation_server_2d.h" void NavigationObstacle2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationObstacle2D::set_navigation_node); ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationObstacle2D::get_navigation_node); } @@ -44,7 +43,6 @@ void NavigationObstacle2D::_bind_methods() { void NavigationObstacle2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - update_agent_shape(); // Search the navigation node and set it diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp index f3f335e66a..29f23050da 100644 --- a/scene/2d/navigation_region_2d.cpp +++ b/scene/2d/navigation_region_2d.cpp @@ -40,7 +40,6 @@ #ifdef TOOLS_ENABLED Rect2 NavigationPolygon::_edit_get_rect() const { - if (rect_cache_dirty) { item_rect = Rect2(); bool first = true; @@ -67,7 +66,6 @@ Rect2 NavigationPolygon::_edit_get_rect() const { } bool NavigationPolygon::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - for (int i = 0; i < outlines.size(); i++) { const Vector &outline = outlines[i]; const int outline_size = outline.size(); @@ -81,7 +79,6 @@ bool NavigationPolygon::_edit_is_selected_on_click(const Point2 &p_point, double #endif void NavigationPolygon::set_vertices(const Vector &p_vertices) { - { MutexLock lock(navmesh_generation); navmesh.unref(); @@ -91,12 +88,10 @@ void NavigationPolygon::set_vertices(const Vector &p_vertices) { } Vector NavigationPolygon::get_vertices() const { - return vertices; } void NavigationPolygon::_set_polygons(const TypedArray> &p_array) { - { MutexLock lock(navmesh_generation); navmesh.unref(); @@ -108,7 +103,6 @@ void NavigationPolygon::_set_polygons(const TypedArray> &p_array } Array NavigationPolygon::_get_polygons() const { - Array ret; ret.resize(polygons.size()); for (int i = 0; i < ret.size(); i++) { @@ -119,7 +113,6 @@ Array NavigationPolygon::_get_polygons() const { } void NavigationPolygon::_set_outlines(const TypedArray> &p_array) { - outlines.resize(p_array.size()); for (int i = 0; i < p_array.size(); i++) { outlines.write[i] = p_array[i]; @@ -128,7 +121,6 @@ void NavigationPolygon::_set_outlines(const TypedArray> &p_array } Array NavigationPolygon::_get_outlines() const { - Array ret; ret.resize(outlines.size()); for (int i = 0; i < ret.size(); i++) { @@ -139,7 +131,6 @@ Array NavigationPolygon::_get_outlines() const { } void NavigationPolygon::add_polygon(const Vector &p_polygon) { - Polygon polygon; polygon.indices = p_polygon; polygons.push_back(polygon); @@ -150,22 +141,18 @@ void NavigationPolygon::add_polygon(const Vector &p_polygon) { } void NavigationPolygon::add_outline_at_index(const Vector &p_outline, int p_index) { - outlines.insert(p_index, p_outline); rect_cache_dirty = true; } int NavigationPolygon::get_polygon_count() const { - return polygons.size(); } Vector NavigationPolygon::get_polygon(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, polygons.size(), Vector()); return polygons[p_idx].indices; } void NavigationPolygon::clear_polygons() { - polygons.clear(); { MutexLock lock(navmesh_generation); @@ -200,13 +187,11 @@ Ref NavigationPolygon::get_mesh() { } void NavigationPolygon::add_outline(const Vector &p_outline) { - outlines.push_back(p_outline); rect_cache_dirty = true; } int NavigationPolygon::get_outline_count() const { - return outlines.size(); } @@ -217,7 +202,6 @@ void NavigationPolygon::set_outline(int p_idx, const Vector &p_outline) } void NavigationPolygon::remove_outline(int p_idx) { - ERR_FAIL_INDEX(p_idx, outlines.size()); outlines.remove(p_idx); rect_cache_dirty = true; @@ -229,12 +213,10 @@ Vector NavigationPolygon::get_outline(int p_idx) const { } void NavigationPolygon::clear_outlines() { - outlines.clear(); rect_cache_dirty = true; } void NavigationPolygon::make_polygons_from_outlines() { - { MutexLock lock(navmesh_generation); navmesh.unref(); @@ -244,7 +226,6 @@ void NavigationPolygon::make_polygons_from_outlines() { Vector2 outside_point(-1e10, -1e10); for (int i = 0; i < outlines.size(); i++) { - Vector ol = outlines[i]; int olsize = ol.size(); if (olsize < 3) @@ -259,7 +240,6 @@ void NavigationPolygon::make_polygons_from_outlines() { outside_point += Vector2(0.7239784, 0.819238); //avoid precision issues for (int i = 0; i < outlines.size(); i++) { - Vector ol = outlines[i]; int olsize = ol.size(); if (olsize < 3) @@ -269,7 +249,6 @@ void NavigationPolygon::make_polygons_from_outlines() { int interscount = 0; //test if this is an outer outline for (int k = 0; k < outlines.size(); k++) { - if (i == k) continue; //no self intersect @@ -280,7 +259,6 @@ void NavigationPolygon::make_polygons_from_outlines() { const Vector2 *r2 = ol2.ptr(); for (int l = 0; l < olsize2; l++) { - if (Geometry::segment_intersects_segment_2d(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], nullptr)) { interscount++; } @@ -316,13 +294,11 @@ void NavigationPolygon::make_polygons_from_outlines() { Map points; for (List::Element *I = out_poly.front(); I; I = I->next()) { - TriangulatorPoly &tp = I->get(); struct Polygon p; for (int64_t i = 0; i < tp.GetNumPoints(); i++) { - Map::Element *E = points.find(tp[i]); if (!E) { E = points.insert(tp[i], vertices.size()); @@ -338,7 +314,6 @@ void NavigationPolygon::make_polygons_from_outlines() { } void NavigationPolygon::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_vertices", "vertices"), &NavigationPolygon::set_vertices); ClassDB::bind_method(D_METHOD("get_vertices"), &NavigationPolygon::get_vertices); @@ -368,7 +343,6 @@ void NavigationPolygon::_bind_methods() { } void NavigationRegion2D::set_enabled(bool p_enabled) { - if (enabled == p_enabled) return; enabled = p_enabled; @@ -377,12 +351,9 @@ void NavigationRegion2D::set_enabled(bool p_enabled) { return; if (!enabled) { - NavigationServer2D::get_singleton()->region_set_map(region, RID()); } else { - if (navigation) { - NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid()); } } @@ -392,36 +363,28 @@ void NavigationRegion2D::set_enabled(bool p_enabled) { } bool NavigationRegion2D::is_enabled() const { - return enabled; } ///////////////////////////// #ifdef TOOLS_ENABLED Rect2 NavigationRegion2D::_edit_get_rect() const { - return navpoly.is_valid() ? navpoly->_edit_get_rect() : Rect2(); } bool NavigationRegion2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - return navpoly.is_valid() ? navpoly->_edit_is_selected_on_click(p_point, p_tolerance) : false; } #endif void NavigationRegion2D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { - Node2D *c = this; while (c) { - navigation = Object::cast_to(c); if (navigation) { - if (enabled) { - NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid()); } break; @@ -432,22 +395,17 @@ void NavigationRegion2D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - NavigationServer2D::get_singleton()->region_set_transform(region, get_global_transform()); } break; case NOTIFICATION_EXIT_TREE: { - if (navigation) { - NavigationServer2D::get_singleton()->region_set_map(region, RID()); } navigation = nullptr; } break; case NOTIFICATION_DRAW: { - if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) { - Vector verts = navpoly->get_vertices(); int vsize = verts.size(); if (vsize < 3) @@ -477,10 +435,8 @@ void NavigationRegion2D::_notification(int p_what) { Vector polygon = navpoly->get_polygon(i); for (int j = 2; j < polygon.size(); j++) { - int kofs[3] = { 0, j - 1, j }; for (int k = 0; k < 3; k++) { - int idx = polygon[kofs[k]]; ERR_FAIL_INDEX(idx, vsize); indices.push_back(idx); @@ -494,7 +450,6 @@ void NavigationRegion2D::_notification(int p_what) { } void NavigationRegion2D::set_navigation_polygon(const Ref &p_navpoly) { - if (p_navpoly == navpoly) { return; } @@ -516,18 +471,15 @@ void NavigationRegion2D::set_navigation_polygon(const Ref &p_ } Ref NavigationRegion2D::get_navigation_polygon() const { - return navpoly; } void NavigationRegion2D::_navpoly_changed() { - if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())) update(); } String NavigationRegion2D::get_configuration_warning() const { - if (!is_visible_in_tree() || !is_inside_tree()) return String(); @@ -536,7 +488,6 @@ String NavigationRegion2D::get_configuration_warning() const { } const Node2D *c = this; while (c) { - if (Object::cast_to(c)) { return String(); } @@ -548,7 +499,6 @@ String NavigationRegion2D::get_configuration_warning() const { } void NavigationRegion2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_navigation_polygon", "navpoly"), &NavigationRegion2D::set_navigation_polygon); ClassDB::bind_method(D_METHOD("get_navigation_polygon"), &NavigationRegion2D::get_navigation_polygon); diff --git a/scene/2d/navigation_region_2d.h b/scene/2d/navigation_region_2d.h index 54d2ac11f8..07cf4d6668 100644 --- a/scene/2d/navigation_region_2d.h +++ b/scene/2d/navigation_region_2d.h @@ -35,7 +35,6 @@ #include "scene/resources/navigation_mesh.h" class NavigationPolygon : public Resource { - GDCLASS(NavigationPolygon, Resource); Vector vertices; @@ -95,7 +94,6 @@ public: class Navigation2D; class NavigationRegion2D : public Node2D { - GDCLASS(NavigationRegion2D, Node2D); bool enabled = true; diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 1ea51be148..b500266620 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -37,7 +37,6 @@ #ifdef TOOLS_ENABLED Dictionary Node2D::_edit_get_state() const { - Dictionary state; state["position"] = get_position(); state["rotation"] = get_rotation(); @@ -48,7 +47,6 @@ Dictionary Node2D::_edit_get_state() const { } void Node2D::_edit_set_state(const Dictionary &p_state) { - pos = p_state["position"]; angle = p_state["rotation"]; _scale = p_state["scale"]; @@ -128,7 +126,6 @@ void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) { #endif void Node2D::_update_xform_values() { - pos = _mat.elements[2]; angle = _mat.get_rotation(); _scale = _mat.get_scale(); @@ -137,7 +134,6 @@ void Node2D::_update_xform_values() { } void Node2D::_update_transform() { - _mat.set_rotation_scale_and_skew(angle, _scale, skew); _mat.elements[2] = pos; @@ -150,7 +146,6 @@ void Node2D::_update_transform() { } void Node2D::set_position(const Point2 &p_pos) { - if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); pos = p_pos; @@ -159,7 +154,6 @@ void Node2D::set_position(const Point2 &p_pos) { } void Node2D::set_rotation(float p_radians) { - if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); angle = p_radians; @@ -169,7 +163,6 @@ void Node2D::set_rotation(float p_radians) { } void Node2D::set_skew(float p_radians) { - if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); skew = p_radians; @@ -179,17 +172,14 @@ void Node2D::set_skew(float p_radians) { } void Node2D::set_rotation_degrees(float p_degrees) { - set_rotation(Math::deg2rad(p_degrees)); } void Node2D::set_skew_degrees(float p_degrees) { - set_skew(Math::deg2rad(p_degrees)); } void Node2D::set_scale(const Size2 &p_scale) { - if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); _scale = p_scale; @@ -203,7 +193,6 @@ void Node2D::set_scale(const Size2 &p_scale) { } Point2 Node2D::get_position() const { - if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); return pos; @@ -224,12 +213,10 @@ float Node2D::get_skew() const { } float Node2D::get_rotation_degrees() const { - return Math::rad2deg(get_rotation()); } float Node2D::get_skew_degrees() const { - return Math::rad2deg(get_skew()); } Size2 Node2D::get_scale() const { @@ -240,32 +227,26 @@ Size2 Node2D::get_scale() const { } Transform2D Node2D::get_transform() const { - return _mat; } void Node2D::rotate(float p_radians) { - set_rotation(get_rotation() + p_radians); } void Node2D::translate(const Vector2 &p_amount) { - set_position(get_position() + p_amount); } void Node2D::global_translate(const Vector2 &p_amount) { - set_global_position(get_global_position() + p_amount); } void Node2D::apply_scale(const Size2 &p_amount) { - set_scale(get_scale() * p_amount); } void Node2D::move_x(float p_delta, bool p_scaled) { - Transform2D t = get_transform(); Vector2 m = t[0]; if (!p_scaled) @@ -274,7 +255,6 @@ void Node2D::move_x(float p_delta, bool p_scaled) { } void Node2D::move_y(float p_delta, bool p_scaled) { - Transform2D t = get_transform(); Vector2 m = t[1]; if (!p_scaled) @@ -283,12 +263,10 @@ void Node2D::move_y(float p_delta, bool p_scaled) { } Point2 Node2D::get_global_position() const { - return get_global_transform().get_origin(); } void Node2D::set_global_position(const Point2 &p_pos) { - Transform2D inv; CanvasItem *pi = get_parent_item(); if (pi) { @@ -300,12 +278,10 @@ void Node2D::set_global_position(const Point2 &p_pos) { } float Node2D::get_global_rotation() const { - return get_global_transform().get_rotation(); } void Node2D::set_global_rotation(float p_radians) { - CanvasItem *pi = get_parent_item(); if (pi) { const float parent_global_rot = pi->get_global_transform().get_rotation(); @@ -316,22 +292,18 @@ void Node2D::set_global_rotation(float p_radians) { } float Node2D::get_global_rotation_degrees() const { - return Math::rad2deg(get_global_rotation()); } void Node2D::set_global_rotation_degrees(float p_degrees) { - set_global_rotation(Math::deg2rad(p_degrees)); } Size2 Node2D::get_global_scale() const { - return get_global_transform().get_scale(); } void Node2D::set_global_scale(const Size2 &p_scale) { - CanvasItem *pi = get_parent_item(); if (pi) { const Size2 parent_global_scale = pi->get_global_transform().get_scale(); @@ -342,7 +314,6 @@ void Node2D::set_global_scale(const Size2 &p_scale) { } void Node2D::set_transform(const Transform2D &p_transform) { - _mat = p_transform; _xform_dirty = true; @@ -355,7 +326,6 @@ void Node2D::set_transform(const Transform2D &p_transform) { } void Node2D::set_global_transform(const Transform2D &p_transform) { - CanvasItem *pi = get_parent_item(); if (pi) set_transform(pi->get_global_transform().affine_inverse() * p_transform); @@ -364,7 +334,6 @@ void Node2D::set_global_transform(const Transform2D &p_transform) { } void Node2D::set_z_index(int p_z) { - ERR_FAIL_COND(p_z < RS::CANVAS_ITEM_Z_MIN); ERR_FAIL_COND(p_z > RS::CANVAS_ITEM_Z_MAX); z_index = p_z; @@ -373,7 +342,6 @@ void Node2D::set_z_index(int p_z) { } void Node2D::set_z_as_relative(bool p_enabled) { - if (z_relative == p_enabled) return; z_relative = p_enabled; @@ -381,17 +349,14 @@ void Node2D::set_z_as_relative(bool p_enabled) { } bool Node2D::is_z_relative() const { - return z_relative; } int Node2D::get_z_index() const { - return z_index; } Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const { - if (p_parent == this) return Transform2D(); @@ -405,27 +370,22 @@ Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const } void Node2D::look_at(const Vector2 &p_pos) { - rotate(get_angle_to(p_pos)); } float Node2D::get_angle_to(const Vector2 &p_pos) const { - return (to_local(p_pos) * get_scale()).angle(); } Point2 Node2D::to_local(Point2 p_global) const { - return get_global_transform().affine_inverse().xform(p_global); } Point2 Node2D::to_global(Point2 p_local) const { - return get_global_transform().xform(p_local); } void Node2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation); ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees); @@ -494,7 +454,6 @@ void Node2D::_bind_methods() { } Node2D::Node2D() { - angle = 0; _scale = Vector2(1, 1); skew = 0; diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index 0afec36254..827c192585 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -34,7 +34,6 @@ #include "scene/main/canvas_item.h" class Node2D : public CanvasItem { - GDCLASS(Node2D, CanvasItem); Point2 pos; diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp index 0d5f74a265..6930307840 100644 --- a/scene/2d/parallax_background.cpp +++ b/scene/2d/parallax_background.cpp @@ -32,24 +32,19 @@ #include "parallax_layer.h" void ParallaxBackground::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - group_name = "__cameras_" + itos(get_viewport().get_id()); add_to_group(group_name); } break; case NOTIFICATION_EXIT_TREE: { - remove_from_group(group_name); } break; } } void ParallaxBackground::_camera_moved(const Transform2D &p_transform, const Point2 &p_screen_offset) { - screen_offset = p_screen_offset; set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5, 0.5))); @@ -57,24 +52,20 @@ void ParallaxBackground::_camera_moved(const Transform2D &p_transform, const Poi } void ParallaxBackground::set_scroll_scale(float p_scale) { - scale = p_scale; } float ParallaxBackground::get_scroll_scale() const { - return scale; } void ParallaxBackground::set_scroll_offset(const Point2 &p_ofs) { - offset = p_ofs; _update_scroll(); } void ParallaxBackground::_update_scroll() { - if (!is_inside_tree()) return; @@ -84,7 +75,6 @@ void ParallaxBackground::_update_scroll() { ofs = -ofs; if (limit_begin.x < limit_end.x) { - if (ofs.x < limit_begin.x) ofs.x = limit_begin.x; else if (ofs.x + vps.x > limit_end.x) @@ -92,7 +82,6 @@ void ParallaxBackground::_update_scroll() { } if (limit_begin.y < limit_end.y) { - if (ofs.y < limit_begin.y) ofs.y = limit_begin.y; else if (ofs.y + vps.y > limit_end.y) @@ -103,7 +92,6 @@ void ParallaxBackground::_update_scroll() { final_offset = ofs; for (int i = 0; i < get_child_count(); i++) { - ParallaxLayer *l = Object::cast_to(get_child(i)); if (!l) continue; @@ -116,71 +104,58 @@ void ParallaxBackground::_update_scroll() { } Point2 ParallaxBackground::get_scroll_offset() const { - return offset; } void ParallaxBackground::set_scroll_base_offset(const Point2 &p_ofs) { - base_offset = p_ofs; _update_scroll(); } Point2 ParallaxBackground::get_scroll_base_offset() const { - return base_offset; } void ParallaxBackground::set_scroll_base_scale(const Point2 &p_ofs) { - base_scale = p_ofs; _update_scroll(); } Point2 ParallaxBackground::get_scroll_base_scale() const { - return base_scale; } void ParallaxBackground::set_limit_begin(const Point2 &p_ofs) { - limit_begin = p_ofs; _update_scroll(); } Point2 ParallaxBackground::get_limit_begin() const { - return limit_begin; } void ParallaxBackground::set_limit_end(const Point2 &p_ofs) { - limit_end = p_ofs; _update_scroll(); } Point2 ParallaxBackground::get_limit_end() const { - return limit_end; } void ParallaxBackground::set_ignore_camera_zoom(bool ignore) { - ignore_camera_zoom = ignore; } bool ParallaxBackground::is_ignore_camera_zoom() { - return ignore_camera_zoom; } Vector2 ParallaxBackground::get_final_offset() const { - return final_offset; } void ParallaxBackground::_bind_methods() { - ClassDB::bind_method(D_METHOD("_camera_moved"), &ParallaxBackground::_camera_moved); ClassDB::bind_method(D_METHOD("set_scroll_offset", "ofs"), &ParallaxBackground::set_scroll_offset); ClassDB::bind_method(D_METHOD("get_scroll_offset"), &ParallaxBackground::get_scroll_offset); @@ -205,7 +180,6 @@ void ParallaxBackground::_bind_methods() { } ParallaxBackground::ParallaxBackground() { - scale = 1.0; set_layer(-100); //behind all by default diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h index 25ccd910d1..1667880ddb 100644 --- a/scene/2d/parallax_background.h +++ b/scene/2d/parallax_background.h @@ -36,7 +36,6 @@ #include "scene/main/canvas_layer.h" class ParallaxBackground : public CanvasLayer { - GDCLASS(ParallaxBackground, CanvasLayer); Point2 offset; diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index 181f0f158c..ffc6e50da2 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -34,7 +34,6 @@ #include "parallax_background.h" void ParallaxLayer::set_motion_scale(const Size2 &p_scale) { - motion_scale = p_scale; ParallaxBackground *pb = Object::cast_to(get_parent()); @@ -46,12 +45,10 @@ void ParallaxLayer::set_motion_scale(const Size2 &p_scale) { } Size2 ParallaxLayer::get_motion_scale() const { - return motion_scale; } void ParallaxLayer::set_motion_offset(const Size2 &p_offset) { - motion_offset = p_offset; ParallaxBackground *pb = Object::cast_to(get_parent()); @@ -63,18 +60,15 @@ void ParallaxLayer::set_motion_offset(const Size2 &p_offset) { } Size2 ParallaxLayer::get_motion_offset() const { - return motion_offset; } void ParallaxLayer::_update_mirroring() { - if (!is_inside_tree()) return; ParallaxBackground *pb = Object::cast_to(get_parent()); if (pb) { - RID c = pb->get_canvas(); RID ci = get_canvas_item(); Point2 mirrorScale = mirroring * get_scale(); @@ -83,7 +77,6 @@ void ParallaxLayer::_update_mirroring() { } void ParallaxLayer::set_mirroring(const Size2 &p_mirroring) { - mirroring = p_mirroring; if (mirroring.x < 0) mirroring.x = 0; @@ -94,22 +87,17 @@ void ParallaxLayer::set_mirroring(const Size2 &p_mirroring) { } Size2 ParallaxLayer::get_mirroring() const { - return mirroring; } void ParallaxLayer::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - orig_offset = get_position(); orig_scale = get_scale(); _update_mirroring(); } break; case NOTIFICATION_EXIT_TREE: { - set_position(orig_offset); set_scale(orig_scale); } break; @@ -143,7 +131,6 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_sc } String ParallaxLayer::get_configuration_warning() const { - if (!Object::cast_to(get_parent())) { return TTR("ParallaxLayer node only works when set as child of a ParallaxBackground node."); } @@ -152,7 +139,6 @@ String ParallaxLayer::get_configuration_warning() const { } void ParallaxLayer::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_motion_scale", "scale"), &ParallaxLayer::set_motion_scale); ClassDB::bind_method(D_METHOD("get_motion_scale"), &ParallaxLayer::get_motion_scale); ClassDB::bind_method(D_METHOD("set_motion_offset", "offset"), &ParallaxLayer::set_motion_offset); diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h index ba59184649..1f001943b5 100644 --- a/scene/2d/parallax_layer.h +++ b/scene/2d/parallax_layer.h @@ -34,7 +34,6 @@ #include "scene/2d/node_2d.h" class ParallaxLayer : public Node2D { - GDCLASS(ParallaxLayer, Node2D); Point2 orig_offset; diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 149d5c6b0d..a914da8fe0 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -39,16 +39,13 @@ #ifdef TOOLS_ENABLED Rect2 Path2D::_edit_get_rect() const { - if (!curve.is_valid() || curve->get_point_count() == 0) return Rect2(0, 0, 0, 0); Rect2 aabb = Rect2(curve->get_point_position(0), Vector2(0, 0)); for (int i = 0; i < curve->get_point_count(); i++) { - for (int j = 0; j <= 8; j++) { - real_t frac = j / 8.0; Vector2 p = curve->interpolate(i, frac); aabb.expand_to(p); @@ -63,7 +60,6 @@ bool Path2D::_edit_use_rect() const { } bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - if (curve.is_null()) { return false; } @@ -89,7 +85,6 @@ bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc #endif void Path2D::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW && curve.is_valid()) { //draw the curve!! @@ -105,11 +100,9 @@ void Path2D::_notification(int p_what) { const Color color = Color(0.5, 0.6, 1.0, 0.7); for (int i = 0; i < curve->get_point_count(); i++) { - Vector2 prev_p = curve->get_point_position(i); for (int j = 1; j <= 8; j++) { - real_t frac = j / 8.0; Vector2 p = curve->interpolate(i, frac); draw_line(prev_p, p, color, line_width); @@ -132,7 +125,6 @@ void Path2D::_curve_changed() { } void Path2D::set_curve(const Ref &p_curve) { - if (curve.is_valid()) { curve->disconnect("changed", callable_mp(this, &Path2D::_curve_changed)); } @@ -147,12 +139,10 @@ void Path2D::set_curve(const Ref &p_curve) { } Ref Path2D::get_curve() const { - return curve; } void Path2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path2D::set_curve); ClassDB::bind_method(D_METHOD("get_curve"), &Path2D::get_curve); @@ -160,14 +150,12 @@ void Path2D::_bind_methods() { } Path2D::Path2D() { - set_curve(Ref(memnew(Curve2D))); //create one by default } ///////////////////////////////////////////////////////////////////////////////// void PathFollow2D::_update_transform() { - if (!path) return; @@ -219,7 +207,6 @@ void PathFollow2D::_update_transform() { set_rotation(tangent_to_curve.angle()); } else { - pos.x += h_offset; pos.y += v_offset; } @@ -228,11 +215,8 @@ void PathFollow2D::_update_transform() { } void PathFollow2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - path = Object::cast_to(get_parent()); if (path) { _update_transform(); @@ -240,26 +224,21 @@ void PathFollow2D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - path = nullptr; } break; } } void PathFollow2D::set_cubic_interpolation(bool p_enable) { - cubic = p_enable; } bool PathFollow2D::get_cubic_interpolation() const { - return cubic; } void PathFollow2D::_validate_property(PropertyInfo &property) const { - if (property.name == "offset") { - float max = 10000; if (path && path->get_curve().is_valid()) max = path->get_curve()->get_baked_length(); @@ -269,7 +248,6 @@ void PathFollow2D::_validate_property(PropertyInfo &property) const { } String PathFollow2D::get_configuration_warning() const { - if (!is_visible_in_tree() || !is_inside_tree()) return String(); @@ -281,7 +259,6 @@ String PathFollow2D::get_configuration_warning() const { } void PathFollow2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_offset", "offset"), &PathFollow2D::set_offset); ClassDB::bind_method(D_METHOD("get_offset"), &PathFollow2D::get_offset); @@ -317,7 +294,6 @@ void PathFollow2D::_bind_methods() { } void PathFollow2D::set_offset(float p_offset) { - offset = p_offset; if (path) { if (path->get_curve().is_valid()) { @@ -340,42 +316,35 @@ void PathFollow2D::set_offset(float p_offset) { } void PathFollow2D::set_h_offset(float p_h_offset) { - h_offset = p_h_offset; if (path) _update_transform(); } float PathFollow2D::get_h_offset() const { - return h_offset; } void PathFollow2D::set_v_offset(float p_v_offset) { - v_offset = p_v_offset; if (path) _update_transform(); } float PathFollow2D::get_v_offset() const { - return v_offset; } float PathFollow2D::get_offset() const { - return offset; } void PathFollow2D::set_unit_offset(float p_unit_offset) { - if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) set_offset(p_unit_offset * path->get_curve()->get_baked_length()); } float PathFollow2D::get_unit_offset() const { - if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) return get_offset() / path->get_curve()->get_baked_length(); else @@ -383,38 +352,31 @@ float PathFollow2D::get_unit_offset() const { } void PathFollow2D::set_lookahead(float p_lookahead) { - lookahead = p_lookahead; } float PathFollow2D::get_lookahead() const { - return lookahead; } void PathFollow2D::set_rotate(bool p_rotate) { - rotate = p_rotate; _update_transform(); } bool PathFollow2D::is_rotating() const { - return rotate; } void PathFollow2D::set_loop(bool p_loop) { - loop = p_loop; } bool PathFollow2D::has_loop() const { - return loop; } PathFollow2D::PathFollow2D() { - offset = 0; h_offset = 0; v_offset = 0; diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h index 35cf8211f4..288ef698e7 100644 --- a/scene/2d/path_2d.h +++ b/scene/2d/path_2d.h @@ -35,7 +35,6 @@ #include "scene/resources/curve.h" class Path2D : public Node2D { - GDCLASS(Path2D, Node2D); Ref curve; @@ -60,7 +59,6 @@ public: }; class PathFollow2D : public Node2D { - GDCLASS(PathFollow2D, Node2D); public: diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 4198eb6c06..23da6ced5b 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -43,18 +43,15 @@ void PhysicsBody2D::_notification(int p_what) { } void PhysicsBody2D::_set_layers(uint32_t p_mask) { - set_collision_layer(p_mask); set_collision_mask(p_mask); } uint32_t PhysicsBody2D::_get_layers() const { - return get_collision_layer(); } void PhysicsBody2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsBody2D::set_collision_layer); ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsBody2D::get_collision_layer); ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsBody2D::set_collision_mask); @@ -80,29 +77,24 @@ void PhysicsBody2D::_bind_methods() { } void PhysicsBody2D::set_collision_layer(uint32_t p_layer) { - collision_layer = p_layer; PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), p_layer); } uint32_t PhysicsBody2D::get_collision_layer() const { - return collision_layer; } void PhysicsBody2D::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), p_mask); } uint32_t PhysicsBody2D::get_collision_mask() const { - return collision_mask; } void PhysicsBody2D::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -111,12 +103,10 @@ void PhysicsBody2D::set_collision_mask_bit(int p_bit, bool p_value) { set_collision_mask(mask); } bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } void PhysicsBody2D::set_collision_layer_bit(int p_bit, bool p_value) { - uint32_t collision_layer = get_collision_layer(); if (p_value) collision_layer |= 1 << p_bit; @@ -126,13 +116,11 @@ void PhysicsBody2D::set_collision_layer_bit(int p_bit, bool p_value) { } bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const { - return get_collision_layer() & (1 << p_bit); } PhysicsBody2D::PhysicsBody2D(PhysicsServer2D::BodyMode p_mode) : CollisionObject2D(PhysicsServer2D::get_singleton()->body_create(), false) { - PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), p_mode); collision_layer = 1; collision_mask = 1; @@ -154,7 +142,6 @@ TypedArray PhysicsBody2D::get_collision_exceptions() { } void PhysicsBody2D::add_collision_exception_with(Node *p_node) { - ERR_FAIL_NULL(p_node); PhysicsBody2D *physics_body = Object::cast_to(p_node); ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody2D type."); @@ -162,7 +149,6 @@ void PhysicsBody2D::add_collision_exception_with(Node *p_node) { } void PhysicsBody2D::remove_collision_exception_with(Node *p_node) { - ERR_FAIL_NULL(p_node); PhysicsBody2D *physics_body = Object::cast_to(p_node); ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody2D type."); @@ -170,23 +156,19 @@ void PhysicsBody2D::remove_collision_exception_with(Node *p_node) { } void StaticBody2D::set_constant_linear_velocity(const Vector2 &p_vel) { - constant_linear_velocity = p_vel; PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity); } void StaticBody2D::set_constant_angular_velocity(real_t p_vel) { - constant_angular_velocity = p_vel; PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity); } Vector2 StaticBody2D::get_constant_linear_velocity() const { - return constant_linear_velocity; } real_t StaticBody2D::get_constant_angular_velocity() const { - return constant_angular_velocity; } @@ -210,7 +192,6 @@ Ref StaticBody2D::get_physics_material_override() const { } void StaticBody2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "vel"), &StaticBody2D::set_constant_linear_velocity); ClassDB::bind_method(D_METHOD("set_constant_angular_velocity", "vel"), &StaticBody2D::set_constant_angular_velocity); ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody2D::get_constant_linear_velocity); @@ -226,7 +207,6 @@ void StaticBody2D::_bind_methods() { StaticBody2D::StaticBody2D() : PhysicsBody2D(PhysicsServer2D::BODY_MODE_STATIC) { - constant_angular_velocity = 0; } @@ -244,7 +224,6 @@ void StaticBody2D::_reload_physics_characteristics() { } void RigidBody2D::_body_enter_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -260,7 +239,6 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) { emit_signal(SceneStringNames::get_singleton()->body_entered, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape); } @@ -268,7 +246,6 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) { } void RigidBody2D::_body_exit_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -283,7 +260,6 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) { emit_signal(SceneStringNames::get_singleton()->body_exited, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape); } @@ -291,7 +267,6 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) { } void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) { - bool body_in = p_status == 1; ObjectID objid = p_instance; @@ -305,7 +280,6 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap if (body_in) { if (!E) { - E = contact_monitor->body_map.insert(objid, BodyState()); //E->get().rc=0; E->get().in_scene = node && node->is_inside_tree(); @@ -328,7 +302,6 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap } } else { - //E->get().rc--; if (node) @@ -337,7 +310,6 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap bool in_scene = E->get().in_scene; if (E->get().shapes.empty()) { - if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody2D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody2D::_body_exit_tree)); @@ -354,14 +326,12 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap } struct _RigidBody2DInOut { - ObjectID id; int shape; int local_shape; }; bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref &p_result) { - PhysicsServer2D::MotionResult *r = nullptr; if (p_result.is_valid()) r = p_result->get_result_ptr(); @@ -369,7 +339,6 @@ bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, } void RigidBody2D::_direct_state_changed(Object *p_state) { - #ifdef DEBUG_ENABLED state = Object::cast_to(p_state); #else @@ -390,15 +359,12 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { set_block_transform_notify(false); // want it back if (contact_monitor) { - contact_monitor->locked = true; //untag all int rc = 0; for (Map::Element *E = contact_monitor->body_map.front(); E; E = E->next()) { - for (int i = 0; i < E->get().shapes.size(); i++) { - E->get().shapes[i].tagged = false; rc++; } @@ -412,7 +378,6 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { //put the ones to add for (int i = 0; i < state->get_contact_count(); i++) { - ObjectID obj = state->get_contact_collider_id(i); int local_shape = state->get_contact_local_shape(i); int shape = state->get_contact_collider_shape(i); @@ -431,7 +396,6 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { ShapePair sp(shape, local_shape); int idx = E->get().shapes.find(sp); if (idx == -1) { - toadd[toadd_count].local_shape = local_shape; toadd[toadd_count].id = obj; toadd[toadd_count].shape = shape; @@ -445,11 +409,8 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { //put the ones to remove for (Map::Element *E = contact_monitor->body_map.front(); E; E = E->next()) { - for (int i = 0; i < E->get().shapes.size(); i++) { - if (!E->get().shapes[i].tagged) { - toremove[toremove_count].body_id = E->key(); toremove[toremove_count].pair = E->get().shapes[i]; toremove_count++; @@ -460,14 +421,12 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { //process remotions for (int i = 0; i < toremove_count; i++) { - _body_inout(0, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape); } //process aditions for (int i = 0; i < toadd_count; i++) { - _body_inout(1, toadd[i].id, toadd[i].shape, toadd[i].local_shape); } @@ -478,21 +437,16 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { } void RigidBody2D::set_mode(Mode p_mode) { - mode = p_mode; switch (p_mode) { - case MODE_RIGID: { - PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_RIGID); } break; case MODE_STATIC: { - PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_STATIC); } break; case MODE_KINEMATIC: { - PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_KINEMATIC); } break; @@ -504,12 +458,10 @@ void RigidBody2D::set_mode(Mode p_mode) { } RigidBody2D::Mode RigidBody2D::get_mode() const { - return mode; } void RigidBody2D::set_mass(real_t p_mass) { - ERR_FAIL_COND(p_mass <= 0); mass = p_mass; _change_notify("mass"); @@ -517,28 +469,23 @@ void RigidBody2D::set_mass(real_t p_mass) { PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_MASS, mass); } real_t RigidBody2D::get_mass() const { - return mass; } void RigidBody2D::set_inertia(real_t p_inertia) { - ERR_FAIL_COND(p_inertia < 0); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA, p_inertia); } real_t RigidBody2D::get_inertia() const { - return PhysicsServer2D::get_singleton()->body_get_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA); } void RigidBody2D::set_weight(real_t p_weight) { - set_mass(p_weight / (real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10)); } real_t RigidBody2D::get_weight() const { - return mass * (real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10); } @@ -562,39 +509,32 @@ Ref RigidBody2D::get_physics_material_override() const { } void RigidBody2D::set_gravity_scale(real_t p_gravity_scale) { - gravity_scale = p_gravity_scale; PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE, gravity_scale); } real_t RigidBody2D::get_gravity_scale() const { - return gravity_scale; } void RigidBody2D::set_linear_damp(real_t p_linear_damp) { - ERR_FAIL_COND(p_linear_damp < -1); linear_damp = p_linear_damp; PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP, linear_damp); } real_t RigidBody2D::get_linear_damp() const { - return linear_damp; } void RigidBody2D::set_angular_damp(real_t p_angular_damp) { - ERR_FAIL_COND(p_angular_damp < -1); angular_damp = p_angular_damp; PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP, angular_damp); } real_t RigidBody2D::get_angular_damp() const { - return angular_damp; } void RigidBody2D::set_axis_velocity(const Vector2 &p_axis) { - Vector2 v = state ? state->get_linear_velocity() : linear_velocity; Vector2 axis = p_axis.normalized(); v -= axis * axis.dot(v); @@ -608,23 +548,19 @@ void RigidBody2D::set_axis_velocity(const Vector2 &p_axis) { } void RigidBody2D::set_linear_velocity(const Vector2 &p_velocity) { - linear_velocity = p_velocity; if (state) state->set_linear_velocity(linear_velocity); else { - PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity); } } Vector2 RigidBody2D::get_linear_velocity() const { - return linear_velocity; } void RigidBody2D::set_angular_velocity(real_t p_velocity) { - angular_velocity = p_velocity; if (state) state->set_angular_velocity(angular_velocity); @@ -632,12 +568,10 @@ void RigidBody2D::set_angular_velocity(real_t p_velocity) { PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity); } real_t RigidBody2D::get_angular_velocity() const { - return angular_velocity; } void RigidBody2D::set_use_custom_integrator(bool p_enable) { - if (custom_integrator == p_enable) return; @@ -645,40 +579,33 @@ void RigidBody2D::set_use_custom_integrator(bool p_enable) { PhysicsServer2D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable); } bool RigidBody2D::is_using_custom_integrator() { - return custom_integrator; } void RigidBody2D::set_sleeping(bool p_sleeping) { - sleeping = p_sleeping; PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_SLEEPING, sleeping); } void RigidBody2D::set_can_sleep(bool p_active) { - can_sleep = p_active; PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_CAN_SLEEP, p_active); } bool RigidBody2D::is_able_to_sleep() const { - return can_sleep; } bool RigidBody2D::is_sleeping() const { - return sleeping; } void RigidBody2D::set_max_contacts_reported(int p_amount) { - max_contacts_reported = p_amount; PhysicsServer2D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount); } int RigidBody2D::get_max_contacts_reported() const { - return max_contacts_reported; } @@ -687,7 +614,6 @@ void RigidBody2D::apply_central_impulse(const Vector2 &p_impulse) { } void RigidBody2D::apply_impulse(const Vector2 &p_offset, const Vector2 &p_impulse) { - PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_offset, p_impulse); } @@ -696,22 +622,18 @@ void RigidBody2D::apply_torque_impulse(float p_torque) { } void RigidBody2D::set_applied_force(const Vector2 &p_force) { - PhysicsServer2D::get_singleton()->body_set_applied_force(get_rid(), p_force); }; Vector2 RigidBody2D::get_applied_force() const { - return PhysicsServer2D::get_singleton()->body_get_applied_force(get_rid()); }; void RigidBody2D::set_applied_torque(const float p_torque) { - PhysicsServer2D::get_singleton()->body_set_applied_torque(get_rid(), p_torque); }; float RigidBody2D::get_applied_torque() const { - return PhysicsServer2D::get_singleton()->body_get_applied_torque(get_rid()); }; @@ -720,7 +642,6 @@ void RigidBody2D::add_central_force(const Vector2 &p_force) { } void RigidBody2D::add_force(const Vector2 &p_offset, const Vector2 &p_force) { - PhysicsServer2D::get_singleton()->body_add_force(get_rid(), p_offset, p_force); } @@ -729,18 +650,15 @@ void RigidBody2D::add_torque(const float p_torque) { } void RigidBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) { - ccd_mode = p_mode; PhysicsServer2D::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), PhysicsServer2D::CCDMode(p_mode)); } RigidBody2D::CCDMode RigidBody2D::get_continuous_collision_detection_mode() const { - return ccd_mode; } TypedArray RigidBody2D::get_colliding_bodies() const { - ERR_FAIL_COND_V(!contact_monitor, Array()); TypedArray ret; @@ -759,16 +677,13 @@ TypedArray RigidBody2D::get_colliding_bodies() const { } void RigidBody2D::set_contact_monitor(bool p_enabled) { - if (p_enabled == is_contact_monitor_enabled()) return; if (!p_enabled) { - ERR_FAIL_COND_MSG(contact_monitor->locked, "Can't disable contact monitoring during in/out callback. Use call_deferred(\"set_contact_monitor\", false) instead."); for (Map::Element *E = contact_monitor->body_map.front(); E; E = E->next()) { - //clean up mess Object *obj = ObjectDB::get_instance(E->key()); Node *node = Object::cast_to(obj); @@ -782,19 +697,16 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) { memdelete(contact_monitor); contact_monitor = nullptr; } else { - contact_monitor = memnew(ContactMonitor); contact_monitor->locked = false; } } bool RigidBody2D::is_contact_monitor_enabled() const { - return contact_monitor != nullptr; } void RigidBody2D::_notification(int p_what) { - #ifdef TOOLS_ENABLED if (p_what == NOTIFICATION_ENTER_TREE) { if (Engine::get_singleton()->is_editor_hint()) { @@ -812,7 +724,6 @@ void RigidBody2D::_notification(int p_what) { } String RigidBody2D::get_configuration_warning() const { - Transform2D t = get_transform(); String warning = CollisionObject2D::get_configuration_warning(); @@ -828,7 +739,6 @@ String RigidBody2D::get_configuration_warning() const { } void RigidBody2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody2D::set_mode); ClassDB::bind_method(D_METHOD("get_mode"), &RigidBody2D::get_mode); @@ -940,7 +850,6 @@ void RigidBody2D::_bind_methods() { RigidBody2D::RigidBody2D() : PhysicsBody2D(PhysicsServer2D::BODY_MODE_RIGID) { - mode = MODE_RIGID; mass = 1; @@ -964,7 +873,6 @@ RigidBody2D::RigidBody2D() : } RigidBody2D::~RigidBody2D() { - if (contact_monitor) memdelete(contact_monitor); } @@ -982,7 +890,6 @@ void RigidBody2D::_reload_physics_characteristics() { ////////////////////////// Ref KinematicBody2D::_move(const Vector2 &p_motion, bool p_infinite_inertia, bool p_exclude_raycast_shapes, bool p_test_only) { - Collision col; if (move_and_collide(p_motion, p_infinite_inertia, col, p_exclude_raycast_shapes, p_test_only)) { @@ -1000,7 +907,6 @@ Ref KinematicBody2D::_move(const Vector2 &p_motion, bool p } bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision) { - PhysicsServer2D::SeparationResult sep_res[8]; //max 8 rays Transform2D gt = get_global_transform(); @@ -1037,7 +943,6 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision } bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_inertia, Collision &r_collision, bool p_exclude_raycast_shapes, bool p_test_only) { - if (sync_to_physics) { ERR_PRINT("Functions move_and_slide and move_and_collide do not work together with 'sync to physics' option. Please read the documentation."); } @@ -1070,7 +975,6 @@ bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_ #define FLOOR_ANGLE_THRESHOLD 0.01 Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) { - Vector2 body_velocity = p_linear_velocity; Vector2 body_velocity_normal = body_velocity.normalized(); @@ -1095,7 +999,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const floor_velocity = Vector2(); while (p_max_slides) { - Collision collision; bool found_collision = false; @@ -1161,7 +1064,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const } Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) { - bool was_on_floor = on_floor; Vector2 ret = move_and_slide(p_linear_velocity, p_up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia); @@ -1201,47 +1103,38 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci } bool KinematicBody2D::is_on_floor() const { - return on_floor; } bool KinematicBody2D::is_on_wall() const { - return on_wall; } bool KinematicBody2D::is_on_ceiling() const { - return on_ceiling; } Vector2 KinematicBody2D::get_floor_normal() const { - return floor_normal; } Vector2 KinematicBody2D::get_floor_velocity() const { - return floor_velocity; } bool KinematicBody2D::test_move(const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia) { - ERR_FAIL_COND_V(!is_inside_tree(), false); return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia, margin); } void KinematicBody2D::set_safe_margin(float p_margin) { - margin = p_margin; } float KinematicBody2D::get_safe_margin() const { - return margin; } int KinematicBody2D::get_slide_count() const { - return colliders.size(); } @@ -1251,7 +1144,6 @@ KinematicBody2D::Collision KinematicBody2D::get_slide_collision(int p_bounce) co } Ref KinematicBody2D::_get_slide_collision(int p_bounce) { - ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref()); if (p_bounce >= slide_colliders.size()) { slide_colliders.resize(p_bounce + 1); @@ -1267,7 +1159,6 @@ Ref KinematicBody2D::_get_slide_collision(int p_bounce) { } void KinematicBody2D::set_sync_to_physics(bool p_enable) { - if (sync_to_physics == p_enable) { return; } @@ -1292,7 +1183,6 @@ bool KinematicBody2D::is_sync_to_physics_enabled() const { } void KinematicBody2D::_direct_state_changed(Object *p_state) { - if (!sync_to_physics) return; @@ -1328,7 +1218,6 @@ void KinematicBody2D::_notification(int p_what) { } } void KinematicBody2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody2D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false)); ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true)); ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true)); @@ -1358,7 +1247,6 @@ void KinematicBody2D::_bind_methods() { KinematicBody2D::KinematicBody2D() : PhysicsBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) { - margin = 0.08; on_floor = false; @@ -1381,7 +1269,6 @@ KinematicBody2D::~KinematicBody2D() { //////////////////////// Vector2 KinematicCollision2D::get_position() const { - return collision.collision; } Vector2 KinematicCollision2D::get_normal() const { @@ -1401,7 +1288,6 @@ Object *KinematicCollision2D::get_local_shape() const { } Object *KinematicCollision2D::get_collider() const { - if (collision.collider.is_valid()) { return ObjectDB::get_instance(collision.collider); } @@ -1409,11 +1295,9 @@ Object *KinematicCollision2D::get_collider() const { return nullptr; } ObjectID KinematicCollision2D::get_collider_id() const { - return collision.collider; } Object *KinematicCollision2D::get_collider_shape() const { - Object *collider = get_collider(); if (collider) { CollisionObject2D *obj2d = Object::cast_to(collider); @@ -1426,20 +1310,16 @@ Object *KinematicCollision2D::get_collider_shape() const { return nullptr; } int KinematicCollision2D::get_collider_shape_index() const { - return collision.collider_shape; } Vector2 KinematicCollision2D::get_collider_velocity() const { - return collision.collider_vel; } Variant KinematicCollision2D::get_collider_metadata() const { - return Variant(); } void KinematicCollision2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_position"), &KinematicCollision2D::get_position); ClassDB::bind_method(D_METHOD("get_normal"), &KinematicCollision2D::get_normal); ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision2D::get_travel); @@ -1466,7 +1346,6 @@ void KinematicCollision2D::_bind_methods() { } KinematicCollision2D::KinematicCollision2D() { - collision.collider_shape = 0; collision.local_shape = 0; owner = nullptr; diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 75f4f778bf..f3bdeb4528 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -39,7 +39,6 @@ class KinematicCollision2D; class PhysicsBody2D : public CollisionObject2D { - GDCLASS(PhysicsBody2D, CollisionObject2D); uint32_t collision_layer; @@ -75,7 +74,6 @@ public: }; class StaticBody2D : public PhysicsBody2D { - GDCLASS(StaticBody2D, PhysicsBody2D); Vector2 constant_linear_velocity; @@ -104,7 +102,6 @@ private: }; class RigidBody2D : public PhysicsBody2D { - GDCLASS(RigidBody2D, PhysicsBody2D); public: @@ -143,7 +140,6 @@ private: CCDMode ccd_mode; struct ShapePair { - int body_shape; int local_shape; bool tagged; @@ -161,19 +157,16 @@ private: } }; struct RigidBody2D_RemoveAction { - ObjectID body_id; ShapePair pair; }; struct BodyState { - //int rc; bool in_scene; VSet shapes; }; struct ContactMonitor { - bool locked; Map body_map; }; @@ -271,7 +264,6 @@ VARIANT_ENUM_CAST(RigidBody2D::Mode); VARIANT_ENUM_CAST(RigidBody2D::CCDMode); class KinematicBody2D : public PhysicsBody2D { - GDCLASS(KinematicBody2D, PhysicsBody2D); public: @@ -344,7 +336,6 @@ public: }; class KinematicCollision2D : public Reference { - GDCLASS(KinematicCollision2D, Reference); KinematicBody2D *owner; diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index cec598774e..c05bbb3cd4 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -81,7 +81,6 @@ bool Polygon2D::_edit_use_rect() const { } bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - Vector polygon2d = Variant(polygon); if (internal_vertices > 0) { polygon2d.resize(polygon2d.size() - internal_vertices); @@ -95,11 +94,8 @@ void Polygon2D::_skeleton_bone_setup_changed() { } void Polygon2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_DRAW: { - if (polygon.size() < 3) return; @@ -147,7 +143,6 @@ void Polygon2D::_notification(int p_what) { points.resize(len); { - const Vector2 *polyr = polygon.ptr(); for (int i = 0; i < len; i++) { points.write[i] = polyr[i] + offset; @@ -155,7 +150,6 @@ void Polygon2D::_notification(int p_what) { } if (invert) { - Rect2 bounds; int highest_idx = -1; float highest_y = -1e20; @@ -195,12 +189,10 @@ void Polygon2D::_notification(int p_what) { points.resize(points.size() + 7); for (int i = points.size() - 1; i >= highest_idx + 7; i--) { - points.write[i] = points[i - 7]; } for (int i = 0; i < 7; i++) { - points.write[highest_idx + i + 1] = ep[i]; } @@ -208,7 +200,6 @@ void Polygon2D::_notification(int p_what) { } if (texture.is_valid()) { - Transform2D texmat(tex_rot, tex_ofs); texmat.scale(tex_scale); Size2 tex_size = texture->get_size(); @@ -216,7 +207,6 @@ void Polygon2D::_notification(int p_what) { uvs.resize(len); if (points.size() == uv.size()) { - const Vector2 *uvr = uv.ptr(); for (int i = 0; i < len; i++) { @@ -356,12 +346,10 @@ void Polygon2D::set_polygon(const Vector &p_polygon) { } Vector Polygon2D::get_polygon() const { - return polygon; } void Polygon2D::set_internal_vertex_count(int p_count) { - internal_vertices = p_count; } @@ -370,49 +358,40 @@ int Polygon2D::get_internal_vertex_count() const { } void Polygon2D::set_uv(const Vector &p_uv) { - uv = p_uv; update(); } Vector Polygon2D::get_uv() const { - return uv; } void Polygon2D::set_polygons(const Array &p_polygons) { - polygons = p_polygons; update(); } Array Polygon2D::get_polygons() const { - return polygons; } void Polygon2D::set_color(const Color &p_color) { - color = p_color; update(); } Color Polygon2D::get_color() const { - return color; } void Polygon2D::set_vertex_colors(const Vector &p_colors) { - vertex_colors = p_colors; update(); } Vector Polygon2D::get_vertex_colors() const { - return vertex_colors; } void Polygon2D::set_texture(const Ref &p_texture) { - texture = p_texture; /*if (texture.is_valid()) { @@ -426,7 +405,6 @@ void Polygon2D::set_texture(const Ref &p_texture) { update(); } Ref Polygon2D::get_texture() const { - return texture; } @@ -467,76 +445,61 @@ float Polygon2D::get_shininess() const { } void Polygon2D::set_texture_offset(const Vector2 &p_offset) { - tex_ofs = p_offset; update(); } Vector2 Polygon2D::get_texture_offset() const { - return tex_ofs; } void Polygon2D::set_texture_rotation(float p_rot) { - tex_rot = p_rot; update(); } float Polygon2D::get_texture_rotation() const { - return tex_rot; } void Polygon2D::set_texture_rotation_degrees(float p_rot) { - set_texture_rotation(Math::deg2rad(p_rot)); } float Polygon2D::get_texture_rotation_degrees() const { - return Math::rad2deg(get_texture_rotation()); } void Polygon2D::set_texture_scale(const Size2 &p_scale) { - tex_scale = p_scale; update(); } Size2 Polygon2D::get_texture_scale() const { - return tex_scale; } void Polygon2D::set_invert(bool p_invert) { - invert = p_invert; update(); } bool Polygon2D::get_invert() const { - return invert; } void Polygon2D::set_antialiased(bool p_antialiased) { - antialiased = p_antialiased; update(); } bool Polygon2D::get_antialiased() const { - return antialiased; } void Polygon2D::set_invert_border(float p_invert_border) { - invert_border = p_invert_border; update(); } float Polygon2D::get_invert_border() const { - return invert_border; } void Polygon2D::set_offset(const Vector2 &p_offset) { - offset = p_offset; rect_cache_dirty = true; update(); @@ -544,12 +507,10 @@ void Polygon2D::set_offset(const Vector2 &p_offset) { } Vector2 Polygon2D::get_offset() const { - return offset; } void Polygon2D::add_bone(const NodePath &p_path, const Vector &p_weights) { - Bone bone; bone.path = p_path; bone.weights = p_weights; @@ -563,12 +524,10 @@ NodePath Polygon2D::get_bone_path(int p_index) const { return bone_weights[p_index].path; } Vector Polygon2D::get_bone_weights(int p_index) const { - ERR_FAIL_INDEX_V(p_index, bone_weights.size(), Vector()); return bone_weights[p_index].weights; } void Polygon2D::erase_bone(int p_idx) { - ERR_FAIL_INDEX(p_idx, bone_weights.size()); bone_weights.remove(p_idx); } @@ -597,7 +556,6 @@ Array Polygon2D::_get_bones() const { return bones; } void Polygon2D::_set_bones(const Array &p_bones) { - ERR_FAIL_COND(p_bones.size() & 1); clear_bones(); for (int i = 0; i < p_bones.size(); i += 2) { @@ -617,7 +575,6 @@ NodePath Polygon2D::get_skeleton() const { } void Polygon2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &Polygon2D::set_polygon); ClassDB::bind_method(D_METHOD("get_polygon"), &Polygon2D::get_polygon); @@ -722,7 +679,6 @@ void Polygon2D::_bind_methods() { } Polygon2D::Polygon2D() { - invert = false; invert_border = 100; antialiased = false; diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index 777c1f82f3..dafec1c343 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -34,7 +34,6 @@ #include "scene/2d/node_2d.h" class Polygon2D : public Node2D { - GDCLASS(Polygon2D, Node2D); Vector polygon; diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp index 9e95a55d9f..4cd46171c6 100644 --- a/scene/2d/position_2d.cpp +++ b/scene/2d/position_2d.cpp @@ -36,7 +36,6 @@ const float DEFAULT_GIZMO_EXTENTS = 10.0; void Position2D::_draw_cross() { - float extents = get_gizmo_extents(); // Colors taken from `axis_x_color` and `axis_y_color` (defined in `editor/editor_themes.cpp`) draw_line(Point2(-extents, 0), Point2(+extents, 0), Color(0.96, 0.20, 0.32)); @@ -45,7 +44,6 @@ void Position2D::_draw_cross() { #ifdef TOOLS_ENABLED Rect2 Position2D::_edit_get_rect() const { - float extents = get_gizmo_extents(); return Rect2(Point2(-extents, -extents), Size2(extents * 2, extents * 2)); } @@ -56,11 +54,8 @@ bool Position2D::_edit_use_rect() const { #endif void Position2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - update(); } break; case NOTIFICATION_DRAW: { @@ -92,7 +87,6 @@ float Position2D::get_gizmo_extents() const { } void Position2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_gizmo_extents", "extents"), &Position2D::set_gizmo_extents); ClassDB::bind_method(D_METHOD("_get_gizmo_extents"), &Position2D::get_gizmo_extents); diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h index 3ea636171d..b53fa4c0e2 100644 --- a/scene/2d/position_2d.h +++ b/scene/2d/position_2d.h @@ -34,7 +34,6 @@ #include "scene/2d/node_2d.h" class Position2D : public Node2D { - GDCLASS(Position2D, Node2D); void _draw_cross(); diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index 9d6c7304ce..707b6da67d 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -36,29 +36,24 @@ #include "servers/physics_server_2d.h" void RayCast2D::set_cast_to(const Vector2 &p_point) { - cast_to = p_point; if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) update(); } Vector2 RayCast2D::get_cast_to() const { - return cast_to; } void RayCast2D::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; } uint32_t RayCast2D::get_collision_mask() const { - return collision_mask; } void RayCast2D::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -68,16 +63,13 @@ void RayCast2D::set_collision_mask_bit(int p_bit, bool p_value) { } bool RayCast2D::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } bool RayCast2D::is_colliding() const { - return collided; } Object *RayCast2D::get_collider() const { - if (against.is_null()) return nullptr; @@ -85,20 +77,16 @@ Object *RayCast2D::get_collider() const { } int RayCast2D::get_collider_shape() const { - return against_shape; } Vector2 RayCast2D::get_collision_point() const { - return collision_point; } Vector2 RayCast2D::get_collision_normal() const { - return collision_normal; } void RayCast2D::set_enabled(bool p_enabled) { - enabled = p_enabled; update(); if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) @@ -108,12 +96,10 @@ void RayCast2D::set_enabled(bool p_enabled) { } bool RayCast2D::is_enabled() const { - return enabled; } void RayCast2D::set_exclude_parent_body(bool p_exclude_parent_body) { - if (exclude_parent_body == p_exclude_parent_body) return; @@ -131,16 +117,12 @@ void RayCast2D::set_exclude_parent_body(bool p_exclude_parent_body) { } bool RayCast2D::get_exclude_parent_body() const { - return exclude_parent_body; } void RayCast2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - if (enabled && !Engine::get_singleton()->is_editor_hint()) set_physics_process_internal(true); else @@ -154,14 +136,12 @@ void RayCast2D::_notification(int p_what) { } } break; case NOTIFICATION_EXIT_TREE: { - if (enabled) set_physics_process_internal(false); } break; case NOTIFICATION_DRAW: { - if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) break; Transform2D xf; @@ -191,7 +171,6 @@ void RayCast2D::_notification(int p_what) { } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - if (!enabled) break; @@ -217,7 +196,6 @@ void RayCast2D::_update_raycast_state() { PhysicsDirectSpaceState2D::RayResult rr; if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) { - collided = true; against = rr.collider_id; collision_point = rr.position; @@ -235,12 +213,10 @@ void RayCast2D::force_raycast_update() { } void RayCast2D::add_exception_rid(const RID &p_rid) { - exclude.insert(p_rid); } void RayCast2D::add_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); const CollisionObject2D *co = Object::cast_to(p_object); if (!co) @@ -249,12 +225,10 @@ void RayCast2D::add_exception(const Object *p_object) { } void RayCast2D::remove_exception_rid(const RID &p_rid) { - exclude.erase(p_rid); } void RayCast2D::remove_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); const CollisionObject2D *co = Object::cast_to(p_object); if (!co) @@ -263,32 +237,26 @@ void RayCast2D::remove_exception(const Object *p_object) { } void RayCast2D::clear_exceptions() { - exclude.clear(); } void RayCast2D::set_collide_with_areas(bool p_clip) { - collide_with_areas = p_clip; } bool RayCast2D::is_collide_with_areas_enabled() const { - return collide_with_areas; } void RayCast2D::set_collide_with_bodies(bool p_clip) { - collide_with_bodies = p_clip; } bool RayCast2D::is_collide_with_bodies_enabled() const { - return collide_with_bodies; } void RayCast2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &RayCast2D::set_enabled); ClassDB::bind_method(D_METHOD("is_enabled"), &RayCast2D::is_enabled); @@ -337,7 +305,6 @@ void RayCast2D::_bind_methods() { } RayCast2D::RayCast2D() { - enabled = false; collided = false; diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index 20f05e7525..6accc264a0 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -34,7 +34,6 @@ #include "scene/2d/node_2d.h" class RayCast2D : public Node2D { - GDCLASS(RayCast2D, Node2D); bool enabled; diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp index ec50f5f922..d9b73a5e6e 100644 --- a/scene/2d/remote_transform_2d.cpp +++ b/scene/2d/remote_transform_2d.cpp @@ -32,7 +32,6 @@ #include "scene/scene_string_names.h" void RemoteTransform2D::_update_cache() { - cache = ObjectID(); if (has_node(remote_node)) { Node *node = get_node(remote_node); @@ -45,7 +44,6 @@ void RemoteTransform2D::_update_cache() { } void RemoteTransform2D::_update_remote() { - if (!is_inside_tree()) return; @@ -61,7 +59,6 @@ void RemoteTransform2D::_update_remote() { //todo make faster if (use_global_coordinates) { - if (update_remote_position && update_remote_rotation && update_remote_scale) { n->set_global_transform(get_global_transform()); } else { @@ -83,7 +80,6 @@ void RemoteTransform2D::_update_remote() { } } else { - if (update_remote_position && update_remote_rotation && update_remote_scale) { n->set_transform(get_transform()); } else { @@ -107,11 +103,8 @@ void RemoteTransform2D::_update_remote() { } void RemoteTransform2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - _update_cache(); } break; @@ -120,7 +113,6 @@ void RemoteTransform2D::_notification(int p_what) { break; if (cache.is_valid()) { - _update_remote(); } @@ -129,7 +121,6 @@ void RemoteTransform2D::_notification(int p_what) { } void RemoteTransform2D::set_remote_node(const NodePath &p_remote_node) { - remote_node = p_remote_node; if (is_inside_tree()) { _update_cache(); @@ -140,7 +131,6 @@ void RemoteTransform2D::set_remote_node(const NodePath &p_remote_node) { } NodePath RemoteTransform2D::get_remote_node() const { - return remote_node; } @@ -185,7 +175,6 @@ void RemoteTransform2D::force_update_cache() { } String RemoteTransform2D::get_configuration_warning() const { - if (!has_node(remote_node) || !Object::cast_to(get_node(remote_node))) { return TTR("Path property must point to a valid Node2D node to work."); } @@ -194,7 +183,6 @@ String RemoteTransform2D::get_configuration_warning() const { } void RemoteTransform2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_remote_node", "path"), &RemoteTransform2D::set_remote_node); ClassDB::bind_method(D_METHOD("get_remote_node"), &RemoteTransform2D::get_remote_node); ClassDB::bind_method(D_METHOD("force_update_cache"), &RemoteTransform2D::force_update_cache); @@ -219,7 +207,6 @@ void RemoteTransform2D::_bind_methods() { } RemoteTransform2D::RemoteTransform2D() { - use_global_coordinates = true; update_remote_position = true; update_remote_rotation = true; diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h index f5b949d10b..caaa0394f2 100644 --- a/scene/2d/remote_transform_2d.h +++ b/scene/2d/remote_transform_2d.h @@ -34,7 +34,6 @@ #include "scene/2d/node_2d.h" class RemoteTransform2D : public Node2D { - GDCLASS(RemoteTransform2D, Node2D); NodePath remote_node; diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index 86c9ff6076..e21f7ff836 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -31,7 +31,6 @@ #include "skeleton_2d.h" void Bone2D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { Node *parent = get_parent(); parent_bone = Object::cast_to(parent); @@ -79,7 +78,6 @@ void Bone2D::_notification(int p_what) { } } void Bone2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_rest", "rest"), &Bone2D::set_rest); ClassDB::bind_method(D_METHOD("get_rest"), &Bone2D::get_rest); ClassDB::bind_method(D_METHOD("apply_rest"), &Bone2D::apply_rest); @@ -106,7 +104,6 @@ Transform2D Bone2D::get_rest() const { } Transform2D Bone2D::get_skeleton_rest() const { - if (parent_bone) { return parent_bone->get_skeleton_rest() * rest; } else { @@ -119,7 +116,6 @@ void Bone2D::apply_rest() { } void Bone2D::set_default_length(float p_length) { - default_length = p_length; } @@ -133,7 +129,6 @@ int Bone2D::get_index_in_skeleton() const { return skeleton_index; } String Bone2D::get_configuration_warning() const { - String warning = Node2D::get_configuration_warning(); if (!skeleton) { if (warning != String()) { @@ -171,7 +166,6 @@ Bone2D::Bone2D() { ////////////////////////////////////// void Skeleton2D::_make_bone_setup_dirty() { - if (bone_setup_dirty) return; bone_setup_dirty = true; @@ -181,7 +175,6 @@ void Skeleton2D::_make_bone_setup_dirty() { } void Skeleton2D::_update_bone_setup() { - if (!bone_setup_dirty) return; @@ -207,7 +200,6 @@ void Skeleton2D::_update_bone_setup() { } void Skeleton2D::_make_transform_dirty() { - if (transform_dirty) return; transform_dirty = true; @@ -217,7 +209,6 @@ void Skeleton2D::_make_transform_dirty() { } void Skeleton2D::_update_transform() { - if (bone_setup_dirty) { _update_bone_setup(); return; //above will update transform anyway @@ -228,7 +219,6 @@ void Skeleton2D::_update_transform() { transform_dirty = false; for (int i = 0; i < bones.size(); i++) { - ERR_CONTINUE(bones[i].parent_index >= i); if (bones[i].parent_index >= 0) { bones.write[i].accum_transform = bones[bones[i].parent_index].accum_transform * bones[i].bone->get_transform(); @@ -238,14 +228,12 @@ void Skeleton2D::_update_transform() { } for (int i = 0; i < bones.size(); i++) { - Transform2D final_xform = bones[i].accum_transform * bones[i].rest_inverse; RS::get_singleton()->skeleton_bone_set_transform_2d(skeleton, i, final_xform); } } int Skeleton2D::get_bone_count() const { - ERR_FAIL_COND_V(!is_inside_tree(), 0); if (bone_setup_dirty) { @@ -256,7 +244,6 @@ int Skeleton2D::get_bone_count() const { } Bone2D *Skeleton2D::get_bone(int p_idx) { - ERR_FAIL_COND_V(!is_inside_tree(), nullptr); ERR_FAIL_INDEX_V(p_idx, bones.size(), nullptr); @@ -264,9 +251,7 @@ Bone2D *Skeleton2D::get_bone(int p_idx) { } void Skeleton2D::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - if (bone_setup_dirty) _update_bone_setup(); if (transform_dirty) @@ -284,7 +269,6 @@ RID Skeleton2D::get_skeleton() const { return skeleton; } void Skeleton2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_bone_setup"), &Skeleton2D::_update_bone_setup); ClassDB::bind_method(D_METHOD("_update_transform"), &Skeleton2D::_update_transform); @@ -305,6 +289,5 @@ Skeleton2D::Skeleton2D() { } Skeleton2D::~Skeleton2D() { - RS::get_singleton()->free(skeleton); } diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp index df8859bd9a..4df66057f0 100644 --- a/scene/2d/sprite_2d.cpp +++ b/scene/2d/sprite_2d.cpp @@ -61,7 +61,6 @@ bool Sprite2D::_edit_use_pivot() const { } bool Sprite2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - return is_pixel_opaque(p_point); } @@ -79,7 +78,6 @@ Rect2 Sprite2D::get_anchorable_rect() const { } void Sprite2D::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_clip) const { - Rect2 base_rect; if (region) { @@ -113,11 +111,8 @@ void Sprite2D::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_c } void Sprite2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_DRAW: { - if (texture.is_null()) return; @@ -138,7 +133,6 @@ void Sprite2D::_notification(int p_what) { } void Sprite2D::set_texture(const Ref &p_texture) { - if (p_texture == texture) return; @@ -157,24 +151,20 @@ void Sprite2D::set_texture(const Ref &p_texture) { } void Sprite2D::set_normal_map(const Ref &p_texture) { - normal_map = p_texture; update(); } Ref Sprite2D::get_normal_map() const { - return normal_map; } void Sprite2D::set_specular_map(const Ref &p_texture) { - specular = p_texture; update(); } Ref Sprite2D::get_specular_map() const { - return specular; } @@ -197,56 +187,46 @@ float Sprite2D::get_shininess() const { } Ref Sprite2D::get_texture() const { - return texture; } void Sprite2D::set_centered(bool p_center) { - centered = p_center; update(); item_rect_changed(); } bool Sprite2D::is_centered() const { - return centered; } void Sprite2D::set_offset(const Point2 &p_offset) { - offset = p_offset; update(); item_rect_changed(); _change_notify("offset"); } Point2 Sprite2D::get_offset() const { - return offset; } void Sprite2D::set_flip_h(bool p_flip) { - hflip = p_flip; update(); } bool Sprite2D::is_flipped_h() const { - return hflip; } void Sprite2D::set_flip_v(bool p_flip) { - vflip = p_flip; update(); } bool Sprite2D::is_flipped_v() const { - return vflip; } void Sprite2D::set_region(bool p_region) { - if (p_region == region) return; @@ -255,12 +235,10 @@ void Sprite2D::set_region(bool p_region) { } bool Sprite2D::is_region() const { - return region; } void Sprite2D::set_region_rect(const Rect2 &p_region_rect) { - if (region_rect == p_region_rect) return; @@ -273,7 +251,6 @@ void Sprite2D::set_region_rect(const Rect2 &p_region_rect) { } Rect2 Sprite2D::get_region_rect() const { - return region_rect; } @@ -287,7 +264,6 @@ bool Sprite2D::is_region_filter_clip_enabled() const { } void Sprite2D::set_frame(int p_frame) { - ERR_FAIL_INDEX(p_frame, vframes * hframes); if (frame != p_frame) @@ -301,7 +277,6 @@ void Sprite2D::set_frame(int p_frame) { } int Sprite2D::get_frame() const { - return frame; } @@ -317,7 +292,6 @@ Vector2 Sprite2D::get_frame_coords() const { } void Sprite2D::set_vframes(int p_amount) { - ERR_FAIL_COND_MSG(p_amount < 1, "Amount of vframes cannot be smaller than 1."); vframes = p_amount; update(); @@ -325,12 +299,10 @@ void Sprite2D::set_vframes(int p_amount) { _change_notify(); } int Sprite2D::get_vframes() const { - return vframes; } void Sprite2D::set_hframes(int p_amount) { - ERR_FAIL_COND_MSG(p_amount < 1, "Amount of hframes cannot be smaller than 1."); hframes = p_amount; update(); @@ -338,12 +310,10 @@ void Sprite2D::set_hframes(int p_amount) { _change_notify(); } int Sprite2D::get_hframes() const { - return hframes; } bool Sprite2D::is_pixel_opaque(const Point2 &p_point) const { - if (texture.is_null()) return false; @@ -393,7 +363,6 @@ bool Sprite2D::is_pixel_opaque(const Point2 &p_point) const { } Rect2 Sprite2D::get_rect() const { - if (texture.is_null()) return Rect2(0, 0, 1, 1); @@ -418,7 +387,6 @@ Rect2 Sprite2D::get_rect() const { } void Sprite2D::_validate_property(PropertyInfo &property) const { - if (property.name == "frame") { property.hint = PROPERTY_HINT_RANGE; property.hint_string = "0," + itos(vframes * hframes - 1) + ",1"; @@ -431,7 +399,6 @@ void Sprite2D::_validate_property(PropertyInfo &property) const { } void Sprite2D::_texture_changed() { - // Changes to the texture need to trigger an update to make // the editor redraw the sprite with the updated texture. if (texture.is_valid()) { @@ -440,7 +407,6 @@ void Sprite2D::_texture_changed() { } void Sprite2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite2D::set_texture); ClassDB::bind_method(D_METHOD("get_texture"), &Sprite2D::get_texture); @@ -520,7 +486,6 @@ void Sprite2D::_bind_methods() { } Sprite2D::Sprite2D() { - centered = true; hflip = false; vflip = false; diff --git a/scene/2d/sprite_2d.h b/scene/2d/sprite_2d.h index 599a9e937e..c72e956307 100644 --- a/scene/2d/sprite_2d.h +++ b/scene/2d/sprite_2d.h @@ -35,7 +35,6 @@ #include "scene/resources/texture.h" class Sprite2D : public Node2D { - GDCLASS(Sprite2D, Node2D); Ref texture; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 869f290f97..fa66a2af22 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -39,7 +39,6 @@ #include "servers/physics_server_2d.h" int TileMap::_get_quadrant_size() const { - if (use_y_sort) return 1; else @@ -47,14 +46,10 @@ int TileMap::_get_quadrant_size() const { } void TileMap::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - Node2D *c = this; while (c) { - navigation = Object::cast_to(c); if (navigation) { break; @@ -79,14 +74,11 @@ void TileMap::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - _update_quadrant_space(RID()); for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Quadrant &q = E->get(); if (navigation) { for (Map::Element *F = q.navpoly_ids.front(); F; F = F->next()) { - NavigationServer2D::get_singleton()->region_set_map(F->get().region, RID()); } q.navpoly_ids.clear(); @@ -109,13 +101,11 @@ void TileMap::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - //move stuff _update_quadrant_transform(); } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (use_parent) { _recreate_quadrants(); } @@ -125,10 +115,8 @@ void TileMap::_notification(int p_what) { } void TileMap::_update_quadrant_space(const RID &p_space) { - if (!use_parent) { for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Quadrant &q = E->get(); PhysicsServer2D::get_singleton()->body_set_space(q.body, p_space); } @@ -136,7 +124,6 @@ void TileMap::_update_quadrant_space(const RID &p_space) { } void TileMap::_update_quadrant_transform() { - if (!is_inside_tree()) return; @@ -151,7 +138,6 @@ void TileMap::_update_quadrant_transform() { nav_rel = get_relative_transform_to_parent(navigation); for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Quadrant &q = E->get(); Transform2D xform; xform.set_origin(q.pos); @@ -163,7 +149,6 @@ void TileMap::_update_quadrant_transform() { if (navigation) { for (Map::Element *F = q.navpoly_ids.front(); F; F = F->next()) { - NavigationServer2D::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform); } } @@ -175,7 +160,6 @@ void TileMap::_update_quadrant_transform() { } void TileMap::set_tileset(const Ref &p_tileset) { - if (tile_set.is_valid()) { tile_set->disconnect("changed", callable_mp(this, &TileMap::_recreate_quadrants)); tile_set->remove_change_receptor(this); @@ -196,12 +180,10 @@ void TileMap::set_tileset(const Ref &p_tileset) { } Ref TileMap::get_tileset() const { - return tile_set; } void TileMap::set_cell_size(Size2 p_size) { - ERR_FAIL_COND(p_size.x < 1 || p_size.y < 1); _clear_quadrants(); @@ -211,12 +193,10 @@ void TileMap::set_cell_size(Size2 p_size) { } Size2 TileMap::get_cell_size() const { - return cell_size; } void TileMap::set_quadrant_size(int p_size) { - ERR_FAIL_COND_MSG(p_size < 1, "Quadrant size cannot be smaller than 1."); _clear_quadrants(); @@ -226,17 +206,14 @@ void TileMap::set_quadrant_size(int p_size) { } int TileMap::get_quadrant_size() const { - return quadrant_size; } void TileMap::_fix_cell_transform(Transform2D &xform, const Cell &p_cell, const Vector2 &p_offset, const Size2 &p_sc) { - Size2 s = p_sc; Vector2 offset = p_offset; if (compatibility_mode && !centered_textures) { - if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) { offset.y += cell_size.y; } else if (tile_origin == TILE_ORIGIN_CENTER) { @@ -326,7 +303,6 @@ void TileMap::_add_shape(int &shape_idx, const Quadrant &p_q, const Ref } void TileMap::update_dirty_quadrants() { - if (!pending_update) return; if (!is_inside_tree() || !tile_set.is_valid()) { @@ -358,11 +334,9 @@ void TileMap::update_dirty_quadrants() { } while (dirty_quadrant_list.first()) { - Quadrant &q = *dirty_quadrant_list.first()->self(); for (List::Element *E = q.canvas_items.front(); E; E = E->next()) { - vs->free(E->get()); } @@ -377,7 +351,6 @@ void TileMap::update_dirty_quadrants() { if (navigation) { for (Map::Element *E = q.navpoly_ids.front(); E; E = E->next()) { - NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID()); } q.navpoly_ids.clear(); @@ -393,7 +366,6 @@ void TileMap::update_dirty_quadrants() { RID prev_debug_canvas_item; for (int i = 0; i < q.cells.size(); i++) { - Map::Element *E = tile_map.find(q.cells[i]); Cell &c = E->get(); //moment of truth @@ -420,7 +392,6 @@ void TileMap::update_dirty_quadrants() { RID debug_canvas_item; if (prev_canvas_item == RID() || prev_material != mat || prev_z_index != z_index) { - canvas_item = vs->canvas_item_create(); if (mat.is_valid()) vs->canvas_item_set_material(canvas_item, mat->get_rid()); @@ -435,7 +406,6 @@ void TileMap::update_dirty_quadrants() { q.canvas_items.push_back(canvas_item); if (debug_shapes) { - debug_canvas_item = vs->canvas_item_create(); vs->canvas_item_set_parent(debug_canvas_item, canvas_item); vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item, false); @@ -509,7 +479,6 @@ void TileMap::update_dirty_quadrants() { rect.position += tile_ofs; } else if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) { - rect.position += tile_ofs; if (c.transpose) { @@ -525,7 +494,6 @@ void TileMap::update_dirty_quadrants() { } } else if (tile_origin == TILE_ORIGIN_CENTER) { - rect.position += tile_ofs; if (c.flip_h) @@ -651,10 +619,8 @@ void TileMap::update_dirty_quadrants() { Vector polygon = navpoly->get_polygon(j); for (int k = 2; k < polygon.size(); k++) { - int kofs[3] = { 0, k - 1, k }; for (int l = 0; l < 3; l++) { - int idx = polygon[kofs[l]]; ERR_FAIL_INDEX(idx, vsize); indices.push_back(idx); @@ -704,13 +670,10 @@ void TileMap::update_dirty_quadrants() { pending_update = false; if (quadrant_order_dirty) { - int index = -(int64_t)0x80000000; //always must be drawn below children for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Quadrant &q = E->get(); for (List::Element *F = q.canvas_items.front(); F; F = F->next()) { - RS::get_singleton()->canvas_item_set_draw_index(F->get(), index++); } } @@ -722,7 +685,6 @@ void TileMap::update_dirty_quadrants() { } void TileMap::_recompute_rect_cache() { - #ifdef DEBUG_ENABLED if (!rect_cache_dirty) @@ -730,7 +692,6 @@ void TileMap::_recompute_rect_cache() { Rect2 r_total; for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Rect2 r; r.position = _map_to_world(E->key().x * _get_quadrant_size(), E->key().y * _get_quadrant_size()); r.expand_to(_map_to_world(E->key().x * _get_quadrant_size() + _get_quadrant_size(), E->key().y * _get_quadrant_size())); @@ -751,7 +712,6 @@ void TileMap::_recompute_rect_cache() { } Map::Element *TileMap::_create_quadrant(const PosKey &p_qk) { - Transform2D xform; //xform.set_origin(Point2(p_qk.x,p_qk.y)*cell_size*quadrant_size); Quadrant q; @@ -794,7 +754,6 @@ Map::Element *TileMap::_create_quadrant(cons } void TileMap::_erase_quadrant(Map::Element *Q) { - Quadrant &q = Q->get(); if (!use_parent) { PhysicsServer2D::get_singleton()->free(q.body); @@ -803,7 +762,6 @@ void TileMap::_erase_quadrant(Map::Element *Q) { } for (List::Element *E = q.canvas_items.front(); E; E = E->next()) { - RenderingServer::get_singleton()->free(E->get()); } q.canvas_items.clear(); @@ -812,7 +770,6 @@ void TileMap::_erase_quadrant(Map::Element *Q) { if (navigation) { for (Map::Element *E = q.navpoly_ids.front(); E; E = E->next()) { - NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID()); } q.navpoly_ids.clear(); @@ -828,7 +785,6 @@ void TileMap::_erase_quadrant(Map::Element *Q) { } void TileMap::_make_quadrant_dirty(Map::Element *Q, bool update) { - Quadrant &q = Q->get(); if (!q.dirty_list.in_list()) dirty_quadrant_list.add(&q.dirty_list); @@ -845,12 +801,10 @@ void TileMap::_make_quadrant_dirty(Map::Element *Q, bool updat } void TileMap::set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose) { - set_cell(p_pos.x, p_pos.y, p_tile, p_flip_x, p_flip_y, p_transpose); } void TileMap::_set_celld(const Vector2 &p_pos, const Dictionary &p_data) { - Variant v_pos_x = p_pos.x, v_pos_y = p_pos.y, v_tile = p_data["id"], v_flip_h = p_data["flip_h"], v_flip_v = p_data["flip_y"], v_transpose = p_data["transpose"], v_autotile_coord = p_data["auto_coord"]; const Variant *args[7] = { &v_pos_x, &v_pos_y, &v_tile, &v_flip_h, &v_flip_v, &v_transpose, &v_autotile_coord }; Callable::CallError ce; @@ -858,7 +812,6 @@ void TileMap::_set_celld(const Vector2 &p_pos, const Dictionary &p_data) { } void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose, Vector2 p_autotile_coord) { - PosKey pk(p_x, p_y); Map::Element *E = tile_map.find(pk); @@ -912,12 +865,10 @@ void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_ } int TileMap::get_cellv(const Vector2 &p_pos) const { - return get_cell(p_pos.x, p_pos.y); } void TileMap::make_bitmask_area_dirty(const Vector2 &p_pos) { - for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) { for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) { PosKey p(x, y); @@ -929,7 +880,6 @@ void TileMap::make_bitmask_area_dirty(const Vector2 &p_pos) { } void TileMap::update_bitmask_area(const Vector2 &p_pos) { - for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) { for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) { update_cell_bitmask(x, y); @@ -938,7 +888,6 @@ void TileMap::update_bitmask_area(const Vector2 &p_pos) { } void TileMap::update_bitmask_region(const Vector2 &p_start, const Vector2 &p_end) { - if ((p_end.x < p_start.x || p_end.y < p_start.y) || (p_end.x == p_start.x && p_end.y == p_start.y)) { Array a = get_used_cells(); for (int i = 0; i < a.size(); i++) { @@ -955,7 +904,6 @@ void TileMap::update_bitmask_region(const Vector2 &p_start, const Vector2 &p_end } void TileMap::update_cell_bitmask(int p_x, int p_y) { - ERR_FAIL_COND_MSG(tile_set.is_null(), "Cannot update cell bitmask if Tileset is not open."); PosKey p(p_x, p_y); Map::Element *E = tile_map.find(p); @@ -1027,11 +975,9 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) { _make_quadrant_dirty(Q); } else if (tile_set->tile_get_tile_mode(id) == TileSet::SINGLE_TILE) { - E->get().autotile_coord_x = 0; E->get().autotile_coord_y = 0; } else if (tile_set->tile_get_tile_mode(id) == TileSet::ATLAS_TILE) { - if (tile_set->autotile_get_bitmask(id, Vector2(p_x, p_y)) == TileSet::BIND_CENTER) { Vector2 coord = tile_set->atlastile_get_subtile_by_priority(id, this, Vector2(p_x, p_y)); @@ -1043,7 +989,6 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) { } void TileMap::update_dirty_bitmask() { - while (dirty_bitmask.size() > 0) { update_cell_bitmask(dirty_bitmask[0].x, dirty_bitmask[0].y); dirty_bitmask.pop_front(); @@ -1051,10 +996,8 @@ void TileMap::update_dirty_bitmask() { } void TileMap::fix_invalid_tiles() { - ERR_FAIL_COND_MSG(tile_set.is_null(), "Cannot fix invalid tiles if Tileset is not open."); for (Map::Element *E = tile_map.front(); E; E = E->next()) { - if (!tile_set->has_tile(get_cell(E->key().x, E->key().y))) { set_cell(E->key().x, E->key().y, INVALID_CELL); } @@ -1062,7 +1005,6 @@ void TileMap::fix_invalid_tiles() { } int TileMap::get_cell(int p_x, int p_y) const { - PosKey pk(p_x, p_y); const Map::Element *E = tile_map.find(pk); @@ -1073,7 +1015,6 @@ int TileMap::get_cell(int p_x, int p_y) const { return E->get().id; } bool TileMap::is_cell_x_flipped(int p_x, int p_y) const { - PosKey pk(p_x, p_y); const Map::Element *E = tile_map.find(pk); @@ -1084,7 +1025,6 @@ bool TileMap::is_cell_x_flipped(int p_x, int p_y) const { return E->get().flip_h; } bool TileMap::is_cell_y_flipped(int p_x, int p_y) const { - PosKey pk(p_x, p_y); const Map::Element *E = tile_map.find(pk); @@ -1095,7 +1035,6 @@ bool TileMap::is_cell_y_flipped(int p_x, int p_y) const { return E->get().flip_v; } bool TileMap::is_cell_transposed(int p_x, int p_y) const { - PosKey pk(p_x, p_y); const Map::Element *E = tile_map.find(pk); @@ -1107,7 +1046,6 @@ bool TileMap::is_cell_transposed(int p_x, int p_y) const { } void TileMap::set_cell_autotile_coord(int p_x, int p_y, const Vector2 &p_coord) { - PosKey pk(p_x, p_y); const Map::Element *E = tile_map.find(pk); @@ -1130,7 +1068,6 @@ void TileMap::set_cell_autotile_coord(int p_x, int p_y, const Vector2 &p_coord) } Vector2 TileMap::get_cell_autotile_coord(int p_x, int p_y) const { - PosKey pk(p_x, p_y); const Map::Element *E = tile_map.find(pk); @@ -1142,11 +1079,9 @@ Vector2 TileMap::get_cell_autotile_coord(int p_x, int p_y) const { } void TileMap::_recreate_quadrants() { - _clear_quadrants(); for (Map::Element *E = tile_map.front(); E; E = E->next()) { - PosKey qk = PosKey(E->key().x, E->key().y).to_quadrant(_get_quadrant_size()); Map::Element *Q = quadrant_map.find(qk); @@ -1162,50 +1097,41 @@ void TileMap::_recreate_quadrants() { } void TileMap::_clear_quadrants() { - while (quadrant_map.size()) { _erase_quadrant(quadrant_map.front()); } } void TileMap::set_material(const Ref &p_material) { - CanvasItem::set_material(p_material); _update_all_items_material_state(); } void TileMap::set_use_parent_material(bool p_use_parent_material) { - CanvasItem::set_use_parent_material(p_use_parent_material); _update_all_items_material_state(); } void TileMap::_update_all_items_material_state() { - for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Quadrant &q = E->get(); for (List::Element *F = q.canvas_items.front(); F; F = F->next()) { - _update_item_material_state(F->get()); } } } void TileMap::_update_item_material_state(const RID &p_canvas_item) { - RS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid()); } void TileMap::clear() { - _clear_quadrants(); tile_map.clear(); used_size_cache_dirty = true; } void TileMap::_set_tile_data(const Vector &p_data) { - ERR_FAIL_COND(format > FORMAT_2); int c = p_data.size(); @@ -1215,7 +1141,6 @@ void TileMap::_set_tile_data(const Vector &p_data) { clear(); for (int i = 0; i < c; i += offset) { - const uint8_t *ptr = (const uint8_t *)&r[i]; uint8_t local[12]; for (int j = 0; j < ((format == FORMAT_2) ? 12 : 8); j++) @@ -1253,7 +1178,6 @@ void TileMap::_set_tile_data(const Vector &p_data) { } Vector TileMap::_get_tile_data() const { - Vector data; data.resize(tile_map.size() * 3); int *w = data.ptrw(); @@ -1293,11 +1217,9 @@ Rect2 TileMap::_edit_get_rect() const { #endif void TileMap::set_collision_layer(uint32_t p_layer) { - collision_layer = p_layer; if (!use_parent) { for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Quadrant &q = E->get(); PhysicsServer2D::get_singleton()->body_set_collision_layer(q.body, collision_layer); } @@ -1305,11 +1227,9 @@ void TileMap::set_collision_layer(uint32_t p_layer) { } void TileMap::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; if (!use_parent) { for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Quadrant &q = E->get(); PhysicsServer2D::get_singleton()->body_set_collision_mask(q.body, collision_mask); } @@ -1317,7 +1237,6 @@ void TileMap::set_collision_mask(uint32_t p_mask) { } void TileMap::set_collision_layer_bit(int p_bit, bool p_value) { - uint32_t layer = get_collision_layer(); if (p_value) layer |= 1 << p_bit; @@ -1327,7 +1246,6 @@ void TileMap::set_collision_layer_bit(int p_bit, bool p_value) { } void TileMap::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -1337,24 +1255,20 @@ void TileMap::set_collision_mask_bit(int p_bit, bool p_value) { } bool TileMap::get_collision_use_kinematic() const { - return use_kinematic; } void TileMap::set_collision_use_kinematic(bool p_use_kinematic) { - _clear_quadrants(); use_kinematic = p_use_kinematic; _recreate_quadrants(); } bool TileMap::get_collision_use_parent() const { - return use_parent; } void TileMap::set_collision_use_parent(bool p_use_parent) { - if (use_parent == p_use_parent) return; @@ -1375,11 +1289,9 @@ void TileMap::set_collision_use_parent(bool p_use_parent) { } void TileMap::set_collision_friction(float p_friction) { - friction = p_friction; if (!use_parent) { for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Quadrant &q = E->get(); PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_FRICTION, p_friction); } @@ -1387,48 +1299,39 @@ void TileMap::set_collision_friction(float p_friction) { } float TileMap::get_collision_friction() const { - return friction; } void TileMap::set_collision_bounce(float p_bounce) { - bounce = p_bounce; if (!use_parent) { for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - Quadrant &q = E->get(); PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_BOUNCE, p_bounce); } } } float TileMap::get_collision_bounce() const { - return bounce; } uint32_t TileMap::get_collision_layer() const { - return collision_layer; } uint32_t TileMap::get_collision_mask() const { - return collision_mask; } bool TileMap::get_collision_layer_bit(int p_bit) const { - return get_collision_layer() & (1 << p_bit); } bool TileMap::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } void TileMap::set_mode(Mode p_mode) { - _clear_quadrants(); mode = p_mode; _recreate_quadrants(); @@ -1440,7 +1343,6 @@ TileMap::Mode TileMap::get_mode() const { } void TileMap::set_half_offset(HalfOffset p_half_offset) { - _clear_quadrants(); half_offset = p_half_offset; _recreate_quadrants(); @@ -1448,7 +1350,6 @@ void TileMap::set_half_offset(HalfOffset p_half_offset) { } void TileMap::set_tile_origin(TileOrigin p_tile_origin) { - _clear_quadrants(); tile_origin = p_tile_origin; _recreate_quadrants(); @@ -1456,25 +1357,19 @@ void TileMap::set_tile_origin(TileOrigin p_tile_origin) { } TileMap::TileOrigin TileMap::get_tile_origin() const { - return tile_origin; } Vector2 TileMap::get_cell_draw_offset() const { - switch (mode) { - case MODE_SQUARE: { - return Vector2(); } break; case MODE_ISOMETRIC: { - return Vector2(-cell_size.x * 0.5, 0); } break; case MODE_CUSTOM: { - Vector2 min; min.x = MIN(custom_transform[0].x, min.x); min.y = MIN(custom_transform[0].y, min.y); @@ -1492,18 +1387,14 @@ TileMap::HalfOffset TileMap::get_half_offset() const { } Transform2D TileMap::get_cell_transform() const { - switch (mode) { - case MODE_SQUARE: { - Transform2D m; m[0] *= cell_size.x; m[1] *= cell_size.y; return m; } break; case MODE_ISOMETRIC: { - //isometric only makes sense when y is positive in both x and y vectors, otherwise //the drawing of tiles will overlap Transform2D m; @@ -1513,7 +1404,6 @@ Transform2D TileMap::get_cell_transform() const { } break; case MODE_CUSTOM: { - return custom_transform; } break; } @@ -1522,7 +1412,6 @@ Transform2D TileMap::get_cell_transform() const { } void TileMap::set_custom_transform(const Transform2D &p_xform) { - _clear_quadrants(); custom_transform = p_xform; _recreate_quadrants(); @@ -1530,20 +1419,16 @@ void TileMap::set_custom_transform(const Transform2D &p_xform) { } Transform2D TileMap::get_custom_transform() const { - return custom_transform; } Vector2 TileMap::_map_to_world(int p_x, int p_y, bool p_ignore_ofs) const { - Vector2 ret = get_cell_transform().xform(Vector2(p_x, p_y)); if (!p_ignore_ofs) { switch (half_offset) { - case HALF_OFFSET_X: case HALF_OFFSET_NEGATIVE_X: { if (ABS(p_y) & 1) { - ret += get_cell_transform()[0] * (half_offset == HALF_OFFSET_X ? 0.5 : -0.5); } } break; @@ -1562,7 +1447,6 @@ Vector2 TileMap::_map_to_world(int p_x, int p_y, bool p_ignore_ofs) const { } bool TileMap::_set(const StringName &p_name, const Variant &p_value) { - if (p_name == "format") { if (p_value.get_type() == Variant::INT) { format = (DataFormat)(p_value.operator int64_t()); // Set format used for loading @@ -1579,7 +1463,6 @@ bool TileMap::_set(const StringName &p_name, const Variant &p_value) { } bool TileMap::_get(const StringName &p_name, Variant &r_ret) const { - if (p_name == "format") { r_ret = FORMAT_2; // When saving, always save highest format return true; @@ -1591,7 +1474,6 @@ bool TileMap::_get(const StringName &p_name, Variant &r_ret) const { } void TileMap::_get_property_list(List *p_list) const { - PropertyInfo p(Variant::INT, "format", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL); p_list->push_back(p); @@ -1606,16 +1488,13 @@ void TileMap::_validate_property(PropertyInfo &property) const { } Vector2 TileMap::map_to_world(const Vector2 &p_pos, bool p_ignore_ofs) const { - return _map_to_world(p_pos.x, p_pos.y, p_ignore_ofs); } Vector2 TileMap::world_to_map(const Vector2 &p_pos) const { - Vector2 ret = get_cell_transform().affine_inverse().xform(p_pos); switch (half_offset) { - case HALF_OFFSET_X: { if (int(floor(ret.y)) & 1) { ret.x -= 0.5; @@ -1650,7 +1529,6 @@ Vector2 TileMap::world_to_map(const Vector2 &p_pos) const { } void TileMap::set_y_sort_enabled(bool p_enable) { - _clear_quadrants(); use_y_sort = p_enable; RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), use_y_sort); @@ -1659,12 +1537,10 @@ void TileMap::set_y_sort_enabled(bool p_enable) { } bool TileMap::is_y_sort_enabled() const { - return use_y_sort; } void TileMap::set_compatibility_mode(bool p_enable) { - _clear_quadrants(); compatibility_mode = p_enable; _recreate_quadrants(); @@ -1672,12 +1548,10 @@ void TileMap::set_compatibility_mode(bool p_enable) { } bool TileMap::is_compatibility_mode_enabled() const { - return compatibility_mode; } void TileMap::set_centered_textures(bool p_enable) { - _clear_quadrants(); centered_textures = p_enable; _recreate_quadrants(); @@ -1685,17 +1559,14 @@ void TileMap::set_centered_textures(bool p_enable) { } bool TileMap::is_centered_textures_enabled() const { - return centered_textures; } TypedArray TileMap::get_used_cells() const { - TypedArray a; a.resize(tile_map.size()); int i = 0; for (Map::Element *E = tile_map.front(); E; E = E->next()) { - Vector2i p(E->key().x, E->key().y); a[i++] = p; } @@ -1704,10 +1575,8 @@ TypedArray TileMap::get_used_cells() const { } TypedArray TileMap::get_used_cells_by_index(int p_id) const { - TypedArray a; for (Map::Element *E = tile_map.front(); E; E = E->next()) { - if (E->value().id == p_id) { Vector2i p(E->key().x, E->key().y); a.push_back(p); @@ -1739,10 +1608,8 @@ Rect2 TileMap::get_used_rect() { // Not const because of cache } void TileMap::set_occluder_light_mask(int p_mask) { - occluder_light_mask = p_mask; for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - for (Map::Element *F = E->get().occluder_instances.front(); F; F = F->next()) { RenderingServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id, occluder_light_mask); } @@ -1750,15 +1617,12 @@ void TileMap::set_occluder_light_mask(int p_mask) { } int TileMap::get_occluder_light_mask() const { - return occluder_light_mask; } void TileMap::set_light_mask(int p_light_mask) { - CanvasItem::set_light_mask(p_light_mask); for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - for (List::Element *F = E->get().canvas_items.front(); F; F = F->next()) { RenderingServer::get_singleton()->canvas_item_set_light_mask(F->get(), get_light_mask()); } @@ -1766,7 +1630,6 @@ void TileMap::set_light_mask(int p_light_mask) { } void TileMap::set_clip_uv(bool p_enable) { - if (clip_uv == p_enable) return; @@ -1776,12 +1639,10 @@ void TileMap::set_clip_uv(bool p_enable) { } bool TileMap::get_clip_uv() const { - return clip_uv; } String TileMap::get_configuration_warning() const { - String warning = Node2D::get_configuration_warning(); if (use_parent && !collision_parent) { @@ -1795,7 +1656,6 @@ String TileMap::get_configuration_warning() const { } void TileMap::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_tileset", "tileset"), &TileMap::set_tileset); ClassDB::bind_method(D_METHOD("get_tileset"), &TileMap::get_tileset); @@ -1942,7 +1802,6 @@ void TileMap::_changed_callback(Object *p_changed, const char *p_prop) { } TileMap::TileMap() { - rect_cache_dirty = true; used_size_cache_dirty = true; pending_update = false; @@ -1974,7 +1833,6 @@ TileMap::TileMap() { } TileMap::~TileMap() { - if (tile_set.is_valid()) tile_set->remove_change_receptor(this); diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 16784571bf..24d4dc09db 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -40,7 +40,6 @@ class CollisionObject2D; class TileMap : public Node2D { - GDCLASS(TileMap, Node2D); public: @@ -82,7 +81,6 @@ private: Navigation2D *navigation; union PosKey { - struct { int16_t x; int16_t y; @@ -112,7 +110,6 @@ private: }; union Cell { - struct { int32_t id : 24; bool flip_h : 1; @@ -130,7 +127,6 @@ private: List dirty_bitmask; struct Quadrant { - Vector2 pos; List canvas_items; RID body; diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 590cc1e6c4..2d8a47ee98 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -36,39 +36,32 @@ #include "scene/main/window.h" # void TouchScreenButton::set_texture(const Ref &p_texture) { - texture = p_texture; update(); } Ref TouchScreenButton::get_texture() const { - return texture; } void TouchScreenButton::set_texture_pressed(const Ref &p_texture_pressed) { - texture_pressed = p_texture_pressed; update(); } Ref TouchScreenButton::get_texture_pressed() const { - return texture_pressed; } void TouchScreenButton::set_bitmask(const Ref &p_bitmask) { - bitmask = p_bitmask; } Ref TouchScreenButton::get_bitmask() const { - return bitmask; } void TouchScreenButton::set_shape(const Ref &p_shape) { - if (shape.is_valid()) shape->disconnect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); @@ -81,45 +74,36 @@ void TouchScreenButton::set_shape(const Ref &p_shape) { } Ref TouchScreenButton::get_shape() const { - return shape; } void TouchScreenButton::set_shape_centered(bool p_shape_centered) { - shape_centered = p_shape_centered; update(); } bool TouchScreenButton::is_shape_visible() const { - return shape_visible; } void TouchScreenButton::set_shape_visible(bool p_shape_visible) { - shape_visible = p_shape_visible; update(); } bool TouchScreenButton::is_shape_centered() const { - return shape_centered; } void TouchScreenButton::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_DRAW: { - if (!is_inside_tree()) return; if (!Engine::get_singleton()->is_editor_hint() && !!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())) && visibility == VISIBILITY_TOUCHSCREEN_ONLY) return; if (finger_pressed != -1) { - if (texture_pressed.is_valid()) draw_texture(texture_pressed, Point2()); else if (texture.is_valid()) @@ -145,7 +129,6 @@ void TouchScreenButton::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { - if (!Engine::get_singleton()->is_editor_hint() && !!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())) && visibility == VISIBILITY_TOUCHSCREEN_ONLY) return; update(); @@ -177,22 +160,18 @@ void TouchScreenButton::_notification(int p_what) { } bool TouchScreenButton::is_pressed() const { - return finger_pressed != -1; } void TouchScreenButton::set_action(const String &p_action) { - action = p_action; } String TouchScreenButton::get_action() const { - return action; } void TouchScreenButton::_input(const Ref &p_event) { - if (!get_tree()) return; @@ -204,21 +183,17 @@ void TouchScreenButton::_input(const Ref &p_event) { const InputEventScreenTouch *st = Object::cast_to(*p_event); if (passby_press) { - const InputEventScreenDrag *sd = Object::cast_to(*p_event); if (st && !st->is_pressed() && finger_pressed == st->get_index()) { - _release(); } if ((st && st->is_pressed()) || sd) { - int index = st ? st->get_index() : sd->get_index(); Point2 coord = st ? st->get_position() : sd->get_position(); if (finger_pressed == -1 || index == finger_pressed) { - if (_is_point_inside(coord)) { if (finger_pressed == -1) { _press(index); @@ -232,11 +207,8 @@ void TouchScreenButton::_input(const Ref &p_event) { } } else { - if (st) { - if (st->is_pressed()) { - const bool can_press = finger_pressed == -1; if (!can_press) return; //already fingering @@ -268,10 +240,8 @@ bool TouchScreenButton::_is_point_inside(const Point2 &p_point) { } if (bitmask.is_valid()) { - check_rect = false; if (!touched && Rect2(Point2(), bitmask->get_size()).has_point(coord)) { - if (bitmask->get_bit(coord)) touched = true; } @@ -286,11 +256,9 @@ bool TouchScreenButton::_is_point_inside(const Point2 &p_point) { } void TouchScreenButton::_press(int p_finger_pressed) { - finger_pressed = p_finger_pressed; if (action != StringName()) { - Input::get_singleton()->action_press(action); Ref iea; iea.instance(); @@ -304,14 +272,11 @@ void TouchScreenButton::_press(int p_finger_pressed) { } void TouchScreenButton::_release(bool p_exiting_tree) { - finger_pressed = -1; if (action != StringName()) { - Input::get_singleton()->action_release(action); if (!p_exiting_tree) { - Ref iea; iea.instance(); iea->set_action(action); @@ -352,22 +317,18 @@ void TouchScreenButton::set_visibility_mode(VisibilityMode p_mode) { } TouchScreenButton::VisibilityMode TouchScreenButton::get_visibility_mode() const { - return visibility; } void TouchScreenButton::set_passby_press(bool p_enable) { - passby_press = p_enable; } bool TouchScreenButton::is_passby_press_enabled() const { - return passby_press; } void TouchScreenButton::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_texture", "texture"), &TouchScreenButton::set_texture); ClassDB::bind_method(D_METHOD("get_texture"), &TouchScreenButton::get_texture); @@ -417,7 +378,6 @@ void TouchScreenButton::_bind_methods() { } TouchScreenButton::TouchScreenButton() { - finger_pressed = -1; passby_press = false; visibility = VISIBILITY_ALWAYS; diff --git a/scene/2d/touch_screen_button.h b/scene/2d/touch_screen_button.h index 42e93f7048..d9c7ef7034 100644 --- a/scene/2d/touch_screen_button.h +++ b/scene/2d/touch_screen_button.h @@ -37,7 +37,6 @@ #include "scene/resources/texture.h" class TouchScreenButton : public Node2D { - GDCLASS(TouchScreenButton, Node2D); public: diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index 780d08693d..6b03d86e8b 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -49,7 +49,6 @@ bool VisibilityNotifier2D::_edit_use_rect() const { #endif void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) { - ERR_FAIL_COND(viewports.has(p_viewport)); viewports.insert(p_viewport); @@ -65,7 +64,6 @@ void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) { } void VisibilityNotifier2D::_exit_viewport(Viewport *p_viewport) { - ERR_FAIL_COND(!viewports.has(p_viewport)); viewports.erase(p_viewport); @@ -81,7 +79,6 @@ void VisibilityNotifier2D::_exit_viewport(Viewport *p_viewport) { } void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) { - rect = p_rect; if (is_inside_tree()) { get_world_2d()->_update_notifier(this, get_global_transform().xform(rect)); @@ -95,44 +92,35 @@ void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) { } Rect2 VisibilityNotifier2D::get_rect() const { - return rect; } void VisibilityNotifier2D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { - //get_world_2d()-> get_world_2d()->_register_notifier(this, get_global_transform().xform(rect)); } break; case NOTIFICATION_TRANSFORM_CHANGED: { - //get_world_2d()-> get_world_2d()->_update_notifier(this, get_global_transform().xform(rect)); } break; case NOTIFICATION_DRAW: { - if (Engine::get_singleton()->is_editor_hint()) { - draw_rect(rect, Color(1, 0.5, 1, 0.2)); } } break; case NOTIFICATION_EXIT_TREE: { - get_world_2d()->_remove_notifier(this); } break; } } bool VisibilityNotifier2D::is_on_screen() const { - return viewports.size() > 0; } void VisibilityNotifier2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_rect", "rect"), &VisibilityNotifier2D::set_rect); ClassDB::bind_method(D_METHOD("get_rect"), &VisibilityNotifier2D::get_rect); ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier2D::is_on_screen); @@ -146,7 +134,6 @@ void VisibilityNotifier2D::_bind_methods() { } VisibilityNotifier2D::VisibilityNotifier2D() { - rect = Rect2(-10, -10, 20, 20); set_notify_transform(true); } @@ -154,9 +141,7 @@ VisibilityNotifier2D::VisibilityNotifier2D() { ////////////////////////////////////// void VisibilityEnabler2D::_screen_enter() { - for (Map::Element *E = nodes.front(); E; E = E->next()) { - _change_node_state(E->key(), true); } @@ -169,9 +154,7 @@ void VisibilityEnabler2D::_screen_enter() { } void VisibilityEnabler2D::_screen_exit() { - for (Map::Element *E = nodes.front(); E; E = E->next()) { - _change_node_state(E->key(), false); } @@ -184,14 +167,12 @@ void VisibilityEnabler2D::_screen_exit() { } void VisibilityEnabler2D::_find_nodes(Node *p_node) { - bool add = false; Variant meta; { RigidBody2D *rb2d = Object::cast_to(p_node); if (rb2d && ((rb2d->get_mode() == RigidBody2D::MODE_CHARACTER || rb2d->get_mode() == RigidBody2D::MODE_RIGID))) { - add = true; meta = rb2d->get_mode(); } @@ -219,7 +200,6 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) { } if (add) { - p_node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler2D::_node_removed), varray(p_node), CONNECT_ONESHOT); nodes[p_node] = meta; _change_node_state(p_node, false); @@ -235,9 +215,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) { } void VisibilityEnabler2D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - if (Engine::get_singleton()->is_editor_hint()) return; @@ -264,12 +242,10 @@ void VisibilityEnabler2D::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE) { - if (Engine::get_singleton()->is_editor_hint()) return; for (Map::Element *E = nodes.front(); E; E = E->next()) { - if (!visible) _change_node_state(E->key(), true); E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler2D::_node_removed)); @@ -280,13 +256,11 @@ void VisibilityEnabler2D::_notification(int p_what) { } void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { - ERR_FAIL_COND(!nodes.has(p_node)); if (enabler[ENABLER_FREEZE_BODIES]) { RigidBody2D *rb = Object::cast_to(p_node); if (rb) { - rb->set_sleeping(!p_enabled); } } @@ -295,7 +269,6 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { AnimationPlayer *ap = Object::cast_to(p_node); if (ap) { - ap->set_active(p_enabled); } } @@ -304,7 +277,6 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { AnimatedSprite2D *as = Object::cast_to(p_node); if (as) { - if (p_enabled) as->play(); else @@ -316,14 +288,12 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { GPUParticles2D *ps = Object::cast_to(p_node); if (ps) { - ps->set_emitting(p_enabled); } } } void VisibilityEnabler2D::_node_removed(Node *p_node) { - if (!visible) _change_node_state(p_node, true); nodes.erase(p_node); @@ -339,7 +309,6 @@ String VisibilityEnabler2D::get_configuration_warning() const { } void VisibilityEnabler2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_enabler", "enabler", "enabled"), &VisibilityEnabler2D::set_enabler); ClassDB::bind_method(D_METHOD("is_enabler_enabled", "enabler"), &VisibilityEnabler2D::is_enabler_enabled); ClassDB::bind_method(D_METHOD("_node_removed"), &VisibilityEnabler2D::_node_removed); @@ -361,18 +330,15 @@ void VisibilityEnabler2D::_bind_methods() { } void VisibilityEnabler2D::set_enabler(Enabler p_enabler, bool p_enable) { - ERR_FAIL_INDEX(p_enabler, ENABLER_MAX); enabler[p_enabler] = p_enable; } bool VisibilityEnabler2D::is_enabler_enabled(Enabler p_enabler) const { - ERR_FAIL_INDEX_V(p_enabler, ENABLER_MAX, false); return enabler[p_enabler]; } VisibilityEnabler2D::VisibilityEnabler2D() { - for (int i = 0; i < ENABLER_MAX; i++) enabler[i] = true; enabler[ENABLER_PARENT_PROCESS] = false; diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h index a3b79d29e9..fb6e48f5e8 100644 --- a/scene/2d/visibility_notifier_2d.h +++ b/scene/2d/visibility_notifier_2d.h @@ -35,7 +35,6 @@ class Viewport; class VisibilityNotifier2D : public Node2D { - GDCLASS(VisibilityNotifier2D, Node2D); Set viewports; @@ -69,7 +68,6 @@ public: }; class VisibilityEnabler2D : public VisibilityNotifier2D { - GDCLASS(VisibilityEnabler2D, VisibilityNotifier2D); public: diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp index 15d97eeaa0..7c2b41db70 100644 --- a/scene/2d/y_sort.cpp +++ b/scene/2d/y_sort.cpp @@ -31,18 +31,15 @@ #include "y_sort.h" void YSort::set_sort_enabled(bool p_enabled) { - sort_enabled = p_enabled; RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), sort_enabled); } bool YSort::is_sort_enabled() const { - return sort_enabled; } void YSort::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_sort_enabled", "enabled"), &YSort::set_sort_enabled); ClassDB::bind_method(D_METHOD("is_sort_enabled"), &YSort::is_sort_enabled); @@ -51,7 +48,6 @@ void YSort::_bind_methods() { } YSort::YSort() { - sort_enabled = true; RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), true); } diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp index b72483d71b..4592b12bf8 100644 --- a/scene/3d/area_3d.cpp +++ b/scene/3d/area_3d.cpp @@ -35,27 +35,22 @@ #include "servers/physics_server_3d.h" void Area3D::set_space_override_mode(SpaceOverride p_mode) { - space_override = p_mode; PhysicsServer3D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer3D::AreaSpaceOverrideMode(p_mode)); } Area3D::SpaceOverride Area3D::get_space_override_mode() const { - return space_override; } void Area3D::set_gravity_is_point(bool p_enabled) { - gravity_is_point = p_enabled; PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled); } bool Area3D::is_gravity_a_point() const { - return gravity_is_point; } void Area3D::set_gravity_distance_scale(real_t p_scale) { - gravity_distance_scale = p_scale; PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale); } @@ -65,57 +60,46 @@ real_t Area3D::get_gravity_distance_scale() const { } void Area3D::set_gravity_vector(const Vector3 &p_vec) { - gravity_vec = p_vec; PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, p_vec); } Vector3 Area3D::get_gravity_vector() const { - return gravity_vec; } void Area3D::set_gravity(real_t p_gravity) { - gravity = p_gravity; PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY, p_gravity); } real_t Area3D::get_gravity() const { - return gravity; } void Area3D::set_linear_damp(real_t p_linear_damp) { - linear_damp = p_linear_damp; PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, p_linear_damp); } real_t Area3D::get_linear_damp() const { - return linear_damp; } void Area3D::set_angular_damp(real_t p_angular_damp) { - angular_damp = p_angular_damp; PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp); } real_t Area3D::get_angular_damp() const { - return angular_damp; } void Area3D::set_priority(real_t p_priority) { - priority = p_priority; PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_PRIORITY, p_priority); } real_t Area3D::get_priority() const { - return priority; } void Area3D::_body_enter_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -127,13 +111,11 @@ void Area3D::_body_enter_tree(ObjectID p_id) { E->get().in_tree = true; emit_signal(SceneStringNames::get_singleton()->body_entered, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape); } } void Area3D::_body_exit_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -143,13 +125,11 @@ void Area3D::_body_exit_tree(ObjectID p_id) { E->get().in_tree = false; emit_signal(SceneStringNames::get_singleton()->body_exited, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape); } } void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) { - bool body_in = p_status == PhysicsServer3D::AREA_BODY_ADDED; ObjectID objid = p_instance; @@ -166,7 +146,6 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i if (body_in) { if (!E) { - E = body_map.insert(objid, BodyState()); E->get().rc = 0; E->get().in_tree = node && node->is_inside_tree(); @@ -187,7 +166,6 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i } } else { - E->get().rc--; if (node) @@ -196,7 +174,6 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i bool eraseit = false; if (E->get().rc == 0) { - if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_body_exit_tree)); @@ -218,7 +195,6 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i } void Area3D::_clear_monitoring() { - ERR_FAIL_COND_MSG(locked, "This function can't be used during the in/out signal."); { @@ -227,7 +203,6 @@ void Area3D::_clear_monitoring() { //disconnect all monitored stuff for (Map::Element *E = bmcopy.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->key()); Node *node = Object::cast_to(obj); @@ -239,7 +214,6 @@ void Area3D::_clear_monitoring() { continue; for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape); } @@ -251,13 +225,11 @@ void Area3D::_clear_monitoring() { } { - Map bmcopy = area_map; area_map.clear(); //disconnect all monitored stuff for (Map::Element *E = bmcopy.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->key()); Node *node = Object::cast_to(obj); @@ -269,7 +241,6 @@ void Area3D::_clear_monitoring() { continue; for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape); } @@ -281,14 +252,12 @@ void Area3D::_clear_monitoring() { } } void Area3D::_notification(int p_what) { - if (p_what == NOTIFICATION_EXIT_TREE) { _clear_monitoring(); } } void Area3D::set_monitoring(bool p_enable) { - ERR_FAIL_COND_MSG(locked, "Function blocked during in/out signal. Use set_deferred(\"monitoring\", true/false)."); if (p_enable == monitoring) @@ -297,7 +266,6 @@ void Area3D::set_monitoring(bool p_enable) { monitoring = p_enable; if (monitoring) { - PhysicsServer3D::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout); PhysicsServer3D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout); } else { @@ -308,7 +276,6 @@ void Area3D::set_monitoring(bool p_enable) { } void Area3D::_area_enter_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -320,13 +287,11 @@ void Area3D::_area_enter_tree(ObjectID p_id) { E->get().in_tree = true; emit_signal(SceneStringNames::get_singleton()->area_entered, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape); } } void Area3D::_area_exit_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -336,13 +301,11 @@ void Area3D::_area_exit_tree(ObjectID p_id) { E->get().in_tree = false; emit_signal(SceneStringNames::get_singleton()->area_exited, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape); } } void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) { - bool area_in = p_status == PhysicsServer3D::AREA_BODY_ADDED; ObjectID objid = p_instance; @@ -359,7 +322,6 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i if (area_in) { if (!E) { - E = area_map.insert(objid, AreaState()); E->get().rc = 0; E->get().in_tree = node && node->is_inside_tree(); @@ -380,7 +342,6 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i } } else { - E->get().rc--; if (node) @@ -389,7 +350,6 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i bool eraseit = false; if (E->get().rc == 0) { - if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_area_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_area_exit_tree)); @@ -412,12 +372,10 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i } bool Area3D::is_monitoring() const { - return monitoring; } TypedArray Area3D::get_overlapping_bodies() const { - ERR_FAIL_COND_V(!monitoring, Array()); Array ret; ret.resize(body_map.size()); @@ -435,7 +393,6 @@ TypedArray Area3D::get_overlapping_bodies() const { } void Area3D::set_monitorable(bool p_enable) { - ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer3D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false)."); if (p_enable == monitorable) @@ -447,12 +404,10 @@ void Area3D::set_monitorable(bool p_enable) { } bool Area3D::is_monitorable() const { - return monitorable; } TypedArray Area3D::get_overlapping_areas() const { - ERR_FAIL_COND_V(!monitoring, Array()); Array ret; ret.resize(area_map.size()); @@ -470,7 +425,6 @@ TypedArray Area3D::get_overlapping_areas() const { } bool Area3D::overlaps_area(Node *p_area) const { - ERR_FAIL_NULL_V(p_area, false); const Map::Element *E = area_map.find(p_area->get_instance_id()); if (!E) @@ -479,7 +433,6 @@ bool Area3D::overlaps_area(Node *p_area) const { } bool Area3D::overlaps_body(Node *p_body) const { - ERR_FAIL_NULL_V(p_body, false); const Map::Element *E = body_map.find(p_body->get_instance_id()); if (!E) @@ -487,28 +440,23 @@ bool Area3D::overlaps_body(Node *p_body) const { return E->get().in_tree; } void Area3D::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; PhysicsServer3D::get_singleton()->area_set_collision_mask(get_rid(), p_mask); } uint32_t Area3D::get_collision_mask() const { - return collision_mask; } void Area3D::set_collision_layer(uint32_t p_layer) { - collision_layer = p_layer; PhysicsServer3D::get_singleton()->area_set_collision_layer(get_rid(), p_layer); } uint32_t Area3D::get_collision_layer() const { - return collision_layer; } void Area3D::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -518,12 +466,10 @@ void Area3D::set_collision_mask_bit(int p_bit, bool p_value) { } bool Area3D::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } void Area3D::set_collision_layer_bit(int p_bit, bool p_value) { - uint32_t layer = get_collision_layer(); if (p_value) layer |= 1 << p_bit; @@ -533,26 +479,21 @@ void Area3D::set_collision_layer_bit(int p_bit, bool p_value) { } bool Area3D::get_collision_layer_bit(int p_bit) const { - return get_collision_layer() & (1 << p_bit); } void Area3D::set_audio_bus_override(bool p_override) { - audio_bus_override = p_override; } bool Area3D::is_overriding_audio_bus() const { - return audio_bus_override; } void Area3D::set_audio_bus(const StringName &p_audio_bus) { - audio_bus = p_audio_bus; } StringName Area3D::get_audio_bus() const { - for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (AudioServer::get_singleton()->get_bus_name(i) == audio_bus) { return audio_bus; @@ -562,20 +503,16 @@ StringName Area3D::get_audio_bus() const { } void Area3D::set_use_reverb_bus(bool p_enable) { - use_reverb_bus = p_enable; } bool Area3D::is_using_reverb_bus() const { - return use_reverb_bus; } void Area3D::set_reverb_bus(const StringName &p_audio_bus) { - reverb_bus = p_audio_bus; } StringName Area3D::get_reverb_bus() const { - for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (AudioServer::get_singleton()->get_bus_name(i) == reverb_bus) { return reverb_bus; @@ -585,27 +522,21 @@ StringName Area3D::get_reverb_bus() const { } void Area3D::set_reverb_amount(float p_amount) { - reverb_amount = p_amount; } float Area3D::get_reverb_amount() const { - return reverb_amount; } void Area3D::set_reverb_uniformity(float p_uniformity) { - reverb_uniformity = p_uniformity; } float Area3D::get_reverb_uniformity() const { - return reverb_uniformity; } void Area3D::_validate_property(PropertyInfo &property) const { - if (property.name == "audio_bus_name" || property.name == "reverb_bus_name") { - String options; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (i > 0) @@ -729,7 +660,6 @@ void Area3D::_bind_methods() { Area3D::Area3D() : CollisionObject3D(PhysicsServer3D::get_singleton()->area_create(), true) { - space_override = SPACE_OVERRIDE_DISABLED; set_gravity(9.8); locked = false; diff --git a/scene/3d/area_3d.h b/scene/3d/area_3d.h index f6503c6d2d..377cf3ccbb 100644 --- a/scene/3d/area_3d.h +++ b/scene/3d/area_3d.h @@ -35,7 +35,6 @@ #include "scene/3d/collision_object_3d.h" class Area3D : public CollisionObject3D { - GDCLASS(Area3D, CollisionObject3D); public: @@ -68,7 +67,6 @@ private: void _body_exit_tree(ObjectID p_id); struct ShapePair { - int body_shape; int area_shape; bool operator<(const ShapePair &p_sp) const { @@ -86,7 +84,6 @@ private: }; struct BodyState { - int rc; bool in_tree; VSet shapes; @@ -100,7 +97,6 @@ private: void _area_exit_tree(ObjectID p_id); struct AreaShapePair { - int area_shape; int self_shape; bool operator<(const AreaShapePair &p_sp) const { @@ -118,7 +114,6 @@ private: }; struct AreaState { - int rc; bool in_tree; VSet shapes; diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 8a00d67e12..83cf5b0142 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -138,7 +138,6 @@ void AudioStreamPlayer3D::_calc_output_vol(const Vector3 &source_dir, real_t tig } void AudioStreamPlayer3D::_mix_audio() { - if (!stream_playback.is_valid() || !active || (stream_paused && !stream_paused_fade_out)) { return; @@ -162,7 +161,6 @@ void AudioStreamPlayer3D::_mix_audio() { // Mix if we're not paused or we're fading out if ((output_count > 0 || out_of_range_mode == OUT_OF_RANGE_MIX)) { - float output_pitch_scale = 0.0; if (output_count) { //used for doppler, not realistic but good enough @@ -179,7 +177,6 @@ void AudioStreamPlayer3D::_mix_audio() { //write all outputs for (int i = 0; i < output_count; i++) { - Output current = outputs[i]; //see if current output exists, to keep volume ramp @@ -228,7 +225,6 @@ void AudioStreamPlayer3D::_mix_audio() { current.filter.set_gain(current.filter_gain); if (interpolate_filter) { - current.filter_process[k * 2 + 0] = prev_outputs[i].filter_process[k * 2 + 0]; current.filter_process[k * 2 + 1] = prev_outputs[i].filter_process[k * 2 + 1]; @@ -238,7 +234,6 @@ void AudioStreamPlayer3D::_mix_audio() { current.filter_process[k * 2 + 0].update_coeffs(buffer_size); current.filter_process[k * 2 + 1].update_coeffs(buffer_size); for (int j = 0; j < buffer_size; j++) { - AudioFrame f = buffer[j] * vol; current.filter_process[k * 2 + 0].process_one_interp(f.l); current.filter_process[k * 2 + 1].process_one_interp(f.r); @@ -253,7 +248,6 @@ void AudioStreamPlayer3D::_mix_audio() { current.filter_process[k * 2 + 0].update_coeffs(); current.filter_process[k * 2 + 1].update_coeffs(); for (int j = 0; j < buffer_size; j++) { - AudioFrame f = buffer[j] * vol; current.filter_process[k * 2 + 0].process_one(f.l); current.filter_process[k * 2 + 1].process_one(f.r); @@ -264,7 +258,6 @@ void AudioStreamPlayer3D::_mix_audio() { } if (current.reverb_bus_index >= 0) { - if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.reverb_bus_index, k)) continue; //may have been deleted, will be updated on process @@ -275,15 +268,12 @@ void AudioStreamPlayer3D::_mix_audio() { AudioFrame rvol = prev_outputs[i].reverb_vol[k]; for (int j = 0; j < buffer_size; j++) { - rtarget[j] += buffer[j] * rvol; rvol += rvol_inc; } } else { - AudioFrame rvol = current.reverb_vol[k]; for (int j = 0; j < buffer_size; j++) { - rtarget[j] += buffer[j] * rvol; } } @@ -306,7 +296,6 @@ void AudioStreamPlayer3D::_mix_audio() { } float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const { - float att = 0; switch (attenuation_model) { case ATTENUATION_INVERSE_DISTANCE: { @@ -340,9 +329,7 @@ void _update_sound() { } void AudioStreamPlayer3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - velocity_tracker->reset(get_global_transform().origin); AudioServer::get_singleton()->add_callback(_mix_audios, this); if (autoplay && !Engine::get_singleton()->is_editor_hint()) { @@ -351,7 +338,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE) { - AudioServer::get_singleton()->remove_callback(_mix_audios, this); } @@ -367,18 +353,15 @@ void AudioStreamPlayer3D::_notification(int p_what) { } if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - if (doppler_tracking != DOPPLER_TRACKING_DISABLED) { velocity_tracker->update_position(get_global_transform().origin); } } if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) { - //update anything related to position first, if possible of course if (!output_ready) { - Vector3 linear_velocity; //compute linear velocity for doppler @@ -423,7 +406,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { world_3d->get_camera_list(&cameras); for (List::Element *E = cameras.front(); E; E = E->next()) { - Camera3D *camera = E->get(); Viewport *vp = camera->get_viewport(); if (!vp->is_audio_listener()) @@ -451,7 +433,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { } if (max_distance > 0) { - float total_max = max_distance; if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) { @@ -497,7 +478,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { int vol_index_max = AudioServer::get_singleton()->get_speaker_mode() + 1; if (area) { - if (area->is_overriding_audio_bus()) { //override audio bus StringName bus_name = area->get_audio_bus(); @@ -505,7 +485,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { } if (area->is_using_reverb_bus()) { - filled_reverb = true; StringName bus_name = area->get_reverb_bus(); output.reverb_bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus_name); @@ -514,7 +493,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { float area_send = area->get_reverb_amount(); if (uniformity > 0.0) { - float distance = listener_area_pos.length(); float attenuation = Math::db2linear(_get_attenuation_db(distance)); @@ -556,26 +534,21 @@ void AudioStreamPlayer3D::_notification(int p_what) { } for (int i = 0; i < vol_index_max; i++) { - output.reverb_vol[i] = output.reverb_vol[i].lerp(center_frame, attenuation); } } else { for (int i = 0; i < vol_index_max; i++) { - output.reverb_vol[i] = center_frame; } } for (int i = 0; i < vol_index_max; i++) { - output.reverb_vol[i] = output.vol[i].lerp(output.reverb_vol[i] * attenuation, uniformity); output.reverb_vol[i] *= area_send; } } else { - for (int i = 0; i < vol_index_max; i++) { - output.reverb_vol[i] = output.vol[i] * area_send; } } @@ -583,7 +556,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { } if (doppler_tracking != DOPPLER_TRACKING_DISABLED) { - Vector3 listener_velocity; if (listener_is_camera) { @@ -608,9 +580,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { } if (!filled_reverb) { - for (int i = 0; i < vol_index_max; i++) { - output.reverb_vol[i] = AudioFrame(0, 0); } } @@ -645,7 +615,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { } void AudioStreamPlayer3D::set_stream(Ref p_stream) { - AudioServer::get_singleton()->lock(); mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size()); @@ -670,34 +639,27 @@ void AudioStreamPlayer3D::set_stream(Ref p_stream) { } Ref AudioStreamPlayer3D::get_stream() const { - return stream; } void AudioStreamPlayer3D::set_unit_db(float p_volume) { - unit_db = p_volume; } float AudioStreamPlayer3D::get_unit_db() const { - return unit_db; } void AudioStreamPlayer3D::set_unit_size(float p_volume) { - unit_size = p_volume; } float AudioStreamPlayer3D::get_unit_size() const { - return unit_size; } void AudioStreamPlayer3D::set_max_db(float p_boost) { - max_db = p_boost; } float AudioStreamPlayer3D::get_max_db() const { - return max_db; } @@ -710,7 +672,6 @@ float AudioStreamPlayer3D::get_pitch_scale() const { } void AudioStreamPlayer3D::play(float p_from_pos) { - if (!is_playing()) { // Reset the prev_output_count if the stream is stopped prev_output_count = 0; @@ -725,14 +686,12 @@ void AudioStreamPlayer3D::play(float p_from_pos) { } void AudioStreamPlayer3D::seek(float p_seconds) { - if (stream_playback.is_valid()) { setseek = p_seconds; } } void AudioStreamPlayer3D::stop() { - if (stream_playback.is_valid()) { active = false; set_physics_process_internal(false); @@ -741,7 +700,6 @@ void AudioStreamPlayer3D::stop() { } bool AudioStreamPlayer3D::is_playing() const { - if (stream_playback.is_valid()) { return active; // && stream_playback->is_playing(); } @@ -750,7 +708,6 @@ bool AudioStreamPlayer3D::is_playing() const { } float AudioStreamPlayer3D::get_playback_position() { - if (stream_playback.is_valid()) { return stream_playback->get_playback_position(); } @@ -759,14 +716,12 @@ float AudioStreamPlayer3D::get_playback_position() { } void AudioStreamPlayer3D::set_bus(const StringName &p_bus) { - //if audio is active, must lock this AudioServer::get_singleton()->lock(); bus = p_bus; AudioServer::get_singleton()->unlock(); } StringName AudioStreamPlayer3D::get_bus() const { - for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (AudioServer::get_singleton()->get_bus_name(i) == bus) { return bus; @@ -776,30 +731,24 @@ StringName AudioStreamPlayer3D::get_bus() const { } void AudioStreamPlayer3D::set_autoplay(bool p_enable) { - autoplay = p_enable; } bool AudioStreamPlayer3D::is_autoplay_enabled() { - return autoplay; } void AudioStreamPlayer3D::_set_playing(bool p_enable) { - if (p_enable) play(); else stop(); } bool AudioStreamPlayer3D::_is_active() const { - return active; } void AudioStreamPlayer3D::_validate_property(PropertyInfo &property) const { - if (property.name == "bus") { - String options; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (i > 0) @@ -813,28 +762,23 @@ void AudioStreamPlayer3D::_validate_property(PropertyInfo &property) const { } void AudioStreamPlayer3D::_bus_layout_changed() { - _change_notify(); } void AudioStreamPlayer3D::set_max_distance(float p_metres) { - ERR_FAIL_COND(p_metres < 0.0); max_distance = p_metres; } float AudioStreamPlayer3D::get_max_distance() const { - return max_distance; } void AudioStreamPlayer3D::set_area_mask(uint32_t p_mask) { - area_mask = p_mask; } uint32_t AudioStreamPlayer3D::get_area_mask() const { - return area_mask; } @@ -859,30 +803,24 @@ float AudioStreamPlayer3D::get_emission_angle() const { } void AudioStreamPlayer3D::set_emission_angle_filter_attenuation_db(float p_angle_attenuation_db) { - emission_angle_filter_attenuation_db = p_angle_attenuation_db; } float AudioStreamPlayer3D::get_emission_angle_filter_attenuation_db() const { - return emission_angle_filter_attenuation_db; } void AudioStreamPlayer3D::set_attenuation_filter_cutoff_hz(float p_hz) { - attenuation_filter_cutoff_hz = p_hz; } float AudioStreamPlayer3D::get_attenuation_filter_cutoff_hz() const { - return attenuation_filter_cutoff_hz; } void AudioStreamPlayer3D::set_attenuation_filter_db(float p_db) { - attenuation_filter_db = p_db; } float AudioStreamPlayer3D::get_attenuation_filter_db() const { - return attenuation_filter_db; } @@ -896,18 +834,15 @@ AudioStreamPlayer3D::AttenuationModel AudioStreamPlayer3D::get_attenuation_model } void AudioStreamPlayer3D::set_out_of_range_mode(OutOfRangeMode p_mode) { - ERR_FAIL_INDEX((int)p_mode, 2); out_of_range_mode = p_mode; } AudioStreamPlayer3D::OutOfRangeMode AudioStreamPlayer3D::get_out_of_range_mode() const { - return out_of_range_mode; } void AudioStreamPlayer3D::set_doppler_tracking(DopplerTracking p_tracking) { - if (doppler_tracking == p_tracking) return; @@ -925,12 +860,10 @@ void AudioStreamPlayer3D::set_doppler_tracking(DopplerTracking p_tracking) { } AudioStreamPlayer3D::DopplerTracking AudioStreamPlayer3D::get_doppler_tracking() const { - return doppler_tracking; } void AudioStreamPlayer3D::set_stream_paused(bool p_pause) { - if (p_pause != stream_paused) { stream_paused = p_pause; stream_paused_fade_in = !stream_paused; @@ -939,7 +872,6 @@ void AudioStreamPlayer3D::set_stream_paused(bool p_pause) { } bool AudioStreamPlayer3D::get_stream_paused() const { - return stream_paused; } @@ -948,7 +880,6 @@ Ref AudioStreamPlayer3D::get_stream_playback() { } void AudioStreamPlayer3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_stream", "stream"), &AudioStreamPlayer3D::set_stream); ClassDB::bind_method(D_METHOD("get_stream"), &AudioStreamPlayer3D::get_stream); @@ -1054,7 +985,6 @@ void AudioStreamPlayer3D::_bind_methods() { } AudioStreamPlayer3D::AudioStreamPlayer3D() { - unit_db = 0; unit_size = 1; attenuation_model = ATTENUATION_INVERSE_DISTANCE; diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h index 13e08339e2..9f261c54b4 100644 --- a/scene/3d/audio_stream_player_3d.h +++ b/scene/3d/audio_stream_player_3d.h @@ -39,7 +39,6 @@ class Camera3D; class AudioStreamPlayer3D : public Node3D { - GDCLASS(AudioStreamPlayer3D, Node3D); public: @@ -69,7 +68,6 @@ private: }; struct Output { - AudioFilterSW filter; AudioFilterSW::Processor filter_process[8]; AudioFrame vol[4]; diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index 82a9a1e589..8838295e93 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -41,7 +41,6 @@ #include "lightmap_probe.h" void BakedLightmapData::add_user(const NodePath &p_path, const Rect2 &p_uv_scale, int p_slice_index, int32_t p_sub_instance) { - User user; user.path = p_path; user.uv_scale = p_uv_scale; @@ -51,29 +50,24 @@ void BakedLightmapData::add_user(const NodePath &p_path, const Rect2 &p_uv_scale } int BakedLightmapData::get_user_count() const { - return users.size(); } NodePath BakedLightmapData::get_user_path(int p_user) const { - ERR_FAIL_INDEX_V(p_user, users.size(), NodePath()); return users[p_user].path; } int32_t BakedLightmapData::get_user_sub_instance(int p_user) const { - ERR_FAIL_INDEX_V(p_user, users.size(), -1); return users[p_user].sub_instance; } Rect2 BakedLightmapData::get_user_lightmap_uv_scale(int p_user) const { - ERR_FAIL_INDEX_V(p_user, users.size(), Rect2()); return users[p_user].uv_scale; } int BakedLightmapData::get_user_lightmap_slice_index(int p_user) const { - ERR_FAIL_INDEX_V(p_user, users.size(), -1); return users[p_user].slice_index; } @@ -83,7 +77,6 @@ void BakedLightmapData::clear_users() { } void BakedLightmapData::_set_user_data(const Array &p_data) { - ERR_FAIL_COND((p_data.size() % 4) != 0); for (int i = 0; i < p_data.size(); i += 4) { @@ -92,7 +85,6 @@ void BakedLightmapData::_set_user_data(const Array &p_data) { } Array BakedLightmapData::_get_user_data() const { - Array ret; for (int i = 0; i < users.size(); i++) { ret.push_back(users[i].path); @@ -190,7 +182,6 @@ Dictionary BakedLightmapData::_get_probe_data() const { return d; } void BakedLightmapData::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_user_data", "data"), &BakedLightmapData::_set_user_data); ClassDB::bind_method(D_METHOD("_get_user_data"), &BakedLightmapData::_get_user_data); @@ -215,28 +206,23 @@ void BakedLightmapData::_bind_methods() { } BakedLightmapData::BakedLightmapData() { - lightmap = RS::get_singleton()->lightmap_create(); } BakedLightmapData::~BakedLightmapData() { - RS::get_singleton()->free(lightmap); } /////////////////////////// void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector &meshes, Vector &lights, Vector &probes) { - MeshInstance3D *mi = Object::cast_to(p_at_node); if (mi && mi->get_gi_mode() == GeometryInstance3D::GI_MODE_BAKED && mi->is_visible_in_tree()) { Ref mesh = mi->get_mesh(); if (mesh.is_valid()) { - bool all_have_uv2_and_normal = true; bool surfaces_found = false; for (int i = 0; i < mesh->get_surface_count(); i++) { - if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { continue; } @@ -284,7 +270,6 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector if (bmeshes.size() && (bmeshes.size() & 1) == 0) { Transform xf = get_global_transform().affine_inverse() * s->get_global_transform(); for (int i = 0; i < bmeshes.size(); i += 2) { - Ref mesh = bmeshes[i]; if (!mesh.is_valid()) continue; @@ -306,7 +291,6 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector Light3D *light = Object::cast_to(p_at_node); if (light && light->get_bake_mode() != Light3D::BAKE_DISABLED) { - LightsFound lf; lf.xform = get_global_transform().affine_inverse() * light->get_global_transform(); lf.light = light; @@ -321,7 +305,6 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector } for (int i = 0; i < p_at_node->get_child_count(); i++) { - Node *child = p_at_node->get_child(i); if (!child->get_owner()) continue; //maybe a helper @@ -331,7 +314,6 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector } int BakedLightmap::_bsp_get_simplex_side(const Vector &p_points, const LocalVector &p_simplices, const Plane &p_plane, uint32_t p_simplex) const { - int over = 0; int under = 0; int coplanar = 0; @@ -360,7 +342,6 @@ int BakedLightmap::_bsp_get_simplex_side(const Vector &p_points, const //#define DEBUG_BSP int32_t BakedLightmap::_compute_bsp_tree(const Vector &p_points, const LocalVector &p_planes, LocalVector &planes_tested, const LocalVector &p_simplices, const LocalVector &p_simplex_indices, LocalVector &bsp_nodes) { - //if we reach here, it means there is more than one simplex int32_t node_index = (int32_t)bsp_nodes.size(); bsp_nodes.push_back(BSPNode()); @@ -427,7 +408,6 @@ int32_t BakedLightmap::_compute_bsp_tree(const Vector &p_points, const //score *= Math::sqrt(float(over_count + under_count) / p_simplex_indices.size()); //also multiply score if (score > best_plane_score) { - best_plane = plane; best_plane_score = score; } @@ -439,7 +419,6 @@ int32_t BakedLightmap::_compute_bsp_tree(const Vector &p_points, const //split again, but add to list for (uint32_t i = 0; i < p_simplex_indices.size(); i++) { - uint32_t index = p_simplex_indices[i]; int side = _bsp_get_simplex_side(p_points, p_simplices, best_plane, index); @@ -478,7 +457,6 @@ int32_t BakedLightmap::_compute_bsp_tree(const Vector &p_points, const for (uint32_t i = 0; i < p_simplex_indices.size(); i++) { AABB bounds; for (uint32_t j = 0; j < 4; j++) { - Vector3 p = p_points[p_simplices[p_simplex_indices[i]].vertices[j]]; if (j == 0) { bounds.position = p; @@ -549,7 +527,6 @@ int32_t BakedLightmap::_compute_bsp_tree(const Vector &p_points, const } bool BakedLightmap::_lightmap_bake_step_function(float p_completion, const String &p_text, void *ud, bool p_refresh) { - BakeStepUD *bsud = (BakeStepUD *)ud; bool ret = false; if (bsud->func) { @@ -559,7 +536,6 @@ bool BakedLightmap::_lightmap_bake_step_function(float p_completion, const Strin } void BakedLightmap::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_cell_size, const Vector3 *p_triangle) { - for (int i = 0; i < 8; i++) { Vector3i pos = p_cell->offset; uint32_t half_size = p_cell->size / 2; @@ -594,9 +570,7 @@ void BakedLightmap::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_ } } void BakedLightmap::_gen_new_positions_from_octree(const GenProbesOctree *p_cell, float p_cell_size, const Vector &probe_positions, LocalVector &new_probe_positions, HashMap &positions_used, const AABB &p_bounds) { - for (int i = 0; i < 8; i++) { - Vector3i pos = p_cell->offset; if (i & 1) { pos.x += p_cell->size; @@ -616,7 +590,6 @@ void BakedLightmap::_gen_new_positions_from_octree(const GenProbesOctree *p_cell const Vector3 *pp = probe_positions.ptr(); bool exists = false; for (int j = 0; j < ppcount; j++) { - if (pp[j].distance_to(real_pos) < CMP_EPSILON) { exists = true; break; @@ -636,13 +609,11 @@ void BakedLightmap::_gen_new_positions_from_octree(const GenProbesOctree *p_cell } } BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_data_path, Lightmapper::BakeStepFunc p_bake_step, void *p_bake_userdata) { - if (p_image_data_path == "" && (get_light_data().is_null() || !get_light_data()->get_path().is_resource_file())) { return BAKE_ERROR_NO_SAVE_PATH; } if (p_image_data_path == "") { - if (get_light_data().is_null()) { return BAKE_ERROR_NO_SAVE_PATH; } @@ -681,7 +652,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d //get the base material textures, help compute altlas size and bounds for (int m_i = 0; m_i < meshes_found.size(); m_i++) { - if (p_bake_step) { float p = (float)(m_i) / meshes_found.size(); p_bake_step(p * 0.1, vformat(TTR("Preparing geometry %d/%d"), m_i, meshes_found.size()), p_bake_userdata, false); @@ -718,7 +688,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d } { - if (albedo->get_format() != Image::FORMAT_RGBA8) { albedo->convert(Image::FORMAT_RGBA8); } @@ -779,7 +748,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d const int *ir = nullptr; if (index.size()) { - facecount = index.size() / 3; ir = index.ptr(); } else { @@ -787,7 +755,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d } for (int j = 0; j < facecount; j++) { - uint32_t vidx[3]; if (ir) { @@ -893,7 +860,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d } //skip first level, since probes are always added at bounds endpoints anyway (code above this) for (int i = 0; i < 8; i++) { - if (octree.children[i]) { _gen_new_positions_from_octree(octree.children[i], subdiv_cell_size, probes_found, new_probe_positions, positions_used, bounds); } @@ -910,7 +876,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d } { - for (int i = 0; i < mesh_data.size(); i++) { lightmapper->add_mesh(mesh_data[i]); } @@ -995,7 +960,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d Ref texture; { - Vector> images; for (int i = 0; i < lightmapper->get_bake_texture_count(); i++) { images.push_back(lightmapper->get_bake_texture(i)); @@ -1016,7 +980,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d config.instance(); if (FileAccess::exists(base_path + ".import")) { - config->load(base_path + ".import"); } @@ -1095,7 +1058,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d PackedInt32Array tetrahedrons; for (int i = 0; i < solved_simplices.size(); i++) { - //Prepare a special representation of the simplex, which uses a BSP Tree BSPSimplex bsp_simplex; for (int j = 0; j < 4; j++) { @@ -1117,7 +1079,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d Plane p(a, b, c); int plane_index = -1; for (uint32_t k = 0; k < bsp_planes.size(); k++) { - if (bsp_planes[k].is_equal_approx_any_side(p)) { plane_index = k; break; @@ -1218,14 +1179,12 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d void BakedLightmap::_notification(int p_what) { if (p_what == NOTIFICATION_POST_ENTER_TREE) { - if (light_data.is_valid()) { _assign_lightmaps(); } } if (p_what == NOTIFICATION_EXIT_TREE) { - if (light_data.is_valid()) { _clear_lightmaps(); } @@ -1233,11 +1192,9 @@ void BakedLightmap::_notification(int p_what) { } void BakedLightmap::_assign_lightmaps() { - ERR_FAIL_COND(!light_data.is_valid()); for (int i = 0; i < light_data->get_user_count(); i++) { - Node *node = get_node(light_data->get_user_path(i)); int instance_idx = light_data->get_user_sub_instance(i); if (instance_idx >= 0) { @@ -1272,7 +1229,6 @@ void BakedLightmap::_clear_lightmaps() { } void BakedLightmap::set_light_data(const Ref &p_data) { - if (light_data.is_valid()) { if (is_inside_tree()) { _clear_lightmaps(); @@ -1292,7 +1248,6 @@ void BakedLightmap::set_light_data(const Ref &p_data) { } Ref BakedLightmap::get_light_data() const { - return light_data; } @@ -1312,12 +1267,10 @@ Vector BakedLightmap::get_faces(uint32_t p_usage_flags) const { } void BakedLightmap::set_use_denoiser(bool p_enable) { - use_denoiser = p_enable; } bool BakedLightmap::is_using_denoiser() const { - return use_denoiser; } @@ -1415,7 +1368,6 @@ void BakedLightmap::_validate_property(PropertyInfo &property) const { } void BakedLightmap::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_light_data", "data"), &BakedLightmap::set_light_data); ClassDB::bind_method(D_METHOD("get_light_data"), &BakedLightmap::get_light_data); @@ -1501,7 +1453,6 @@ void BakedLightmap::_bind_methods() { } BakedLightmap::BakedLightmap() { - environment_mode = ENVIRONMENT_MODE_DISABLED; environment_custom_color = Color(0.2, 0.7, 1.0); environment_custom_energy = 1.0; diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h index 748fdf913f..08098c3d5d 100644 --- a/scene/3d/baked_lightmap.h +++ b/scene/3d/baked_lightmap.h @@ -52,7 +52,6 @@ class BakedLightmapData : public Resource { AABB bounds; struct User { - NodePath path; int32_t sub_instance; Rect2 uv_scale; diff --git a/scene/3d/bone_attachment_3d.cpp b/scene/3d/bone_attachment_3d.cpp index 825cb39e2d..5e4b995aa1 100644 --- a/scene/3d/bone_attachment_3d.cpp +++ b/scene/3d/bone_attachment_3d.cpp @@ -31,12 +31,10 @@ #include "bone_attachment_3d.h" void BoneAttachment3D::_validate_property(PropertyInfo &property) const { - if (property.name == "bone_name") { Skeleton3D *parent = Object::cast_to(get_parent()); if (parent) { - String names; for (int i = 0; i < parent->get_bone_count(); i++) { if (i > 0) @@ -47,7 +45,6 @@ void BoneAttachment3D::_validate_property(PropertyInfo &property) const { property.hint = PROPERTY_HINT_ENUM; property.hint_string = names; } else { - property.hint = PROPERTY_HINT_NONE; property.hint_string = ""; } @@ -55,10 +52,8 @@ void BoneAttachment3D::_validate_property(PropertyInfo &property) const { } void BoneAttachment3D::_check_bind() { - Skeleton3D *sk = Object::cast_to(get_parent()); if (sk) { - int idx = sk->find_bone(bone_name); if (idx != -1) { sk->bind_child_node_to_bone(idx, this); @@ -69,12 +64,9 @@ void BoneAttachment3D::_check_bind() { } void BoneAttachment3D::_check_unbind() { - if (bound) { - Skeleton3D *sk = Object::cast_to(get_parent()); if (sk) { - int idx = sk->find_bone(bone_name); if (idx != -1) { sk->unbind_child_node_from_bone(idx, this); @@ -85,7 +77,6 @@ void BoneAttachment3D::_check_unbind() { } void BoneAttachment3D::set_bone_name(const String &p_name) { - if (is_inside_tree()) _check_unbind(); @@ -96,20 +87,15 @@ void BoneAttachment3D::set_bone_name(const String &p_name) { } String BoneAttachment3D::get_bone_name() const { - return bone_name; } void BoneAttachment3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - _check_bind(); } break; case NOTIFICATION_EXIT_TREE: { - _check_unbind(); } break; } diff --git a/scene/3d/bone_attachment_3d.h b/scene/3d/bone_attachment_3d.h index d2a3ffec90..fec59217d2 100644 --- a/scene/3d/bone_attachment_3d.h +++ b/scene/3d/bone_attachment_3d.h @@ -34,7 +34,6 @@ #include "scene/3d/skeleton_3d.h" class BoneAttachment3D : public Node3D { - GDCLASS(BoneAttachment3D, Node3D); bool bound; diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 871f3119bc..0f7aa28bf3 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -39,16 +39,13 @@ void Camera3D::_update_audio_listener_state() { } void Camera3D::_request_camera_update() { - _update_camera(); } void Camera3D::_update_camera_mode() { - force_change = true; switch (mode) { case PROJECTION_PERSPECTIVE: { - set_perspective(fov, near, far); } break; @@ -78,7 +75,6 @@ void Camera3D::_validate_property(PropertyInfo &p_property) const { } void Camera3D::_update_camera() { - if (!is_inside_tree()) return; @@ -101,11 +97,8 @@ void Camera3D::_update_camera() { } void Camera3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_WORLD: { - // Needs to track the Viewport because it's needed on NOTIFICATION_EXIT_WORLD // and Spatial will handle it first, including clearing its reference to the Viewport, // therefore making it impossible to subclasses to access it @@ -118,14 +111,12 @@ void Camera3D::_notification(int p_what) { } 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()) { clear_current(); @@ -156,7 +147,6 @@ void Camera3D::_notification(int p_what) { } Transform Camera3D::get_camera_transform() const { - Transform tr = get_global_transform().orthonormalized(); tr.origin += tr.basis.get_axis(1) * v_offset; tr.origin += tr.basis.get_axis(0) * h_offset; @@ -164,7 +154,6 @@ Transform Camera3D::get_camera_transform() const { } void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far) { - if (!force_change && fov == p_fovy_degrees && p_z_near == near && p_z_far == far && mode == PROJECTION_PERSPECTIVE) return; @@ -178,7 +167,6 @@ void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_f force_change = false; } void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) { - if (!force_change && size == p_size && p_z_near == near && p_z_far == far && mode == PROJECTION_ORTHOGONAL) return; @@ -218,12 +206,10 @@ void Camera3D::set_projection(Camera3D::Projection p_mode) { } RID Camera3D::get_camera() const { - return camera; }; void Camera3D::make_current() { - current = true; if (!is_inside_tree()) @@ -235,7 +221,6 @@ void Camera3D::make_current() { } void Camera3D::clear_current(bool p_enable_next) { - current = false; if (!is_inside_tree()) return; @@ -258,27 +243,22 @@ void Camera3D::set_current(bool p_current) { } bool Camera3D::is_current() const { - if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) { - return get_viewport()->get_camera() == this; } else return current; } bool Camera3D::_can_gizmo_scale() const { - return false; } Vector3 Camera3D::project_ray_normal(const Point2 &p_pos) const { - Vector3 ray = project_local_ray_normal(p_pos); return get_camera_transform().basis.xform(ray).normalized(); }; Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const { - ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_camera_rect_size(); @@ -286,7 +266,6 @@ Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const { Vector3 ray; if (mode == PROJECTION_ORTHOGONAL) { - ray = Vector3(0, 0, -1); } else { CameraMatrix cm; @@ -299,7 +278,6 @@ Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const { }; Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const { - ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_camera_rect_size(); @@ -307,10 +285,8 @@ Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const { ERR_FAIL_COND_V(viewport_size.y == 0, Vector3()); if (mode == PROJECTION_PERSPECTIVE) { - return get_camera_transform().origin; } else { - Vector2 pos = cpos / viewport_size; float vsize, hsize; if (keep_aspect == KEEP_WIDTH) { @@ -331,7 +307,6 @@ Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const { }; bool Camera3D::is_position_behind(const Vector3 &p_pos) const { - Transform t = get_global_transform(); Vector3 eyedir = -get_global_transform().basis.get_axis(2).normalized(); return eyedir.dot(p_pos) < (eyedir.dot(t.origin) + near); @@ -361,7 +336,6 @@ Vector Camera3D::get_near_plane_points() const { } Point2 Camera3D::unproject_position(const Vector3 &p_pos) const { - ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector2(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_visible_rect().size; @@ -386,7 +360,6 @@ Point2 Camera3D::unproject_position(const Vector3 &p_pos) const { } Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const { - ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); if (p_z_depth == 0 && mode != PROJECTION_ORTHOGONAL) { @@ -414,7 +387,6 @@ Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const } void Camera3D::set_environment(const Ref &p_environment) { - environment = p_environment; if (environment.is_valid()) RS::get_singleton()->camera_set_environment(camera, environment->get_rid()); @@ -424,12 +396,10 @@ void Camera3D::set_environment(const Ref &p_environment) { } Ref Camera3D::get_environment() const { - return environment; } void Camera3D::set_effects(const Ref &p_effects) { - effects = p_effects; if (effects.is_valid()) RS::get_singleton()->camera_set_camera_effects(camera, effects->get_rid()); @@ -439,7 +409,6 @@ void Camera3D::set_effects(const Ref &p_effects) { } Ref Camera3D::get_effects() const { - return effects; } @@ -451,12 +420,10 @@ void Camera3D::set_keep_aspect_mode(KeepAspect p_aspect) { } Camera3D::KeepAspect Camera3D::get_keep_aspect_mode() const { - return keep_aspect; } void Camera3D::set_doppler_tracking(DopplerTracking p_tracking) { - if (doppler_tracking == p_tracking) return; @@ -475,7 +442,6 @@ Camera3D::DopplerTracking Camera3D::get_doppler_tracking() const { } void Camera3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("project_ray_normal", "screen_point"), &Camera3D::project_ray_normal); ClassDB::bind_method(D_METHOD("project_local_ray_normal", "screen_point"), &Camera3D::project_local_ray_normal); ClassDB::bind_method(D_METHOD("project_ray_origin", "screen_point"), &Camera3D::project_ray_origin); @@ -552,17 +518,14 @@ void Camera3D::_bind_methods() { } float Camera3D::get_fov() const { - return fov; } float Camera3D::get_size() const { - return size; } float Camera3D::get_znear() const { - return near; } @@ -571,12 +534,10 @@ Vector2 Camera3D::get_frustum_offset() const { } float Camera3D::get_zfar() const { - return far; } Camera3D::Projection Camera3D::get_projection() const { - return mode; } @@ -616,7 +577,6 @@ void Camera3D::set_cull_mask(uint32_t p_layers) { } uint32_t Camera3D::get_cull_mask() const { - return layers; } @@ -635,7 +595,6 @@ bool Camera3D::get_cull_mask_bit(int p_layer) const { } Vector Camera3D::get_frustum() const { - ERR_FAIL_COND_V(!is_inside_world(), Vector()); Size2 viewport_size = get_viewport()->get_visible_rect().size; @@ -649,13 +608,11 @@ Vector Camera3D::get_frustum() const { } void Camera3D::set_v_offset(float p_offset) { - v_offset = p_offset; _update_camera(); } float Camera3D::get_v_offset() const { - return v_offset; } @@ -665,12 +622,10 @@ void Camera3D::set_h_offset(float p_offset) { } float Camera3D::get_h_offset() const { - return h_offset; } Vector3 Camera3D::get_doppler_tracked_velocity() const { - if (doppler_tracking != DOPPLER_TRACKING_DISABLED) { return velocity_tracker->get_tracked_linear_velocity(); } else { @@ -678,7 +633,6 @@ Vector3 Camera3D::get_doppler_tracked_velocity() const { } } Camera3D::Camera3D() { - camera = RenderingServer::get_singleton()->camera_create(); size = 1; fov = 0; @@ -703,7 +657,6 @@ Camera3D::Camera3D() { } Camera3D::~Camera3D() { - RenderingServer::get_singleton()->free(camera); } @@ -716,7 +669,6 @@ float ClippedCamera3D::get_margin() const { return margin; } void ClippedCamera3D::set_process_mode(ProcessMode p_mode) { - if (process_mode == p_mode) { return; } @@ -729,7 +681,6 @@ ClippedCamera3D::ProcessMode ClippedCamera3D::get_process_mode() const { } Transform ClippedCamera3D::get_camera_transform() const { - Transform t = Camera3D::get_camera_transform(); t.origin += -t.basis.get_axis(Vector3::AXIS_Z).normalized() * clip_offset; return t; @@ -737,7 +688,6 @@ Transform ClippedCamera3D::get_camera_transform() const { void ClippedCamera3D::_notification(int p_what) { if (p_what == NOTIFICATION_INTERNAL_PROCESS || p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) { - Node3D *parent = Object::cast_to(get_parent()); if (!parent) { return; @@ -797,17 +747,14 @@ void ClippedCamera3D::_notification(int p_what) { } void ClippedCamera3D::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; } uint32_t ClippedCamera3D::get_collision_mask() const { - return collision_mask; } void ClippedCamera3D::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -817,17 +764,14 @@ void ClippedCamera3D::set_collision_mask_bit(int p_bit, bool p_value) { } bool ClippedCamera3D::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } void ClippedCamera3D::add_exception_rid(const RID &p_rid) { - exclude.insert(p_rid); } void ClippedCamera3D::add_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); const CollisionObject3D *co = Object::cast_to(p_object); if (!co) @@ -836,12 +780,10 @@ void ClippedCamera3D::add_exception(const Object *p_object) { } void ClippedCamera3D::remove_exception_rid(const RID &p_rid) { - exclude.erase(p_rid); } void ClippedCamera3D::remove_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); const CollisionObject3D *co = Object::cast_to(p_object); if (!co) @@ -850,37 +792,30 @@ void ClippedCamera3D::remove_exception(const Object *p_object) { } void ClippedCamera3D::clear_exceptions() { - exclude.clear(); } float ClippedCamera3D::get_clip_offset() const { - return clip_offset; } void ClippedCamera3D::set_clip_to_areas(bool p_clip) { - clip_to_areas = p_clip; } bool ClippedCamera3D::is_clip_to_areas_enabled() const { - return clip_to_areas; } void ClippedCamera3D::set_clip_to_bodies(bool p_clip) { - clip_to_bodies = p_clip; } bool ClippedCamera3D::is_clip_to_bodies_enabled() const { - return clip_to_bodies; } void ClippedCamera3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_margin", "margin"), &ClippedCamera3D::set_margin); ClassDB::bind_method(D_METHOD("get_margin"), &ClippedCamera3D::get_margin); diff --git a/scene/3d/camera_3d.h b/scene/3d/camera_3d.h index 9a005226cb..138b1b8a7a 100644 --- a/scene/3d/camera_3d.h +++ b/scene/3d/camera_3d.h @@ -37,7 +37,6 @@ #include "scene/resources/environment.h" class Camera3D : public Node3D { - GDCLASS(Camera3D, Node3D); public: @@ -184,7 +183,6 @@ VARIANT_ENUM_CAST(Camera3D::KeepAspect); VARIANT_ENUM_CAST(Camera3D::DopplerTracking); class ClippedCamera3D : public Camera3D { - GDCLASS(ClippedCamera3D, Camera3D); public: diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index 5d050e32b0..9aaa182a13 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -34,11 +34,8 @@ #include "servers/physics_server_3d.h" void CollisionObject3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_WORLD: { - if (area) PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform()); else @@ -55,7 +52,6 @@ void CollisionObject3D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - if (area) PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform()); else @@ -63,12 +59,10 @@ void CollisionObject3D::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { - _update_pickable(); } break; case NOTIFICATION_EXIT_WORLD: { - if (area) { PhysicsServer3D::get_singleton()->area_set_space(rid, RID()); } else @@ -79,7 +73,6 @@ void CollisionObject3D::_notification(int p_what) { } void CollisionObject3D::_input_event(Node *p_camera, const Ref &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_input_event, p_camera, p_input_event, p_pos, p_normal, p_shape); } @@ -87,7 +80,6 @@ void CollisionObject3D::_input_event(Node *p_camera, const Ref &p_in } void CollisionObject3D::_mouse_enter() { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter); } @@ -95,7 +87,6 @@ void CollisionObject3D::_mouse_enter() { } void CollisionObject3D::_mouse_exit() { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit); } @@ -114,18 +105,15 @@ void CollisionObject3D::_update_pickable() { } void CollisionObject3D::set_ray_pickable(bool p_ray_pickable) { - ray_pickable = p_ray_pickable; _update_pickable(); } bool CollisionObject3D::is_ray_pickable() const { - return ray_pickable; } void CollisionObject3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &CollisionObject3D::set_ray_pickable); ClassDB::bind_method(D_METHOD("is_ray_pickable"), &CollisionObject3D::is_ray_pickable); ClassDB::bind_method(D_METHOD("set_capture_input_on_drag", "enable"), &CollisionObject3D::set_capture_input_on_drag); @@ -158,7 +146,6 @@ void CollisionObject3D::_bind_methods() { } uint32_t CollisionObject3D::create_shape_owner(Object *p_owner) { - ShapeData sd; uint32_t id; @@ -176,7 +163,6 @@ uint32_t CollisionObject3D::create_shape_owner(Object *p_owner) { } void CollisionObject3D::remove_shape_owner(uint32_t owner) { - ERR_FAIL_COND(!shapes.has(owner)); shape_owner_clear_shapes(owner); @@ -199,21 +185,18 @@ void CollisionObject3D::shape_owner_set_disabled(uint32_t p_owner, bool p_disabl } bool CollisionObject3D::is_shape_owner_disabled(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), false); return shapes[p_owner].disabled; } void CollisionObject3D::get_shape_owners(List *r_owners) { - for (Map::Element *E = shapes.front(); E; E = E->next()) { r_owners->push_back(E->key()); } } Array CollisionObject3D::_get_shape_owners() { - Array ret; for (Map::Element *E = shapes.front(); E; E = E->next()) { ret.push_back(E->key()); @@ -223,7 +206,6 @@ Array CollisionObject3D::_get_shape_owners() { } void CollisionObject3D::shape_owner_set_transform(uint32_t p_owner, const Transform &p_transform) { - ERR_FAIL_COND(!shapes.has(p_owner)); ShapeData &sd = shapes[p_owner]; @@ -237,21 +219,18 @@ void CollisionObject3D::shape_owner_set_transform(uint32_t p_owner, const Transf } } Transform CollisionObject3D::shape_owner_get_transform(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), Transform()); return shapes[p_owner].xform; } Object *CollisionObject3D::shape_owner_get_owner(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr); return shapes[p_owner].owner; } void CollisionObject3D::shape_owner_add_shape(uint32_t p_owner, const Ref &p_shape) { - ERR_FAIL_COND(!shapes.has(p_owner)); ERR_FAIL_COND(p_shape.is_null()); @@ -269,20 +248,17 @@ void CollisionObject3D::shape_owner_add_shape(uint32_t p_owner, const Ref CollisionObject3D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), Ref()); ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref()); return shapes[p_owner].shapes[p_shape].shape; } int CollisionObject3D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), -1); ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), -1); @@ -290,7 +266,6 @@ int CollisionObject3D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape } void CollisionObject3D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) { - ERR_FAIL_COND(!shapes.has(p_owner)); ERR_FAIL_INDEX(p_shape, shapes[p_owner].shapes.size()); @@ -315,7 +290,6 @@ void CollisionObject3D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) } void CollisionObject3D::shape_owner_clear_shapes(uint32_t p_owner) { - ERR_FAIL_COND(!shapes.has(p_owner)); while (shape_owner_get_shape_count(p_owner) > 0) { @@ -324,7 +298,6 @@ void CollisionObject3D::shape_owner_clear_shapes(uint32_t p_owner) { } uint32_t CollisionObject3D::shape_find_owner(int p_shape_index) const { - ERR_FAIL_INDEX_V(p_shape_index, total_subshapes, 0); for (const Map::Element *E = shapes.front(); E; E = E->next()) { @@ -340,7 +313,6 @@ uint32_t CollisionObject3D::shape_find_owner(int p_shape_index) const { } CollisionObject3D::CollisionObject3D(RID p_rid, bool p_area) { - rid = p_rid; area = p_area; capture_input_on_drag = false; @@ -357,17 +329,14 @@ CollisionObject3D::CollisionObject3D(RID p_rid, bool p_area) { } void CollisionObject3D::set_capture_input_on_drag(bool p_capture) { - capture_input_on_drag = p_capture; } bool CollisionObject3D::get_capture_input_on_drag() const { - return capture_input_on_drag; } String CollisionObject3D::get_configuration_warning() const { - String warning = Node3D::get_configuration_warning(); if (shapes.empty()) { @@ -381,7 +350,6 @@ String CollisionObject3D::get_configuration_warning() const { } CollisionObject3D::CollisionObject3D() { - capture_input_on_drag = false; ray_pickable = true; set_notify_transform(true); @@ -391,6 +359,5 @@ CollisionObject3D::CollisionObject3D() { } CollisionObject3D::~CollisionObject3D() { - PhysicsServer3D::get_singleton()->free(rid); } diff --git a/scene/3d/collision_object_3d.h b/scene/3d/collision_object_3d.h index 67d3aed3c8..8bcbef0e98 100644 --- a/scene/3d/collision_object_3d.h +++ b/scene/3d/collision_object_3d.h @@ -35,7 +35,6 @@ #include "scene/resources/shape_3d.h" class CollisionObject3D : public Node3D { - GDCLASS(CollisionObject3D, Node3D); bool area; @@ -43,7 +42,6 @@ class CollisionObject3D : public Node3D { RID rid; struct ShapeData { - Object *owner; Transform xform; struct ShapeBase { diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp index 66bd903eeb..bf123fa417 100644 --- a/scene/3d/collision_polygon_3d.cpp +++ b/scene/3d/collision_polygon_3d.cpp @@ -35,7 +35,6 @@ #include "scene/resources/convex_polygon_shape_3d.h" void CollisionPolygon3D::_build_polygon() { - if (!parent) return; @@ -60,7 +59,6 @@ void CollisionPolygon3D::_build_polygon() { Vector3 *w = cp.ptrw(); int idx = 0; for (int j = 0; j < cs; j++) { - Vector2 d = decomp[i][j]; w[idx++] = Vector3(d.x, d.y, depth * 0.5); w[idx++] = Vector3(d.x, d.y, -depth * 0.5); @@ -74,7 +72,6 @@ void CollisionPolygon3D::_build_polygon() { } void CollisionPolygon3D::_update_in_shape_owner(bool p_xform_only) { - parent->shape_owner_set_transform(owner_id, get_transform()); if (p_xform_only) return; @@ -82,9 +79,7 @@ void CollisionPolygon3D::_update_in_shape_owner(bool p_xform_only) { } void CollisionPolygon3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_PARENTED: { parent = Object::cast_to(get_parent()); if (parent) { @@ -94,14 +89,12 @@ void CollisionPolygon3D::_notification(int p_what) { } } break; case NOTIFICATION_ENTER_TREE: { - if (parent) { _update_in_shape_owner(); } } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (parent) { _update_in_shape_owner(true); } @@ -118,7 +111,6 @@ void CollisionPolygon3D::_notification(int p_what) { } void CollisionPolygon3D::set_polygon(const Vector &p_polygon) { - polygon = p_polygon; if (parent) { _build_polygon(); @@ -128,24 +120,20 @@ void CollisionPolygon3D::set_polygon(const Vector &p_polygon) { } Vector CollisionPolygon3D::get_polygon() const { - return polygon; } AABB CollisionPolygon3D::get_item_rect() const { - return aabb; } void CollisionPolygon3D::set_depth(float p_depth) { - depth = p_depth; _build_polygon(); update_gizmo(); } float CollisionPolygon3D::get_depth() const { - return depth; } @@ -163,7 +151,6 @@ bool CollisionPolygon3D::is_disabled() const { } String CollisionPolygon3D::get_configuration_warning() const { - if (!Object::cast_to(get_parent())) { return TTR("CollisionPolygon3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, KinematicBody3D, etc. to give them a shape."); } @@ -179,7 +166,6 @@ bool CollisionPolygon3D::_is_editable_3d_polygon() const { return true; } void CollisionPolygon3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CollisionPolygon3D::set_depth); ClassDB::bind_method(D_METHOD("get_depth"), &CollisionPolygon3D::get_depth); @@ -197,7 +183,6 @@ void CollisionPolygon3D::_bind_methods() { } CollisionPolygon3D::CollisionPolygon3D() { - aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); depth = 1.0; set_notify_local_transform(true); diff --git a/scene/3d/collision_polygon_3d.h b/scene/3d/collision_polygon_3d.h index 256aee3d7e..0cd9aee111 100644 --- a/scene/3d/collision_polygon_3d.h +++ b/scene/3d/collision_polygon_3d.h @@ -36,7 +36,6 @@ class CollisionObject3D; class CollisionPolygon3D : public Node3D { - GDCLASS(CollisionPolygon3D, Node3D); protected: diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index a66e84ac3c..711dfd6fb9 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -45,20 +45,16 @@ //TODO: Implement CylinderShape and HeightMapShape? void CollisionShape3D::make_convex_from_brothers() { - Node *p = get_parent(); if (!p) return; for (int i = 0; i < p->get_child_count(); i++) { - Node *n = p->get_child(i); MeshInstance3D *mi = Object::cast_to(n); if (mi) { - Ref m = mi->get_mesh(); if (m.is_valid()) { - Ref s = m->create_convex_shape(); set_shape(s); } @@ -74,9 +70,7 @@ void CollisionShape3D::_update_in_shape_owner(bool p_xform_only) { } void CollisionShape3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_PARENTED: { parent = Object::cast_to(get_parent()); if (parent) { @@ -111,12 +105,10 @@ void CollisionShape3D::_notification(int p_what) { } void CollisionShape3D::resource_changed(RES res) { - update_gizmo(); } String CollisionShape3D::get_configuration_warning() const { - if (!Object::cast_to(get_parent())) { return TTR("CollisionShape3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, KinematicBody3D, etc. to give them a shape."); } @@ -137,7 +129,6 @@ String CollisionShape3D::get_configuration_warning() const { } void CollisionShape3D::_bind_methods() { - //not sure if this should do anything ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &CollisionShape3D::resource_changed); ClassDB::bind_method(D_METHOD("set_shape", "shape"), &CollisionShape3D::set_shape); @@ -154,7 +145,6 @@ void CollisionShape3D::_bind_methods() { } void CollisionShape3D::set_shape(const Ref &p_shape) { - if (!shape.is_null()) { shape->unregister_owner(this); shape->disconnect("changed", callable_mp(this, &CollisionShape3D::_shape_changed)); @@ -178,12 +168,10 @@ void CollisionShape3D::set_shape(const Ref &p_shape) { } Ref CollisionShape3D::get_shape() const { - return shape; } void CollisionShape3D::set_disabled(bool p_disabled) { - disabled = p_disabled; update_gizmo(); if (parent) { @@ -192,12 +180,10 @@ void CollisionShape3D::set_disabled(bool p_disabled) { } bool CollisionShape3D::is_disabled() const { - return disabled; } CollisionShape3D::CollisionShape3D() { - //indicator = RenderingServer::get_singleton()->mesh_create(); disabled = false; debug_shape = nullptr; diff --git a/scene/3d/collision_shape_3d.h b/scene/3d/collision_shape_3d.h index 8515d292af..4ed2f4007b 100644 --- a/scene/3d/collision_shape_3d.h +++ b/scene/3d/collision_shape_3d.h @@ -35,7 +35,6 @@ #include "scene/resources/shape_3d.h" class CollisionObject3D; class CollisionShape3D : public Node3D { - GDCLASS(CollisionShape3D, Node3D); OBJ_CATEGORY("3D Physics Nodes"); diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 414dc6f97b..631ab4e0f7 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -36,16 +36,13 @@ #include "servers/rendering_server.h" AABB CPUParticles3D::get_aabb() const { - return AABB(); } Vector CPUParticles3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); } void CPUParticles3D::set_emitting(bool p_emitting) { - if (emitting == p_emitting) return; @@ -60,7 +57,6 @@ void CPUParticles3D::set_emitting(bool p_emitting) { } void CPUParticles3D::set_amount(int p_amount) { - ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles must be greater than 0."); particles.resize(p_amount); @@ -79,97 +75,76 @@ void CPUParticles3D::set_amount(int p_amount) { particle_order.resize(p_amount); } void CPUParticles3D::set_lifetime(float p_lifetime) { - ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); lifetime = p_lifetime; } void CPUParticles3D::set_one_shot(bool p_one_shot) { - one_shot = p_one_shot; } void CPUParticles3D::set_pre_process_time(float p_time) { - pre_process_time = p_time; } void CPUParticles3D::set_explosiveness_ratio(float p_ratio) { - explosiveness_ratio = p_ratio; } void CPUParticles3D::set_randomness_ratio(float p_ratio) { - randomness_ratio = p_ratio; } void CPUParticles3D::set_lifetime_randomness(float p_random) { - lifetime_randomness = p_random; } void CPUParticles3D::set_use_local_coordinates(bool p_enable) { - local_coords = p_enable; } void CPUParticles3D::set_speed_scale(float p_scale) { - speed_scale = p_scale; } bool CPUParticles3D::is_emitting() const { - return emitting; } int CPUParticles3D::get_amount() const { - return particles.size(); } float CPUParticles3D::get_lifetime() const { - return lifetime; } bool CPUParticles3D::get_one_shot() const { - return one_shot; } float CPUParticles3D::get_pre_process_time() const { - return pre_process_time; } float CPUParticles3D::get_explosiveness_ratio() const { - return explosiveness_ratio; } float CPUParticles3D::get_randomness_ratio() const { - return randomness_ratio; } float CPUParticles3D::get_lifetime_randomness() const { - return lifetime_randomness; } bool CPUParticles3D::get_use_local_coordinates() const { - return local_coords; } float CPUParticles3D::get_speed_scale() const { - return speed_scale; } void CPUParticles3D::set_draw_order(DrawOrder p_order) { - draw_order = p_order; } CPUParticles3D::DrawOrder CPUParticles3D::get_draw_order() const { - return draw_order; } void CPUParticles3D::set_mesh(const Ref &p_mesh) { - mesh = p_mesh; if (mesh.is_valid()) { RS::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid()); @@ -179,7 +154,6 @@ void CPUParticles3D::set_mesh(const Ref &p_mesh) { } Ref CPUParticles3D::get_mesh() const { - return mesh; } @@ -200,7 +174,6 @@ bool CPUParticles3D::get_fractional_delta() const { } String CPUParticles3D::get_configuration_warning() const { - String warnings; bool mesh_found = false; @@ -236,7 +209,6 @@ String CPUParticles3D::get_configuration_warning() const { } void CPUParticles3D::restart() { - time = 0; inactive_time = 0; frame_remainder = 0; @@ -256,62 +228,51 @@ void CPUParticles3D::restart() { } void CPUParticles3D::set_direction(Vector3 p_direction) { - direction = p_direction; } Vector3 CPUParticles3D::get_direction() const { - return direction; } void CPUParticles3D::set_spread(float p_spread) { - spread = p_spread; } float CPUParticles3D::get_spread() const { - return spread; } void CPUParticles3D::set_flatness(float p_flatness) { - flatness = p_flatness; } float CPUParticles3D::get_flatness() const { - return flatness; } void CPUParticles3D::set_param(Parameter p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); parameters[p_param] = p_value; } float CPUParticles3D::get_param(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return parameters[p_param]; } void CPUParticles3D::set_param_randomness(Parameter p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); randomness[p_param] = p_value; } float CPUParticles3D::get_param_randomness(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return randomness[p_param]; } static void _adjust_curve_range(const Ref &p_curve, float p_min, float p_max) { - Ref curve = p_curve; if (!curve.is_valid()) return; @@ -320,7 +281,6 @@ static void _adjust_curve_range(const Ref &p_curve, float p_min, float p_ } void CPUParticles3D::set_param_curve(Parameter p_param, const Ref &p_curve) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); curve_parameters[p_param] = p_curve; @@ -351,7 +311,6 @@ void CPUParticles3D::set_param_curve(Parameter p_param, const Ref &p_curv _adjust_curve_range(p_curve, -360, 360); } break; case PARAM_SCALE: { - } break; case PARAM_HUE_VARIATION: { _adjust_curve_range(p_curve, -1, 1); @@ -366,29 +325,24 @@ void CPUParticles3D::set_param_curve(Parameter p_param, const Ref &p_curv } } Ref CPUParticles3D::get_param_curve(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref()); return curve_parameters[p_param]; } void CPUParticles3D::set_color(const Color &p_color) { - color = p_color; } Color CPUParticles3D::get_color() const { - return color; } void CPUParticles3D::set_color_ramp(const Ref &p_ramp) { - color_ramp = p_ramp; } Ref CPUParticles3D::get_color_ramp() const { - return color_ramp; } @@ -411,49 +365,39 @@ void CPUParticles3D::set_emission_shape(EmissionShape p_shape) { } void CPUParticles3D::set_emission_sphere_radius(float p_radius) { - emission_sphere_radius = p_radius; } void CPUParticles3D::set_emission_box_extents(Vector3 p_extents) { - emission_box_extents = p_extents; } void CPUParticles3D::set_emission_points(const Vector &p_points) { - emission_points = p_points; } void CPUParticles3D::set_emission_normals(const Vector &p_normals) { - emission_normals = p_normals; } void CPUParticles3D::set_emission_colors(const Vector &p_colors) { - emission_colors = p_colors; } float CPUParticles3D::get_emission_sphere_radius() const { - return emission_sphere_radius; } Vector3 CPUParticles3D::get_emission_box_extents() const { - return emission_box_extents; } Vector CPUParticles3D::get_emission_points() const { - return emission_points; } Vector CPUParticles3D::get_emission_normals() const { - return emission_normals; } Vector CPUParticles3D::get_emission_colors() const { - return emission_colors; } @@ -461,17 +405,14 @@ CPUParticles3D::EmissionShape CPUParticles3D::get_emission_shape() const { return emission_shape; } void CPUParticles3D::set_gravity(const Vector3 &p_gravity) { - gravity = p_gravity; } Vector3 CPUParticles3D::get_gravity() const { - return gravity; } void CPUParticles3D::_validate_property(PropertyInfo &property) const { - if (property.name == "color" && color_ramp.is_valid()) { property.usage = 0; } @@ -498,7 +439,6 @@ void CPUParticles3D::_validate_property(PropertyInfo &property) const { } static uint32_t idhash(uint32_t x) { - x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b); x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b); x = (x >> uint32_t(16)) ^ x; @@ -519,7 +459,6 @@ static float rand_from_seed(uint32_t &seed) { } void CPUParticles3D::_update_internal() { - if (particles.size() == 0 || !is_visible_in_tree()) { _set_redraw(false); return; @@ -547,7 +486,6 @@ void CPUParticles3D::_update_internal() { bool processed = false; if (time == 0 && pre_process_time > 0.0) { - float frame_time; if (fixed_fps > 0) frame_time = 1.0 / fixed_fps; @@ -594,7 +532,6 @@ void CPUParticles3D::_update_internal() { } void CPUParticles3D::_particles_process(float p_delta) { - p_delta *= speed_scale; int pcount = particles.size(); @@ -623,7 +560,6 @@ void CPUParticles3D::_particles_process(float p_delta) { float system_phase = time / lifetime; for (int i = 0; i < pcount; i++) { - Particle &p = parray[i]; if (!emitting && !p.active) @@ -681,7 +617,6 @@ void CPUParticles3D::_particles_process(float p_delta) { } if (restart) { - if (!emitting) { p.active = false; continue; @@ -750,7 +685,6 @@ void CPUParticles3D::_particles_process(float p_delta) { } break; case EMISSION_SHAPE_POINTS: case EMISSION_SHAPE_DIRECTED_POINTS: { - int pc = emission_points.size(); if (pc == 0) break; @@ -805,7 +739,6 @@ void CPUParticles3D::_particles_process(float p_delta) { } else if (p.time > p.lifetime) { p.active = false; } else { - uint32_t alt_seed = p.seed; p.time += local_delta; @@ -875,7 +808,6 @@ void CPUParticles3D::_particles_process(float p_delta) { force += diff.length() > 0.0 ? diff.normalized() * (parameters[PARAM_RADIAL_ACCEL] + tex_radial_accel) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_RADIAL_ACCEL]) : Vector3(); //apply tangential acceleration; if (flags[FLAG_DISABLE_Z]) { - Vector2 yx = Vector2(diff.y, diff.x); Vector2 yx2 = (yx * Vector2(-1.0, 1.0)).normalized(); force += yx.length() > 0.0 ? Vector3(yx2.x, yx2.y, 0.0) * ((parameters[PARAM_TANGENTIAL_ACCEL] + tex_tangential_accel) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_TANGENTIAL_ACCEL])) : Vector3(); @@ -903,7 +835,6 @@ void CPUParticles3D::_particles_process(float p_delta) { p.velocity = p.velocity.normalized() * tex_linear_velocity; } if (parameters[PARAM_DAMPING] + tex_damping > 0.0) { - float v = p.velocity.length(); float damp = (parameters[PARAM_DAMPING] + tex_damping) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_DAMPING]); v -= damp * local_delta; @@ -960,7 +891,6 @@ void CPUParticles3D::_particles_process(float p_delta) { p.color *= p.base_color; if (flags[FLAG_DISABLE_Z]) { - if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) { if (p.velocity.length() > 0.0) { p.transform.basis.set_axis(1, p.velocity.normalized()); @@ -1047,7 +977,6 @@ void CPUParticles3D::_update_particle_data_buffer() { Vector3 dir = c->get_global_transform().basis.get_axis(2); //far away to close if (local_coords) { - // will look different from Particles in editor as this is based on the camera in the scenetree // and not the editor camera dir = inv_emission_transform.xform(dir).normalized(); @@ -1064,7 +993,6 @@ void CPUParticles3D::_update_particle_data_buffer() { } for (int i = 0; i < pc; i++) { - int idx = order ? order[i] : i; Transform t = r[idx].transform; @@ -1131,7 +1059,6 @@ void CPUParticles3D::_set_redraw(bool p_redraw) { } void CPUParticles3D::_update_render_thread() { - MutexLock lock(update_mutex); if (can_update) { @@ -1141,7 +1068,6 @@ void CPUParticles3D::_update_render_thread() { } void CPUParticles3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { set_process_internal(emitting); @@ -1165,11 +1091,9 @@ void CPUParticles3D::_notification(int p_what) { } 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(); @@ -1177,7 +1101,6 @@ void CPUParticles3D::_notification(int p_what) { float *ptr = w; for (int i = 0; i < pc; i++) { - Transform t = inv_emission_transform * r[i].transform; if (r[i].active) { @@ -1206,7 +1129,6 @@ void CPUParticles3D::_notification(int p_what) { } void CPUParticles3D::convert_from_particles(Node *p_particles) { - GPUParticles3D *particles = Object::cast_to(p_particles); ERR_FAIL_COND_MSG(!particles, "Only GPUParticles3D nodes can be converted to CPUParticles3D."); @@ -1276,7 +1198,6 @@ void CPUParticles3D::convert_from_particles(Node *p_particles) { } void CPUParticles3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &CPUParticles3D::set_emitting); ClassDB::bind_method(D_METHOD("set_amount", "amount"), &CPUParticles3D::set_amount); ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &CPUParticles3D::set_lifetime); @@ -1481,7 +1402,6 @@ void CPUParticles3D::_bind_methods() { } CPUParticles3D::CPUParticles3D() { - time = 0; inactive_time = 0; frame_remainder = 0; diff --git a/scene/3d/cpu_particles_3d.h b/scene/3d/cpu_particles_3d.h index ffe0ecc9a9..2afb6846c0 100644 --- a/scene/3d/cpu_particles_3d.h +++ b/scene/3d/cpu_particles_3d.h @@ -122,7 +122,6 @@ private: const Particle *particles; Vector3 axis; bool operator()(int p_a, int p_b) const { - return axis.dot(particles[p_a].transform.origin) < axis.dot(particles[p_b].transform.origin); } }; diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp index 4c824aedc4..b97859f44a 100644 --- a/scene/3d/decal.cpp +++ b/scene/3d/decal.cpp @@ -134,19 +134,16 @@ uint32_t Decal::get_cull_mask() const { } AABB Decal::get_aabb() const { - AABB aabb; aabb.position = -extents; aabb.size = extents * 2.0; return aabb; } Vector Decal::get_faces(uint32_t p_usage_flags) const { - return Vector(); } void Decal::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_extents", "extents"), &Decal::set_extents); ClassDB::bind_method(D_METHOD("get_extents"), &Decal::get_extents); @@ -212,7 +209,6 @@ void Decal::_bind_methods() { } Decal::Decal() { - extents = Vector3(1, 1, 1); emission_energy = 1.0; modulate = Color(1, 1, 1, 1); @@ -230,6 +226,5 @@ Decal::Decal() { } Decal::~Decal() { - RS::get_singleton()->free(decal); } diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 65a330ddc0..0ba1b3d984 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -212,7 +212,6 @@ bool GIProbeData::is_using_two_bounces() const { } RID GIProbeData::get_rid() const { - return probe; } @@ -283,7 +282,6 @@ void GIProbeData::_bind_methods() { } GIProbeData::GIProbeData() { - ao = 0.0; ao_size = 0.5; dynamic_range = 4; @@ -299,7 +297,6 @@ GIProbeData::GIProbeData() { } GIProbeData::~GIProbeData() { - RS::get_singleton()->free(probe); } @@ -307,7 +304,6 @@ GIProbeData::~GIProbeData() { ////////////////////// void GIProbe::set_probe_data(const Ref &p_data) { - if (p_data.is_valid()) { RS::get_singleton()->instance_set_base(get_instance(), p_data->get_rid()); } else { @@ -318,41 +314,34 @@ void GIProbe::set_probe_data(const Ref &p_data) { } Ref GIProbe::get_probe_data() const { - return probe_data; } void GIProbe::set_subdiv(Subdiv p_subdiv) { - ERR_FAIL_INDEX(p_subdiv, SUBDIV_MAX); subdiv = p_subdiv; update_gizmo(); } GIProbe::Subdiv GIProbe::get_subdiv() const { - return subdiv; } void GIProbe::set_extents(const Vector3 &p_extents) { - extents = p_extents; update_gizmo(); _change_notify("extents"); } Vector3 GIProbe::get_extents() const { - return extents; } void GIProbe::_find_meshes(Node *p_at_node, List &plot_meshes) { - MeshInstance3D *mi = Object::cast_to(p_at_node); if (mi && mi->get_gi_mode() == GeometryInstance3D::GI_MODE_BAKED && mi->is_visible_in_tree()) { Ref mesh = mi->get_mesh(); if (mesh.is_valid()) { - AABB aabb = mesh->get_aabb(); Transform xf = get_global_transform().affine_inverse() * mi->get_global_transform(); @@ -372,12 +361,9 @@ void GIProbe::_find_meshes(Node *p_at_node, List &plot_meshes) { Node3D *s = Object::cast_to(p_at_node); if (s) { - if (s->is_visible_in_tree()) { - Array meshes = p_at_node->call("get_meshes"); for (int i = 0; i < meshes.size(); i += 2) { - Transform mxf = meshes[i]; Ref mesh = meshes[i + 1]; if (!mesh.is_valid()) @@ -416,7 +402,6 @@ Vector3i GIProbe::get_estimated_cell_size() const { axis_cell_size[longest_axis] = 1 << cell_subdiv; for (int i = 0; i < 3; i++) { - if (i == longest_axis) continue; @@ -433,7 +418,6 @@ Vector3i GIProbe::get_estimated_cell_size() const { return Vector3i(axis_cell_size[0], axis_cell_size[1], axis_cell_size[2]); } void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { - static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 }; Voxelizer baker; @@ -451,7 +435,6 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { int pmc = 0; for (List::Element *E = mesh_list.front(); E; E = E->next()) { - if (bake_step_function) { bake_step_function(pmc, RTR("Plotting Meshes") + " " + itos(pmc) + "/" + itos(mesh_list.size())); } @@ -483,7 +466,6 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { #endif } else { - Ref probe_data = get_probe_data(); if (probe_data.is_null()) @@ -511,22 +493,18 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { } void GIProbe::_debug_bake() { - bake(nullptr, true); } AABB GIProbe::get_aabb() const { - return AABB(-extents, extents * 2); } Vector GIProbe::get_faces(uint32_t p_usage_flags) const { - return Vector(); } String GIProbe::get_configuration_warning() const { - if (RenderingServer::get_singleton()->is_low_end()) { return TTR("GIProbes are not supported by the GLES2 video driver.\nUse a BakedLightmap instead."); } @@ -534,7 +512,6 @@ String GIProbe::get_configuration_warning() const { } void GIProbe::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_probe_data", "data"), &GIProbe::set_probe_data); ClassDB::bind_method(D_METHOD("get_probe_data"), &GIProbe::get_probe_data); @@ -560,7 +537,6 @@ void GIProbe::_bind_methods() { } GIProbe::GIProbe() { - subdiv = SUBDIV_128; extents = Vector3(10, 10, 10); diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index 28b533e82d..b7abfbd01b 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -35,7 +35,6 @@ #include "scene/3d/visual_instance_3d.h" class GIProbeData : public Resource { - GDCLASS(GIProbeData, Resource); RID probe; diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index 01886a730f..1ce25f1e6e 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -36,16 +36,13 @@ #include "servers/rendering_server.h" AABB GPUParticles3D::get_aabb() const { - return AABB(); } Vector GPUParticles3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); } void GPUParticles3D::set_emitting(bool p_emitting) { - RS::get_singleton()->particles_set_emitting(particles, p_emitting); if (p_emitting && one_shot) { @@ -56,25 +53,21 @@ void GPUParticles3D::set_emitting(bool p_emitting) { } void GPUParticles3D::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 GPUParticles3D::set_lifetime(float p_lifetime) { - ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); lifetime = p_lifetime; RS::get_singleton()->particles_set_lifetime(particles, lifetime); } void GPUParticles3D::set_one_shot(bool p_one_shot) { - one_shot = p_one_shot; RS::get_singleton()->particles_set_one_shot(particles, one_shot); if (is_emitting()) { - set_process_internal(true); if (!one_shot) RenderingServer::get_singleton()->particles_restart(particles); @@ -85,34 +78,28 @@ void GPUParticles3D::set_one_shot(bool p_one_shot) { } void GPUParticles3D::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 GPUParticles3D::set_explosiveness_ratio(float p_ratio) { - explosiveness_ratio = p_ratio; RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio); } void GPUParticles3D::set_randomness_ratio(float p_ratio) { - randomness_ratio = p_ratio; RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); } void GPUParticles3D::set_visibility_aabb(const AABB &p_aabb) { - visibility_aabb = p_aabb; RS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb); update_gizmo(); _change_notify("visibility_aabb"); } void GPUParticles3D::set_use_local_coordinates(bool p_enable) { - local_coords = p_enable; RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords); } void GPUParticles3D::set_process_material(const Ref &p_material) { - process_material = p_material; RID material_rid; if (process_material.is_valid()) @@ -123,83 +110,66 @@ void GPUParticles3D::set_process_material(const Ref &p_material) { } void GPUParticles3D::set_speed_scale(float p_scale) { - speed_scale = p_scale; RS::get_singleton()->particles_set_speed_scale(particles, p_scale); } bool GPUParticles3D::is_emitting() const { - return RS::get_singleton()->particles_get_emitting(particles); } int GPUParticles3D::get_amount() const { - return amount; } float GPUParticles3D::get_lifetime() const { - return lifetime; } bool GPUParticles3D::get_one_shot() const { - return one_shot; } float GPUParticles3D::get_pre_process_time() const { - return pre_process_time; } float GPUParticles3D::get_explosiveness_ratio() const { - return explosiveness_ratio; } float GPUParticles3D::get_randomness_ratio() const { - return randomness_ratio; } AABB GPUParticles3D::get_visibility_aabb() const { - return visibility_aabb; } bool GPUParticles3D::get_use_local_coordinates() const { - return local_coords; } Ref GPUParticles3D::get_process_material() const { - return process_material; } float GPUParticles3D::get_speed_scale() const { - return speed_scale; } void GPUParticles3D::set_draw_order(DrawOrder p_order) { - draw_order = p_order; RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order)); } GPUParticles3D::DrawOrder GPUParticles3D::get_draw_order() const { - return draw_order; } void GPUParticles3D::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 GPUParticles3D::get_draw_passes() const { - return draw_passes.size(); } void GPUParticles3D::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; @@ -214,7 +184,6 @@ void GPUParticles3D::set_draw_pass_mesh(int p_pass, const Ref &p_mesh) { } Ref GPUParticles3D::get_draw_pass_mesh(int p_pass) const { - ERR_FAIL_INDEX_V(p_pass, draw_passes.size(), Ref()); return draw_passes[p_pass]; @@ -239,7 +208,6 @@ bool GPUParticles3D::get_fractional_delta() const { } String GPUParticles3D::get_configuration_warning() const { - if (RenderingServer::get_singleton()->is_low_end()) { return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles3D node instead. You can use the \"Convert to CPUParticles3D\" option for this purpose."); } @@ -291,18 +259,15 @@ String GPUParticles3D::get_configuration_warning() const { } void GPUParticles3D::restart() { - RenderingServer::get_singleton()->particles_restart(particles); RenderingServer::get_singleton()->particles_set_emitting(particles, true); } AABB GPUParticles3D::capture_aabb() const { - return RS::get_singleton()->particles_get_current_aabb(particles); } void GPUParticles3D::_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()) { @@ -313,12 +278,10 @@ void GPUParticles3D::_validate_property(PropertyInfo &property) 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); } } @@ -326,7 +289,6 @@ void GPUParticles3D::_notification(int p_what) { // Use internal process when emitting and one_shot are on so that when // the shot ends the editor can properly update if (p_what == NOTIFICATION_INTERNAL_PROCESS) { - if (one_shot && !is_emitting()) { _change_notify(); set_process_internal(false); @@ -342,7 +304,6 @@ void GPUParticles3D::_notification(int p_what) { } void GPUParticles3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &GPUParticles3D::set_emitting); ClassDB::bind_method(D_METHOD("set_amount", "amount"), &GPUParticles3D::set_amount); ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &GPUParticles3D::set_lifetime); @@ -404,7 +365,6 @@ void GPUParticles3D::_bind_methods() { ADD_GROUP("Draw Passes", "draw_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_passes", PROPERTY_HINT_RANGE, "0," + itos(MAX_DRAW_PASSES) + ",1"), "set_draw_passes", "get_draw_passes"); for (int i = 0; i < MAX_DRAW_PASSES; i++) { - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "draw_pass_" + itos(i + 1), PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_draw_pass_mesh", "get_draw_pass_mesh", i); } @@ -416,7 +376,6 @@ void GPUParticles3D::_bind_methods() { } GPUParticles3D::GPUParticles3D() { - particles = RS::get_singleton()->particles_create(); set_base(particles); one_shot = false; // Needed so that set_emitting doesn't access uninitialized values @@ -437,6 +396,5 @@ GPUParticles3D::GPUParticles3D() { } GPUParticles3D::~GPUParticles3D() { - RS::get_singleton()->free(particles); } diff --git a/scene/3d/immediate_geometry_3d.cpp b/scene/3d/immediate_geometry_3d.cpp index 63d4b1ac84..0d0ce1505f 100644 --- a/scene/3d/immediate_geometry_3d.cpp +++ b/scene/3d/immediate_geometry_3d.cpp @@ -31,39 +31,32 @@ #include "immediate_geometry_3d.h" void ImmediateGeometry3D::begin(Mesh::PrimitiveType p_primitive, const Ref &p_texture) { - RS::get_singleton()->immediate_begin(im, (RS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID()); if (p_texture.is_valid()) cached_textures.push_back(p_texture); } void ImmediateGeometry3D::set_normal(const Vector3 &p_normal) { - RS::get_singleton()->immediate_normal(im, p_normal); } void ImmediateGeometry3D::set_tangent(const Plane &p_tangent) { - RS::get_singleton()->immediate_tangent(im, p_tangent); } void ImmediateGeometry3D::set_color(const Color &p_color) { - RS::get_singleton()->immediate_color(im, p_color); } void ImmediateGeometry3D::set_uv(const Vector2 &p_uv) { - RS::get_singleton()->immediate_uv(im, p_uv); } void ImmediateGeometry3D::set_uv2(const Vector2 &p_uv2) { - RS::get_singleton()->immediate_uv2(im, p_uv2); } void ImmediateGeometry3D::add_vertex(const Vector3 &p_vertex) { - RS::get_singleton()->immediate_vertex(im, p_vertex); if (empty) { aabb.position = p_vertex; @@ -75,28 +68,23 @@ void ImmediateGeometry3D::add_vertex(const Vector3 &p_vertex) { } void ImmediateGeometry3D::end() { - RS::get_singleton()->immediate_end(im); } void ImmediateGeometry3D::clear() { - RS::get_singleton()->immediate_clear(im); empty = true; cached_textures.clear(); } AABB ImmediateGeometry3D::get_aabb() const { - return aabb; } Vector ImmediateGeometry3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); } void ImmediateGeometry3D::add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv) { - for (int i = 1; i <= p_lats; i++) { double lat0 = Math_PI * (-0.5 + (double)(i - 1) / p_lats); double z0 = Math::sin(lat0); @@ -107,7 +95,6 @@ void ImmediateGeometry3D::add_sphere(int p_lats, int p_lons, float p_radius, boo double zr1 = Math::cos(lat1); for (int j = p_lons; j >= 1; j--) { - double lng0 = 2 * Math_PI * (double)(j - 1) / p_lons; double x0 = Math::cos(lng0); double y0 = Math::sin(lng0); @@ -143,7 +130,6 @@ void ImmediateGeometry3D::add_sphere(int p_lats, int p_lons, float p_radius, boo } void ImmediateGeometry3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("begin", "primitive", "texture"), &ImmediateGeometry3D::begin, DEFVAL(Ref())); ClassDB::bind_method(D_METHOD("set_normal", "normal"), &ImmediateGeometry3D::set_normal); ClassDB::bind_method(D_METHOD("set_tangent", "tangent"), &ImmediateGeometry3D::set_tangent); @@ -157,13 +143,11 @@ void ImmediateGeometry3D::_bind_methods() { } ImmediateGeometry3D::ImmediateGeometry3D() { - im = RenderingServer::get_singleton()->immediate_create(); set_base(im); empty = true; } ImmediateGeometry3D::~ImmediateGeometry3D() { - RenderingServer::get_singleton()->free(im); } diff --git a/scene/3d/immediate_geometry_3d.h b/scene/3d/immediate_geometry_3d.h index 6e15450a5b..7c9e8851a2 100644 --- a/scene/3d/immediate_geometry_3d.h +++ b/scene/3d/immediate_geometry_3d.h @@ -35,7 +35,6 @@ #include "scene/resources/mesh.h" class ImmediateGeometry3D : public GeometryInstance3D { - GDCLASS(ImmediateGeometry3D, GeometryInstance3D); RID im; diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 0aa0f7e5ac..1fa50b6872 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -35,12 +35,10 @@ #include "scene/resources/surface_tool.h" bool Light3D::_can_gizmo_scale() const { - return false; } void Light3D::set_param(Param p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); param[p_param] = p_value; @@ -60,13 +58,11 @@ void Light3D::set_param(Param p_param, float p_value) { } float Light3D::get_param(Param p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return param[p_param]; } void Light3D::set_shadow(bool p_enable) { - shadow = p_enable; RS::get_singleton()->light_set_shadow(light, p_enable); @@ -75,50 +71,41 @@ void Light3D::set_shadow(bool p_enable) { } } bool Light3D::has_shadow() const { - return shadow; } void Light3D::set_negative(bool p_enable) { - negative = p_enable; RS::get_singleton()->light_set_negative(light, p_enable); } bool Light3D::is_negative() const { - return negative; } void Light3D::set_cull_mask(uint32_t p_cull_mask) { - cull_mask = p_cull_mask; RS::get_singleton()->light_set_cull_mask(light, p_cull_mask); } uint32_t Light3D::get_cull_mask() const { - return cull_mask; } void Light3D::set_color(const Color &p_color) { - color = p_color; RS::get_singleton()->light_set_color(light, p_color); // The gizmo color depends on the light color, so update it. update_gizmo(); } Color Light3D::get_color() const { - return color; } void Light3D::set_shadow_color(const Color &p_shadow_color) { - shadow_color = p_shadow_color; RS::get_singleton()->light_set_shadow_color(light, p_shadow_color); } Color Light3D::get_shadow_color() const { - return shadow_color; } @@ -128,22 +115,17 @@ void Light3D::set_shadow_reverse_cull_face(bool p_enable) { } bool Light3D::get_shadow_reverse_cull_face() const { - return reverse_cull; } AABB Light3D::get_aabb() const { - if (type == RenderingServer::LIGHT_DIRECTIONAL) { - return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); } else if (type == RenderingServer::LIGHT_OMNI) { - return AABB(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]); } else if (type == RenderingServer::LIGHT_SPOT) { - float len = param[PARAM_RANGE]; float size = Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE])) * len; return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); @@ -153,7 +135,6 @@ AABB Light3D::get_aabb() const { } Vector Light3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); } @@ -167,7 +148,6 @@ Light3D::BakeMode Light3D::get_bake_mode() const { } void Light3D::set_projector(const Ref &p_texture) { - projector = p_texture; RID tex_id = projector.is_valid() ? projector->get_rid() : RID(); RS::get_singleton()->light_set_projector(light, tex_id); @@ -179,7 +159,6 @@ Ref Light3D::get_projector() const { } void Light3D::_update_visibility() { - if (!is_inside_tree()) return; @@ -205,9 +184,7 @@ void Light3D::_update_visibility() { } void Light3D::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - _update_visibility(); } @@ -217,18 +194,15 @@ void Light3D::_notification(int p_what) { } void Light3D::set_editor_only(bool p_editor_only) { - editor_only = p_editor_only; _update_visibility(); } bool Light3D::is_editor_only() const { - return editor_only; } void Light3D::_validate_property(PropertyInfo &property) const { - if (get_light_type() == RS::LIGHT_DIRECTIONAL && property.name == "light_size") { property.usage = 0; } @@ -243,7 +217,6 @@ void Light3D::_validate_property(PropertyInfo &property) const { } void Light3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_editor_only", "editor_only"), &Light3D::set_editor_only); ClassDB::bind_method(D_METHOD("is_editor_only"), &Light3D::is_editor_only); @@ -323,7 +296,6 @@ void Light3D::_bind_methods() { } Light3D::Light3D(RenderingServer::LightType p_type) { - type = p_type; switch (p_type) { case RS::LIGHT_DIRECTIONAL: @@ -373,13 +345,11 @@ Light3D::Light3D(RenderingServer::LightType p_type) { } Light3D::Light3D() { - type = RenderingServer::LIGHT_DIRECTIONAL; ERR_PRINT("Light3D should not be instanced directly; use the DirectionalLight3D, OmniLight3D or SpotLight3D subtypes instead."); } Light3D::~Light3D() { - RS::get_singleton()->instance_set_base(get_instance(), RID()); if (light.is_valid()) @@ -388,13 +358,11 @@ Light3D::~Light3D() { ///////////////////////////////////////// void DirectionalLight3D::set_shadow_mode(ShadowMode p_mode) { - shadow_mode = p_mode; RS::get_singleton()->light_directional_set_shadow_mode(light, RS::LightDirectionalShadowMode(p_mode)); } DirectionalLight3D::ShadowMode DirectionalLight3D::get_shadow_mode() const { - return shadow_mode; } @@ -404,23 +372,19 @@ void DirectionalLight3D::set_shadow_depth_range(ShadowDepthRange p_range) { } DirectionalLight3D::ShadowDepthRange DirectionalLight3D::get_shadow_depth_range() const { - return shadow_depth_range; } void DirectionalLight3D::set_blend_splits(bool p_enable) { - blend_splits = p_enable; RS::get_singleton()->light_directional_set_blend_splits(light, p_enable); } bool DirectionalLight3D::is_blend_splits_enabled() const { - return blend_splits; } void DirectionalLight3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight3D::set_shadow_mode); ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight3D::get_shadow_mode); @@ -451,7 +415,6 @@ void DirectionalLight3D::_bind_methods() { DirectionalLight3D::DirectionalLight3D() : Light3D(RenderingServer::LIGHT_DIRECTIONAL) { - set_param(PARAM_SHADOW_MAX_DISTANCE, 100); set_param(PARAM_SHADOW_FADE_START, 0.8); set_shadow_mode(SHADOW_PARALLEL_4_SPLITS); @@ -461,13 +424,11 @@ DirectionalLight3D::DirectionalLight3D() : } void OmniLight3D::set_shadow_mode(ShadowMode p_mode) { - shadow_mode = p_mode; RS::get_singleton()->light_omni_set_shadow_mode(light, RS::LightOmniShadowMode(p_mode)); } OmniLight3D::ShadowMode OmniLight3D::get_shadow_mode() const { - return shadow_mode; } @@ -485,7 +446,6 @@ String OmniLight3D::get_configuration_warning() const { } void OmniLight3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &OmniLight3D::set_shadow_mode); ClassDB::bind_method(D_METHOD("get_shadow_mode"), &OmniLight3D::get_shadow_mode); @@ -500,7 +460,6 @@ void OmniLight3D::_bind_methods() { OmniLight3D::OmniLight3D() : Light3D(RenderingServer::LIGHT_OMNI) { - set_shadow_mode(SHADOW_CUBE); } @@ -526,7 +485,6 @@ String SpotLight3D::get_configuration_warning() const { } void SpotLight3D::_bind_methods() { - ADD_GROUP("Spot", "spot_"); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "spot_range", PROPERTY_HINT_EXP_RANGE, "0,4096,0.1,or_greater"), "set_param", "get_param", PARAM_RANGE); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "spot_attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), "set_param", "get_param", PARAM_ATTENUATION); diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h index 6e78217342..f16773f6ae 100644 --- a/scene/3d/light_3d.h +++ b/scene/3d/light_3d.h @@ -36,7 +36,6 @@ #include "servers/rendering_server.h" class Light3D : public VisualInstance3D { - GDCLASS(Light3D, VisualInstance3D); OBJ_CATEGORY("3D Light Nodes"); @@ -140,7 +139,6 @@ VARIANT_ENUM_CAST(Light3D::Param); VARIANT_ENUM_CAST(Light3D::BakeMode); class DirectionalLight3D : public Light3D { - GDCLASS(DirectionalLight3D, Light3D); public: @@ -180,7 +178,6 @@ VARIANT_ENUM_CAST(DirectionalLight3D::ShadowMode) VARIANT_ENUM_CAST(DirectionalLight3D::ShadowDepthRange) class OmniLight3D : public Light3D { - GDCLASS(OmniLight3D, Light3D); public: @@ -208,7 +205,6 @@ public: VARIANT_ENUM_CAST(OmniLight3D::ShadowMode) class SpotLight3D : public Light3D { - GDCLASS(SpotLight3D, Light3D); protected: diff --git a/scene/3d/listener_3d.cpp b/scene/3d/listener_3d.cpp index 426e34ea80..6a5307565b 100644 --- a/scene/3d/listener_3d.cpp +++ b/scene/3d/listener_3d.cpp @@ -36,12 +36,10 @@ void Listener3D::_update_audio_listener_state() { } void Listener3D::_request_listener_update() { - _update_listener(); } bool Listener3D::_set(const StringName &p_name, const Variant &p_value) { - if (p_name == "current") { if (p_value.operator bool()) { make_current(); @@ -54,7 +52,6 @@ bool Listener3D::_set(const StringName &p_name, const Variant &p_value) { return true; } bool Listener3D::_get(const StringName &p_name, Variant &r_ret) const { - if (p_name == "current") { if (is_inside_tree() && get_tree()->is_node_being_edited(this)) { r_ret = current; @@ -68,21 +65,17 @@ bool Listener3D::_get(const StringName &p_name, Variant &r_ret) const { } void Listener3D::_get_property_list(List *p_list) const { - p_list->push_back(PropertyInfo(Variant::BOOL, "current")); } void Listener3D::_update_listener() { - if (is_inside_tree() && is_current()) { get_viewport()->_listener_transform_changed_notify(); } } void Listener3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_WORLD: { bool first_listener = get_viewport()->_listener_add(this); if (!get_tree()->is_node_being_edited(this) && (current || first_listener)) @@ -92,7 +85,6 @@ void Listener3D::_notification(int p_what) { _request_listener_update(); } break; case NOTIFICATION_EXIT_WORLD: { - if (!get_tree()->is_node_being_edited(this)) { if (is_current()) { clear_current(); @@ -110,12 +102,10 @@ void Listener3D::_notification(int p_what) { } Transform Listener3D::get_listener_transform() const { - return get_global_transform().orthonormalized(); } void Listener3D::make_current() { - current = true; if (!is_inside_tree()) @@ -125,7 +115,6 @@ void Listener3D::make_current() { } void Listener3D::clear_current() { - current = false; if (!is_inside_tree()) return; @@ -137,9 +126,7 @@ void Listener3D::clear_current() { } bool Listener3D::is_current() const { - if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) { - return get_viewport()->get_listener() == this; } else return current; @@ -148,7 +135,6 @@ bool Listener3D::is_current() const { } bool Listener3D::_can_gizmo_scale() const { - return false; } @@ -159,7 +145,6 @@ RES Listener3D::_get_gizmo_geometry() const { } void Listener3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("make_current"), &Listener3D::make_current); ClassDB::bind_method(D_METHOD("clear_current"), &Listener3D::clear_current); ClassDB::bind_method(D_METHOD("is_current"), &Listener3D::is_current); @@ -167,7 +152,6 @@ void Listener3D::_bind_methods() { } Listener3D::Listener3D() { - current = false; force_change = false; set_notify_transform(true); diff --git a/scene/3d/listener_3d.h b/scene/3d/listener_3d.h index 3383d6725e..4b6923d6e8 100644 --- a/scene/3d/listener_3d.h +++ b/scene/3d/listener_3d.h @@ -35,7 +35,6 @@ #include "scene/main/window.h" class Listener3D : public Node3D { - GDCLASS(Listener3D, Node3D); private: diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index cdc8db8aea..08a2426e1c 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -37,7 +37,6 @@ #include "skeleton_3d.h" bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) { - //this is not _too_ bad performance wise, really. it only arrives here if the property was not set anywhere else. //add to it that it's probably found on first call to _set anyway. @@ -64,7 +63,6 @@ bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) { } bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const { - if (!get_instance().is_valid()) return false; @@ -85,10 +83,8 @@ bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const { } void MeshInstance3D::_get_property_list(List *p_list) const { - List ls; for (const Map::Element *E = blend_shape_tracks.front(); E; E = E->next()) { - ls.push_back(E->key()); } @@ -106,7 +102,6 @@ void MeshInstance3D::_get_property_list(List *p_list) const { } void MeshInstance3D::set_mesh(const Ref &p_mesh) { - if (mesh == p_mesh) return; @@ -119,9 +114,7 @@ void MeshInstance3D::set_mesh(const Ref &p_mesh) { blend_shape_tracks.clear(); if (mesh.is_valid()) { - for (int i = 0; i < mesh->get_blend_shape_count(); i++) { - BlendShapeTrack mt; mt.idx = i; mt.value = 0; @@ -133,7 +126,6 @@ void MeshInstance3D::set_mesh(const Ref &p_mesh) { set_base(mesh->get_rid()); } else { - set_base(RID()); } @@ -142,12 +134,10 @@ void MeshInstance3D::set_mesh(const Ref &p_mesh) { _change_notify(); } Ref MeshInstance3D::get_mesh() const { - return mesh; } void MeshInstance3D::_resolve_skeleton_path() { - Ref new_skin_reference; if (!skeleton_path.is_empty()) { @@ -184,7 +174,6 @@ Ref MeshInstance3D::get_skin() const { } void MeshInstance3D::set_skeleton_path(const NodePath &p_skeleton) { - skeleton_path = p_skeleton; if (!is_inside_tree()) return; @@ -196,7 +185,6 @@ NodePath MeshInstance3D::get_skeleton_path() { } AABB MeshInstance3D::get_aabb() const { - if (!mesh.is_null()) return mesh->get_aabb(); @@ -204,7 +192,6 @@ AABB MeshInstance3D::get_aabb() const { } Vector MeshInstance3D::get_faces(uint32_t p_usage_flags) const { - if (!(p_usage_flags & (FACES_SOLID | FACES_ENCLOSING))) return Vector(); @@ -215,7 +202,6 @@ Vector MeshInstance3D::get_faces(uint32_t p_usage_flags) const { } Node *MeshInstance3D::create_trimesh_collision_node() { - if (mesh.is_null()) return nullptr; @@ -231,7 +217,6 @@ Node *MeshInstance3D::create_trimesh_collision_node() { } void MeshInstance3D::create_trimesh_collision() { - StaticBody3D *static_body = Object::cast_to(create_trimesh_collision_node()); ERR_FAIL_COND(!static_body); static_body->set_name(String(get_name()) + "_col"); @@ -245,7 +230,6 @@ void MeshInstance3D::create_trimesh_collision() { } Node *MeshInstance3D::create_convex_collision_node() { - if (mesh.is_null()) return nullptr; @@ -261,7 +245,6 @@ Node *MeshInstance3D::create_convex_collision_node() { } void MeshInstance3D::create_convex_collision() { - StaticBody3D *static_body = Object::cast_to(create_convex_collision_node()); ERR_FAIL_COND(!static_body); static_body->set_name(String(get_name()) + "_col"); @@ -275,19 +258,16 @@ void MeshInstance3D::create_convex_collision() { } void MeshInstance3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { _resolve_skeleton_path(); } } int MeshInstance3D::get_surface_material_count() const { - return materials.size(); } void MeshInstance3D::set_surface_material(int p_surface, const Ref &p_material) { - ERR_FAIL_INDEX(p_surface, materials.size()); materials.write[p_surface] = p_material; @@ -299,14 +279,12 @@ void MeshInstance3D::set_surface_material(int p_surface, const Ref &p_ } Ref MeshInstance3D::get_surface_material(int p_surface) const { - ERR_FAIL_INDEX_V(p_surface, materials.size(), Ref()); return materials[p_surface]; } Ref MeshInstance3D::get_active_material(int p_surface) const { - Ref material_override = get_material_override(); if (material_override.is_valid()) { return material_override; @@ -326,12 +304,10 @@ Ref MeshInstance3D::get_active_material(int p_surface) const { } void MeshInstance3D::_mesh_changed() { - materials.resize(mesh->get_surface_count()); } void MeshInstance3D::create_debug_tangents() { - Vector lines; Vector colors; @@ -373,7 +349,6 @@ void MeshInstance3D::create_debug_tangents() { } if (lines.size()) { - Ref sm; sm.instance(); @@ -406,7 +381,6 @@ void MeshInstance3D::create_debug_tangents() { } void MeshInstance3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MeshInstance3D::set_mesh); ClassDB::bind_method(D_METHOD("get_mesh"), &MeshInstance3D::get_mesh); ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &MeshInstance3D::set_skeleton_path); diff --git a/scene/3d/mesh_instance_3d.h b/scene/3d/mesh_instance_3d.h index 914148f427..e29204f702 100644 --- a/scene/3d/mesh_instance_3d.h +++ b/scene/3d/mesh_instance_3d.h @@ -37,7 +37,6 @@ #include "scene/resources/skin.h" class MeshInstance3D : public GeometryInstance3D { - GDCLASS(MeshInstance3D, GeometryInstance3D); protected: @@ -48,7 +47,6 @@ protected: NodePath skeleton_path; struct BlendShapeTrack { - int idx; float value; BlendShapeTrack() { diff --git a/scene/3d/multimesh_instance_3d.cpp b/scene/3d/multimesh_instance_3d.cpp index a625a34283..9892323173 100644 --- a/scene/3d/multimesh_instance_3d.cpp +++ b/scene/3d/multimesh_instance_3d.cpp @@ -31,14 +31,12 @@ #include "multimesh_instance_3d.h" void MultiMeshInstance3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_multimesh", "multimesh"), &MultiMeshInstance3D::set_multimesh); ClassDB::bind_method(D_METHOD("get_multimesh"), &MultiMeshInstance3D::get_multimesh); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multimesh", PROPERTY_HINT_RESOURCE_TYPE, "MultiMesh"), "set_multimesh", "get_multimesh"); } void MultiMeshInstance3D::set_multimesh(const Ref &p_multimesh) { - multimesh = p_multimesh; if (multimesh.is_valid()) set_base(multimesh->get_rid()); @@ -47,17 +45,14 @@ void MultiMeshInstance3D::set_multimesh(const Ref &p_multimesh) { } Ref MultiMeshInstance3D::get_multimesh() const { - return multimesh; } Vector MultiMeshInstance3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); } AABB MultiMeshInstance3D::get_aabb() const { - if (multimesh.is_null()) return AABB(); else diff --git a/scene/3d/navigation_3d.cpp b/scene/3d/navigation_3d.cpp index f880f65d37..07a4824c28 100644 --- a/scene/3d/navigation_3d.cpp +++ b/scene/3d/navigation_3d.cpp @@ -33,7 +33,6 @@ #include "servers/navigation_server_3d.h" Vector Navigation3D::get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize) const { - return NavigationServer3D::get_singleton()->map_get_path(map, p_start, p_end, p_optimize); } @@ -54,13 +53,11 @@ RID Navigation3D::get_closest_point_owner(const Vector3 &p_point) const { } void Navigation3D::set_up_vector(const Vector3 &p_up) { - up = p_up; NavigationServer3D::get_singleton()->map_set_up(map, up); } Vector3 Navigation3D::get_up_vector() const { - return up; } @@ -75,7 +72,6 @@ void Navigation3D::set_edge_connection_margin(float p_edge_connection_margin) { } void Navigation3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_rid"), &Navigation3D::get_rid); ClassDB::bind_method(D_METHOD("get_simple_path", "start", "end", "optimize"), &Navigation3D::get_simple_path, DEFVAL(true)); @@ -104,14 +100,12 @@ void Navigation3D::_notification(int p_what) { NavigationServer3D::get_singleton()->map_set_active(map, true); } break; case NOTIFICATION_EXIT_TREE: { - NavigationServer3D::get_singleton()->map_set_active(map, false); } break; } } Navigation3D::Navigation3D() { - map = NavigationServer3D::get_singleton()->map_create(); set_cell_size(0.3); diff --git a/scene/3d/navigation_3d.h b/scene/3d/navigation_3d.h index daa9558125..890caed171 100644 --- a/scene/3d/navigation_3d.h +++ b/scene/3d/navigation_3d.h @@ -35,7 +35,6 @@ #include "scene/3d/node_3d.h" class Navigation3D : public Node3D { - GDCLASS(Navigation3D, Node3D); RID map; diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 020d598f00..4b1e602f77 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -35,7 +35,6 @@ #include "servers/navigation_server_3d.h" void NavigationAgent3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent3D::set_target_desired_distance); ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent3D::get_target_desired_distance); @@ -99,7 +98,6 @@ void NavigationAgent3D::_bind_methods() { void NavigationAgent3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - agent_parent = Object::cast_to(get_parent()); NavigationServer3D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); @@ -128,7 +126,6 @@ void NavigationAgent3D::_notification(int p_what) { } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (agent_parent) { - NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin); if (!target_reached) { if (distance_to_target() < target_desired_distance) { @@ -296,7 +293,6 @@ String NavigationAgent3D::get_configuration_warning() const { } void NavigationAgent3D::update_navigation() { - if (agent_parent == nullptr) return; if (navigation == nullptr) diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp index 2f99a5f99e..daa9222d84 100644 --- a/scene/3d/navigation_obstacle_3d.cpp +++ b/scene/3d/navigation_obstacle_3d.cpp @@ -36,7 +36,6 @@ #include "servers/navigation_server_3d.h" void NavigationObstacle3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationObstacle3D::set_navigation_node); ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationObstacle3D::get_navigation_node); } @@ -44,7 +43,6 @@ void NavigationObstacle3D::_bind_methods() { void NavigationObstacle3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - update_agent_shape(); // Search the navigation node and set it @@ -76,7 +74,6 @@ void NavigationObstacle3D::_notification(int p_what) { PhysicsBody3D *rigid = Object::cast_to(get_parent()); if (rigid) { - Vector3 v = rigid->get_linear_velocity(); NavigationServer3D::get_singleton()->agent_set_velocity(agent, v); NavigationServer3D::get_singleton()->agent_set_target_velocity(agent, v); @@ -115,7 +112,6 @@ Node *NavigationObstacle3D::get_navigation_node() const { String NavigationObstacle3D::get_configuration_warning() const { if (!Object::cast_to(get_parent())) { - return TTR("The NavigationObstacle3D only serves to provide collision avoidance to a spatial object."); } diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index b15fa6166f..bc13b7097f 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -36,7 +36,6 @@ #include "servers/navigation_server_3d.h" void NavigationRegion3D::set_enabled(bool p_enabled) { - if (enabled == p_enabled) return; enabled = p_enabled; @@ -45,12 +44,9 @@ void NavigationRegion3D::set_enabled(bool p_enabled) { return; if (!enabled) { - NavigationServer3D::get_singleton()->region_set_map(region, RID()); } else { - if (navigation) { - NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); } } @@ -68,25 +64,19 @@ void NavigationRegion3D::set_enabled(bool p_enabled) { } bool NavigationRegion3D::is_enabled() const { - return enabled; } ///////////////////////////// void NavigationRegion3D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { - Node3D *c = this; while (c) { - navigation = Object::cast_to(c); if (navigation) { - if (enabled) { - NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); } break; @@ -96,7 +86,6 @@ void NavigationRegion3D::_notification(int p_what) { } if (navmesh.is_valid() && get_tree()->is_debugging_navigation_hint()) { - MeshInstance3D *dm = memnew(MeshInstance3D); dm->set_mesh(navmesh->get_debug_mesh()); if (is_enabled()) { @@ -110,14 +99,11 @@ void NavigationRegion3D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform()); } break; case NOTIFICATION_EXIT_TREE: { - if (navigation) { - NavigationServer3D::get_singleton()->region_set_map(region, RID()); } @@ -131,7 +117,6 @@ void NavigationRegion3D::_notification(int p_what) { } void NavigationRegion3D::set_navigation_mesh(const Ref &p_navmesh) { - if (p_navmesh == navmesh) return; @@ -158,7 +143,6 @@ void NavigationRegion3D::set_navigation_mesh(const Ref &p_navmes } Ref NavigationRegion3D::get_navigation_mesh() const { - return navmesh; } @@ -176,7 +160,6 @@ void _bake_navigation_mesh(void *p_user_data) { args->nav_region->call_deferred("_bake_finished", nav_mesh); memdelete(args); } else { - ERR_PRINT("Can't bake the navigation mesh if the `NavigationMesh` resource doesn't exist"); args->nav_region->call_deferred("_bake_finished", Ref()); memdelete(args); @@ -199,7 +182,6 @@ void NavigationRegion3D::_bake_finished(Ref p_nav_mesh) { } String NavigationRegion3D::get_configuration_warning() const { - if (!is_visible_in_tree() || !is_inside_tree()) return String(); @@ -208,7 +190,6 @@ String NavigationRegion3D::get_configuration_warning() const { } const Node3D *c = this; while (c) { - if (Object::cast_to(c)) return String(); @@ -219,7 +200,6 @@ String NavigationRegion3D::get_configuration_warning() const { } void NavigationRegion3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navmesh"), &NavigationRegion3D::set_navigation_mesh); ClassDB::bind_method(D_METHOD("get_navigation_mesh"), &NavigationRegion3D::get_navigation_mesh); diff --git a/scene/3d/navigation_region_3d.h b/scene/3d/navigation_region_3d.h index a7b5077f53..fcd2efd4ef 100644 --- a/scene/3d/navigation_region_3d.h +++ b/scene/3d/navigation_region_3d.h @@ -38,7 +38,6 @@ class Navigation3D; class NavigationRegion3D : public Node3D { - GDCLASS(NavigationRegion3D, Node3D); bool enabled = true; diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 913a3ea49f..c823e7e532 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -74,7 +74,6 @@ Node3DGizmo::Node3DGizmo() { } void Node3D::_notify_dirty() { - #ifdef TOOLS_ENABLED if ((data.gizmo.is_valid() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) { #else @@ -91,7 +90,6 @@ void Node3D::_update_local_transform() const { data.dirty &= ~DIRTY_LOCAL; } void Node3D::_propagate_transform_changed(Node3D *p_origin) { - if (!is_inside_tree()) { return; } @@ -104,7 +102,6 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) { data.children_lock++; for (List::Element *E = data.children.front(); E; E = E->next()) { - if (E->get()->data.toplevel_active) continue; //don't propagate to a toplevel E->get()->_propagate_transform_changed(p_origin); @@ -122,7 +119,6 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) { } void Node3D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { ERR_FAIL_COND(!get_tree()); @@ -137,7 +133,6 @@ void Node3D::_notification(int p_what) { data.C = nullptr; if (data.toplevel && !Engine::get_singleton()->is_editor_hint()) { - if (data.parent) { data.local_transform = data.parent->get_global_transform() * get_transform(); data.dirty = DIRTY_VECTORS; //global is always dirty upon entering a scene @@ -152,7 +147,6 @@ void Node3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - notification(NOTIFICATION_EXIT_WORLD, true); if (xform_change.in_list()) get_tree()->xform_change_list.remove(&xform_change); @@ -163,7 +157,6 @@ void Node3D::_notification(int p_what) { data.toplevel_active = false; } break; case NOTIFICATION_ENTER_WORLD: { - data.inside_world = true; data.viewport = nullptr; Node *parent = get_parent(); @@ -175,16 +168,13 @@ void Node3D::_notification(int p_what) { ERR_FAIL_COND(!data.viewport); if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, nullptr, 0); } #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) { - //get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this); get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this); if (!data.gizmo_disabled) { - if (data.gizmo.is_valid()) { data.gizmo->create(); if (is_visible_in_tree()) { @@ -198,7 +188,6 @@ void Node3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_WORLD: { - #ifdef TOOLS_ENABLED if (data.gizmo.is_valid()) { data.gizmo->free(); @@ -207,7 +196,6 @@ void Node3D::_notification(int p_what) { #endif if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, nullptr, 0); } @@ -217,7 +205,6 @@ void Node3D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - #ifdef TOOLS_ENABLED if (data.gizmo.is_valid()) { data.gizmo->transform(); @@ -231,7 +218,6 @@ void Node3D::_notification(int p_what) { } void Node3D::set_transform(const Transform &p_transform) { - data.local_transform = p_transform; data.dirty |= DIRTY_VECTORS; _change_notify("translation"); @@ -245,7 +231,6 @@ void Node3D::set_transform(const Transform &p_transform) { } void Node3D::set_global_transform(const Transform &p_transform) { - Transform xform = (data.parent && !data.toplevel_active) ? data.parent->get_global_transform().affine_inverse() * p_transform : @@ -255,30 +240,23 @@ void Node3D::set_global_transform(const Transform &p_transform) { } Transform Node3D::get_transform() const { - if (data.dirty & DIRTY_LOCAL) { - _update_local_transform(); } return data.local_transform; } Transform Node3D::get_global_transform() const { - ERR_FAIL_COND_V(!is_inside_tree(), Transform()); if (data.dirty & DIRTY_GLOBAL) { - if (data.dirty & DIRTY_LOCAL) { - _update_local_transform(); } if (data.parent && !data.toplevel_active) { - data.global_transform = data.parent->get_global_transform() * data.local_transform; } else { - data.global_transform = data.local_transform; } @@ -303,12 +281,10 @@ Transform Node3D::get_local_gizmo_transform() const { #endif Node3D *Node3D::get_parent_spatial() const { - return data.parent; } Transform Node3D::get_relative_transform(const Node *p_parent) const { - if (p_parent == this) return Transform(); @@ -321,7 +297,6 @@ Transform Node3D::get_relative_transform(const Node *p_parent) const { } void Node3D::set_translation(const Vector3 &p_translation) { - data.local_transform.origin = p_translation; _change_notify("transform"); _propagate_transform_changed(this); @@ -331,7 +306,6 @@ void Node3D::set_translation(const Vector3 &p_translation) { } void Node3D::set_rotation(const Vector3 &p_euler_rad) { - if (data.dirty & DIRTY_VECTORS) { data.scale = data.local_transform.basis.get_scale(); data.dirty &= ~DIRTY_VECTORS; @@ -347,12 +321,10 @@ void Node3D::set_rotation(const Vector3 &p_euler_rad) { } void Node3D::set_rotation_degrees(const Vector3 &p_euler_deg) { - set_rotation(p_euler_deg * Math_PI / 180.0); } void Node3D::set_scale(const Vector3 &p_scale) { - if (data.dirty & DIRTY_VECTORS) { data.rotation = data.local_transform.basis.get_rotation(); data.dirty &= ~DIRTY_VECTORS; @@ -368,12 +340,10 @@ void Node3D::set_scale(const Vector3 &p_scale) { } Vector3 Node3D::get_translation() const { - return data.local_transform.origin; } Vector3 Node3D::get_rotation() const { - if (data.dirty & DIRTY_VECTORS) { data.scale = data.local_transform.basis.get_scale(); data.rotation = data.local_transform.basis.get_rotation(); @@ -385,12 +355,10 @@ Vector3 Node3D::get_rotation() const { } Vector3 Node3D::get_rotation_degrees() const { - return get_rotation() * 180.0 / Math_PI; } Vector3 Node3D::get_scale() const { - if (data.dirty & DIRTY_VECTORS) { data.scale = data.local_transform.basis.get_scale(); data.rotation = data.local_transform.basis.get_rotation(); @@ -402,7 +370,6 @@ Vector3 Node3D::get_scale() const { } void Node3D::update_gizmo() { - #ifdef TOOLS_ENABLED if (!is_inside_world()) return; @@ -418,7 +385,6 @@ void Node3D::update_gizmo() { } void Node3D::set_gizmo(const Ref &p_gizmo) { - #ifdef TOOLS_ENABLED if (data.gizmo_disabled) @@ -427,7 +393,6 @@ void Node3D::set_gizmo(const Ref &p_gizmo) { data.gizmo->free(); data.gizmo = p_gizmo; if (data.gizmo.is_valid() && is_inside_world()) { - data.gizmo->create(); if (is_visible_in_tree()) { data.gizmo->redraw(); @@ -439,7 +404,6 @@ void Node3D::set_gizmo(const Ref &p_gizmo) { } Ref Node3D::get_gizmo() const { - #ifdef TOOLS_ENABLED return data.gizmo; @@ -450,7 +414,6 @@ Ref Node3D::get_gizmo() const { } void Node3D::_update_gizmo() { - #ifdef TOOLS_ENABLED if (!is_inside_world()) return; @@ -466,7 +429,6 @@ void Node3D::_update_gizmo() { #ifdef TOOLS_ENABLED void Node3D::set_disable_gizmo(bool p_enabled) { - data.gizmo_disabled = p_enabled; if (!p_enabled && data.gizmo.is_valid()) data.gizmo = Ref(); @@ -475,7 +437,6 @@ void Node3D::set_disable_gizmo(bool p_enabled) { #endif void Node3D::set_disable_scale(bool p_enabled) { - data.disable_scale = p_enabled; } @@ -484,11 +445,9 @@ bool Node3D::is_scale_disabled() const { } void Node3D::set_as_toplevel(bool p_enabled) { - if (data.toplevel == p_enabled) return; if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) { - if (p_enabled) set_transform(get_global_transform()); else if (data.parent) @@ -503,12 +462,10 @@ void Node3D::set_as_toplevel(bool p_enabled) { } bool Node3D::is_set_as_toplevel() const { - return data.toplevel; } Ref Node3D::get_world_3d() const { - ERR_FAIL_COND_V(!is_inside_world(), Ref()); ERR_FAIL_COND_V(!data.viewport, Ref()); @@ -516,7 +473,6 @@ Ref Node3D::get_world_3d() const { } void Node3D::_propagate_visibility_changed() { - notification(NOTIFICATION_VISIBILITY_CHANGED); emit_signal(SceneStringNames::get_singleton()->visibility_changed); _change_notify("visible"); @@ -526,7 +482,6 @@ void Node3D::_propagate_visibility_changed() { #endif for (List::Element *E = data.children.front(); E; E = E->next()) { - Node3D *c = E->get(); if (!c || !c->data.visible) continue; @@ -535,7 +490,6 @@ void Node3D::_propagate_visibility_changed() { } void Node3D::show() { - if (data.visible) return; @@ -548,7 +502,6 @@ void Node3D::show() { } void Node3D::hide() { - if (!data.visible) return; @@ -561,7 +514,6 @@ void Node3D::hide() { } bool Node3D::is_visible_in_tree() const { - const Node3D *s = this; while (s) { @@ -575,7 +527,6 @@ bool Node3D::is_visible_in_tree() const { } void Node3D::set_visible(bool p_visible) { - if (p_visible) show(); else @@ -583,7 +534,6 @@ void Node3D::set_visible(bool p_visible) { } bool Node3D::is_visible() const { - return data.visible; } @@ -594,34 +544,29 @@ void Node3D::rotate_object_local(const Vector3 &p_axis, float p_angle) { } void Node3D::rotate(const Vector3 &p_axis, float p_angle) { - Transform t = get_transform(); t.basis.rotate(p_axis, p_angle); set_transform(t); } void Node3D::rotate_x(float p_angle) { - Transform t = get_transform(); t.basis.rotate(Vector3(1, 0, 0), p_angle); set_transform(t); } void Node3D::rotate_y(float p_angle) { - Transform t = get_transform(); t.basis.rotate(Vector3(0, 1, 0), p_angle); set_transform(t); } void Node3D::rotate_z(float p_angle) { - Transform t = get_transform(); t.basis.rotate(Vector3(0, 0, 1), p_angle); set_transform(t); } void Node3D::translate(const Vector3 &p_offset) { - Transform t = get_transform(); t.translate(p_offset); set_transform(t); @@ -636,7 +581,6 @@ void Node3D::translate_object_local(const Vector3 &p_offset) { } void Node3D::scale(const Vector3 &p_ratio) { - Transform t = get_transform(); t.basis.scale(p_ratio); set_transform(t); @@ -649,14 +593,12 @@ void Node3D::scale_object_local(const Vector3 &p_scale) { } void Node3D::global_rotate(const Vector3 &p_axis, float p_angle) { - Transform t = get_global_transform(); t.basis.rotate(p_axis, p_angle); set_global_transform(t); } void Node3D::global_scale(const Vector3 &p_scale) { - Transform t = get_global_transform(); t.basis.scale(p_scale); set_global_transform(t); @@ -669,25 +611,21 @@ void Node3D::global_translate(const Vector3 &p_offset) { } void Node3D::orthonormalize() { - Transform t = get_transform(); t.orthonormalize(); set_transform(t); } void Node3D::set_identity() { - set_transform(Transform()); } void Node3D::look_at(const Vector3 &p_target, const Vector3 &p_up) { - Vector3 origin(get_global_transform().origin); look_at_from_position(origin, p_target, p_up); } void Node3D::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up) { - ERR_FAIL_COND_MSG(p_pos == p_target, "Node origin and target are in the same position, look_at() failed."); ERR_FAIL_COND_MSG(p_up.cross(p_target - p_pos) == Vector3(), "Up vector and direction between node origin and target are aligned, look_at() failed."); @@ -701,12 +639,10 @@ void Node3D::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target } Vector3 Node3D::to_local(Vector3 p_global) const { - return get_global_transform().affine_inverse().xform(p_global); } Vector3 Node3D::to_global(Vector3 p_local) const { - return get_global_transform().xform(p_local); } @@ -737,7 +673,6 @@ void Node3D::force_update_transform() { } void Node3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_transform", "local"), &Node3D::set_transform); ClassDB::bind_method(D_METHOD("get_transform"), &Node3D::get_transform); ClassDB::bind_method(D_METHOD("set_translation", "translation"), &Node3D::set_translation); @@ -821,7 +756,6 @@ void Node3D::_bind_methods() { Node3D::Node3D() : xform_change(this) { - data.dirty = DIRTY_NONE; data.children_lock = 0; diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h index a4191eb2b3..327d4671e9 100644 --- a/scene/3d/node_3d.h +++ b/scene/3d/node_3d.h @@ -35,7 +35,6 @@ #include "scene/main/scene_tree.h" class Node3DGizmo : public Reference { - GDCLASS(Node3DGizmo, Reference); public: @@ -50,7 +49,6 @@ public: }; class Node3D : public Node { - GDCLASS(Node3D, Node); OBJ_CATEGORY("3D"); @@ -64,7 +62,6 @@ class Node3D : public Node { mutable SelfList xform_change; struct Data { - mutable Transform global_transform; mutable Transform local_transform; mutable Vector3 rotation; diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index 4a425d1e0e..6f57bf81c4 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -37,7 +37,6 @@ void Path3D::_notification(int p_what) { } void Path3D::_curve_changed() { - if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) update_gizmo(); if (is_inside_tree()) { @@ -57,7 +56,6 @@ void Path3D::_curve_changed() { } void Path3D::set_curve(const Ref &p_curve) { - if (curve.is_valid()) { curve->disconnect("changed", callable_mp(this, &Path3D::_curve_changed)); } @@ -71,12 +69,10 @@ void Path3D::set_curve(const Ref &p_curve) { } Ref Path3D::get_curve() const { - return curve; } void Path3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path3D::set_curve); ClassDB::bind_method(D_METHOD("get_curve"), &Path3D::get_curve); @@ -86,14 +82,12 @@ void Path3D::_bind_methods() { } Path3D::Path3D() { - set_curve(Ref(memnew(Curve3D))); //create one by default } ////////////// void PathFollow3D::_update_transform() { - if (!path) return; @@ -124,7 +118,6 @@ void PathFollow3D::_update_transform() { // will be replaced by "Vector3(h_offset, v_offset, 0)" where it was formerly used if (rotation_mode == ROTATION_ORIENTED) { - Vector3 forward = c->interpolate_baked(o_next, cubic) - pos; if (forward.length_squared() < CMP_EPSILON2) @@ -213,11 +206,8 @@ void PathFollow3D::_update_transform() { } void PathFollow3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - Node *parent = get_parent(); if (parent) { path = Object::cast_to(parent); @@ -228,26 +218,21 @@ void PathFollow3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - path = nullptr; } break; } } void PathFollow3D::set_cubic_interpolation(bool p_enable) { - cubic = p_enable; } bool PathFollow3D::get_cubic_interpolation() const { - return cubic; } void PathFollow3D::_validate_property(PropertyInfo &property) const { - if (property.name == "offset") { - float max = 10000; if (path && path->get_curve().is_valid()) max = path->get_curve()->get_baked_length(); @@ -257,7 +242,6 @@ void PathFollow3D::_validate_property(PropertyInfo &property) const { } String PathFollow3D::get_configuration_warning() const { - if (!is_visible_in_tree() || !is_inside_tree()) return String(); @@ -274,7 +258,6 @@ String PathFollow3D::get_configuration_warning() const { } void PathFollow3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_offset", "offset"), &PathFollow3D::set_offset); ClassDB::bind_method(D_METHOD("get_offset"), &PathFollow3D::get_offset); @@ -336,42 +319,35 @@ void PathFollow3D::set_offset(float p_offset) { } void PathFollow3D::set_h_offset(float p_h_offset) { - h_offset = p_h_offset; if (path) _update_transform(); } float PathFollow3D::get_h_offset() const { - return h_offset; } void PathFollow3D::set_v_offset(float p_v_offset) { - v_offset = p_v_offset; if (path) _update_transform(); } float PathFollow3D::get_v_offset() const { - return v_offset; } float PathFollow3D::get_offset() const { - return offset; } void PathFollow3D::set_unit_offset(float p_unit_offset) { - if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) set_offset(p_unit_offset * path->get_curve()->get_baked_length()); } float PathFollow3D::get_unit_offset() const { - if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) return get_offset() / path->get_curve()->get_baked_length(); else @@ -379,7 +355,6 @@ float PathFollow3D::get_unit_offset() const { } void PathFollow3D::set_rotation_mode(RotationMode p_rotation_mode) { - rotation_mode = p_rotation_mode; update_configuration_warning(); @@ -387,22 +362,18 @@ void PathFollow3D::set_rotation_mode(RotationMode p_rotation_mode) { } PathFollow3D::RotationMode PathFollow3D::get_rotation_mode() const { - return rotation_mode; } void PathFollow3D::set_loop(bool p_loop) { - loop = p_loop; } bool PathFollow3D::has_loop() const { - return loop; } PathFollow3D::PathFollow3D() { - offset = 0; delta_offset = 0; h_offset = 0; diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h index 6f0db8c5c2..5a33016bc6 100644 --- a/scene/3d/path_3d.h +++ b/scene/3d/path_3d.h @@ -35,7 +35,6 @@ #include "scene/resources/curve.h" class Path3D : public Node3D { - GDCLASS(Path3D, Node3D); Ref curve; @@ -54,7 +53,6 @@ public: }; class PathFollow3D : public Node3D { - GDCLASS(PathFollow3D, Node3D); public: diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index d672c6f6b5..01e456debc 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -45,43 +45,35 @@ #endif Vector3 PhysicsBody3D::get_linear_velocity() const { - return Vector3(); } Vector3 PhysicsBody3D::get_angular_velocity() const { - return Vector3(); } float PhysicsBody3D::get_inverse_mass() const { - return 0; } void PhysicsBody3D::set_collision_layer(uint32_t p_layer) { - collision_layer = p_layer; PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), p_layer); } uint32_t PhysicsBody3D::get_collision_layer() const { - return collision_layer; } void PhysicsBody3D::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), p_mask); } uint32_t PhysicsBody3D::get_collision_mask() const { - return collision_mask; } void PhysicsBody3D::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -91,12 +83,10 @@ void PhysicsBody3D::set_collision_mask_bit(int p_bit, bool p_value) { } bool PhysicsBody3D::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } void PhysicsBody3D::set_collision_layer_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_layer(); if (p_value) mask |= 1 << p_bit; @@ -106,7 +96,6 @@ void PhysicsBody3D::set_collision_layer_bit(int p_bit, bool p_value) { } bool PhysicsBody3D::get_collision_layer_bit(int p_bit) const { - return get_collision_layer() & (1 << p_bit); } @@ -125,7 +114,6 @@ TypedArray PhysicsBody3D::get_collision_exceptions() { } void PhysicsBody3D::add_collision_exception_with(Node *p_node) { - ERR_FAIL_NULL(p_node); CollisionObject3D *collision_object = Object::cast_to(p_node); ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds."); @@ -133,7 +121,6 @@ void PhysicsBody3D::add_collision_exception_with(Node *p_node) { } void PhysicsBody3D::remove_collision_exception_with(Node *p_node) { - ERR_FAIL_NULL(p_node); CollisionObject3D *collision_object = Object::cast_to(p_node); ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds."); @@ -146,7 +133,6 @@ void PhysicsBody3D::_set_layers(uint32_t p_mask) { } uint32_t PhysicsBody3D::_get_layers() const { - return get_collision_layer(); } @@ -173,7 +159,6 @@ void PhysicsBody3D::_bind_methods() { PhysicsBody3D::PhysicsBody3D(PhysicsServer3D::BodyMode p_mode) : CollisionObject3D(PhysicsServer3D::get_singleton()->body_create(p_mode), false) { - collision_layer = 1; collision_mask = 1; } @@ -198,28 +183,23 @@ Ref StaticBody3D::get_physics_material_override() const { } void StaticBody3D::set_constant_linear_velocity(const Vector3 &p_vel) { - constant_linear_velocity = p_vel; PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity); } void StaticBody3D::set_constant_angular_velocity(const Vector3 &p_vel) { - constant_angular_velocity = p_vel; PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity); } Vector3 StaticBody3D::get_constant_linear_velocity() const { - return constant_linear_velocity; } Vector3 StaticBody3D::get_constant_angular_velocity() const { - return constant_angular_velocity; } void StaticBody3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "vel"), &StaticBody3D::set_constant_linear_velocity); ClassDB::bind_method(D_METHOD("set_constant_angular_velocity", "vel"), &StaticBody3D::set_constant_angular_velocity); ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody3D::get_constant_linear_velocity); @@ -254,7 +234,6 @@ void StaticBody3D::_reload_physics_characteristics() { } void RigidBody3D::_body_enter_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -271,7 +250,6 @@ void RigidBody3D::_body_enter_tree(ObjectID p_id) { emit_signal(SceneStringNames::get_singleton()->body_entered, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape); } @@ -279,7 +257,6 @@ void RigidBody3D::_body_enter_tree(ObjectID p_id) { } void RigidBody3D::_body_exit_tree(ObjectID p_id) { - Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to(obj); ERR_FAIL_COND(!node); @@ -294,7 +271,6 @@ void RigidBody3D::_body_exit_tree(ObjectID p_id) { emit_signal(SceneStringNames::get_singleton()->body_exited, node); for (int i = 0; i < E->get().shapes.size(); i++) { - emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape); } @@ -302,7 +278,6 @@ void RigidBody3D::_body_exit_tree(ObjectID p_id) { } void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) { - bool body_in = p_status == 1; ObjectID objid = p_instance; @@ -316,7 +291,6 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap if (body_in) { if (!E) { - E = contact_monitor->body_map.insert(objid, BodyState()); //E->get().rc=0; E->get().in_tree = node && node->is_inside_tree(); @@ -337,7 +311,6 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap } } else { - //E->get().rc--; if (node) @@ -346,7 +319,6 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap bool in_tree = E->get().in_tree; if (E->get().shapes.empty()) { - if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree)); @@ -363,14 +335,12 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap } struct _RigidBodyInOut { - ObjectID id; int shape; int local_shape; }; void RigidBody3D::_direct_state_changed(Object *p_state) { - #ifdef DEBUG_ENABLED state = Object::cast_to(p_state); #else @@ -390,15 +360,12 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { set_ignore_transform_notification(false); if (contact_monitor) { - contact_monitor->locked = true; //untag all int rc = 0; for (Map::Element *E = contact_monitor->body_map.front(); E; E = E->next()) { - for (int i = 0; i < E->get().shapes.size(); i++) { - E->get().shapes[i].tagged = false; rc++; } @@ -412,7 +379,6 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { //put the ones to add for (int i = 0; i < state->get_contact_count(); i++) { - ObjectID obj = state->get_contact_collider_id(i); int local_shape = state->get_contact_local_shape(i); int shape = state->get_contact_collider_shape(i); @@ -431,7 +397,6 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { ShapePair sp(shape, local_shape); int idx = E->get().shapes.find(sp); if (idx == -1) { - toadd[toadd_count].local_shape = local_shape; toadd[toadd_count].id = obj; toadd[toadd_count].shape = shape; @@ -445,11 +410,8 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { //put the ones to remove for (Map::Element *E = contact_monitor->body_map.front(); E; E = E->next()) { - for (int i = 0; i < E->get().shapes.size(); i++) { - if (!E->get().shapes[i].tagged) { - toremove[toremove_count].body_id = E->key(); toremove[toremove_count].pair = E->get().shapes[i]; toremove_count++; @@ -460,14 +422,12 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { //process remotions for (int i = 0; i < toremove_count; i++) { - _body_inout(0, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape); } //process aditions for (int i = 0; i < toadd_count; i++) { - _body_inout(1, toadd[i].id, toadd[i].shape, toadd[i].local_shape); } @@ -478,7 +438,6 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { } void RigidBody3D::_notification(int p_what) { - #ifdef TOOLS_ENABLED if (p_what == NOTIFICATION_ENTER_TREE) { if (Engine::get_singleton()->is_editor_hint()) { @@ -496,16 +455,12 @@ void RigidBody3D::_notification(int p_what) { } void RigidBody3D::set_mode(Mode p_mode) { - mode = p_mode; switch (p_mode) { - case MODE_RIGID: { - PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_RIGID); } break; case MODE_STATIC: { - PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_STATIC); } break; @@ -514,7 +469,6 @@ void RigidBody3D::set_mode(Mode p_mode) { } break; case MODE_KINEMATIC: { - PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_KINEMATIC); } break; } @@ -522,12 +476,10 @@ void RigidBody3D::set_mode(Mode p_mode) { } RigidBody3D::Mode RigidBody3D::get_mode() const { - return mode; } void RigidBody3D::set_mass(real_t p_mass) { - ERR_FAIL_COND(p_mass <= 0); mass = p_mass; _change_notify("mass"); @@ -535,16 +487,13 @@ void RigidBody3D::set_mass(real_t p_mass) { PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass); } real_t RigidBody3D::get_mass() const { - return mass; } void RigidBody3D::set_weight(real_t p_weight) { - set_mass(p_weight / real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8))); } real_t RigidBody3D::get_weight() const { - return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8)); } @@ -568,39 +517,32 @@ Ref RigidBody3D::get_physics_material_override() const { } void RigidBody3D::set_gravity_scale(real_t p_gravity_scale) { - gravity_scale = p_gravity_scale; PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale); } real_t RigidBody3D::get_gravity_scale() const { - return gravity_scale; } void RigidBody3D::set_linear_damp(real_t p_linear_damp) { - ERR_FAIL_COND(p_linear_damp < -1); linear_damp = p_linear_damp; PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP, linear_damp); } real_t RigidBody3D::get_linear_damp() const { - return linear_damp; } void RigidBody3D::set_angular_damp(real_t p_angular_damp) { - ERR_FAIL_COND(p_angular_damp < -1); angular_damp = p_angular_damp; PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP, angular_damp); } real_t RigidBody3D::get_angular_damp() const { - return angular_damp; } void RigidBody3D::set_axis_velocity(const Vector3 &p_axis) { - Vector3 v = state ? state->get_linear_velocity() : linear_velocity; Vector3 axis = p_axis.normalized(); v -= axis * axis.dot(v); @@ -614,7 +556,6 @@ void RigidBody3D::set_axis_velocity(const Vector3 &p_axis) { } void RigidBody3D::set_linear_velocity(const Vector3 &p_velocity) { - linear_velocity = p_velocity; if (state) state->set_linear_velocity(linear_velocity); @@ -623,12 +564,10 @@ void RigidBody3D::set_linear_velocity(const Vector3 &p_velocity) { } Vector3 RigidBody3D::get_linear_velocity() const { - return linear_velocity; } void RigidBody3D::set_angular_velocity(const Vector3 &p_velocity) { - angular_velocity = p_velocity; if (state) state->set_angular_velocity(angular_velocity); @@ -636,12 +575,10 @@ void RigidBody3D::set_angular_velocity(const Vector3 &p_velocity) { PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity); } Vector3 RigidBody3D::get_angular_velocity() const { - return angular_velocity; } void RigidBody3D::set_use_custom_integrator(bool p_enable) { - if (custom_integrator == p_enable) return; @@ -649,40 +586,33 @@ void RigidBody3D::set_use_custom_integrator(bool p_enable) { PhysicsServer3D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable); } bool RigidBody3D::is_using_custom_integrator() { - return custom_integrator; } void RigidBody3D::set_sleeping(bool p_sleeping) { - sleeping = p_sleeping; PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_SLEEPING, sleeping); } void RigidBody3D::set_can_sleep(bool p_active) { - can_sleep = p_active; PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_CAN_SLEEP, p_active); } bool RigidBody3D::is_able_to_sleep() const { - return can_sleep; } bool RigidBody3D::is_sleeping() const { - return sleeping; } void RigidBody3D::set_max_contacts_reported(int p_amount) { - max_contacts_reported = p_amount; PhysicsServer3D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount); } int RigidBody3D::get_max_contacts_reported() const { - return max_contacts_reported; } @@ -703,7 +633,6 @@ void RigidBody3D::apply_central_impulse(const Vector3 &p_impulse) { } void RigidBody3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) { - PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse); } @@ -712,27 +641,22 @@ void RigidBody3D::apply_torque_impulse(const Vector3 &p_impulse) { } void RigidBody3D::set_use_continuous_collision_detection(bool p_enable) { - ccd = p_enable; PhysicsServer3D::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(), p_enable); } bool RigidBody3D::is_using_continuous_collision_detection() const { - return ccd; } void RigidBody3D::set_contact_monitor(bool p_enabled) { - if (p_enabled == is_contact_monitor_enabled()) return; if (!p_enabled) { - ERR_FAIL_COND_MSG(contact_monitor->locked, "Can't disable contact monitoring during in/out callback. Use call_deferred(\"set_contact_monitor\", false) instead."); for (Map::Element *E = contact_monitor->body_map.front(); E; E = E->next()) { - //clean up mess Object *obj = ObjectDB::get_instance(E->key()); Node *node = Object::cast_to(obj); @@ -746,14 +670,12 @@ void RigidBody3D::set_contact_monitor(bool p_enabled) { memdelete(contact_monitor); contact_monitor = nullptr; } else { - contact_monitor = memnew(ContactMonitor); contact_monitor->locked = false; } } bool RigidBody3D::is_contact_monitor_enabled() const { - return contact_monitor != nullptr; } @@ -766,7 +688,6 @@ bool RigidBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const { } Array RigidBody3D::get_colliding_bodies() const { - ERR_FAIL_COND_V(!contact_monitor, Array()); Array ret; @@ -785,7 +706,6 @@ Array RigidBody3D::get_colliding_bodies() const { } String RigidBody3D::get_configuration_warning() const { - Transform t = get_transform(); String warning = CollisionObject3D::get_configuration_warning(); @@ -801,7 +721,6 @@ String RigidBody3D::get_configuration_warning() const { } void RigidBody3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody3D::set_mode); ClassDB::bind_method(D_METHOD("get_mode"), &RigidBody3D::get_mode); @@ -905,7 +824,6 @@ void RigidBody3D::_bind_methods() { RigidBody3D::RigidBody3D() : PhysicsBody3D(PhysicsServer3D::BODY_MODE_RIGID) { - mode = MODE_RIGID; mass = 1; @@ -928,7 +846,6 @@ RigidBody3D::RigidBody3D() : } RigidBody3D::~RigidBody3D() { - if (contact_monitor) memdelete(contact_monitor); } @@ -947,7 +864,6 @@ void RigidBody3D::_reload_physics_characteristics() { ////////////////////////// Ref KinematicBody3D::_move(const Vector3 &p_motion, bool p_infinite_inertia, bool p_exclude_raycast_shapes, bool p_test_only) { - Collision col; if (move_and_collide(p_motion, p_infinite_inertia, col, p_exclude_raycast_shapes, p_test_only)) { if (motion_cache.is_null()) { @@ -972,7 +888,6 @@ Vector3 KinematicBody3D::get_angular_velocity() const { } bool KinematicBody3D::move_and_collide(const Vector3 &p_motion, bool p_infinite_inertia, Collision &r_collision, bool p_exclude_raycast_shapes, bool p_test_only) { - Transform gt = get_global_transform(); PhysicsServer3D::MotionResult result; bool colliding = PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, &result, p_exclude_raycast_shapes); @@ -1008,7 +923,6 @@ bool KinematicBody3D::move_and_collide(const Vector3 &p_motion, bool p_infinite_ #define FLOOR_ANGLE_THRESHOLD 0.01 Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) { - Vector3 body_velocity = p_linear_velocity; Vector3 body_velocity_normal = body_velocity.normalized(); @@ -1030,7 +944,6 @@ Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const floor_velocity = Vector3(); while (p_max_slides) { - Collision collision; bool found_collision = false; @@ -1102,7 +1015,6 @@ Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const } Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) { - bool was_on_floor = on_floor; Vector3 ret = move_and_slide(p_linear_velocity, p_up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia); @@ -1114,7 +1026,6 @@ Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_veloci Transform gt = get_global_transform(); if (move_and_collide(p_snap, p_infinite_inertia, col, false, true)) { - bool apply = true; if (p_up_direction != Vector3()) { if (Math::acos(p_up_direction.normalized().dot(col.normal)) < p_floor_max_angle) { @@ -1141,38 +1052,31 @@ Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_veloci } bool KinematicBody3D::is_on_floor() const { - return on_floor; } bool KinematicBody3D::is_on_wall() const { - return on_wall; } bool KinematicBody3D::is_on_ceiling() const { - return on_ceiling; } Vector3 KinematicBody3D::get_floor_normal() const { - return floor_normal; } Vector3 KinematicBody3D::get_floor_velocity() const { - return floor_velocity; } bool KinematicBody3D::test_move(const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia) { - ERR_FAIL_COND_V(!is_inside_tree(), false); return PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia); } bool KinematicBody3D::separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision) { - PhysicsServer3D::SeparationResult sep_res[8]; //max 8 rays Transform gt = get_global_transform(); @@ -1217,17 +1121,14 @@ bool KinematicBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const { } void KinematicBody3D::set_safe_margin(float p_margin) { - margin = p_margin; PhysicsServer3D::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin); } float KinematicBody3D::get_safe_margin() const { - return margin; } int KinematicBody3D::get_slide_count() const { - return colliders.size(); } @@ -1237,7 +1138,6 @@ KinematicBody3D::Collision KinematicBody3D::get_slide_collision(int p_bounce) co } Ref KinematicBody3D::_get_slide_collision(int p_bounce) { - ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref()); if (p_bounce >= slide_colliders.size()) { slide_colliders.resize(p_bounce + 1); @@ -1265,7 +1165,6 @@ void KinematicBody3D::_notification(int p_what) { } void KinematicBody3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("_direct_state_changed"), &KinematicBody3D::_direct_state_changed); ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody3D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false)); @@ -1309,7 +1208,6 @@ void KinematicBody3D::_direct_state_changed(Object *p_state) { KinematicBody3D::KinematicBody3D() : PhysicsBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) { - margin = 0.001; locked_axis = 0; on_floor = false; @@ -1319,7 +1217,6 @@ KinematicBody3D::KinematicBody3D() : PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); } KinematicBody3D::~KinematicBody3D() { - if (motion_cache.is_valid()) { motion_cache->owner = nullptr; } @@ -1333,7 +1230,6 @@ KinematicBody3D::~KinematicBody3D() { /////////////////////////////////////// Vector3 KinematicCollision3D::get_position() const { - return collision.collision; } Vector3 KinematicCollision3D::get_normal() const { @@ -1353,7 +1249,6 @@ Object *KinematicCollision3D::get_local_shape() const { } Object *KinematicCollision3D::get_collider() const { - if (collision.collider.is_valid()) { return ObjectDB::get_instance(collision.collider); } @@ -1361,11 +1256,9 @@ Object *KinematicCollision3D::get_collider() const { return nullptr; } ObjectID KinematicCollision3D::get_collider_id() const { - return collision.collider; } Object *KinematicCollision3D::get_collider_shape() const { - Object *collider = get_collider(); if (collider) { CollisionObject3D *obj2d = Object::cast_to(collider); @@ -1378,20 +1271,16 @@ Object *KinematicCollision3D::get_collider_shape() const { return nullptr; } int KinematicCollision3D::get_collider_shape_index() const { - return collision.collider_shape; } Vector3 KinematicCollision3D::get_collider_velocity() const { - return collision.collider_vel; } Variant KinematicCollision3D::get_collider_metadata() const { - return Variant(); } void KinematicCollision3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_position"), &KinematicCollision3D::get_position); ClassDB::bind_method(D_METHOD("get_normal"), &KinematicCollision3D::get_normal); ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision3D::get_travel); @@ -1418,7 +1307,6 @@ void KinematicCollision3D::_bind_methods() { } KinematicCollision3D::KinematicCollision3D() { - collision.collider_shape = 0; collision.local_shape = 0; owner = nullptr; @@ -2039,11 +1927,9 @@ bool PhysicalBone3D::_get(const StringName &p_name, Variant &r_ret) const { } void PhysicalBone3D::_get_property_list(List *p_list) const { - Skeleton3D *parent = find_skeleton_parent(get_parent()); if (parent) { - String names; for (int i = 0; i < parent->get_bone_count(); i++) { if (i > 0) @@ -2053,7 +1939,6 @@ void PhysicalBone3D::_get_property_list(List *p_list) const { p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bone_name", PROPERTY_HINT_ENUM, names)); } else { - p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bone_name")); } @@ -2087,7 +1972,6 @@ void PhysicalBone3D::_notification(int p_what) { break; case NOTIFICATION_TRANSFORM_CHANGED: if (Engine::get_singleton()->is_editor_hint()) { - update_offset(); } break; @@ -2095,7 +1979,6 @@ void PhysicalBone3D::_notification(int p_what) { } void PhysicalBone3D::_direct_state_changed(Object *p_state) { - if (!simulate_physics || !_internal_simulate_physics) { return; } @@ -2238,7 +2121,6 @@ void PhysicalBone3D::_fix_joint_offset() { } void PhysicalBone3D::_reload_joint() { - if (joint.is_valid()) { PhysicsServer3D::get_singleton()->free(joint); joint = RID(); @@ -2259,7 +2141,6 @@ void PhysicalBone3D::_reload_joint() { switch (get_joint_type()) { case JOINT_TYPE_PIN: { - joint = PhysicsServer3D::get_singleton()->joint_create_pin(body_a->get_rid(), local_a.origin, get_rid(), joint_offset.origin); const PinJointData *pjd(static_cast(joint_data)); PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_BIAS, pjd->bias); @@ -2268,7 +2149,6 @@ void PhysicalBone3D::_reload_joint() { } break; case JOINT_TYPE_CONE: { - joint = PhysicsServer3D::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, get_rid(), joint_offset); const ConeJointData *cjd(static_cast(joint_data)); PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, cjd->swing_span); @@ -2279,7 +2159,6 @@ void PhysicalBone3D::_reload_joint() { } break; case JOINT_TYPE_HINGE: { - joint = PhysicsServer3D::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, get_rid(), joint_offset); const HingeJointData *hjd(static_cast(joint_data)); PhysicsServer3D::get_singleton()->hinge_joint_set_flag(joint, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, hjd->angular_limit_enabled); @@ -2291,7 +2170,6 @@ void PhysicalBone3D::_reload_joint() { } break; case JOINT_TYPE_SLIDER: { - joint = PhysicsServer3D::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, get_rid(), joint_offset); const SliderJointData *sjd(static_cast(joint_data)); PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, sjd->linear_limit_upper); @@ -2307,7 +2185,6 @@ void PhysicalBone3D::_reload_joint() { } break; case JOINT_TYPE_6DOF: { - joint = PhysicsServer3D::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, get_rid(), joint_offset); const SixDOFJointData *g6dofjd(static_cast(joint_data)); for (int axis = 0; axis < 3; ++axis) { @@ -2370,7 +2247,6 @@ Skeleton3D *PhysicalBone3D::find_skeleton_parent() { } void PhysicalBone3D::set_joint_type(JointType p_joint_type) { - if (p_joint_type == get_joint_type()) return; @@ -2469,7 +2345,6 @@ bool PhysicalBone3D::is_simulating_physics() { } void PhysicalBone3D::set_bone_name(const String &p_name) { - bone_name = p_name; bone_id = -1; @@ -2478,34 +2353,28 @@ void PhysicalBone3D::set_bone_name(const String &p_name) { } const String &PhysicalBone3D::get_bone_name() const { - return bone_name; } void PhysicalBone3D::set_mass(real_t p_mass) { - ERR_FAIL_COND(p_mass <= 0); mass = p_mass; PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass); } real_t PhysicalBone3D::get_mass() const { - return mass; } void PhysicalBone3D::set_weight(real_t p_weight) { - set_mass(p_weight / real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8))); } real_t PhysicalBone3D::get_weight() const { - return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8)); } void PhysicalBone3D::set_friction(real_t p_friction) { - ERR_FAIL_COND(p_friction < 0 || p_friction > 1); friction = p_friction; @@ -2513,12 +2382,10 @@ void PhysicalBone3D::set_friction(real_t p_friction) { } real_t PhysicalBone3D::get_friction() const { - return friction; } void PhysicalBone3D::set_bounce(real_t p_bounce) { - ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1); bounce = p_bounce; @@ -2526,18 +2393,15 @@ void PhysicalBone3D::set_bounce(real_t p_bounce) { } real_t PhysicalBone3D::get_bounce() const { - return bounce; } void PhysicalBone3D::set_gravity_scale(real_t p_gravity_scale) { - gravity_scale = p_gravity_scale; PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale); } real_t PhysicalBone3D::get_gravity_scale() const { - return gravity_scale; } @@ -2614,7 +2478,6 @@ void PhysicalBone3D::update_bone_id() { void PhysicalBone3D::update_offset() { #ifdef TOOLS_ENABLED if (parent_skeleton) { - Transform bone_transform(parent_skeleton->get_global_transform()); if (-1 != bone_id) bone_transform *= parent_skeleton->get_bone_global_pose(bone_id); diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index 205052f798..3a5b94e3b7 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -38,7 +38,6 @@ #include "skeleton_3d.h" class PhysicsBody3D : public CollisionObject3D { - GDCLASS(PhysicsBody3D, CollisionObject3D); uint32_t collision_layer; @@ -76,7 +75,6 @@ public: }; class StaticBody3D : public PhysicsBody3D { - GDCLASS(StaticBody3D, PhysicsBody3D); Vector3 constant_linear_velocity; @@ -105,7 +103,6 @@ private: }; class RigidBody3D : public PhysicsBody3D { - GDCLASS(RigidBody3D, PhysicsBody3D); public: @@ -138,7 +135,6 @@ protected: bool custom_integrator; struct ShapePair { - int body_shape; int local_shape; bool tagged; @@ -157,19 +153,16 @@ protected: } }; struct RigidBody3D_RemoveAction { - ObjectID body_id; ShapePair pair; }; struct BodyState { - //int rc; bool in_tree; VSet shapes; }; struct ContactMonitor { - bool locked; Map body_map; }; @@ -261,7 +254,6 @@ VARIANT_ENUM_CAST(RigidBody3D::Mode); class KinematicCollision3D; class KinematicBody3D : public PhysicsBody3D { - GDCLASS(KinematicBody3D, PhysicsBody3D); public: @@ -338,7 +330,6 @@ public: }; class KinematicCollision3D : public Reference { - GDCLASS(KinematicCollision3D, Reference); KinematicBody3D *owner; @@ -365,7 +356,6 @@ public: }; class PhysicalBone3D : public PhysicsBody3D { - GDCLASS(PhysicalBone3D, PhysicsBody3D); public: diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp index b6953fafac..d1a26f33bf 100644 --- a/scene/3d/physics_joint_3d.cpp +++ b/scene/3d/physics_joint_3d.cpp @@ -31,7 +31,6 @@ #include "physics_joint_3d.h" void Joint3D::_update_joint(bool p_only_free) { - if (joint.is_valid()) { if (ba.is_valid() && bb.is_valid()) PhysicsServer3D::get_singleton()->body_remove_collision_exception(ba, bb); @@ -72,7 +71,6 @@ void Joint3D::_update_joint(bool p_only_free) { } void Joint3D::set_node_a(const NodePath &p_node_a) { - if (a == p_node_a) return; @@ -81,38 +79,31 @@ void Joint3D::set_node_a(const NodePath &p_node_a) { } NodePath Joint3D::get_node_a() const { - return a; } void Joint3D::set_node_b(const NodePath &p_node_b) { - if (b == p_node_b) return; b = p_node_b; _update_joint(); } NodePath Joint3D::get_node_b() const { - return b; } void Joint3D::set_solver_priority(int p_priority) { - solver_priority = p_priority; if (joint.is_valid()) PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority); } int Joint3D::get_solver_priority() const { - return solver_priority; } void Joint3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_READY: { _update_joint(); } break; @@ -125,7 +116,6 @@ void Joint3D::_notification(int p_what) { } void Joint3D::set_exclude_nodes_from_collision(bool p_enable) { - if (exclude_from_collision == p_enable) return; exclude_from_collision = p_enable; @@ -133,12 +123,10 @@ void Joint3D::set_exclude_nodes_from_collision(bool p_enable) { } bool Joint3D::get_exclude_nodes_from_collision() const { - return exclude_from_collision; } void Joint3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_node_a", "node"), &Joint3D::set_node_a); ClassDB::bind_method(D_METHOD("get_node_a"), &Joint3D::get_node_a); @@ -159,7 +147,6 @@ void Joint3D::_bind_methods() { } Joint3D::Joint3D() { - exclude_from_collision = true; solver_priority = 1; set_notify_transform(true); @@ -168,7 +155,6 @@ Joint3D::Joint3D() { /////////////////////////////////// void PinJoint3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &PinJoint3D::set_param); ClassDB::bind_method(D_METHOD("get_param", "param"), &PinJoint3D::get_param); @@ -182,20 +168,17 @@ void PinJoint3D::_bind_methods() { } void PinJoint3D::set_param(Param p_param, float p_value) { - ERR_FAIL_INDEX(p_param, 3); params[p_param] = p_value; if (get_joint().is_valid()) PhysicsServer3D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer3D::PinJointParam(p_param), p_value); } float PinJoint3D::get_param(Param p_param) const { - ERR_FAIL_INDEX_V(p_param, 3, 0); return params[p_param]; } RID PinJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) { - Vector3 pinpos = get_global_transform().origin; Vector3 local_a = body_a->get_global_transform().affine_inverse().xform(pinpos); Vector3 local_b; @@ -213,7 +196,6 @@ RID PinJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) { } PinJoint3D::PinJoint3D() { - params[PARAM_BIAS] = 0.3; params[PARAM_DAMPING] = 1; params[PARAM_IMPULSE_CLAMP] = 0; @@ -224,27 +206,22 @@ PinJoint3D::PinJoint3D() { /////////////////////////////////// void HingeJoint3D::_set_upper_limit(float p_limit) { - set_param(PARAM_LIMIT_UPPER, Math::deg2rad(p_limit)); } float HingeJoint3D::_get_upper_limit() const { - return Math::rad2deg(get_param(PARAM_LIMIT_UPPER)); } void HingeJoint3D::_set_lower_limit(float p_limit) { - set_param(PARAM_LIMIT_LOWER, Math::deg2rad(p_limit)); } float HingeJoint3D::_get_lower_limit() const { - return Math::rad2deg(get_param(PARAM_LIMIT_LOWER)); } void HingeJoint3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &HingeJoint3D::set_param); ClassDB::bind_method(D_METHOD("get_param", "param"), &HingeJoint3D::get_param); @@ -286,7 +263,6 @@ void HingeJoint3D::_bind_methods() { } void HingeJoint3D::set_param(Param p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); params[p_param] = p_value; if (get_joint().is_valid()) @@ -295,13 +271,11 @@ void HingeJoint3D::set_param(Param p_param, float p_value) { update_gizmo(); } float HingeJoint3D::get_param(Param p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return params[p_param]; } void HingeJoint3D::set_flag(Flag p_flag, bool p_value) { - ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags[p_flag] = p_value; if (get_joint().is_valid()) @@ -310,13 +284,11 @@ void HingeJoint3D::set_flag(Flag p_flag, bool p_value) { update_gizmo(); } bool HingeJoint3D::get_flag(Flag p_flag) const { - ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false); return flags[p_flag]; } RID HingeJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) { - Transform gt = get_global_transform(); Transform ainv = body_a->get_global_transform().affine_inverse(); @@ -343,7 +315,6 @@ RID HingeJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) } HingeJoint3D::HingeJoint3D() { - params[PARAM_BIAS] = 0.3; params[PARAM_LIMIT_UPPER] = Math_PI * 0.5; params[PARAM_LIMIT_LOWER] = -Math_PI * 0.5; @@ -362,27 +333,22 @@ HingeJoint3D::HingeJoint3D() { ////////////////////////////////// void SliderJoint3D::_set_upper_limit_angular(float p_limit_angular) { - set_param(PARAM_ANGULAR_LIMIT_UPPER, Math::deg2rad(p_limit_angular)); } float SliderJoint3D::_get_upper_limit_angular() const { - return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_UPPER)); } void SliderJoint3D::_set_lower_limit_angular(float p_limit_angular) { - set_param(PARAM_ANGULAR_LIMIT_LOWER, Math::deg2rad(p_limit_angular)); } float SliderJoint3D::_get_lower_limit_angular() const { - return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_LOWER)); } void SliderJoint3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &SliderJoint3D::set_param); ClassDB::bind_method(D_METHOD("get_param", "param"), &SliderJoint3D::get_param); @@ -444,7 +410,6 @@ void SliderJoint3D::_bind_methods() { } void SliderJoint3D::set_param(Param p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); params[p_param] = p_value; if (get_joint().is_valid()) @@ -452,13 +417,11 @@ void SliderJoint3D::set_param(Param p_param, float p_value) { update_gizmo(); } float SliderJoint3D::get_param(Param p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return params[p_param]; } RID SliderJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) { - Transform gt = get_global_transform(); Transform ainv = body_a->get_global_transform().affine_inverse(); @@ -482,7 +445,6 @@ RID SliderJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b } SliderJoint3D::SliderJoint3D() { - params[PARAM_LINEAR_LIMIT_UPPER] = 1.0; params[PARAM_LINEAR_LIMIT_LOWER] = -1.0; params[PARAM_LINEAR_LIMIT_SOFTNESS] = 1.0; @@ -511,27 +473,22 @@ SliderJoint3D::SliderJoint3D() { ////////////////////////////////// void ConeTwistJoint3D::_set_swing_span(float p_limit_angular) { - set_param(PARAM_SWING_SPAN, Math::deg2rad(p_limit_angular)); } float ConeTwistJoint3D::_get_swing_span() const { - return Math::rad2deg(get_param(PARAM_SWING_SPAN)); } void ConeTwistJoint3D::_set_twist_span(float p_limit_angular) { - set_param(PARAM_TWIST_SPAN, Math::deg2rad(p_limit_angular)); } float ConeTwistJoint3D::_get_twist_span() const { - return Math::rad2deg(get_param(PARAM_TWIST_SPAN)); } void ConeTwistJoint3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &ConeTwistJoint3D::set_param); ClassDB::bind_method(D_METHOD("get_param", "param"), &ConeTwistJoint3D::get_param); @@ -557,7 +514,6 @@ void ConeTwistJoint3D::_bind_methods() { } void ConeTwistJoint3D::set_param(Param p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); params[p_param] = p_value; if (get_joint().is_valid()) @@ -566,13 +522,11 @@ void ConeTwistJoint3D::set_param(Param p_param, float p_value) { update_gizmo(); } float ConeTwistJoint3D::get_param(Param p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return params[p_param]; } RID ConeTwistJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) { - Transform gt = get_global_transform(); //Vector3 cone_twistpos = gt.origin; //Vector3 cone_twistdir = gt.basis.get_axis(2); @@ -599,7 +553,6 @@ RID ConeTwistJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *bod } ConeTwistJoint3D::ConeTwistJoint3D() { - params[PARAM_SWING_SPAN] = Math_PI * 0.25; params[PARAM_TWIST_SPAN] = Math_PI; params[PARAM_BIAS] = 0.3; @@ -610,67 +563,54 @@ ConeTwistJoint3D::ConeTwistJoint3D() { ///////////////////////////////////////////////////////////////////// void Generic6DOFJoint3D::_set_angular_hi_limit_x(float p_limit_angular) { - set_param_x(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular)); } float Generic6DOFJoint3D::_get_angular_hi_limit_x() const { - return Math::rad2deg(get_param_x(PARAM_ANGULAR_UPPER_LIMIT)); } void Generic6DOFJoint3D::_set_angular_lo_limit_x(float p_limit_angular) { - set_param_x(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular)); } float Generic6DOFJoint3D::_get_angular_lo_limit_x() const { - return Math::rad2deg(get_param_x(PARAM_ANGULAR_LOWER_LIMIT)); } void Generic6DOFJoint3D::_set_angular_hi_limit_y(float p_limit_angular) { - set_param_y(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular)); } float Generic6DOFJoint3D::_get_angular_hi_limit_y() const { - return Math::rad2deg(get_param_y(PARAM_ANGULAR_UPPER_LIMIT)); } void Generic6DOFJoint3D::_set_angular_lo_limit_y(float p_limit_angular) { - set_param_y(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular)); } float Generic6DOFJoint3D::_get_angular_lo_limit_y() const { - return Math::rad2deg(get_param_y(PARAM_ANGULAR_LOWER_LIMIT)); } void Generic6DOFJoint3D::_set_angular_hi_limit_z(float p_limit_angular) { - set_param_z(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular)); } float Generic6DOFJoint3D::_get_angular_hi_limit_z() const { - return Math::rad2deg(get_param_z(PARAM_ANGULAR_UPPER_LIMIT)); } void Generic6DOFJoint3D::_set_angular_lo_limit_z(float p_limit_angular) { - set_param_z(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular)); } float Generic6DOFJoint3D::_get_angular_lo_limit_z() const { - return Math::rad2deg(get_param_z(PARAM_ANGULAR_LOWER_LIMIT)); } void Generic6DOFJoint3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_x", "angle"), &Generic6DOFJoint3D::_set_angular_hi_limit_x); ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_x"), &Generic6DOFJoint3D::_get_angular_hi_limit_x); @@ -834,7 +774,6 @@ void Generic6DOFJoint3D::_bind_methods() { } void Generic6DOFJoint3D::set_param_x(Param p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); params_x[p_param] = p_value; if (get_joint().is_valid()) @@ -843,13 +782,11 @@ void Generic6DOFJoint3D::set_param_x(Param p_param, float p_value) { update_gizmo(); } float Generic6DOFJoint3D::get_param_x(Param p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return params_x[p_param]; } void Generic6DOFJoint3D::set_param_y(Param p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); params_y[p_param] = p_value; if (get_joint().is_valid()) @@ -857,13 +794,11 @@ void Generic6DOFJoint3D::set_param_y(Param p_param, float p_value) { update_gizmo(); } float Generic6DOFJoint3D::get_param_y(Param p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return params_y[p_param]; } void Generic6DOFJoint3D::set_param_z(Param p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); params_z[p_param] = p_value; if (get_joint().is_valid()) @@ -871,13 +806,11 @@ void Generic6DOFJoint3D::set_param_z(Param p_param, float p_value) { update_gizmo(); } float Generic6DOFJoint3D::get_param_z(Param p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return params_z[p_param]; } void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) { - ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags_x[p_flag] = p_enabled; if (get_joint().is_valid()) @@ -885,13 +818,11 @@ void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) { update_gizmo(); } bool Generic6DOFJoint3D::get_flag_x(Flag p_flag) const { - ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false); return flags_x[p_flag]; } void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) { - ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags_y[p_flag] = p_enabled; if (get_joint().is_valid()) @@ -899,13 +830,11 @@ void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) { update_gizmo(); } bool Generic6DOFJoint3D::get_flag_y(Flag p_flag) const { - ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false); return flags_y[p_flag]; } void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) { - ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags_z[p_flag] = p_enabled; if (get_joint().is_valid()) @@ -913,7 +842,6 @@ void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) { update_gizmo(); } bool Generic6DOFJoint3D::get_flag_z(Flag p_flag) const { - ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false); return flags_z[p_flag]; } @@ -927,7 +855,6 @@ void Generic6DOFJoint3D::set_precision(int p_precision) { } RID Generic6DOFJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) { - Transform gt = get_global_transform(); //Vector3 cone_twistpos = gt.origin; //Vector3 cone_twistdir = gt.basis.get_axis(2); @@ -961,7 +888,6 @@ RID Generic6DOFJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *b } Generic6DOFJoint3D::Generic6DOFJoint3D() { - set_param_x(PARAM_LINEAR_LOWER_LIMIT, 0); set_param_x(PARAM_LINEAR_UPPER_LIMIT, 0); set_param_x(PARAM_LINEAR_LIMIT_SOFTNESS, 0.7); diff --git a/scene/3d/physics_joint_3d.h b/scene/3d/physics_joint_3d.h index 38a3f314ba..a3225ab01c 100644 --- a/scene/3d/physics_joint_3d.h +++ b/scene/3d/physics_joint_3d.h @@ -35,7 +35,6 @@ #include "scene/3d/physics_body_3d.h" class Joint3D : public Node3D { - GDCLASS(Joint3D, Node3D); RID ba, bb; @@ -77,7 +76,6 @@ public: /////////////////////////////////////////// class PinJoint3D : public Joint3D { - GDCLASS(PinJoint3D, Joint3D); public: @@ -102,7 +100,6 @@ public: VARIANT_ENUM_CAST(PinJoint3D::Param); class HingeJoint3D : public Joint3D { - GDCLASS(HingeJoint3D, Joint3D); public: @@ -150,7 +147,6 @@ VARIANT_ENUM_CAST(HingeJoint3D::Param); VARIANT_ENUM_CAST(HingeJoint3D::Flag); class SliderJoint3D : public Joint3D { - GDCLASS(SliderJoint3D, Joint3D); public: @@ -203,7 +199,6 @@ public: VARIANT_ENUM_CAST(SliderJoint3D::Param); class ConeTwistJoint3D : public Joint3D { - GDCLASS(ConeTwistJoint3D, Joint3D); public: @@ -238,7 +233,6 @@ public: VARIANT_ENUM_CAST(ConeTwistJoint3D::Param); class Generic6DOFJoint3D : public Joint3D { - GDCLASS(Generic6DOFJoint3D, Joint3D); public: diff --git a/scene/3d/position_3d.h b/scene/3d/position_3d.h index 9c806723fb..1c5f05ef95 100644 --- a/scene/3d/position_3d.h +++ b/scene/3d/position_3d.h @@ -34,7 +34,6 @@ #include "scene/3d/node_3d.h" class Position3D : public Node3D { - GDCLASS(Position3D, Node3D); public: diff --git a/scene/3d/proximity_group_3d.cpp b/scene/3d/proximity_group_3d.cpp index 44ffabb655..cef3381fc1 100644 --- a/scene/3d/proximity_group_3d.cpp +++ b/scene/3d/proximity_group_3d.cpp @@ -33,7 +33,6 @@ #include "core/math/math_funcs.h" void ProximityGroup3D::clear_groups() { - Map::Element *E; { @@ -42,7 +41,6 @@ void ProximityGroup3D::clear_groups() { E = groups.front(); int num = 0; while (E && num < size) { - if (E->get() != group_version) { remove_list[num++] = E->key(); }; @@ -50,7 +48,6 @@ void ProximityGroup3D::clear_groups() { E = E->next(); }; for (int i = 0; i < num; i++) { - groups.erase(remove_list[i]); }; }; @@ -61,7 +58,6 @@ void ProximityGroup3D::clear_groups() { }; void ProximityGroup3D::update_groups() { - if (grid_radius == Vector3(0, 0, 0)) return; @@ -77,10 +73,8 @@ void ProximityGroup3D::update_groups() { }; void ProximityGroup3D::add_groups(int *p_cell, String p_base, int p_depth) { - p_base = p_base + "|"; if (grid_radius[p_depth] == 0) { - if (p_depth == 2) { _new_group(p_base); } else { @@ -92,7 +86,6 @@ void ProximityGroup3D::add_groups(int *p_cell, String p_base, int p_depth) { int end = p_cell[p_depth] + grid_radius[p_depth]; for (int i = start; i <= end; i++) { - String gname = p_base + itos(i); if (p_depth == 2) { _new_group(gname); @@ -103,7 +96,6 @@ void ProximityGroup3D::add_groups(int *p_cell, String p_base, int p_depth) { }; void ProximityGroup3D::_new_group(StringName p_name) { - const Map::Element *E = groups.find(p_name); if (!E) { add_to_group(p_name); @@ -113,9 +105,7 @@ void ProximityGroup3D::_new_group(StringName p_name) { }; void ProximityGroup3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_EXIT_TREE: ++group_version; clear_groups(); @@ -127,59 +117,47 @@ void ProximityGroup3D::_notification(int p_what) { }; void ProximityGroup3D::broadcast(String p_name, Variant p_params) { - Map::Element *E; E = groups.front(); while (E) { - get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params); E = E->next(); }; }; void ProximityGroup3D::_proximity_group_broadcast(String p_name, Variant p_params) { - if (dispatch_mode == MODE_PROXY) { - get_parent()->call(p_name, p_params); } else { - emit_signal("broadcast", p_name, p_params); }; }; void ProximityGroup3D::set_group_name(const String &p_group_name) { - group_name = p_group_name; }; String ProximityGroup3D::get_group_name() const { - return group_name; }; void ProximityGroup3D::set_dispatch_mode(DispatchMode p_mode) { - dispatch_mode = p_mode; }; ProximityGroup3D::DispatchMode ProximityGroup3D::get_dispatch_mode() const { - return dispatch_mode; }; void ProximityGroup3D::set_grid_radius(const Vector3 &p_radius) { - grid_radius = p_radius; }; Vector3 ProximityGroup3D::get_grid_radius() const { - return grid_radius; }; void ProximityGroup3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_group_name", "name"), &ProximityGroup3D::set_group_name); ClassDB::bind_method(D_METHOD("get_group_name"), &ProximityGroup3D::get_group_name); ClassDB::bind_method(D_METHOD("set_dispatch_mode", "mode"), &ProximityGroup3D::set_dispatch_mode); @@ -200,7 +178,6 @@ void ProximityGroup3D::_bind_methods() { }; ProximityGroup3D::ProximityGroup3D() { - group_version = 0; dispatch_mode = MODE_PROXY; diff --git a/scene/3d/proximity_group_3d.h b/scene/3d/proximity_group_3d.h index 751bfbdb52..780c65e92b 100644 --- a/scene/3d/proximity_group_3d.h +++ b/scene/3d/proximity_group_3d.h @@ -34,7 +34,6 @@ #include "node_3d.h" class ProximityGroup3D : public Node3D { - GDCLASS(ProximityGroup3D, Node3D); OBJ_CATEGORY("3D"); diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index 304a5e1254..7693906f6f 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -36,7 +36,6 @@ #include "servers/physics_server_3d.h" void RayCast3D::set_cast_to(const Vector3 &p_point) { - cast_to = p_point; if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) update_gizmo(); @@ -45,22 +44,18 @@ void RayCast3D::set_cast_to(const Vector3 &p_point) { } Vector3 RayCast3D::get_cast_to() const { - return cast_to; } void RayCast3D::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; } uint32_t RayCast3D::get_collision_mask() const { - return collision_mask; } void RayCast3D::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -70,16 +65,13 @@ void RayCast3D::set_collision_mask_bit(int p_bit, bool p_value) { } bool RayCast3D::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } bool RayCast3D::is_colliding() const { - return collided; } Object *RayCast3D::get_collider() const { - if (against.is_null()) return nullptr; @@ -87,20 +79,16 @@ Object *RayCast3D::get_collider() const { } int RayCast3D::get_collider_shape() const { - return against_shape; } Vector3 RayCast3D::get_collision_point() const { - return collision_point; } Vector3 RayCast3D::get_collision_normal() const { - return collision_normal; } void RayCast3D::set_enabled(bool p_enabled) { - enabled = p_enabled; update_gizmo(); @@ -118,12 +106,10 @@ void RayCast3D::set_enabled(bool p_enabled) { } bool RayCast3D::is_enabled() const { - return enabled; } void RayCast3D::set_exclude_parent_body(bool p_exclude_parent_body) { - if (exclude_parent_body == p_exclude_parent_body) return; @@ -141,16 +127,12 @@ void RayCast3D::set_exclude_parent_body(bool p_exclude_parent_body) { } bool RayCast3D::get_exclude_parent_body() const { - return exclude_parent_body; } void RayCast3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - if (enabled && !Engine::get_singleton()->is_editor_hint()) { set_physics_process_internal(true); @@ -168,7 +150,6 @@ void RayCast3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - if (enabled) { set_physics_process_internal(false); } @@ -178,7 +159,6 @@ void RayCast3D::_notification(int p_what) { } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - if (!enabled) break; @@ -211,7 +191,6 @@ void RayCast3D::_update_raycast_state() { PhysicsDirectSpaceState3D::RayResult rr; if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) { - collided = true; against = rr.collider_id; collision_point = rr.position; @@ -229,12 +208,10 @@ void RayCast3D::force_raycast_update() { } void RayCast3D::add_exception_rid(const RID &p_rid) { - exclude.insert(p_rid); } void RayCast3D::add_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); const CollisionObject3D *co = Object::cast_to(p_object); if (!co) @@ -243,12 +220,10 @@ void RayCast3D::add_exception(const Object *p_object) { } void RayCast3D::remove_exception_rid(const RID &p_rid) { - exclude.erase(p_rid); } void RayCast3D::remove_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); const CollisionObject3D *co = Object::cast_to(p_object); if (!co) @@ -257,32 +232,26 @@ void RayCast3D::remove_exception(const Object *p_object) { } void RayCast3D::clear_exceptions() { - exclude.clear(); } void RayCast3D::set_collide_with_areas(bool p_clip) { - collide_with_areas = p_clip; } bool RayCast3D::is_collide_with_areas_enabled() const { - return collide_with_areas; } void RayCast3D::set_collide_with_bodies(bool p_clip) { - collide_with_bodies = p_clip; } bool RayCast3D::is_collide_with_bodies_enabled() const { - return collide_with_bodies; } void RayCast3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &RayCast3D::set_enabled); ClassDB::bind_method(D_METHOD("is_enabled"), &RayCast3D::is_enabled); @@ -331,7 +300,6 @@ void RayCast3D::_bind_methods() { } void RayCast3D::_create_debug_shape() { - if (!debug_material.is_valid()) { debug_material = Ref(memnew(StandardMaterial3D)); @@ -350,7 +318,6 @@ void RayCast3D::_create_debug_shape() { } void RayCast3D::_update_debug_shape() { - if (!enabled) return; @@ -377,7 +344,6 @@ void RayCast3D::_update_debug_shape() { } void RayCast3D::_clear_debug_shape() { - if (!debug_shape) return; @@ -391,7 +357,6 @@ void RayCast3D::_clear_debug_shape() { } RayCast3D::RayCast3D() { - enabled = false; collided = false; diff --git a/scene/3d/ray_cast_3d.h b/scene/3d/ray_cast_3d.h index f8bfb7846a..8f617e5491 100644 --- a/scene/3d/ray_cast_3d.h +++ b/scene/3d/ray_cast_3d.h @@ -34,7 +34,6 @@ #include "scene/3d/node_3d.h" class RayCast3D : public Node3D { - GDCLASS(RayCast3D, Node3D); bool enabled; diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index 24bf8b43d1..2cc7913d1c 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -31,18 +31,15 @@ #include "reflection_probe.h" void ReflectionProbe::set_intensity(float p_intensity) { - intensity = p_intensity; RS::get_singleton()->reflection_probe_set_intensity(probe, p_intensity); } float ReflectionProbe::get_intensity() const { - return intensity; } void ReflectionProbe::set_interior_ambient(Color p_ambient) { - interior_ambient = p_ambient; RS::get_singleton()->reflection_probe_set_interior_ambient(probe, p_ambient); } @@ -57,33 +54,27 @@ float ReflectionProbe::get_interior_ambient_energy() const { } Color ReflectionProbe::get_interior_ambient() const { - return interior_ambient; } void ReflectionProbe::set_interior_ambient_probe_contribution(float p_contribution) { - interior_ambient_probe_contribution = p_contribution; RS::get_singleton()->reflection_probe_set_interior_ambient_probe_contribution(probe, p_contribution); } float ReflectionProbe::get_interior_ambient_probe_contribution() const { - return interior_ambient_probe_contribution; } void ReflectionProbe::set_max_distance(float p_distance) { - max_distance = p_distance; RS::get_singleton()->reflection_probe_set_max_distance(probe, p_distance); } float ReflectionProbe::get_max_distance() const { - return max_distance; } void ReflectionProbe::set_extents(const Vector3 &p_extents) { - extents = p_extents; for (int i = 0; i < 3; i++) { @@ -103,16 +94,13 @@ void ReflectionProbe::set_extents(const Vector3 &p_extents) { update_gizmo(); } Vector3 ReflectionProbe::get_extents() const { - return extents; } void ReflectionProbe::set_origin_offset(const Vector3 &p_extents) { - origin_offset = p_extents; for (int i = 0; i < 3; i++) { - if (extents[i] - 0.01 < ABS(origin_offset[i])) { origin_offset[i] = SGN(origin_offset[i]) * (extents[i] - 0.01); } @@ -124,49 +112,40 @@ void ReflectionProbe::set_origin_offset(const Vector3 &p_extents) { update_gizmo(); } Vector3 ReflectionProbe::get_origin_offset() const { - return origin_offset; } void ReflectionProbe::set_enable_box_projection(bool p_enable) { - box_projection = p_enable; RS::get_singleton()->reflection_probe_set_enable_box_projection(probe, p_enable); } bool ReflectionProbe::is_box_projection_enabled() const { - return box_projection; } void ReflectionProbe::set_as_interior(bool p_enable) { - interior = p_enable; RS::get_singleton()->reflection_probe_set_as_interior(probe, interior); _change_notify(); } bool ReflectionProbe::is_set_as_interior() const { - return interior; } void ReflectionProbe::set_enable_shadows(bool p_enable) { - enable_shadows = p_enable; RS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_enable); } bool ReflectionProbe::are_shadows_enabled() const { - return enable_shadows; } void ReflectionProbe::set_cull_mask(uint32_t p_layers) { - cull_mask = p_layers; RS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers); } uint32_t ReflectionProbe::get_cull_mask() const { - return cull_mask; } @@ -180,19 +159,16 @@ ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const { } AABB ReflectionProbe::get_aabb() const { - AABB aabb; aabb.position = -origin_offset; aabb.size = origin_offset + extents; return aabb; } Vector ReflectionProbe::get_faces(uint32_t p_usage_flags) const { - return Vector(); } void ReflectionProbe::_validate_property(PropertyInfo &property) const { - if (property.name == "interior/ambient_color" || property.name == "interior/ambient_energy" || property.name == "interior/ambient_contrib") { if (!interior) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; @@ -201,7 +177,6 @@ void ReflectionProbe::_validate_property(PropertyInfo &property) const { } void ReflectionProbe::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_intensity", "intensity"), &ReflectionProbe::set_intensity); ClassDB::bind_method(D_METHOD("get_intensity"), &ReflectionProbe::get_intensity); @@ -258,7 +233,6 @@ void ReflectionProbe::_bind_methods() { } ReflectionProbe::ReflectionProbe() { - intensity = 1.0; interior_ambient = Color(0, 0, 0); interior_ambient_probe_contribution = 0; @@ -278,6 +252,5 @@ ReflectionProbe::ReflectionProbe() { } ReflectionProbe::~ReflectionProbe() { - RS::get_singleton()->free(probe); } diff --git a/scene/3d/remote_transform_3d.cpp b/scene/3d/remote_transform_3d.cpp index 38792bbb58..7872a8ee1c 100644 --- a/scene/3d/remote_transform_3d.cpp +++ b/scene/3d/remote_transform_3d.cpp @@ -43,7 +43,6 @@ void RemoteTransform3D::_update_cache() { } void RemoteTransform3D::_update_remote() { - if (!is_inside_tree()) return; @@ -59,7 +58,6 @@ void RemoteTransform3D::_update_remote() { //todo make faster if (use_global_coordinates) { - if (update_remote_position && update_remote_rotation && update_remote_scale) { n->set_global_transform(get_global_transform()); } else { @@ -102,11 +100,8 @@ void RemoteTransform3D::_update_remote() { } void RemoteTransform3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - _update_cache(); } break; @@ -115,7 +110,6 @@ void RemoteTransform3D::_notification(int p_what) { break; if (cache.is_valid()) { - _update_remote(); } @@ -124,7 +118,6 @@ void RemoteTransform3D::_notification(int p_what) { } void RemoteTransform3D::set_remote_node(const NodePath &p_remote_node) { - remote_node = p_remote_node; if (is_inside_tree()) { _update_cache(); @@ -135,7 +128,6 @@ void RemoteTransform3D::set_remote_node(const NodePath &p_remote_node) { } NodePath RemoteTransform3D::get_remote_node() const { - return remote_node; } @@ -179,7 +171,6 @@ void RemoteTransform3D::force_update_cache() { } String RemoteTransform3D::get_configuration_warning() const { - if (!has_node(remote_node) || !Object::cast_to(get_node(remote_node))) { return TTR("The \"Remote Path\" property must point to a valid Node3D or Node3D-derived node to work."); } @@ -188,7 +179,6 @@ String RemoteTransform3D::get_configuration_warning() const { } void RemoteTransform3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_remote_node", "path"), &RemoteTransform3D::set_remote_node); ClassDB::bind_method(D_METHOD("get_remote_node"), &RemoteTransform3D::get_remote_node); ClassDB::bind_method(D_METHOD("force_update_cache"), &RemoteTransform3D::force_update_cache); @@ -213,7 +203,6 @@ void RemoteTransform3D::_bind_methods() { } RemoteTransform3D::RemoteTransform3D() { - use_global_coordinates = true; update_remote_position = true; update_remote_rotation = true; diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index 973822653a..c834dad2d0 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -67,7 +67,6 @@ SkinReference::~SkinReference() { } bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) { - String path = p_path; if (!path.begins_with("bones/")) @@ -77,7 +76,6 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) { String what = path.get_slicec('/', 2); if (which == bones.size() && what == "name") { - add_bone(p_value); return true; } @@ -99,7 +97,6 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) { bones.write[which].nodes_bound.clear(); for (int i = 0; i < children.size(); i++) { - NodePath npath = children[i]; ERR_CONTINUE(npath.operator String() == ""); Node *node = get_node(npath); @@ -115,7 +112,6 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) { } bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const { - String path = p_path; if (!path.begins_with("bones/")) @@ -140,7 +136,6 @@ bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const { Array children; for (const List::Element *E = bones[which].nodes_bound.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); ERR_CONTINUE(!obj); Node *node = Object::cast_to(obj); @@ -156,9 +151,7 @@ bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const { return true; } void Skeleton3D::_get_property_list(List *p_list) const { - for (int i = 0; i < bones.size(); i++) { - String prep = "bones/" + itos(i) + "/"; p_list->push_back(PropertyInfo(Variant::STRING, prep + "name")); p_list->push_back(PropertyInfo(Variant::INT, prep + "parent", PROPERTY_HINT_RANGE, "-1," + itos(bones.size() - 1) + ",1")); @@ -170,7 +163,6 @@ void Skeleton3D::_get_property_list(List *p_list) const { } void Skeleton3D::_update_process_order() { - if (!process_order_dirty) return; @@ -180,7 +172,6 @@ void Skeleton3D::_update_process_order() { process_order.resize(len); int *order = process_order.ptrw(); for (int i = 0; i < len; i++) { - if (bonesptr[i].parent >= len) { //validate this just in case ERR_PRINT("Bone " + itos(i) + " has invalid parent: " + itos(bonesptr[i].parent)); @@ -223,11 +214,8 @@ void Skeleton3D::_update_process_order() { } void Skeleton3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_UPDATE_SKELETON: { - RenderingServer *vs = RenderingServer::get_singleton(); Bone *bonesptr = bones.ptrw(); int len = bones.size(); @@ -237,7 +225,6 @@ void Skeleton3D::_notification(int p_what) { const int *order = process_order.ptr(); for (int i = 0; i < len; i++) { - Bone &b = bonesptr[order[i]]; if (b.global_pose_override_amount >= 0.999) { @@ -245,50 +232,38 @@ void Skeleton3D::_notification(int p_what) { } else { if (b.disable_rest) { if (b.enabled) { - Transform pose = b.pose; if (b.custom_pose_enable) { pose = b.custom_pose * pose; } if (b.parent >= 0) { - b.pose_global = bonesptr[b.parent].pose_global * pose; } else { - b.pose_global = pose; } } else { - if (b.parent >= 0) { - b.pose_global = bonesptr[b.parent].pose_global; } else { - b.pose_global = Transform(); } } } else { if (b.enabled) { - Transform pose = b.pose; if (b.custom_pose_enable) { pose = b.custom_pose * pose; } if (b.parent >= 0) { - b.pose_global = bonesptr[b.parent].pose_global * (b.rest * pose); } else { - b.pose_global = b.rest * pose; } } else { - if (b.parent >= 0) { - b.pose_global = bonesptr[b.parent].pose_global * b.rest; } else { - b.pose_global = b.rest; } } @@ -304,7 +279,6 @@ void Skeleton3D::_notification(int p_what) { } for (List::Element *E = b.nodes_bound.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); ERR_CONTINUE(!obj); Node3D *sp = Object::cast_to(obj); @@ -315,7 +289,6 @@ void Skeleton3D::_notification(int p_what) { //update skins for (Set::Element *E = skin_bindings.front(); E; E = E->next()) { - const Skin *skin = E->get()->skin.operator->(); RID skeleton = E->get()->skeleton; uint32_t bind_count = skin->get_bind_count(); @@ -328,7 +301,6 @@ void Skeleton3D::_notification(int p_what) { } if (E->get()->skeleton_version != version) { - for (uint32_t i = 0; i < bind_count; i++) { StringName bind_name = skin->get_bind_name(i); @@ -405,7 +377,6 @@ void Skeleton3D::clear_bones_global_pose_override() { } void Skeleton3D::set_bone_global_pose_override(int p_bone, const Transform &p_pose, float p_amount, bool p_persistent) { - ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].global_pose_override_amount = p_amount; bones.write[p_bone].global_pose_override = p_pose; @@ -414,7 +385,6 @@ void Skeleton3D::set_bone_global_pose_override(int p_bone, const Transform &p_po } Transform Skeleton3D::get_bone_global_pose(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); if (dirty) const_cast(this)->notification(NOTIFICATION_UPDATE_SKELETON); @@ -423,11 +393,9 @@ Transform Skeleton3D::get_bone_global_pose(int p_bone) const { // skeleton creation api void Skeleton3D::add_bone(const String &p_name) { - ERR_FAIL_COND(p_name == "" || p_name.find(":") != -1 || p_name.find("/") != -1); for (int i = 0; i < bones.size(); i++) { - ERR_FAIL_COND(bones[i].name == p_name); } @@ -440,9 +408,7 @@ void Skeleton3D::add_bone(const String &p_name) { update_gizmo(); } int Skeleton3D::find_bone(const String &p_name) const { - for (int i = 0; i < bones.size(); i++) { - if (bones[i].name == p_name) return i; } @@ -450,14 +416,12 @@ int Skeleton3D::find_bone(const String &p_name) const { return -1; } String Skeleton3D::get_bone_name(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), ""); return bones[p_bone].name; } bool Skeleton3D::is_bone_parent_of(int p_bone, int p_parent_bone_id) const { - int parent_of_bone = get_bone_parent(p_bone); if (-1 == parent_of_bone) @@ -470,12 +434,10 @@ bool Skeleton3D::is_bone_parent_of(int p_bone, int p_parent_bone_id) const { } int Skeleton3D::get_bone_count() const { - return bones.size(); } void Skeleton3D::set_bone_parent(int p_bone, int p_parent) { - ERR_FAIL_INDEX(p_bone, bones.size()); ERR_FAIL_COND(p_parent != -1 && (p_parent < 0)); @@ -485,7 +447,6 @@ void Skeleton3D::set_bone_parent(int p_bone, int p_parent) { } void Skeleton3D::unparent_bone_and_rest(int p_bone) { - ERR_FAIL_INDEX(p_bone, bones.size()); _update_process_order(); @@ -503,60 +464,51 @@ void Skeleton3D::unparent_bone_and_rest(int p_bone) { } void Skeleton3D::set_bone_disable_rest(int p_bone, bool p_disable) { - ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].disable_rest = p_disable; } bool Skeleton3D::is_bone_rest_disabled(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), false); return bones[p_bone].disable_rest; } int Skeleton3D::get_bone_parent(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), -1); return bones[p_bone].parent; } void Skeleton3D::set_bone_rest(int p_bone, const Transform &p_rest) { - ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].rest = p_rest; _make_dirty(); } Transform Skeleton3D::get_bone_rest(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); return bones[p_bone].rest; } void Skeleton3D::set_bone_enabled(int p_bone, bool p_enabled) { - ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].enabled = p_enabled; _make_dirty(); } bool Skeleton3D::is_bone_enabled(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), false); return bones[p_bone].enabled; } void Skeleton3D::bind_child_node_to_bone(int p_bone, Node *p_node) { - ERR_FAIL_NULL(p_node); ERR_FAIL_INDEX(p_bone, bones.size()); ObjectID id = p_node->get_instance_id(); for (const List::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) { - if (E->get() == id) return; // already here } @@ -564,7 +516,6 @@ void Skeleton3D::bind_child_node_to_bone(int p_bone, Node *p_node) { bones.write[p_bone].nodes_bound.push_back(id); } void Skeleton3D::unbind_child_node_from_bone(int p_bone, Node *p_node) { - ERR_FAIL_NULL(p_node); ERR_FAIL_INDEX(p_bone, bones.size()); @@ -572,11 +523,9 @@ void Skeleton3D::unbind_child_node_from_bone(int p_bone, Node *p_node) { bones.write[p_bone].nodes_bound.erase(id); } void Skeleton3D::get_bound_child_nodes_to_bone(int p_bone, List *p_bound) const { - ERR_FAIL_INDEX(p_bone, bones.size()); for (const List::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); ERR_CONTINUE(!obj); p_bound->push_back(Object::cast_to(obj)); @@ -584,7 +533,6 @@ void Skeleton3D::get_bound_child_nodes_to_bone(int p_bone, List *p_bound } void Skeleton3D::clear_bones() { - bones.clear(); process_order_dirty = true; version++; @@ -594,7 +542,6 @@ void Skeleton3D::clear_bones() { // posing api void Skeleton3D::set_bone_pose(int p_bone, const Transform &p_pose) { - ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].pose = p_pose; @@ -603,13 +550,11 @@ void Skeleton3D::set_bone_pose(int p_bone, const Transform &p_pose) { } } Transform Skeleton3D::get_bone_pose(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); return bones[p_bone].pose; } void Skeleton3D::set_bone_custom_pose(int p_bone, const Transform &p_custom_pose) { - ERR_FAIL_INDEX(p_bone, bones.size()); //ERR_FAIL_COND( !is_inside_scene() ); @@ -620,13 +565,11 @@ void Skeleton3D::set_bone_custom_pose(int p_bone, const Transform &p_custom_pose } Transform Skeleton3D::get_bone_custom_pose(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); return bones[p_bone].custom_pose; } void Skeleton3D::_make_dirty() { - if (dirty) return; @@ -641,7 +584,6 @@ int Skeleton3D::get_process_order(int p_idx) { } void Skeleton3D::localize_rests() { - _update_process_order(); for (int i = bones.size() - 1; i >= 0; i--) { @@ -736,7 +678,6 @@ void Skeleton3D::_rebuild_physical_bones_cache() { } void _pb_stop_simulation(Node *p_node) { - for (int i = p_node->get_child_count() - 1; 0 <= i; --i) { _pb_stop_simulation(p_node->get_child(i)); } @@ -755,7 +696,6 @@ void Skeleton3D::physical_bones_stop_simulation() { } void _pb_start_simulation(const Skeleton3D *p_skeleton, Node *p_node, const Vector &p_sim_bones) { - for (int i = p_node->get_child_count() - 1; 0 <= i; --i) { _pb_start_simulation(p_skeleton, p_node->get_child(i), p_sim_bones); } @@ -792,7 +732,6 @@ void Skeleton3D::physical_bones_start_simulation_on(const TypedArray } void _physical_bones_add_remove_collision_exception(bool p_add, Node *p_node, RID p_exception) { - for (int i = p_node->get_child_count() - 1; 0 <= i; --i) { _physical_bones_add_remove_collision_exception(p_add, p_node->get_child(i), p_exception); } @@ -822,7 +761,6 @@ void Skeleton3D::_skin_changed() { } Ref Skeleton3D::register_skin(const Ref &p_skin) { - for (Set::Element *E = skin_bindings.front(); E; E = E->next()) { if (E->get()->skin == p_skin) { return Ref(E->get()); @@ -883,7 +821,6 @@ Ref Skeleton3D::register_skin(const Ref &p_skin) { } void Skeleton3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_bone", "name"), &Skeleton3D::add_bone); ClassDB::bind_method(D_METHOD("find_bone", "name"), &Skeleton3D::find_bone); ClassDB::bind_method(D_METHOD("get_bone_name", "bone_idx"), &Skeleton3D::get_bone_name); @@ -938,7 +875,6 @@ void Skeleton3D::_bind_methods() { } Skeleton3D::Skeleton3D() { - animate_physical_bones = true; dirty = false; version = 1; @@ -946,7 +882,6 @@ Skeleton3D::Skeleton3D() { } Skeleton3D::~Skeleton3D() { - //some skins may remain bound for (Set::Element *E = skin_bindings.front(); E; E = E->next()) { E->get()->skeleton_node = nullptr; diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h index 0bccd3f8fc..1e864c1c48 100644 --- a/scene/3d/skeleton_3d.h +++ b/scene/3d/skeleton_3d.h @@ -66,7 +66,6 @@ public: }; class Skeleton3D : public Node3D { - GDCLASS(Skeleton3D, Node3D); private: @@ -77,7 +76,6 @@ private: void _skin_changed(); struct Bone { - String name; bool enabled; @@ -130,13 +128,11 @@ private: // bind helpers Array _get_bound_child_nodes_to_bone(int p_bone) const { - Array bound; List children; get_bound_child_nodes_to_bone(p_bone, &children); for (int i = 0; i < children.size(); i++) { - bound.push_back(children[i]); } return bound; diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp index 5c0e48a5df..40c91fca69 100644 --- a/scene/3d/skeleton_ik_3d.cpp +++ b/scene/3d/skeleton_ik_3d.cpp @@ -55,7 +55,6 @@ FabrikInverseKinematic::ChainItem *FabrikInverseKinematic::ChainItem::add_child( /// Build a chain that starts from the root to tip bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain) { - ERR_FAIL_COND_V(-1 == p_task->root_bone, false); Chain &chain(p_task->chain); @@ -75,7 +74,6 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain chain_ids.resize(p_task->skeleton->get_bone_count()); for (int x = p_task->end_effectors.size() - 1; 0 <= x; --x) { - const EndEffector *ee(&p_task->end_effectors[x]); ERR_FAIL_COND_V(p_task->root_bone >= ee->tip_bone, false); ERR_FAIL_INDEX_V(ee->tip_bone, p_task->skeleton->get_bone_count(), false); @@ -84,7 +82,6 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain // Picks all IDs that composing a single chain in reverse order (except the root) BoneId chain_sub_tip(ee->tip_bone); while (chain_sub_tip > p_task->root_bone) { - chain_ids.write[sub_chain_size++] = chain_sub_tip; chain_sub_tip = p_task->skeleton->get_bone_parent(chain_sub_tip); } @@ -95,10 +92,8 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain // For each chain item id will be created a ChainItem if doesn't exists ChainItem *sub_chain(&chain.chain_root); for (int i = sub_chain_size - 1; 0 <= i; --i) { - ChainItem *child_ci(sub_chain->find_child(chain_ids[i])); if (!child_ci) { - child_ci = sub_chain->add_child(chain_ids[i]); child_ci->pb = p_task->skeleton->get_physical_bone(child_ci->bone); @@ -137,7 +132,6 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain } void FabrikInverseKinematic::update_chain(const Skeleton3D *p_sk, ChainItem *p_chain_item) { - if (!p_chain_item) return; @@ -151,7 +145,6 @@ void FabrikInverseKinematic::update_chain(const Skeleton3D *p_sk, ChainItem *p_c } void FabrikInverseKinematic::solve_simple(Task *p_task, bool p_solve_magnet) { - real_t distance_to_goal(1e4); real_t previous_distance_to_goal(0); int can_solve(p_task->max_iterations); @@ -167,7 +160,6 @@ void FabrikInverseKinematic::solve_simple(Task *p_task, bool p_solve_magnet) { } void FabrikInverseKinematic::solve_simple_backwards(Chain &r_chain, bool p_solve_magnet) { - if (p_solve_magnet && !r_chain.middle_chain_item) { return; } @@ -200,7 +192,6 @@ void FabrikInverseKinematic::solve_simple_backwards(Chain &r_chain, bool p_solve } void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_magnet) { - if (p_solve_magnet && !r_chain.middle_chain_item) { return; } @@ -212,7 +203,6 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_ sub_chain_root->current_pos = origin; if (!sub_chain_root->children.empty()) { - ChainItem &child(sub_chain_root->children.write[0]); // Is not tip @@ -231,7 +221,6 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_ sub_chain_root = &child; } } else { - // Is tip sub_chain_root = nullptr; } @@ -239,7 +228,6 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_ } FabrikInverseKinematic::Task *FabrikInverseKinematic::create_simple_task(Skeleton3D *p_sk, BoneId root_bone, BoneId tip_bone, const Transform &goal_transform) { - FabrikInverseKinematic::EndEffector ee; ee.tip_bone = tip_bone; @@ -267,12 +255,10 @@ void FabrikInverseKinematic::set_goal(Task *p_task, const Transform &p_goal) { } void FabrikInverseKinematic::make_goal(Task *p_task, const Transform &p_inverse_transf, real_t blending_delta) { - if (blending_delta >= 0.99f) { // Update the end_effector (local transform) without blending p_task->end_effectors.write[0].goal_transform = p_inverse_transf * p_task->goal_global_transform; } else { - // End effector in local transform const Transform end_effector_pose(p_task->skeleton->get_bone_global_pose(p_task->end_effectors.write[0].tip_bone)); @@ -282,7 +268,6 @@ void FabrikInverseKinematic::make_goal(Task *p_task, const Transform &p_inverse_ } void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool override_tip_basis, bool p_use_magnet, const Vector3 &p_magnet_position) { - if (blending_delta <= 0.01f) { return; // Skip solving } @@ -314,7 +299,6 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove new_bone_pose.origin = ci->current_pos; if (!ci->children.empty()) { - /// Rotate basis const Vector3 initial_ori((ci->children[0].initial_transform.origin - ci->initial_transform.origin).normalized()); const Vector3 rot_axis(initial_ori.cross(ci->current_ori).normalized()); @@ -341,11 +325,8 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove } void SkeletonIK3D::_validate_property(PropertyInfo &property) const { - if (property.name == "root_bone" || property.name == "tip_bone") { - if (skeleton) { - String names("--,"); for (int i = 0; i < skeleton->get_bone_count(); i++) { if (i > 0) @@ -356,7 +337,6 @@ void SkeletonIK3D::_validate_property(PropertyInfo &property) const { property.hint = PROPERTY_HINT_ENUM; property.hint_string = names; } else { - property.hint = PROPERTY_HINT_NONE; property.hint_string = ""; } @@ -364,7 +344,6 @@ void SkeletonIK3D::_validate_property(PropertyInfo &property) const { } void SkeletonIK3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_root_bone", "root_bone"), &SkeletonIK3D::set_root_bone); ClassDB::bind_method(D_METHOD("get_root_bone"), &SkeletonIK3D::get_root_bone); @@ -421,7 +400,6 @@ void SkeletonIK3D::_notification(int p_what) { reload_chain(); } break; case NOTIFICATION_INTERNAL_PROCESS: { - if (target_node_override) reload_goal(); @@ -537,7 +515,6 @@ void SkeletonIK3D::stop() { } Transform SkeletonIK3D::_get_target_transform() { - if (!target_node_override && !target_node_path_override.is_empty()) target_node_override = Object::cast_to(get_node(target_node_path_override)); @@ -548,7 +525,6 @@ Transform SkeletonIK3D::_get_target_transform() { } void SkeletonIK3D::reload_chain() { - FabrikInverseKinematic::free_task(task); task = nullptr; diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h index ad2623193b..0d948f13a9 100644 --- a/scene/3d/skeleton_ik_3d.h +++ b/scene/3d/skeleton_ik_3d.h @@ -41,14 +41,12 @@ #include "scene/3d/skeleton_3d.h" class FabrikInverseKinematic { - struct EndEffector { BoneId tip_bone; Transform goal_transform; }; struct ChainItem { - Vector children; ChainItem *parent_item = nullptr; diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 91b8b5c859..ea89f07266 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -65,7 +65,6 @@ void SoftBodyRenderingServerHandler::prepare(RID p_mesh, int p_surface) { } void SoftBodyRenderingServerHandler::clear() { - if (mesh.is_valid()) { buffer.resize(0); } @@ -127,11 +126,9 @@ bool SoftBody3D::_set(const StringName &p_name, const Variant &p_value) { String which = name.get_slicec('/', 0); if ("pinned_points" == which) { - return _set_property_pinned_points_indices(p_value); } else if ("attachments" == which) { - int idx = name.get_slicec('/', 1).to_int(); String what = name.get_slicec('/', 2); @@ -159,7 +156,6 @@ bool SoftBody3D::_get(const StringName &p_name, Variant &r_ret) const { return true; } else if ("attachments" == which) { - int idx = name.get_slicec('/', 1).to_int(); String what = name.get_slicec('/', 2); @@ -170,7 +166,6 @@ bool SoftBody3D::_get(const StringName &p_name, Variant &r_ret) const { } void SoftBody3D::_get_property_list(List *p_list) const { - const int pinned_points_indices_size = pinned_points.size(); p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "pinned_points")); @@ -183,7 +178,6 @@ void SoftBody3D::_get_property_list(List *p_list) const { } bool SoftBody3D::_set_property_pinned_points_indices(const Array &p_indices) { - const int p_indices_size = p_indices.size(); { // Remove the pined points on physics server that will be removed by resize @@ -262,9 +256,7 @@ void SoftBody3D::_changed_callback(Object *p_changed, const char *p_prop) { void SoftBody3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { - if (Engine::get_singleton()->is_editor_hint()) { - add_change_receptor(this); } @@ -278,7 +270,6 @@ void SoftBody3D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - if (Engine::get_singleton()->is_editor_hint()) { _reset_points_offsets(); return; @@ -294,12 +285,10 @@ void SoftBody3D::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { - _update_pickable(); } break; case NOTIFICATION_EXIT_WORLD: { - PhysicsServer3D::get_singleton()->soft_body_set_space(physics_rid, RID()); } break; @@ -317,7 +306,6 @@ void SoftBody3D::_notification(int p_what) { } void SoftBody3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &SoftBody3D::set_collision_mask); ClassDB::bind_method(D_METHOD("get_collision_mask"), &SoftBody3D::get_collision_mask); @@ -386,7 +374,6 @@ void SoftBody3D::_bind_methods() { } String SoftBody3D::get_configuration_warning() const { - String warning = MeshInstance3D::get_configuration_warning(); if (get_mesh().is_null()) { @@ -427,7 +414,6 @@ void SoftBody3D::_draw_soft_mesh() { return; if (!rendering_server_handler.is_ready()) { - rendering_server_handler.prepare(get_mesh()->get_rid(), 0); /// Necessary in order to render the mesh correctly (Soft body nodes are in global space) @@ -446,9 +432,7 @@ void SoftBody3D::_draw_soft_mesh() { } void SoftBody3D::prepare_physics_server() { - if (Engine::get_singleton()->is_editor_hint()) { - if (get_mesh().is_valid()) PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh()); else @@ -458,12 +442,10 @@ void SoftBody3D::prepare_physics_server() { } if (get_mesh().is_valid()) { - become_mesh_owner(); PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh()); RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh)); } else { - PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, nullptr); if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh))) { RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh)); @@ -689,19 +671,16 @@ bool SoftBody3D::is_point_pinned(int p_point_index) const { } void SoftBody3D::set_ray_pickable(bool p_ray_pickable) { - ray_pickable = p_ray_pickable; _update_pickable(); } bool SoftBody3D::is_ray_pickable() const { - return ray_pickable; } SoftBody3D::SoftBody3D() : physics_rid(PhysicsServer3D::get_singleton()->soft_body_create()) { - PhysicsServer3D::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id()); } @@ -729,7 +708,6 @@ void SoftBody3D::_update_cache_pin_points_datas() { PinnedPoint *w = pinned_points.ptrw(); for (int i = pinned_points.size() - 1; 0 <= i; --i) { - if (!w[i].spatial_attachment_path.is_empty()) { w[i].spatial_attachment = Object::cast_to(get_node(w[i].spatial_attachment_path)); } @@ -746,7 +724,6 @@ void SoftBody3D::_pin_point_on_physics_server(int p_point_index, bool pin) { void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path) { SoftBody3D::PinnedPoint *pinned_point; if (-1 == _get_pinned_point(p_point_index, pinned_point)) { - // Create new PinnedPoint pp; pp.point_index = p_point_index; @@ -760,7 +737,6 @@ void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_ pinned_points.push_back(pp); } else { - pinned_point->point_index = p_point_index; pinned_point->spatial_attachment_path = p_spatial_attachment_path; @@ -772,14 +748,12 @@ void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_ } void SoftBody3D::_reset_points_offsets() { - if (!Engine::get_singleton()->is_editor_hint()) return; const PinnedPoint *r = pinned_points.ptr(); PinnedPoint *w = pinned_points.ptrw(); for (int i = pinned_points.size() - 1; 0 <= i; --i) { - if (!r[i].spatial_attachment) w[i].spatial_attachment = Object::cast_to(get_node(r[i].spatial_attachment_path)); diff --git a/scene/3d/soft_body_3d.h b/scene/3d/soft_body_3d.h index 485f7427f8..0063e342f2 100644 --- a/scene/3d/soft_body_3d.h +++ b/scene/3d/soft_body_3d.h @@ -36,7 +36,6 @@ class SoftBody3D; class SoftBodyRenderingServerHandler { - friend class SoftBody3D; RID mesh; diff --git a/scene/3d/spring_arm_3d.cpp b/scene/3d/spring_arm_3d.cpp index f61e6eb2a7..3f94645bae 100644 --- a/scene/3d/spring_arm_3d.cpp +++ b/scene/3d/spring_arm_3d.cpp @@ -54,7 +54,6 @@ void SpringArm3D::_notification(int p_what) { } void SpringArm3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_hit_length"), &SpringArm3D::get_hit_length); ClassDB::bind_method(D_METHOD("set_length", "length"), &SpringArm3D::set_length); @@ -157,7 +156,6 @@ void SpringArm3D::process_spring() { childs_transform.origin = get_global_transform().origin + cast_direction * (spring_length * motion_delta); for (int i = get_child_count() - 1; 0 <= i; --i) { - Node3D *child = Object::cast_to(get_child(i)); if (child) { childs_transform.basis = child->get_global_transform().basis; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 85e5ebc475..9764bf77c5 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -34,7 +34,6 @@ #include "scene/scene_string_names.h" Color SpriteBase3D::_get_color_accum() { - if (!color_dirty) return color_accum; @@ -52,7 +51,6 @@ Color SpriteBase3D::_get_color_accum() { } void SpriteBase3D::_propagate_color_changed() { - if (color_dirty) return; @@ -60,15 +58,12 @@ void SpriteBase3D::_propagate_color_changed() { _queue_update(); for (List::Element *E = children.front(); E; E = E->next()) { - E->get()->_propagate_color_changed(); } } void SpriteBase3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - if (!pending_update) _im_update(); @@ -79,9 +74,7 @@ void SpriteBase3D::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE) { - if (parent_sprite) { - parent_sprite->children.erase(pI); pI = nullptr; parent_sprite = nullptr; @@ -90,98 +83,80 @@ void SpriteBase3D::_notification(int p_what) { } void SpriteBase3D::set_centered(bool p_center) { - centered = p_center; _queue_update(); } bool SpriteBase3D::is_centered() const { - return centered; } void SpriteBase3D::set_offset(const Point2 &p_offset) { - offset = p_offset; _queue_update(); } Point2 SpriteBase3D::get_offset() const { - return offset; } void SpriteBase3D::set_flip_h(bool p_flip) { - hflip = p_flip; _queue_update(); } bool SpriteBase3D::is_flipped_h() const { - return hflip; } void SpriteBase3D::set_flip_v(bool p_flip) { - vflip = p_flip; _queue_update(); } bool SpriteBase3D::is_flipped_v() const { - return vflip; } void SpriteBase3D::set_modulate(const Color &p_color) { - modulate = p_color; _propagate_color_changed(); _queue_update(); } Color SpriteBase3D::get_modulate() const { - return modulate; } void SpriteBase3D::set_pixel_size(float p_amount) { - pixel_size = p_amount; _queue_update(); } float SpriteBase3D::get_pixel_size() const { - return pixel_size; } void SpriteBase3D::set_opacity(float p_amount) { - opacity = p_amount; _queue_update(); } float SpriteBase3D::get_opacity() const { - return opacity; } void SpriteBase3D::set_axis(Vector3::Axis p_axis) { - ERR_FAIL_INDEX(p_axis, 3); axis = p_axis; _queue_update(); } Vector3::Axis SpriteBase3D::get_axis() const { - return axis; } void SpriteBase3D::_im_update() { - _draw(); pending_update = false; } void SpriteBase3D::_queue_update() { - if (pending_update) return; @@ -193,11 +168,9 @@ void SpriteBase3D::_queue_update() { } AABB SpriteBase3D::get_aabb() const { - return aabb; } Vector SpriteBase3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); } @@ -260,7 +233,6 @@ Ref SpriteBase3D::generate_triangle_mesh() const { } void SpriteBase3D::set_draw_flag(DrawFlags p_flag, bool p_enable) { - ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags[p_flag] = p_enable; _queue_update(); @@ -272,31 +244,26 @@ bool SpriteBase3D::get_draw_flag(DrawFlags p_flag) const { } void SpriteBase3D::set_alpha_cut_mode(AlphaCutMode p_mode) { - ERR_FAIL_INDEX(p_mode, 3); alpha_cut = p_mode; _queue_update(); } SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const { - return alpha_cut; } void SpriteBase3D::set_billboard_mode(StandardMaterial3D::BillboardMode p_mode) { - ERR_FAIL_INDEX(p_mode, 3); billboard_mode = p_mode; _queue_update(); } StandardMaterial3D::BillboardMode SpriteBase3D::get_billboard_mode() const { - return billboard_mode; } void SpriteBase3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_centered", "centered"), &SpriteBase3D::set_centered); ClassDB::bind_method(D_METHOD("is_centered"), &SpriteBase3D::is_centered); @@ -359,7 +326,6 @@ void SpriteBase3D::_bind_methods() { } SpriteBase3D::SpriteBase3D() { - color_dirty = true; centered = true; hflip = false; @@ -382,14 +348,12 @@ SpriteBase3D::SpriteBase3D() { } SpriteBase3D::~SpriteBase3D() { - RenderingServer::get_singleton()->free(immediate); } /////////////////////////////////////////// void Sprite3D::_draw() { - RID immediate = get_immediate(); RS::get_singleton()->immediate_clear(immediate); @@ -458,7 +422,6 @@ void Sprite3D::_draw() { SWAP(uvs[2], uvs[3]); } if (is_flipped_v()) { - SWAP(uvs[0], uvs[3]); SWAP(uvs[1], uvs[2]); } @@ -499,7 +462,6 @@ void Sprite3D::_draw() { AABB aabb; for (int i = 0; i < 6; i++) { - static const int index[6] = { 0, 1, 2, 0, 2, 3 }; RS::get_singleton()->immediate_normal(immediate, normal); @@ -527,7 +489,6 @@ void Sprite3D::_texture_changed() { } void Sprite3D::set_texture(const Ref &p_texture) { - if (p_texture == texture) return; if (texture.is_valid()) { @@ -541,12 +502,10 @@ void Sprite3D::set_texture(const Ref &p_texture) { } Ref Sprite3D::get_texture() const { - return texture; } void Sprite3D::set_region(bool p_region) { - if (p_region == region) return; @@ -555,12 +514,10 @@ void Sprite3D::set_region(bool p_region) { } bool Sprite3D::is_region() const { - return region; } void Sprite3D::set_region_rect(const Rect2 &p_region_rect) { - bool changed = region_rect != p_region_rect; region_rect = p_region_rect; if (region && changed) { @@ -569,12 +526,10 @@ void Sprite3D::set_region_rect(const Rect2 &p_region_rect) { } Rect2 Sprite3D::get_region_rect() const { - return region_rect; } void Sprite3D::set_frame(int p_frame) { - ERR_FAIL_INDEX(p_frame, int64_t(vframes) * hframes); frame = p_frame; @@ -587,7 +542,6 @@ void Sprite3D::set_frame(int p_frame) { } int Sprite3D::get_frame() const { - return frame; } @@ -603,31 +557,26 @@ Vector2 Sprite3D::get_frame_coords() const { } void Sprite3D::set_vframes(int p_amount) { - ERR_FAIL_COND(p_amount < 1); vframes = p_amount; _queue_update(); _change_notify(); } int Sprite3D::get_vframes() const { - return vframes; } void Sprite3D::set_hframes(int p_amount) { - ERR_FAIL_COND(p_amount < 1); hframes = p_amount; _queue_update(); _change_notify(); } int Sprite3D::get_hframes() const { - return hframes; } Rect2 Sprite3D::get_item_rect() const { - if (texture.is_null()) return Rect2(0, 0, 1, 1); /* @@ -638,7 +587,6 @@ Rect2 Sprite3D::get_item_rect() const { Size2i s; if (region) { - s = region_rect.size; } else { s = texture->get_size(); @@ -656,7 +604,6 @@ Rect2 Sprite3D::get_item_rect() const { } void Sprite3D::_validate_property(PropertyInfo &property) const { - if (property.name == "frame") { property.hint = PROPERTY_HINT_RANGE; property.hint_string = "0," + itos(vframes * hframes - 1) + ",1"; @@ -669,7 +616,6 @@ void Sprite3D::_validate_property(PropertyInfo &property) const { } void Sprite3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite3D::set_texture); ClassDB::bind_method(D_METHOD("get_texture"), &Sprite3D::get_texture); @@ -705,7 +651,6 @@ void Sprite3D::_bind_methods() { } Sprite3D::Sprite3D() { - region = false; frame = 0; vframes = 1; @@ -715,7 +660,6 @@ Sprite3D::Sprite3D() { //////////////////////////////////////// void AnimatedSprite3D::_draw() { - RID immediate = get_immediate(); RS::get_singleton()->immediate_clear(immediate); @@ -792,7 +736,6 @@ void AnimatedSprite3D::_draw() { SWAP(uvs[2], uvs[3]); } if (is_flipped_v()) { - SWAP(uvs[0], uvs[3]); SWAP(uvs[1], uvs[2]); } @@ -834,7 +777,6 @@ void AnimatedSprite3D::_draw() { AABB aabb; for (int i = 0; i < 6; i++) { - static const int indices[6] = { 0, 1, 2, 0, 2, 3 @@ -861,11 +803,9 @@ void AnimatedSprite3D::_draw() { } void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { - if (!frames.is_valid()) return; if (property.name == "animation") { - property.hint = PROPERTY_HINT_ENUM; List names; frames->get_animation_list(&names); @@ -903,10 +843,8 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { } void AnimatedSprite3D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_INTERNAL_PROCESS: { - if (frames.is_null()) return; if (!frames->has_animation(animation)) @@ -921,9 +859,7 @@ void AnimatedSprite3D::_notification(int p_what) { float remaining = get_process_delta_time(); while (remaining) { - if (timeout <= 0) { - timeout = 1.0 / speed; int fc = frames->get_frame_count(animation); @@ -950,7 +886,6 @@ void AnimatedSprite3D::_notification(int p_what) { } void AnimatedSprite3D::set_sprite_frames(const Ref &p_frames) { - if (frames.is_valid()) frames->disconnect("changed", callable_mp(this, &AnimatedSprite3D::_res_changed)); frames = p_frames; @@ -970,12 +905,10 @@ void AnimatedSprite3D::set_sprite_frames(const Ref &p_frames) { } Ref AnimatedSprite3D::get_sprite_frames() const { - return frames; } void AnimatedSprite3D::set_frame(int p_frame) { - if (!frames.is_valid()) { return; } @@ -999,12 +932,10 @@ void AnimatedSprite3D::set_frame(int p_frame) { emit_signal(SceneStringNames::get_singleton()->frame_changed); } int AnimatedSprite3D::get_frame() const { - return frame; } Rect2 AnimatedSprite3D::get_item_rect() const { - if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) { return Rect2(0, 0, 1, 1); } @@ -1027,7 +958,6 @@ Rect2 AnimatedSprite3D::get_item_rect() const { } void AnimatedSprite3D::_res_changed() { - set_frame(frame); _change_notify("frame"); _change_notify("animation"); @@ -1035,7 +965,6 @@ void AnimatedSprite3D::_res_changed() { } void AnimatedSprite3D::_set_playing(bool p_playing) { - if (playing == p_playing) return; playing = p_playing; @@ -1044,29 +973,24 @@ void AnimatedSprite3D::_set_playing(bool p_playing) { } bool AnimatedSprite3D::_is_playing() const { - return playing; } void AnimatedSprite3D::play(const StringName &p_animation) { - if (p_animation) set_animation(p_animation); _set_playing(true); } void AnimatedSprite3D::stop() { - _set_playing(false); } bool AnimatedSprite3D::is_playing() const { - return is_processing(); } void AnimatedSprite3D::_reset_timeout() { - if (!playing) return; @@ -1083,7 +1007,6 @@ void AnimatedSprite3D::_reset_timeout() { } void AnimatedSprite3D::set_animation(const StringName &p_animation) { - if (animation == p_animation) return; @@ -1094,12 +1017,10 @@ void AnimatedSprite3D::set_animation(const StringName &p_animation) { _queue_update(); } StringName AnimatedSprite3D::get_animation() const { - return animation; } String AnimatedSprite3D::get_configuration_warning() const { - if (frames.is_null()) { return TTR("A SpriteFrames resource must be created or set in the \"Frames\" property in order for AnimatedSprite3D to display frames."); } @@ -1108,7 +1029,6 @@ String AnimatedSprite3D::get_configuration_warning() const { } void AnimatedSprite3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite3D::set_sprite_frames); ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite3D::get_sprite_frames); @@ -1134,7 +1054,6 @@ void AnimatedSprite3D::_bind_methods() { } AnimatedSprite3D::AnimatedSprite3D() { - frame = 0; playing = false; animation = "default"; diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 64bef41fd8..721bed56f1 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -35,7 +35,6 @@ #include "scene/3d/visual_instance_3d.h" class SpriteBase3D : public GeometryInstance3D { - GDCLASS(SpriteBase3D, GeometryInstance3D); mutable Ref triangle_mesh; //cached @@ -145,7 +144,6 @@ public: }; class Sprite3D : public SpriteBase3D { - GDCLASS(Sprite3D, SpriteBase3D); Ref texture; @@ -194,7 +192,6 @@ public: }; class AnimatedSprite3D : public SpriteBase3D { - GDCLASS(AnimatedSprite3D, SpriteBase3D); Ref frames; diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index 66fcf0e40b..186bb48744 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -79,9 +79,7 @@ public: }; void VehicleWheel3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - VehicleBody3D *cb = Object::cast_to(get_parent()); if (!cb) return; @@ -94,7 +92,6 @@ void VehicleWheel3D::_notification(int p_what) { m_wheelAxleCS = get_transform().basis.get_axis(Vector3::AXIS_X).normalized(); } if (p_what == NOTIFICATION_EXIT_TREE) { - VehicleBody3D *cb = Object::cast_to(get_parent()); if (!cb) return; @@ -112,7 +109,6 @@ String VehicleWheel3D::get_configuration_warning() const { } void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) { - if (m_raycastInfo.m_isInContact) { @@ -145,77 +141,61 @@ void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) { } void VehicleWheel3D::set_radius(float p_radius) { - m_wheelRadius = p_radius; update_gizmo(); } float VehicleWheel3D::get_radius() const { - return m_wheelRadius; } void VehicleWheel3D::set_suspension_rest_length(float p_length) { - m_suspensionRestLength = p_length; update_gizmo(); } float VehicleWheel3D::get_suspension_rest_length() const { - return m_suspensionRestLength; } void VehicleWheel3D::set_suspension_travel(float p_length) { - m_maxSuspensionTravelCm = p_length / 0.01; } float VehicleWheel3D::get_suspension_travel() const { - return m_maxSuspensionTravelCm * 0.01; } void VehicleWheel3D::set_suspension_stiffness(float p_value) { - m_suspensionStiffness = p_value; } float VehicleWheel3D::get_suspension_stiffness() const { - return m_suspensionStiffness; } void VehicleWheel3D::set_suspension_max_force(float p_value) { - m_maxSuspensionForce = p_value; } float VehicleWheel3D::get_suspension_max_force() const { - return m_maxSuspensionForce; } void VehicleWheel3D::set_damping_compression(float p_value) { - m_wheelsDampingCompression = p_value; } float VehicleWheel3D::get_damping_compression() const { - return m_wheelsDampingCompression; } void VehicleWheel3D::set_damping_relaxation(float p_value) { - m_wheelsDampingRelaxation = p_value; } float VehicleWheel3D::get_damping_relaxation() const { - return m_wheelsDampingRelaxation; } void VehicleWheel3D::set_friction_slip(float p_value) { - m_frictionSlip = p_value; } float VehicleWheel3D::get_friction_slip() const { - return m_frictionSlip; } @@ -232,7 +212,6 @@ bool VehicleWheel3D::is_in_contact() const { } void VehicleWheel3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_radius", "length"), &VehicleWheel3D::set_radius); ClassDB::bind_method(D_METHOD("get_radius"), &VehicleWheel3D::get_radius); @@ -303,65 +282,52 @@ void VehicleWheel3D::_bind_methods() { } void VehicleWheel3D::set_engine_force(float p_engine_force) { - m_engineForce = p_engine_force; } float VehicleWheel3D::get_engine_force() const { - return m_engineForce; } void VehicleWheel3D::set_brake(float p_brake) { - m_brake = p_brake; } float VehicleWheel3D::get_brake() const { - return m_brake; } void VehicleWheel3D::set_steering(float p_steering) { - m_steering = p_steering; } float VehicleWheel3D::get_steering() const { - return m_steering; } void VehicleWheel3D::set_use_as_traction(bool p_enable) { - engine_traction = p_enable; } bool VehicleWheel3D::is_used_as_traction() const { - return engine_traction; } void VehicleWheel3D::set_use_as_steering(bool p_enabled) { - steers = p_enabled; } bool VehicleWheel3D::is_used_as_steering() const { - return steers; } float VehicleWheel3D::get_skidinfo() const { - return m_skidInfo; } float VehicleWheel3D::get_rpm() const { - return m_rpm; } VehicleWheel3D::VehicleWheel3D() { - steers = false; engine_traction = false; m_steering = real_t(0.); @@ -389,7 +355,6 @@ VehicleWheel3D::VehicleWheel3D() { } void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState3D *s) { - wheel.m_raycastInfo.m_isInContact = false; Transform chassisTrans = s->get_transform(); @@ -406,7 +371,6 @@ void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirect } void VehicleBody3D::_update_wheel(int p_idx, PhysicsDirectBodyState3D *s) { - VehicleWheel3D &wheel = *wheels[p_idx]; _update_wheel_transform(wheel, s); @@ -431,7 +395,6 @@ void VehicleBody3D::_update_wheel(int p_idx, PhysicsDirectBodyState3D *s) { } real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) { - VehicleWheel3D &wheel = *wheels[p_idx]; _update_wheel_transform(wheel, s); @@ -514,7 +477,6 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) { } void VehicleBody3D::_update_suspension(PhysicsDirectBodyState3D *s) { - real_t chassisMass = mass; for (int w_it = 0; w_it < wheels.size(); w_it++) { @@ -560,7 +522,6 @@ void VehicleBody3D::_update_suspension(PhysicsDirectBodyState3D *s) { //bilateral constraint between two dynamic objects void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState3D *s, const Vector3 &pos1, PhysicsBody3D *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence) { - real_t normalLenSqr = normal.length_squared(); //ERR_FAIL_COND( normalLenSqr < real_t(1.1)); @@ -668,7 +629,6 @@ VehicleBody3D::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDir } real_t VehicleBody3D::_calc_rolling_friction(btVehicleWheelContactPoint &contactPoint) { - real_t j1 = 0.f; const Vector3 &contactPosWorld = contactPoint.m_frictionPositionWorld; @@ -699,7 +659,6 @@ real_t VehicleBody3D::_calc_rolling_friction(btVehicleWheelContactPoint &contact static const real_t sideFrictionStiffness2 = real_t(1.0); void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) { - //calculate the impulse, so that the wheels don't move sidewards int numWheel = wheels.size(); if (!numWheel) @@ -717,13 +676,10 @@ void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) { } { - for (int i = 0; i < wheels.size(); i++) { - VehicleWheel3D &wheelInfo = *wheels[i]; if (wheelInfo.m_raycastInfo.m_isInContact) { - //const btTransform& wheelTrans = getWheelTransformWS( i ); Basis wheelBasis0 = wheelInfo.m_worldTransform.basis; //get_global_transform().basis; @@ -851,7 +807,6 @@ void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) { } void VehicleBody3D::_direct_state_changed(Object *p_state) { - RigidBody3D::_direct_state_changed(p_state); state = Object::cast_to(p_state); @@ -859,12 +814,10 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) { float step = state->get_step(); for (int i = 0; i < wheels.size(); i++) { - _update_wheel(i, state); } for (int i = 0; i < wheels.size(); i++) { - _ray_cast(i, state); wheels[i]->set_transform(state->get_transform().inverse() * wheels[i]->m_worldTransform); } @@ -872,7 +825,6 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) { _update_suspension(state); for (int i = 0; i < wheels.size(); i++) { - //apply suspension force VehicleWheel3D &wheel = *wheels[i]; @@ -921,7 +873,6 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) { } void VehicleBody3D::set_engine_force(float p_engine_force) { - engine_force = p_engine_force; for (int i = 0; i < wheels.size(); i++) { VehicleWheel3D &wheelInfo = *wheels[i]; @@ -931,12 +882,10 @@ void VehicleBody3D::set_engine_force(float p_engine_force) { } float VehicleBody3D::get_engine_force() const { - return engine_force; } void VehicleBody3D::set_brake(float p_brake) { - brake = p_brake; for (int i = 0; i < wheels.size(); i++) { VehicleWheel3D &wheelInfo = *wheels[i]; @@ -944,12 +893,10 @@ void VehicleBody3D::set_brake(float p_brake) { } } float VehicleBody3D::get_brake() const { - return brake; } void VehicleBody3D::set_steering(float p_steering) { - m_steeringValue = p_steering; for (int i = 0; i < wheels.size(); i++) { VehicleWheel3D &wheelInfo = *wheels[i]; @@ -958,12 +905,10 @@ void VehicleBody3D::set_steering(float p_steering) { } } float VehicleBody3D::get_steering() const { - return m_steeringValue; } void VehicleBody3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleBody3D::set_engine_force); ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleBody3D::get_engine_force); @@ -980,7 +925,6 @@ void VehicleBody3D::_bind_methods() { } VehicleBody3D::VehicleBody3D() { - m_pitchControl = 0; m_currentVehicleSpeedKmHour = real_t(0.); m_steeringValue = real_t(0.); diff --git a/scene/3d/vehicle_body_3d.h b/scene/3d/vehicle_body_3d.h index d5e896263d..e76f44acfd 100644 --- a/scene/3d/vehicle_body_3d.h +++ b/scene/3d/vehicle_body_3d.h @@ -36,7 +36,6 @@ class VehicleBody3D; class VehicleWheel3D : public Node3D { - GDCLASS(VehicleWheel3D, Node3D); friend class VehicleBody3D; @@ -152,7 +151,6 @@ public: }; class VehicleBody3D : public RigidBody3D { - GDCLASS(VehicleBody3D, RigidBody3D); float engine_force; diff --git a/scene/3d/velocity_tracker_3d.cpp b/scene/3d/velocity_tracker_3d.cpp index c9b95e6397..f4f3c7a200 100644 --- a/scene/3d/velocity_tracker_3d.cpp +++ b/scene/3d/velocity_tracker_3d.cpp @@ -32,16 +32,13 @@ #include "core/engine.h" void VelocityTracker3D::set_track_physics_step(bool p_track_physics_step) { - physics_step = p_track_physics_step; } bool VelocityTracker3D::is_tracking_physics_step() const { - return physics_step; } void VelocityTracker3D::update_position(const Vector3 &p_position) { - PositionHistory ph; ph.position = p_position; if (physics_step) { @@ -60,7 +57,6 @@ void VelocityTracker3D::update_position(const Vector3 &p_position) { position_history.write[0] = ph; } Vector3 VelocityTracker3D::get_tracked_linear_velocity() const { - Vector3 linear_velocity; float max_time = 1 / 5.0; //maximum time to interpolate a velocity @@ -105,7 +101,6 @@ Vector3 VelocityTracker3D::get_tracked_linear_velocity() const { } void VelocityTracker3D::reset(const Vector3 &p_new_pos) { - PositionHistory ph; ph.position = p_new_pos; if (physics_step) { @@ -119,7 +114,6 @@ void VelocityTracker3D::reset(const Vector3 &p_new_pos) { } void VelocityTracker3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_track_physics_step", "enable"), &VelocityTracker3D::set_track_physics_step); ClassDB::bind_method(D_METHOD("is_tracking_physics_step"), &VelocityTracker3D::is_tracking_physics_step); ClassDB::bind_method(D_METHOD("update_position", "position"), &VelocityTracker3D::update_position); diff --git a/scene/3d/visibility_notifier_3d.cpp b/scene/3d/visibility_notifier_3d.cpp index 2707a0a514..9c2035f1d8 100644 --- a/scene/3d/visibility_notifier_3d.cpp +++ b/scene/3d/visibility_notifier_3d.cpp @@ -37,7 +37,6 @@ #include "scene/scene_string_names.h" void VisibilityNotifier3D::_enter_camera(Camera3D *p_camera) { - ERR_FAIL_COND(cameras.has(p_camera)); cameras.insert(p_camera); if (cameras.size() == 1) { @@ -49,7 +48,6 @@ void VisibilityNotifier3D::_enter_camera(Camera3D *p_camera) { } void VisibilityNotifier3D::_exit_camera(Camera3D *p_camera) { - ERR_FAIL_COND(!cameras.has(p_camera)); cameras.erase(p_camera); @@ -62,7 +60,6 @@ void VisibilityNotifier3D::_exit_camera(Camera3D *p_camera) { } void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) { - if (aabb == p_aabb) return; aabb = p_aabb; @@ -76,35 +73,28 @@ void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) { } AABB VisibilityNotifier3D::get_aabb() const { - return aabb; } void VisibilityNotifier3D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_WORLD: { - get_world_3d()->_register_notifier(this, get_global_transform().xform(aabb)); } break; case NOTIFICATION_TRANSFORM_CHANGED: { - get_world_3d()->_update_notifier(this, get_global_transform().xform(aabb)); } break; case NOTIFICATION_EXIT_WORLD: { - get_world_3d()->_remove_notifier(this); } break; } } bool VisibilityNotifier3D::is_on_screen() const { - return cameras.size() != 0; } void VisibilityNotifier3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_aabb", "rect"), &VisibilityNotifier3D::set_aabb); ClassDB::bind_method(D_METHOD("get_aabb"), &VisibilityNotifier3D::get_aabb); ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier3D::is_on_screen); @@ -118,7 +108,6 @@ void VisibilityNotifier3D::_bind_methods() { } VisibilityNotifier3D::VisibilityNotifier3D() { - aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); set_notify_transform(true); } @@ -126,9 +115,7 @@ VisibilityNotifier3D::VisibilityNotifier3D() { ////////////////////////////////////// void VisibilityEnabler3D::_screen_enter() { - for (Map::Element *E = nodes.front(); E; E = E->next()) { - _change_node_state(E->key(), true); } @@ -136,9 +123,7 @@ void VisibilityEnabler3D::_screen_enter() { } void VisibilityEnabler3D::_screen_exit() { - for (Map::Element *E = nodes.front(); E; E = E->next()) { - _change_node_state(E->key(), false); } @@ -146,14 +131,12 @@ void VisibilityEnabler3D::_screen_exit() { } void VisibilityEnabler3D::_find_nodes(Node *p_node) { - bool add = false; Variant meta; { RigidBody3D *rb = Object::cast_to(p_node); if (rb && ((rb->get_mode() == RigidBody3D::MODE_CHARACTER || rb->get_mode() == RigidBody3D::MODE_RIGID))) { - add = true; meta = rb->get_mode(); } @@ -167,7 +150,6 @@ void VisibilityEnabler3D::_find_nodes(Node *p_node) { } if (add) { - p_node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler3D::_node_removed), varray(p_node), CONNECT_ONESHOT); nodes[p_node] = meta; _change_node_state(p_node, false); @@ -183,9 +165,7 @@ void VisibilityEnabler3D::_find_nodes(Node *p_node) { } void VisibilityEnabler3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - if (Engine::get_singleton()->is_editor_hint()) return; @@ -198,12 +178,10 @@ void VisibilityEnabler3D::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE) { - if (Engine::get_singleton()->is_editor_hint()) return; for (Map::Element *E = nodes.front(); E; E = E->next()) { - if (!visible) _change_node_state(E->key(), true); E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler3D::_node_removed)); @@ -214,7 +192,6 @@ void VisibilityEnabler3D::_notification(int p_what) { } void VisibilityEnabler3D::_change_node_state(Node *p_node, bool p_enabled) { - ERR_FAIL_COND(!nodes.has(p_node)); if (enabler[ENABLER_FREEZE_BODIES]) { @@ -228,21 +205,18 @@ void VisibilityEnabler3D::_change_node_state(Node *p_node, bool p_enabled) { AnimationPlayer *ap = Object::cast_to(p_node); if (ap) { - ap->set_active(p_enabled); } } } void VisibilityEnabler3D::_node_removed(Node *p_node) { - if (!visible) _change_node_state(p_node, true); nodes.erase(p_node); } void VisibilityEnabler3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_enabler", "enabler", "enabled"), &VisibilityEnabler3D::set_enabler); ClassDB::bind_method(D_METHOD("is_enabler_enabled", "enabler"), &VisibilityEnabler3D::is_enabler_enabled); @@ -255,18 +229,15 @@ void VisibilityEnabler3D::_bind_methods() { } void VisibilityEnabler3D::set_enabler(Enabler p_enabler, bool p_enable) { - ERR_FAIL_INDEX(p_enabler, ENABLER_MAX); enabler[p_enabler] = p_enable; } bool VisibilityEnabler3D::is_enabler_enabled(Enabler p_enabler) const { - ERR_FAIL_INDEX_V(p_enabler, ENABLER_MAX, false); return enabler[p_enabler]; } VisibilityEnabler3D::VisibilityEnabler3D() { - for (int i = 0; i < ENABLER_MAX; i++) enabler[i] = true; diff --git a/scene/3d/visibility_notifier_3d.h b/scene/3d/visibility_notifier_3d.h index 19204a6a4e..3864b398f4 100644 --- a/scene/3d/visibility_notifier_3d.h +++ b/scene/3d/visibility_notifier_3d.h @@ -35,7 +35,6 @@ class Camera3D; class VisibilityNotifier3D : public Node3D { - GDCLASS(VisibilityNotifier3D, Node3D); Set cameras; @@ -62,7 +61,6 @@ public: }; class VisibilityEnabler3D : public VisibilityNotifier3D { - GDCLASS(VisibilityEnabler3D, VisibilityNotifier3D); public: diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index 4724c88a30..3af0c0dff0 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -35,12 +35,10 @@ #include "skeleton_3d.h" AABB VisualInstance3D::get_transformed_aabb() const { - return get_global_transform().xform(get_aabb()); } void VisualInstance3D::_update_visibility() { - if (!is_inside_tree()) return; @@ -49,11 +47,8 @@ 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(get_parent()); @@ -66,42 +61,35 @@ void VisualInstance3D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - Transform 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; } } RID VisualInstance3D::get_instance() const { - return instance; } RID VisualInstance3D::_get_visual_instance_rid() const { - return instance; } void VisualInstance3D::set_layer_mask(uint32_t p_mask) { - layers = p_mask; RenderingServer::get_singleton()->instance_set_layer_mask(instance, p_mask); } uint32_t VisualInstance3D::get_layer_mask() const { - return layers; } @@ -120,7 +108,6 @@ bool VisualInstance3D::get_layer_mask_bit(int p_layer) const { } void VisualInstance3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"), &VisualInstance3D::_get_visual_instance_rid); ClassDB::bind_method(D_METHOD("set_base", "base"), &VisualInstance3D::set_base); ClassDB::bind_method(D_METHOD("get_base"), &VisualInstance3D::get_base); @@ -136,18 +123,15 @@ void VisualInstance3D::_bind_methods() { } void VisualInstance3D::set_base(const RID &p_base) { - RenderingServer::get_singleton()->instance_set_base(instance, p_base); base = p_base; } RID VisualInstance3D::get_base() const { - return base; } VisualInstance3D::VisualInstance3D() { - instance = RenderingServer::get_singleton()->instance_create(); RenderingServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id()); layers = 1; @@ -155,62 +139,51 @@ VisualInstance3D::VisualInstance3D() { } VisualInstance3D::~VisualInstance3D() { - RenderingServer::get_singleton()->free(instance); } void GeometryInstance3D::set_material_override(const Ref &p_material) { - material_override = p_material; RS::get_singleton()->instance_geometry_set_material_override(get_instance(), p_material.is_valid() ? p_material->get_rid() : RID()); } Ref GeometryInstance3D::get_material_override() const { - return material_override; } void GeometryInstance3D::set_lod_min_distance(float p_dist) { - lod_min_distance = p_dist; RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); } float GeometryInstance3D::get_lod_min_distance() const { - return lod_min_distance; } void GeometryInstance3D::set_lod_max_distance(float p_dist) { - lod_max_distance = p_dist; RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); } float GeometryInstance3D::get_lod_max_distance() const { - return lod_max_distance; } void GeometryInstance3D::set_lod_min_hysteresis(float p_dist) { - lod_min_hysteresis = p_dist; RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); } float GeometryInstance3D::get_lod_min_hysteresis() const { - return lod_min_hysteresis; } void GeometryInstance3D::set_lod_max_hysteresis(float p_dist) { - lod_max_hysteresis = p_dist; RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); } float GeometryInstance3D::get_lod_max_hysteresis() const { - return lod_max_hysteresis; } @@ -284,31 +257,26 @@ void GeometryInstance3D::_get_property_list(List *p_list) const { } void GeometryInstance3D::set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting) { - shadow_casting_setting = p_shadow_casting_setting; RS::get_singleton()->instance_geometry_set_cast_shadows_setting(get_instance(), (RS::ShadowCastingSetting)p_shadow_casting_setting); } GeometryInstance3D::ShadowCastingSetting GeometryInstance3D::get_cast_shadows_setting() const { - return shadow_casting_setting; } void GeometryInstance3D::set_extra_cull_margin(float p_margin) { - ERR_FAIL_COND(p_margin < 0); extra_cull_margin = p_margin; RS::get_singleton()->instance_set_extra_visibility_margin(get_instance(), extra_cull_margin); } float GeometryInstance3D::get_extra_cull_margin() const { - return extra_cull_margin; } void GeometryInstance3D::set_shader_instance_uniform(const StringName &p_uniform, const Variant &p_value) { - if (p_value.get_type() == Variant::NIL) { Variant def_value = RS::get_singleton()->instance_geometry_get_shader_parameter_default_value(get_instance(), p_uniform); RS::get_singleton()->instance_geometry_set_shader_parameter(get_instance(), p_uniform, def_value); @@ -320,11 +288,9 @@ void GeometryInstance3D::set_shader_instance_uniform(const StringName &p_uniform } Variant GeometryInstance3D::get_shader_instance_uniform(const StringName &p_uniform) const { - return RS::get_singleton()->instance_geometry_get_shader_parameter(get_instance(), p_uniform); } void GeometryInstance3D::set_custom_aabb(AABB aabb) { - RS::get_singleton()->instance_set_custom_aabb(get_instance(), aabb); } @@ -338,7 +304,6 @@ GeometryInstance3D::LightmapScale GeometryInstance3D::get_lightmap_scale() const } void GeometryInstance3D::set_gi_mode(GIMode p_mode) { - switch (p_mode) { case GI_MODE_DISABLED: { RS::get_singleton()->instance_geometry_set_flag(get_instance(), RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false); @@ -363,7 +328,6 @@ GeometryInstance3D::GIMode GeometryInstance3D::get_gi_mode() const { } void GeometryInstance3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_material_override", "material"), &GeometryInstance3D::set_material_override); ClassDB::bind_method(D_METHOD("get_material_override"), &GeometryInstance3D::get_material_override); diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index a871c65b6a..195674f62d 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -37,7 +37,6 @@ #include "scene/resources/material.h" class VisualInstance3D : public Node3D { - GDCLASS(VisualInstance3D, Node3D); OBJ_CATEGORY("3D Visual Nodes"); @@ -81,7 +80,6 @@ public: }; class GeometryInstance3D : public VisualInstance3D { - GDCLASS(GeometryInstance3D, VisualInstance3D); public: diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp index f9c3810843..333c486165 100644 --- a/scene/3d/voxelizer.cpp +++ b/scene/3d/voxelizer.cpp @@ -36,7 +36,6 @@ #include static _FORCE_INLINE_ void get_uv_and_normal(const Vector3 &p_pos, const Vector3 *p_vtx, const Vector2 *p_uv, const Vector3 *p_normal, Vector2 &r_uv, Vector3 &r_normal) { - if (p_pos.distance_squared_to(p_vtx[0]) < CMP_EPSILON2) { r_uv = p_uv[0]; r_normal = p_normal[0]; @@ -77,7 +76,6 @@ static _FORCE_INLINE_ void get_uv_and_normal(const Vector3 &p_pos, const Vector3 } void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector3 *p_normal, const Vector2 *p_uv, const MaterialCache &p_material, const AABB &p_aabb) { - if (p_level == cell_subdiv) { //plot the face by guessing its albedo and emission value @@ -89,7 +87,6 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co Vector3 normal = plane.normal; for (int i = 0; i < 3; i++) { - Vector3 axis; axis[i] = 1.0; float dot = ABS(normal.dot(axis)); @@ -117,11 +114,9 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co //map to a grid average in the best axis for this face for (int i = 0; i < color_scan_cell_width; i++) { - Vector3 ofs_i = float(i) * t1; for (int j = 0; j < color_scan_cell_width; j++) { - Vector3 ofs_j = float(j) * t2; Vector3 from = p_aabb.position + ofs_i + ofs_j; @@ -147,7 +142,6 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co if (ABS(plane.distance_to(ray_from)) < ABS(plane.distance_to(ray_to))) { intersection = plane.project(ray_from); } else { - intersection = plane.project(ray_to); } } @@ -210,7 +204,6 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co normal_accum = lnormal * alpha; } else { - float accdiv = 1.0 / (color_scan_cell_width * color_scan_cell_width); alpha *= accdiv; @@ -243,7 +236,6 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co int half = (1 << cell_subdiv) >> (p_level + 1); for (int i = 0; i < 8; i++) { - AABB aabb = p_aabb; aabb.size *= 0.5; @@ -297,11 +289,9 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co } Vector Voxelizer::_get_bake_texture(Ref p_image, const Color &p_color_mul, const Color &p_color_add) { - Vector ret; if (p_image.is_null() || p_image->empty()) { - ret.resize(bake_texture_size * bake_texture_size); for (int i = 0; i < bake_texture_size * bake_texture_size; i++) { ret.write[i] = p_color_add; @@ -335,7 +325,6 @@ Vector Voxelizer::_get_bake_texture(Ref p_image, const Color &p_co } Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref p_material) { - //this way of obtaining materials is inaccurate and also does not support some compressed formats very well Ref mat = p_material; @@ -348,12 +337,10 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref p_material MaterialCache mc; if (mat.is_valid()) { - Ref albedo_tex = mat->get_texture(StandardMaterial3D::TEXTURE_ALBEDO); Ref img_albedo; if (albedo_tex.is_valid()) { - img_albedo = albedo_tex->get_data(); mc.albedo = _get_bake_texture(img_albedo, mat->get_albedo(), Color(0, 0, 0)); // albedo texture, color is multiplicative } else { @@ -368,7 +355,6 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref p_material Ref img_emission; if (emission_tex.is_valid()) { - img_emission = emission_tex->get_data(); } @@ -390,9 +376,7 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref p_material } void Voxelizer::plot_mesh(const Transform &p_xform, Ref &p_mesh, const Vector> &p_materials, const Ref &p_override_material) { - for (int i = 0; i < p_mesh->get_surface_count(); i++) { - if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) continue; //only triangles @@ -426,12 +410,10 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref &p_mesh, const Vec } if (index.size()) { - int facecount = index.size() / 3; const int *ir = index.ptr(); for (int j = 0; j < facecount; j++) { - Vector3 vtxs[3]; Vector2 uvs[3]; Vector3 normal[3]; @@ -460,11 +442,9 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref &p_mesh, const Vec } } else { - int facecount = vertices.size() / 3; for (int j = 0; j < facecount; j++) { - Vector3 vtxs[3]; Vector2 uvs[3]; Vector3 normal[3]; @@ -498,7 +478,6 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref &p_mesh, const Vec } void Voxelizer::_sort() { - // cells need to be sorted by level and coordinates // it is important that level has more priority (for compute), and that Z has the least, // given it may aid older implementations plot using GPU @@ -507,7 +486,6 @@ void Voxelizer::_sort() { uint32_t cell_count = bake_cells.size(); sorted_cells.resize(cell_count); { - CellSort *sort_cellsp = sorted_cells.ptrw(); const Cell *bake_cellsp = bake_cells.ptr(); @@ -540,7 +518,6 @@ void Voxelizer::_sort() { } { - const CellSort *sort_cellsp = sorted_cells.ptr(); const Cell *bake_cellsp = bake_cells.ptr(); const uint32_t *reverse_mapp = reverse_map.ptr(); @@ -563,9 +540,7 @@ void Voxelizer::_sort() { } void Voxelizer::_fixup_plot(int p_idx, int p_level) { - if (p_level == cell_subdiv) { - leaf_voxel_count++; float alpha = bake_cells[p_idx].alpha; @@ -604,7 +579,6 @@ void Voxelizer::_fixup_plot(int p_idx, int p_level) { }*/ } else { - //go down bake_cells.write[p_idx].emission[0] = 0; @@ -621,7 +595,6 @@ void Voxelizer::_fixup_plot(int p_idx, int p_level) { int children_found = 0; for (int i = 0; i < 8; i++) { - uint32_t child = bake_cells[p_idx].children[i]; if (child == CHILD_EMPTY) @@ -638,7 +611,6 @@ void Voxelizer::_fixup_plot(int p_idx, int p_level) { } void Voxelizer::begin_bake(int p_subdiv, const AABB &p_bounds) { - sorted = false; original_bounds = p_bounds; cell_subdiv = p_subdiv; @@ -653,7 +625,6 @@ void Voxelizer::begin_bake(int p_subdiv, const AABB &p_bounds) { leaf_voxel_count = 0; for (int i = 0; i < 3; i++) { - if (i == longest_axis) continue; @@ -711,7 +682,6 @@ Vector Voxelizer::get_giprobe_octree_cells() const { uint32_t cell_count = bake_cells.size(); for (uint32_t i = 0; i < cell_count; i++) { - for (uint32_t j = 0; j < 8; j++) { children_cells[i * 8 + j] = cells[i].children[j]; } @@ -731,7 +701,6 @@ Vector Voxelizer::get_giprobe_data_cells() const { uint32_t cell_count = bake_cells.size(); for (uint32_t i = 0; i < cell_count; i++) { - { //position uint32_t x = cells[i].x; @@ -803,7 +772,6 @@ Vector Voxelizer::get_giprobe_level_cell_count() const { /* dt of 1d function using squared distance */ static void edt(float *f, int stride, int n) { - float *d = (float *)alloca(sizeof(float) * n + sizeof(int) * n + sizeof(float) * (n + 1)); int *v = (int *)&(d[n]); float *z = (float *)&v[n]; @@ -840,7 +808,6 @@ static void edt(float *f, int stride, int n) { #undef square Vector Voxelizer::get_sdf_3d_image() const { - Vector3i octree_size = get_giprobe_octree_size(); uint32_t float_count = octree_size.x * octree_size.y * octree_size.z; @@ -858,7 +825,6 @@ Vector Voxelizer::get_sdf_3d_image() const { uint32_t cell_count = bake_cells.size(); for (uint32_t i = 0; i < cell_count; i++) { - if (cells[i].level < (cell_subdiv - 1)) { continue; //do not care about this level } @@ -912,9 +878,7 @@ Vector Voxelizer::get_sdf_3d_image() const { #undef INF void Voxelizer::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref &p_multimesh, int &idx) { - if (p_level == cell_subdiv - 1) { - Vector3 center = p_aabb.position + p_aabb.size * 0.5; Transform xform; xform.origin = center; @@ -928,9 +892,7 @@ void Voxelizer::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref= (uint32_t)max_original_cells) @@ -952,7 +914,6 @@ void Voxelizer::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref Voxelizer::create_debug_multimesh() { - Ref mm; mm.instance(); @@ -975,18 +936,15 @@ Ref Voxelizer::create_debug_multimesh() { colors.push_back(Color(1, 1, 1, 1)); for (int i = 0; i < 6; i++) { - Vector3 face_points[4]; for (int j = 0; j < 4; j++) { - float v[3]; v[0] = 1.0; v[1] = 1 - 2 * ((j >> 1) & 1); v[2] = v[1] * (1 - 2 * (j & 1)); for (int k = 0; k < 3; k++) { - if (i < 3) face_points[j][(i + k) % 3] = v[k]; else diff --git a/scene/3d/voxelizer.h b/scene/3d/voxelizer.h index 1fde6237a2..3546fd7729 100644 --- a/scene/3d/voxelizer.h +++ b/scene/3d/voxelizer.h @@ -43,7 +43,6 @@ private: }; struct Cell { - uint32_t children[8]; float albedo[3]; //albedo in RGB24 float emission[3]; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast) diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp index 8dbb709ae4..ac314e005b 100644 --- a/scene/3d/world_environment.cpp +++ b/scene/3d/world_environment.cpp @@ -32,9 +32,7 @@ #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()) { if (get_viewport()->find_world_3d()->get_environment().is_valid()) { WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding."); @@ -52,7 +50,6 @@ void WorldEnvironment::_notification(int p_what) { } } else if (p_what == Node3D::NOTIFICATION_EXIT_WORLD || p_what == Node3D::NOTIFICATION_EXIT_TREE) { - if (environment.is_valid() && get_viewport()->find_world_3d()->get_environment() == environment) { get_viewport()->find_world_3d()->set_environment(Ref()); remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); @@ -66,7 +63,6 @@ void WorldEnvironment::_notification(int p_what) { } void WorldEnvironment::set_environment(const Ref &p_environment) { - if (is_inside_tree() && environment.is_valid() && get_viewport()->find_world_3d()->get_environment() == environment) { get_viewport()->find_world_3d()->set_environment(Ref()); remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); @@ -86,12 +82,10 @@ void WorldEnvironment::set_environment(const Ref &p_environment) { } Ref WorldEnvironment::get_environment() const { - return environment; } void WorldEnvironment::set_camera_effects(const Ref &p_camera_effects) { - if (is_inside_tree() && camera_effects.is_valid() && get_viewport()->find_world_3d()->get_camera_effects() == camera_effects) { get_viewport()->find_world_3d()->set_camera_effects(Ref()); remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); @@ -111,12 +105,10 @@ void WorldEnvironment::set_camera_effects(const Ref &p_camera_eff } Ref WorldEnvironment::get_camera_effects() const { - return camera_effects; } String WorldEnvironment::get_configuration_warning() const { - if (!environment.is_valid()) { return TTR("WorldEnvironment requires its \"Environment\" property to contain an Environment to have a visible effect."); } @@ -135,7 +127,6 @@ String WorldEnvironment::get_configuration_warning() const { } void WorldEnvironment::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_environment", "env"), &WorldEnvironment::set_environment); ClassDB::bind_method(D_METHOD("get_environment"), &WorldEnvironment::get_environment); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_environment", "get_environment"); diff --git a/scene/3d/world_environment.h b/scene/3d/world_environment.h index e4c9fc071d..ddb2af7bd3 100644 --- a/scene/3d/world_environment.h +++ b/scene/3d/world_environment.h @@ -34,7 +34,6 @@ #include "scene/3d/node_3d.h" class WorldEnvironment : public Node { - GDCLASS(WorldEnvironment, Node); Ref environment; diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp index 1b13b64744..1d01a8b5b4 100644 --- a/scene/3d/xr_nodes.cpp +++ b/scene/3d/xr_nodes.cpp @@ -443,7 +443,6 @@ void XRAnchor3D::_notification(int p_what) { }; void XRAnchor3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &XRAnchor3D::set_anchor_id); ClassDB::bind_method(D_METHOD("get_anchor_id"), &XRAnchor3D::get_anchor_id); ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_anchor_id", "get_anchor_id"); diff --git a/scene/3d/xr_nodes.h b/scene/3d/xr_nodes.h index 55dcfe087e..4685328f16 100644 --- a/scene/3d/xr_nodes.h +++ b/scene/3d/xr_nodes.h @@ -44,7 +44,6 @@ XRCamera is a subclass of camera which will register itself with its parent XROrigin and as a result is automatically positioned */ class XRCamera3D : public Camera3D { - GDCLASS(XRCamera3D, Camera3D); protected: @@ -69,7 +68,6 @@ public: */ class XRController3D : public Node3D { - GDCLASS(XRController3D, Node3D); private: @@ -150,7 +148,6 @@ public: This node will automatically locate any camera child nodes and update its position while our XRController3D node will handle tracked controllers. */ class XROrigin3D : public Node3D { - GDCLASS(XROrigin3D, Node3D); private: diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp index 3502f5e961..22477f452c 100644 --- a/scene/animation/animation_blend_space_1d.cpp +++ b/scene/animation/animation_blend_space_1d.cpp @@ -167,7 +167,6 @@ void AnimationNodeBlendSpace1D::remove_blend_point(int p_point) { } int AnimationNodeBlendSpace1D::get_blend_point_count() const { - return blend_points_used; } @@ -220,7 +219,6 @@ void AnimationNodeBlendSpace1D::_add_blend_point(int p_index, const Ref= max_space.x) { min_space.x = max_space.x - 1; @@ -241,7 +236,6 @@ Vector2 AnimationNodeBlendSpace2D::get_min_space() const { } void AnimationNodeBlendSpace2D::set_max_space(const Vector2 &p_max) { - max_space = p_max; if (max_space.x <= min_space.x) { max_space.x = min_space.x + 1; @@ -284,7 +278,6 @@ void AnimationNodeBlendSpace2D::_add_blend_point(int p_index, const Ref &p_triangles) { - if (auto_triangles) return; ERR_FAIL_COND(p_triangles.size() % 3 != 0); @@ -294,7 +287,6 @@ void AnimationNodeBlendSpace2D::_set_triangles(const Vector &p_triangles) { } Vector AnimationNodeBlendSpace2D::_get_triangles() const { - Vector t; if (auto_triangles && trianges_dirty) return t; @@ -318,7 +310,6 @@ void AnimationNodeBlendSpace2D::_queue_auto_triangles() { } void AnimationNodeBlendSpace2D::_update_triangles() { - if (!auto_triangles || !trianges_dirty) return; @@ -344,7 +335,6 @@ void AnimationNodeBlendSpace2D::_update_triangles() { } Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) { - _update_triangles(); if (triangles.size() == 0) @@ -360,7 +350,6 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) { } if (Geometry::is_point_in_triangle(p_point, points[0], points[1], points[2])) { - return p_point; } @@ -381,7 +370,6 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) { } void AnimationNodeBlendSpace2D::_blend_triangle(const Vector2 &p_pos, const Vector2 *p_points, float *r_weights) { - if (p_pos.distance_squared_to(p_points[0]) < CMP_EPSILON2) { r_weights[0] = 1; r_weights[1] = 0; @@ -427,7 +415,6 @@ void AnimationNodeBlendSpace2D::_blend_triangle(const Vector2 &p_pos, const Vect } float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) { - _update_triangles(); Vector2 blend_pos = get_parameter(blend_position); @@ -436,7 +423,6 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) { float mind = 0; //time of min distance point if (blend_mode == BLEND_MODE_INTERPOLATED) { - if (triangles.size() == 0) return 0; @@ -452,7 +438,6 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) { } if (Geometry::is_point_in_triangle(blend_pos, points[0], points[1], points[2])) { - blend_triangle = i; _blend_triangle(blend_pos, points, blend_weights); break; @@ -494,7 +479,6 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) { first = true; for (int i = 0; i < blend_points_used; i++) { - bool found = false; for (int j = 0; j < 3; j++) { if (i == triangle_points[j]) { @@ -515,22 +499,18 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) { } } } else { - int new_closest = -1; float new_closest_dist = 1e20; for (int i = 0; i < blend_points_used; i++) { - float d = blend_points[i].position.distance_squared_to(blend_pos); if (d < new_closest_dist) { - new_closest = i; new_closest_dist = d; } } if (new_closest != closest && new_closest != -1) { - float from = 0; if (blend_mode == BLEND_MODE_DISCRETE_CARRY && closest != -1) { //see how much animation remains @@ -557,7 +537,6 @@ String AnimationNodeBlendSpace2D::get_caption() const { } void AnimationNodeBlendSpace2D::_validate_property(PropertyInfo &property) const { - if (auto_triangles && property.name == "triangles") { property.usage = 0; } @@ -601,7 +580,6 @@ AnimationNodeBlendSpace2D::BlendMode AnimationNodeBlendSpace2D::get_blend_mode() } void AnimationNodeBlendSpace2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_blend_point", "node", "pos", "at_index"), &AnimationNodeBlendSpace2D::add_blend_point, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("set_blend_point_position", "point", "pos"), &AnimationNodeBlendSpace2D::set_blend_point_position); ClassDB::bind_method(D_METHOD("get_blend_point_position", "point"), &AnimationNodeBlendSpace2D::get_blend_point_position); @@ -666,7 +644,6 @@ void AnimationNodeBlendSpace2D::_bind_methods() { } AnimationNodeBlendSpace2D::AnimationNodeBlendSpace2D() { - for (int i = 0; i < MAX_BLEND_POINTS; i++) { blend_points[i].name = itos(i); } diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 570735ad87..671e86ab3b 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -47,12 +47,10 @@ void AnimationNodeAnimation::get_parameter_list(List *r_list) cons r_list->push_back(PropertyInfo(Variant::FLOAT, time, PROPERTY_HINT_NONE, "", 0)); } void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const { - if (property.name == "animation" && get_editable_animation_list) { Vector names = get_editable_animation_list(); String anims; for (int i = 0; i < names.size(); i++) { - if (i > 0) { anims += ","; } @@ -66,14 +64,12 @@ void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const { } float AnimationNodeAnimation::process(float p_time, bool p_seek) { - AnimationPlayer *ap = state->player; ERR_FAIL_COND_V(!ap, 0); float time = get_parameter(this->time); if (!ap->has_animation(animation)) { - AnimationNodeBlendTree *tree = Object::cast_to(parent); if (tree) { String name = tree->get_node_name(Ref(this)); @@ -101,13 +97,11 @@ float AnimationNodeAnimation::process(float p_time, bool p_seek) { float anim_size = anim->get_length(); if (anim->has_loop()) { - if (anim_size) { time = Math::fposmod(time, anim_size); } } else if (time > anim_size) { - time = anim_size; } @@ -156,56 +150,44 @@ Variant AnimationNodeOneShot::get_parameter_default_value(const StringName &p_pa } void AnimationNodeOneShot::set_fadein_time(float p_time) { - fade_in = p_time; } void AnimationNodeOneShot::set_fadeout_time(float p_time) { - fade_out = p_time; } float AnimationNodeOneShot::get_fadein_time() const { - return fade_in; } float AnimationNodeOneShot::get_fadeout_time() const { - return fade_out; } void AnimationNodeOneShot::set_autorestart(bool p_active) { - autorestart = p_active; } void AnimationNodeOneShot::set_autorestart_delay(float p_time) { - autorestart_delay = p_time; } void AnimationNodeOneShot::set_autorestart_random_delay(float p_time) { - autorestart_random_delay = p_time; } bool AnimationNodeOneShot::has_autorestart() const { - return autorestart; } float AnimationNodeOneShot::get_autorestart_delay() const { - return autorestart_delay; } float AnimationNodeOneShot::get_autorestart_random_delay() const { - return autorestart_random_delay; } void AnimationNodeOneShot::set_mix_mode(MixMode p_mix) { - mix = p_mix; } AnimationNodeOneShot::MixMode AnimationNodeOneShot::get_mix_mode() const { - return mix; } @@ -218,7 +200,6 @@ bool AnimationNodeOneShot::has_filter() const { } float AnimationNodeOneShot::process(float p_time, bool p_seek) { - bool active = get_parameter(this->active); bool prev_active = get_parameter(this->prev_active); float time = get_parameter(this->time); @@ -260,14 +241,12 @@ float AnimationNodeOneShot::process(float p_time, bool p_seek) { float blend; if (time < fade_in) { - if (fade_in > 0) blend = time / fade_in; else blend = 0; //wtf } else if (!do_start && remaining < fade_out) { - if (fade_out) blend = (remaining / fade_out); else @@ -307,17 +286,14 @@ float AnimationNodeOneShot::process(float p_time, bool p_seek) { return MAX(main_rem, remaining); } void AnimationNodeOneShot::set_use_sync(bool p_sync) { - sync = p_sync; } bool AnimationNodeOneShot::is_using_sync() const { - return sync; } void AnimationNodeOneShot::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_fadein_time", "time"), &AnimationNodeOneShot::set_fadein_time); ClassDB::bind_method(D_METHOD("get_fadein_time"), &AnimationNodeOneShot::get_fadein_time); @@ -356,7 +332,6 @@ void AnimationNodeOneShot::_bind_methods() { } AnimationNodeOneShot::AnimationNodeOneShot() { - add_input("in"); add_input("shot"); @@ -389,22 +364,18 @@ String AnimationNodeAdd2::get_caption() const { return "Add2"; } void AnimationNodeAdd2::set_use_sync(bool p_sync) { - sync = p_sync; } bool AnimationNodeAdd2::is_using_sync() const { - return sync; } bool AnimationNodeAdd2::has_filter() const { - return true; } float AnimationNodeAdd2::process(float p_time, bool p_seek) { - float amount = get_parameter(add_amount); float rem0 = blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync); blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync); @@ -413,7 +384,6 @@ float AnimationNodeAdd2::process(float p_time, bool p_seek) { } void AnimationNodeAdd2::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeAdd2::set_use_sync); ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeAdd2::is_using_sync); @@ -421,7 +391,6 @@ void AnimationNodeAdd2::_bind_methods() { } AnimationNodeAdd2::AnimationNodeAdd2() { - add_amount = "add_amount"; add_input("in"); add_input("add"); @@ -441,22 +410,18 @@ String AnimationNodeAdd3::get_caption() const { return "Add3"; } void AnimationNodeAdd3::set_use_sync(bool p_sync) { - sync = p_sync; } bool AnimationNodeAdd3::is_using_sync() const { - return sync; } bool AnimationNodeAdd3::has_filter() const { - return true; } float AnimationNodeAdd3::process(float p_time, bool p_seek) { - float amount = get_parameter(add_amount); blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_PASS, !sync); float rem0 = blend_input(1, p_time, p_seek, 1.0, FILTER_IGNORE, !sync); @@ -466,7 +431,6 @@ float AnimationNodeAdd3::process(float p_time, bool p_seek) { } void AnimationNodeAdd3::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeAdd3::set_use_sync); ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeAdd3::is_using_sync); @@ -474,7 +438,6 @@ void AnimationNodeAdd3::_bind_methods() { } AnimationNodeAdd3::AnimationNodeAdd3() { - add_amount = "add_amount"; add_input("-add"); add_input("in"); @@ -495,7 +458,6 @@ String AnimationNodeBlend2::get_caption() const { } float AnimationNodeBlend2::process(float p_time, bool p_seek) { - float amount = get_parameter(blend_amount); float rem0 = blend_input(0, p_time, p_seek, 1.0 - amount, FILTER_BLEND, !sync); @@ -505,21 +467,17 @@ float AnimationNodeBlend2::process(float p_time, bool p_seek) { } void AnimationNodeBlend2::set_use_sync(bool p_sync) { - sync = p_sync; } bool AnimationNodeBlend2::is_using_sync() const { - return sync; } bool AnimationNodeBlend2::has_filter() const { - return true; } void AnimationNodeBlend2::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeBlend2::set_use_sync); ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeBlend2::is_using_sync); @@ -546,17 +504,14 @@ String AnimationNodeBlend3::get_caption() const { } void AnimationNodeBlend3::set_use_sync(bool p_sync) { - sync = p_sync; } bool AnimationNodeBlend3::is_using_sync() const { - return sync; } float AnimationNodeBlend3::process(float p_time, bool p_seek) { - float amount = get_parameter(blend_amount); float rem0 = blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_IGNORE, !sync); float rem1 = blend_input(1, p_time, p_seek, 1.0 - ABS(amount), FILTER_IGNORE, !sync); @@ -566,7 +521,6 @@ float AnimationNodeBlend3::process(float p_time, bool p_seek) { } void AnimationNodeBlend3::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeBlend3::set_use_sync); ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeBlend3::is_using_sync); @@ -594,7 +548,6 @@ String AnimationNodeTimeScale::get_caption() const { } float AnimationNodeTimeScale::process(float p_time, bool p_seek) { - float scale = get_parameter(this->scale); if (p_seek) { return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false); @@ -624,7 +577,6 @@ String AnimationNodeTimeSeek::get_caption() const { } float AnimationNodeTimeSeek::process(float p_time, bool p_seek) { - float seek_pos = get_parameter(this->seek_pos); if (p_seek) { return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false); @@ -649,7 +601,6 @@ AnimationNodeTimeSeek::AnimationNodeTimeSeek() { ///////////////////////////////////////////////// void AnimationNodeTransition::get_parameter_list(List *r_list) const { - String anims; for (int i = 0; i < enabled_inputs; i++) { if (i > 0) { @@ -728,7 +679,6 @@ float AnimationNodeTransition::get_cross_fade_time() const { } float AnimationNodeTransition::process(float p_time, bool p_seek) { - int current = get_parameter(this->current); int prev = get_parameter(this->prev); int prev_current = get_parameter(this->prev_current); @@ -764,7 +714,6 @@ float AnimationNodeTransition::process(float p_time, bool p_seek) { time += p_time; if (inputs[current].auto_advance && rem <= xfade) { - set_parameter(this->current, (current + 1) % enabled_inputs); } @@ -776,7 +725,6 @@ float AnimationNodeTransition::process(float p_time, bool p_seek) { rem = blend_input(current, 0, true, 1.0 - blend, FILTER_IGNORE, false); } else { - rem = blend_input(current, p_time, p_seek, 1.0 - blend, FILTER_IGNORE, false); } @@ -800,7 +748,6 @@ float AnimationNodeTransition::process(float p_time, bool p_seek) { } void AnimationNodeTransition::_validate_property(PropertyInfo &property) const { - if (property.name.begins_with("input_")) { String n = property.name.get_slicec('/', 0).get_slicec('_', 1); if (n != "count") { @@ -815,7 +762,6 @@ void AnimationNodeTransition::_validate_property(PropertyInfo &property) const { } void AnimationNodeTransition::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_enabled_inputs", "amount"), &AnimationNodeTransition::set_enabled_inputs); ClassDB::bind_method(D_METHOD("get_enabled_inputs"), &AnimationNodeTransition::get_enabled_inputs); @@ -838,7 +784,6 @@ void AnimationNodeTransition::_bind_methods() { } AnimationNodeTransition::AnimationNodeTransition() { - prev_xfading = "prev_xfading"; prev = "prev"; time = "time"; @@ -869,7 +814,6 @@ AnimationNodeOutput::AnimationNodeOutput() { /////////////////////////////////////////////////////// void AnimationNodeBlendTree::add_node(const StringName &p_name, Ref p_node, const Vector2 &p_position) { - ERR_FAIL_COND(nodes.has(p_name)); ERR_FAIL_COND(p_node.is_null()); ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output); @@ -889,7 +833,6 @@ void AnimationNodeBlendTree::add_node(const StringName &p_name, Ref AnimationNodeBlendTree::get_node(const StringName &p_name) const { - ERR_FAIL_COND_V(!nodes.has(p_name), Ref()); return nodes[p_name].node; @@ -936,12 +879,10 @@ bool AnimationNodeBlendTree::has_node(const StringName &p_name) const { return nodes.has(p_name); } Vector AnimationNodeBlendTree::get_node_connection_array(const StringName &p_name) const { - ERR_FAIL_COND_V(!nodes.has(p_name), Vector()); return nodes[p_name].connections; } void AnimationNodeBlendTree::remove_node(const StringName &p_name) { - ERR_FAIL_COND(!nodes.has(p_name)); ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output); //can't delete output @@ -967,7 +908,6 @@ void AnimationNodeBlendTree::remove_node(const StringName &p_name) { } void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringName &p_new_name) { - ERR_FAIL_COND(!nodes.has(p_name)); ERR_FAIL_COND(nodes.has(p_new_name)); ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output); @@ -980,7 +920,6 @@ void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringN //rename connections for (Map::Element *E = nodes.front(); E; E = E->next()) { - for (int i = 0; i < E->get().connections.size(); i++) { if (E->get().connections[i] == p_name) { E->get().connections.write[i] = p_new_name; @@ -994,7 +933,6 @@ void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringN } void AnimationNodeBlendTree::connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) { - ERR_FAIL_COND(!nodes.has(p_output_node)); ERR_FAIL_COND(!nodes.has(p_input_node)); ERR_FAIL_COND(p_output_node == SceneStringNames::get_singleton()->output); @@ -1016,7 +954,6 @@ void AnimationNodeBlendTree::connect_node(const StringName &p_input_node, int p_ } void AnimationNodeBlendTree::disconnect_node(const StringName &p_node, int p_input_index) { - ERR_FAIL_COND(!nodes.has(p_node)); Ref input = nodes[p_node].node; @@ -1026,7 +963,6 @@ void AnimationNodeBlendTree::disconnect_node(const StringName &p_node, int p_inp } AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) const { - if (!nodes.has(p_output_node) || p_output_node == SceneStringNames::get_singleton()->output) { return CONNECTION_ERROR_NO_OUTPUT; } @@ -1061,7 +997,6 @@ AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node } void AnimationNodeBlendTree::get_node_connections(List *r_connections) const { - for (Map::Element *E = nodes.front(); E; E = E->next()) { for (int i = 0; i < E->get().connections.size(); i++) { StringName output = E->get().connections[i]; @@ -1081,25 +1016,21 @@ String AnimationNodeBlendTree::get_caption() const { } float AnimationNodeBlendTree::process(float p_time, bool p_seek) { - Ref output = nodes[SceneStringNames::get_singleton()->output].node; return _blend_node("output", nodes[SceneStringNames::get_singleton()->output].connections, this, output, p_time, p_seek, 1.0); } void AnimationNodeBlendTree::get_node_list(List *r_list) { - for (Map::Element *E = nodes.front(); E; E = E->next()) { r_list->push_back(E->key()); } } void AnimationNodeBlendTree::set_graph_offset(const Vector2 &p_graph_offset) { - graph_offset = p_graph_offset; } Vector2 AnimationNodeBlendTree::get_graph_offset() const { - return graph_offset; } @@ -1108,10 +1039,8 @@ Ref AnimationNodeBlendTree::get_child_by_name(const StringName &p } bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; if (name.begins_with("nodes/")) { - String node_name = name.get_slicec('/', 1); String what = name.get_slicec('/', 2); @@ -1124,14 +1053,12 @@ bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_val } if (what == "position") { - if (nodes.has(node_name)) { nodes[node_name].position = p_value; } return true; } } else if (name == "node_connections") { - Array conns = p_value; ERR_FAIL_COND_V(conns.size() % 3 != 0, false); @@ -1145,7 +1072,6 @@ bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_val } bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; if (name.begins_with("nodes/")) { String node_name = name.get_slicec('/', 1); @@ -1159,7 +1085,6 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons } if (what == "position") { - if (nodes.has(node_name)) { r_ret = nodes[node_name].position; return true; @@ -1186,7 +1111,6 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons return false; } void AnimationNodeBlendTree::_get_property_list(List *p_list) const { - List names; for (Map::Element *E = nodes.front(); E; E = E->next()) { names.push_back(E->key()); @@ -1209,13 +1133,11 @@ void AnimationNodeBlendTree::_tree_changed() { } void AnimationNodeBlendTree::_node_changed(const StringName &p_node) { - ERR_FAIL_COND(!nodes.has(p_node)); nodes[p_node].connections.resize(nodes[p_node].node->get_input_count()); } void AnimationNodeBlendTree::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_node", "name", "node", "position"), &AnimationNodeBlendTree::add_node, DEFVAL(Vector2())); ClassDB::bind_method(D_METHOD("get_node", "name"), &AnimationNodeBlendTree::get_node); ClassDB::bind_method(D_METHOD("remove_node", "name"), &AnimationNodeBlendTree::remove_node); @@ -1241,7 +1163,6 @@ void AnimationNodeBlendTree::_bind_methods() { } AnimationNodeBlendTree::AnimationNodeBlendTree() { - Ref output; output.instance(); Node n; diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h index 7ebe3f5444..5c722d00f9 100644 --- a/scene/animation/animation_blend_tree.h +++ b/scene/animation/animation_blend_tree.h @@ -34,7 +34,6 @@ #include "scene/animation/animation_tree.h" class AnimationNodeAnimation : public AnimationRootNode { - GDCLASS(AnimationNodeAnimation, AnimationRootNode); StringName animation; @@ -268,7 +267,6 @@ class AnimationNodeTransition : public AnimationNode { MAX_INPUTS = 32 }; struct InputData { - String name; bool auto_advance; InputData() { auto_advance = false; } diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index ab8be47b4d..1eea73fab8 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -31,7 +31,6 @@ #include "animation_cache.h" void AnimationCache::_node_exit_tree(Node *p_node) { - //it is one shot, so it disconnects upon arrival ERR_FAIL_COND(!connected_nodes.has(p_node)); @@ -39,7 +38,6 @@ void AnimationCache::_node_exit_tree(Node *p_node) { connected_nodes.erase(p_node); for (int i = 0; i < path_cache.size(); i++) { - if (path_cache[i].node != p_node) continue; @@ -48,14 +46,11 @@ void AnimationCache::_node_exit_tree(Node *p_node) { } void AnimationCache::_animation_changed() { - _clear_cache(); } void AnimationCache::_clear_cache() { - while (connected_nodes.size()) { - connected_nodes.front()->get()->disconnect("tree_exiting", callable_mp(this, &AnimationCache::_node_exit_tree)); connected_nodes.erase(connected_nodes.front()); } @@ -65,7 +60,6 @@ void AnimationCache::_clear_cache() { } void AnimationCache::_update_cache() { - cache_valid = false; ERR_FAIL_COND(!root); @@ -73,12 +67,10 @@ void AnimationCache::_update_cache() { ERR_FAIL_COND(animation.is_null()); for (int i = 0; i < animation->get_track_count(); i++) { - NodePath np = animation->track_get_path(i); Node *node = root->get_node(np); if (!node) { - path_cache.push_back(Path()); ERR_CONTINUE_MSG(!node, "Invalid track path in animation '" + np + "'."); } @@ -88,7 +80,6 @@ void AnimationCache::_update_cache() { Ref res; if (animation->track_get_type(i) == Animation::TYPE_TRANSFORM) { - if (np.get_subname_count() > 1) { path_cache.push_back(Path()); ERR_CONTINUE_MSG(animation->track_get_type(i) == Animation::TYPE_TRANSFORM, "Transform tracks can't have a subpath '" + np + "'."); @@ -97,7 +88,6 @@ void AnimationCache::_update_cache() { Node3D *sp = Object::cast_to(node); if (!sp) { - path_cache.push_back(Path()); ERR_CONTINUE_MSG(!sp, "Transform track not of type Node3D '" + np + "'."); } @@ -108,7 +98,6 @@ void AnimationCache::_update_cache() { Skeleton3D *sk = Object::cast_to(node); if (!sk) { - path_cache.push_back(Path()); ERR_CONTINUE_MSG(!sk, "Property defined in Transform track, but not a Skeleton! '" + np + "'."); } @@ -127,7 +116,6 @@ void AnimationCache::_update_cache() { } else { if (np.get_subname_count() > 0) { - RES res2; Vector leftover_subpath; @@ -144,7 +132,6 @@ void AnimationCache::_update_cache() { path.subpath = leftover_subpath; } else { - path.node = node; path.object = node; path.subpath = np.get_subnames(); @@ -152,15 +139,12 @@ void AnimationCache::_update_cache() { } if (animation->track_get_type(i) == Animation::TYPE_VALUE) { - if (np.get_subname_count() == 0) { - path_cache.push_back(Path()); ERR_CONTINUE_MSG(np.get_subname_count() == 0, "Value Track lacks property: " + np + "."); } } else if (animation->track_get_type(i) == Animation::TYPE_METHOD) { - if (path.subpath.size() != 0) { // Trying to call a method of a non-resource path_cache.push_back(Path()); @@ -183,7 +167,6 @@ void AnimationCache::_update_cache() { } void AnimationCache::set_track_transform(int p_idx, const Transform &p_transform) { - if (cache_dirty) _update_cache(); @@ -204,7 +187,6 @@ void AnimationCache::set_track_transform(int p_idx, const Transform &p_transform } void AnimationCache::set_track_value(int p_idx, const Variant &p_value) { - if (cache_dirty) _update_cache(); @@ -219,7 +201,6 @@ void AnimationCache::set_track_value(int p_idx, const Variant &p_value) { } void AnimationCache::call_track(int p_idx, const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - if (cache_dirty) _update_cache(); @@ -234,7 +215,6 @@ void AnimationCache::call_track(int p_idx, const StringName &p_method, const Var } void AnimationCache::set_all(float p_time, float p_delta) { - if (cache_dirty) _update_cache(); @@ -242,11 +222,8 @@ void AnimationCache::set_all(float p_time, float p_delta) { int tc = animation->get_track_count(); for (int i = 0; i < tc; i++) { - switch (animation->track_get_type(i)) { - case Animation::TYPE_TRANSFORM: { - Vector3 loc, scale; Quat rot; animation->transform_track_interpolate(i, p_time, &loc, &rot, &scale); @@ -257,17 +234,14 @@ void AnimationCache::set_all(float p_time, float p_delta) { } break; case Animation::TYPE_VALUE: { - if (animation->value_track_get_update_mode(i) == Animation::UPDATE_CONTINUOUS || (animation->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE && p_delta == 0)) { Variant v = animation->value_track_interpolate(i, p_time); set_track_value(i, v); } else { - List indices; animation->value_track_get_key_indices(i, p_time, p_delta, &indices); for (List::Element *E = indices.front(); E; E = E->next()) { - Variant v = animation->track_get_key_value(i, E->get()); set_track_value(i, v); } @@ -275,25 +249,20 @@ void AnimationCache::set_all(float p_time, float p_delta) { } break; case Animation::TYPE_METHOD: { - List indices; animation->method_track_get_key_indices(i, p_time, p_delta, &indices); for (List::Element *E = indices.front(); E; E = E->next()) { - Vector args = animation->method_track_get_params(i, E->get()); StringName name = animation->method_track_get_name(i, E->get()); Callable::CallError err; if (!args.size()) { - call_track(i, name, nullptr, 0, err); } else { - Vector argptrs; argptrs.resize(args.size()); for (int j = 0; j < args.size(); j++) { - argptrs.write[j] = &args.write[j]; } @@ -309,7 +278,6 @@ void AnimationCache::set_all(float p_time, float p_delta) { } void AnimationCache::set_animation(const Ref &p_animation) { - _clear_cache(); if (animation.is_valid()) @@ -325,13 +293,11 @@ void AnimationCache::_bind_methods() { } void AnimationCache::set_root(Node *p_root) { - _clear_cache(); root = p_root; } AnimationCache::AnimationCache() { - root = nullptr; cache_dirty = true; cache_valid = false; diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h index 23312ca7ec..feff1d364a 100644 --- a/scene/animation/animation_cache.h +++ b/scene/animation/animation_cache.h @@ -35,11 +35,9 @@ #include "scene/resources/animation.h" class AnimationCache : public Object { - GDCLASS(AnimationCache, Object); struct Path { - RES resource; Object *object; Skeleton3D *skeleton; // haxor diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 9f5e06c43d..4a387772a8 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -33,12 +33,10 @@ ///////////////////////////////////////////////// void AnimationNodeStateMachineTransition::set_switch_mode(SwitchMode p_mode) { - switch_mode = p_mode; } AnimationNodeStateMachineTransition::SwitchMode AnimationNodeStateMachineTransition::get_switch_mode() const { - return switch_mode; } @@ -71,7 +69,6 @@ StringName AnimationNodeStateMachineTransition::get_advance_condition_name() con } void AnimationNodeStateMachineTransition::set_xfade_time(float p_xfade) { - ERR_FAIL_COND(p_xfade < 0); xfade = p_xfade; emit_changed(); @@ -133,7 +130,6 @@ void AnimationNodeStateMachineTransition::_bind_methods() { } AnimationNodeStateMachineTransition::AnimationNodeStateMachineTransition() { - switch_mode = SWITCH_MODE_IMMEDIATE; auto_advance = false; xfade = 0; @@ -144,7 +140,6 @@ AnimationNodeStateMachineTransition::AnimationNodeStateMachineTransition() { //////////////////////////////////////////////////////// void AnimationNodeStateMachinePlayback::travel(const StringName &p_state) { - start_request_travel = true; start_request = p_state; stop_request = false; @@ -156,7 +151,6 @@ void AnimationNodeStateMachinePlayback::start(const StringName &p_state) { stop_request = false; } void AnimationNodeStateMachinePlayback::stop() { - stop_request = true; } bool AnimationNodeStateMachinePlayback::is_playing() const { @@ -179,7 +173,6 @@ float AnimationNodeStateMachinePlayback::get_current_length() const { } bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_state_machine, const StringName &p_travel) { - ERR_FAIL_COND_V(!playing, false); ERR_FAIL_COND_V(!p_state_machine->states.has(p_travel), false); ERR_FAIL_COND_V(!p_state_machine->states.has(current), false); @@ -219,7 +212,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta //begin astar bool found_route = false; while (!found_route) { - if (open_list.size() == 0) { return false; //no path found } @@ -229,7 +221,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta float least_cost = 1e20; for (List::Element *E = open_list.front(); E; E = E->next()) { - float cost = cost_map[p_state_machine->transitions[E->get()].to].distance; cost += p_state_machine->states[p_state_machine->transitions[E->get()].to].position.distance_to(target_pos); @@ -293,7 +284,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta } float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_state_machine, float p_time, bool p_seek) { - //if not playing and it can restart, then restart if (!playing && start_request == StringName()) { if (!stop_request && p_state_machine->start_node) { @@ -347,7 +337,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st bool do_start = (p_seek && p_time == 0) || play_start || current == StringName(); if (do_start) { - if (p_state_machine->start_node != StringName() && p_seek && p_time == 0) { current = p_state_machine->start_node; } @@ -365,7 +354,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st float fade_blend = 1.0; if (fading_from != StringName()) { - if (!p_state_machine->states.has(fading_from)) { fading_from = StringName(); } else { @@ -382,7 +370,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st float rem = p_state_machine->blend_node(current, p_state_machine->states[current].node, p_time, p_seek, fade_blend, AnimationNode::FILTER_IGNORE, false); if (fading_from != StringName()) { - p_state_machine->blend_node(fading_from, p_state_machine->states[fading_from].node, p_time, p_seek, 1.0 - fade_blend, AnimationNode::FILTER_IGNORE, false); } @@ -407,7 +394,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st AnimationNodeStateMachineTransition::SwitchMode switch_mode = AnimationNodeStateMachineTransition::SWITCH_MODE_IMMEDIATE; if (path.size()) { - for (int i = 0; i < p_state_machine->transitions.size(); i++) { if (p_state_machine->transitions[i].from == current && p_state_machine->transitions[i].to == path[0]) { next_xfade = p_state_machine->transitions[i].transition->get_xfade_time(); @@ -419,7 +405,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st float priority_best = 1e20; int auto_advance_to = -1; for (int i = 0; i < p_state_machine->transitions.size(); i++) { - bool auto_advance = false; if (p_state_machine->transitions[i].transition->has_auto_advance()) { auto_advance = true; @@ -430,7 +415,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st } if (p_state_machine->transitions[i].from == current && auto_advance) { - if (p_state_machine->transitions[i].transition->get_priority() <= priority_best) { priority_best = p_state_machine->transitions[i].transition->get_priority(); auto_advance_to = i; @@ -447,7 +431,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st //if next, see when to transition if (next != StringName()) { - bool goto_next = false; if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_AT_END) { @@ -492,7 +475,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st //compute time left for transitions by using the end node if (p_state_machine->end_node != StringName() && p_state_machine->end_node != current) { - rem = p_state_machine->blend_node(p_state_machine->end_node, p_state_machine->states[p_state_machine->end_node].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false); } @@ -500,7 +482,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st } void AnimationNodeStateMachinePlayback::_bind_methods() { - ClassDB::bind_method(D_METHOD("travel", "to_node"), &AnimationNodeStateMachinePlayback::travel); ClassDB::bind_method(D_METHOD("start", "node"), &AnimationNodeStateMachinePlayback::start); ClassDB::bind_method(D_METHOD("stop"), &AnimationNodeStateMachinePlayback::stop); @@ -542,7 +523,6 @@ void AnimationNodeStateMachine::get_parameter_list(List *r_list) c } Variant AnimationNodeStateMachine::get_parameter_default_value(const StringName &p_parameter) const { - if (p_parameter == playback) { Ref p; p.instance(); @@ -553,7 +533,6 @@ Variant AnimationNodeStateMachine::get_parameter_default_value(const StringName } void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref p_node, const Vector2 &p_position) { - ERR_FAIL_COND(states.has(p_name)); ERR_FAIL_COND(p_node.is_null()); ERR_FAIL_COND(String(p_name).find("/") != -1); @@ -571,7 +550,6 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref p_node) { - ERR_FAIL_COND(states.has(p_name) == false); ERR_FAIL_COND(p_node.is_null()); ERR_FAIL_COND(String(p_name).find("/") != -1); @@ -592,7 +570,6 @@ void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref AnimationNodeStateMachine::get_node(const StringName &p_name) const { - ERR_FAIL_COND_V(!states.has(p_name), Ref()); return states[p_name].node; @@ -629,7 +606,6 @@ bool AnimationNodeStateMachine::has_node(const StringName &p_name) const { return states.has(p_name); } void AnimationNodeStateMachine::remove_node(const StringName &p_name) { - ERR_FAIL_COND(!states.has(p_name)); { @@ -668,7 +644,6 @@ void AnimationNodeStateMachine::remove_node(const StringName &p_name) { } void AnimationNodeStateMachine::rename_node(const StringName &p_name, const StringName &p_new_name) { - ERR_FAIL_COND(!states.has(p_name)); ERR_FAIL_COND(states.has(p_new_name)); @@ -702,7 +677,6 @@ void AnimationNodeStateMachine::rename_node(const StringName &p_name, const Stri } void AnimationNodeStateMachine::get_node_list(List *r_nodes) const { - List nodes; for (Map::Element *E = states.front(); E; E = E->next()) { nodes.push_back(E->key()); @@ -715,7 +689,6 @@ void AnimationNodeStateMachine::get_node_list(List *r_nodes) const { } bool AnimationNodeStateMachine::has_transition(const StringName &p_from, const StringName &p_to) const { - for (int i = 0; i < transitions.size(); i++) { if (transitions[i].from == p_from && transitions[i].to == p_to) return true; @@ -724,7 +697,6 @@ bool AnimationNodeStateMachine::has_transition(const StringName &p_from, const S } int AnimationNodeStateMachine::find_transition(const StringName &p_from, const StringName &p_to) const { - for (int i = 0; i < transitions.size(); i++) { if (transitions[i].from == p_from && transitions[i].to == p_to) return i; @@ -733,7 +705,6 @@ int AnimationNodeStateMachine::find_transition(const StringName &p_from, const S } void AnimationNodeStateMachine::add_transition(const StringName &p_from, const StringName &p_to, const Ref &p_transition) { - ERR_FAIL_COND(p_from == p_to); ERR_FAIL_COND(!states.has(p_from)); ERR_FAIL_COND(!states.has(p_to)); @@ -758,22 +729,18 @@ Ref AnimationNodeStateMachine::get_transiti return transitions[p_transition].transition; } StringName AnimationNodeStateMachine::get_transition_from(int p_transition) const { - ERR_FAIL_INDEX_V(p_transition, transitions.size(), StringName()); return transitions[p_transition].from; } StringName AnimationNodeStateMachine::get_transition_to(int p_transition) const { - ERR_FAIL_INDEX_V(p_transition, transitions.size(), StringName()); return transitions[p_transition].to; } int AnimationNodeStateMachine::get_transition_count() const { - return transitions.size(); } void AnimationNodeStateMachine::remove_transition(const StringName &p_from, const StringName &p_to) { - for (int i = 0; i < transitions.size(); i++) { if (transitions[i].from == p_from && transitions[i].to == p_to) { transitions.write[i].transition->disconnect("advance_condition_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed)); @@ -788,7 +755,6 @@ void AnimationNodeStateMachine::remove_transition(const StringName &p_from, cons } void AnimationNodeStateMachine::remove_transition_by_index(int p_transition) { - ERR_FAIL_INDEX(p_transition, transitions.size()); transitions.write[p_transition].transition->disconnect("advance_condition_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed)); transitions.remove(p_transition); @@ -798,24 +764,20 @@ void AnimationNodeStateMachine::remove_transition_by_index(int p_transition) { } void AnimationNodeStateMachine::set_start_node(const StringName &p_node) { - ERR_FAIL_COND(p_node != StringName() && !states.has(p_node)); start_node = p_node; } String AnimationNodeStateMachine::get_start_node() const { - return start_node; } void AnimationNodeStateMachine::set_end_node(const StringName &p_node) { - ERR_FAIL_COND(p_node != StringName() && !states.has(p_node)); end_node = p_node; } String AnimationNodeStateMachine::get_end_node() const { - return end_node; } @@ -828,7 +790,6 @@ Vector2 AnimationNodeStateMachine::get_graph_offset() const { } float AnimationNodeStateMachine::process(float p_time, bool p_seek) { - Ref playback = get_parameter(this->playback); ERR_FAIL_COND_V(playback.is_null(), 0.0); @@ -847,7 +808,6 @@ Ref AnimationNodeStateMachine::get_child_by_name(const StringName } bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; if (name.begins_with("states/")) { String node_name = name.get_slicec('/', 1); @@ -862,14 +822,12 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_ } if (what == "position") { - if (states.has(node_name)) { states[node_name].position = p_value; } return true; } } else if (name == "transitions") { - Array trans = p_value; ERR_FAIL_COND_V(trans.size() % 3 != 0, false); @@ -892,7 +850,6 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_ } bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; if (name.begins_with("states/")) { String node_name = name.get_slicec('/', 1); @@ -906,7 +863,6 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c } if (what == "position") { - if (states.has(node_name)) { r_ret = states[node_name].position; return true; @@ -938,7 +894,6 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c return false; } void AnimationNodeStateMachine::_get_property_list(List *p_list) const { - List names; for (Map::Element *E = states.front(); E; E = E->next()) { names.push_back(E->key()); @@ -963,7 +918,6 @@ void AnimationNodeStateMachine::set_node_position(const StringName &p_name, cons } Vector2 AnimationNodeStateMachine::get_node_position(const StringName &p_name) const { - ERR_FAIL_COND_V(!states.has(p_name), Vector2()); return states[p_name].position; } @@ -973,7 +927,6 @@ void AnimationNodeStateMachine::_tree_changed() { } void AnimationNodeStateMachine::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_node", "name", "node", "position"), &AnimationNodeStateMachine::add_node, DEFVAL(Vector2())); ClassDB::bind_method(D_METHOD("replace_node", "name", "node"), &AnimationNodeStateMachine::replace_node); ClassDB::bind_method(D_METHOD("get_node", "name"), &AnimationNodeStateMachine::get_node); @@ -1005,6 +958,5 @@ void AnimationNodeStateMachine::_bind_methods() { } AnimationNodeStateMachine::AnimationNodeStateMachine() { - playback = "playback"; } diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h index 27a4451f08..72fa6f77d0 100644 --- a/scene/animation/animation_node_state_machine.h +++ b/scene/animation/animation_node_state_machine.h @@ -134,7 +134,6 @@ public: }; class AnimationNodeStateMachine : public AnimationRootNode { - GDCLASS(AnimationNodeStateMachine, AnimationRootNode); private: @@ -148,7 +147,6 @@ private: Map states; struct Transition { - StringName from; StringName to; Ref transition; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 7bac09f839..c6bd1fc531 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -40,7 +40,6 @@ #include "scene/2d/skeleton_2d.h" void AnimatedValuesBackup::update_skeletons() { - for (int i = 0; i < entries.size(); i++) { if (entries[i].bone_idx != -1) { // 3D bone @@ -57,7 +56,6 @@ void AnimatedValuesBackup::update_skeletons() { #endif bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; if (name.begins_with("playback/play")) { // bw compatibility @@ -65,23 +63,19 @@ bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) { set_current_animation(p_value); } else if (name.begins_with("anims/")) { - String which = name.get_slicec('/', 1); add_animation(which, p_value); } else if (name.begins_with("next/")) { - String which = name.get_slicec('/', 1); animation_set_next(which, p_value); } else if (p_name == SceneStringNames::get_singleton()->blend_times) { - Array array = p_value; int len = array.size(); ERR_FAIL_COND_V(len % 3, false); for (int i = 0; i < len / 3; i++) { - StringName from = array[i * 3 + 0]; StringName to = array[i * 3 + 1]; float time = array[i * 3 + 2]; @@ -96,7 +90,6 @@ bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) { } bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; if (name == "playback/play") { // bw compatibility @@ -104,27 +97,22 @@ bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const { r_ret = get_current_animation(); } else if (name.begins_with("anims/")) { - String which = name.get_slicec('/', 1); r_ret = get_animation(which); } else if (name.begins_with("next/")) { - String which = name.get_slicec('/', 1); r_ret = animation_get_next(which); } else if (name == "blend_times") { - Vector keys; for (Map::Element *E = blend_times.front(); E; E = E->next()) { - keys.ordered_insert(E->key()); } Array array; for (int i = 0; i < keys.size(); i++) { - array.push_back(keys[i].from); array.push_back(keys[i].to); array.push_back(blend_times[keys[i]]); @@ -138,7 +126,6 @@ bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const { } void AnimationPlayer::_validate_property(PropertyInfo &property) const { - if (property.name == "current_animation") { List names; @@ -149,7 +136,6 @@ void AnimationPlayer::_validate_property(PropertyInfo &property) const { names.push_front("[stop]"); String hint; for (List::Element *E = names.front(); E; E = E->next()) { - if (E != names.front()) hint += ","; hint += E->get(); @@ -160,11 +146,9 @@ void AnimationPlayer::_validate_property(PropertyInfo &property) const { } void AnimationPlayer::_get_property_list(List *p_list) const { - List anim_names; for (Map::Element *E = animation_set.front(); E; E = E->next()) { - anim_names.push_back(PropertyInfo(Variant::OBJECT, "anims/" + String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE)); if (E->get().next != StringName()) anim_names.push_back(PropertyInfo(Variant::STRING, "next/" + String(E->key()), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); @@ -180,16 +164,12 @@ void AnimationPlayer::_get_property_list(List *p_list) const { } void AnimationPlayer::advance(float p_time) { - _animation_process(p_time); } void AnimationPlayer::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - if (!processing) { //make sure that a previous process state was not saved //only process if "processing" is set @@ -200,7 +180,6 @@ void AnimationPlayer::_notification(int p_what) { clear_caches(); } break; case NOTIFICATION_READY: { - if (!Engine::get_singleton()->is_editor_hint() && animation_set.has(autoplay)) { play(autoplay); _animation_process(0); @@ -214,7 +193,6 @@ void AnimationPlayer::_notification(int p_what) { _animation_process(get_process_delta_time()); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - if (animation_process_mode == ANIMATION_PROCESS_IDLE) break; @@ -222,14 +200,12 @@ void AnimationPlayer::_notification(int p_what) { _animation_process(get_physics_process_delta_time()); } break; case NOTIFICATION_EXIT_TREE: { - clear_caches(); } break; } } void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { - // Already cached? if (p_anim->node_cache.size() == p_anim->animation->get_track_count()) return; @@ -243,7 +219,6 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { p_anim->node_cache.resize(a->get_track_count()); for (int i = 0; i < a->get_track_count(); i++) { - p_anim->node_cache.write[i] = nullptr; RES resource; Vector leftover_path; @@ -253,11 +228,9 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { int bone_idx = -1; if (a->track_get_path(i).get_subname_count() == 1 && Object::cast_to(child)) { - Skeleton3D *sk = Object::cast_to(child); bone_idx = sk->find_bone(a->track_get_path(i).get_subname(0)); if (bone_idx == -1) { - continue; } } @@ -305,16 +278,13 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { } if (a->track_get_type(i) == Animation::TYPE_VALUE) { - if (!p_anim->node_cache[i]->property_anim.has(a->track_get_path(i).get_concatenated_subnames())) { - TrackNodeCache::PropertyAnim pa; pa.subpath = leftover_path; pa.object = resource.is_valid() ? (Object *)resource.ptr() : (Object *)child; pa.special = SP_NONE; pa.owner = p_anim->node_cache[i]; if (false && p_anim->node_cache[i]->node_2d) { - if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_pos) pa.special = SP_NODE2D_POS; else if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_rot) @@ -327,9 +297,7 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { } if (a->track_get_type(i) == Animation::TYPE_BEZIER && leftover_path.size()) { - if (!p_anim->node_cache[i]->bezier_anim.has(a->track_get_path(i).get_concatenated_subnames())) { - TrackNodeCache::BezierAnim ba; ba.bezier_property = leftover_path; ba.object = resource.is_valid() ? (Object *)resource.ptr() : (Object *)child; @@ -342,7 +310,6 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { } void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float p_time, float p_delta, float p_interp, bool p_is_current, bool p_seeked, bool p_started) { - _ensure_node_caches(p_anim); ERR_FAIL_COND(p_anim->node_cache.size() != p_anim->animation->get_track_count()); @@ -350,7 +317,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint(); for (int i = 0; i < a->get_track_count(); i++) { - // If an animation changes this animation (or it animates itself) // we need to recreate our animation cache if (p_anim->node_cache.size() != a->get_track_count()) { @@ -369,9 +335,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float continue; // do nothing if track is empty switch (a->track_get_type(i)) { - case Animation::TYPE_TRANSFORM: { - if (!nc->spatial) continue; @@ -394,7 +358,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float nc->scale_accum = scale; } else { - nc->loc_accum = nc->loc_accum.lerp(loc, p_interp); nc->rot_accum = nc->rot_accum.slerp(rot, p_interp); nc->scale_accum = nc->scale_accum.lerp(scale, p_interp); @@ -402,7 +365,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } break; case Animation::TYPE_VALUE: { - if (!nc->node) continue; @@ -416,7 +378,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float Animation::UpdateMode update_mode = a->value_track_get_update_mode(i); if (update_mode == Animation::UPDATE_CAPTURE) { - if (p_started) { pa->capture = pa->object->get_indexed(pa->subpath); } @@ -479,15 +440,12 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } } else if (p_is_current && p_delta != 0) { - List indices; a->value_track_get_key_indices(i, p_time, p_delta, &indices); for (List::Element *F = indices.front(); F; F = F->next()) { - Variant value = a->track_get_key_value(i, F->get()); switch (pa->special) { - case SP_NONE: { bool valid; pa->object->set_indexed(pa->subpath, value, &valid); //you are not speshul @@ -530,7 +488,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } break; case Animation::TYPE_METHOD: { - if (!nc->node) continue; if (p_delta == 0) { @@ -544,7 +501,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float a->method_track_get_key_indices(i, p_time, p_delta, &indices); for (List::Element *E = indices.front(); E; E = E->next()) { - StringName method = a->method_track_get_name(i, E->get()); Vector params = a->method_track_get_params(i, E->get()); @@ -581,7 +537,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } break; case Animation::TYPE_BEZIER: { - if (!nc->node) continue; @@ -602,7 +557,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } break; case Animation::TYPE_AUDIO: { - if (!nc->node) continue; if (p_delta == 0) { @@ -678,7 +632,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float nc->audio_start = p_time; } } else if (nc->audio_playing) { - bool loop = a->has_loop(); bool stop = false; @@ -704,7 +657,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } break; case Animation::TYPE_ANIMATION: { - AnimationPlayer *player = Object::cast_to(nc->node); if (!player) continue; @@ -749,7 +701,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float StringName anim_name = a->animation_track_get_key_animation(i, idx); if (String(anim_name) == "[stop]" || !player->has_animation(anim_name)) { - if (playing_caches.has(nc)) { playing_caches.erase(nc); player->stop(); @@ -769,7 +720,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, float p_blend, bool p_seeked, bool p_started) { - float delta = p_delta * speed_scale * cd.speed_scale; float next_pos = cd.pos + delta; @@ -777,7 +727,6 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f bool loop = cd.from->animation->has_loop(); if (!loop) { - if (next_pos < 0) next_pos = 0; else if (next_pos > len) @@ -787,7 +736,6 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f delta = next_pos - cd.pos; if (&cd == &playback.current) { - bool backwards = delta < 0; if (!backwards && cd.pos <= len && next_pos == len /*&& playback.blend.empty()*/) { @@ -804,7 +752,6 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f } } else { - float looped_next_pos = Math::fposmod(next_pos, len); if (looped_next_pos == 0 && next_pos != 0) { // Loop multiples of the length to it, rather than 0 @@ -820,7 +767,6 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f _animation_process_animation(cd.from, cd.pos, delta, p_blend, &cd == &playback.current, p_seeked, p_started); } void AnimationPlayer::_animation_process2(float p_delta, bool p_started) { - Playback &c = playback; accum_pass++; @@ -832,7 +778,6 @@ void AnimationPlayer::_animation_process2(float p_delta, bool p_started) { List::Element *prev = nullptr; for (List::Element *E = c.blend.back(); E; E = prev) { - Blend &b = E->get(); float blend = b.blend_left / b.blend_time; _animation_process_data(b.data, p_delta, blend, false, false); @@ -841,7 +786,6 @@ void AnimationPlayer::_animation_process2(float p_delta, bool p_started) { prev = E->prev(); if (b.blend_left < 0) { - c.blend.erase(E); } } @@ -851,7 +795,6 @@ void AnimationPlayer::_animation_update_transforms() { { Transform t; for (int i = 0; i < cache_update_size; i++) { - TrackNodeCache *nc = cache_update[i]; ERR_CONTINUE(nc->accum_pass != accum_pass); @@ -859,11 +802,9 @@ void AnimationPlayer::_animation_update_transforms() { t.origin = nc->loc_accum; t.basis.set_quat_scale(nc->rot_accum, nc->scale_accum); if (nc->skeleton && nc->bone_idx >= 0) { - nc->skeleton->set_bone_pose(nc->bone_idx, t); } else if (nc->spatial) { - nc->spatial->set_transform(t); } } @@ -872,13 +813,11 @@ void AnimationPlayer::_animation_update_transforms() { cache_update_size = 0; for (int i = 0; i < cache_update_prop_size; i++) { - TrackNodeCache::PropertyAnim *pa = cache_update_prop[i]; ERR_CONTINUE(pa->accum_pass != accum_pass); switch (pa->special) { - case SP_NONE: { bool valid; pa->object->set_indexed(pa->subpath, pa->value_accum, &valid); //you are not speshul @@ -921,7 +860,6 @@ void AnimationPlayer::_animation_update_transforms() { cache_update_prop_size = 0; for (int i = 0; i < cache_update_bezier_size; i++) { - TrackNodeCache::BezierAnim *ba = cache_update_bezier[i]; ERR_CONTINUE(ba->accum_pass != accum_pass); @@ -932,9 +870,7 @@ void AnimationPlayer::_animation_update_transforms() { } void AnimationPlayer::_animation_process(float p_delta) { - if (playback.current.from) { - end_reached = false; end_notify = false; _animation_process2(p_delta, playback.started); @@ -968,7 +904,6 @@ void AnimationPlayer::_animation_process(float p_delta) { } Error AnimationPlayer::add_animation(const StringName &p_name, const Ref &p_animation) { - #ifdef DEBUG_ENABLED ERR_FAIL_COND_V_MSG(String(p_name).find("/") != -1 || String(p_name).find(":") != -1 || String(p_name).find(",") != -1 || String(p_name).find("[") != -1, ERR_INVALID_PARAMETER, "Invalid animation name: " + String(p_name) + "."); #endif @@ -976,12 +911,10 @@ Error AnimationPlayer::add_animation(const StringName &p_name, const Ref &p_anim) { - Ref(p_anim)->connect(SceneStringNames::get_singleton()->tracks_changed, callable_mp(this, &AnimationPlayer::_animation_changed), varray(), CONNECT_REFERENCE_COUNTED); } void AnimationPlayer::_unref_anim(const Ref &p_anim) { - Ref(p_anim)->disconnect(SceneStringNames::get_singleton()->tracks_changed, callable_mp(this, &AnimationPlayer::_animation_changed)); } void AnimationPlayer::rename_animation(const StringName &p_name, const StringName &p_new_name) { - ERR_FAIL_COND(!animation_set.has(p_name)); ERR_FAIL_COND(String(p_new_name).find("/") != -1 || String(p_new_name).find(":") != -1); ERR_FAIL_COND(animation_set.has(p_new_name)); @@ -1030,7 +959,6 @@ void AnimationPlayer::rename_animation(const StringName &p_name, const StringNam List to_erase; Map to_insert; for (Map::Element *E = blend_times.front(); E; E = E->next()) { - BlendKey bk = E->key(); BlendKey new_bk = bk; bool erase = false; @@ -1050,7 +978,6 @@ void AnimationPlayer::rename_animation(const StringName &p_name, const StringNam } while (to_erase.size()) { - blend_times.erase(to_erase.front()->get()); to_erase.pop_front(); } @@ -1068,11 +995,9 @@ void AnimationPlayer::rename_animation(const StringName &p_name, const StringNam } bool AnimationPlayer::has_animation(const StringName &p_name) const { - return animation_set.has(p_name); } Ref AnimationPlayer::get_animation(const StringName &p_name) const { - ERR_FAIL_COND_V(!animation_set.has(p_name), Ref()); const AnimationData &data = animation_set[p_name]; @@ -1080,24 +1005,20 @@ Ref AnimationPlayer::get_animation(const StringName &p_name) const { return data.animation; } void AnimationPlayer::get_animation_list(List *p_animations) const { - List anims; for (Map::Element *E = animation_set.front(); E; E = E->next()) { - anims.push_back(E->key()); } anims.sort(); for (List::Element *E = anims.front(); E; E = E->next()) { - p_animations->push_back(E->get()); } } void AnimationPlayer::set_blend_time(const StringName &p_animation1, const StringName &p_animation2, float p_time) { - ERR_FAIL_COND_MSG(p_time < 0, "Blend time cannot be smaller than 0."); BlendKey bk; @@ -1110,7 +1031,6 @@ void AnimationPlayer::set_blend_time(const StringName &p_animation1, const Strin } float AnimationPlayer::get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const { - BlendKey bk; bk.from = p_animation1; bk.to = p_animation2; @@ -1122,7 +1042,6 @@ float AnimationPlayer::get_blend_time(const StringName &p_animation1, const Stri } void AnimationPlayer::queue(const StringName &p_name) { - if (!is_playing()) play(p_name); else @@ -1143,12 +1062,10 @@ void AnimationPlayer::clear_queue() { } void AnimationPlayer::play_backwards(const StringName &p_name, float p_custom_blend) { - play(p_name, p_custom_blend, -1, true); } void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float p_custom_scale, bool p_from_end) { - StringName name = p_name; if (String(name) == "") @@ -1159,7 +1076,6 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float Playback &c = playback; if (c.current.from) { - float blend_time = 0; // find if it can blend BlendKey bk; @@ -1169,21 +1085,16 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float if (p_custom_blend >= 0) { blend_time = p_custom_blend; } else if (blend_times.has(bk)) { - blend_time = blend_times[bk]; } else { - bk.from = "*"; if (blend_times.has(bk)) { - blend_time = blend_times[bk]; } else { - bk.from = c.current.from->name; bk.to = "*"; if (blend_times.has(bk)) { - blend_time = blend_times[bk]; } } @@ -1192,7 +1103,6 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float if (p_custom_blend < 0 && blend_time == 0 && default_blend_time) blend_time = default_blend_time; if (blend_time > 0) { - Blend b; b.data = c.current; b.blend_time = b.blend_left = blend_time; @@ -1240,12 +1150,10 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float } bool AnimationPlayer::is_playing() const { - return playing; } void AnimationPlayer::set_current_animation(const String &p_anim) { - if (p_anim == "[stop]" || p_anim == "") { stop(); } else if (!is_playing() || playback.assigned != p_anim) { @@ -1256,12 +1164,10 @@ void AnimationPlayer::set_current_animation(const String &p_anim) { } String AnimationPlayer::get_current_animation() const { - return (is_playing() ? playback.assigned : ""); } void AnimationPlayer::set_assigned_animation(const String &p_anim) { - if (is_playing()) { play(p_anim); } else { @@ -1273,12 +1179,10 @@ void AnimationPlayer::set_assigned_animation(const String &p_anim) { } String AnimationPlayer::get_assigned_animation() const { - return playback.assigned; } void AnimationPlayer::stop(bool p_reset) { - _stop_playing_caches(); Playback &c = playback; c.blend.clear(); @@ -1293,15 +1197,12 @@ void AnimationPlayer::stop(bool p_reset) { } void AnimationPlayer::set_speed_scale(float p_speed) { - speed_scale = p_speed; } float AnimationPlayer::get_speed_scale() const { - return speed_scale; } float AnimationPlayer::get_playing_speed() const { - if (!playing) { return 0; } @@ -1309,7 +1210,6 @@ float AnimationPlayer::get_playing_speed() const { } void AnimationPlayer::seek(float p_time, bool p_update) { - if (!playback.current.from) { if (playback.assigned) { ERR_FAIL_COND(!animation_set.has(playback.assigned)); @@ -1326,7 +1226,6 @@ void AnimationPlayer::seek(float p_time, bool p_update) { } void AnimationPlayer::seek_delta(float p_time, float p_delta) { - if (!playback.current.from) { if (playback.assigned) { ERR_FAIL_COND(!animation_set.has(playback.assigned)); @@ -1343,24 +1242,20 @@ void AnimationPlayer::seek_delta(float p_time, float p_delta) { } bool AnimationPlayer::is_valid() const { - return (playback.current.from); } float AnimationPlayer::get_current_animation_position() const { - ERR_FAIL_COND_V(!playback.current.from, 0); return playback.current.pos; } float AnimationPlayer::get_current_animation_length() const { - ERR_FAIL_COND_V(!playback.current.from, 0); return playback.current.from->animation->get_length(); } void AnimationPlayer::_animation_changed() { - clear_caches(); emit_signal("caches_cleared"); if (is_playing()) { @@ -1369,9 +1264,7 @@ void AnimationPlayer::_animation_changed() { } void AnimationPlayer::_stop_playing_caches() { - for (Set::Element *E = playing_caches.front(); E; E = E->next()) { - if (E->get()->node && E->get()->audio_playing) { E->get()->node->call("stop"); } @@ -1387,18 +1280,15 @@ void AnimationPlayer::_stop_playing_caches() { } void AnimationPlayer::_node_removed(Node *p_node) { - clear_caches(); // nodes contained here ar being removed, clear the caches } void AnimationPlayer::clear_caches() { - _stop_playing_caches(); node_cache_map.clear(); for (Map::Element *E = animation_set.front(); E; E = E->next()) { - E->get().node_cache.clear(); } @@ -1408,7 +1298,6 @@ void AnimationPlayer::clear_caches() { } void AnimationPlayer::set_active(bool p_active) { - if (active == p_active) return; @@ -1417,14 +1306,11 @@ void AnimationPlayer::set_active(bool p_active) { } bool AnimationPlayer::is_active() const { - return active; } StringName AnimationPlayer::find_animation(const Ref &p_animation) const { - for (Map::Element *E = animation_set.front(); E; E = E->next()) { - if (E->get().animation == p_animation) return E->key(); } @@ -1440,12 +1326,10 @@ void AnimationPlayer::set_autoplay(const String &p_name) { } String AnimationPlayer::get_autoplay() const { - return autoplay; } void AnimationPlayer::set_animation_process_mode(AnimationProcessMode p_mode) { - if (animation_process_mode == p_mode) return; @@ -1458,27 +1342,22 @@ void AnimationPlayer::set_animation_process_mode(AnimationProcessMode p_mode) { } AnimationPlayer::AnimationProcessMode AnimationPlayer::get_animation_process_mode() const { - return animation_process_mode; } void AnimationPlayer::set_method_call_mode(AnimationMethodCallMode p_mode) { - method_call_mode = p_mode; } AnimationPlayer::AnimationMethodCallMode AnimationPlayer::get_method_call_mode() const { - return method_call_mode; } void AnimationPlayer::_set_process(bool p_process, bool p_force) { - if (processing == p_process && !p_force) return; switch (animation_process_mode) { - case ANIMATION_PROCESS_PHYSICS: set_physics_process_internal(p_process && active); break; @@ -1493,41 +1372,34 @@ void AnimationPlayer::_set_process(bool p_process, bool p_force) { } void AnimationPlayer::animation_set_next(const StringName &p_animation, const StringName &p_next) { - ERR_FAIL_COND(!animation_set.has(p_animation)); animation_set[p_animation].next = p_next; } StringName AnimationPlayer::animation_get_next(const StringName &p_animation) const { - if (!animation_set.has(p_animation)) return StringName(); return animation_set[p_animation].next; } void AnimationPlayer::set_default_blend_time(float p_default) { - default_blend_time = p_default; } float AnimationPlayer::get_default_blend_time() const { - return default_blend_time; } void AnimationPlayer::set_root(const NodePath &p_root) { - root = p_root; clear_caches(); } NodePath AnimationPlayer::get_root() const { - return root; } void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List *r_options) const { - #ifdef TOOLS_ENABLED const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\""; #else @@ -1539,7 +1411,6 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i List al; get_animation_list(&al); for (List::Element *E = al.front(); E; E = E->next()) { - r_options->push_back(quote_style + String(E->get()) + quote_style); } } @@ -1548,7 +1419,6 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i #ifdef TOOLS_ENABLED AnimatedValuesBackup AnimationPlayer::backup_animated_values() { - if (!playback.current.from) return AnimatedValuesBackup(); @@ -1597,9 +1467,7 @@ AnimatedValuesBackup AnimationPlayer::backup_animated_values() { } void AnimationPlayer::restore_animated_values(const AnimatedValuesBackup &p_backup) { - for (int i = 0; i < p_backup.entries.size(); i++) { - const AnimatedValuesBackup::Entry *entry = &p_backup.entries[i]; if (entry->bone_idx == -1) { entry->object->set_indexed(entry->subpath, entry->value); @@ -1697,7 +1565,6 @@ void AnimationPlayer::_bind_methods() { } AnimationPlayer::AnimationPlayer() { - accum_pass = 1; cache_update_size = 0; cache_update_prop_size = 0; diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index d709082f62..c7b3d7fc7b 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -85,7 +85,6 @@ private: }; struct TrackNodeCache { - NodePath path; uint32_t id = 0; RES resource; @@ -108,7 +107,6 @@ private: bool animation_playing = false; struct PropertyAnim { - TrackNodeCache *owner = nullptr; SpecialProperty special = SP_NONE; //small optimization Vector subpath; @@ -123,7 +121,6 @@ private: Map property_anim; struct BezierAnim { - Vector bezier_property; TrackNodeCache *owner = nullptr; float bezier_accum = 0.0; @@ -139,12 +136,10 @@ private: }; struct TrackNodeCacheKey { - ObjectID id; int bone_idx; inline bool operator<(const TrackNodeCacheKey &p_right) const { - if (id == p_right.id) return bone_idx < p_right.bone_idx; else @@ -175,7 +170,6 @@ private: Map animation_set; struct BlendKey { - StringName from; StringName to; bool operator<(const BlendKey &bk) const { return from == bk.from ? String(to) < String(bk.to) : String(from) < String(bk.from); } @@ -184,13 +178,11 @@ private: Map blend_times; struct PlaybackData { - AnimationData *from; float pos; float speed_scale; PlaybackData() { - pos = 0; speed_scale = 1.0; from = nullptr; @@ -198,21 +190,18 @@ private: }; struct Blend { - PlaybackData data; float blend_time; float blend_left; Blend() { - blend_left = 0; blend_time = 0; } }; struct Playback { - List blend; PlaybackData current; StringName assigned; @@ -246,12 +235,10 @@ private: // bind helpers Vector _get_animation_list() const { - List animations; get_animation_list(&animations); Vector ret; while (animations.size()) { - ret.push_back(animations.front()->get()); animations.pop_front(); } diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 56e224819f..81575b7f48 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -73,7 +73,6 @@ Variant AnimationNode::get_parameter(const StringName &p_name) const { } void AnimationNode::get_child_nodes(List *r_child_nodes) { - if (get_script_instance()) { Dictionary cn = get_script_instance()->call("get_child_nodes"); List keys; @@ -88,14 +87,12 @@ void AnimationNode::get_child_nodes(List *r_child_nodes) { } void AnimationNode::blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend) { - ERR_FAIL_COND(!state); ERR_FAIL_COND(!state->player->has_animation(p_animation)); Ref animation = state->player->get_animation(p_animation); if (animation.is_null()) { - AnimationNodeBlendTree *btree = Object::cast_to(parent); if (btree) { String name = btree->get_node_name(Ref(this)); @@ -120,7 +117,6 @@ void AnimationNode::blend_animation(const StringName &p_animation, float p_time, } float AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector &p_connections) { - base_path = p_base_path; parent = p_parent; connections = p_connections; @@ -176,12 +172,10 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p } float AnimationNode::blend_node(const StringName &p_sub_path, Ref p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) { - return _blend_node(p_sub_path, Vector(), this, p_node, p_time, p_seek, p_blend, p_filter, p_optimize); } float AnimationNode::_blend_node(const StringName &p_subpath, const Vector &p_connections, AnimationNode *p_new_parent, Ref p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize, float *r_max) { - ERR_FAIL_COND_V(!p_node.is_valid(), 0); ERR_FAIL_COND_V(!state, 0); @@ -197,7 +191,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector CMP_EPSILON) { @@ -297,7 +287,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vectorcall("get_caption"); } @@ -338,7 +326,6 @@ void AnimationNode::remove_input(int p_index) { } float AnimationNode::process(float p_time, bool p_seek) { - if (get_script_instance()) { return get_script_instance()->call("process", p_time, p_seek); } @@ -371,7 +358,6 @@ bool AnimationNode::has_filter() const { } Array AnimationNode::_get_filters() const { - Array paths; const NodePath *K = nullptr; @@ -403,7 +389,6 @@ Ref AnimationNode::get_child_by_name(const StringName &p_name) { } void AnimationNode::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_input_count"), &AnimationNode::get_input_count); ClassDB::bind_method(D_METHOD("get_input_name", "input"), &AnimationNode::get_input_name); @@ -452,7 +437,6 @@ void AnimationNode::_bind_methods() { } AnimationNode::AnimationNode() { - state = nullptr; parent = nullptr; filter_enabled = false; @@ -461,7 +445,6 @@ AnimationNode::AnimationNode() { //////////////////// void AnimationTree::set_tree_root(const Ref &p_root) { - if (root.is_valid()) { root->disconnect("tree_changed", callable_mp(this, &AnimationTree::_tree_changed)); } @@ -482,7 +465,6 @@ Ref AnimationTree::get_tree_root() const { } void AnimationTree::set_active(bool p_active) { - if (active == p_active) return; @@ -492,13 +474,11 @@ void AnimationTree::set_active(bool p_active) { if (process_mode == ANIMATION_PROCESS_IDLE) { set_process_internal(active); } else { - set_physics_process_internal(active); } if (!active && is_inside_tree()) { for (Set::Element *E = playing_caches.front(); E; E = E->next()) { - if (ObjectDB::get_instance(E->get()->object_id)) { E->get()->object->call("stop"); } @@ -509,12 +489,10 @@ void AnimationTree::set_active(bool p_active) { } bool AnimationTree::is_active() const { - return active; } void AnimationTree::set_process_mode(AnimationProcessMode p_mode) { - if (process_mode == p_mode) return; @@ -539,7 +517,6 @@ void AnimationTree::_node_removed(Node *p_node) { } bool AnimationTree::_update_caches(AnimationPlayer *player) { - setup_pass++; if (!player->has_node(player->get_root())) { @@ -572,7 +549,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { } if (!track) { - RES resource; Vector leftover_path; Node *child = parent->get_node_and_resource(path, resource, leftover_path); @@ -588,7 +564,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { switch (track_type) { case Animation::TYPE_VALUE: { - TrackCacheValue *track_value = memnew(TrackCacheValue); if (resource.is_valid()) { @@ -604,7 +579,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { } break; case Animation::TYPE_TRANSFORM: { - Node3D *spatial = Object::cast_to(child); if (!spatial) { @@ -619,11 +593,9 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { track_xform->bone_idx = -1; if (path.get_subname_count() == 1 && Object::cast_to(spatial)) { - Skeleton3D *sk = Object::cast_to(spatial); int bone_idx = sk->find_bone(path.get_subname(0)); if (bone_idx != -1) { - track_xform->skeleton = sk; track_xform->bone_idx = bone_idx; } @@ -636,7 +608,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { } break; case Animation::TYPE_METHOD: { - TrackCacheMethod *track_method = memnew(TrackCacheMethod); if (resource.is_valid()) { @@ -651,7 +622,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { } break; case Animation::TYPE_BEZIER: { - TrackCacheBezier *track_bezier = memnew(TrackCacheBezier); if (resource.is_valid()) { @@ -666,7 +636,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { track = track_bezier; } break; case Animation::TYPE_AUDIO: { - TrackCacheAudio *track_audio = memnew(TrackCacheAudio); track_audio->object = child; @@ -676,7 +645,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { } break; case Animation::TYPE_ANIMATION: { - TrackCacheAnimation *track_animation = memnew(TrackCacheAnimation); track_animation->object = child; @@ -732,7 +700,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { } void AnimationTree::_clear_caches() { - const NodePath *K = nullptr; while ((K = track_cache.next(K))) { memdelete(track_cache[*K]); @@ -744,7 +711,6 @@ void AnimationTree::_clear_caches() { } void AnimationTree::_process_graph(float p_delta) { - _update_properties(); //if properties need updating, update them //check all tracks, see if they need modification @@ -774,7 +740,6 @@ void AnimationTree::_process_graph(float p_delta) { } if (last_animation_player != current_animation_player) { - if (last_animation_player.is_valid()) { Object *old_player = ObjectDB::get_instance(last_animation_player); if (old_player) { @@ -826,7 +791,6 @@ void AnimationTree::_process_graph(float p_delta) { //process { - if (started) { //if started, seek root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, 0, true, Vector()); @@ -842,11 +806,9 @@ void AnimationTree::_process_graph(float p_delta) { //apply value/transform/bezier blends to track caches and execute method/audio/animation tracks { - bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint(); for (List::Element *E = state.animation_states.front(); E; E = E->next()) { - const AnimationNode::AnimationState &as = E->get(); Ref a = as.animation; @@ -855,7 +817,6 @@ void AnimationTree::_process_graph(float p_delta) { bool seeked = as.seeked; for (int i = 0; i < a->get_track_count(); i++) { - NodePath path = a->track_get_path(i); ERR_CONTINUE(!track_cache.has(path)); @@ -878,15 +839,11 @@ void AnimationTree::_process_graph(float p_delta) { continue; //nothing to blend switch (track->type) { - case Animation::TYPE_TRANSFORM: { - TrackCacheTransform *t = static_cast(track); if (track->root_motion) { - if (t->process_pass != process_pass) { - t->process_pass = process_pass; t->loc = Vector3(); t->rot = Quat(); @@ -908,7 +865,6 @@ void AnimationTree::_process_graph(float p_delta) { Vector3 scale[2]; if (prev_time > time) { - Error err = a->transform_track_interpolate(i, prev_time, &loc[0], &rot[0], &scale[0]); if (err != OK) { continue; @@ -947,7 +903,6 @@ void AnimationTree::_process_graph(float p_delta) { //ERR_CONTINUE(err!=OK); //used for testing, should be removed if (t->process_pass != process_pass) { - t->process_pass = process_pass; t->loc = loc; t->rot = rot; @@ -972,7 +927,6 @@ void AnimationTree::_process_graph(float p_delta) { } break; case Animation::TYPE_VALUE: { - TrackCacheValue *t = static_cast(track); Animation::UpdateMode update_mode = a->value_track_get_update_mode(i); @@ -992,12 +946,10 @@ void AnimationTree::_process_graph(float p_delta) { Variant::interpolate(t->value, value, blend, t->value); } else if (delta != 0) { - List indices; a->value_track_get_key_indices(i, time, delta, &indices); for (List::Element *F = indices.front(); F; F = F->next()) { - Variant value = a->track_get_key_value(i, F->get()); t->object->set_indexed(t->subpath, value); } @@ -1005,7 +957,6 @@ void AnimationTree::_process_graph(float p_delta) { } break; case Animation::TYPE_METHOD: { - if (delta == 0) { continue; } @@ -1016,7 +967,6 @@ void AnimationTree::_process_graph(float p_delta) { a->method_track_get_key_indices(i, time, delta, &indices); for (List::Element *F = indices.front(); F; F = F->next()) { - StringName method = a->method_track_get_name(i, F->get()); Vector params = a->method_track_get_params(i, F->get()); @@ -1036,7 +986,6 @@ void AnimationTree::_process_graph(float p_delta) { } break; case Animation::TYPE_BEZIER: { - TrackCacheBezier *t = static_cast(track); float bezier = a->bezier_track_interpolate(i, time); @@ -1050,7 +999,6 @@ void AnimationTree::_process_graph(float p_delta) { } break; case Animation::TYPE_AUDIO: { - TrackCacheAudio *t = static_cast(track); if (seeked) { @@ -1122,7 +1070,6 @@ void AnimationTree::_process_graph(float p_delta) { t->start = time; } } else if (t->playing) { - bool loop = a->has_loop(); bool stop = false; @@ -1154,7 +1101,6 @@ void AnimationTree::_process_graph(float p_delta) { } } break; case Animation::TYPE_ANIMATION: { - TrackCacheAnimation *t = static_cast(track); AnimationPlayer *player2 = Object::cast_to(t->object); @@ -1202,7 +1148,6 @@ void AnimationTree::_process_graph(float p_delta) { StringName anim_name = a->animation_track_get_key_animation(i, idx); if (String(anim_name) == "[stop]" || !player2->has_animation(anim_name)) { - if (playing_caches.has(t)) { playing_caches.erase(t); player2->stop(); @@ -1231,9 +1176,7 @@ void AnimationTree::_process_graph(float p_delta) { continue; //not processed, ignore switch (track->type) { - case Animation::TYPE_TRANSFORM: { - TrackCacheTransform *t = static_cast(track); Transform xform; @@ -1242,31 +1185,26 @@ void AnimationTree::_process_graph(float p_delta) { xform.basis.set_quat_scale(t->rot, t->scale); if (t->root_motion) { - root_motion_transform = xform; if (t->skeleton && t->bone_idx >= 0) { root_motion_transform = (t->skeleton->get_bone_rest(t->bone_idx) * root_motion_transform) * t->skeleton->get_bone_rest(t->bone_idx).affine_inverse(); } } else if (t->skeleton && t->bone_idx >= 0) { - t->skeleton->set_bone_pose(t->bone_idx, xform); } else { - t->spatial->set_transform(xform); } } break; case Animation::TYPE_VALUE: { - TrackCacheValue *t = static_cast(track); t->object->set_indexed(t->subpath, t->value); } break; case Animation::TYPE_BEZIER: { - TrackCacheBezier *t = static_cast(track); t->object->set_indexed(t->subpath, t->value); @@ -1280,12 +1218,10 @@ void AnimationTree::_process_graph(float p_delta) { } void AnimationTree::advance(float p_time) { - _process_graph(p_time); } void AnimationTree::_notification(int p_what) { - if (active && p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS && process_mode == ANIMATION_PROCESS_PHYSICS) { _process_graph(get_physics_process_delta_time()); } @@ -1297,7 +1233,6 @@ void AnimationTree::_notification(int p_what) { if (p_what == NOTIFICATION_EXIT_TREE) { _clear_caches(); if (last_animation_player.is_valid()) { - Object *player = ObjectDB::get_instance(last_animation_player); if (player) { player->disconnect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches)); @@ -1305,7 +1240,6 @@ void AnimationTree::_notification(int p_what) { } } else if (p_what == NOTIFICATION_ENTER_TREE) { if (last_animation_player.is_valid()) { - Object *player = ObjectDB::get_instance(last_animation_player); if (player) { player->connect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches)); @@ -1324,11 +1258,9 @@ NodePath AnimationTree::get_animation_player() const { } bool AnimationTree::is_state_invalid() const { - return !state.valid; } String AnimationTree::get_invalid_state_reason() const { - return state.invalid_reasons; } @@ -1337,7 +1269,6 @@ uint64_t AnimationTree::get_last_process_pass() const { } String AnimationTree::get_configuration_warning() const { - String warning = Node::get_configuration_warning(); if (!root.is_valid()) { @@ -1348,7 +1279,6 @@ String AnimationTree::get_configuration_warning() const { } if (!has_node(animation_player)) { - if (warning != String()) { warning += "\n\n"; } @@ -1402,13 +1332,11 @@ void AnimationTree::_tree_changed() { } void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref node) { - if (!property_parent_map.has(p_base_path)) { property_parent_map[p_base_path] = HashMap(); } if (node->get_input_count() && !input_activity_map.has(p_base_path)) { - Vector activity; for (int i = 0; i < node->get_input_count(); i++) { Activity a; @@ -1503,7 +1431,6 @@ void AnimationTree::_get_property_list(List *p_list) const { } void AnimationTree::rename_parameter(const String &p_base, const String &p_new_base) { - //rename values first for (const List::Element *E = properties.front(); E; E = E->next()) { if (E->get().name.begins_with(p_base)) { @@ -1518,7 +1445,6 @@ void AnimationTree::rename_parameter(const String &p_base, const String &p_new_b } float AnimationTree::get_connection_activity(const StringName &p_path, int p_connection) const { - if (!input_activity_map_get.has(p_path)) { return 0; } @@ -1572,7 +1498,6 @@ void AnimationTree::_bind_methods() { } AnimationTree::AnimationTree() { - process_mode = ANIMATION_PROCESS_IDLE; active = false; cache_valid = false; diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index d558170f23..8fe01fac8f 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -52,7 +52,6 @@ public: }; struct Input { - String name; }; @@ -63,7 +62,6 @@ public: friend class AnimationTree; struct AnimationState { - Ref animation; float time; float delta; @@ -73,7 +71,6 @@ public: }; struct State { - int track_count; HashMap track_map; List animation_states; @@ -174,7 +171,6 @@ public: private: struct TrackCache { - bool root_motion; uint64_t setup_pass; uint64_t process_pass; @@ -209,19 +205,16 @@ private: }; struct TrackCacheValue : public TrackCache { - Variant value; Vector subpath; TrackCacheValue() { type = Animation::TYPE_VALUE; } }; struct TrackCacheMethod : public TrackCache { - TrackCacheMethod() { type = Animation::TYPE_METHOD; } }; struct TrackCacheBezier : public TrackCache { - float value; Vector subpath; TrackCacheBezier() { @@ -231,7 +224,6 @@ private: }; struct TrackCacheAudio : public TrackCache { - bool playing; float start; float len; @@ -245,7 +237,6 @@ private: }; struct TrackCacheAnimation : public TrackCache { - bool playing; TrackCacheAnimation() { diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp index f993127b07..bbfec588f4 100644 --- a/scene/animation/root_motion_view.cpp +++ b/scene/animation/root_motion_view.cpp @@ -76,9 +76,7 @@ bool RootMotionView::get_zero_y() const { } void RootMotionView::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - RS::get_singleton()->immediate_set_material(immediate, StandardMaterial3D::get_material_rid_for_2d(false, true, false, false, false)); first = true; } @@ -87,7 +85,6 @@ void RootMotionView::_notification(int p_what) { Transform transform; if (has_node(path)) { - Node *node = get_node(path); AnimationTree *tree = Object::cast_to(node); @@ -129,7 +126,6 @@ void RootMotionView::_notification(int p_what) { RS::get_singleton()->immediate_begin(immediate, RS::PRIMITIVE_LINES); for (int i = -cells_in_radius; i < cells_in_radius; i++) { for (int j = -cells_in_radius; j < cells_in_radius; j++) { - Vector3 from(i * cell_size, 0, j * cell_size); Vector3 from_i((i + 1) * cell_size, 0, j * cell_size); Vector3 from_j(i * cell_size, 0, (j + 1) * cell_size); @@ -161,7 +157,6 @@ void RootMotionView::_notification(int p_what) { } AABB RootMotionView::get_aabb() const { - return AABB(Vector3(-radius, 0, -radius), Vector3(radius * 2, 0.001, radius * 2)); } Vector RootMotionView::get_faces(uint32_t p_usage_flags) const { @@ -169,7 +164,6 @@ Vector RootMotionView::get_faces(uint32_t p_usage_flags) const { } void RootMotionView::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_animation_path", "path"), &RootMotionView::set_animation_path); ClassDB::bind_method(D_METHOD("get_animation_path"), &RootMotionView::get_animation_path); diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index b826907a3a..d94cbfa08c 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -33,7 +33,6 @@ #include "core/method_bind_ext.gen.inc" void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5, const Variant &p_arg6, const Variant &p_arg7, const Variant &p_arg8, const Variant &p_arg9, const Variant &p_arg10) { - // Add a new pending command and reference it pending_commands.push_back(PendingCommand()); PendingCommand &cmd = pending_commands.back()->get(); @@ -90,10 +89,8 @@ void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const } void Tween::_process_pending_commands() { - // For each pending command... for (List::Element *E = pending_commands.front(); E; E = E->next()) { - // Get the command PendingCommand &cmd = E->get(); Callable::CallError err; @@ -121,7 +118,6 @@ void Tween::_process_pending_commands() { } bool Tween::_set(const StringName &p_name, const Variant &p_value) { - // Set the correct attribute based on the given name String name = p_name; if (name == "playback/speed" || name == "speed") { // Backwards compatibility @@ -140,7 +136,6 @@ bool Tween::_set(const StringName &p_name, const Variant &p_value) { } bool Tween::_get(const StringName &p_name, Variant &r_ret) const { - // Get the correct attribute based on the given name String name = p_name; if (name == "playback/speed") { // Backwards compatibility @@ -168,7 +163,6 @@ void Tween::_get_property_list(List *p_list) const { void Tween::_notification(int p_what) { // What notification did we receive? switch (p_what) { - case NOTIFICATION_ENTER_TREE: { // Are we not already active? if (!is_active()) { @@ -289,7 +283,6 @@ void Tween::_bind_methods() { } Variant Tween::_get_initial_val(const InterpolateData &p_data) const { - // What type of data are we interpolating? switch (p_data.type) { case INTER_PROPERTY: @@ -366,7 +359,6 @@ Variant Tween::_get_final_val(const InterpolateData &p_data) const { } Variant &Tween::_get_delta_val(InterpolateData &p_data) { - // What kind of data are we interpolating? switch (p_data.type) { case INTER_PROPERTY: @@ -438,7 +430,6 @@ Variant Tween::_run_equation(InterpolateData &p_data) { // What type of data are we interpolating? switch (initial_val.get_type()) { - case Variant::BOOL: // Run the boolean specific equation (checking if it is at least 0.5) result = (_run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.duration)) >= 0.5; @@ -613,14 +604,12 @@ Variant Tween::_run_equation(InterpolateData &p_data) { } bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) { - // Get the object we want to apply the new value to Object *object = ObjectDB::get_instance(p_data.id); ERR_FAIL_COND_V(object == nullptr, false); // What kind of data are we mutating? switch (p_data.type) { - case INTER_PROPERTY: case FOLLOW_PROPERTY: case TARGETING_PROPERTY: { @@ -696,7 +685,6 @@ void Tween::_tween_process(float p_delta) { // For each tween we wish to interpolate... for (List::Element *E = interpolates.front(); E; E = E->next()) { - // Get the data from it InterpolateData &data = E->get(); @@ -852,7 +840,6 @@ float Tween::get_speed_scale() const { } void Tween::start() { - ERR_FAIL_COND_MSG(!is_inside_tree(), "Tween was not added to the SceneTree!"); // Are there any pending updates? @@ -910,7 +897,6 @@ void Tween::stop(Object *p_object, StringName p_key) { // Find the tween that has the given target object and string key pending_update++; for (List::Element *E = interpolates.front(); E; E = E->next()) { - // Get the object the tween is targeting InterpolateData &data = E->get(); Object *object = ObjectDB::get_instance(data.id); @@ -1123,7 +1109,6 @@ real_t Tween::get_runtime() const { } bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final_val, Variant &p_delta_val) { - // Get the initial, final, and delta values const Variant &initial_val = p_initial_val; const Variant &final_val = p_final_val; @@ -1131,7 +1116,6 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final // What kind of data are we interpolating? switch (initial_val.get_type()) { - case Variant::BOOL: // We'll treat booleans just like integers case Variant::INT: @@ -1263,7 +1247,6 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final } void Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p_object, NodePath *p_property, StringName *p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { - // TODO: Add initialization+implementation for remaining interpolation types // TODO: Fix this method's organization to take advantage of the type diff --git a/scene/animation/tween.h b/scene/animation/tween.h index f74df50f68..668870c526 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -34,7 +34,6 @@ #include "scene/main/node.h" class Tween : public Node { - GDCLASS(Tween, Node); public: diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index f612944a62..6cd4914519 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -33,7 +33,6 @@ #include "core/engine.h" void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames, int p_amount) { - int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus); AudioFrame *targets[4] = { nullptr, nullptr, nullptr, nullptr }; @@ -66,7 +65,6 @@ void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames, int p_amount) { } void AudioStreamPlayer::_mix_internal(bool p_fadeout) { - //get data AudioFrame *buffer = mix_buffer.ptrw(); int buffer_size = mix_buffer.size(); @@ -95,7 +93,6 @@ void AudioStreamPlayer::_mix_internal(bool p_fadeout) { } void AudioStreamPlayer::_mix_audio() { - if (use_fadeout) { _mix_to_bus(fadeout_buffer.ptr(), fadeout_buffer.size()); use_fadeout = false; @@ -122,7 +119,6 @@ void AudioStreamPlayer::_mix_audio() { if (setseek >= 0.0 && !stop_has_priority) { if (stream_playback->is_playing()) { - //fade out to avoid pops _mix_internal(true); } @@ -138,9 +134,7 @@ void AudioStreamPlayer::_mix_audio() { } void AudioStreamPlayer::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - AudioServer::get_singleton()->add_callback(_mix_audios, this); if (autoplay && !Engine::get_singleton()->is_editor_hint()) { play(); @@ -148,7 +142,6 @@ void AudioStreamPlayer::_notification(int p_what) { } if (p_what == NOTIFICATION_INTERNAL_PROCESS) { - if (!active || (setseek < 0 && !stream_playback->is_playing())) { active = false; set_process_internal(false); @@ -157,7 +150,6 @@ void AudioStreamPlayer::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE) { - AudioServer::get_singleton()->remove_callback(_mix_audios, this); } @@ -174,7 +166,6 @@ void AudioStreamPlayer::_notification(int p_what) { } void AudioStreamPlayer::set_stream(Ref p_stream) { - AudioServer::get_singleton()->lock(); if (active && stream_playback.is_valid() && !stream_paused) { @@ -222,16 +213,13 @@ void AudioStreamPlayer::set_stream(Ref p_stream) { } Ref AudioStreamPlayer::get_stream() const { - return stream; } void AudioStreamPlayer::set_volume_db(float p_volume) { - volume_db = p_volume; } float AudioStreamPlayer::get_volume_db() const { - return volume_db; } @@ -244,7 +232,6 @@ float AudioStreamPlayer::get_pitch_scale() const { } void AudioStreamPlayer::play(float p_from_pos) { - if (stream_playback.is_valid()) { //mix_volume_db = volume_db; do not reset volume ramp here, can cause clicks setseek = p_from_pos; @@ -255,14 +242,12 @@ void AudioStreamPlayer::play(float p_from_pos) { } void AudioStreamPlayer::seek(float p_seconds) { - if (stream_playback.is_valid()) { setseek = p_seconds; } } void AudioStreamPlayer::stop() { - if (stream_playback.is_valid() && active) { setstop = true; stop_has_priority = true; @@ -270,7 +255,6 @@ void AudioStreamPlayer::stop() { } bool AudioStreamPlayer::is_playing() const { - if (stream_playback.is_valid()) { return active && !setstop; //&& stream_playback->is_playing(); } @@ -279,7 +263,6 @@ bool AudioStreamPlayer::is_playing() const { } float AudioStreamPlayer::get_playback_position() { - if (stream_playback.is_valid()) { return stream_playback->get_playback_position(); } @@ -288,14 +271,12 @@ float AudioStreamPlayer::get_playback_position() { } void AudioStreamPlayer::set_bus(const StringName &p_bus) { - //if audio is active, must lock this AudioServer::get_singleton()->lock(); bus = p_bus; AudioServer::get_singleton()->unlock(); } StringName AudioStreamPlayer::get_bus() const { - for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (AudioServer::get_singleton()->get_bus_name(i) == bus) { return bus; @@ -305,38 +286,31 @@ StringName AudioStreamPlayer::get_bus() const { } void AudioStreamPlayer::set_autoplay(bool p_enable) { - autoplay = p_enable; } bool AudioStreamPlayer::is_autoplay_enabled() { - return autoplay; } void AudioStreamPlayer::set_mix_target(MixTarget p_target) { - mix_target = p_target; } AudioStreamPlayer::MixTarget AudioStreamPlayer::get_mix_target() const { - return mix_target; } void AudioStreamPlayer::_set_playing(bool p_enable) { - if (p_enable) play(); else stop(); } bool AudioStreamPlayer::_is_active() const { - return active; } void AudioStreamPlayer::set_stream_paused(bool p_pause) { - if (p_pause != stream_paused) { stream_paused = p_pause; stream_paused_fade = p_pause; @@ -344,14 +318,11 @@ void AudioStreamPlayer::set_stream_paused(bool p_pause) { } bool AudioStreamPlayer::get_stream_paused() const { - return stream_paused; } void AudioStreamPlayer::_validate_property(PropertyInfo &property) const { - if (property.name == "bus") { - String options; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (i > 0) @@ -365,7 +336,6 @@ void AudioStreamPlayer::_validate_property(PropertyInfo &property) const { } void AudioStreamPlayer::_bus_layout_changed() { - _change_notify(); } @@ -374,7 +344,6 @@ Ref AudioStreamPlayer::get_stream_playback() { } void AudioStreamPlayer::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_stream", "stream"), &AudioStreamPlayer::set_stream); ClassDB::bind_method(D_METHOD("get_stream"), &AudioStreamPlayer::get_stream); @@ -425,7 +394,6 @@ void AudioStreamPlayer::_bind_methods() { } AudioStreamPlayer::AudioStreamPlayer() { - mix_volume_db = 0; pitch_scale = 1.0; volume_db = 0; diff --git a/scene/audio/audio_stream_player.h b/scene/audio/audio_stream_player.h index 0f6d855d0e..6769f1bb48 100644 --- a/scene/audio/audio_stream_player.h +++ b/scene/audio/audio_stream_player.h @@ -35,7 +35,6 @@ #include "servers/audio/audio_stream.h" class AudioStreamPlayer : public Node { - GDCLASS(AudioStreamPlayer, Node); public: diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 8cb63c4ab5..965dd2c8a3 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -202,7 +202,6 @@ void SceneDebugger::_send_object_id(ObjectID p_id, int p_max_size) { } void SceneDebugger::_set_object_property(ObjectID p_id, const String &p_property, const Variant &p_value) { - Object *obj = ObjectDB::get_instance(p_id); if (!obj) return; @@ -243,7 +242,6 @@ void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) { Map>::Element *F = remove_list.find(p_node); if (F) { for (Map::Element *G = F->get().front(); G; G = G->next()) { - memdelete(G->get()); } remove_list.erase(F); @@ -403,7 +401,6 @@ void SceneDebuggerObject::deserialize(const Array &p_arr) { Array props = p_arr[2]; for (int i = 0; i < props.size(); i++) { - CHECK_TYPE(props[i], ARRAY); Array prop = props[i]; @@ -496,17 +493,14 @@ void LiveEditor::_send_tree() { } void LiveEditor::_node_path_func(const NodePath &p_path, int p_id) { - live_edit_node_path_cache[p_id] = p_path; } void LiveEditor::_res_path_func(const String &p_path, int p_id) { - live_edit_resource_cache[p_id] = p_path; } void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Variant &p_value) { - SceneTree *scene_tree = SceneTree::get_singleton(); if (!scene_tree) return; @@ -524,7 +518,6 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian return; //scene not editable for (Set::Element *F = E->get().front(); F; F = F->next()) { - Node *n = F->get(); if (base && !base->is_a_parent_of(n)) @@ -539,7 +532,6 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian } void LiveEditor::_node_set_res_func(int p_id, const StringName &p_prop, const String &p_value) { - RES r = ResourceLoader::load(p_value); if (!r.is_valid()) return; @@ -562,7 +554,6 @@ void LiveEditor::_node_call_func(int p_id, const StringName &p_method, VARIANT_A return; //scene not editable for (Set::Element *F = E->get().front(); F; F = F->next()) { - Node *n = F->get(); if (base && !base->is_a_parent_of(n)) @@ -576,7 +567,6 @@ void LiveEditor::_node_call_func(int p_id, const StringName &p_method, VARIANT_A } } void LiveEditor::_res_set_func(int p_id, const StringName &p_prop, const Variant &p_value) { - if (!live_edit_resource_cache.has(p_id)) return; @@ -592,14 +582,12 @@ void LiveEditor::_res_set_func(int p_id, const StringName &p_prop, const Variant r->set(p_prop, p_value); } void LiveEditor::_res_set_res_func(int p_id, const StringName &p_prop, const String &p_value) { - RES r = ResourceLoader::load(p_value); if (!r.is_valid()) return; _res_set_func(p_id, p_prop, r); } void LiveEditor::_res_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) { - if (!live_edit_resource_cache.has(p_id)) return; @@ -616,7 +604,6 @@ void LiveEditor::_res_call_func(int p_id, const StringName &p_method, VARIANT_AR } void LiveEditor::_root_func(const NodePath &p_scene_path, const String &p_scene_from) { - live_edit_root = p_scene_path; live_edit_scene = p_scene_from; } @@ -635,7 +622,6 @@ void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_typ return; //scene not editable for (Set::Element *F = E->get().front(); F; F = F->next()) { - Node *n = F->get(); if (base && !base->is_a_parent_of(n)) @@ -673,7 +659,6 @@ void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_p return; //scene not editable for (Set::Element *F = E->get().front(); F; F = F->next()) { - Node *n = F->get(); if (base && !base->is_a_parent_of(n)) @@ -706,7 +691,6 @@ void LiveEditor::_remove_node_func(const NodePath &p_at) { return; //scene not editable for (Set::Element *F = E->get().front(); F;) { - Set::Element *N = F->next(); Node *n = F->get(); @@ -737,7 +721,6 @@ void LiveEditor::_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_kee return; //scene not editable for (Set::Element *F = E->get().front(); F;) { - Set::Element *N = F->next(); Node *n = F->get(); @@ -771,7 +754,6 @@ void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_a return; //scene not editable for (Set::Element *F = E->get().front(); F;) { - Set::Element *N = F->next(); Node *n = F->get(); @@ -817,7 +799,6 @@ void LiveEditor::_duplicate_node_func(const NodePath &p_at, const String &p_new_ return; //scene not editable for (Set::Element *F = E->get().front(); F; F = F->next()) { - Node *n = F->get(); if (base && !base->is_a_parent_of(n)) @@ -850,7 +831,6 @@ void LiveEditor::_reparent_node_func(const NodePath &p_at, const NodePath &p_new return; //scene not editable for (Set::Element *F = E->get().front(); F; F = F->next()) { - Node *n = F->get(); if (base && !base->is_a_parent_of(n)) diff --git a/scene/debugger/scene_debugger.h b/scene/debugger/scene_debugger.h index e8521d6a20..a2bafde039 100644 --- a/scene/debugger/scene_debugger.h +++ b/scene/debugger/scene_debugger.h @@ -39,7 +39,6 @@ class Script; class SceneDebugger { - public: static void initialize(); static void deinitialize(); @@ -59,7 +58,6 @@ public: #ifdef DEBUG_ENABLED class SceneDebuggerObject { - private: void _parse_script_properties(Script *p_script, ScriptInstance *p_instance); @@ -77,7 +75,6 @@ public: }; class SceneDebuggerTree { - public: struct RemoteNode { int child_count; @@ -104,7 +101,6 @@ public: }; class LiveEditor { - private: friend class SceneDebugger; Map live_edit_node_path_cache; diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 1cdc6f8057..79e1102f6b 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -35,7 +35,6 @@ #include "scene/scene_string_names.h" void BaseButton::_unpress_group() { - if (!button_group.is_valid()) return; @@ -52,7 +51,6 @@ void BaseButton::_unpress_group() { } void BaseButton::_gui_input(Ref p_event) { - if (status.disabled) // no interaction with disabled button return; @@ -78,9 +76,7 @@ void BaseButton::_gui_input(Ref p_event) { } void BaseButton::_notification(int p_what) { - if (p_what == NOTIFICATION_MOUSE_ENTER) { - status.hovering = true; update(); } @@ -90,7 +86,6 @@ void BaseButton::_notification(int p_what) { update(); } if (p_what == NOTIFICATION_DRAG_BEGIN || p_what == NOTIFICATION_SCROLL_BEGIN) { - if (status.press_attempt) { status.press_attempt = false; update(); @@ -98,13 +93,11 @@ void BaseButton::_notification(int p_what) { } if (p_what == NOTIFICATION_FOCUS_ENTER) { - status.hovering = true; update(); } if (p_what == NOTIFICATION_FOCUS_EXIT) { - if (status.press_attempt) { status.press_attempt = false; status.hovering = false; @@ -116,7 +109,6 @@ void BaseButton::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE || (p_what == NOTIFICATION_VISIBILITY_CHANGED && !is_visible_in_tree())) { - if (!toggle_mode) { status.pressed = false; } @@ -127,7 +119,6 @@ void BaseButton::_notification(int p_what) { } void BaseButton::_pressed() { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_pressed); } @@ -136,7 +127,6 @@ void BaseButton::_pressed() { } void BaseButton::_toggled(bool p_pressed) { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, p_pressed); } @@ -145,7 +135,6 @@ void BaseButton::_toggled(bool p_pressed) { } void BaseButton::on_action_event(Ref p_event) { - if (p_event->is_pressed()) { status.press_attempt = true; status.pressing_inside = true; @@ -210,12 +199,10 @@ void BaseButton::set_disabled(bool p_disabled) { } bool BaseButton::is_disabled() const { - return status.disabled; } void BaseButton::set_pressed(bool p_pressed) { - if (!toggle_mode) return; if (status.pressed == p_pressed) @@ -232,22 +219,18 @@ void BaseButton::set_pressed(bool p_pressed) { } bool BaseButton::is_pressing() const { - return status.press_attempt; } bool BaseButton::is_pressed() const { - return toggle_mode ? status.pressed : status.press_attempt; } bool BaseButton::is_hovered() const { - return status.hovering; } BaseButton::DrawMode BaseButton::get_draw_mode() const { - if (status.disabled) { return DRAW_DISABLED; }; @@ -262,12 +245,10 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const { bool pressing; if (status.press_attempt) { - pressing = (status.pressing_inside || keep_pressed_outside); if (status.pressed) pressing = !pressing; } else { - pressing = status.pressed; } @@ -281,47 +262,38 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const { } void BaseButton::set_toggle_mode(bool p_on) { - toggle_mode = p_on; } bool BaseButton::is_toggle_mode() const { - return toggle_mode; } void BaseButton::set_shortcut_in_tooltip(bool p_on) { - shortcut_in_tooltip = p_on; } bool BaseButton::is_shortcut_in_tooltip_enabled() const { - return shortcut_in_tooltip; } void BaseButton::set_action_mode(ActionMode p_mode) { - action_mode = p_mode; } BaseButton::ActionMode BaseButton::get_action_mode() const { - return action_mode; } void BaseButton::set_button_mask(int p_mask) { - button_mask = p_mask; } int BaseButton::get_button_mask() const { - return button_mask; } void BaseButton::set_enabled_focus_mode(FocusMode p_mode) { - enabled_focus_mode = p_mode; if (!status.disabled) { set_focus_mode(p_mode); @@ -329,22 +301,18 @@ void BaseButton::set_enabled_focus_mode(FocusMode p_mode) { } Control::FocusMode BaseButton::get_enabled_focus_mode() const { - return enabled_focus_mode; } void BaseButton::set_keep_pressed_outside(bool p_on) { - keep_pressed_outside = p_on; } bool BaseButton::is_keep_pressed_outside() const { - return keep_pressed_outside; } void BaseButton::set_shortcut(const Ref &p_shortcut) { - shortcut = p_shortcut; set_process_unhandled_input(shortcut.is_valid()); } @@ -354,15 +322,12 @@ Ref BaseButton::get_shortcut() const { } void BaseButton::_unhandled_input(Ref p_event) { - if (!is_disabled() && is_visible_in_tree() && !p_event->is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) { - on_action_event(p_event); } } String BaseButton::get_tooltip(const Point2 &p_pos) const { - String tooltip = Control::get_tooltip(p_pos); if (shortcut_in_tooltip && shortcut.is_valid() && shortcut->is_valid()) { String text = shortcut->get_name() + " (" + shortcut->get_as_text() + ")"; @@ -375,7 +340,6 @@ String BaseButton::get_tooltip(const Point2 &p_pos) const { } void BaseButton::set_button_group(const Ref &p_group) { - if (button_group.is_valid()) { button_group->buttons.erase(this); } @@ -390,12 +354,10 @@ void BaseButton::set_button_group(const Ref &p_group) { } Ref BaseButton::get_button_group() const { - return button_group; } void BaseButton::_bind_methods() { - ClassDB::bind_method(D_METHOD("_gui_input"), &BaseButton::_gui_input); ClassDB::bind_method(D_METHOD("_unhandled_input"), &BaseButton::_unhandled_input); ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &BaseButton::set_pressed); @@ -452,7 +414,6 @@ void BaseButton::_bind_methods() { } BaseButton::BaseButton() { - toggle_mode = false; shortcut_in_tooltip = true; keep_pressed_outside = false; @@ -468,21 +429,18 @@ BaseButton::BaseButton() { } BaseButton::~BaseButton() { - if (button_group.is_valid()) { button_group->buttons.erase(this); } } void ButtonGroup::get_buttons(List *r_buttons) { - for (Set::Element *E = buttons.front(); E; E = E->next()) { r_buttons->push_back(E->get()); } } Array ButtonGroup::_get_buttons() { - Array btns; for (Set::Element *E = buttons.front(); E; E = E->next()) { btns.push_back(E->get()); @@ -492,7 +450,6 @@ Array ButtonGroup::_get_buttons() { } BaseButton *ButtonGroup::get_pressed_button() { - for (Set::Element *E = buttons.front(); E; E = E->next()) { if (E->get()->is_pressed()) return E->get(); @@ -502,12 +459,10 @@ BaseButton *ButtonGroup::get_pressed_button() { } void ButtonGroup::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_pressed_button"), &ButtonGroup::get_pressed_button); ClassDB::bind_method(D_METHOD("get_buttons"), &ButtonGroup::_get_buttons); } ButtonGroup::ButtonGroup() { - set_local_to_scene(true); } diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h index 21757488a6..05a975e266 100644 --- a/scene/gui/base_button.h +++ b/scene/gui/base_button.h @@ -36,7 +36,6 @@ class ButtonGroup; class BaseButton : public Control { - GDCLASS(BaseButton, Control); public: @@ -55,7 +54,6 @@ private: ActionMode action_mode; struct Status { - bool pressed; bool hovering; bool press_attempt; @@ -136,7 +134,6 @@ VARIANT_ENUM_CAST(BaseButton::DrawMode) VARIANT_ENUM_CAST(BaseButton::ActionMode) class ButtonGroup : public Resource { - GDCLASS(ButtonGroup, Resource); friend class BaseButton; Set buttons; diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 0da6e0fdfa..5252f3f2f2 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -33,14 +33,12 @@ #include "margin_container.h" struct _MinSizeCache { - int min_size; bool will_stretch; int final_size; }; void BoxContainer::_resort() { - /** First pass, determine minimum size AND amount of stretchable elements */ Size2i new_size = get_size(); @@ -105,7 +103,6 @@ void BoxContainer::_resort() { bool refit_successful = true; //assume refit-test will go well for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; @@ -158,7 +155,6 @@ void BoxContainer::_resort() { int idx = 0; for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; @@ -187,10 +183,8 @@ void BoxContainer::_resort() { Rect2 rect; if (vertical) { - rect = Rect2(0, from, new_size.width, size); } else { - rect = Rect2(from, 0, size, new_size.height); } @@ -202,7 +196,6 @@ void BoxContainer::_resort() { } Size2 BoxContainer::get_minimum_size() const { - /* Calculate MINIMUM SIZE */ Size2i minimum; @@ -247,15 +240,11 @@ Size2 BoxContainer::get_minimum_size() const { } void BoxContainer::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_SORT_CHILDREN: { - _resort(); } break; case NOTIFICATION_THEME_CHANGED: { - minimum_size_changed(); } break; } @@ -271,7 +260,6 @@ BoxContainer::AlignMode BoxContainer::get_alignment() const { } void BoxContainer::add_spacer(bool p_begin) { - Control *c = memnew(Control); c->set_mouse_filter(MOUSE_FILTER_PASS); //allow spacer to pass mouse events @@ -286,13 +274,11 @@ void BoxContainer::add_spacer(bool p_begin) { } BoxContainer::BoxContainer(bool p_vertical) { - vertical = p_vertical; align = ALIGN_BEGIN; } void BoxContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_spacer", "begin"), &BoxContainer::add_spacer); ClassDB::bind_method(D_METHOD("get_alignment"), &BoxContainer::get_alignment); ClassDB::bind_method(D_METHOD("set_alignment", "alignment"), &BoxContainer::set_alignment); @@ -305,7 +291,6 @@ void BoxContainer::_bind_methods() { } MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control *p_control, bool p_expand) { - Label *l = memnew(Label); l->set_text(p_label); add_child(l); diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h index 0d7deda364..cc6f6349df 100644 --- a/scene/gui/box_container.h +++ b/scene/gui/box_container.h @@ -34,7 +34,6 @@ #include "scene/gui/container.h" class BoxContainer : public Container { - GDCLASS(BoxContainer, Container); public: @@ -67,7 +66,6 @@ public: }; class HBoxContainer : public BoxContainer { - GDCLASS(HBoxContainer, BoxContainer); public: @@ -77,7 +75,6 @@ public: class MarginContainer; class VBoxContainer : public BoxContainer { - GDCLASS(VBoxContainer, BoxContainer); public: diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 1f8487c173..cf1ff059bf 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -34,7 +34,6 @@ #include "servers/rendering_server.h" Size2 Button::get_minimum_size() const { - Size2 minsize = get_theme_font("font")->get_string_size(xl_text); if (clip_text) minsize.width = 0; @@ -47,7 +46,6 @@ Size2 Button::get_minimum_size() const { _icon = icon; if (!_icon.is_null()) { - minsize.height = MAX(minsize.height, _icon->get_height()); minsize.width += _icon->get_width(); if (xl_text != "") @@ -59,21 +57,17 @@ Size2 Button::get_minimum_size() const { } void Button::_set_internal_margin(Margin p_margin, float p_value) { - _internal_margin[p_margin] = p_value; } void Button::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_TRANSLATION_CHANGED: { - xl_text = tr(text); minimum_size_changed(); update(); } break; case NOTIFICATION_DRAW: { - RID ci = get_canvas_item(); Size2 size = get_size(); Color color; @@ -83,7 +77,6 @@ void Button::_notification(int p_what) { switch (get_draw_mode()) { case DRAW_NORMAL: { - style = get_theme_stylebox("normal"); if (!flat) style->draw(ci, Rect2(Point2(0, 0), size)); @@ -92,7 +85,6 @@ void Button::_notification(int p_what) { color_icon = get_theme_color("icon_color_normal"); } break; case DRAW_HOVER_PRESSED: { - if (has_theme_stylebox("hover_pressed") && has_theme_stylebox_override("hover_pressed")) { style = get_theme_stylebox("hover_pressed"); if (!flat) @@ -109,7 +101,6 @@ void Button::_notification(int p_what) { [[fallthrough]]; } case DRAW_PRESSED: { - style = get_theme_stylebox("pressed"); if (!flat) style->draw(ci, Rect2(Point2(0, 0), size)); @@ -122,7 +113,6 @@ void Button::_notification(int p_what) { } break; case DRAW_HOVER: { - style = get_theme_stylebox("hover"); if (!flat) style->draw(ci, Rect2(Point2(0, 0), size)); @@ -132,7 +122,6 @@ void Button::_notification(int p_what) { } break; case DRAW_DISABLED: { - style = get_theme_stylebox("disabled"); if (!flat) style->draw(ci, Rect2(Point2(0, 0), size)); @@ -144,7 +133,6 @@ void Button::_notification(int p_what) { } if (has_focus()) { - Ref style2 = get_theme_stylebox("focus"); style2->draw(ci, Rect2(Point2(), size)); } @@ -158,7 +146,6 @@ void Button::_notification(int p_what) { Rect2 icon_region = Rect2(); if (!_icon.is_null()) { - int valign = size.height - style->get_minimum_size().y; if (is_disabled()) { color_icon.a = 0.4; @@ -235,7 +222,6 @@ void Button::_notification(int p_what) { } void Button::set_text(const String &p_text) { - if (text == p_text) return; text = p_text; @@ -245,12 +231,10 @@ void Button::set_text(const String &p_text) { minimum_size_changed(); } String Button::get_text() const { - return text; } void Button::set_icon(const Ref &p_icon) { - if (icon == p_icon) return; icon = p_icon; @@ -260,59 +244,49 @@ void Button::set_icon(const Ref &p_icon) { } Ref Button::get_icon() const { - return icon; } void Button::set_expand_icon(bool p_expand_icon) { - expand_icon = p_expand_icon; update(); minimum_size_changed(); } bool Button::is_expand_icon() const { - return expand_icon; } void Button::set_flat(bool p_flat) { - flat = p_flat; update(); _change_notify("flat"); } bool Button::is_flat() const { - return flat; } void Button::set_clip_text(bool p_clip_text) { - clip_text = p_clip_text; update(); minimum_size_changed(); } bool Button::get_clip_text() const { - return clip_text; } void Button::set_text_align(TextAlign p_align) { - align = p_align; update(); } Button::TextAlign Button::get_text_align() const { - return align; } void Button::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_text", "text"), &Button::set_text); ClassDB::bind_method(D_METHOD("get_text"), &Button::get_text); ClassDB::bind_method(D_METHOD("set_button_icon", "texture"), &Button::set_icon); @@ -339,7 +313,6 @@ void Button::_bind_methods() { } Button::Button(const String &p_text) { - flat = false; clip_text = false; expand_icon = false; diff --git a/scene/gui/button.h b/scene/gui/button.h index 3135b98578..e757badd3e 100644 --- a/scene/gui/button.h +++ b/scene/gui/button.h @@ -34,7 +34,6 @@ #include "scene/gui/base_button.h" class Button : public BaseButton { - GDCLASS(Button, BaseButton); public: diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp index 64d6885bc8..ff2b5ea17e 100644 --- a/scene/gui/center_container.cpp +++ b/scene/gui/center_container.cpp @@ -31,12 +31,10 @@ #include "center_container.h" Size2 CenterContainer::get_minimum_size() const { - if (use_top_left) return Size2(); Size2 ms; for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to(get_child(i)); if (!c) continue; @@ -53,7 +51,6 @@ Size2 CenterContainer::get_minimum_size() const { } void CenterContainer::set_use_top_left(bool p_enable) { - if (use_top_left == p_enable) { return; } @@ -65,17 +62,13 @@ void CenterContainer::set_use_top_left(bool p_enable) { } bool CenterContainer::is_using_top_left() const { - return use_top_left; } void CenterContainer::_notification(int p_what) { - if (p_what == NOTIFICATION_SORT_CHILDREN) { - Size2 size = get_size(); for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to(get_child(i)); if (!c) continue; @@ -90,7 +83,6 @@ void CenterContainer::_notification(int p_what) { } void CenterContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_use_top_left", "enable"), &CenterContainer::set_use_top_left); ClassDB::bind_method(D_METHOD("is_using_top_left"), &CenterContainer::is_using_top_left); @@ -98,6 +90,5 @@ void CenterContainer::_bind_methods() { } CenterContainer::CenterContainer() { - use_top_left = false; } diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h index 98733f384d..ae9f87db16 100644 --- a/scene/gui/center_container.h +++ b/scene/gui/center_container.h @@ -34,7 +34,6 @@ #include "scene/gui/container.h" class CenterContainer : public Container { - GDCLASS(CenterContainer, Container); bool use_top_left; diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index 470450e3ed..8681b9bda7 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -51,7 +51,6 @@ Size2 CheckBox::get_icon_size() const { } Size2 CheckBox::get_minimum_size() const { - Size2 minsize = Button::get_minimum_size(); Size2 tex_size = get_icon_size(); minsize.width += tex_size.width; @@ -65,12 +64,9 @@ Size2 CheckBox::get_minimum_size() const { } void CheckBox::_notification(int p_what) { - if (p_what == NOTIFICATION_THEME_CHANGED) { - _set_internal_margin(MARGIN_LEFT, get_icon_size().width); } else if (p_what == NOTIFICATION_DRAW) { - RID ci = get_canvas_item(); Ref on = Control::get_theme_icon(is_radio() ? "radio_checked" : "checked"); @@ -89,7 +85,6 @@ void CheckBox::_notification(int p_what) { } bool CheckBox::is_radio() { - return get_button_group().is_valid(); } diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h index 7c8f8c11d6..58f7cce55e 100644 --- a/scene/gui/check_box.h +++ b/scene/gui/check_box.h @@ -36,7 +36,6 @@ @author Mariano Suligoy */ class CheckBox : public Button { - GDCLASS(CheckBox, Button); protected: diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index 96484424f8..041a28a0be 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -34,7 +34,6 @@ #include "servers/rendering_server.h" Size2 CheckButton::get_icon_size() const { - Ref on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on"); Ref off = Control::get_theme_icon(is_disabled() ? "off_disabled" : "off"); Size2 tex_size = Size2(0, 0); @@ -47,7 +46,6 @@ Size2 CheckButton::get_icon_size() const { } Size2 CheckButton::get_minimum_size() const { - Size2 minsize = Button::get_minimum_size(); Size2 tex_size = get_icon_size(); minsize.width += tex_size.width; @@ -60,12 +58,9 @@ Size2 CheckButton::get_minimum_size() const { } void CheckButton::_notification(int p_what) { - if (p_what == NOTIFICATION_THEME_CHANGED) { - _set_internal_margin(MARGIN_RIGHT, get_icon_size().width); } else if (p_what == NOTIFICATION_DRAW) { - RID ci = get_canvas_item(); Ref on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on"); @@ -86,7 +81,6 @@ void CheckButton::_notification(int p_what) { } CheckButton::CheckButton() { - set_toggle_mode(true); set_text_align(ALIGN_LEFT); diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h index 3599c26a4c..8bbad0b4b3 100644 --- a/scene/gui/check_button.h +++ b/scene/gui/check_button.h @@ -36,7 +36,6 @@ @author Juan Linietsky */ class CheckButton : public Button { - GDCLASS(CheckButton, Button); protected: diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 63878a0b26..1730df6bb3 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -41,17 +41,14 @@ #include "scene/main/window.h" void ColorPicker::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker")); bt_add_preset->set_icon(get_theme_icon("add_preset")); _update_controls(); } break; case NOTIFICATION_ENTER_TREE: { - btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker")); bt_add_preset->set_icon(get_theme_icon("add_preset")); @@ -68,18 +65,15 @@ void ColorPicker::_notification(int p_what) { #endif } break; case NOTIFICATION_PARENTED: { - for (int i = 0; i < 4; i++) set_margin((Margin)i, get_theme_constant("margin")); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - Popup *p = Object::cast_to(get_parent()); if (p) p->set_size(Size2(get_combined_minimum_size().width + get_theme_constant("margin") * 2, get_combined_minimum_size().height + get_theme_constant("margin") * 2)); } break; case NOTIFICATION_WM_CLOSE_REQUEST: { - if (screen != nullptr && screen->is_visible()) screen->hide(); } break; @@ -87,12 +81,10 @@ void ColorPicker::_notification(int p_what) { } void ColorPicker::set_focus_on_line_edit() { - c_text->call_deferred("grab_focus"); } void ColorPicker::_update_controls() { - const char *rgb[3] = { "R", "G", "B" }; const char *hsv[3] = { "H", "S", "V" }; @@ -127,7 +119,6 @@ void ColorPicker::_update_controls() { } void ColorPicker::_set_pick_color(const Color &p_color, bool p_update_sliders) { - color = p_color; if (color != last_hsv) { h = color.get_h(); @@ -143,12 +134,10 @@ void ColorPicker::_set_pick_color(const Color &p_color, bool p_update_sliders) { } void ColorPicker::set_pick_color(const Color &p_color) { - _set_pick_color(p_color, true); //because setters can't have more arguments } void ColorPicker::set_edit_alpha(bool p_show) { - edit_alpha = p_show; _update_controls(); @@ -160,12 +149,10 @@ void ColorPicker::set_edit_alpha(bool p_show) { } bool ColorPicker::is_editing_alpha() const { - return edit_alpha; } void ColorPicker::_value_changed(double) { - if (updating) return; @@ -185,7 +172,6 @@ void ColorPicker::_value_changed(double) { } void ColorPicker::_html_entered(const String &p_html) { - if (updating || text_is_constructor || !c_text->is_visible()) return; @@ -202,11 +188,9 @@ void ColorPicker::_html_entered(const String &p_html) { } void ColorPicker::_update_color(bool p_update_sliders) { - updating = true; if (p_update_sliders) { - if (hsv_mode_enabled) { for (int i = 0; i < 4; i++) { scroll[i]->set_step(1.0); @@ -266,7 +250,6 @@ void ColorPicker::_update_presets() { } void ColorPicker::_text_type_toggled() { - text_is_constructor = !text_is_constructor; if (text_is_constructor) { text_type->set_text(""); @@ -283,12 +266,10 @@ void ColorPicker::_text_type_toggled() { } Color ColorPicker::get_pick_color() const { - return color; } void ColorPicker::add_preset(const Color &p_color) { - if (presets.find(p_color)) { presets.move_to_back(presets.find(p_color)); } else { @@ -305,7 +286,6 @@ void ColorPicker::add_preset(const Color &p_color) { } void ColorPicker::erase_preset(const Color &p_color) { - if (presets.find(p_color)) { presets.erase(presets.find(p_color)); preset->update(); @@ -320,7 +300,6 @@ void ColorPicker::erase_preset(const Color &p_color) { } PackedColorArray ColorPicker::get_presets() const { - PackedColorArray arr; arr.resize(presets.size()); for (int i = 0; i < presets.size(); i++) { @@ -330,7 +309,6 @@ PackedColorArray ColorPicker::get_presets() const { } void ColorPicker::set_hsv_mode(bool p_enabled) { - if (hsv_mode_enabled == p_enabled || raw_mode_enabled) return; hsv_mode_enabled = p_enabled; @@ -345,12 +323,10 @@ void ColorPicker::set_hsv_mode(bool p_enabled) { } bool ColorPicker::is_hsv_mode() const { - return hsv_mode_enabled; } void ColorPicker::set_raw_mode(bool p_enabled) { - if (raw_mode_enabled == p_enabled || hsv_mode_enabled) return; raw_mode_enabled = p_enabled; @@ -365,7 +341,6 @@ void ColorPicker::set_raw_mode(bool p_enabled) { } bool ColorPicker::is_raw_mode() const { - return raw_mode_enabled; } @@ -458,7 +433,6 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { } void ColorPicker::_uv_input(const Ref &p_event) { - Ref bev = p_event; if (bev.is_valid()) { @@ -501,11 +475,9 @@ void ColorPicker::_uv_input(const Ref &p_event) { } void ColorPicker::_w_input(const Ref &p_event) { - Ref bev = p_event; if (bev.is_valid()) { - if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) { changing_color = true; float y = CLAMP((float)bev->get_position().y, 0, w_edit->get_size().height); @@ -526,7 +498,6 @@ void ColorPicker::_w_input(const Ref &p_event) { Ref mev = p_event; if (mev.is_valid()) { - if (!changing_color) return; float y = CLAMP((float)mev->get_position().y, 0, w_edit->get_size().height); @@ -541,7 +512,6 @@ void ColorPicker::_w_input(const Ref &p_event) { } void ColorPicker::_preset_input(const Ref &p_event) { - Ref bev = p_event; if (bev.is_valid()) { @@ -569,7 +539,6 @@ void ColorPicker::_preset_input(const Ref &p_event) { Ref mev = p_event; if (mev.is_valid()) { - int index = mev->get_position().x * presets.size(); if (preset->get_size().x != 0) { index /= preset->get_size().x; @@ -581,7 +550,6 @@ void ColorPicker::_preset_input(const Ref &p_event) { } void ColorPicker::_screen_input(const Ref &p_event) { - Ref bev = p_event; if (bev.is_valid() && bev->get_button_index() == BUTTON_LEFT && !bev->is_pressed()) { emit_signal("color_changed", color); @@ -596,7 +564,6 @@ void ColorPicker::_screen_input(const Ref &p_event) { Ref img = r->get_texture()->get_data(); if (img.is_valid() && !img->empty()) { - Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position(); Color c = img->get_pixel(ofs.x, r->get_visible_rect().size.height - ofs.y); @@ -688,7 +655,6 @@ bool ColorPicker::are_presets_visible() const { } void ColorPicker::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPicker::set_pick_color); ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPicker::get_pick_color); ClassDB::bind_method(D_METHOD("set_hsv_mode"), &ColorPicker::set_hsv_mode); @@ -722,7 +688,6 @@ void ColorPicker::_bind_methods() { ColorPicker::ColorPicker() : BoxContainer(true) { - updating = true; edit_alpha = true; text_is_constructor = false; @@ -779,7 +744,6 @@ ColorPicker::ColorPicker() : vbr->set_h_size_flags(SIZE_EXPAND_FILL); for (int i = 0; i < 4; i++) { - HBoxContainer *hbc = memnew(HBoxContainer); labels[i] = memnew(Label()); @@ -826,13 +790,11 @@ ColorPicker::ColorPicker() : text_type->set_text("#"); text_type->set_tooltip(TTR("Switch between hexadecimal and code values.")); if (Engine::get_singleton()->is_editor_hint()) { - #ifdef TOOLS_ENABLED text_type->set_custom_minimum_size(Size2(28 * EDSCALE, 0)); // Adjust for the width of the "Script" icon. #endif text_type->connect("pressed", callable_mp(this, &ColorPicker::_text_type_toggled)); } else { - text_type->set_flat(true); text_type->set_mouse_filter(MOUSE_FILTER_IGNORE); } @@ -873,19 +835,16 @@ ColorPicker::ColorPicker() : ///////////////// void ColorPickerButton::_color_changed(const Color &p_color) { - color = p_color; update(); emit_signal("color_changed", color); } void ColorPickerButton::_modal_closed() { - emit_signal("popup_closed"); } void ColorPickerButton::pressed() { - _update_picker(); popup->set_as_minsize(); @@ -904,7 +863,6 @@ void ColorPickerButton::pressed() { if (i & 1) { cp_rect.position.x = get_screen_position().x; } else { - cp_rect.position.x = get_screen_position().x - MAX(0, (cp_rect.size.x - get_size().x)); } @@ -918,10 +876,8 @@ void ColorPickerButton::pressed() { } void ColorPickerButton::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_DRAW: { - const Ref normal = get_theme_stylebox("normal"); const Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size()); draw_texture_rect(Control::get_theme_icon("bg", "ColorPickerButton"), r, true); @@ -933,7 +889,6 @@ void ColorPickerButton::_notification(int p_what) { } } break; case NOTIFICATION_WM_CLOSE_REQUEST: { - if (popup) popup->hide(); } break; @@ -947,7 +902,6 @@ void ColorPickerButton::_notification(int p_what) { } void ColorPickerButton::set_pick_color(const Color &p_color) { - color = p_color; if (picker) { picker->set_pick_color(p_color); @@ -956,12 +910,10 @@ void ColorPickerButton::set_pick_color(const Color &p_color) { update(); } Color ColorPickerButton::get_pick_color() const { - return color; } void ColorPickerButton::set_edit_alpha(bool p_show) { - edit_alpha = p_show; if (picker) { picker->set_edit_alpha(p_show); @@ -969,18 +921,15 @@ void ColorPickerButton::set_edit_alpha(bool p_show) { } bool ColorPickerButton::is_editing_alpha() const { - return edit_alpha; } ColorPicker *ColorPickerButton::get_picker() { - _update_picker(); return picker; } PopupPanel *ColorPickerButton::get_popup() { - _update_picker(); return popup; } @@ -1004,7 +953,6 @@ void ColorPickerButton::_update_picker() { } void ColorPickerButton::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPickerButton::set_pick_color); ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPickerButton::get_pick_color); ClassDB::bind_method(D_METHOD("get_picker"), &ColorPickerButton::get_picker); @@ -1020,7 +968,6 @@ void ColorPickerButton::_bind_methods() { } ColorPickerButton::ColorPickerButton() { - // Initialization is now done deferred, // this improves performance in the inspector as the color picker // can be expensive to initialize. diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index dde2f37135..31ae92f4e4 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -44,7 +44,6 @@ #include "scene/gui/tool_button.h" class ColorPicker : public BoxContainer { - GDCLASS(ColorPicker, BoxContainer); private: @@ -139,7 +138,6 @@ public: }; class ColorPickerButton : public Button { - GDCLASS(ColorPickerButton, Button); PopupPanel *popup; diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp index 61260e153c..627e589c02 100644 --- a/scene/gui/color_rect.cpp +++ b/scene/gui/color_rect.cpp @@ -31,25 +31,21 @@ #include "color_rect.h" void ColorRect::set_frame_color(const Color &p_color) { - color = p_color; update(); } Color ColorRect::get_frame_color() const { - return color; } void ColorRect::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { draw_rect(Rect2(Point2(), get_size()), color); } } void ColorRect::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_frame_color", "color"), &ColorRect::set_frame_color); ClassDB::bind_method(D_METHOD("get_frame_color"), &ColorRect::get_frame_color); @@ -57,6 +53,5 @@ void ColorRect::_bind_methods() { } ColorRect::ColorRect() { - color = Color(1, 1, 1); } diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index 41f33bb719..5bde293648 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -33,7 +33,6 @@ #include "scene/scene_string_names.h" void Container::_child_minsize_changed() { - //Size2 ms = get_combined_minimum_size(); //if (ms.width > get_size().width || ms.height > get_size().height) { minimum_size_changed(); @@ -41,7 +40,6 @@ void Container::_child_minsize_changed() { } void Container::add_child_notify(Node *p_child) { - Control::add_child_notify(p_child); Control *control = Object::cast_to(p_child); @@ -57,7 +55,6 @@ void Container::add_child_notify(Node *p_child) { } void Container::move_child_notify(Node *p_child) { - Control::move_child_notify(p_child); if (!Object::cast_to(p_child)) @@ -68,7 +65,6 @@ void Container::move_child_notify(Node *p_child) { } void Container::remove_child_notify(Node *p_child) { - Control::remove_child_notify(p_child); Control *control = Object::cast_to(p_child); @@ -84,7 +80,6 @@ void Container::remove_child_notify(Node *p_child) { } void Container::_sort_children() { - if (!is_inside_tree()) return; @@ -94,7 +89,6 @@ void Container::_sort_children() { } void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) { - ERR_FAIL_COND(!p_child); ERR_FAIL_COND(p_child->get_parent() != this); @@ -133,7 +127,6 @@ void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) { } void Container::queue_sort() { - if (!is_inside_tree()) return; @@ -145,23 +138,18 @@ void Container::queue_sort() { } void Container::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { pending_sort = false; queue_sort(); } break; case NOTIFICATION_RESIZED: { - queue_sort(); } break; case NOTIFICATION_THEME_CHANGED: { - queue_sort(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible_in_tree()) { queue_sort(); } @@ -170,7 +158,6 @@ void Container::_notification(int p_what) { } String Container::get_configuration_warning() const { - String warning = Control::get_configuration_warning(); if (get_class() == "Container" && get_script().is_null()) { @@ -183,7 +170,6 @@ String Container::get_configuration_warning() const { } void Container::_bind_methods() { - ClassDB::bind_method(D_METHOD("_sort_children"), &Container::_sort_children); ClassDB::bind_method(D_METHOD("queue_sort"), &Container::queue_sort); @@ -194,7 +180,6 @@ void Container::_bind_methods() { } Container::Container() { - pending_sort = false; // All containers should let mouse events pass by default. set_mouse_filter(MOUSE_FILTER_PASS); diff --git a/scene/gui/container.h b/scene/gui/container.h index 0b736d9790..c8db5ee28f 100644 --- a/scene/gui/container.h +++ b/scene/gui/container.h @@ -34,7 +34,6 @@ #include "scene/gui/control.h" class Container : public Control { - GDCLASS(Container, Control); bool pending_sort; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index b710ba4803..3dbdd4dfab 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -49,7 +49,6 @@ #ifdef TOOLS_ENABLED Dictionary Control::_edit_get_state() const { - Dictionary s; s["rotation"] = get_rotation(); s["scale"] = get_scale(); @@ -70,7 +69,6 @@ Dictionary Control::_edit_get_state() const { } void Control::_edit_set_state(const Dictionary &p_state) { - Dictionary state = p_state; set_rotation(state["rotation"]); @@ -162,7 +160,6 @@ Size2 Control::_edit_get_minimum_size() const { #endif void Control::set_custom_minimum_size(const Size2 &p_custom) { - if (p_custom == data.custom_minimum_size) return; data.custom_minimum_size = p_custom; @@ -170,12 +167,10 @@ void Control::set_custom_minimum_size(const Size2 &p_custom) { } Size2 Control::get_custom_minimum_size() const { - return data.custom_minimum_size; } void Control::_update_minimum_size_cache() { - Size2 minsize = get_minimum_size(); minsize.x = MAX(minsize.x, data.custom_minimum_size.x); minsize.y = MAX(minsize.y, data.custom_minimum_size.y); @@ -192,7 +187,6 @@ void Control::_update_minimum_size_cache() { } Size2 Control::get_combined_minimum_size() const { - if (!data.minimum_size_valid) { const_cast(this)->_update_minimum_size_cache(); } @@ -200,7 +194,6 @@ Size2 Control::get_combined_minimum_size() const { } Transform2D Control::_get_internal_transform() const { - Transform2D rot_scale; rot_scale.set_rotation_and_scale(data.rotation, data.scale); Transform2D offset; @@ -210,14 +203,12 @@ Transform2D Control::_get_internal_transform() const { } bool Control::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; if (!name.begins_with("custom")) { return false; } if (p_value.get_type() == Variant::NIL) { - if (name.begins_with("custom_icons/")) { String dname = name.get_slicec('/', 1); if (data.icon_override.has(dname)) { @@ -283,7 +274,6 @@ bool Control::_set(const StringName &p_name, const Variant &p_value) { } void Control::_update_minimum_size() { - if (!is_inside_tree()) return; @@ -302,7 +292,6 @@ void Control::_update_minimum_size() { } bool Control::_get(const StringName &p_name, Variant &r_ret) const { - String sname = p_name; if (!sname.begins_with("custom")) { @@ -338,7 +327,6 @@ bool Control::_get(const StringName &p_name, Variant &r_ret) const { return true; } void Control::_get_property_list(List *p_list) const { - Ref theme = Theme::get_default(); /* Using the default theme since the properties below are meant for editor only if (data.theme.is_valid()) { @@ -353,7 +341,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_icon_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.icon_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -365,7 +352,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_shader_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.shader_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -377,7 +363,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_stylebox_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.style_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -389,7 +374,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_font_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.font_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -401,7 +385,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_color_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.color_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -413,7 +396,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_constant_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.constant_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -424,19 +406,16 @@ void Control::_get_property_list(List *p_list) const { } Control *Control::get_parent_control() const { - return data.parent; } void Control::_resize(const Size2 &p_size) { - _size_changed(); } //moved theme configuration here, so controls can set up even if still not inside active scene void Control::add_child_notify(Node *p_child) { - Control *child_c = Object::cast_to(p_child); if (child_c && child_c->data.theme.is_null() && (data.theme_owner || data.theme_owner_window)) { @@ -451,7 +430,6 @@ void Control::add_child_notify(Node *p_child) { } void Control::remove_child_notify(Node *p_child) { - Control *child_c = Object::cast_to(p_child); if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) { @@ -466,7 +444,6 @@ void Control::remove_child_notify(Node *p_child) { } void Control::_update_canvas_item_transform() { - Transform2D xform = _get_internal_transform(); xform[2] += get_position(); @@ -474,24 +451,19 @@ void Control::_update_canvas_item_transform() { } void Control::_notification(int p_notification) { - switch (p_notification) { - case NOTIFICATION_ENTER_TREE: { - } break; case NOTIFICATION_POST_ENTER_TREE: { data.minimum_size_valid = false; _size_changed(); } break; case NOTIFICATION_EXIT_TREE: { - get_viewport()->_gui_remove_control(this); } break; case NOTIFICATION_ENTER_CANVAS: { - data.parent = Object::cast_to(get_parent()); Node *parent = this; //meh @@ -499,7 +471,6 @@ void Control::_notification(int p_notification) { bool subwindow = false; while (parent) { - parent = parent->get_parent(); if (!parent) @@ -516,7 +487,6 @@ void Control::_notification(int p_notification) { if (parent_control) { break; } else if (ci) { - } else { break; } @@ -536,7 +506,6 @@ void Control::_notification(int p_notification) { data.parent_canvas_item = get_parent_item(); if (data.parent_canvas_item) { - data.parent_canvas_item->connect("item_rect_changed", callable_mp(this, &Control::_size_changed)); } else { //connect viewport @@ -544,9 +513,7 @@ void Control::_notification(int p_notification) { } } break; case NOTIFICATION_EXIT_CANVAS: { - if (data.parent_canvas_item) { - data.parent_canvas_item->disconnect("item_rect_changed", callable_mp(this, &Control::_size_changed)); data.parent_canvas_item = nullptr; } else if (!is_set_as_toplevel()) { @@ -576,11 +543,9 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_RESIZED: { - emit_signal(SceneStringNames::get_singleton()->resized); } break; case NOTIFICATION_DRAW: { - _update_canvas_item_transform(); RenderingServer::get_singleton()->canvas_item_set_custom_rect(get_canvas_item(), !data.disable_visibility_clip, Rect2(Point2(), get_size())); RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), data.clip_contents); @@ -588,33 +553,26 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_MOUSE_ENTER: { - emit_signal(SceneStringNames::get_singleton()->mouse_entered); } break; case NOTIFICATION_MOUSE_EXIT: { - emit_signal(SceneStringNames::get_singleton()->mouse_exited); } break; case NOTIFICATION_FOCUS_ENTER: { - emit_signal(SceneStringNames::get_singleton()->focus_entered); update(); } break; case NOTIFICATION_FOCUS_EXIT: { - emit_signal(SceneStringNames::get_singleton()->focus_exited); update(); } break; case NOTIFICATION_THEME_CHANGED: { - minimum_size_changed(); update(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (!is_visible_in_tree()) { - if (get_viewport() != nullptr) get_viewport()->_gui_hid_control(this); @@ -630,14 +588,12 @@ void Control::_notification(int p_notification) { } bool Control::clips_input() const { - if (get_script_instance()) { return get_script_instance()->call(SceneStringNames::get_singleton()->_clips_input); } return false; } bool Control::has_point(const Point2 &p_point) const { - if (get_script_instance()) { Variant v = p_point; const Variant *p = &v; @@ -655,7 +611,6 @@ bool Control::has_point(const Point2 &p_point) const { } void Control::set_drag_forwarding(Control *p_target) { - if (p_target) data.drag_owner = p_target->get_instance_id(); else @@ -663,7 +618,6 @@ void Control::set_drag_forwarding(Control *p_target) { } Variant Control::get_drag_data(const Point2 &p_point) { - if (data.drag_owner.is_valid()) { Object *obj = ObjectDB::get_instance(data.drag_owner); if (obj) { @@ -685,7 +639,6 @@ Variant Control::get_drag_data(const Point2 &p_point) { } bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const { - if (data.drag_owner.is_valid()) { Object *obj = ObjectDB::get_instance(data.drag_owner); if (obj) { @@ -706,7 +659,6 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const return Variant(); } void Control::drop_data(const Point2 &p_point, const Variant &p_data) { - if (data.drag_owner.is_valid()) { Object *obj = ObjectDB::get_instance(data.drag_owner); if (obj) { @@ -727,7 +679,6 @@ void Control::drop_data(const Point2 &p_point, const Variant &p_data) { } void Control::force_drag(const Variant &p_data, Control *p_control) { - ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(p_data.get_type() == Variant::NIL); @@ -735,17 +686,14 @@ void Control::force_drag(const Variant &p_data, Control *p_control) { } void Control::set_drag_preview(Control *p_control) { - ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(!get_viewport()->gui_is_dragging()); get_viewport()->_gui_set_drag_preview(this, p_control); } Size2 Control::get_minimum_size() const { - ScriptInstance *si = const_cast(this)->get_script_instance(); if (si) { - Callable::CallError ce; Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) @@ -756,13 +704,11 @@ Size2 Control::get_minimum_size() const { template bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, T &r_ret, T (Theme::*get_func)(const StringName &, const StringName &) const, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type) { - // try with custom themes Control *theme_owner = p_theme_owner; Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - StringName class_name = p_type; while (class_name != StringName()) { @@ -792,7 +738,6 @@ bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_win theme_owner = parent_w->theme_owner; theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = nullptr; theme_owner_window = nullptr; } @@ -802,13 +747,11 @@ bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_win } bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type) { - // try with custom themes Control *theme_owner = p_theme_owner; Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - StringName class_name = p_type; while (class_name != StringName()) { @@ -836,7 +779,6 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind theme_owner = parent_w->theme_owner; theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = nullptr; theme_owner_window = nullptr; } @@ -846,9 +788,7 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind } Ref Control::get_theme_icon(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { - const Ref *tex = data.icon_override.getptr(p_name); if (tex) return *tex; @@ -860,7 +800,6 @@ Ref Control::get_theme_icon(const StringName &p_name, const StringNam } Ref Control::get_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Ref icon; if (_find_theme_item(p_theme_owner, p_theme_owner_window, icon, &Theme::get_icon, &Theme::has_icon, p_name, p_type)) { @@ -877,9 +816,7 @@ Ref Control::get_icons(Control *p_theme_owner, Window *p_theme_owner_ } Ref Control::get_theme_shader(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { - const Ref *sdr = data.shader_override.getptr(p_name); if (sdr) return *sdr; @@ -891,7 +828,6 @@ Ref Control::get_theme_shader(const StringName &p_name, const StringName } Ref Control::get_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Ref shader; if (_find_theme_item(p_theme_owner, p_theme_owner_window, shader, &Theme::get_shader, &Theme::has_shader, p_name, p_type)) { @@ -908,7 +844,6 @@ Ref Control::get_shaders(Control *p_theme_owner, Window *p_theme_owner_w } Ref Control::get_theme_stylebox(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { const Ref *style = data.style_override.getptr(p_name); if (style) @@ -921,7 +856,6 @@ Ref Control::get_theme_stylebox(const StringName &p_name, const String } Ref Control::get_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Ref stylebox; if (_find_theme_item(p_theme_owner, p_theme_owner_window, stylebox, &Theme::get_stylebox, &Theme::has_stylebox, p_name, p_type)) { @@ -938,7 +872,6 @@ Ref Control::get_styleboxs(Control *p_theme_owner, Window *p_theme_own } Ref Control::get_theme_font(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { const Ref *font = data.font_override.getptr(p_name); if (font) @@ -951,7 +884,6 @@ Ref Control::get_theme_font(const StringName &p_name, const StringName &p_ } Ref Control::get_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Ref font; if (_find_theme_item(p_theme_owner, p_theme_owner_window, font, &Theme::get_font, &Theme::has_font, p_name, p_type)) { @@ -968,7 +900,6 @@ Ref Control::get_fonts(Control *p_theme_owner, Window *p_theme_owner_windo } Color Control::get_theme_color(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { const Color *color = data.color_override.getptr(p_name); if (color) @@ -981,7 +912,6 @@ Color Control::get_theme_color(const StringName &p_name, const StringName &p_typ } Color Control::get_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Color color; if (_find_theme_item(p_theme_owner, p_theme_owner_window, color, &Theme::get_color, &Theme::has_color, p_name, p_type)) { @@ -997,7 +927,6 @@ Color Control::get_colors(Control *p_theme_owner, Window *p_theme_owner_window, } int Control::get_theme_constant(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { const int *constant = data.constant_override.getptr(p_name); if (constant) @@ -1010,7 +939,6 @@ int Control::get_theme_constant(const StringName &p_name, const StringName &p_ty } int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - int constant; if (_find_theme_item(p_theme_owner, p_theme_owner_window, constant, &Theme::get_constant, &Theme::has_constant, p_name, p_type)) { @@ -1026,43 +954,36 @@ int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window, } bool Control::has_theme_icon_override(const StringName &p_name) const { - const Ref *tex = data.icon_override.getptr(p_name); return tex != nullptr; } bool Control::has_theme_shader_override(const StringName &p_name) const { - const Ref *sdr = data.shader_override.getptr(p_name); return sdr != nullptr; } bool Control::has_theme_stylebox_override(const StringName &p_name) const { - const Ref *style = data.style_override.getptr(p_name); return style != nullptr; } bool Control::has_theme_font_override(const StringName &p_name) const { - const Ref *font = data.font_override.getptr(p_name); return font != nullptr; } bool Control::has_theme_color_override(const StringName &p_name) const { - const Color *color = data.color_override.getptr(p_name); return color != nullptr; } bool Control::has_theme_constant_override(const StringName &p_name) const { - const int *constant = data.constant_override.getptr(p_name); return constant != nullptr; } bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_icon_override(p_name)) return true; @@ -1074,7 +995,6 @@ bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) } bool Control::has_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_icon, p_name, p_type)) { return true; } @@ -1088,7 +1008,6 @@ bool Control::has_icons(Control *p_theme_owner, Window *p_theme_owner_window, co } bool Control::has_theme_shader(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_shader_override(p_name)) return true; @@ -1099,7 +1018,6 @@ bool Control::has_theme_shader(const StringName &p_name, const StringName &p_typ return has_shaders(data.theme_owner, data.theme_owner_window, p_name, type); } bool Control::has_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_shader, p_name, p_type)) { return true; } @@ -1113,7 +1031,6 @@ bool Control::has_shaders(Control *p_theme_owner, Window *p_theme_owner_window, } bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_stylebox_override(p_name)) return true; @@ -1125,7 +1042,6 @@ bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_t } bool Control::has_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_stylebox, p_name, p_type)) { return true; } @@ -1139,7 +1055,6 @@ bool Control::has_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window } bool Control::has_theme_font(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_font_override(p_name)) return true; @@ -1150,7 +1065,6 @@ bool Control::has_theme_font(const StringName &p_name, const StringName &p_type) return has_fonts(data.theme_owner, data.theme_owner_window, p_name, type); } bool Control::has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_font, p_name, p_type)) { return true; } @@ -1164,7 +1078,6 @@ bool Control::has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, co } bool Control::has_theme_color(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_color_override(p_name)) return true; @@ -1175,7 +1088,6 @@ bool Control::has_theme_color(const StringName &p_name, const StringName &p_type return has_colors(data.theme_owner, data.theme_owner_window, p_name, type); } bool Control::has_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_color, p_name, p_type)) { return true; } @@ -1189,7 +1101,6 @@ bool Control::has_colors(Control *p_theme_owner, Window *p_theme_owner_window, c } bool Control::has_theme_constant(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_constant_override(p_name)) return true; @@ -1201,7 +1112,6 @@ bool Control::has_theme_constant(const StringName &p_name, const StringName &p_t } bool Control::has_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_constant, p_name, p_type)) { return true; } @@ -1229,18 +1139,15 @@ Rect2 Control::get_parent_anchorable_rect() const { } Size2 Control::get_parent_area_size() const { - return get_parent_anchorable_rect().size; } void Control::_size_changed() { - Rect2 parent_rect = get_parent_anchorable_rect(); float margin_pos[4]; for (int i = 0; i < 4; i++) { - float area = parent_rect.size[i & 1]; margin_pos[i] = data.margin[i] + (data.anchor[i] * area); } @@ -1293,7 +1200,6 @@ void Control::_size_changed() { } void Control::set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin, bool p_push_opposite_anchor) { - ERR_FAIL_INDEX((int)p_margin, 4); Rect2 parent_rect = get_parent_anchorable_rect(); @@ -1334,13 +1240,11 @@ void Control::_set_anchor(Margin p_margin, float p_anchor) { } void Control::set_anchor_and_margin(Margin p_margin, float p_anchor, float p_pos, bool p_push_opposite_anchor) { - set_anchor(p_margin, p_anchor, false, p_push_opposite_anchor); set_margin(p_margin, p_pos); } void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { - ERR_FAIL_INDEX((int)p_preset, 16); //Left @@ -1457,7 +1361,6 @@ void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { } void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode, int p_margin) { - ERR_FAIL_INDEX((int)p_preset, 16); ERR_FAIL_INDEX((int)p_resize_mode, 4); @@ -1594,14 +1497,12 @@ void Control::set_anchors_and_margins_preset(LayoutPreset p_preset, LayoutPreset } float Control::get_anchor(Margin p_margin) const { - ERR_FAIL_INDEX_V(int(p_margin), 4, 0.0); return data.anchor[p_margin]; } void Control::_change_notify_margins() { - // this avoids sending the whole object data again on a change _change_notify("margin_left"); _change_notify("margin_top"); @@ -1612,7 +1513,6 @@ void Control::_change_notify_margins() { } void Control::set_margin(Margin p_margin, float p_value) { - ERR_FAIL_INDEX((int)p_margin, 4); data.margin[p_margin] = p_value; @@ -1620,37 +1520,31 @@ void Control::set_margin(Margin p_margin, float p_value) { } void Control::set_begin(const Size2 &p_point) { - data.margin[0] = p_point.x; data.margin[1] = p_point.y; _size_changed(); } void Control::set_end(const Size2 &p_point) { - data.margin[2] = p_point.x; data.margin[3] = p_point.y; _size_changed(); } float Control::get_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); return data.margin[p_margin]; } Size2 Control::get_begin() const { - return Size2(data.margin[0], data.margin[1]); } Size2 Control::get_end() const { - return Size2(data.margin[2], data.margin[3]); } Point2 Control::get_global_position() const { - return get_global_transform().get_origin(); } @@ -1670,11 +1564,9 @@ void Control::_set_global_position(const Point2 &p_point) { } void Control::set_global_position(const Point2 &p_point, bool p_keep_margins) { - Transform2D inv; if (data.parent_canvas_item) { - inv = data.parent_canvas_item->get_global_transform().affine_inverse(); } @@ -1682,7 +1574,6 @@ void Control::set_global_position(const Point2 &p_point, bool p_keep_margins) { } void Control::_compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r_anchors)[4]) { - Size2 parent_rect_size = get_parent_anchorable_rect().size; ERR_FAIL_COND(parent_rect_size.x == 0.0); ERR_FAIL_COND(parent_rect_size.y == 0.0); @@ -1694,7 +1585,6 @@ void Control::_compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r } void Control::_compute_margins(Rect2 p_rect, const float p_anchors[4], float (&r_margins)[4]) { - Size2 parent_rect_size = get_parent_anchorable_rect().size; r_margins[0] = p_rect.position.x - (p_anchors[0] * parent_rect_size.x); r_margins[1] = p_rect.position.y - (p_anchors[1] * parent_rect_size.y); @@ -1724,7 +1614,6 @@ void Control::_set_size(const Size2 &p_size) { } void Control::set_size(const Size2 &p_size, bool p_keep_margins) { - Size2 new_size = p_size; Size2 min = get_combined_minimum_size(); if (new_size.x < min.x) @@ -1745,22 +1634,18 @@ void Control::set_size(const Size2 &p_size, bool p_keep_margins) { } Size2 Control::get_position() const { - return data.pos_cache; } Size2 Control::get_size() const { - return data.size_cache; } Rect2 Control::get_global_rect() const { - return Rect2(get_global_position(), get_size()); } Rect2 Control::get_screen_rect() const { - ERR_FAIL_COND_V(!is_inside_tree(), Rect2()); Rect2 r(get_global_position(), get_size()); @@ -1781,17 +1666,14 @@ Rect2 Control::get_window_rect() const { } Rect2 Control::get_rect() const { - return Rect2(get_position(), get_size()); } Rect2 Control::get_anchorable_rect() const { - return Rect2(Point2(), get_size()); } void Control::add_theme_icon_override(const StringName &p_name, const Ref &p_icon) { - if (data.icon_override.has(p_name)) { data.icon_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } @@ -1809,7 +1691,6 @@ void Control::add_theme_icon_override(const StringName &p_name, const Ref &p_shader) { - if (data.shader_override.has(p_name)) { data.shader_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } @@ -1826,7 +1707,6 @@ void Control::add_theme_shader_override(const StringName &p_name, const Ref &p_style) { - if (data.style_override.has(p_name)) { data.style_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } @@ -1844,7 +1724,6 @@ void Control::add_theme_style_override(const StringName &p_name, const Ref