| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup edobj | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  |  * | 
					
						
							|  |  |  |  * General utils to handle mode switching, | 
					
						
							|  |  |  |  * actual mode switching logic is per-object type. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-31 10:22:19 +02:00
										 |  |  | #include "DNA_gpencil_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | #include "DNA_object_types.h"
 | 
					
						
							|  |  |  | #include "DNA_scene_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-02 14:46:21 +11:00
										 |  |  | #include "DNA_workspace_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BKE_context.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-29 10:31:56 +01:00
										 |  |  | #include "BKE_layer.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | #include "BKE_object.h"
 | 
					
						
							|  |  |  | #include "BKE_paint.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | #include "BKE_report.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-29 10:31:56 +01:00
										 |  |  | #include "BKE_scene.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "WM_api.h"
 | 
					
						
							|  |  |  | #include "WM_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | #include "RNA_access.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "DEG_depsgraph.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-30 15:21:26 +02:00
										 |  |  | #include "ED_armature.h"
 | 
					
						
							| 
									
										
										
										
											2019-06-28 13:54:09 +02:00
										 |  |  | #include "ED_gpencil.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-02 23:04:19 +11:00
										 |  |  | #include "ED_screen.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | #include "ED_object.h" /* own include */
 | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name High Level Mode Operations
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | static const char *object_mode_op_string(eObjectMode mode) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   if (mode & OB_MODE_EDIT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "OBJECT_OT_editmode_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_SCULPT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "SCULPT_OT_sculptmode_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_VERTEX_PAINT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "PAINT_OT_vertex_paint_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_WEIGHT_PAINT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "PAINT_OT_weight_paint_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_TEXTURE_PAINT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "PAINT_OT_texture_paint_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_PARTICLE_EDIT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "PARTICLE_OT_particle_edit_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_POSE) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "OBJECT_OT_posemode_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_EDIT_GPENCIL) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "GPENCIL_OT_editmode_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_PAINT_GPENCIL) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "GPENCIL_OT_paintmode_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_SCULPT_GPENCIL) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "GPENCIL_OT_sculptmode_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (mode == OB_MODE_WEIGHT_GPENCIL) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return "GPENCIL_OT_weightmode_toggle"; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   return NULL; | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Checks the mode to be set is compatible with the object | 
					
						
							|  |  |  |  * should be made into a generic function | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (ob) { | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |     if (mode == OB_MODE_OBJECT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       return true; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     switch (ob->type) { | 
					
						
							|  |  |  |       case OB_MESH: | 
					
						
							|  |  |  |         if (mode & (OB_MODE_EDIT | OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | | 
					
						
							|  |  |  |                     OB_MODE_TEXTURE_PAINT | OB_MODE_PARTICLE_EDIT)) { | 
					
						
							|  |  |  |           return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |       case OB_CURVE: | 
					
						
							|  |  |  |       case OB_SURF: | 
					
						
							|  |  |  |       case OB_FONT: | 
					
						
							|  |  |  |       case OB_MBALL: | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |         if (mode & (OB_MODE_EDIT)) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |           return true; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         break; | 
					
						
							|  |  |  |       case OB_LATTICE: | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |         if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT)) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |           return true; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         break; | 
					
						
							|  |  |  |       case OB_ARMATURE: | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |         if (mode & (OB_MODE_EDIT | OB_MODE_POSE)) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |           return true; | 
					
						
							| 
									
										
										
										
											2019-04-22 09:19:45 +10:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         break; | 
					
						
							|  |  |  |       case OB_GPENCIL: | 
					
						
							|  |  |  |         if (mode & (OB_MODE_EDIT | OB_MODE_EDIT_GPENCIL | OB_MODE_PAINT_GPENCIL | | 
					
						
							|  |  |  |                     OB_MODE_SCULPT_GPENCIL | OB_MODE_WEIGHT_GPENCIL)) { | 
					
						
							|  |  |  |           return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   return false; | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Sets the mode to a compatible state (use before entering the mode). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This is so each mode's exec function can call | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-04-05 18:20:27 +02:00
										 |  |  | bool ED_object_mode_compat_set(bContext *C, Object *ob, eObjectMode mode, ReportList *reports) | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   bool ok; | 
					
						
							|  |  |  |   if (!ELEM(ob->mode, mode, OB_MODE_OBJECT)) { | 
					
						
							|  |  |  |     const char *opstring = object_mode_op_string(ob->mode); | 
					
						
							| 
									
										
										
										
											2018-03-02 14:46:21 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL); | 
					
						
							|  |  |  |     ok = ELEM(ob->mode, mode, OB_MODE_OBJECT); | 
					
						
							|  |  |  |     if (!ok) { | 
					
						
							|  |  |  |       wmOperatorType *ot = WM_operatortype_find(opstring, false); | 
					
						
							|  |  |  |       BKE_reportf(reports, RPT_ERROR, "Unable to execute '%s', error changing modes", ot->name); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							|  |  |  |     ok = true; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   return ok; | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ED_object_mode_toggle(bContext *C, eObjectMode mode) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (mode != OB_MODE_OBJECT) { | 
					
						
							|  |  |  |     const char *opstring = object_mode_op_string(mode); | 
					
						
							| 
									
										
										
										
											2018-03-02 14:46:21 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     if (opstring) { | 
					
						
							|  |  |  |       wmOperatorType *ot = WM_operatortype_find(opstring, false); | 
					
						
							|  |  |  |       WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_REGION_WIN, NULL); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-03-02 13:53:17 +11:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-19 14:17:59 +01:00
										 |  |  | /* Wrapper for operator  */ | 
					
						
							|  |  |  | void ED_object_mode_set(bContext *C, eObjectMode mode) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   wmWindowManager *wm = CTX_wm_manager(C); | 
					
						
							|  |  |  |   wm->op_undo_depth++; | 
					
						
							|  |  |  |   /* needed so we don't do undo pushes. */ | 
					
						
							|  |  |  |   ED_object_mode_generic_enter(C, mode); | 
					
						
							|  |  |  |   wm->op_undo_depth--; | 
					
						
							| 
									
										
										
										
											2018-03-19 14:17:59 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-04-01 11:03:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-02 11:33:57 +10:00
										 |  |  | void ED_object_mode_exit(bContext *C, Depsgraph *depsgraph) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   struct Main *bmain = CTX_data_main(C); | 
					
						
							|  |  |  |   Scene *scene = CTX_data_scene(C); | 
					
						
							|  |  |  |   ViewLayer *view_layer = CTX_data_view_layer(C); | 
					
						
							|  |  |  |   FOREACH_OBJECT_BEGIN (view_layer, ob) { | 
					
						
							|  |  |  |     if (ob->mode & OB_MODE_ALL_MODE_DATA) { | 
					
						
							|  |  |  |       ED_object_mode_generic_exit(bmain, depsgraph, scene, ob); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   FOREACH_OBJECT_END; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Generic Mode Enter/Exit
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Supports exiting a mode without it being in the current context. | 
					
						
							|  |  |  |  * This could be done for entering modes too if it's needed. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | bool ED_object_mode_generic_enter(struct bContext *C, eObjectMode object_mode) | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   ViewLayer *view_layer = CTX_data_view_layer(C); | 
					
						
							|  |  |  |   Object *ob = OBACT(view_layer); | 
					
						
							|  |  |  |   if (ob == NULL) { | 
					
						
							|  |  |  |     return (object_mode == OB_MODE_OBJECT); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (ob->mode == object_mode) { | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_mode_set", false); | 
					
						
							|  |  |  |   PointerRNA ptr; | 
					
						
							|  |  |  |   WM_operator_properties_create_ptr(&ptr, ot); | 
					
						
							|  |  |  |   RNA_enum_set(&ptr, "mode", object_mode); | 
					
						
							|  |  |  |   WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr); | 
					
						
							|  |  |  |   WM_operator_properties_free(&ptr); | 
					
						
							|  |  |  |   return (ob->mode == object_mode); | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Use for changing works-paces or changing active object. | 
					
						
							|  |  |  |  * Caller can check #OB_MODE_ALL_MODE_DATA to test if this needs to be run. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | static bool ed_object_mode_generic_exit_ex(struct Main *bmain, | 
					
						
							|  |  |  |                                            struct Depsgraph *depsgraph, | 
					
						
							|  |  |  |                                            struct Scene *scene, | 
					
						
							|  |  |  |                                            struct Object *ob, | 
					
						
							|  |  |  |                                            bool only_test) | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   BLI_assert((bmain == NULL) == only_test); | 
					
						
							|  |  |  |   if (ob->mode & OB_MODE_EDIT) { | 
					
						
							|  |  |  |     if (BKE_object_is_in_editmode(ob)) { | 
					
						
							|  |  |  |       if (only_test) { | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else if (ob->mode & OB_MODE_VERTEX_PAINT) { | 
					
						
							|  |  |  |     if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_VERTEX_PAINT)) { | 
					
						
							|  |  |  |       if (only_test) { | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       ED_object_vpaintmode_exit_ex(ob); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else if (ob->mode & OB_MODE_WEIGHT_PAINT) { | 
					
						
							|  |  |  |     if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_WEIGHT_PAINT)) { | 
					
						
							|  |  |  |       if (only_test) { | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       ED_object_wpaintmode_exit_ex(ob); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else if (ob->mode & OB_MODE_SCULPT) { | 
					
						
							|  |  |  |     if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_SCULPT)) { | 
					
						
							|  |  |  |       if (only_test) { | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-05-31 12:28:31 +02:00
										 |  |  |       ED_object_sculptmode_exit_ex(bmain, depsgraph, scene, ob); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else if (ob->mode & OB_MODE_POSE) { | 
					
						
							|  |  |  |     if (ob->pose != NULL) { | 
					
						
							|  |  |  |       if (only_test) { | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       ED_object_posemode_exit_ex(bmain, ob); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-06-28 13:54:09 +02:00
										 |  |  |   else if ((ob->type == OB_GPENCIL) && ((ob->mode & OB_MODE_OBJECT) == 0)) { | 
					
						
							|  |  |  |     if (only_test) { | 
					
						
							|  |  |  |       return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ED_object_gpencil_exit(bmain, ob); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   else { | 
					
						
							|  |  |  |     if (only_test) { | 
					
						
							|  |  |  |       return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     BLI_assert((ob->mode & OB_MODE_ALL_MODE_DATA) == 0); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   return false; | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | void ED_object_mode_generic_exit(struct Main *bmain, | 
					
						
							|  |  |  |                                  struct Depsgraph *depsgraph, | 
					
						
							|  |  |  |                                  struct Scene *scene, | 
					
						
							|  |  |  |                                  struct Object *ob) | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   ed_object_mode_generic_exit_ex(bmain, depsgraph, scene, ob, false); | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, struct Object *ob) | 
					
						
							| 
									
										
										
										
											2018-03-02 14:55:53 +11:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   return ed_object_mode_generic_exit_ex(NULL, depsgraph, NULL, ob, true); | 
					
						
							| 
									
										
										
										
											2018-03-03 16:39:57 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-02 23:04:19 +11:00
										 |  |  | /** \} */ |