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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -37,6 +37,7 @@ struct wmOperatorType;
|
||||
|
||||
/* ed_util.c */
|
||||
|
||||
void ED_editors_init (struct bContext *C);
|
||||
void ED_editors_exit (struct bContext *C);
|
||||
|
||||
/* ************** Undo ************************ */
|
||||
|
||||
@@ -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 ***********************/
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user