Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-04-07 12:27:13 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-04-07 12:27:13 +0400
commit45ce1c003d7d28b2beb5dbf465f523c5bc41bc55 (patch)
treea03f36a0c8513d837d2d4e8db40b6d022b40d546
parentf4e312dd1b53d3fa4c65f47bfb9972bbb9f5abab (diff)
Modes are now toggled on using operators on load if the file was saved in
that mode. This ensures proper initialization happens like creating the cursor or building an acceleration structure. It also means edit and particle mode are now saveable. Not sure yet if this is a good feature, though personally I like being able to load my exact state again after saving, but maybe entering edit mode is too slow in some cases? It's easy to make it work only for the sculpt/paint modes again if wanted. This fixes bug #21004 about a missing sculpt cursor on load.
-rw-r--r--source/blender/blenloader/intern/readfile.c3
-rw-r--r--source/blender/editors/include/ED_util.h1
-rw-r--r--source/blender/editors/object/object_edit.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c2
-rw-r--r--source/blender/editors/util/ed_util.c22
-rw-r--r--source/blender/windowmanager/intern/wm_files.c3
6 files changed, 28 insertions, 5 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6dcfb7f0ec7..be3e3c25b05 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3887,9 +3887,6 @@ static void direct_link_object(FileData *fd, Object *ob)
/* weak weak... this was only meant as draw flag, now is used in give_base too */
ob->flag &= ~OB_FROMGROUP;
- /* editmode doesn't get saved in files, so should get cleared when reloading... */
- ob->mode &= ~(OB_MODE_EDIT|OB_MODE_PARTICLE_EDIT);
-
ob->disp.first=ob->disp.last= NULL;
ob->adt= newdataadr(fd, ob->adt);
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index cc4f906ad37..7bf3ec88a4b 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -37,6 +37,7 @@ struct wmOperatorType;
/* ed_util.c */
+void ED_editors_init (struct bContext *C);
void ED_editors_exit (struct bContext *C);
/* ************** Undo ************************ */
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 2332f08c021..8fb2f402a64 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -2054,6 +2054,8 @@ void ED_object_toggle_modes(bContext *C, int mode)
WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL);
if(mode & OB_MODE_POSE)
WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+ if(mode & OB_MODE_EDIT)
+ WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
}
/************************ Game Properties ***********************/
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 7bfb7716c9c..a3c21a690c1 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1123,8 +1123,6 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */
/* for switching to/from mode */
static int paint_poll_test(bContext *C)
{
- if(ED_operator_view3d_active(C)==0)
- return 0;
if(CTX_data_edit_object(C))
return 0;
if(CTX_data_active_object(C)==NULL)
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 19bd18ade1f..0c9ce9648c7 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -43,6 +43,7 @@
#include "ED_armature.h"
#include "ED_mesh.h"
+#include "ED_object.h"
#include "ED_sculpt.h"
#include "ED_util.h"
@@ -50,6 +51,27 @@
/* ********* general editor util funcs, not BKE stuff please! ********* */
+void ED_editors_init(bContext *C)
+{
+ Main *bmain= CTX_data_main(C);
+ Scene *sce= CTX_data_scene(C);
+ Object *ob, *obact= (sce && sce->basact)? sce->basact->object: NULL;
+
+ /* toggle on modes for objects that were saved with these enabled. for
+ e.g. linked objects we have to ensure that they are actually the
+ active object in this scene. */
+ for(ob=bmain->object.first; ob; ob=ob->id.next) {
+ int mode= ob->mode;
+
+ if(mode && (mode != OB_MODE_POSE)) {
+ ob->mode= 0;
+
+ if(ob == obact)
+ ED_object_toggle_modes(C, mode);
+ }
+ }
+}
+
/* frees all editmode stuff */
void ED_editors_exit(bContext *C)
{
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index f79b083857e..ff5797b1e69 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -296,6 +296,9 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL);
// refresh_interface_font();
+ CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
+ ED_editors_init(C);
+
CTX_wm_window_set(C, NULL); /* exits queues */
#ifndef DISABLE_PYTHON
/* run any texts that were loaded in and flagged as modules */