diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-04-20 19:38:02 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-04-20 19:38:02 -0300 |
commit | 59154cccf9fcf814a21a2596993fb1b6777d3bb7 (patch) | |
tree | 4132620a9d924463dae4b64fea2dde68a14023e7 /tools/editor/plugins | |
parent | 28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6 (diff) |
-Changed Godot exit to be clean.
-Added more debug information on memory cleanliness on exit (if run with -v)
-Fixed several memory leaks, fixes #1731, fixes #755
Diffstat (limited to 'tools/editor/plugins')
-rw-r--r-- | tools/editor/plugins/baked_light_baker.cpp | 1 | ||||
-rw-r--r-- | tools/editor/plugins/canvas_item_editor_plugin.cpp | 39 | ||||
-rw-r--r-- | tools/editor/plugins/canvas_item_editor_plugin.h | 5 | ||||
-rw-r--r-- | tools/editor/plugins/sample_library_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | tools/editor/plugins/spatial_editor_plugin.cpp | 41 | ||||
-rw-r--r-- | tools/editor/plugins/spatial_editor_plugin.h | 3 |
6 files changed, 70 insertions, 22 deletions
diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index 184f80a1b7..4599dbfb54 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -2127,6 +2127,7 @@ void BakedLightBaker::_stop_thread() { bake_thread_exit=true; for(int i=0;i<threads.size();i++) { Thread::wait_to_finish(threads[i]); + memdelete(threads[i]); } threads.clear(); } diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 4b1b8a612e..fef5890f11 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -943,13 +943,13 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { } - List<BoneList>::Element *Cbone=NULL; //closest + Map<ObjectID,BoneList>::Element *Cbone=NULL; //closest { bone_ik_list.clear(); float closest_dist=1e20; int bone_width = EditorSettings::get_singleton()->get("2d_editor/bone_width"); - for(List<BoneList>::Element *E=bone_list.front();E;E=E->next()) { + for(Map<ObjectID,BoneList>::Element *E=bone_list.front();E;E=E->next()) { if (E->get().from == E->get().to) continue; @@ -1789,7 +1789,7 @@ void CanvasItemEditor::_viewport_draw() { Color bone_ik_color = EditorSettings::get_singleton()->get("2d_editor/bone_ik_color"); Color bone_selected_color = EditorSettings::get_singleton()->get("2d_editor/bone_selected_color"); - for(List<BoneList>::Element*E=bone_list.front();E;E=E->next()) { + for(Map<ObjectID,BoneList>::Element*E=bone_list.front();E;E=E->next()) { E->get().from=Vector2(); E->get().to=Vector2(); @@ -1884,10 +1884,12 @@ void CanvasItemEditor::_notification(int p_what) { } - for(List<BoneList>::Element *E=bone_list.front();E;E=E->next()) { + + for(Map<ObjectID,BoneList>::Element *E=bone_list.front();E;E=E->next()) { Object *b = ObjectDB::get_instance(E->get().bone); if (!b) { + viewport->update(); break; } @@ -1989,9 +1991,14 @@ void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2& r_rect, cons if (c->has_meta("_edit_bone_")) { - BoneList bone; - bone.bone=c->get_instance_ID(); - bone_list.push_back(bone); + ObjectID id = c->get_instance_ID(); + if (!bone_list.has(id)) { + BoneList bone; + bone.bone=id; + bone_list[id]=bone; + } + + bone_list[id].last_pass=bone_last_frame; } r_rect.expand_to( xform.xform(rect.pos) ); @@ -2026,11 +2033,26 @@ void CanvasItemEditor::_update_scrollbars() { Rect2 canvas_item_rect=Rect2(Point2(),screen_rect); lock_list.clear();; - bone_list.clear();; + bone_last_frame++; + + if (editor->get_edited_scene()) _find_canvas_items_span(editor->get_edited_scene(),canvas_item_rect,Matrix32()); + List<Map<ObjectID,BoneList>::Element*> bone_to_erase; + + for(Map<ObjectID,BoneList>::Element*E=bone_list.front();E;E=E->next()) { + + if (E->get().last_pass!=bone_last_frame) { + bone_to_erase.push_back(E); + } + } + + while(bone_to_erase.size()) { + bone_list.erase(bone_to_erase.front()->get()); + bone_to_erase.pop_front(); + } //expand area so it's easier to do animations and stuff at 0,0 canvas_item_rect.size+=screen_rect*2; @@ -3024,6 +3046,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { set_process_unhandled_key_input(true); can_move_pivot=false; drag=DRAG_NONE; + bone_last_frame=0; } CanvasItemEditor *CanvasItemEditor::singleton=NULL; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h index aa892dca48..48a34e2d07 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.h +++ b/tools/editor/plugins/canvas_item_editor_plugin.h @@ -181,9 +181,12 @@ class CanvasItemEditor : public VBoxContainer { Vector2 from; Vector2 to; ObjectID bone; + uint64_t last_pass; }; - List<BoneList> bone_list; + uint64_t bone_last_frame; + Map<ObjectID,BoneList> bone_list; + Matrix32 bone_orig_xform; struct BoneIK { diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index 372e8558f6..bb9d1f9dd0 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -332,7 +332,8 @@ SampleLibraryEditor::SampleLibraryEditor() { play->set_pos(Point2( 5, 5 )); play->set_size( Size2(1,1 ) ); play->set_toggle_mode(true); - //add_child(play); + add_child(play); + play->hide(); stop = memnew( Button ); diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 04a5587151..4dae60399b 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1765,6 +1765,12 @@ void SpatialEditorViewport::_notification(int p_what) { _init_gizmo_instance(index); } + if (p_what==NOTIFICATION_EXIT_TREE) { + + + _finish_gizmo_instances(); + + } if (p_what==NOTIFICATION_MOUSE_ENTER) { @@ -2052,6 +2058,16 @@ void SpatialEditorViewport::_init_gizmo_instance(int p_idx) { } + +void SpatialEditorViewport::_finish_gizmo_instances() { + + + for(int i=0;i<3;i++) { + VS::get_singleton()->free(move_gizmo_instance[i]); + VS::get_singleton()->free(rotate_gizmo_instance[i]); + } + +} void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { @@ -2971,14 +2987,14 @@ void SpatialEditor::_init_indicators() { VisualServer::get_singleton()->instance_set_transform(light_instance,light_transform); - RID mat = VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); - VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); + //RID mat = VisualServer::get_singleton()->fixed_material_create(); + ///VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); + //VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); { - RID indicator_mat = VisualServer::get_singleton()->fixed_material_create(); + indicator_mat = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_ONTOP, false ); VisualServer::get_singleton()->fixed_material_set_flag(indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); @@ -3042,7 +3058,7 @@ void SpatialEditor::_init_indicators() { d[VisualServer::ARRAY_COLOR]=origin_colors; VisualServer::get_singleton()->mesh_add_surface(origin,VisualServer::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(origin,0,indicator_mat,true); + VisualServer::get_singleton()->mesh_surface_set_material(origin,0,indicator_mat); // origin = VisualServer::get_singleton()->poly_create(); @@ -3073,17 +3089,17 @@ void SpatialEditor::_init_indicators() { cursor_points.push_back(Vector3(0,-cs,0)); cursor_points.push_back(Vector3(0,0,+cs)); cursor_points.push_back(Vector3(0,0,-cs)); - RID cmat=VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->fixed_material_set_param(cmat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0,1,1)); - VisualServer::get_singleton()->material_set_flag( cmat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); - VisualServer::get_singleton()->fixed_material_set_flag(cmat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); - VisualServer::get_singleton()->fixed_material_set_flag(cmat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); + cursor_material=VisualServer::get_singleton()->fixed_material_create(); + VisualServer::get_singleton()->fixed_material_set_param(cursor_material,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0,1,1)); + VisualServer::get_singleton()->material_set_flag( cursor_material, VisualServer::MATERIAL_FLAG_UNSHADED, true ); + VisualServer::get_singleton()->fixed_material_set_flag(cursor_material, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); + VisualServer::get_singleton()->fixed_material_set_flag(cursor_material, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); Array d; d.resize(VS::ARRAY_MAX); d[VS::ARRAY_VERTEX]=cursor_points; VisualServer::get_singleton()->mesh_add_surface(cursor_mesh,VS::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(cursor_mesh,0,cmat,true); + VisualServer::get_singleton()->mesh_surface_set_material(cursor_mesh,0,cursor_material); cursor_instance = VisualServer::get_singleton()->instance_create2(cursor_mesh,get_tree()->get_root()->get_world()->get_scenario()); VS::get_singleton()->instance_set_layer_mask(cursor_instance,1<<SpatialEditorViewport::GIZMO_GRID_LAYER); @@ -3252,7 +3268,6 @@ void SpatialEditor::_init_indicators() { void SpatialEditor::_finish_indicators() { - VisualServer::get_singleton()->free(origin_instance); VisualServer::get_singleton()->free(origin); for(int i=0;i<3;i++) { @@ -3267,6 +3282,8 @@ void SpatialEditor::_finish_indicators() { VisualServer::get_singleton()->free(cursor_instance); VisualServer::get_singleton()->free(cursor_mesh); + VisualServer::get_singleton()->free(indicator_mat); + VisualServer::get_singleton()->free(cursor_material); } void SpatialEditor::_instance_scene() { diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h index 76ae7bf1e6..b890f285ee 100644 --- a/tools/editor/plugins/spatial_editor_plugin.h +++ b/tools/editor/plugins/spatial_editor_plugin.h @@ -224,6 +224,7 @@ private: void _preview_exited_scene(); void _toggle_camera_preview(bool); void _init_gizmo_instance(int p_idx); + void _finish_gizmo_instances(); protected: @@ -324,6 +325,8 @@ private: RID indicators_instance; RID cursor_mesh; RID cursor_instance; + RID indicator_mat; + RID cursor_material; /* struct Selected { |