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:
authorCampbell Barton <ideasman42@gmail.com>2018-04-05 19:20:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-04-05 19:21:14 +0300
commit1c24c04e6023f2d2a328dfcdc9f86cd381d029a3 (patch)
tree7a5af59ce078cb66fb17ec33cf111ffc8d5fb328 /source/blender
parent57329304b061efe756e3a4ce1b828e9a7c7f7030 (diff)
Remove workspace object mode, reverts changes w/ 2.8
This caused too many problems syncing object modes with multiple objects/windows/workspaces, see: D3130 for details.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h4
-rw-r--r--source/blender/blenkernel/BKE_cloth.h1
-rw-r--r--source/blender/blenkernel/BKE_modifier.h3
-rw-r--r--source/blender/blenkernel/BKE_multires.h33
-rw-r--r--source/blender/blenkernel/BKE_object.h18
-rw-r--r--source/blender/blenkernel/BKE_paint.h15
-rw-r--r--source/blender/blenkernel/BKE_particle.h3
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h7
-rw-r--r--source/blender/blenkernel/BKE_workspace.h8
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c43
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c5
-rw-r--r--source/blender/blenkernel/intern/cloth.c4
-rw-r--r--source/blender/blenkernel/intern/context.c6
-rw-r--r--source/blender/blenkernel/intern/modifier.c4
-rw-r--r--source/blender/blenkernel/intern/multires.c132
-rw-r--r--source/blender/blenkernel/intern/object.c46
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c2
-rw-r--r--source/blender/blenkernel/intern/object_update.c4
-rw-r--r--source/blender/blenkernel/intern/paint.c108
-rw-r--r--source/blender/blenkernel/intern/particle.c21
-rw-r--r--source/blender/blenkernel/intern/particle_system.c7
-rw-r--r--source/blender/blenkernel/intern/scene.c7
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c10
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c17
-rw-r--r--source/blender/blenkernel/intern/workspace.c25
-rw-r--r--source/blender/blenloader/intern/readfile.c19
-rw-r--r--source/blender/blenloader/intern/versioning_250.c7
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c4
-rw-r--r--source/blender/collada/AnimationExporter.cpp4
-rw-r--r--source/blender/collada/SkinInfo.cpp2
-rw-r--r--source/blender/depsgraph/DEG_depsgraph.h4
-rw-r--r--source/blender/depsgraph/intern/depsgraph_eval.cc4
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc3
-rw-r--r--source/blender/draw/DRW_engine.h10
-rw-r--r--source/blender/draw/intern/draw_manager.c37
-rw-r--r--source/blender/draw/intern/draw_view.c2
-rw-r--r--source/blender/editors/animation/keyframing.c13
-rw-r--r--source/blender/editors/armature/armature_relations.c5
-rw-r--r--source/blender/editors/armature/armature_skinning.c14
-rw-r--r--source/blender/editors/armature/meshlaplacian.c3
-rw-r--r--source/blender/editors/armature/meshlaplacian.h1
-rw-r--r--source/blender/editors/armature/pose_edit.c12
-rw-r--r--source/blender/editors/armature/pose_select.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c4
-rw-r--r--source/blender/editors/include/ED_armature.h3
-rw-r--r--source/blender/editors/include/ED_image.h6
-rw-r--r--source/blender/editors/include/ED_info.h5
-rw-r--r--source/blender/editors/include/ED_mesh.h2
-rw-r--r--source/blender/editors/include/ED_object.h59
-rw-r--r--source/blender/editors/include/ED_screen.h6
-rw-r--r--source/blender/editors/include/ED_uvedit.h2
-rw-r--r--source/blender/editors/interface/interface_handlers.c10
-rw-r--r--source/blender/editors/interface/interface_icons.c7
-rw-r--r--source/blender/editors/interface/interface_templates.c14
-rw-r--r--source/blender/editors/mesh/editmesh_select.c4
-rw-r--r--source/blender/editors/mesh/mesh_data.c11
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c8
-rw-r--r--source/blender/editors/mesh/meshtools.c49
-rw-r--r--source/blender/editors/object/object_add.c18
-rw-r--r--source/blender/editors/object/object_bake.c21
-rw-r--r--source/blender/editors/object/object_bake_api.c2
-rw-r--r--source/blender/editors/object/object_constraint.c39
-rw-r--r--source/blender/editors/object/object_edit.c87
-rw-r--r--source/blender/editors/object/object_facemap_ops.c3
-rw-r--r--source/blender/editors/object/object_modes.c112
-rw-r--r--source/blender/editors/object/object_modifier.c142
-rw-r--r--source/blender/editors/object/object_ops.c3
-rw-r--r--source/blender/editors/object/object_relations.c12
-rw-r--r--source/blender/editors/object/object_select.c57
-rw-r--r--source/blender/editors/object/object_shapekey.c10
-rw-r--r--source/blender/editors/object/object_transform.c3
-rw-r--r--source/blender/editors/object/object_vgroup.c42
-rw-r--r--source/blender/editors/physics/particle_edit.c26
-rw-r--r--source/blender/editors/physics/particle_object.c8
-rw-r--r--source/blender/editors/render/render_shading.c6
-rw-r--r--source/blender/editors/render/render_update.c28
-rw-r--r--source/blender/editors/scene/scene_edit.c21
-rw-r--r--source/blender/editors/screen/screen_context.c16
-rw-r--r--source/blender/editors/screen/screen_ops.c63
-rw-r--r--source/blender/editors/screen/workspace_edit.c130
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c47
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_undo.c5
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c99
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c32
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c3
-rw-r--r--source/blender/editors/space_buttons/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c5
-rw-r--r--source/blender/editors/space_image/image_edit.c16
-rw-r--r--source/blender/editors/space_image/image_ops.c6
-rw-r--r--source/blender/editors/space_image/space_image.c7
-rw-r--r--source/blender/editors/space_info/info_stats.c27
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h2
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c19
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c401
-rw-r--r--source/blender/editors/space_time/space_time.c3
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c44
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c18
-rw-r--r--source/blender/editors/space_view3d/drawobject.c220
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c37
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c32
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c37
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h25
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c133
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c12
-rw-r--r--source/blender/editors/transform/transform.h2
-rw-r--r--source/blender/editors/transform/transform_conversions.c20
-rw-r--r--source/blender/editors/transform/transform_generics.c6
-rw-r--r--source/blender/editors/transform/transform_manipulator.c28
-rw-r--r--source/blender/editors/transform/transform_orientations.c14
-rw-r--r--source/blender/editors/transform/transform_snap.c2
-rw-r--r--source/blender/editors/transform/transform_snap_object.c6
-rw-r--r--source/blender/editors/undo/memfile_undo.c54
-rw-r--r--source/blender/editors/util/ed_util.c50
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c8
-rw-r--r--source/blender/gpu/GPU_draw.h3
-rw-r--r--source/blender/gpu/intern/gpu_draw.c8
-rw-r--r--source/blender/makesdna/DNA_object_types.h3
-rw-r--r--source/blender/makesdna/DNA_scene_types.h9
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_brush.c12
-rw-r--r--source/blender/makesrna/intern/rna_layer.c19
-rw-r--r--source/blender/makesrna/intern/rna_material.c13
-rw-r--r--source/blender/makesrna/intern/rna_object.c12
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c5
-rw-r--r--source/blender/makesrna/intern/rna_scene.c4
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c6
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c4
-rw-r--r--source/blender/makesrna/intern/rna_space.c15
-rw-r--r--source/blender/makesrna/intern/rna_texture.c4
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c5
-rw-r--r--source/blender/makesrna/intern/rna_wm.c25
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c2
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c6
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c8
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c6
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c2
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c4
-rw-r--r--source/blender/render/intern/source/convertblender.c2
-rw-r--r--source/blender/windowmanager/WM_api.h8
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c4
-rw-r--r--source/blender/windowmanager/intern/wm_window.c32
155 files changed, 1302 insertions, 2157 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 9d48ddb4f32..4ae11b5cca5 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -100,8 +100,6 @@ struct GPUDrawObject;
struct PBVH;
struct EvaluationContext;
-#include "DNA_object_enums.h"
-
/* number of sub-elements each mesh element has (for interpolation) */
#define SUB_ELEMS_VERT 0
#define SUB_ELEMS_EDGE 2
@@ -383,7 +381,7 @@ struct DerivedMesh {
/** Get the BVH used for paint modes
*/
- struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm, eObjectMode object_mode);
+ struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm);
/* Drawing Operations */
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 27b928c1671..8923edacb07 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -237,7 +237,6 @@ void bvhselftree_update_from_cloth(struct ClothModifierData *clmd, bool moving);
// needed for button_object.c
void cloth_clear_cache(
- const struct EvaluationContext *eval_ctx,
struct Object *ob, struct ClothModifierData *clmd, float framenr );
void cloth_parallel_transport_hair_frame(float mat[3][3], const float dir_old[3], const float dir_new[3]);
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 7eb3ad33950..329defbc77c 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -376,8 +376,7 @@ struct Object *modifiers_isDeformedByArmature(struct Object *ob);
struct Object *modifiers_isDeformedByLattice(struct Object *ob);
struct Object *modifiers_isDeformedByCurve(struct Object *ob);
bool modifiers_usesArmature(struct Object *ob, struct bArmature *arm);
-bool modifiers_isCorrectableDeformed(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+bool modifiers_isCorrectableDeformed(struct Scene *scene, struct Object *ob);
void modifier_freeTemporaryData(struct ModifierData *md);
bool modifiers_isPreview(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index 22933a093ed..761bb7e8acb 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -48,21 +48,20 @@ struct MVert;
struct MPoly;
struct MLoopTri;
-#include "DNA_object_enums.h"
-
/* Delete mesh mdisps and grid paint masks */
void multires_customdata_delete(struct Mesh *me);
-void multires_set_tot_level(struct MultiresModifierData *mmd, int lvl, eObjectMode object_mode);
+void multires_set_tot_level(struct Object *ob,
+ struct MultiresModifierData *mmd, int lvl);
void multires_mark_as_modified(struct Object *ob, enum MultiresModifiedFlags flags);
void multires_force_update(struct Object *ob);
-void multires_force_render_update(struct Object *ob, eObjectMode object_mode);
+void multires_force_render_update(struct Object *ob);
void multires_force_external_reload(struct Object *ob);
/* internal, only called in subsurf_ccg.c */
-void multires_modifier_update_mdisps(struct DerivedMesh *dm, eObjectMode object_mode);
+void multires_modifier_update_mdisps(struct DerivedMesh *dm);
void multires_modifier_update_hidden(struct DerivedMesh *dm);
void multiresModifier_set_levels_from_disps(struct MultiresModifierData *mmd, struct Object *ob);
@@ -74,27 +73,21 @@ typedef enum {
MULTIRES_IGNORE_SIMPLIFY = 8
} MultiresFlags;
-struct DerivedMesh *multires_make_derived_from_derived(
- struct DerivedMesh *dm,
- struct MultiresModifierData *mmd,
- struct Object *ob,
- MultiresFlags flags,
- eObjectMode object_mode);
+struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm,
+ struct MultiresModifierData *mmd,
+ struct Object *ob,
+ MultiresFlags flags);
struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene,
struct ModifierData *lastmd);
struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first);
struct DerivedMesh *get_multires_dm(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob);
-void multiresModifier_del_levels(
- struct MultiresModifierData *, struct Object *, int direction, eObjectMode object_mode);
-void multiresModifier_base_apply(
- struct MultiresModifierData *mmd, struct Object *ob, eObjectMode object_mode);
-void multiresModifier_subdivide(
- struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple, eObjectMode object_mode);
+void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction);
+void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob);
+void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple);
void multiresModifier_sync_levels_ex(
- struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst,
- eObjectMode object_mode);
+ struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst);
int multiresModifier_reshape(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *dst, struct Object *src);
int multiresModifier_reshapeFromDM(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
@@ -110,7 +103,7 @@ enum {
MULTIRES_SPACE_OBJECT,
MULTIRES_SPACE_ABSOLUTE
};
-void multires_set_space(struct DerivedMesh *dm, struct Object *ob, int from, int to, eObjectMode object_mode);
+void multires_set_space(struct DerivedMesh *dm, struct Object *ob, int from, int to);
/* Related to the old multires */
void multires_free(struct Multires *mr);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 1af31d5e024..c5eefedcfad 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -74,18 +74,16 @@ void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *
bool BKE_object_support_modifier_type_check(struct Object *ob, int modifier_type);
-void BKE_object_link_modifiers(
- struct Object *ob_dst, const struct Object *ob_src,
- eObjectMode object_mode);
+void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src);
void BKE_object_free_modifiers(struct Object *ob, const int flag);
void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
bool BKE_object_exists_check(struct Object *obtest);
-bool BKE_object_is_in_editmode(const struct Object *ob);
+bool BKE_object_is_in_editmode(struct Object *ob);
bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
-bool BKE_object_is_in_wpaint_select_vert(const struct Object *ob, eObjectMode object_mode);
+bool BKE_object_is_in_wpaint_select_vert(const struct Object *ob);
typedef enum eObjectVisibilityCheck {
OB_VISIBILITY_CHECK_FOR_VIEWPORT,
@@ -117,12 +115,9 @@ void BKE_object_lod_add(struct Object *ob);
void BKE_object_lod_sort(struct Object *ob);
bool BKE_object_lod_remove(struct Object *ob, int level);
void BKE_object_lod_update(struct Object *ob, const float camera_position[3]);
-bool BKE_object_lod_is_usable(
- struct Object *ob, struct ViewLayer *view_layer, const eObjectMode object_mode);
-struct Object *BKE_object_lod_meshob_get(
- struct Object *ob, struct ViewLayer *view_layer, const eObjectMode object_mode);
-struct Object *BKE_object_lod_matob_get(
- struct Object *ob, struct ViewLayer *view_layer, const eObjectMode object_mode);
+bool BKE_object_lod_is_usable(struct Object *ob, struct ViewLayer *view_layer);
+struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct ViewLayer *view_layer);
+struct Object *BKE_object_lod_matob_get(struct Object *ob, struct ViewLayer *view_layer);
void BKE_object_copy_data(struct Main *bmain, struct Object *ob_dst, const struct Object *ob_src, const int flag);
struct Object *BKE_object_copy(struct Main *bmain, const struct Object *ob);
@@ -141,7 +136,6 @@ void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
void BKE_object_apply_mat4(struct Object *ob, float mat[4][4], const bool use_compat, const bool use_parent);
void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]);
-bool BKE_object_pose_context_check_ex(struct Object *ob, bool selected);
bool BKE_object_pose_context_check(struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);
struct Object *BKE_object_pose_armature_get_visible(struct Object *ob, struct ViewLayer *view_layer);
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 2840971f157..fa67c07395d 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -93,10 +93,8 @@ typedef enum eOverlayControlFlags {
PAINT_OVERLAY_OVERRIDE_PRIMARY | \
PAINT_OVERLAY_OVERRIDE_CURSOR)
-void BKE_paint_invalidate_overlay_tex(
- struct Scene *scene, struct ViewLayer *view_layer, const struct Tex *tex, eObjectMode object_mode);
-void BKE_paint_invalidate_cursor_overlay(
- struct Scene *scene, struct ViewLayer *view_layer, struct CurveMapping *curve, eObjectMode object_mode);
+void BKE_paint_invalidate_overlay_tex(struct Scene *scene, struct ViewLayer *view_layer, const struct Tex *tex);
+void BKE_paint_invalidate_cursor_overlay(struct Scene *scene, struct ViewLayer *view_layer, struct CurveMapping *curve);
void BKE_paint_invalidate_overlay_all(void);
eOverlayControlFlags BKE_paint_get_overlay_flags(void);
void BKE_paint_reset_overlay_invalid(eOverlayControlFlags flag);
@@ -130,8 +128,7 @@ void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
eObjectMode BKE_paint_object_mode_from_paint_mode(ePaintMode mode);
struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode);
-struct Paint *BKE_paint_get_active(
- struct Scene *sce, struct ViewLayer *view_layer, const eObjectMode object_mode);
+struct Paint *BKE_paint_get_active(struct Scene *sce, struct ViewLayer *view_layer);
struct Paint *BKE_paint_get_active_from_context(const struct bContext *C);
ePaintMode BKE_paintmode_get_active_from_context(const struct bContext *C);
struct Brush *BKE_paint_brush(struct Paint *paint);
@@ -147,9 +144,9 @@ bool BKE_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool
/* testing face select mode
* Texture paint could be removed since selected faces are not used
* however hiding faces is useful */
-bool BKE_paint_select_face_test(struct Object *ob, eObjectMode object_mode);
-bool BKE_paint_select_vert_test(struct Object *ob, eObjectMode object_mode);
-bool BKE_paint_select_elem_test(struct Object *ob, eObjectMode object_mode);
+bool BKE_paint_select_face_test(struct Object *ob);
+bool BKE_paint_select_vert_test(struct Object *ob);
+bool BKE_paint_select_elem_test(struct Object *ob);
/* partial visibility */
bool paint_is_face_hidden(const struct MLoopTri *lt, const struct MVert *mvert, const struct MLoop *mloop);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 06c74d93e7c..886ccb9113a 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -301,8 +301,7 @@ void psys_set_current_num(Object *ob, int index);
struct LatticeDeformData *psys_create_lattice_deform_data(struct ParticleSimulationData *sim);
-bool psys_in_edit_mode(
- const struct EvaluationContext *eval_ctx, struct ViewLayer *view_layer, struct ParticleSystem *psys);
+bool psys_in_edit_mode(struct ViewLayer *view_layer, struct ParticleSystem *psys);
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
bool psys_check_edited(struct ParticleSystem *psys);
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index 0c4f2bc9c05..d2ab4f3164c 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -54,7 +54,6 @@ struct ShrinkwrapModifierData;
struct MDeformVert;
struct BVHTree;
struct SpaceTransform;
-struct EvaluationContext;
typedef struct ShrinkwrapCalcData {
@@ -77,10 +76,8 @@ typedef struct ShrinkwrapCalcData {
} ShrinkwrapCalcData;
-void shrinkwrapModifier_deform(
- const struct EvaluationContext *eval_ctx,
- struct ShrinkwrapModifierData *smd, struct Object *ob, struct DerivedMesh *dm,
- float (*vertexCos)[3], int numVerts, bool for_render);
+void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Object *ob, struct DerivedMesh *dm,
+ float (*vertexCos)[3], int numVerts, bool for_render);
/*
* This function casts a ray in the given BVHTree.. but it takes into consideration the space_transform, that is:
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 0aff79b7e30..9ba4105edda 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -95,6 +95,7 @@ void BKE_workspace_active_layout_set(struct WorkSpaceInstanceHook *h
struct bScreen *BKE_workspace_active_screen_get(const struct WorkSpaceInstanceHook *hook) GETTER_ATTRS;
void BKE_workspace_active_screen_set(
struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct bScreen *screen) SETTER_ATTRS;
+
struct Base *BKE_workspace_active_base_get(const struct WorkSpace *workspace, const struct Scene *scene);
struct ListBase *BKE_workspace_transform_orientations_get(struct WorkSpace *workspace) GETTER_ATTRS;
struct ViewLayer *BKE_workspace_view_layer_get(
@@ -129,13 +130,6 @@ void BKE_workspace_update_tagged(struct EvaluationContext *eval_ctx,
struct WorkSpace *workspace,
struct Scene *scene);
-void BKE_workspace_update_object_mode(
- struct EvaluationContext *eval_ctx,
- struct WorkSpace *workspace);
-
-struct Object *BKE_workspace_edit_object(
- struct WorkSpace *workspace, struct Scene *scene);
-
bool BKE_workspace_owner_id_check(
const struct WorkSpace *workspace, const char *owner_id) ATTR_NONNULL();
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 3001b1f05d5..916e11dbd46 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -51,8 +51,6 @@
#include "BLI_linklist.h"
#include "BLI_task.h"
-#include "DEG_depsgraph.h"
-
#include "BKE_cdderivedmesh.h"
#include "BKE_colorband.h"
#include "BKE_editmesh.h"
@@ -352,7 +350,7 @@ void DM_init(
dm->numPolyData = numPolys;
DM_init_funcs(dm);
-
+
dm->needsFree = 1;
dm->auto_bump_scale = -1.0f;
dm->dirty = 0;
@@ -412,7 +410,6 @@ int DM_release(DerivedMesh *dm)
if (dm->needsFree) {
bvhcache_free(&dm->bvhCache);
GPU_drawobject_free(dm);
-
CustomData_free(&dm->vertData, dm->numVertData);
CustomData_free(&dm->edgeData, dm->numEdgeData);
CustomData_free(&dm->faceData, dm->numTessFaceData);
@@ -1778,19 +1775,17 @@ static void mesh_calc_modifiers(
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
const bool has_multires = (mmd && mmd->sculptlvl != 0);
bool multires_applied = false;
- const bool sculpt_mode = eval_ctx->object_mode & OB_MODE_SCULPT && ob->sculpt && !useRenderParams;
+ const bool sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt && !useRenderParams;
const bool sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm) && !useRenderParams;
const int draw_flag = dm_drawflag_calc(scene->toolsettings, me);
/* Generic preview only in object mode! */
- const bool do_mod_mcol = (eval_ctx->object_mode == OB_MODE_OBJECT);
+ const bool do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
#if 0 /* XXX Will re-enable this when we have global mod stack options. */
const bool do_final_wmcol = (scene->toolsettings->weights_preview == WP_WPREVIEW_FINAL) && do_wmcol;
#endif
const bool do_final_wmcol = false;
- const bool do_init_wmcol = (
- (dataMask & CD_MASK_PREVIEW_MLOOPCOL) &&
- (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) && !do_final_wmcol);
+ const bool do_init_wmcol = ((dataMask & CD_MASK_PREVIEW_MLOOPCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && !do_final_wmcol);
/* XXX Same as above... For now, only weights preview in WPaint mode. */
const bool do_mod_wmcol = do_init_wmcol;
@@ -2628,7 +2623,7 @@ static bool calc_modifiers_skip_orco(const EvaluationContext *eval_ctx,
if (U.opensubdiv_compute_type == USER_OPENSUBDIV_COMPUTE_NONE) {
return false;
}
- else if ((eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
+ else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
return false;
}
else if ((DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
@@ -2669,7 +2664,7 @@ static void mesh_build_data(
ob->lastDataMask = dataMask;
ob->lastNeedMapping = need_mapping;
- if ((eval_ctx->object_mode & OB_MODE_ALL_SCULPT) && ob->sculpt) {
+ if ((ob->mode & OB_MODE_ALL_SCULPT) && ob->sculpt) {
/* create PBVH immediately (would be created on the fly too,
* but this avoids waiting on first stroke) */
@@ -2707,9 +2702,7 @@ static void editbmesh_build_data(
BLI_assert(!(em->derivedFinal->dirty & DM_DIRTY_NORMALS));
}
-static CustomDataMask object_get_datamask(
- const EvaluationContext *eval_ctx,
- const Scene *scene, Object *ob, bool *r_need_mapping)
+static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *r_need_mapping)
{
/* TODO(sergey): Avoid this linear list lookup. */
ViewLayer *view_layer = BKE_view_layer_context_active_PLACEHOLDER(scene);
@@ -2721,28 +2714,28 @@ static CustomDataMask object_get_datamask(
}
if (ob == actob) {
- bool editing = BKE_paint_select_face_test(ob, eval_ctx->object_mode);
+ bool editing = BKE_paint_select_face_test(ob);
/* weight paint and face select need original indices because of selection buffer drawing */
if (r_need_mapping) {
- *r_need_mapping = (editing || (eval_ctx->object_mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT)));
+ *r_need_mapping = (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT)));
}
/* check if we need tfaces & mcols due to face select or texture paint */
- if ((eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) || editing) {
+ if ((ob->mode & OB_MODE_TEXTURE_PAINT) || editing) {
mask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL;
}
/* check if we need mcols due to vertex paint or weightpaint */
- if (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) {
+ if (ob->mode & OB_MODE_VERTEX_PAINT) {
mask |= CD_MASK_MLOOPCOL;
}
- if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (ob->mode & OB_MODE_WEIGHT_PAINT) {
mask |= CD_MASK_PREVIEW_MLOOPCOL;
}
- if (eval_ctx->object_mode & OB_MODE_EDIT)
+ if (ob->mode & OB_MODE_EDIT)
mask |= CD_MASK_MVERT_SKIN;
}
@@ -2754,7 +2747,7 @@ void makeDerivedMesh(
CustomDataMask dataMask, const bool build_shapekey_layers)
{
bool need_mapping;
- dataMask |= object_get_datamask(eval_ctx, scene, ob, &need_mapping);
+ dataMask |= object_get_datamask(scene, ob, &need_mapping);
if (em) {
editbmesh_build_data(eval_ctx, scene, ob, em, dataMask);
@@ -2773,7 +2766,7 @@ DerivedMesh *mesh_get_derived_final(
* the data we need, rebuild the derived mesh
*/
bool need_mapping;
- dataMask |= object_get_datamask(eval_ctx, scene, ob, &need_mapping);
+ dataMask |= object_get_datamask(scene, ob, &need_mapping);
if (!ob->derivedFinal ||
((dataMask & ob->lastDataMask) != dataMask) ||
@@ -2793,7 +2786,7 @@ DerivedMesh *mesh_get_derived_deform(const struct EvaluationContext *eval_ctx, S
*/
bool need_mapping;
- dataMask |= object_get_datamask(eval_ctx, scene, ob, &need_mapping);
+ dataMask |= object_get_datamask(scene, ob, &need_mapping);
if (!ob->derivedDeform ||
((dataMask & ob->lastDataMask) != dataMask) ||
@@ -2912,7 +2905,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- dataMask |= object_get_datamask(eval_ctx, scene, obedit, NULL);
+ dataMask |= object_get_datamask(scene, obedit, NULL);
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
@@ -2932,7 +2925,7 @@ DerivedMesh *editbmesh_get_derived_cage(
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- dataMask |= object_get_datamask(eval_ctx, scene, obedit, NULL);
+ dataMask |= object_get_datamask(scene, obedit, NULL);
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index fc860817a83..a6c6d360769 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -64,8 +64,6 @@
#include "GPU_shader.h"
#include "GPU_basic_shader.h"
-#include "DEG_depsgraph.h"
-
#include <string.h>
#include <limits.h>
#include <math.h>
@@ -262,8 +260,7 @@ static bool can_pbvh_draw(Object *ob, DerivedMesh *dm)
return cddm->mvert == me->mvert || ob->sculpt->kb;
}
-static PBVH *cdDM_getPBVH(
- Object *ob, DerivedMesh *dm, eObjectMode UNUSED(object_mode))
+static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
{
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 704a0163a81..339dcc4a62e 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -306,14 +306,14 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, bool moving)
}
}
-void cloth_clear_cache(const EvaluationContext *eval_ctx, Object *ob, ClothModifierData *clmd, float framenr)
+void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
{
PTCacheID pid;
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
// don't do anything as long as we're in editmode!
- if (pid.cache->edit && eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)
+ if (pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT)
return;
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 2af3b6ce593..98e5bb8ce6e 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -1035,10 +1035,9 @@ int CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectM
int CTX_data_mode_enum(const bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *obedit = CTX_data_edit_object(C);
Object *obact = obedit ? NULL : CTX_data_active_object(C);
- return CTX_data_mode_enum_ex(obedit, obact, workspace->object_mode);
+ return CTX_data_mode_enum_ex(obedit, obact, obact ? obact->mode : OB_MODE_OBJECT);
}
/* would prefer if we can use the enum version below over this one - Campbell */
@@ -1275,9 +1274,8 @@ void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx)
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
RenderEngineType *engine_type = CTX_data_engine_type(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
DEG_evaluation_context_init_from_scene(
eval_ctx,
scene, view_layer, engine_type,
- workspace->object_mode, DAG_EVAL_VIEWPORT);
+ DAG_EVAL_VIEWPORT);
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 1f570dcb531..5eb5272f3e5 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -684,13 +684,13 @@ bool modifier_isCorrectableDeformed(ModifierData *md)
return (mti->deformMatricesEM != NULL);
}
-bool modifiers_isCorrectableDeformed(const EvaluationContext *eval_ctx, struct Scene *scene, Object *ob)
+bool modifiers_isCorrectableDeformed(struct Scene *scene, Object *ob)
{
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
int required_mode = eModifierMode_Realtime;
- if (eval_ctx->object_mode == OB_MODE_EDIT) {
+ if (ob->mode == OB_MODE_EDIT) {
required_mode |= eModifierMode_Editmode;
}
for (; md; md = md->next) {
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index e7c36685c42..55f11604710 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -60,8 +60,6 @@
#include "BKE_object.h"
-#include "DEG_depsgraph.h"
-
#include "CCGSubSurf.h"
#include <math.h>
@@ -338,13 +336,12 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, bool use_f
return mmd;
}
-static int multires_get_level(
- MultiresModifierData *mmd,
- bool render, bool ignore_simplify, eObjectMode object_mode)
+static int multires_get_level(Object *ob, MultiresModifierData *mmd,
+ bool render, bool ignore_simplify)
{
if (render)
return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl, true) : mmd->renderlvl;
- else if (object_mode == OB_MODE_SCULPT)
+ else if (ob->mode == OB_MODE_SCULPT)
return mmd->sculptlvl;
else if (ignore_simplify)
return mmd->lvl;
@@ -352,13 +349,12 @@ static int multires_get_level(
return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl, false) : mmd->lvl;
}
-void multires_set_tot_level(MultiresModifierData *mmd, int lvl, eObjectMode object_mode)
+void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl)
{
mmd->totlvl = lvl;
- if (object_mode != OB_MODE_SCULPT) {
+ if (ob->mode != OB_MODE_SCULPT)
mmd->lvl = CLAMPIS(MAX2(mmd->lvl, lvl), 0, mmd->totlvl);
- }
mmd->sculptlvl = CLAMPIS(MAX2(mmd->sculptlvl, lvl), 0, mmd->totlvl);
mmd->renderlvl = CLAMPIS(MAX2(mmd->renderlvl, lvl), 0, mmd->totlvl);
@@ -396,9 +392,9 @@ void multires_force_external_reload(Object *ob)
multires_force_update(ob);
}
-void multires_force_render_update(Object *ob, eObjectMode object_mode)
+void multires_force_render_update(Object *ob)
{
- if (ob && (object_mode & OB_MODE_SCULPT) && modifiers_findByType(ob, eModifierType_Multires))
+ if (ob && (ob->mode & OB_MODE_SCULPT) && modifiers_findByType(ob, eModifierType_Multires))
multires_force_update(ob);
}
@@ -438,7 +434,7 @@ int multiresModifier_reshapeFromDeformMod(const struct EvaluationContext *eval_c
int numVerts, result;
float (*deformedVerts)[3];
- if (multires_get_level(mmd, false, true, eval_ctx->object_mode) == 0)
+ if (multires_get_level(ob, mmd, false, true) == 0)
return 0;
/* Create DerivedMesh for deformation modifier */
@@ -618,7 +614,7 @@ static void multires_grid_paint_mask_downsample(GridPaintMask *gpm, int level)
}
}
-static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl, eObjectMode object_mode)
+static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
{
Mesh *me = (Mesh *)ob->data;
int levels = mmd->totlvl - lvl;
@@ -680,14 +676,14 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl,
}
}
- multires_set_tot_level(mmd, lvl, object_mode);
+ multires_set_tot_level(ob, mmd, lvl);
}
/* (direction = 1) for delete higher, (direction = 0) for lower (not implemented yet) */
-void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int direction, eObjectMode object_mode)
+void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int direction)
{
Mesh *me = BKE_mesh_from_object(ob);
- int lvl = multires_get_level(mmd, false, true, object_mode);
+ int lvl = multires_get_level(ob, mmd, false, true);
int levels = mmd->totlvl - lvl;
MDisps *mdisps;
@@ -698,14 +694,13 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire
multires_force_update(ob);
if (mdisps && levels > 0 && direction == 1) {
- multires_del_higher(mmd, ob, lvl, object_mode);
+ multires_del_higher(mmd, ob, lvl);
}
- multires_set_tot_level(mmd, lvl, object_mode);
+ multires_set_tot_level(ob, mmd, lvl);
}
-static DerivedMesh *multires_dm_create_local(
- Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple, bool alloc_paint_mask, eObjectMode object_mode)
+static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple, bool alloc_paint_mask)
{
MultiresModifierData mmd = {{NULL}};
MultiresFlags flags = MULTIRES_USE_LOCAL_MMD;
@@ -719,12 +714,10 @@ static DerivedMesh *multires_dm_create_local(
if (alloc_paint_mask)
flags |= MULTIRES_ALLOC_PAINT_MASK;
- return multires_make_derived_from_derived(dm, &mmd, ob, flags, object_mode);
+ return multires_make_derived_from_derived(dm, &mmd, ob, flags);
}
-static DerivedMesh *subsurf_dm_create_local(
- DerivedMesh *dm, int lvl, int simple,
- int optimal, int plain_uv, int alloc_paint_mask, eObjectMode object_mode)
+static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv, int alloc_paint_mask)
{
SubsurfModifierData smd = {{NULL}};
SubsurfFlags flags = 0;
@@ -737,7 +730,7 @@ static DerivedMesh *subsurf_dm_create_local(
if (optimal)
smd.flags |= eSubsurfModifierFlag_ControlEdges;
- if (object_mode & OB_MODE_EDIT)
+ if (ob->mode & OB_MODE_EDIT)
flags |= SUBSURF_IN_EDIT_MODE;
if (alloc_paint_mask)
@@ -757,7 +750,7 @@ static float v3_dist_from_plane(float v[3], float center[3], float no[3])
return dot_v3v3(s, no);
}
-void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob, eObjectMode object_mode)
+void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
{
DerivedMesh *cddm, *dispdm, *origdm;
Mesh *me;
@@ -779,7 +772,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob, eObjectM
/* generate highest level with displacements */
cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
- dispdm = multires_dm_create_local(ob, cddm, totlvl, totlvl, 0, 0, object_mode);
+ dispdm = multires_dm_create_local(ob, cddm, totlvl, totlvl, 0, 0);
cddm->release(cddm);
/* copy the new locations of the base verts into the mesh */
@@ -875,9 +868,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob, eObjectM
/* subdivide the mesh to highest level without displacements */
cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
- origdm = subsurf_dm_create_local(
- cddm, totlvl, 0,
- 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0, object_mode);
+ origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0);
cddm->release(cddm);
/* calc disps */
@@ -887,8 +878,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob, eObjectM
dispdm->release(dispdm);
}
-static void multires_subdivide(
- MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple, eObjectMode object_mode)
+static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple)
{
Mesh *me = ob->data;
MDisps *mdisps;
@@ -917,13 +907,11 @@ static void multires_subdivide(
/* create subsurf DM from original mesh at high level */
cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
- highdm = subsurf_dm_create_local(
- cddm, totlvl, simple,
- 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask, object_mode);
+ highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask);
ss = ((CCGDerivedMesh *)highdm)->ss;
/* create multires DM from original mesh at low level */
- lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple, has_mask, object_mode);
+ lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple, has_mask);
BLI_assert(lowdm != cddm);
cddm->release(cddm);
@@ -970,13 +958,12 @@ static void multires_subdivide(
multires_reallocate_mdisps(me->totloop, mdisps, totlvl);
}
- multires_set_tot_level(mmd, totlvl, object_mode);
+ multires_set_tot_level(ob, mmd, totlvl);
}
-void multiresModifier_subdivide(
- MultiresModifierData *mmd, Object *ob, int updateblock, int simple, eObjectMode object_mode)
+void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple)
{
- multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple, object_mode);
+ multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple);
}
static void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, float t[3])
@@ -1209,7 +1196,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
}
}
-void multires_modifier_update_mdisps(struct DerivedMesh *dm, eObjectMode object_mode)
+void multires_modifier_update_mdisps(struct DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
Object *ob;
@@ -1241,13 +1228,11 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, eObjectMode object_
else cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
- highdm = subsurf_dm_create_local(
- cddm, totlvl, mmd->simple,
- 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask, object_mode);
+ highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask);
ss = ((CCGDerivedMesh *)highdm)->ss;
/* create multires DM from original mesh and displacements */
- lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple, has_mask, object_mode);
+ lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple, has_mask);
cddm->release(cddm);
/* gather grid data */
@@ -1305,9 +1290,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, eObjectMode object_
else cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
- subdm = subsurf_dm_create_local(
- cddm, mmd->totlvl, mmd->simple,
- 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask, object_mode);
+ subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask);
cddm->release(cddm);
multiresModifier_disp_run(dm, me, NULL, CALC_DISPLACEMENTS, subdm->getGridData(subdm), mmd->totlvl);
@@ -1349,7 +1332,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
}
}
-void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to, eObjectMode object_mode)
+void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
{
DerivedMesh *ccgdm = NULL, *subsurf = NULL;
CCGElem **gridData, **subGridData = NULL;
@@ -1370,11 +1353,10 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to, eObjectMo
}
totlvl = mmd->totlvl;
- ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple, false, object_mode);
+ ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple, false);
- subsurf = subsurf_dm_create_local(
- dm, totlvl, mmd->simple,
- mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv, 0, object_mode);
+ subsurf = subsurf_dm_create_local(ob, dm, totlvl,
+ mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv, 0);
numGrids = subsurf->getNumGrids(subsurf);
gridSize = subsurf->getGridSize(subsurf);
@@ -1489,12 +1471,10 @@ void multires_stitch_grids(Object *ob)
}
}
-DerivedMesh *multires_make_derived_from_derived(
- DerivedMesh *dm,
- MultiresModifierData *mmd,
- Object *ob,
- MultiresFlags flags,
- eObjectMode object_mode)
+DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm,
+ MultiresModifierData *mmd,
+ Object *ob,
+ MultiresFlags flags)
{
Mesh *me = ob->data;
DerivedMesh *result;
@@ -1503,18 +1483,16 @@ DerivedMesh *multires_make_derived_from_derived(
CCGKey key;
const bool render = (flags & MULTIRES_USE_RENDER_PARAMS) != 0;
const bool ignore_simplify = (flags & MULTIRES_IGNORE_SIMPLIFY) != 0;
- int lvl = multires_get_level(mmd, render, ignore_simplify, object_mode);
+ int lvl = multires_get_level(ob, mmd, render, ignore_simplify);
int i, gridSize, numGrids;
if (lvl == 0)
return dm;
- result = subsurf_dm_create_local(
- dm, lvl, mmd->simple,
- mmd->flags & eMultiresModifierFlag_ControlEdges,
- mmd->flags & eMultiresModifierFlag_PlainUv,
- flags & MULTIRES_ALLOC_PAINT_MASK,
- object_mode);
+ result = subsurf_dm_create_local(ob, dm, lvl,
+ mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges,
+ mmd->flags & eMultiresModifierFlag_PlainUv,
+ flags & MULTIRES_ALLOC_PAINT_MASK);
if (!(flags & MULTIRES_USE_LOCAL_MMD)) {
ccgdm = (CCGDerivedMesh *)result;
@@ -2142,7 +2120,6 @@ void multires_load_old(Object *ob, Mesh *me)
DerivedMesh *dm, *orig;
CustomDataLayer *l;
int i;
- const eObjectMode object_mode = OB_MODE_OBJECT;
/* Load original level into the mesh */
lvl = me->mr->levels.first;
@@ -2191,7 +2168,7 @@ void multires_load_old(Object *ob, Mesh *me)
BLI_insertlinkbefore(&ob->modifiers, md, mmd);
for (i = 0; i < me->mr->level_count - 1; ++i)
- multiresModifier_subdivide(mmd, ob, 1, 0, object_mode);
+ multiresModifier_subdivide(mmd, ob, 1, 0);
mmd->lvl = mmd->totlvl;
orig = CDDM_from_mesh(me);
@@ -2200,7 +2177,7 @@ void multires_load_old(Object *ob, Mesh *me)
* reference subsurfed dm with this option, before calling multiresModifier_disp_run(),
* which implicitly expects both subsurfs from its first dm and oldGridData parameters to
* be of the same "format"! */
- dm = multires_make_derived_from_derived(orig, mmd, ob, 0, object_mode);
+ dm = multires_make_derived_from_derived(orig, mmd, ob, 0);
multires_load_old_dm(dm, me, mmd->totlvl + 1);
@@ -2215,22 +2192,21 @@ void multires_load_old(Object *ob, Mesh *me)
/* If 'ob_src' and 'ob_dst' both have multires modifiers, synchronize them
* such that 'ob_dst' has the same total number of levels as 'ob_src'. */
-void multiresModifier_sync_levels_ex(
- Object *ob_dst, MultiresModifierData *mmd_src, MultiresModifierData *mmd_dst, eObjectMode object_mode)
+void multiresModifier_sync_levels_ex(Object *ob_dst, MultiresModifierData *mmd_src, MultiresModifierData *mmd_dst)
{
if (mmd_src->totlvl == mmd_dst->totlvl) {
return;
}
if (mmd_src->totlvl > mmd_dst->totlvl) {
- multires_subdivide(mmd_dst, ob_dst, mmd_src->totlvl, false, mmd_dst->simple, object_mode);
+ multires_subdivide(mmd_dst, ob_dst, mmd_src->totlvl, false, mmd_dst->simple);
}
else {
- multires_del_higher(mmd_dst, ob_dst, mmd_src->totlvl, object_mode);
+ multires_del_higher(mmd_dst, ob_dst, mmd_src->totlvl);
}
}
-static void multires_sync_levels(Scene *scene, Object *ob_src, Object *ob_dst, eObjectMode object_mode)
+static void multires_sync_levels(Scene *scene, Object *ob_src, Object *ob_dst)
{
MultiresModifierData *mmd_src = get_multires_modifier(scene, ob_src, true);
MultiresModifierData *mmd_dst = get_multires_modifier(scene, ob_dst, true);
@@ -2245,7 +2221,7 @@ static void multires_sync_levels(Scene *scene, Object *ob_src, Object *ob_dst, e
}
if (mmd_src && mmd_dst) {
- multiresModifier_sync_levels_ex(ob_dst, mmd_src, mmd_dst, object_mode);
+ multiresModifier_sync_levels_ex(ob_dst, mmd_src, mmd_dst);
}
}
@@ -2338,9 +2314,7 @@ static void multires_apply_smat(const struct EvaluationContext *eval_ctx, Scene
MEM_freeN(vertCos);
/* scaled ccgDM for tangent space of object with applied scale */
- dm = subsurf_dm_create_local(
- cddm, high_mmd.totlvl, high_mmd.simple,
- 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0, eval_ctx->object_mode);
+ dm = subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0);
cddm->release(cddm);
gridSize = dm->getGridSize(dm);
@@ -2403,7 +2377,7 @@ void multiresModifier_scale_disp(const struct EvaluationContext *eval_ctx, Scene
void multiresModifier_prepare_join(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *to_ob)
{
float smat[3][3], tmat[3][3], mat[3][3];
- multires_sync_levels(scene, to_ob, ob, eval_ctx->object_mode);
+ multires_sync_levels(scene, to_ob, ob);
/* construct scale matrix for displacement */
BKE_object_scale_to_mat3(to_ob, tmat);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 59d2bcc89fd..98fcd478b07 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -262,9 +262,7 @@ bool BKE_object_support_modifier_type_check(Object *ob, int modifier_type)
return true;
}
-void BKE_object_link_modifiers(
- struct Object *ob_dst, const struct Object *ob_src,
- eObjectMode object_mode)
+void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src)
{
ModifierData *md;
BKE_object_free_modifiers(ob_dst, 0);
@@ -303,8 +301,7 @@ void BKE_object_link_modifiers(
if (md->type == eModifierType_Multires) {
/* Has to be done after mod creation, but *before* we actually copy its settings! */
- multiresModifier_sync_levels_ex(
- ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd, object_mode);
+ multiresModifier_sync_levels_ex(ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd);
}
modifier_copyData(md, nmd);
@@ -490,7 +487,7 @@ void BKE_object_free(Object *ob)
}
/* actual check for internal data, not context or flags */
-bool BKE_object_is_in_editmode(const Object *ob)
+bool BKE_object_is_in_editmode(Object *ob)
{
if (ob->data == NULL)
return false;
@@ -539,11 +536,11 @@ bool BKE_object_is_in_editmode_vgroup(Object *ob)
BKE_object_is_in_editmode(ob));
}
-bool BKE_object_is_in_wpaint_select_vert(const Object *ob, eObjectMode object_mode)
+bool BKE_object_is_in_wpaint_select_vert(const Object *ob)
{
if (ob->type == OB_MESH) {
- const Mesh *me = ob->data;
- return ((object_mode & OB_MODE_WEIGHT_PAINT) &&
+ Mesh *me = ob->data;
+ return ((ob->mode & OB_MODE_WEIGHT_PAINT) &&
(me->edit_btmesh == NULL) &&
(ME_EDIT_PAINT_SEL_MODE(me) == SCE_SELECT_VERTEX));
}
@@ -888,10 +885,10 @@ static LodLevel *lod_level_select(Object *ob, const float camera_position[3])
return current;
}
-bool BKE_object_lod_is_usable(Object *ob, ViewLayer *view_layer, const eObjectMode object_mode)
+bool BKE_object_lod_is_usable(Object *ob, ViewLayer *view_layer)
{
bool active = (view_layer) ? ob == OBACT(view_layer) : false;
- return (object_mode == OB_MODE_OBJECT || !active);
+ return (ob->mode == OB_MODE_OBJECT || !active);
}
void BKE_object_lod_update(Object *ob, const float camera_position[3])
@@ -904,11 +901,11 @@ void BKE_object_lod_update(Object *ob, const float camera_position[3])
}
}
-static Object *lod_ob_get(Object *ob, ViewLayer *view_layer, int flag, const eObjectMode object_mode)
+static Object *lod_ob_get(Object *ob, ViewLayer *view_layer, int flag)
{
LodLevel *current = ob->currentlod;
- if (!current || !BKE_object_lod_is_usable(ob, view_layer, object_mode))
+ if (!current || !BKE_object_lod_is_usable(ob, view_layer))
return ob;
while (current->prev && (!(current->flags & flag) || !current->source || current->source->type != OB_MESH)) {
@@ -918,14 +915,14 @@ static Object *lod_ob_get(Object *ob, ViewLayer *view_layer, int flag, const eOb
return current->source;
}
-struct Object *BKE_object_lod_meshob_get(Object *ob, ViewLayer *view_layer, const eObjectMode object_mode)
+struct Object *BKE_object_lod_meshob_get(Object *ob, ViewLayer *view_layer)
{
- return lod_ob_get(ob, view_layer, OB_LOD_USE_MESH, object_mode);
+ return lod_ob_get(ob, view_layer, OB_LOD_USE_MESH);
}
-struct Object *BKE_object_lod_matob_get(Object *ob, ViewLayer *view_layer, const eObjectMode object_mode)
+struct Object *BKE_object_lod_matob_get(Object *ob, ViewLayer *view_layer)
{
- return lod_ob_get(ob, view_layer, OB_LOD_USE_MAT, object_mode);
+ return lod_ob_get(ob, view_layer, OB_LOD_USE_MAT);
}
#endif /* WITH_GAMEENGINE */
@@ -1154,13 +1151,12 @@ static void copy_object_lod(Object *obn, const Object *ob, const int UNUSED(flag
obn->currentlod = (LodLevel *)obn->lodlevels.first;
}
-bool BKE_object_pose_context_check_ex(Object *ob, bool selected)
+bool BKE_object_pose_context_check(Object *ob)
{
if ((ob) &&
(ob->type == OB_ARMATURE) &&
(ob->pose) &&
- /* Currently using selection when the object isn't active. */
- ((selected == false) || (ob->flag & SELECT)))
+ (ob->mode & OB_MODE_POSE))
{
return true;
}
@@ -1169,23 +1165,18 @@ bool BKE_object_pose_context_check_ex(Object *ob, bool selected)
}
}
-bool BKE_object_pose_context_check(Object *ob)
-{
- return BKE_object_pose_context_check_ex(ob, false);
-}
-
Object *BKE_object_pose_armature_get(Object *ob)
{
if (ob == NULL)
return NULL;
- if (BKE_object_pose_context_check_ex(ob, false))
+ if (BKE_object_pose_context_check(ob))
return ob;
ob = modifiers_isDeformedByArmature(ob);
/* Only use selected check when non-active. */
- if (BKE_object_pose_context_check_ex(ob, true))
+ if (BKE_object_pose_context_check(ob))
return ob;
return NULL;
@@ -1265,6 +1256,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
BKE_object_facemap_copy_list(&ob_dst->fmaps, &ob_src->fmaps);
BKE_constraints_copy_ex(&ob_dst->constraints, &ob_src->constraints, flag_subdata, true);
+ ob_dst->mode = OB_MODE_OBJECT;
ob_dst->sculpt = NULL;
if (ob_src->pd) {
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 7419efba065..0db77432d53 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -108,8 +108,8 @@ static void init_context(DupliContext *r_ctx, const EvaluationContext *eval_ctx,
r_ctx->animated = false;
r_ctx->group = NULL;
- r_ctx->obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx);
r_ctx->object = ob;
+ r_ctx->obedit = OBEDIT_FROM_OBACT(ob);
if (space_mat)
copy_m4_m4(r_ctx->space_mat, space_mat);
else
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 2a33937e6ed..de2002624c0 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -172,7 +172,7 @@ void BKE_object_handle_data_update(
switch (ob->type) {
case OB_MESH:
{
- BMEditMesh *em = (eval_ctx->object_mode & OB_MODE_EDIT) ? BKE_editmesh_from_object(ob) : NULL;
+ BMEditMesh *em = (ob->mode & OB_MODE_EDIT) ? BKE_editmesh_from_object(ob) : NULL;
uint64_t data_mask = scene->customdata_mask | CD_MASK_BAREMESH;
#ifdef WITH_FREESTYLE
/* make sure Freestyle edge/face marks appear in DM for render (see T40315) */
@@ -222,7 +222,7 @@ void BKE_object_handle_data_update(
}
/* particles */
- if ((ob != OBEDIT_FROM_EVAL_CTX(eval_ctx)) && ob->particlesystem.first) {
+ if ((ob != OBEDIT_FROM_VIEW_LAYER(eval_ctx->view_layer)) && ob->particlesystem.first) {
ParticleSystem *tpsys, *psys;
DerivedMesh *dm;
ob->transflag &= ~OB_DUPLIPARTS;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 3ed2aeb6582..20375fe6953 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -76,67 +76,27 @@ const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
static eOverlayControlFlags overlay_flags = 0;
-/* Keep in sync with 'BKE_paint_get_active' */
-#define OB_MODE_HAS_PAINT_STRUCT(SEP) \
- OB_MODE_SCULPT SEP \
- OB_MODE_VERTEX_PAINT SEP \
- OB_MODE_WEIGHT_PAINT SEP \
- OB_MODE_TEXTURE_PAINT SEP \
- OB_MODE_EDIT
-
-#define COMMA ,
-static const eObjectMode ob_mode_has_paint_struct = OB_MODE_HAS_PAINT_STRUCT(|);
-static const eObjectMode ob_mode_has_paint_struct_array[] = {OB_MODE_HAS_PAINT_STRUCT(COMMA)};
-#undef COMMA
-
-#define FOREACH_OB_MODE_PAINT_ITER_BEGIN(scene, view_layer, object_mode, p) \
-{ \
- eObjectMode object_mode_test = object_mode & ob_mode_has_paint_struct; \
- for (uint _i = 0; _i < ARRAY_SIZE(ob_mode_has_paint_struct_array) && object_mode_test; _i++) { \
- eObjectMode object_mode_single = ob_mode_has_paint_struct_array[_i]; \
- if (object_mode_test & object_mode_single) { \
- object_mode_test &= ~object_mode_single; \
- Paint *p = BKE_paint_get_active(scene, view_layer, object_mode_single); \
- {
-
-#define FOREACH_OB_MODE_PAINT_ITER_END \
- } \
- } \
- } \
-} ((void)0)
-
-void BKE_paint_invalidate_overlay_tex(
- Scene *scene, ViewLayer *view_layer, const Tex *tex, eObjectMode object_mode)
+void BKE_paint_invalidate_overlay_tex(Scene *scene, ViewLayer *view_layer, const Tex *tex)
{
- FOREACH_OB_MODE_PAINT_ITER_BEGIN(scene, view_layer, object_mode, p)
- {
- Brush *br = p->brush;
- if (br) {
- if (br->mtex.tex == tex) {
- overlay_flags |= PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY;
- }
- if (br->mask_mtex.tex == tex) {
- overlay_flags |= PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY;
- }
- }
- }
- FOREACH_OB_MODE_PAINT_ITER_END;
+ Paint *p = BKE_paint_get_active(scene, view_layer);
+ Brush *br = p->brush;
+
+ if (!br)
+ return;
+
+ if (br->mtex.tex == tex)
+ overlay_flags |= PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY;
+ if (br->mask_mtex.tex == tex)
+ overlay_flags |= PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY;
}
-void BKE_paint_invalidate_cursor_overlay(
- Scene *scene, ViewLayer *view_layer, CurveMapping *curve, eObjectMode object_mode)
+void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, CurveMapping *curve)
{
- FOREACH_OB_MODE_PAINT_ITER_BEGIN(scene, view_layer, object_mode, p)
- {
- Brush *br = p->brush;
- if (br) {
- if (br->curve == curve) {
- overlay_flags |= PAINT_INVALID_OVERLAY_CURVE;
- break;
- }
- }
- }
- FOREACH_OB_MODE_PAINT_ITER_END;
+ Paint *p = BKE_paint_get_active(scene, view_layer);
+ Brush *br = p->brush;
+
+ if (br && br->curve == curve)
+ overlay_flags |= PAINT_INVALID_OVERLAY_CURVE;
}
void BKE_paint_invalidate_overlay_all(void)
@@ -198,13 +158,13 @@ Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
return NULL;
}
-Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer, const eObjectMode object_mode)
+Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
{
if (sce && view_layer) {
ToolSettings *ts = sce->toolsettings;
if (view_layer->basact && view_layer->basact->object) {
- switch (object_mode) {
+ switch (view_layer->basact->object->mode) {
case OB_MODE_SCULPT:
return &ts->sculpt->paint;
case OB_MODE_VERTEX_PAINT:
@@ -236,7 +196,6 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
SpaceImage *sima;
if (sce && view_layer) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
ToolSettings *ts = sce->toolsettings;
Object *obact = NULL;
@@ -244,7 +203,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
obact = view_layer->basact->object;
if ((sima = CTX_wm_space_image(C)) != NULL) {
- if (obact && workspace->object_mode == OB_MODE_EDIT) {
+ if (obact && obact->mode == OB_MODE_EDIT) {
if (sima->mode == SI_MODE_PAINT)
return &ts->imapaint.paint;
else if (ts->use_uv_sculpt)
@@ -255,7 +214,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
}
}
else if (obact) {
- switch (workspace->object_mode) {
+ switch (obact->mode) {
case OB_MODE_SCULPT:
return &ts->sculpt->paint;
case OB_MODE_VERTEX_PAINT:
@@ -288,7 +247,6 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
SpaceImage *sima;
if (sce && view_layer) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
ToolSettings *ts = sce->toolsettings;
Object *obact = NULL;
@@ -296,7 +254,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
obact = view_layer->basact->object;
if ((sima = CTX_wm_space_image(C)) != NULL) {
- if (obact && workspace->object_mode == OB_MODE_EDIT) {
+ if (obact && obact->mode == OB_MODE_EDIT) {
if (sima->mode == SI_MODE_PAINT)
return ePaintTexture2D;
else if (ts->use_uv_sculpt)
@@ -307,7 +265,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
}
}
else if (obact) {
- switch (workspace->object_mode) {
+ switch (obact->mode) {
case OB_MODE_SCULPT:
return ePaintSculpt;
case OB_MODE_VERTEX_PAINT:
@@ -498,24 +456,24 @@ bool BKE_palette_is_empty(const struct Palette *palette)
/* are we in vertex paint or weight pain face select mode? */
-bool BKE_paint_select_face_test(Object *ob, eObjectMode object_mode)
+bool BKE_paint_select_face_test(Object *ob)
{
return ( (ob != NULL) &&
(ob->type == OB_MESH) &&
(ob->data != NULL) &&
(((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) &&
- (object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))
+ (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))
);
}
/* are we in weight paint vertex select mode? */
-bool BKE_paint_select_vert_test(Object *ob, eObjectMode object_mode)
+bool BKE_paint_select_vert_test(Object *ob)
{
return ( (ob != NULL) &&
(ob->type == OB_MESH) &&
(ob->data != NULL) &&
(((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) &&
- (object_mode & OB_MODE_WEIGHT_PAINT || object_mode & OB_MODE_VERTEX_PAINT)
+ (ob->mode & OB_MODE_WEIGHT_PAINT || ob->mode & OB_MODE_VERTEX_PAINT)
);
}
@@ -523,10 +481,10 @@ bool BKE_paint_select_vert_test(Object *ob, eObjectMode object_mode)
* used to check if selection is possible
* (when we don't care if its face or vert)
*/
-bool BKE_paint_select_elem_test(Object *ob, eObjectMode object_mode)
+bool BKE_paint_select_elem_test(Object *ob)
{
- return (BKE_paint_select_vert_test(ob, object_mode) ||
- BKE_paint_select_face_test(ob, object_mode));
+ return (BKE_paint_select_vert_test(ob) ||
+ BKE_paint_select_face_test(ob));
}
void BKE_paint_cavity_curve_preset(Paint *p, int preset)
@@ -829,7 +787,7 @@ void BKE_sculptsession_free(Object *ob)
BM_log_free(ss->bm_log);
if (dm && dm->getPBVH)
- dm->getPBVH(NULL, dm, OB_MODE_OBJECT); /* signal to clear */
+ dm->getPBVH(NULL, dm); /* signal to clear */
if (ss->texcache)
MEM_freeN(ss->texcache);
@@ -966,7 +924,7 @@ void BKE_sculpt_update_mesh_elements(
dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
/* VWPaint require mesh info for loop lookup, so require sculpt mode here */
- if (mmd && eval_ctx->object_mode & OB_MODE_SCULPT) {
+ if (mmd && ob->mode & OB_MODE_SCULPT) {
ss->multires = mmd;
ss->totvert = dm->getNumVerts(dm);
ss->totpoly = dm->getNumPolys(dm);
@@ -984,7 +942,7 @@ void BKE_sculpt_update_mesh_elements(
ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK);
}
- ss->pbvh = dm->getPBVH(ob, dm, eval_ctx->object_mode);
+ ss->pbvh = dm->getPBVH(ob, dm);
ss->pmap = (need_pmap && dm->getPolyMap) ? dm->getPolyMap(ob, dm) : NULL;
pbvh_show_diffuse_color_set(ss->pbvh, ss->show_diffuse_color);
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 5a30b3dacf8..3e9c525b92d 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -251,7 +251,7 @@ struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData
{
struct LatticeDeformData *lattice_deform_data = NULL;
- if (psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, sim->psys) == 0) {
+ if (psys_in_edit_mode(sim->eval_ctx->view_layer, sim->psys) == 0) {
Object *lattice = NULL;
ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys);
int mode = G.is_rendering ? eModifierMode_Render : eModifierMode_Realtime;
@@ -288,12 +288,11 @@ void psys_enable_all(Object *ob)
psys->flag &= ~PSYS_DISABLED;
}
-bool psys_in_edit_mode(const EvaluationContext *eval_ctx, ViewLayer *view_layer, ParticleSystem *psys)
+bool psys_in_edit_mode(ViewLayer *view_layer, ParticleSystem *psys)
{
- /* TODO(mai): the check for view_layer shouldnt be needed, remove when render engine api is updated for this */
- return (view_layer && view_layer->basact &&
- (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT) &&
- psys == psys_get_current(view_layer->basact->object) &&
+ return (view_layer->basact &&
+ (view_layer->basact->object->mode & OB_MODE_PARTICLE_EDIT) &&
+ psys == psys_get_current((view_layer->basact)->object) &&
(psys->edit || psys->pointcache->edit) &&
!psys->renderdata);
}
@@ -2095,7 +2094,7 @@ static bool psys_thread_context_init_path(
psys_thread_context_init(ctx, sim);
/*---start figuring out what is actually wanted---*/
- if (psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, psys)) {
+ if (psys_in_edit_mode(sim->eval_ctx->view_layer, psys)) {
ParticleEditSettings *pset = &scene->toolsettings->particle;
if ((psys->renderdata == 0 && use_render_params == 0) && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0)
@@ -2192,7 +2191,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
ParticleSystem *psys = ctx->sim.psys;
ParticleSettings *part = psys->part;
ParticleCacheKey **cache = psys->childcache;
- ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.eval_ctx, ctx->sim.eval_ctx->view_layer, psys) && psys->edit ? psys->edit->pathcache : psys->pathcache;
+ ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.eval_ctx->view_layer, psys) && psys->edit ? psys->edit->pathcache : psys->pathcache;
ParticleCacheKey *child, *key[4];
ParticleTexture ptex;
float *cpa_fuv = 0, *par_rot = 0, rot[4];
@@ -2616,7 +2615,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
return;
#if 0 /* TODO(mai): something is very wrong with these conditionals, they dont make sense and the cache isnt updating */
- if (psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, psys))
+ if (psys_in_edit_mode(sim->eval_ctx->view_layer, psys))
if (psys->renderdata == 0 && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0)
return;
#endif
@@ -3244,6 +3243,8 @@ void object_remove_particle_system(Scene *UNUSED(scene), Object *ob)
if (ob->particlesystem.first)
((ParticleSystem *) ob->particlesystem.first)->flag |= PSYS_CURRENT;
+ else
+ ob->mode &= ~OB_MODE_PARTICLE_EDIT;
DEG_relations_tag_update(G.main);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -3829,7 +3830,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE);
/* pind.dm disabled in editmode means we don't get effectors taken into
* account when subdividing for instance */
- pind.dm = psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, psys) ? NULL : psys->hair_out_dm;
+ pind.dm = psys_in_edit_mode(sim->eval_ctx->view_layer, psys) ? NULL : psys->hair_out_dm;
init_particle_interpolation(sim->ob, psys, pa, &pind);
do_particle_interpolation(psys, p, pa, t, &pind, state);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 8bb35dae96c..2b00e52246f 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2911,11 +2911,8 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons
if ((psys->part->childtype && psys->totchild != psys_get_tot_child(sim->scene, psys)) || psys->recalc&PSYS_RECALC_RESET)
alloc=1;
- if (alloc || psys->recalc&PSYS_RECALC_CHILD ||
- (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT)))
- {
+ if (alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
distr=1;
- }
if (distr) {
if (alloc)
@@ -2945,7 +2942,7 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons
skip = 1; /* no need to cache paths while baking dynamics */
#if 0 /* TODO(mai): something is very wrong with these conditionals, they dont make sense and the cache isnt updating */
- else if (psys_in_edit_mode(sim->eval_ctx, sim->eval_ctx->view_layer, psys)) {
+ else if (psys_in_edit_mode(sim->eval_ctx->view_layer, psys)) {
if ((pset->flag & PE_DRAW_PART)==0)
skip = 1;
else if (part->childtype==0 && (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0)
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index ca9cddde65a..b27f7370ff4 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1353,7 +1353,7 @@ static bool check_rendered_viewport_visible(Main *bmain)
/* TODO(campbell): shouldn't we be able to use 'eval_ctx->view_layer' here?
* Currently this is NULL on load, so don't. */
static void prepare_mesh_for_viewport_render(
- Main *bmain, const EvaluationContext *eval_ctx, const ViewLayer *view_layer)
+ Main *bmain, const ViewLayer *view_layer)
{
/* This is needed to prepare mesh to be used by the render
* engine from the viewport rendering. We do loading here
@@ -1364,8 +1364,7 @@ static void prepare_mesh_for_viewport_render(
* call loading of the edit data for the mesh objects.
*/
- /* Expanded 'OBEDIT_FROM_EVAL_CTX' */
- Object *obedit = (eval_ctx->object_mode & OB_MODE_EDIT) ? OBACT(view_layer) : NULL;
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
if (obedit) {
Mesh *mesh = obedit->data;
if ((obedit->type == OB_MESH) &&
@@ -1407,7 +1406,7 @@ void BKE_scene_graph_update_tagged(EvaluationContext *eval_ctx,
/* Uncomment this to check if graph was properly tagged for update. */
// DEG_debug_graph_relations_validate(depsgraph, bmain, scene);
/* Flush editing data if needed. */
- prepare_mesh_for_viewport_render(bmain, eval_ctx, view_layer);
+ prepare_mesh_for_viewport_render(bmain, view_layer);
/* Flush recalc flags to dependencies. */
DEG_graph_flush_update(bmain, depsgraph);
/* Update all objects: drivers, matrices, displists, etc. flags set
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index e91c3e43b83..618f495dbf1 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -57,8 +57,6 @@
#include "BLI_strict_flags.h"
-#include "DEG_depsgraph.h"
-
/* for timing... */
#if 0
# include "PIL_time_utildefines.h"
@@ -616,9 +614,8 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
}
/* Main shrinkwrap function */
-void shrinkwrapModifier_deform(
- const EvaluationContext *eval_ctx, ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm,
- float (*vertexCos)[3], int numVerts, bool for_render)
+void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm,
+ float (*vertexCos)[3], int numVerts, bool for_render)
{
DerivedMesh *ss_mesh = NULL;
@@ -673,8 +670,7 @@ void shrinkwrapModifier_deform(
ssmd.subdivType = ME_CC_SUBSURF; /* catmull clark */
ssmd.levels = smd->subsurfLevels; /* levels */
- ss_mesh = subsurf_make_derived_from_derived(
- dm, &ssmd, NULL, (eval_ctx->object_mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0);
+ ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0);
if (ss_mesh) {
calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT);
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 10792b7d579..9280341b4e4 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -85,8 +85,6 @@
#include "CCGSubSurf.h"
-#include "DEG_depsgraph.h"
-
#ifdef WITH_OPENSUBDIV
# include "opensubdiv_capi.h"
#endif
@@ -3790,14 +3788,12 @@ static void ccgDM_release(DerivedMesh *dm)
{
ccgdm->multires.mmd = NULL;
}
+
if (ccgdm->multires.mmd) {
- if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED) {
- /* TODO/OBMODE, pass real mode? */
- multires_modifier_update_mdisps(dm, OB_MODE_OBJECT);
- }
- if (ccgdm->multires.modified_flags & MULTIRES_HIDDEN_MODIFIED) {
+ if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED)
+ multires_modifier_update_mdisps(dm);
+ if (ccgdm->multires.modified_flags & MULTIRES_HIDDEN_MODIFIED)
multires_modifier_update_hidden(dm);
- }
}
}
@@ -4191,8 +4187,7 @@ static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm)
return 1;
}
-static struct PBVH *ccgDM_getPBVH(
- Object *ob, DerivedMesh *dm, eObjectMode object_mode)
+static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
CCGKey key;
@@ -4209,7 +4204,7 @@ static struct PBVH *ccgDM_getPBVH(
return NULL;
bool grid_pbvh = ccgDM_use_grid_pbvh(ccgdm);
- if ((object_mode & OB_MODE_SCULPT) == 0) {
+ if ((ob->mode & OB_MODE_SCULPT) == 0) {
/* In vwpaint, we may use a grid_pbvh for multires/subsurf, under certain conditions.
* More complex cases break 'history' trail back to original vertices, in that case we fall back to
* deformed cage only (i.e. original deformed mesh). */
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 301084e22fc..26a680c881f 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -511,30 +511,6 @@ void BKE_workspace_update_tagged(struct EvaluationContext *eval_ctx,
BKE_scene_graph_update_tagged(eval_ctx, depsgraph, bmain, scene, view_layer);
}
-void BKE_workspace_update_object_mode(
- struct EvaluationContext *eval_ctx,
- WorkSpace *workspace)
-{
- /* TODO(campbell): Investigate how this should work exactly,
- * for now without this 'bmain->eval_ctx' is never set. */
-
- eval_ctx->object_mode = workspace->object_mode;
-}
-
-Object *BKE_workspace_edit_object(WorkSpace *workspace, Scene *scene)
-{
- if (workspace->object_mode & OB_MODE_EDIT) {
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
- if (view_layer) {
- Object *obedit = OBACT(view_layer);
- if (obedit) {
- BLI_assert(BKE_object_is_in_editmode(obedit));
- return obedit;
- }
- }
- }
- return NULL;
-}
bool BKE_workspace_owner_id_check(
const WorkSpace *workspace, const char *owner_id)
@@ -549,3 +525,4 @@ bool BKE_workspace_owner_id_check(
return BLI_findstring(&workspace->owner_ids, owner_id, offsetof(wmOwnerID, name)) != NULL;
}
}
+
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 0b61aa5557a..7ae8f0410c5 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4944,7 +4944,8 @@ static void lib_link_object(FileData *fd, Main *main)
#else
MEM_freeN(ob->pose);
#endif
- ob->pose = NULL;
+ ob->pose= NULL;
+ ob->mode &= ~OB_MODE_POSE;
}
}
for (a=0; a < ob->totcol; a++)
@@ -5553,6 +5554,19 @@ static void direct_link_object(FileData *fd, Object *ob)
/* XXX This should not be needed - but seems like it can happen in some cases, so for now play safe... */
ob->proxy_from = NULL;
+
+ /* loading saved files with editmode enabled works, but for undo we like
+ * to stay in object mode during undo presses so keep editmode disabled.
+ *
+ * Also when linking in a file don't allow edit and pose modes.
+ * See [#34776, #42780] for more information.
+ */
+ if (fd->memfile || (ob->id.tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT))) {
+ ob->mode &= ~(OB_MODE_EDIT | OB_MODE_PARTICLE_EDIT);
+ if (!fd->memfile) {
+ ob->mode &= ~OB_MODE_POSE;
+ }
+ }
ob->adt = newdataadr(fd, ob->adt);
direct_link_animdata(fd, ob->adt);
@@ -10500,6 +10514,7 @@ static void link_object_postprocess(ID *id, Scene *scene, ViewLayer *view_layer,
SceneCollection *sc;
ob = (Object *)id;
+ ob->mode = OB_MODE_OBJECT;
sc = get_scene_collection_active_or_create(scene, view_layer, flag);
BKE_collection_object_add(&scene->id, sc, ob);
@@ -10542,6 +10557,8 @@ void BLO_library_link_copypaste(Main *mainl, BlendHandle *bh)
if (bhead->code == ID_OB) {
/* Instead of instancing Base's directly, postpone until after groups are loaded
* otherwise the base's flag is set incorrectly when groups are used */
+ Object *ob = (Object *)id;
+ ob->mode = OB_MODE_OBJECT;
/* ensure give_base_to_objects runs on this object */
BLI_assert(id->us == 0);
}
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 59dc6e9d6b7..f5a4a33860f 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -1087,6 +1087,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) {
Scene *sce;
+ Object *ob;
+
for (sce = main->scene.first; sce; sce = sce->id.next) {
if (fd->fileflags & G_FILE_ENABLE_ALL_FRAMES)
sce->gm.flag |= GAME_ENABLE_ALL_FRAMES;
@@ -1118,6 +1120,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
else
sce->gm.matmode = GAME_MAT_TEXFACE;
}
+
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ if (ob->flag & 8192) // OB_POSEMODE = 8192
+ ob->mode |= OB_MODE_POSE;
+ }
}
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 4)) {
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index ef7b54195ff..9e03c28ba1b 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -1042,7 +1042,7 @@ void BM_edges_sharp_from_angle_set(BMesh *bm, const float split_angle)
}
static void UNUSED_FUNCTION(bm_mdisps_space_set)(
- Object *ob, BMesh *bm, int from, int to, eObjectMode object_mode)
+ Object *ob, BMesh *bm, int from, int to)
{
/* switch multires data out of tangent space */
if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
@@ -1053,7 +1053,7 @@ static void UNUSED_FUNCTION(bm_mdisps_space_set)(
BMIter iter;
// int i = 0; // UNUSED
- multires_set_space(dm, ob, from, to, object_mode);
+ multires_set_space(dm, ob, from, to);
mdisps = CustomData_get_layer(&dm->loopData, CD_MDISPS);
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 1df0705c855..2f692cb0f33 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -403,7 +403,7 @@ void AnimationExporter::export_morph_animation(Object *ob)
void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<float> &frames )
{
- ListBase *conlist = get_active_constraints(this->eval_ctx, ob);
+ ListBase *conlist = get_active_constraints(ob);
if (conlist == NULL) return;
bConstraint *con;
for (con = (bConstraint *)conlist->first; con; con = con->next) {
@@ -1006,7 +1006,7 @@ std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemanti
void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime)
{
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
- ListBase *conlist = get_active_constraints(this->eval_ctx, ob);
+ ListBase *conlist = get_active_constraints(ob);
bConstraint *con;
for (con = (bConstraint *)conlist->first; con; con = con->next) {
ListBase targets = { NULL, NULL };
diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp
index 24b47f8db3c..a2cb8237d08 100644
--- a/source/blender/collada/SkinInfo.cpp
+++ b/source/blender/collada/SkinInfo.cpp
@@ -227,7 +227,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- ModifierData *md = ED_object_modifier_add(NULL, bmain, scene, ob, OB_MODE_OBJECT, NULL, eModifierType_Armature);
+ ModifierData *md = ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Armature);
ArmatureModifierData *amd = (ArmatureModifierData *)md;
amd->object = ob_arm;
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 5cd1b48e80e..43fb83e205b 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -75,8 +75,6 @@ typedef enum eEvaluationMode {
DAG_EVAL_RENDER = 2, /* evaluate for render purposes */
} eEvaluationMode;
-#include "DNA_object_enums.h"
-
/* Dependency graph evaluation context
*
* This structure stores all the local dependency graph data,
@@ -85,7 +83,6 @@ typedef enum eEvaluationMode {
typedef struct EvaluationContext {
eEvaluationMode mode;
float ctime;
- eObjectMode object_mode;
struct Depsgraph *depsgraph;
struct ViewLayer *view_layer;
@@ -221,7 +218,6 @@ void DEG_evaluation_context_init_from_scene(
struct Scene *scene,
struct ViewLayer *view_layer,
struct RenderEngineType *engine_type,
- const eObjectMode object_mode,
eEvaluationMode mode);
void DEG_evaluation_context_init_from_view_layer_for_render(
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc
index d76eba29628..0b3e4fd8db9 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -84,7 +84,6 @@ void DEG_evaluation_context_init_from_scene(
Scene *scene,
ViewLayer *view_layer,
RenderEngineType *engine_type,
- eObjectMode object_mode,
eEvaluationMode mode)
{
DEG_evaluation_context_init(eval_ctx, mode);
@@ -92,7 +91,6 @@ void DEG_evaluation_context_init_from_scene(
eval_ctx->view_layer = view_layer;
eval_ctx->engine_type = engine_type;
eval_ctx->ctime = BKE_scene_frame_get(scene);
- eval_ctx->object_mode = object_mode;
}
void DEG_evaluation_context_init_from_view_layer_for_render(
@@ -107,7 +105,6 @@ void DEG_evaluation_context_init_from_view_layer_for_render(
DEG_evaluation_context_init(eval_ctx, DAG_EVAL_RENDER);
eval_ctx->ctime = BKE_scene_frame_get(scene);
- eval_ctx->object_mode = OB_MODE_OBJECT;
eval_ctx->depsgraph = depsgraph;
eval_ctx->view_layer = view_layer_original;
eval_ctx->engine_type = NULL;
@@ -121,7 +118,6 @@ void DEG_evaluation_context_init_from_depsgraph(
Scene *scene = DEG_get_evaluated_scene(depsgraph);
DEG_evaluation_context_init(eval_ctx, mode);
eval_ctx->ctime = (float)scene->r.cfra + scene->r.subframe;
- eval_ctx->object_mode = OB_MODE_OBJECT;
eval_ctx->depsgraph = depsgraph;
eval_ctx->view_layer = DEG_get_evaluated_view_layer(depsgraph);
eval_ctx->engine_type = NULL;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 6cbd6b62851..64f5caccb0c 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -437,9 +437,11 @@ void update_special_pointers(const Depsgraph *depsgraph,
* new copy of the object.
*/
Object *object_cow = (Object *)id_cow;
+ const Object *object_orig = (const Object *)id_orig;
(void) object_cow; /* Ignored for release builds. */
BLI_assert(object_cow->derivedFinal == NULL);
BLI_assert(object_cow->derivedDeform == NULL);
+ object_cow->mode = object_orig->mode;
break;
}
case ID_ME:
@@ -634,6 +636,7 @@ void update_copy_on_write_object(const Depsgraph * /*depsgraph*/,
extract_pose_from_pose(pose_cow, pose_orig);
/* Update object itself. */
BKE_object_transform_copy(object_cow, object_orig);
+ object_cow->mode = object_orig->mode;
}
/* Update copy-on-write version of datablock from it's original ID without re-building
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index e42b5a49d64..cf76bfdeef5 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -101,26 +101,26 @@ void DRW_draw_view(const struct bContext *C);
void DRW_draw_render_loop_ex(
struct Depsgraph *depsgraph,
struct RenderEngineType *engine_type,
- struct ARegion *ar, struct View3D *v3d, const eObjectMode object_mode,
+ struct ARegion *ar, struct View3D *v3d,
const struct bContext *evil_C);
void DRW_draw_render_loop(
struct Depsgraph *depsgraph,
- struct ARegion *ar, struct View3D *v3d, const eObjectMode object_mode);
+ struct ARegion *ar, struct View3D *v3d);
void DRW_draw_render_loop_offscreen(
struct Depsgraph *depsgraph,
struct RenderEngineType *engine_type,
- struct ARegion *ar, struct View3D *v3d, const eObjectMode object_mode,
+ struct ARegion *ar, struct View3D *v3d,
const bool draw_background,
struct GPUOffScreen *ofs,
struct GPUViewport *viewport);
void DRW_draw_select_loop(
struct Depsgraph *depsgraph,
- struct ARegion *ar, struct View3D *v3d, const eObjectMode object_mode,
+ struct ARegion *ar, struct View3D *v3d,
bool use_obedit_skip, bool use_nearest, const struct rcti *rect,
DRW_SelectPassFn select_pass_fn, void *select_pass_user_data);
void DRW_draw_depth_loop(
struct Depsgraph *depsgraph,
- struct ARegion *ar, struct View3D *v3d, const eObjectMode object_mode);
+ struct ARegion *ar, struct View3D *v3d);
/* This is here because GPUViewport needs it */
void DRW_pass_free(struct DRWPass *pass);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 96cd096ae27..15b0c793a50 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -358,13 +358,19 @@ static void drw_state_eval_ctx_init(DRWManager *dst)
draw_ctx->scene,
draw_ctx->view_layer,
draw_ctx->engine_type,
- draw_ctx->object_mode,
DST.options.is_scene_render ? DAG_EVAL_RENDER : DAG_EVAL_VIEWPORT);
}
/* Not a viewport variable, we could split this out. */
static void drw_context_state_init(void)
{
+ if (DST.draw_ctx.obact) {
+ DST.draw_ctx.object_mode = DST.draw_ctx.obact->mode;
+ }
+ else {
+ DST.draw_ctx.object_mode = OB_MODE_OBJECT;
+ }
+
/* Edit object. */
if (DST.draw_ctx.object_mode & OB_MODE_EDIT) {
DST.draw_ctx.object_edit = DST.draw_ctx.obact;
@@ -1125,7 +1131,7 @@ void DRW_draw_view(const bContext *C)
/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
- DRW_draw_render_loop_ex(eval_ctx.depsgraph, engine_type, ar, v3d, eval_ctx.object_mode, C);
+ DRW_draw_render_loop_ex(eval_ctx.depsgraph, engine_type, ar, v3d, C);
}
/**
@@ -1135,7 +1141,7 @@ void DRW_draw_view(const bContext *C)
void DRW_draw_render_loop_ex(
struct Depsgraph *depsgraph,
RenderEngineType *engine_type,
- ARegion *ar, View3D *v3d, const eObjectMode object_mode,
+ ARegion *ar, View3D *v3d,
const bContext *evil_C)
{
@@ -1155,7 +1161,7 @@ void DRW_draw_render_loop_ex(
.ar = ar, .rv3d = rv3d, .v3d = v3d,
.scene = scene, .view_layer = view_layer, .obact = OBACT(view_layer),
.engine_type = engine_type,
- .depsgraph = depsgraph, .object_mode = object_mode,
+ .depsgraph = depsgraph,
/* reuse if caller sets */
.evil_C = DST.draw_ctx.evil_C,
@@ -1280,7 +1286,7 @@ void DRW_draw_render_loop_ex(
void DRW_draw_render_loop(
struct Depsgraph *depsgraph,
- ARegion *ar, View3D *v3d, const eObjectMode object_mode)
+ ARegion *ar, View3D *v3d)
{
/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
@@ -1288,13 +1294,13 @@ void DRW_draw_render_loop(
Scene *scene = DEG_get_evaluated_scene(depsgraph);
RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
- DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, object_mode, NULL);
+ DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, NULL);
}
/* @viewport CAN be NULL, in this case we create one. */
void DRW_draw_render_loop_offscreen(
struct Depsgraph *depsgraph, RenderEngineType *engine_type,
- ARegion *ar, View3D *v3d, const eObjectMode object_mode,
+ ARegion *ar, View3D *v3d,
const bool draw_background, GPUOffScreen *ofs,
GPUViewport *viewport)
{
@@ -1318,7 +1324,7 @@ void DRW_draw_render_loop_offscreen(
drw_state_prepare_clean_for_draw(&DST);
DST.options.is_image_render = true;
DST.options.draw_background = draw_background;
- DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, object_mode, NULL);
+ DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, NULL);
/* restore */
{
@@ -1476,7 +1482,7 @@ void DRW_render_instance_buffer_finish(void)
*/
void DRW_draw_select_loop(
struct Depsgraph *depsgraph,
- ARegion *ar, View3D *v3d, const eObjectMode object_mode,
+ ARegion *ar, View3D *v3d,
bool UNUSED(use_obedit_skip), bool UNUSED(use_nearest), const rcti *rect,
DRW_SelectPassFn select_pass_fn, void *select_pass_user_data)
{
@@ -1484,6 +1490,7 @@ void DRW_draw_select_loop(
RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
Object *obact = OBACT(view_layer);
+ Object *obedit = OBEDIT_FROM_OBACT(obact);
#ifndef USE_GPU_SELECT
UNUSED_VARS(vc, scene, view_layer, v3d, ar, rect);
#else
@@ -1498,12 +1505,12 @@ void DRW_draw_select_loop(
bool use_obedit = false;
int obedit_mode = 0;
- if (object_mode & OB_MODE_EDIT) {
- if (obact->type == OB_MBALL) {
+ if (obedit != NULL) {
+ if (obedit->type == OB_MBALL) {
use_obedit = true;
obedit_mode = CTX_MODE_EDIT_METABALL;
}
- else if (obact->type == OB_ARMATURE) {
+ else if (obedit->type == OB_ARMATURE) {
use_obedit = true;
obedit_mode = CTX_MODE_EDIT_ARMATURE;
}
@@ -1533,7 +1540,7 @@ void DRW_draw_select_loop(
.ar = ar, .rv3d = rv3d, .v3d = v3d,
.scene = scene, .view_layer = view_layer, .obact = obact,
.engine_type = engine_type,
- .depsgraph = depsgraph, .object_mode = object_mode,
+ .depsgraph = depsgraph,
};
drw_context_state_init();
drw_viewport_var_init();
@@ -1662,7 +1669,7 @@ static void draw_depth_texture_to_screen(GPUTexture *texture)
*/
void DRW_draw_depth_loop(
Depsgraph *depsgraph,
- ARegion *ar, View3D *v3d, const eObjectMode object_mode)
+ ARegion *ar, View3D *v3d)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
@@ -1706,7 +1713,7 @@ void DRW_draw_depth_loop(
.ar = ar, .rv3d = rv3d, .v3d = v3d,
.scene = scene, .view_layer = view_layer, .obact = OBACT(view_layer),
.engine_type = engine_type,
- .depsgraph = depsgraph, .object_mode = object_mode,
+ .depsgraph = depsgraph,
};
drw_context_state_init();
drw_viewport_var_init();
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index f38a7689c06..c65ed55561e 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -625,7 +625,7 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie
}
/* exception: object in texture paint mode, clone brush, use_clone_layer disabled */
else if (draw_ctx->object_mode & OB_MODE_TEXTURE_PAINT) {
- const Paint *p = BKE_paint_get_active(scene, view_layer, draw_ctx->object_mode);
+ const Paint *p = BKE_paint_get_active(scene, view_layer);
if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) {
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 4ed5c49c1e3..126e4b5f736 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1579,9 +1579,6 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot)
static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
bool changed = false;
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
@@ -1598,7 +1595,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
fcn = fcu->next;
/* in pose mode, only delete the F-Curve if it belongs to a selected bone */
- if (eval_ctx.object_mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones[")) {
bPoseChannel *pchan;
char *bone_name;
@@ -1661,10 +1658,8 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
static int delete_key_v3d_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
- const float cfra = eval_ctx.ctime;
+ Scene *scene = CTX_data_scene(C);
+ float cfra = (float)CFRA;
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
@@ -1692,7 +1687,7 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
/* special exception for bones, as this makes this operator more convenient to use
* NOTE: This is only done in pose mode. In object mode, we're dealign with the entire object.
*/
- if ((eval_ctx.object_mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) {
+ if ((ob->mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) {
bPoseChannel *pchan;
char *bone_name;
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 8fc7aeaf029..de2611f7092 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -281,6 +281,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
/* get pose of active object and move it out of posemode */
pose = ob->pose;
+ ob->mode &= ~OB_MODE_POSE;
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
{
@@ -301,6 +302,8 @@ int join_armature_exec(bContext *C, wmOperator *op)
/* Get Pose of current armature */
opose = base->object->pose;
+ base->object->mode &= ~OB_MODE_POSE;
+ //BASACT->flag &= ~OB_MODE_POSE;
/* Find the difference matrix */
invert_m4_m4(oimat, ob->obmat);
@@ -605,6 +608,8 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
/* 1) store starting settings and exit editmode */
oldob = obedit;
oldbase = view_layer->basact;
+ oldob->mode &= ~OB_MODE_POSE;
+ //oldbase->flag &= ~OB_POSEMODE;
ED_armature_from_edit(obedit->data);
ED_armature_edit_free(obedit->data);
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index 8900da900c0..5c8e08a0d89 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -192,7 +192,6 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
}
static void envelope_bone_weighting(
- const EvaluationContext *eval_ctx,
Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist,
bDeformGroup **dgrouplist, bDeformGroup **dgroupflip,
float (*root)[3], float (*tip)[3], const int *selected, float scale)
@@ -206,7 +205,7 @@ static void envelope_bone_weighting(
bool use_topology = (mesh->editflag & ME_EDIT_MIRROR_TOPO) != 0;
bool use_mask = false;
- if ((eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) &&
+ if ((ob->mode & OB_MODE_WEIGHT_PAINT) &&
(mesh->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)))
{
use_mask = true;
@@ -277,12 +276,13 @@ static void add_verts_to_dgroups(
float (*root)[3], (*tip)[3], (*verts)[3];
int *selected;
int numbones, vertsfilled = 0, i, j, segments = 0;
+ const bool wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT);
struct { Object *armob; void *list; int heat; bool is_weight_paint; } looper_data;
looper_data.armob = par;
looper_data.heat = heat;
looper_data.list = NULL;
- looper_data.is_weight_paint = (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT);
+ looper_data.is_weight_paint = wpmode;
/* count the number of skinnable bones */
numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb);
@@ -355,7 +355,7 @@ static void add_verts_to_dgroups(
mul_m4_v3(par->obmat, tip[j]);
/* set selected */
- if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (wpmode) {
if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))
selected[j] = 1;
}
@@ -375,7 +375,7 @@ static void add_verts_to_dgroups(
mesh = (Mesh *)ob->data;
verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts");
- if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (wpmode) {
/* if in weight paint mode, use final verts from derivedmesh */
DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
@@ -406,7 +406,7 @@ static void add_verts_to_dgroups(
const char *error = NULL;
heat_bone_weighting(
- eval_ctx, ob, mesh, verts, numbones, dgrouplist, dgroupflip,
+ ob, mesh, verts, numbones, dgrouplist, dgroupflip,
root, tip, selected, &error);
if (error) {
BKE_report(reports, RPT_WARNING, error);
@@ -414,7 +414,7 @@ static void add_verts_to_dgroups(
}
else {
envelope_bone_weighting(
- eval_ctx, ob, mesh, verts, numbones, bonelist, dgrouplist,
+ ob, mesh, verts, numbones, bonelist, dgrouplist,
dgroupflip, root, tip, selected, mat4_to_scale(par->obmat));
}
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index d53350ab3cb..489940007e4 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -603,7 +603,6 @@ static float heat_limit_weight(float weight)
}
void heat_bone_weighting(
- const EvaluationContext *eval_ctx,
Object *ob, Mesh *me, float (*verts)[3], int numsource,
bDeformGroup **dgrouplist, bDeformGroup **dgroupflip,
float (*root)[3], float (*tip)[3], int *selected, const char **err_str)
@@ -627,7 +626,7 @@ void heat_bone_weighting(
tottri = poly_to_tri_count(me->totpoly, me->totloop);
/* count triangles and create mask */
- if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT &&
+ if (ob->mode & OB_MODE_WEIGHT_PAINT &&
(use_face_sel || use_vert_sel))
{
mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask");
diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h
index c790c2fbee7..05ade4fc43e 100644
--- a/source/blender/editors/armature/meshlaplacian.h
+++ b/source/blender/editors/armature/meshlaplacian.h
@@ -53,7 +53,6 @@ float laplacian_system_get_solution(LaplacianSystem *sys, int v);
/* Heat Weighting */
void heat_bone_weighting(
- const struct EvaluationContext *eval_ctx,
struct Object *ob, struct Mesh *me, float (*verts)[3],
int numbones, struct bDeformGroup **dgrouplist,
struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3],
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 3f2cf6f5853..15ffd09ebd4 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -94,16 +94,13 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
switch (ob->type) {
case OB_ARMATURE:
- {
- WorkSpace *workspace = CTX_wm_workspace(C);
- workspace->object_mode_restore = workspace->object_mode;
- workspace->object_mode |= OB_MODE_POSE;
+ ob->restore_mode = ob->mode;
+ ob->mode |= OB_MODE_POSE;
/* Inform all CoW versions that we changed the mode. */
DEG_id_tag_update_ex(CTX_data_main(C), &ob->id, DEG_TAG_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL);
break;
- }
default:
return;
}
@@ -115,11 +112,10 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
void ED_armature_exit_posemode(bContext *C, Base *base)
{
if (base) {
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = base->object;
- workspace->object_mode_restore = workspace->object_mode;
- workspace->object_mode &= ~OB_MODE_POSE;
+ ob->restore_mode = ob->mode;
+ ob->mode &= ~OB_MODE_POSE;
/* Inform all CoW versions that we changed the mode. */
DEG_id_tag_update_ex(CTX_data_main(C), &ob->id, DEG_TAG_COPY_ON_WRITE);
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 04e453c44c6..a66cedd8d4f 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -134,7 +134,6 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
/* called from editview.c, for mode-less pose selection */
/* assumes scene obact and basact is still on old situation */
bool ED_do_pose_selectbuffer(
- const EvaluationContext *eval_ctx,
ViewLayer *view_layer, Base *base, const unsigned int *buffer, short hits,
bool extend, bool deselect, bool toggle, bool do_nearest)
{
@@ -144,7 +143,7 @@ bool ED_do_pose_selectbuffer(
if (!ob || !ob->pose) return 0;
Object *ob_act = OBACT(view_layer);
- Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
nearBone = get_bone_from_selectbuffer(base, obedit, buffer, hits, 1, do_nearest);
@@ -157,7 +156,7 @@ bool ED_do_pose_selectbuffer(
* note, special exception for armature mode so we can do multi-select
* we could check for multi-select explicitly but think its fine to
* always give predictable behavior in weight paint mode - campbell */
- if ((ob_act == NULL) || ((ob_act != ob) && (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) == 0)) {
+ if ((ob_act == NULL) || ((ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0)) {
/* when we are entering into posemode via toggle-select,
* from another active object - always select the bone. */
if (!extend && !deselect && toggle) {
@@ -198,7 +197,7 @@ bool ED_do_pose_selectbuffer(
if (ob_act) {
/* in weightpaint we select the associated vertex group too */
- if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
if (nearBone == arm->act_bone) {
ED_vgroup_select_by_name(ob_act, nearBone->name);
DEG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
@@ -876,7 +875,6 @@ void POSE_OT_select_grouped(wmOperatorType *ot)
*/
static int pose_select_mirror_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob_act = CTX_data_active_object(C);
Object *ob = BKE_object_pose_armature_get(ob_act);
bArmature *arm;
@@ -884,6 +882,10 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op)
const bool active_only = RNA_boolean_get(op->ptr, "only_active");
const bool extend = RNA_boolean_get(op->ptr, "extend");
+ if ((ob && (ob->mode & OB_MODE_POSE)) == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
arm = ob->data;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -920,7 +922,7 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op)
arm->act_bone = pchan_mirror_act->bone;
/* in weightpaint we select the associated vertex group too */
- if (workspace->object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
ED_vgroup_select_by_name(ob_act, pchan_mirror_act->name);
DEG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
}
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 8d45c6af686..2c3c9f4f9b9 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1294,7 +1294,7 @@ static int gp_convert_poll(bContext *C)
bGPDframe *gpf = NULL;
ScrArea *sa = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
- const WorkSpace *workspace = CTX_wm_workspace(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
/* only if the current view is 3D View, if there's valid data (i.e. at least one stroke!),
* and if we are not in edit mode!
@@ -1303,7 +1303,7 @@ static int gp_convert_poll(bContext *C)
(gpl = BKE_gpencil_layer_getactive(gpd)) &&
(gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0)) &&
(gpf->strokes.first) &&
- ((workspace->object_mode & OB_MODE_EDIT) == 0));
+ (OBEDIT_FROM_VIEW_LAYER(view_layer) == NULL));
}
static int gp_convert_layer_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 0b1fb57af94..0181cc20cdc 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -143,7 +143,6 @@ void ED_armature_deselect_all(struct Object *obedit);
void ED_armature_deselect_all_visible(struct Object *obedit);
bool ED_do_pose_selectbuffer(
- const struct EvaluationContext *eval_ctx,
struct ViewLayer *view_layer, struct Base *base, const unsigned int *buffer, short hits,
bool extend, bool deselect, bool toggle, bool do_nearest);
bool ED_armature_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
@@ -190,8 +189,6 @@ void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone);
void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep);
void ED_armature_bones_flip_names(struct bArmature *arm, struct ListBase *bones_names, const bool do_strip_numbers);
-void undo_push_armature(struct bContext *C, const char *name);
-
/* low level selection functions which handle */
int ED_armature_ebone_selectflag_get(const EditBone *ebone);
void ED_armature_ebone_selectflag_set(EditBone *ebone, int flag);
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 9802f8c3c03..cb824b3c9b7 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -40,7 +40,6 @@ struct wmWindowManager;
struct ARegion;
struct Scene;
struct ViewLayer;
-struct WorkSpace;
/* image_edit.c, exported for transform */
struct Image *ED_space_image(struct SpaceImage *sima);
@@ -76,10 +75,7 @@ bool ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit);
bool ED_space_image_paint_curve(const struct bContext *C);
-bool ED_space_image_check_show_maskedit(
- struct SpaceImage *sima,
- const struct WorkSpace *workspace,
- struct ViewLayer *view_layer);
+bool ED_space_image_check_show_maskedit(struct SpaceImage *sima, struct ViewLayer *view_layer);
int ED_space_image_maskedit_poll(struct bContext *C);
int ED_space_image_maskedit_mask_poll(struct bContext *C);
diff --git a/source/blender/editors/include/ED_info.h b/source/blender/editors/include/ED_info.h
index 3d873906ecf..072b1a135a3 100644
--- a/source/blender/editors/include/ED_info.h
+++ b/source/blender/editors/include/ED_info.h
@@ -27,11 +27,8 @@
#ifndef __ED_INFO_H__
#define __ED_INFO_H__
-struct EvaluationContext;
-
/* info_stats.c */
void ED_info_stats_clear(struct ViewLayer *view_layer);
-const char *ED_info_stats_string(
- struct Scene *scene, struct WorkSpace *workspace, struct ViewLayer *view_layer);
+const char *ED_info_stats_string(struct Scene *scene, struct ViewLayer *view_layer);
#endif /* __ED_INFO_H__ */
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index b9723e3865e..3217433204e 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -36,7 +36,6 @@ extern "C" {
#endif
struct ID;
-struct EvaluationContext;
struct View3D;
struct ARegion;
struct bContext;
@@ -267,7 +266,6 @@ void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGrou
float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum);
void ED_vgroup_vert_active_mirror(struct Object *ob, int def_nr);
-
/* mesh_data.c */
// void ED_mesh_geometry_add(struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces);
void ED_mesh_polys_add(struct Mesh *mesh, struct ReportList *reports, int count);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 95adea7fbe2..ebd9313f7c5 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -52,13 +52,12 @@ struct wmKeyConfig;
struct wmKeyMap;
struct wmOperator;
struct wmOperatorType;
+struct wmWindow;
+struct wmWindowManager;
struct PointerRNA;
struct PropertyRNA;
struct EnumPropertyItem;
struct EvaluationContext;
-struct WorkSpace;
-struct wmWindow;
-struct wmWindowManager;
#include "DNA_object_enums.h"
@@ -126,7 +125,7 @@ void ED_object_parent(struct Object *ob, struct Object *parent, const int type,
#define EM_DO_UNDO 8
#define EM_IGNORE_LAYER 16
void ED_object_editmode_exit_ex(
- struct bContext *C, struct WorkSpace *workspace, struct Scene *scene, struct Object *obedit, int flag);
+ struct bContext *C, struct Scene *scene, struct Object *obedit, int flag);
void ED_object_editmode_exit(struct bContext *C, int flag);
void ED_object_editmode_enter(struct bContext *C, int flag);
bool ED_object_editmode_load(struct Object *obedit);
@@ -136,26 +135,26 @@ bool ED_object_editmode_calc_active_center(struct Object *obedit, const bool sel
void ED_object_vpaintmode_enter_ex(
const struct EvaluationContext *eval_ctx, struct wmWindowManager *wm,
- struct WorkSpace *workspace, struct Scene *scene, struct Object *ob);
+ struct Scene *scene, struct Object *ob);
void ED_object_vpaintmode_enter(struct bContext *C);
void ED_object_wpaintmode_enter_ex(
const struct EvaluationContext *eval_ctx, struct wmWindowManager *wm,
- struct WorkSpace *workspace, struct Scene *scene, struct Object *ob);
+ struct Scene *scene, struct Object *ob);
void ED_object_wpaintmode_enter(struct bContext *C);
-void ED_object_vpaintmode_exit_ex(struct WorkSpace *workspace, struct Object *ob);
+void ED_object_vpaintmode_exit_ex(struct Object *ob);
void ED_object_vpaintmode_exit(struct bContext *C);
-void ED_object_wpaintmode_exit_ex(struct WorkSpace *workspace, struct Object *ob);
+void ED_object_wpaintmode_exit_ex(struct Object *ob);
void ED_object_wpaintmode_exit(struct bContext *C);
void ED_object_sculptmode_enter_ex(
const struct EvaluationContext *eval_ctx,
- struct WorkSpace *workspace, struct Scene *scene, struct Object *ob,
+ struct Scene *scene, struct Object *ob,
struct ReportList *reports);
void ED_object_sculptmode_enter(struct bContext *C, struct ReportList *reports);
void ED_object_sculptmode_exit_ex(
const struct EvaluationContext *eval_ctx,
- struct WorkSpace *workspace, struct Scene *scene, struct Object *ob);
+ struct Scene *scene, struct Object *ob);
void ED_object_sculptmode_exit(struct bContext *C);
void ED_object_location_from_view(struct bContext *C, float loc[3]);
@@ -190,9 +189,9 @@ void ED_objects_clear_paths(struct bContext *C, bool only_selected);
void ED_objects_recalculate_paths(struct bContext *C, struct Scene *scene);
/* constraints */
-struct ListBase *get_active_constraints(const struct EvaluationContext *eval_ctx, struct Object *ob);
+struct ListBase *get_active_constraints(struct Object *ob);
struct ListBase *get_constraint_lb(struct Object *ob, struct bConstraint *con, struct bPoseChannel **r_pchan);
-struct bConstraint *get_active_constraint(const struct EvaluationContext *eval_ctx, struct Object *ob);
+struct bConstraint *get_active_constraint(struct Object *ob);
void object_test_constraints(struct Object *ob);
@@ -205,7 +204,7 @@ void ED_object_constraint_dependency_tag_update(struct Main *bmain, struct Objec
/* object_modes.c */
bool ED_object_mode_compat_test(const struct Object *ob, eObjectMode mode);
-bool ED_object_mode_compat_set(struct bContext *C, struct WorkSpace *workspace, eObjectMode mode, struct ReportList *reports);
+bool ED_object_mode_compat_set(struct bContext *C, struct Object *ob, eObjectMode mode, struct ReportList *reports);
void ED_object_mode_toggle(struct bContext *C, eObjectMode mode);
void ED_object_mode_set(struct bContext *C, eObjectMode mode);
@@ -214,18 +213,11 @@ bool ED_object_mode_generic_enter(
eObjectMode object_mode);
void ED_object_mode_generic_exit(
const struct EvaluationContext *eval_ctx,
- struct WorkSpace *workspace, struct Scene *scene, struct Object *ob);
+ struct Scene *scene, struct Object *ob);
bool ED_object_mode_generic_has_data(
const struct EvaluationContext *eval_ctx,
struct Object *ob);
-bool ED_object_mode_generic_enter_or_other_window(
- struct bContext *C, const struct wmWindow *win_compare,
- eObjectMode object_mode);
-void ED_object_mode_generic_exit_or_other_window(
- const struct EvaluationContext *eval_ctx, struct wmWindowManager *wm,
- struct WorkSpace *workspace, struct Scene *scene, struct Object *ob);
-
bool ED_object_mode_generic_exists(
struct wmWindowManager *wm, struct Object *ob,
eObjectMode object_mode);
@@ -236,30 +228,25 @@ enum {
MODIFIER_APPLY_SHAPE
};
-struct ModifierData *ED_object_modifier_add(
- struct ReportList *reports, struct Main *bmain, struct Scene *scene,
- struct Object *ob, eObjectMode object_mode, const char *name, int type);
+struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene,
+ struct Object *ob, const char *name, int type);
bool ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain,
struct Object *ob, struct ModifierData *md);
void ED_object_modifier_clear(struct Main *bmain, struct Object *ob);
int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
-int ED_object_modifier_convert(
- struct ReportList *reports, struct Main *bmain, struct Scene *scene,
- struct ViewLayer *view_layer, struct Object *ob, eObjectMode object_mode, struct ModifierData *md);
-int ED_object_modifier_apply(struct ReportList *reports, const struct bContext *C, struct Scene *scene,
+int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene,
+ struct ViewLayer *view_layer, struct Object *ob, struct ModifierData *md);
+int ED_object_modifier_apply(struct ReportList *reports, const struct EvaluationContext *eval_ctx, struct Scene *scene,
struct Object *ob, struct ModifierData *md, int mode);
int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
bool ED_object_iter_other(
- const struct EvaluationContext *eval_ctx, struct Main *bmain,
- struct Object *orig_ob, const bool include_orig,
- bool (*callback)(const struct EvaluationContext *eval_ctx, struct Object *ob, void *callback_data),
+ struct Main *bmain, struct Object *orig_ob, const bool include_orig,
+ bool (*callback)(struct Object *ob, void *callback_data),
void *callback_data);
-bool ED_object_multires_update_totlevels_cb(
- const struct EvaluationContext *eval_ctx,
- struct Object *ob, void *totlevel_v);
+bool ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v);
/* object_select.c */
void ED_object_select_linked_by_id(struct bContext *C, struct ID *id);
@@ -271,9 +258,7 @@ const struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper(
bool *r_free,
const unsigned int selection_mask);
-void ED_object_check_force_modifiers(
- struct Main *bmain, struct Scene *scene,
- struct Object *object, eObjectMode object_mode);
+void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object);
/* object_facemap_ops.c */
void ED_object_facemap_face_add(struct Object *ob, struct bFaceMap *fmap, int facenum);
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 1f78a5292a7..4720eb05367 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -162,7 +162,7 @@ struct WorkSpace *ED_workspace_add(
bool ED_workspace_change(
struct WorkSpace *workspace_new,
struct bContext *C,
- struct wmWindow *win) ATTR_NONNULL();
+ struct wmWindowManager *wm, struct wmWindow *win) ATTR_NONNULL();
struct WorkSpace *ED_workspace_duplicate(
struct WorkSpace *workspace_old,
struct Main *bmain, struct wmWindow *win);
@@ -194,10 +194,6 @@ void ED_workspace_object_mode_sync_from_object(
void ED_workspace_object_mode_sync_from_scene(
struct wmWindowManager *wm, WorkSpace *workspace, struct Scene *scene);
-bool ED_workspace_object_mode_in_other_window(
- struct wmWindowManager *wm, const struct wmWindow *win_compare, struct Object *obact,
- eObjectMode *r_object_mode);
-
/* anim */
void ED_update_for_newframe(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, struct Depsgraph *depsgraph);
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 15de57da09c..2a5ad494643 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -131,7 +131,7 @@ void ED_unwrap_lscm(struct Scene *scene, struct Object *obedit, const short sel)
void ED_image_draw_cursor(
struct ARegion *ar, const float cursor[2]);
void ED_uvedit_draw_main(
- struct SpaceImage *sima, const struct EvaluationContext *eval_ctx,
+ struct SpaceImage *sima,
struct ARegion *ar, struct Scene *scene, struct ViewLayer *view_layer,
struct Object *obedit, struct Object *obact, struct Depsgraph *depsgraph);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index e01121ed277..b95bf466186 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -46,7 +46,6 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
-#include "DNA_workspace_types.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
@@ -74,8 +73,6 @@
#include "BKE_unit.h"
#include "BKE_paint.h"
-#include "DEG_depsgraph.h"
-
#include "ED_screen.h"
#include "ED_undo.h"
#include "ED_keyframing.h"
@@ -5234,10 +5231,9 @@ static int ui_do_but_COLOR(
if ((int)(but->a1) == UI_PALETTE_COLOR) {
if (!event->ctrl) {
float color[3];
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Paint *paint = BKE_paint_get_active(scene, view_layer, workspace->object_mode);
+ Paint *paint = BKE_paint_get_active(scene, view_layer);
Brush *brush = BKE_paint_brush(paint);
if (brush->flag & BRUSH_USE_GRADIENT) {
@@ -6153,7 +6149,6 @@ static int ui_do_but_CURVE(
{
int mx, my, a;
bool changed = false;
-
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -6270,7 +6265,6 @@ static int ui_do_but_CURVE(
}
else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
if (data->dragsel != -1) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
CurveMapping *cumap = (CurveMapping *)but->poin;
CurveMap *cuma = cumap->cm + cumap->cur;
CurveMapPoint *cmp = cuma->curve;
@@ -6285,7 +6279,7 @@ static int ui_do_but_CURVE(
}
else {
curvemapping_changed(cumap, true); /* remove doubles */
- BKE_paint_invalidate_cursor_overlay(scene, view_layer, cumap, workspace->object_mode);
+ BKE_paint_invalidate_cursor_overlay(scene, view_layer, cumap);
}
}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index bcc6c40a9e7..9fbb5efdcf3 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1289,7 +1289,6 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
ui_id_icon_render(C, id, true);
}
else {
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
SpaceImage *sima;
const EnumPropertyItem *items = NULL;
@@ -1300,11 +1299,11 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
* checking various context stuff here */
if (CTX_wm_view3d(C) && ob) {
- if (workspace->object_mode & OB_MODE_SCULPT)
+ if (ob->mode & OB_MODE_SCULPT)
mode = OB_MODE_SCULPT;
- else if (workspace->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
+ else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
mode = OB_MODE_VERTEX_PAINT;
- else if (workspace->object_mode & OB_MODE_TEXTURE_PAINT)
+ else if (ob->mode & OB_MODE_TEXTURE_PAINT)
mode = OB_MODE_TEXTURE_PAINT;
}
else if ((sima = CTX_wm_space_image(C)) &&
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index af14c57fade..375027a84d0 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -575,9 +575,6 @@ static void template_ID(
bContext *C, uiLayout *layout, TemplateID *template_ui, StructRNA *type, int flag,
const char *newop, const char *openop, const char *unlinkop)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
uiBut *but;
uiBlock *block;
PointerRNA idptr;
@@ -662,7 +659,7 @@ static void template_ID(
(idfrom && idfrom->lib) ||
(!editable) ||
/* object in editmode - don't change data */
- (idfrom && GS(idfrom->name) == ID_OB && (eval_ctx.object_mode & OB_MODE_EDIT)))
+ (idfrom && GS(idfrom->name) == ID_OB && (((Object *)idfrom)->mode & OB_MODE_EDIT)))
{
UI_but_flag_enable(but, UI_BUT_DISABLED);
}
@@ -1210,8 +1207,7 @@ static int modifier_is_simulation(ModifierData *md)
}
static uiLayout *draw_modifier(
- uiLayout *layout,
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ uiLayout *layout, Scene *scene, Object *ob,
ModifierData *md, int index, int cageIndex, int lastCageIndex)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1348,7 +1344,7 @@ static uiLayout *draw_modifier(
if (md->type == eModifierType_ParticleSystem) {
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
- if (!(eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) {
+ if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
uiItemO(row, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
"OBJECT_OT_duplicates_make_real");
@@ -1397,8 +1393,6 @@ static uiLayout *draw_modifier(
uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
Object *ob;
ModifierData *md, *vmd;
@@ -1429,7 +1423,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
for (i = 0; vmd; i++, vmd = vmd->next) {
if (md == vmd)
- return draw_modifier(layout, &eval_ctx, scene, ob, md, i, cageIndex, lastCageIndex);
+ return draw_modifier(layout, scene, ob, md, i, cageIndex, lastCageIndex);
else if (vmd->mode & eModifierMode_Virtual)
i--;
}
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 40a64435cf3..87937fd4146 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -295,7 +295,7 @@ bool EDBM_backbuf_border_mask_init(const struct EvaluationContext *eval_ctx, Vie
/* method in use for face selecting too */
if (vc->obedit == NULL) {
- if (!BKE_paint_select_elem_test(vc->obact, eval_ctx->object_mode)) {
+ if (!BKE_paint_select_elem_test(vc->obact)) {
return false;
}
}
@@ -347,7 +347,7 @@ bool EDBM_backbuf_circle_init(
/* method in use for face selecting too */
if (vc->obedit == NULL) {
- if (!BKE_paint_select_elem_test(vc->obact, eval_ctx->object_mode)) {
+ if (!BKE_paint_select_elem_test(vc->obact)) {
return false;
}
}
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index aca67dc84e9..69e265f7315 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -506,14 +506,13 @@ static int layers_poll(bContext *C)
static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
if (ED_mesh_uv_texture_add(me, NULL, true) == -1)
return OPERATOR_CANCELLED;
- if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) {
+ if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
@@ -623,14 +622,13 @@ void MESH_OT_drop_named_image(wmOperatorType *ot)
static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
if (!ED_mesh_uv_texture_remove_active(me))
return OPERATOR_CANCELLED;
- if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) {
+ if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
@@ -744,14 +742,13 @@ static int mesh_customdata_mask_clear_poll(bContext *C)
{
Object *ob = ED_object_context(C);
if (ob && ob->type == OB_MESH) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
+ Mesh *me = ob->data;
/* special case - can't run this if we're in sculpt mode */
- if (workspace->object_mode & OB_MODE_SCULPT) {
+ if (ob->mode & OB_MODE_SCULPT) {
return false;
}
- Mesh *me = ob->data;
if (!ID_IS_LINKED(me)) {
CustomData *data = GET_CD_DATA(me, vdata);
if (CustomData_has_layer(data, CD_PAINT_MASK)) {
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
index aaa06951ec6..bd2ad21d51c 100644
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ b/source/blender/editors/mesh/mesh_navmesh.c
@@ -662,10 +662,8 @@ void MESH_OT_navmesh_face_add(struct wmOperatorType *ot)
static int navmesh_obmode_data_poll(bContext *C)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- if (ob && (eval_ctx.object_mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
+ if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
Mesh *me = ob->data;
return CustomData_has_layer(&me->pdata, CD_RECAST);
}
@@ -674,10 +672,8 @@ static int navmesh_obmode_data_poll(bContext *C)
static int navmesh_obmode_poll(bContext *C)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- if (ob && (eval_ctx.object_mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
+ if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
return true;
}
return false;
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index fd5beac9cc6..531a26a66a8 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -79,7 +79,7 @@
* return 0 if no join is made (error) and 1 if the join is done */
static void join_mesh_single(
- bContext *C, Main *bmain, Scene *scene,
+ const EvaluationContext *eval_ctx, Main *bmain, Scene *scene,
Object *ob_dst, Object *ob_src, float imat[4][4],
MVert **mvert_pp, MEdge **medge_pp, MLoop **mloop_pp, MPoly **mpoly_pp,
CustomData *vdata, CustomData *edata, CustomData *ldata, CustomData *pdata,
@@ -88,7 +88,6 @@ static void join_mesh_single(
Material **matar, int *matmap, int totcol,
int *vertofs, int *edgeofs, int *loopofs, int *polyofs)
{
- EvaluationContext eval_ctx;
int a, b;
Mesh *me = ob_src->data;
@@ -97,8 +96,6 @@ static void join_mesh_single(
MLoop *mloop = *mloop_pp;
MPoly *mpoly = *mpoly_pp;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (me->totvert) {
/* merge customdata flag */
((Mesh *)ob_dst->data)->cd_flag |= me->cd_flag;
@@ -210,13 +207,12 @@ static void join_mesh_single(
if (ob_src != ob_dst) {
MultiresModifierData *mmd;
- multiresModifier_prepare_join(&eval_ctx, scene, ob_src, ob_dst);
+ multiresModifier_prepare_join(eval_ctx, scene, ob_src, ob_dst);
if ((mmd = get_multires_modifier(scene, ob_src, true))) {
- ED_object_iter_other(
- &eval_ctx, bmain, ob_src, true,
- ED_object_multires_update_totlevels_cb,
- &mmd->totlvl);
+ ED_object_iter_other(bmain, ob_src, true,
+ ED_object_multires_update_totlevels_cb,
+ &mmd->totlvl);
}
}
@@ -266,7 +262,6 @@ static void join_mesh_single(
int join_mesh_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
@@ -286,7 +281,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
bDeformGroup *dg, *odg;
CustomData vdata, edata, fdata, ldata, pdata;
- if (workspace->object_mode & OB_MODE_EDIT) {
+ if (ob->mode & OB_MODE_EDIT) {
BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode");
return OPERATOR_CANCELLED;
}
@@ -296,7 +291,10 @@ int join_mesh_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "Active object is not a mesh");
return OPERATOR_CANCELLED;
}
-
+
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* count & check */
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
@@ -491,7 +489,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
* active mesh will remain first ones in new result of the merge, in same order for CD layers, etc. See also T50084.
*/
join_mesh_single(
- C, bmain, scene,
+ &eval_ctx, bmain, scene,
ob, ob, imat,
&mvert, &medge, &mloop, &mpoly,
&vdata, &edata, &ldata, &pdata,
@@ -508,7 +506,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* only join if this is a mesh */
if (base->object->type == OB_MESH) {
join_mesh_single(
- C, bmain, scene,
+ &eval_ctx, bmain, scene,
ob, base->object, imat,
&mvert, &medge, &mloop, &mpoly,
&vdata, &edata, &ldata, &pdata,
@@ -1253,17 +1251,17 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve)
{
- if (ob->type == OB_MESH && ob->defbase.first) {
+ if (ob->mode & OB_MODE_EDIT && ob->type == OB_MESH && ob->defbase.first) {
Mesh *me = ob->data;
- if (me->edit_btmesh != NULL) {
- BMesh *bm = me->edit_btmesh->bm;
- const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
- if (cd_dvert_offset != -1) {
- BMVert *eve = BM_mesh_active_vert_get(bm);
- if (eve) {
- if (r_eve) *r_eve = eve;
- return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
- }
+ BMesh *bm = me->edit_btmesh->bm;
+ const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
+
+ if (cd_dvert_offset != -1) {
+ BMVert *eve = BM_mesh_active_vert_get(bm);
+
+ if (eve) {
+ if (r_eve) *r_eve = eve;
+ return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
}
}
}
@@ -1288,8 +1286,7 @@ MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index)
MDeformVert *ED_mesh_active_dvert_get_only(Object *ob)
{
if (ob->type == OB_MESH) {
- Mesh *me = ob->data;
- if (me->edit_btmesh != NULL) {
+ if (ob->mode & OB_MODE_EDIT) {
return ED_mesh_active_dvert_get_em(ob, NULL);
}
else {
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 96a5a95a5cd..bfeb48f9308 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2081,9 +2081,7 @@ void OBJECT_OT_convert(wmOperatorType *ot)
/* used below, assumes id.new is correct */
/* leaves selection of base/object unaltered */
/* Does set ID->newid pointers. */
-static Base *object_add_duplicate_internal(
- Main *bmain, Scene *scene,
- ViewLayer *view_layer, Object *ob, int dupflag)
+static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer *view_layer, Object *ob, int dupflag)
{
#define ID_NEW_REMAP_US(a) if ( (a)->id.newid) { (a) = (void *)(a)->id.newid; (a)->id.us++; }
#define ID_NEW_REMAP_US2(a) if (((ID *)a)->newid) { (a) = ((ID *)a)->newid; ((ID *)a)->us++; }
@@ -2094,14 +2092,10 @@ static Base *object_add_duplicate_internal(
ID *id;
int a, didit;
- /* ignore pose mode now, Caller can inspect mode. */
-#if 0
- if (eval_ctx->object_mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
; /* nothing? */
}
- else
-#endif
- {
+ else {
obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob));
DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
@@ -2529,10 +2523,9 @@ static int join_poll(bContext *C)
static int join_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- if (workspace->object_mode & OB_MODE_EDIT) {
+ if (ob->mode & OB_MODE_EDIT) {
BKE_report(op->reports, RPT_ERROR, "This data does not support joining in edit mode");
return OPERATOR_CANCELLED;
}
@@ -2583,10 +2576,9 @@ static int join_shapes_poll(bContext *C)
static int join_shapes_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- if (workspace->object_mode & OB_MODE_EDIT) {
+ if (ob->mode & OB_MODE_EDIT) {
BKE_report(op->reports, RPT_ERROR, "This data does not support joining in edit mode");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index e23329a7a68..a38b9959dab 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -206,8 +206,7 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
return ok;
}
-static DerivedMesh *multiresbake_create_loresdm(
- Scene *scene, Object *ob, eObjectMode object_mode, int *lvl)
+static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *lvl)
{
DerivedMesh *dm;
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
@@ -227,15 +226,13 @@ static DerivedMesh *multiresbake_create_loresdm(
tmp_mmd.lvl = *lvl;
tmp_mmd.sculptlvl = *lvl;
- dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0, object_mode);
+ dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0);
cddm->release(cddm);
return dm;
}
-static DerivedMesh *multiresbake_create_hiresdm(
- Scene *scene, Object *ob, eObjectMode object_mode,
- int *lvl, bool *simple)
+static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *lvl, bool *simple)
{
Mesh *me = (Mesh *)ob->data;
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
@@ -256,7 +253,7 @@ static DerivedMesh *multiresbake_create_hiresdm(
tmp_mmd.lvl = mmd->totlvl;
tmp_mmd.sculptlvl = mmd->totlvl;
- dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0, object_mode);
+ dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0);
cddm->release(cddm);
return dm;
@@ -320,7 +317,6 @@ static void clear_images_poly(Image **ob_image_array, int ob_image_array_len, Cl
static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
{
Object *ob;
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
int objects_baked = 0;
@@ -375,8 +371,8 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
bkr.ob_image.array = BKE_object_material_edit_image_get_array(ob);
bkr.ob_image.len = ob->totcol;
- bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, workspace->object_mode, &bkr.tot_lvl, &bkr.simple);
- bkr.lores_dm = multiresbake_create_loresdm(scene, ob, workspace->object_mode, &bkr.lvl);
+ bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple);
+ bkr.lores_dm = multiresbake_create_loresdm(scene, ob, &bkr.lvl);
RE_multires_bake_images(&bkr);
@@ -400,7 +396,6 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
/* Multiresbake adopted for job-system executing */
static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *ob;
@@ -432,8 +427,8 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
data->ob_image.len = ob->totcol;
/* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */
- data->hires_dm = multiresbake_create_hiresdm(scene, ob, workspace->object_mode, &data->tot_lvl, &data->simple);
- data->lores_dm = multiresbake_create_loresdm(scene, ob, workspace->object_mode, &lvl);
+ data->hires_dm = multiresbake_create_hiresdm(scene, ob, &data->tot_lvl, &data->simple);
+ data->lores_dm = multiresbake_create_loresdm(scene, ob, &lvl);
data->lvl = lvl;
BLI_addtail(&bkj->data, data);
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index acf3f73c9c6..0fde6f643a8 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -866,7 +866,7 @@ static int bake(
/* triangulating so BVH returns the primitive_id that will be used for rendering */
highpoly[i].tri_mod = ED_object_modifier_add(
- reports, bmain, scene, highpoly[i].ob, OB_MODE_OBJECT,
+ reports, bmain, scene, highpoly[i].ob,
"TmpTriangulate", eModifierType_Triangulate);
tmd = (TriangulateModifierData *)highpoly[i].tri_mod;
tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 1b462e92ca4..1a20a8db5b3 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -87,12 +87,12 @@
/* -------------- Get Active Constraint Data ---------------------- */
/* if object in posemode, active bone constraints, else object constraints */
-ListBase *get_active_constraints(const EvaluationContext *eval_ctx, Object *ob)
+ListBase *get_active_constraints(Object *ob)
{
if (ob == NULL)
return NULL;
- if (eval_ctx->object_mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan;
pchan = BKE_pose_channel_active(ob);
@@ -142,9 +142,9 @@ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan
}
/* single constraint */
-bConstraint *get_active_constraint(const EvaluationContext *eval_ctx, Object *ob)
+bConstraint *get_active_constraint(Object *ob)
{
- return BKE_constraints_active_get(get_active_constraints(eval_ctx, ob));
+ return BKE_constraints_active_get(get_active_constraints(ob));
}
/* -------------- Constraint Management (Add New, Remove, Rename) -------------------- */
@@ -639,8 +639,7 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op)
return 0;
}
-static bConstraint *edit_constraint_property_get(
- const EvaluationContext *eval_ctx, wmOperator *op, Object *ob, int type)
+static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int type)
{
char constraint_name[MAX_NAME];
int owner = RNA_enum_get(op->ptr, "owner");
@@ -665,7 +664,7 @@ static bConstraint *edit_constraint_property_get(
else {
//if (G.debug & G_DEBUG)
//printf("edit_constraint_property_get: defaulting to getting list in the standard way\n");
- list = get_active_constraints(eval_ctx, ob);
+ list = get_active_constraints(ob);
}
con = BKE_constraints_find_name(list, constraint_name);
@@ -688,7 +687,7 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op)
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- bConstraint *con = edit_constraint_property_get(&eval_ctx, op, ob, CONSTRAINT_TYPE_STRETCHTO);
+ bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_STRETCHTO);
bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL;
/* despite 3 layers of checks, we may still not be able to find a constraint */
@@ -736,7 +735,7 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op)
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- bConstraint *con = edit_constraint_property_get(&eval_ctx, op, ob, CONSTRAINT_TYPE_DISTLIMIT);
+ bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_DISTLIMIT);
bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL;
/* despite 3 layers of checks, we may still not be able to find a constraint */
@@ -875,7 +874,7 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op)
CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
- bConstraint *con = edit_constraint_property_get(&eval_ctx, op, ob, CONSTRAINT_TYPE_CHILDOF);
+ bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF);
bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL;
const int owner = RNA_enum_get(op->ptr, "owner");
@@ -926,7 +925,7 @@ static int childof_clear_inverse_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
- bConstraint *con = edit_constraint_property_get(&eval_ctx, op, ob, CONSTRAINT_TYPE_CHILDOF);
+ bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF);
bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL;
if (data == NULL) {
@@ -976,7 +975,7 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op)
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- bConstraint *con = edit_constraint_property_get(&eval_ctx, op, ob, CONSTRAINT_TYPE_FOLLOWPATH);
+ bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_FOLLOWPATH);
bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : NULL;
bAction *act = NULL;
@@ -1103,7 +1102,7 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op)
CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
- bConstraint *con = edit_constraint_property_get(&eval_ctx, op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
+ bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL;
const int owner = RNA_enum_get(op->ptr, "owner");
@@ -1153,7 +1152,7 @@ static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op)
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- bConstraint *con = edit_constraint_property_get(&eval_ctx, op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
+ bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL;
if (data == NULL) {
@@ -1324,7 +1323,7 @@ static int constraint_move_down_exec(bContext *C, wmOperator *op)
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- bConstraint *con = edit_constraint_property_get(&eval_ctx, op, ob, 0);
+ bConstraint *con = edit_constraint_property_get(op, ob, 0);
if (con && con->next) {
ListBase *conlist = get_constraint_lb(ob, con, NULL);
@@ -1375,7 +1374,7 @@ static int constraint_move_up_exec(bContext *C, wmOperator *op)
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- bConstraint *con = edit_constraint_property_get(&eval_ctx, op, ob, 0);
+ bConstraint *con = edit_constraint_property_get(op, ob, 0);
if (con && con->prev) {
ListBase *conlist = get_constraint_lb(ob, con, NULL);
@@ -1892,8 +1891,6 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op)
/* dummy operator callback */
static int pose_constraint_add_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = BKE_object_pose_armature_get(ED_object_active_context(C));
int type = RNA_enum_get(op->ptr, "type");
short with_targets = 0;
@@ -1909,7 +1906,7 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op)
if (strstr(op->idname, "with_targets"))
with_targets = 1;
- return constraint_add_exec(C, op, ob, get_active_constraints(&eval_ctx, ob), type, with_targets);
+ return constraint_add_exec(C, op, ob, get_active_constraints(ob), type, with_targets);
}
/* ------------------ */
@@ -2050,13 +2047,11 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
/* call constraint_add_exec() to add the IK constraint */
static int pose_ik_add_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = CTX_data_active_object(C);
const bool with_targets = RNA_boolean_get(op->ptr, "with_targets");
/* add the constraint - all necessary checks should have been done by the invoke() callback already... */
- return constraint_add_exec(C, op, ob, get_active_constraints(&eval_ctx, ob), CONSTRAINT_TYPE_KINEMATIC, with_targets);
+ return constraint_add_exec(C, op, ob, get_active_constraints(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets);
}
void POSE_OT_ik_add(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 0506225769c..9306213581e 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -274,9 +274,12 @@ bool ED_object_editmode_load(Object *obedit)
* - Only in exceptional cases should #EM_DO_UNDO NOT be in the flag.
* - If #EM_FREEDATA isn't in the flag, use ED_object_editmode_load directly.
*/
-void ED_object_editmode_exit_ex(bContext *C, WorkSpace *workspace, Scene *scene, Object *obedit, int flag)
+void ED_object_editmode_exit_ex(bContext *C, Scene *scene, Object *obedit, int flag)
{
BLI_assert(C || !(flag & EM_DO_UNDO));
+ /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */
+ /* Note! if 'EM_FREEDATA' isn't in the flag, use ED_object_editmode_load directly */
+ ViewLayer *view_layer = CTX_data_view_layer(C);
const bool freedata = (flag & EM_FREEDATA) != 0;
if (flag & EM_WAITCURSOR) waitcursor(1);
@@ -284,7 +287,9 @@ void ED_object_editmode_exit_ex(bContext *C, WorkSpace *workspace, Scene *scene,
if (ED_object_editmode_load_ex(G.main, obedit, freedata) == false) {
/* in rare cases (background mode) its possible active object
* is flagged for editmode, without 'obedit' being set [#35489] */
- workspace->object_mode &= ~OB_MODE_EDIT;
+ if (UNLIKELY(view_layer->basact && (view_layer->basact->object->mode & OB_MODE_EDIT))) {
+ view_layer->basact->object->mode &= ~OB_MODE_EDIT;
+ }
if (flag & EM_WAITCURSOR) waitcursor(0);
return;
}
@@ -306,21 +311,14 @@ void ED_object_editmode_exit_ex(bContext *C, WorkSpace *workspace, Scene *scene,
/* also flush ob recalc, doesn't take much overhead, but used for particles */
DEG_id_tag_update(&obedit->id, OB_RECALC_OB | OB_RECALC_DATA);
-
- workspace->object_mode &= ~OB_MODE_EDIT;
if (flag & EM_DO_UNDO)
ED_undo_push(C, "Editmode");
- if (C != NULL) {
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
- }
- else {
- WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
- }
- }
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
- ED_workspace_object_mode_sync_from_object(G.main->wm.first, workspace, obedit);
+ obedit->mode &= ~OB_MODE_EDIT;
+ }
if (flag & EM_WAITCURSOR) waitcursor(0);
@@ -330,15 +328,13 @@ void ED_object_editmode_exit_ex(bContext *C, WorkSpace *workspace, Scene *scene,
void ED_object_editmode_exit(bContext *C, int flag)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
- ED_object_editmode_exit_ex(C, workspace, scene, obedit, flag);
+ ED_object_editmode_exit_ex(C, scene, obedit, flag);
}
void ED_object_editmode_enter(bContext *C, int flag)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob;
@@ -368,14 +364,14 @@ void ED_object_editmode_enter(bContext *C, int flag)
if (flag & EM_WAITCURSOR) waitcursor(1);
- workspace->object_mode_restore = workspace->object_mode;
+ ob->restore_mode = ob->mode;
/* note, when switching scenes the object can have editmode data but
* not be scene->obedit: bug 22954, this avoids calling self eternally */
- if ((workspace->object_mode_restore & OB_MODE_EDIT) == 0)
- ED_object_mode_toggle(C, workspace->object_mode);
+ if ((ob->restore_mode & OB_MODE_EDIT) == 0)
+ ED_object_mode_toggle(C, ob->mode);
- workspace->object_mode = OB_MODE_EDIT;
+ ob->mode = OB_MODE_EDIT;
if (ob->type == OB_MESH) {
BMEditMesh *em;
@@ -446,25 +442,23 @@ void ED_object_editmode_enter(bContext *C, int flag)
DEG_id_tag_update(&scene->id, 0);
}
else {
- workspace->object_mode &= ~OB_MODE_EDIT;
+ ob->mode &= ~OB_MODE_EDIT;
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
}
- ED_workspace_object_mode_sync_from_object(G.main->wm.first, workspace, ob);
-
if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode");
if (flag & EM_WAITCURSOR) waitcursor(0);
}
static int editmode_toggle_exec(bContext *C, wmOperator *op)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
const int mode_flag = OB_MODE_EDIT;
const bool is_mode_set = (CTX_data_edit_object(C) != NULL);
Scene *scene = CTX_data_scene(C);
if (!is_mode_set) {
- if (!ED_object_mode_compat_set(C, workspace, mode_flag, op->reports)) {
+ Object *ob = CTX_data_active_object(C);
+ if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
}
}
@@ -487,10 +481,8 @@ static int editmode_toggle_poll(bContext *C)
if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob->data))
return 0;
- const WorkSpace *workspace = CTX_wm_workspace(C);
-
/* if hidden but in edit mode, we still display */
- if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(workspace->object_mode & OB_MODE_EDIT)) {
+ if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT)) {
return 0;
}
@@ -517,15 +509,13 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot)
static int posemode_exec(bContext *C, wmOperator *op)
{
- wmWindowManager *wm = CTX_wm_manager(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
Base *base = CTX_data_active_base(C);
Object *ob = base->object;
const int mode_flag = OB_MODE_POSE;
- const bool is_mode_set = (workspace->object_mode & mode_flag) != 0;
-
+ const bool is_mode_set = (ob->mode & mode_flag) != 0;
+
if (!is_mode_set) {
- if (!ED_object_mode_compat_set(C, workspace, mode_flag, op->reports)) {
+ if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
}
}
@@ -540,8 +530,6 @@ static int posemode_exec(bContext *C, wmOperator *op)
else
ED_armature_enter_posemode(C, base);
- ED_workspace_object_mode_sync_from_object(wm, workspace, ob);
-
return OPERATOR_FINISHED;
}
@@ -1020,7 +1008,7 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLaye
/* ******************* force field toggle operator ***************** */
-void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object, eObjectMode object_mode)
+void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object)
{
PartDeflect *pd = object->pd;
ModifierData *md = modifiers_findByType(object, eModifierType_Surface);
@@ -1029,7 +1017,7 @@ void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object,
if (!md) {
if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) && !ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) {
if (ELEM(object->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE)) {
- ED_object_modifier_add(NULL, bmain, scene, object, object_mode, NULL, eModifierType_Surface);
+ ED_object_modifier_add(NULL, bmain, scene, object, NULL, eModifierType_Surface);
}
}
}
@@ -1051,8 +1039,7 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
else
ob->pd->forcefield = 0;
- const WorkSpace *workspace = CTX_wm_workspace(C);
- ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob, workspace->object_mode);
+ ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1513,11 +1500,10 @@ static int object_mode_set_poll(bContext *C)
static int object_mode_set_exec(bContext *C, wmOperator *op)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
eObjectMode mode = RNA_enum_get(op->ptr, "mode");
- eObjectMode restore_mode = workspace->object_mode;
+ eObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT;
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
if (gpd) {
@@ -1541,31 +1527,28 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
if (!ob || !ED_object_mode_compat_test(ob, mode))
return OPERATOR_PASS_THROUGH;
- if (workspace->object_mode != mode) {
+ if (ob->mode != mode) {
/* we should be able to remove this call, each operator calls */
- ED_object_mode_compat_set(C, workspace, mode, op->reports);
+ ED_object_mode_compat_set(C, ob, mode, op->reports);
}
/* Exit current mode if it's not the mode we're setting */
- if (mode != OB_MODE_OBJECT && (workspace->object_mode != mode || toggle)) {
+ if (mode != OB_MODE_OBJECT && (ob->mode != mode || toggle)) {
/* Enter new mode */
ED_object_mode_toggle(C, mode);
}
if (toggle) {
/* Special case for Object mode! */
- if ((mode == OB_MODE_OBJECT) &&
- (restore_mode == OB_MODE_OBJECT) &&
- (workspace->object_mode_restore != OB_MODE_OBJECT))
- {
- ED_object_mode_toggle(C, workspace->object_mode_restore);
+ if (mode == OB_MODE_OBJECT && restore_mode == OB_MODE_OBJECT && ob->restore_mode != OB_MODE_OBJECT) {
+ ED_object_mode_toggle(C, ob->restore_mode);
}
- else if (workspace->object_mode == mode) {
+ else if (ob->mode == mode) {
/* For toggling, store old mode so we know what to go back to */
- workspace->object_mode_restore = restore_mode;
+ ob->restore_mode = restore_mode;
}
- else if (!ELEM(workspace->object_mode_restore, mode, OB_MODE_OBJECT)) {
- ED_object_mode_toggle(C, workspace->object_mode_restore);
+ else if (ob->restore_mode != OB_MODE_OBJECT && ob->restore_mode != mode) {
+ ED_object_mode_toggle(C, ob->restore_mode);
}
}
diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c
index c865b45889a..a076521b41d 100644
--- a/source/blender/editors/object/object_facemap_ops.c
+++ b/source/blender/editors/object/object_facemap_ops.c
@@ -175,8 +175,7 @@ static int face_map_supported_edit_mode_poll(bContext *C)
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
if (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->object_mode == OB_MODE_EDIT) {
+ if (ob->mode == OB_MODE_EDIT) {
return true;
}
}
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
index 8bfd94d9e59..f074a56fb86 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -121,14 +121,14 @@ bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode)
*
* This is so each mode's exec function can call
*/
-bool ED_object_mode_compat_set(bContext *C, WorkSpace *workspace, eObjectMode mode, ReportList *reports)
+bool ED_object_mode_compat_set(bContext *C, Object *ob, eObjectMode mode, ReportList *reports)
{
bool ok;
- if (!ELEM(workspace->object_mode, mode, OB_MODE_OBJECT)) {
- const char *opstring = object_mode_op_string(workspace->object_mode);
+ if (!ELEM(ob->mode, mode, OB_MODE_OBJECT)) {
+ const char *opstring = object_mode_op_string(ob->mode);
WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL);
- ok = ELEM(workspace->object_mode, mode, OB_MODE_OBJECT);
+ 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);
@@ -176,8 +176,8 @@ void ED_object_mode_set(bContext *C, eObjectMode mode)
bool ED_object_mode_generic_enter(
struct bContext *C, eObjectMode object_mode)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->object_mode == object_mode) {
+ Object *ob = CTX_data_active_object(C);
+ if (ob->mode == object_mode) {
return true;
}
wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_mode_set", false);
@@ -186,7 +186,7 @@ bool ED_object_mode_generic_enter(
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 (workspace->object_mode == object_mode);
+ return (ob->mode == object_mode);
}
/**
@@ -195,46 +195,46 @@ bool ED_object_mode_generic_enter(
*/
static bool ed_object_mode_generic_exit_ex(
const struct EvaluationContext *eval_ctx,
- struct WorkSpace *workspace, struct Scene *scene, struct Object *ob,
+ struct Scene *scene, struct Object *ob,
bool only_test)
{
- if (eval_ctx->object_mode & OB_MODE_EDIT) {
+ if (ob->mode & OB_MODE_EDIT) {
if (BKE_object_is_in_editmode(ob)) {
if (only_test) {
return true;
}
- ED_object_editmode_exit_ex(NULL, workspace, scene, ob, EM_FREEDATA);
+ ED_object_editmode_exit_ex(NULL, scene, ob, EM_FREEDATA);
}
}
- else if (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) {
+ 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(workspace, ob);
+ ED_object_vpaintmode_exit_ex(ob);
}
}
- else if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
+ 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(workspace, ob);
+ ED_object_wpaintmode_exit_ex(ob);
}
}
- else if (eval_ctx->object_mode & OB_MODE_SCULPT) {
+ else if (ob->mode & OB_MODE_SCULPT) {
if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_SCULPT)) {
if (only_test) {
return true;
}
- ED_object_sculptmode_exit_ex(eval_ctx, workspace, scene, ob);
+ ED_object_sculptmode_exit_ex(eval_ctx, scene, ob);
}
}
else {
if (only_test) {
return false;
}
- BLI_assert((eval_ctx->object_mode & OB_MODE_ALL_MODE_DATA) == 0);
+ BLI_assert((ob->mode & OB_MODE_ALL_MODE_DATA) == 0);
}
return false;
@@ -242,88 +242,16 @@ static bool ed_object_mode_generic_exit_ex(
void ED_object_mode_generic_exit(
const struct EvaluationContext *eval_ctx,
- struct WorkSpace *workspace, struct Scene *scene, struct Object *ob)
+ struct Scene *scene, struct Object *ob)
{
- ed_object_mode_generic_exit_ex(eval_ctx, workspace, scene, ob, false);
+ ed_object_mode_generic_exit_ex(eval_ctx, scene, ob, false);
}
bool ED_object_mode_generic_has_data(
const struct EvaluationContext *eval_ctx,
struct Object *ob)
{
- return ed_object_mode_generic_exit_ex(eval_ctx, NULL, NULL, ob, true);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Mode Syncing Utils
- *
- * \{ */
-
-/**
- * A version of #ED_object_mode_generic_enter that checks if the object
- * has an active mode mode in another window we need to use another window first.
- */
-bool ED_object_mode_generic_enter_or_other_window(
- struct bContext *C, const wmWindow *win_compare, eObjectMode object_mode)
-{
- WorkSpace *workspace = CTX_wm_workspace(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Base *basact = view_layer->basact;
- if (basact == NULL) {
- workspace->object_mode = OB_MODE_OBJECT;
- return (workspace->object_mode == object_mode);
- }
-
- wmWindowManager *wm = CTX_wm_manager(C);
- eObjectMode object_mode_set = OB_MODE_OBJECT;
- bool use_object_mode = ED_workspace_object_mode_in_other_window(wm, win_compare, basact->object, &object_mode_set);
-
- if (use_object_mode) {
- workspace->object_mode = object_mode_set;
- return (workspace->object_mode == object_mode);
- }
- else {
- workspace->object_mode = OB_MODE_OBJECT;
- return ED_object_mode_generic_enter(C, object_mode);
- }
-}
-
-void ED_object_mode_generic_exit_or_other_window(
- const struct EvaluationContext *eval_ctx, wmWindowManager *wm,
- struct WorkSpace *workspace, struct Scene *scene, struct Object *ob)
-{
- if (ob == NULL) {
- return;
- }
- bool is_active = ED_workspace_object_mode_in_other_window(wm, NULL, ob, NULL);
- if (is_active == false) {
- ED_object_mode_generic_exit(eval_ctx, workspace, scene, ob);
- }
-}
-
-/**
- * Use to find if we need to create the mode-data.
- *
- * When the mode 'exists' it means we have a windowing showing an object with this mode.
- * So it's data is already created.
- * Used to check if we need to perform mode switching.
- */
-bool ED_object_mode_generic_exists(
- wmWindowManager *wm, struct Object *ob,
- eObjectMode object_mode)
-{
- if (ob == NULL) {
- return false;
- }
- eObjectMode object_mode_test;
- if (ED_workspace_object_mode_in_other_window(wm, NULL, ob, &object_mode_test)) {
- if (object_mode == object_mode_test) {
- return true;
- }
- }
- return false;
+ return ed_object_mode_generic_exit_ex(eval_ctx, NULL, ob, true);
}
/** \} */
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 9d1792e9f16..04243660440 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -95,10 +95,7 @@ static void modifier_skin_customdata_delete(struct Object *ob);
/******************************** API ****************************/
-ModifierData *ED_object_modifier_add(
- ReportList *reports,
- Main *bmain, Scene *scene,
- Object *ob, eObjectMode object_mode, const char *name, int type)
+ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
{
ModifierData *md = NULL, *new_md = NULL;
const ModifierTypeInfo *mti = modifierType_getInfo(type);
@@ -165,7 +162,7 @@ ModifierData *ED_object_modifier_add(
/* set totlvl from existing MDISPS layer if object already had it */
multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob);
- if (object_mode & OB_MODE_SCULPT) {
+ if (ob->mode & OB_MODE_SCULPT) {
/* ensure that grid paint mask layer is created */
BKE_sculpt_mask_layers_ensure(ob, (MultiresModifierData *)new_md);
}
@@ -205,11 +202,9 @@ static bool object_has_modifier(const Object *ob, const ModifierData *exclude,
* If the callback ever returns true, iteration will stop and the
* function value will be true. Otherwise the function returns false.
*/
-bool ED_object_iter_other(
- const EvaluationContext *eval_ctx,
- Main *bmain, Object *orig_ob, const bool include_orig,
- bool (*callback)(const EvaluationContext *eval_ctx, Object *ob, void *callback_data),
- void *callback_data)
+bool ED_object_iter_other(Main *bmain, Object *orig_ob, const bool include_orig,
+ bool (*callback)(Object *ob, void *callback_data),
+ void *callback_data)
{
ID *ob_data_id = orig_ob->data;
int users = ob_data_id->us;
@@ -228,7 +223,7 @@ bool ED_object_iter_other(
if (((ob != orig_ob) || include_orig) &&
(ob->data == orig_ob->data))
{
- if (callback(eval_ctx, ob, callback_data))
+ if (callback(ob, callback_data))
return true;
totfound++;
@@ -236,15 +231,13 @@ bool ED_object_iter_other(
}
}
else if (include_orig) {
- return callback(eval_ctx, orig_ob, callback_data);
+ return callback(orig_ob, callback_data);
}
return false;
}
-static bool object_has_modifier_cb(
- const EvaluationContext *UNUSED(eval_ctx),
- Object *ob, void *data)
+static bool object_has_modifier_cb(Object *ob, void *data)
{
ModifierType type = *((ModifierType *)data);
@@ -254,16 +247,14 @@ static bool object_has_modifier_cb(
/* Use with ED_object_iter_other(). Sets the total number of levels
* for any multires modifiers on the object to the int pointed to by
* callback_data. */
-bool ED_object_multires_update_totlevels_cb(
- const struct EvaluationContext *eval_ctx,
- Object *ob, void *totlevel_v)
+bool ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v)
{
ModifierData *md;
int totlevel = *((char *)totlevel_v);
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Multires) {
- multires_set_tot_level((MultiresModifierData *)md, totlevel, eval_ctx->object_mode);
+ multires_set_tot_level(ob, (MultiresModifierData *)md, totlevel);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
}
@@ -276,7 +267,7 @@ static bool object_modifier_safe_to_delete(Main *bmain, Object *ob,
ModifierType type)
{
return (!object_has_modifier(ob, exclude, type) &&
- !ED_object_iter_other(NULL, bmain, ob, false,
+ !ED_object_iter_other(bmain, ob, false,
object_has_modifier_cb, &type));
}
@@ -325,13 +316,11 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md,
modifier_skin_customdata_delete(ob);
}
-#if 0 /* not needed now modes are in workspace */
if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) &&
BLI_listbase_is_empty(&ob->particlesystem))
{
ob->mode &= ~OB_MODE_PARTICLE_EDIT;
}
-#endif
DEG_relations_tag_update(bmain);
@@ -424,9 +413,7 @@ int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData *
return 1;
}
-int ED_object_modifier_convert(
- ReportList *UNUSED(reports), Main *bmain, Scene *scene,
- ViewLayer *view_layer, Object *UNUSED(ob), eObjectMode object_mode, ModifierData *md)
+int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *scene, ViewLayer *view_layer, Object *ob, ModifierData *md)
{
Object *obn;
ParticleSystem *psys;
@@ -440,7 +427,7 @@ int ED_object_modifier_convert(
int totpart = 0, totchild = 0;
if (md->type != eModifierType_ParticleSystem) return 0;
- if (object_mode & OB_MODE_PARTICLE_EDIT) return 0;
+ if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0;
psys = ((ParticleSystemModifierData *)md)->psys;
part = psys->part;
@@ -535,12 +522,9 @@ int ED_object_modifier_convert(
return 1;
}
-static int modifier_apply_shape(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md)
+static int modifier_apply_shape(ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ModifierData *md)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
md->scene = scene;
@@ -571,7 +555,7 @@ static int modifier_apply_shape(ReportList *reports, const bContext *C, Scene *s
return 0;
}
- dm = mesh_create_derived_for_modifier(&eval_ctx, scene, ob, md, 0);
+ dm = mesh_create_derived_for_modifier(eval_ctx, scene, ob, md, 0);
if (!dm) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
return 0;
@@ -598,12 +582,9 @@ static int modifier_apply_shape(ReportList *reports, const bContext *C, Scene *s
return 1;
}
-static int modifier_apply_obdata(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md)
+static int modifier_apply_obdata(ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ModifierData *md)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
md->scene = scene;
@@ -627,13 +608,13 @@ static int modifier_apply_obdata(ReportList *reports, const bContext *C, Scene *
multires_force_update(ob);
if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) {
- if (!multiresModifier_reshapeFromDeformMod(&eval_ctx, scene, mmd, ob, md)) {
+ if (!multiresModifier_reshapeFromDeformMod(eval_ctx, scene, mmd, ob, md)) {
BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply");
return 0;
}
}
else {
- dm = mesh_create_derived_for_modifier(&eval_ctx, scene, ob, md, 1);
+ dm = mesh_create_derived_for_modifier(eval_ctx, scene, ob, md, 1);
if (!dm) {
BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
return 0;
@@ -659,7 +640,7 @@ static int modifier_apply_obdata(ReportList *reports, const bContext *C, Scene *
BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices");
vertexCos = BKE_curve_nurbs_vertexCos_get(&cu->nurb, &numVerts);
- mti->deformVerts(md, &eval_ctx, ob, NULL, vertexCos, numVerts, 0);
+ mti->deformVerts(md, eval_ctx, ob, NULL, vertexCos, numVerts, 0);
BK_curve_nurbs_vertexCos_apply(&cu->nurb, vertexCos);
MEM_freeN(vertexCos);
@@ -681,16 +662,17 @@ static int modifier_apply_obdata(ReportList *reports, const bContext *C, Scene *
if (psys->part->type != PART_HAIR)
continue;
- psys_apply_hair_lattice(&eval_ctx, scene, ob, psys);
+ psys_apply_hair_lattice(eval_ctx, scene, ob, psys);
}
}
return 1;
}
-int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md, int mode)
+int ED_object_modifier_apply(
+ ReportList *reports, const EvaluationContext *eval_ctx,
+ Scene *scene, Object *ob, ModifierData *md, int mode)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
int prev_mode;
if (BKE_object_is_in_editmode(ob)) {
@@ -701,7 +683,7 @@ int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scen
BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data");
return 0;
}
- else if ((workspace->object_mode & OB_MODE_SCULPT) &&
+ else if ((ob->mode & OB_MODE_SCULPT) &&
(find_multires_modifier_before(scene, md)) &&
(modifier_isSameTopology(md) == false))
{
@@ -717,13 +699,13 @@ int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scen
md->mode |= eModifierMode_Realtime;
if (mode == MODIFIER_APPLY_SHAPE) {
- if (!modifier_apply_shape(reports, C, scene, ob, md)) {
+ if (!modifier_apply_shape(reports, eval_ctx, scene, ob, md)) {
md->mode = prev_mode;
return 0;
}
}
else {
- if (!modifier_apply_obdata(reports, C, scene, ob, md)) {
+ if (!modifier_apply_obdata(reports, eval_ctx, scene, ob, md)) {
md->mode = prev_mode;
return 0;
}
@@ -753,13 +735,12 @@ int ED_object_modifier_copy(ReportList *UNUSED(reports), Object *ob, ModifierDat
static int modifier_add_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
int type = RNA_enum_get(op->ptr, "type");
- if (!ED_object_modifier_add(op->reports, bmain, scene, ob, workspace->object_mode, NULL, type))
+ if (!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -896,12 +877,11 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type)
static int modifier_remove_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- int mode_orig = workspace->object_mode;
+ int mode_orig = ob->mode;
if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
return OPERATOR_CANCELLED;
@@ -910,8 +890,8 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
/* if cloth/softbody was removed, particle mode could be cleared */
if (mode_orig & OB_MODE_PARTICLE_EDIT) {
- if ((workspace->object_mode & OB_MODE_PARTICLE_EDIT) == 0) {
- if (view_layer->basact && view_layer->basact->object == ob) {
+ if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) {
+ if (ob == OBACT(view_layer)) {
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
}
}
@@ -1029,7 +1009,10 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int apply_as = RNA_enum_get(op->ptr, "apply_as");
- if (!md || !ED_object_modifier_apply(op->reports, C, scene, ob, md, apply_as)) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ if (!md || !ED_object_modifier_apply(op->reports, &eval_ctx, scene, ob, md, apply_as)) {
return OPERATOR_CANCELLED;
}
@@ -1074,16 +1057,14 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot)
static int modifier_convert_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
-
- if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, workspace->object_mode, md)) {
+
+ if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, md))
return OPERATOR_CANCELLED;
- }
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1167,13 +1148,10 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op)
if (!mmd)
return OPERATOR_CANCELLED;
+
+ multiresModifier_del_levels(mmd, ob, 1);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
- multiresModifier_del_levels(mmd, ob, 1, eval_ctx.object_mode);
-
- ED_object_iter_other(&eval_ctx, CTX_data_main(C), ob, true,
+ ED_object_iter_other(CTX_data_main(C), ob, true,
ED_object_multires_update_totlevels_cb,
&mmd->totlvl);
@@ -1214,20 +1192,17 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
if (!mmd)
return OPERATOR_CANCELLED;
+
+ multiresModifier_subdivide(mmd, ob, 0, mmd->simple);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
- multiresModifier_subdivide(mmd, ob, 0, mmd->simple, eval_ctx.object_mode);
-
- ED_object_iter_other(
- &eval_ctx, CTX_data_main(C), ob, true,
- ED_object_multires_update_totlevels_cb,
- &mmd->totlvl);
+ ED_object_iter_other(CTX_data_main(C), ob, true,
+ ED_object_multires_update_totlevels_cb,
+ &mmd->totlvl);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
- if (eval_ctx.mode & OB_MODE_SCULPT) {
+ if (ob->mode & OB_MODE_SCULPT) {
/* ensure that grid paint mask layer is created */
BKE_sculpt_mask_layers_ensure(ob, mmd);
}
@@ -1264,11 +1239,8 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C), *secondob = NULL;
Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (!mmd)
return OPERATOR_CANCELLED;
@@ -1291,6 +1263,9 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (!multiresModifier_reshape(&eval_ctx, scene, mmd, ob, secondob)) {
BKE_report(op->reports, RPT_ERROR, "Objects do not have the same number of vertices");
return OPERATOR_CANCELLED;
@@ -1441,9 +1416,8 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op)
if (!mmd)
return OPERATOR_CANCELLED;
-
- const WorkSpace *workspace = CTX_wm_workspace(C);
- multiresModifier_base_apply(mmd, ob, workspace->object_mode);
+
+ multiresModifier_base_apply(mmd, ob);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1725,10 +1699,8 @@ static void skin_armature_bone_create(Object *skin_ob,
}
}
-static Object *modifier_skin_armature_create(const bContext *C, Scene *scene, ViewLayer *view_layer, Object *skin_ob)
+static Object *modifier_skin_armature_create(const EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *skin_ob)
{
- Main *bmain = CTX_data_main(C);
- EvaluationContext eval_ctx;
BLI_bitmap *edges_visited;
DerivedMesh *deform_dm;
MVert *mvert;
@@ -1740,9 +1712,7 @@ static Object *modifier_skin_armature_create(const bContext *C, Scene *scene, Vi
int *emap_mem;
int v;
- CTX_data_eval_ctx(C, &eval_ctx);
-
- deform_dm = mesh_get_derived_deform(&eval_ctx, scene, skin_ob, CD_MASK_BAREMESH);
+ deform_dm = mesh_get_derived_deform(eval_ctx, scene, skin_ob, CD_MASK_BAREMESH);
mvert = deform_dm->getVertArray(deform_dm);
/* add vertex weights to original mesh */
@@ -1752,7 +1722,7 @@ static Object *modifier_skin_armature_create(const bContext *C, Scene *scene, Vi
NULL,
me->totvert);
- arm_ob = BKE_object_add(bmain, scene, view_layer, OB_ARMATURE, NULL);
+ arm_ob = BKE_object_add(bmain, scene, eval_ctx->view_layer, OB_ARMATURE, NULL);
BKE_object_transform_copy(arm_ob, skin_ob);
arm = arm_ob->data;
arm->layer = 1;
@@ -1811,7 +1781,6 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = CTX_data_active_object(C), *arm_ob;
Mesh *me = ob->data;
ModifierData *skin_md;
@@ -1822,8 +1791,11 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* create new armature */
- arm_ob = modifier_skin_armature_create(C, scene, view_layer, ob);
+ arm_ob = modifier_skin_armature_create(&eval_ctx, bmain, scene, ob);
/* add a modifier to connect the new armature to the mesh */
arm_md = (ArmatureModifierData *)modifier_new(eModifierType_Armature);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 492eca20006..66dc17fe77d 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -286,9 +286,8 @@ void ED_operatormacros_object(void)
static int object_mode_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- return (!ob || workspace->object_mode == OB_MODE_OBJECT);
+ return (!ob || ob->mode == OB_MODE_OBJECT);
}
void ED_keymap_object(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 00c5fdf3cc7..3443a268ef2 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -717,8 +717,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
switch (partype) {
case PAR_CURVE: /* curve deform */
if (modifiers_isDeformedByCurve(ob) != par) {
- md = ED_object_modifier_add(
- reports, bmain, scene, ob, eval_ctx.object_mode, NULL, eModifierType_Curve);
+ md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve);
if (md) {
((CurveModifierData *)md)->object = par;
}
@@ -729,8 +728,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
break;
case PAR_LATTICE: /* lattice deform */
if (modifiers_isDeformedByLattice(ob) != par) {
- md = ED_object_modifier_add(
- reports, bmain, scene, ob, eval_ctx.object_mode, NULL, eModifierType_Lattice);
+ md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice);
if (md) {
((LatticeModifierData *)md)->object = par;
}
@@ -738,8 +736,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
break;
default: /* armature deform */
if (modifiers_isDeformedByArmature(ob) != par) {
- md = ED_object_modifier_add(
- reports, bmain, scene, ob, eval_ctx.object_mode, NULL, eModifierType_Armature);
+ md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature);
if (md) {
((ArmatureModifierData *)md)->object = par;
}
@@ -1428,7 +1425,6 @@ static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst
static int make_links_data_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Main *bmain = CTX_data_main(C);
const int type = RNA_enum_get(op->ptr, "type");
Object *ob_src;
@@ -1513,7 +1509,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
}
break;
case MAKE_LINKS_MODIFIERS:
- BKE_object_link_modifiers(ob_dst, ob_src, workspace->object_mode);
+ BKE_object_link_modifiers(ob_dst, ob_src);
DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
break;
case MAKE_LINKS_FONTS:
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 2feca9184f8..cd1300dd52e 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -123,51 +123,7 @@ void ED_object_base_select(Base *base, eObjectSelect_Mode mode)
void ED_object_base_activate(bContext *C, Base *base)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
-
- wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win = CTX_wm_window(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
-
- eObjectMode object_mode = workspace->object_mode;
- eObjectMode object_mode_set = OB_MODE_OBJECT;
-
- if (base && ED_workspace_object_mode_in_other_window(
- wm, win, base->object,
- &object_mode_set))
- {
- /* Sync existing object mode with workspace. */
- workspace->object_mode = object_mode_set;
- view_layer->basact = base;
- }
- else {
- /* Apply the workspaces mode to the object (when possible). */
- Scene *scene = CTX_data_scene(C);
- Object *obact = base ? base->object : NULL;
- /* We don't know the previous active object in update.
- *
- * Not correct because it's possible other work-spaces use these.
- * although that's a corner case. */
- if (workspace->object_mode & OB_MODE_ALL_MODE_DATA) {
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
- FOREACH_OBJECT_BEGIN(view_layer, ob) {
- if (ob != obact) {
- if (ED_object_mode_generic_has_data(&eval_ctx, ob) &&
- ED_workspace_object_mode_in_other_window(wm, win, ob, NULL) == false)
- {
- ED_object_mode_generic_exit(&eval_ctx, workspace, scene, ob);
- }
- }
- }
- FOREACH_OBJECT_END;
- }
-
- workspace->object_mode = OB_MODE_OBJECT;
-
- view_layer->basact = base;
-
- ED_object_mode_generic_enter(C, object_mode);
- }
+ view_layer->basact = base;
if (base) {
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, view_layer);
@@ -183,14 +139,13 @@ static int objects_selectable_poll(bContext *C)
{
/* we don't check for linked scenes here, selection is
* still allowed then for inspection of scene */
- if (CTX_data_edit_object(C)) {
- return 0;
- }
+ Object *obact = CTX_data_active_object(C);
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->object_mode != OB_MODE_OBJECT) {
+ if (CTX_data_edit_object(C))
return 0;
- }
+ if (obact && obact->mode)
+ return 0;
+
return 1;
}
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index bd3bd8fd0a5..1f80cb5f0bc 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -49,7 +49,6 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "DNA_workspace_types.h"
#include "BKE_context.h"
#include "BKE_key.h"
@@ -226,20 +225,18 @@ static bool object_shape_key_mirror(bContext *C, Object *ob,
static int shape_key_mode_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
- return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && (workspace->object_mode != OB_MODE_EDIT));
+ return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && ob->mode != OB_MODE_EDIT);
}
static int shape_key_mode_exists_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
/* same as shape_key_mode_poll */
- return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && (workspace->object_mode != OB_MODE_EDIT)) &&
+ return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && ob->mode != OB_MODE_EDIT) &&
/* check a keyblock exists */
(BKE_keyblock_from_object(ob) != NULL);
}
@@ -247,13 +244,12 @@ static int shape_key_mode_exists_poll(bContext *C)
static int shape_key_move_poll(bContext *C)
{
/* Same as shape_key_mode_exists_poll above, but ensure we have at least two shapes! */
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
Key *key = BKE_key_from_object(ob);
return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) &&
- (workspace->object_mode != OB_MODE_EDIT) && key && key->totkey > 1);
+ ob->mode != OB_MODE_EDIT && key && key->totkey > 1);
}
static int shape_key_poll(bContext *C)
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 7ea1a04f31f..bb23f871a25 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -245,7 +245,6 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
void (*clear_func)(Object *, const bool),
const char default_ksName[])
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
const bool clear_delta = RNA_boolean_get(op->ptr, "clear_delta");
@@ -264,7 +263,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
*/
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
- if (!(workspace->object_mode & OB_MODE_WEIGHT_PAINT)) {
+ if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) {
/* run provided clearing function */
clear_func(ob, clear_delta);
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index eb04de5feb2..7026e8671ad 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -85,9 +85,9 @@
#include "object_intern.h"
/************************ Exported Functions **********************/
-static bool vertex_group_use_vert_sel(const Object *ob)
+static bool vertex_group_use_vert_sel(Object *ob)
{
- if (BKE_object_is_in_editmode(ob)) {
+ if (ob->mode == OB_MODE_EDIT) {
return true;
}
else if (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) {
@@ -108,15 +108,13 @@ static Lattice *vgroup_edit_lattice(Object *ob)
bool ED_vgroup_sync_from_pose(Object *ob)
{
Object *armobj = BKE_object_pose_armature_get(ob);
- if (armobj) {
+ if (armobj && (armobj->mode & OB_MODE_POSE)) {
struct bArmature *arm = armobj->data;
- if (arm->flag & ARM_POSEMODE) {
- if (arm->act_bone) {
- int def_num = defgroup_name_index(ob, arm->act_bone->name);
- if (def_num != -1) {
- ob->actdef = def_num + 1;
- return true;
- }
+ if (arm->act_bone) {
+ int def_num = defgroup_name_index(ob, arm->act_bone->name);
+ if (def_num != -1) {
+ ob->actdef = def_num + 1;
+ return true;
}
}
}
@@ -2550,13 +2548,12 @@ static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const
return false;
}
- const WorkSpace *workspace = CTX_wm_workspace(C);
if (BKE_object_is_in_editmode_vgroup(ob)) {
return true;
}
- else if (workspace->object_mode & OB_MODE_WEIGHT_PAINT) {
+ else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
if (needs_select) {
- if (BKE_object_is_in_wpaint_select_vert(ob, workspace->object_mode)) {
+ if (BKE_object_is_in_wpaint_select_vert(ob)) {
return true;
}
else {
@@ -2608,9 +2605,8 @@ static int vertex_group_vert_select_unlocked_poll(bContext *C)
if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
return 0;
- const WorkSpace *workspace = CTX_wm_workspace(C);
if (!(BKE_object_is_in_editmode_vgroup(ob) ||
- BKE_object_is_in_wpaint_select_vert(ob, workspace->object_mode)))
+ BKE_object_is_in_wpaint_select_vert(ob)))
{
return 0;
}
@@ -2636,9 +2632,8 @@ static int vertex_group_vert_select_mesh_poll(bContext *C)
if (ob->type != OB_MESH)
return 0;
- const WorkSpace *workspace = CTX_wm_workspace(C);
return (BKE_object_is_in_editmode_vgroup(ob) ||
- BKE_object_is_in_wpaint_select_vert(ob, workspace->object_mode));
+ BKE_object_is_in_wpaint_select_vert(ob));
}
static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
@@ -3522,8 +3517,7 @@ static char *vgroup_init_remap(Object *ob)
return name_array;
}
-static int vgroup_do_remap(
- const EvaluationContext *eval_ctx, Object *ob, const char *name_array, wmOperator *op)
+static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
{
MDeformVert *dvert = NULL;
bDeformGroup *def;
@@ -3544,7 +3538,7 @@ static int vgroup_do_remap(
BLI_assert(sort_map[i] != -1);
}
- if (eval_ctx->object_mode == OB_MODE_EDIT) {
+ if (ob->mode == OB_MODE_EDIT) {
if (ob->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(ob);
const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
@@ -3642,8 +3636,6 @@ enum {
static int vertex_group_sort_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
char *name_array;
int ret;
@@ -3663,7 +3655,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
}
/*remap vgroup data to map to correct names*/
- ret = vgroup_do_remap(&eval_ctx, ob, name_array, op);
+ ret = vgroup_do_remap(ob, name_array, op);
if (ret != OPERATOR_CANCELLED) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -3699,8 +3691,6 @@ void OBJECT_OT_vertex_group_sort(wmOperatorType *ot)
static int vgroup_move_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
bDeformGroup *def;
char *name_array;
@@ -3715,7 +3705,7 @@ static int vgroup_move_exec(bContext *C, wmOperator *op)
name_array = vgroup_init_remap(ob);
if (BLI_listbase_link_move(&ob->defbase, def, dir)) {
- ret = vgroup_do_remap(&eval_ctx, ob, name_array, op);
+ ret = vgroup_do_remap(ob, name_array, op);
if (ret != OPERATOR_CANCELLED) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 14bcba3416f..51abb5b2eaa 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -42,7 +42,6 @@
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
-#include "DNA_workspace_types.h"
#include "BLI_math.h"
#include "BLI_lasso_2d.h"
@@ -93,12 +92,10 @@
int PE_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene= CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob= CTX_data_active_object(C);
- if (!scene || !view_layer || !ob || !(workspace->object_mode & OB_MODE_PARTICLE_EDIT)) {
+ if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) {
return 0;
}
return (PE_get_current(scene, ob) != NULL);
@@ -106,12 +103,11 @@ int PE_poll(bContext *C)
int PE_hair_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
PTCacheEdit *edit;
- if (!scene || !ob || !(workspace->object_mode & OB_MODE_PARTICLE_EDIT)) {
+ if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) {
return 0;
}
edit= PE_get_current(scene, ob);
@@ -295,7 +291,7 @@ PTCacheEdit *PE_create_current(const EvaluationContext *eval_ctx, Scene *scene,
void PE_current_changed(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
- if (eval_ctx->object_mode == OB_MODE_PARTICLE_EDIT) {
+ if (ob->mode == OB_MODE_PARTICLE_EDIT) {
PE_create_current(eval_ctx, scene, ob);
}
}
@@ -4459,25 +4455,23 @@ static int particle_edit_toggle_poll(bContext *C)
static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
{
- wmWindowManager *wm = CTX_wm_manager(C);
- struct WorkSpace *workspace = CTX_wm_workspace(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_PARTICLE_EDIT;
- const bool is_mode_set = (eval_ctx.object_mode & mode_flag) != 0;
+ const bool is_mode_set = (ob->mode & mode_flag) != 0;
if (!is_mode_set) {
- if (!ED_object_mode_compat_set(C, workspace, mode_flag, op->reports)) {
+ if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
}
}
if (!is_mode_set) {
PTCacheEdit *edit;
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
- workspace->object_mode |= mode_flag;
+ ob->mode |= mode_flag;
edit= PE_create_current(&eval_ctx, scene, ob);
/* mesh may have changed since last entering editmode.
@@ -4489,12 +4483,12 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL);
}
else {
- workspace->object_mode &= ~mode_flag;
+ ob->mode &= ~mode_flag;
toggle_particle_cursor(C, 0);
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
}
- ED_workspace_object_mode_sync_from_object(wm, workspace, ob);
+ // ED_workspace_object_mode_sync_from_object(wm, workspace, ob);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index ce4137b182d..1fae5b70aff 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -110,25 +110,23 @@ void OBJECT_OT_particle_system_add(wmOperatorType *ot)
static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- eObjectMode mode_orig;
+ int mode_orig;
if (!scene || !ob)
return OPERATOR_CANCELLED;
- mode_orig = workspace->object_mode;
+ mode_orig = ob->mode;
object_remove_particle_system(scene, ob);
/* possible this isn't the active object
* object_remove_particle_system() clears the mode on the last psys
*/
if (mode_orig & OB_MODE_PARTICLE_EDIT) {
- if ((workspace->object_mode & OB_MODE_PARTICLE_EDIT) == 0) {
+ if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) {
if (view_layer->basact && view_layer->basact->object == ob) {
- workspace->object_mode &= ~OB_MODE_PARTICLE_EDIT;
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
}
}
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 222e0e20dff..270ba2a7947 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -99,7 +99,6 @@
static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_context(C);
if (!ob)
@@ -107,7 +106,7 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
BKE_object_material_slot_add(ob);
- if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) {
+ if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
@@ -137,7 +136,6 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot)
static int material_slot_remove_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_context(C);
if (!ob)
@@ -151,7 +149,7 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
BKE_object_material_slot_remove(ob);
- if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) {
+ if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 4d006028245..d29985041c6 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -401,12 +401,10 @@ static void texture_changed(Main *bmain, Tex *tex)
/* icons */
BKE_icon_changed(BKE_icon_id_ensure(&tex->id));
- const eObjectMode object_mode = WM_windows_object_mode_get(bmain->wm.first);
-
/* paint overlays */
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
- BKE_paint_invalidate_overlay_tex(scene, view_layer, tex, object_mode);
+ BKE_paint_invalidate_overlay_tex(scene, view_layer, tex);
}
}
@@ -526,23 +524,11 @@ static void scene_changed(Main *bmain, Scene *scene)
Object *ob;
/* glsl */
- bool has_texture_mode = false;
- wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) {
- has_texture_mode = true;
- break;
- }
- }
-
- if (has_texture_mode) {
- for (ob = bmain->object.first; ob; ob = ob->id.next) {
- if (ob->type == OB_MESH) {
- BKE_texpaint_slots_refresh_object(scene, ob);
- BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
- GPU_drawobject_free(ob->derivedFinal);
- }
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
+ if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+ BKE_texpaint_slots_refresh_object(scene, ob);
+ BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
+ GPU_drawobject_free(ob->derivedFinal);
}
}
}
@@ -572,10 +558,8 @@ void ED_render_id_flush_update(const DEGEditorUpdateContext *update_ctx, ID *id)
lamp_changed(bmain, (Lamp *)id);
break;
case ID_IM:
- {
image_changed(bmain, (Image *)id);
break;
- }
case ID_SCE:
scene_changed(bmain, (Scene *)id);
render_engine_flag_changed(bmain, RE_ENGINE_UPDATE_OTHER);
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index da720272f67..76abc1489fd 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -122,21 +122,23 @@ static ViewLayer *scene_change_get_new_view_layer(const WorkSpace *workspace, co
void ED_scene_change_update(
Main *bmain, bContext *C,
- wmWindow *win, const bScreen *screen, Scene *scene_old, Scene *scene_new)
+ wmWindow *win, const bScreen *screen, Scene *UNUSED(scene_old), Scene *scene_new)
{
WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *layer_new = scene_change_get_new_view_layer(workspace, scene_new);
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene_new, layer_new, true);
Object *obact_new = OBACT(layer_new);
+ UNUSED_VARS(obact_new);
+#if 0
/* mode syncing */
EvaluationContext eval_ctx_old;
CTX_data_eval_ctx(C, &eval_ctx_old);
eObjectMode object_mode_old = workspace->object_mode;
ViewLayer *layer_old = BKE_view_layer_from_workspace_get(scene_old, workspace);
Object *obact_old = OBACT(layer_old);
- bool obact_new_mode_exists = ED_object_mode_generic_exists(bmain->wm.first, obact_new, workspace->object_mode);
-
+ UNUSED_VARS(obact_old, object_mode_old);
+#endif
win->scene = scene_new;
CTX_data_scene_set(C, scene_new);
@@ -145,19 +147,6 @@ void ED_scene_change_update(
DEG_graph_relations_update(depsgraph, bmain, scene_new, layer_new);
DEG_on_visible_update(bmain, false);
- if (obact_new == obact_old) {
- /* pass */
- }
- else {
- ED_object_mode_generic_exit_or_other_window(&eval_ctx_old, bmain->wm.first, workspace, scene_old, obact_old);
- if (obact_new_mode_exists) {
- workspace->object_mode = object_mode_old;
- }
- else {
- ED_object_mode_generic_enter_or_other_window(C, win, object_mode_old);
- }
- }
-
ED_screen_update_after_scene_change(screen, scene_new, layer_new);
ED_render_engine_changed(bmain);
ED_update_for_newframe(bmain, scene_new, layer_new, depsgraph);
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 4c217a5e829..e0c73b1782e 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -93,6 +93,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace);
Object *obact = (view_layer && view_layer->basact) ? view_layer->basact->object : NULL;
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
if (CTX_data_dir(member)) {
CTX_data_dir_set(result, screen_context_dir);
@@ -203,7 +204,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) {
- Object *obedit = BKE_workspace_edit_object(workspace, scene);
bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
EditBone *ebone, *flipbone = NULL;
const bool editable_bones = CTX_data_equals(member, "editable_bones");
@@ -246,7 +246,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) {
- Object *obedit = BKE_workspace_edit_object(workspace, scene);
bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
EditBone *ebone, *flipbone = NULL;
const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones");
@@ -368,38 +367,37 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "edit_object")) {
/* convenience for now, 1 object per scene in editmode */
- Object *obedit = BKE_workspace_edit_object(workspace, scene);
if (obedit)
CTX_data_id_pointer_set(result, &obedit->id);
return 1;
}
else if (CTX_data_equals(member, "sculpt_object")) {
- if (obact && (workspace->object_mode & OB_MODE_SCULPT)) {
+ if (obact && (obact->mode & OB_MODE_SCULPT))
CTX_data_id_pointer_set(result, &obact->id);
- }
+
return 1;
}
else if (CTX_data_equals(member, "vertex_paint_object")) {
- if (obact && (workspace->object_mode & OB_MODE_VERTEX_PAINT))
+ if (obact && (obact->mode & OB_MODE_VERTEX_PAINT))
CTX_data_id_pointer_set(result, &obact->id);
return 1;
}
else if (CTX_data_equals(member, "weight_paint_object")) {
- if (obact && (workspace->object_mode & OB_MODE_WEIGHT_PAINT))
+ if (obact && (obact->mode & OB_MODE_WEIGHT_PAINT))
CTX_data_id_pointer_set(result, &obact->id);
return 1;
}
else if (CTX_data_equals(member, "image_paint_object")) {
- if (obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT))
+ if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT))
CTX_data_id_pointer_set(result, &obact->id);
return 1;
}
else if (CTX_data_equals(member, "particle_edit_object")) {
- if (obact && (workspace->object_mode & OB_MODE_PARTICLE_EDIT))
+ if (obact && (obact->mode & OB_MODE_PARTICLE_EDIT))
CTX_data_id_pointer_set(result, &obact->id);
return 1;
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index c24d08d5fed..0b893d23e13 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -153,7 +153,6 @@ int ED_operator_scene_editable(bContext *C)
int ED_operator_objectmode(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
@@ -163,7 +162,7 @@ int ED_operator_objectmode(bContext *C)
return 0;
/* add a check for ob->mode too? */
- if (obact && (workspace->object_mode != OB_MODE_OBJECT))
+ if (obact && (obact->mode != OB_MODE_OBJECT))
return 0;
return 1;
@@ -305,39 +304,35 @@ int ED_operator_console_active(bContext *C)
return ed_spacetype_test(C, SPACE_CONSOLE);
}
-static int ed_object_hidden(Object *ob, eObjectMode object_mode)
+static int ed_object_hidden(Object *ob)
{
/* if hidden but in edit mode, we still display, can happen with animation */
- return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(object_mode & OB_MODE_EDIT));
+ return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT));
}
int ED_operator_object_active(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ed_object_hidden(ob, workspace->object_mode));
+ return ((ob != NULL) && !ed_object_hidden(ob));
}
int ED_operator_object_active_editable(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob, workspace->object_mode));
+ return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob));
}
int ED_operator_object_active_editable_mesh(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob, workspace->object_mode) &&
+ return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) &&
(ob->type == OB_MESH) && !ID_IS_LINKED(ob->data));
}
int ED_operator_object_active_editable_font(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob, workspace->object_mode) &&
+ return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) &&
(ob->type == OB_FONT));
}
@@ -382,14 +377,11 @@ int ED_operator_posemode_exclusive(bContext *C)
{
Object *obact = CTX_data_active_object(C);
- if (obact) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if ((workspace->object_mode & OB_MODE_EDIT) == 0) {
- Object *obpose;
- if ((obpose = BKE_object_pose_armature_get(obact))) {
- if (obact == obpose) {
- return 1;
- }
+ if (obact && !(obact->mode & OB_MODE_EDIT)) {
+ Object *obpose;
+ if ((obpose = BKE_object_pose_armature_get(obact))) {
+ if (obact == obpose) {
+ return 1;
}
}
}
@@ -403,15 +395,9 @@ int ED_operator_posemode_context(bContext *C)
{
Object *obpose = ED_pose_object_from_context(C);
- if (obpose) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- /* TODO, should we allow this out of pose mode? */
- if (workspace->object_mode & OB_MODE_POSE) {
- // if ((workspace->object_mode & OB_MODE_EDIT) == 0) {
- if (BKE_object_pose_context_check(obpose)) {
- return 1;
- }
- // }
+ if (obpose && !(obpose->mode & OB_MODE_EDIT)) {
+ if (BKE_object_pose_context_check(obpose)) {
+ return 1;
}
}
@@ -422,17 +408,11 @@ int ED_operator_posemode(bContext *C)
{
Object *obact = CTX_data_active_object(C);
-
- if (obact) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if ((workspace->object_mode & OB_MODE_EDIT) == 0) {
- Object *obpose;
- if ((obpose = BKE_object_pose_armature_get(obact))) {
- if (((workspace->object_mode & OB_MODE_POSE) && (obact == obpose)) ||
- (workspace->object_mode & OB_MODE_WEIGHT_PAINT))
- {
- return 1;
- }
+ if (obact && !(obact->mode & OB_MODE_EDIT)) {
+ Object *obpose;
+ if ((obpose = BKE_object_pose_armature_get(obact))) {
+ if ((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) {
+ return 1;
}
}
}
@@ -568,10 +548,9 @@ int ED_operator_mask(bContext *C)
}
case SPACE_IMAGE:
{
- WorkSpace *workspace = CTX_wm_workspace(C);
SpaceImage *sima = sa->spacedata.first;
ViewLayer *view_layer = CTX_data_view_layer(C);
- return ED_space_image_check_show_maskedit(sima, workspace, view_layer);
+ return ED_space_image_check_show_maskedit(sima, view_layer);
}
}
}
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index bf2e788e2b0..dee62f9c5dd 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -85,6 +85,26 @@ WorkSpace *ED_workspace_add(
return workspace;
}
+/**
+ * Changes the object mode (if needed) to the one set in \a workspace_new.
+ * Object mode is still stored on object level. In future it should all be workspace level instead.
+ */
+static void workspace_change_update_mode(
+ const WorkSpace *workspace_old, const WorkSpace *workspace_new,
+ bContext *C, Object *ob_act, ReportList *reports)
+{
+ UNUSED_VARS(workspace_old, workspace_new, C, ob_act, reports);
+#if 0
+ eObjectMode mode_old = workspace_old->object_mode;
+ eObjectMode mode_new = workspace_new->object_mode;
+
+ if (mode_old != mode_new) {
+ ED_object_mode_compat_set(C, ob_act, mode_new, reports);
+ ED_object_mode_toggle(C, mode_new);
+ }
+#endif
+}
+
static void workspace_change_update_view_layer(
WorkSpace *workspace_new, const WorkSpace *workspace_old,
Scene *scene)
@@ -96,10 +116,11 @@ static void workspace_change_update_view_layer(
static void workspace_change_update(
WorkSpace *workspace_new, const WorkSpace *workspace_old,
- bContext *C)
+ bContext *C, wmWindowManager *wm)
{
/* needs to be done before changing mode! (to ensure right context) */
workspace_change_update_view_layer(workspace_new, workspace_old, CTX_data_scene(C));
+ workspace_change_update_mode(workspace_old, workspace_new, C, CTX_data_active_object(C), &wm->reports);
}
static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, void *UNUSED(arg))
@@ -151,7 +172,7 @@ static WorkSpaceLayout *workspace_change_get_new_layout(
* \returns if workspace changing was successful.
*/
bool ED_workspace_change(
- WorkSpace *workspace_new, bContext *C, wmWindow *win)
+ WorkSpace *workspace_new, bContext *C, wmWindowManager *wm, wmWindow *win)
{
Main *bmain = CTX_data_main(C);
WorkSpace *workspace_old = WM_window_get_active_workspace(win);
@@ -169,20 +190,11 @@ bool ED_workspace_change(
BLI_assert(BKE_workspace_layout_screen_get(layout_new) == screen_new);
if (screen_new) {
- Scene *scene = WM_window_get_active_scene(win);
- bool use_object_mode = false;
-
- /* Store old context for exiting edit-mode. */
- EvaluationContext eval_ctx_old;
- CTX_data_eval_ctx(C, &eval_ctx_old);
-
-
WM_window_set_active_layout(win, workspace_new, layout_new);
WM_window_set_active_workspace(win, workspace_new);
/* update screen *after* changing workspace - which also causes the actual screen change */
- screen_change_update(C, win, screen_new);
- workspace_change_update(workspace_new, workspace_old, C);
+ workspace_change_update(workspace_new, workspace_old, C, wm);
BLI_assert(BKE_workspace_view_layer_get(workspace_new, CTX_data_scene(C)) != NULL);
BLI_assert(CTX_wm_workspace(C) == workspace_new);
@@ -190,40 +202,6 @@ bool ED_workspace_change(
WM_toolsystem_unlink(C, workspace_old);
WM_toolsystem_link(C, workspace_new);
- ViewLayer *view_layer_old = BKE_workspace_view_layer_get(workspace_old, scene);
- Object *obact_old = OBACT(view_layer_old);
-
- ViewLayer *view_layer_new = BKE_workspace_view_layer_get(workspace_new, scene);
- Object *obact_new = OBACT(view_layer_new);
-
- /* Handle object mode switching */
- if ((workspace_old->object_mode != OB_MODE_OBJECT) ||
- (workspace_new->object_mode != OB_MODE_OBJECT))
- {
- if ((workspace_old->object_mode == workspace_new->object_mode) &&
- (obact_old == obact_new))
- {
- /* pass */
- }
- else {
- use_object_mode = true;
- }
- }
-
- if (use_object_mode) {
- /* weak, set it back so it's used when activating again. */
- eObjectMode object_mode = workspace_old->object_mode;
- ED_object_mode_generic_exit_or_other_window(&eval_ctx_old, bmain->wm.first, workspace_old, scene, obact_old);
- workspace_old->object_mode = object_mode;
- ED_workspace_object_mode_sync_from_object(bmain->wm.first, workspace_old, obact_old);
- ED_object_mode_generic_enter_or_other_window(C, NULL, workspace_new->object_mode);
- }
- else {
- if (obact_new == NULL) {
- workspace_new->object_mode = OB_MODE_OBJECT;
- }
- }
-
return true;
}
@@ -250,7 +228,6 @@ WorkSpace *ED_workspace_duplicate(
BLI_duplicatelist(transform_orientations_new, transform_orientations_old);
workspace_new->tool = workspace_old->tool;
- workspace_new->object_mode = workspace_old->object_mode;
for (WorkSpaceLayout *layout_old = layouts_old->first; layout_old; layout_old = layout_old->next) {
WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(workspace_new, layout_old, win);
@@ -278,7 +255,7 @@ bool ED_workspace_delete(
WorkSpace *prev = workspace_id->prev;
WorkSpace *next = workspace_id->next;
- ED_workspace_change((prev != NULL) ? prev : next, C, win);
+ ED_workspace_change((prev != NULL) ? prev : next, C, wm, win);
}
BKE_libblock_free(bmain, workspace_id);
@@ -307,63 +284,6 @@ void ED_workspace_view_layer_unset(
}
}
-/**
- * When a work-space mode has changed,
- * flush it to all other visible work-spaces using the same object
- * since we don't support one object being in two different modes at once.
- * \note We could support this but it's more trouble than it's worth.
- */
-
-void ED_workspace_object_mode_sync_from_object(wmWindowManager *wm, WorkSpace *workspace, Object *obact)
-{
- if (obact == NULL) {
- return;
- }
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- WorkSpace *workspace_iter = BKE_workspace_active_get(win->workspace_hook);
- if ((workspace != workspace_iter) && (workspace->object_mode != workspace_iter->object_mode)) {
- Scene *scene_iter = WM_window_get_active_scene(win);
- ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene_iter, workspace_iter);
- if (obact == OBACT(view_layer)) {
- workspace_iter->object_mode = workspace->object_mode;
- /* TODO(campbell), use msgbus */
- WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene_iter);
- }
- }
- }
-}
-
-void ED_workspace_object_mode_sync_from_scene(wmWindowManager *wm, WorkSpace *workspace, Scene *scene)
-{
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
- if (view_layer) {
- Object *obact = OBACT(view_layer);
- ED_workspace_object_mode_sync_from_object(wm, workspace, obact);
- }
-}
-
-bool ED_workspace_object_mode_in_other_window(
- struct wmWindowManager *wm, const wmWindow *win_compare, Object *obact,
- eObjectMode *r_object_mode)
-{
- for (wmWindow *win_iter = wm->windows.first; win_iter; win_iter = win_iter->next) {
- if (win_compare != win_iter) {
- WorkSpace *workspace_iter = BKE_workspace_active_get(win_iter->workspace_hook);
- Scene *scene_iter = WM_window_get_active_scene(win_iter);
- ViewLayer *view_layer_iter = BKE_view_layer_from_workspace_get(scene_iter, workspace_iter);
- Object *obact_iter = OBACT(view_layer_iter);
- if (obact == obact_iter) {
- if (r_object_mode) {
- *r_object_mode = workspace_iter->object_mode;
- }
- return true;
- }
- }
- }
-
- return false;
-}
-
/** \} Workspace API */
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c
index 710ee7fcb44..049d8ff8c0b 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -32,7 +32,6 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
-#include "DNA_workspace_types.h"
#include "BLI_math_vector.h"
@@ -60,13 +59,12 @@
int paint_curve_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
Paint *p;
RegionView3D *rv3d = CTX_wm_region_view3d(C);
SpaceImage *sima;
- if (rv3d && !(ob && ((workspace->object_mode & OB_MODE_ALL_PAINT) != 0)))
+ if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0)))
return false;
sima = CTX_wm_space_image(C);
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 5d4451dd3d8..4d3c8fe4d5c 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -384,7 +384,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
clip_planes_from_rect(C, clip_planes, &rect);
dm = mesh_get_derived_final(&eval_ctx, CTX_data_scene(C), ob, CD_MASK_BAREMESH);
- pbvh = dm->getPBVH(ob, dm, eval_ctx.object_mode);
+ pbvh = dm->getPBVH(ob, dm);
ob->sculpt->pbvh = pbvh;
get_pbvh_nodes(pbvh, &nodes, &totnode, clip_planes, area);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index e72dac3b19e..ae26de8b269 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -269,13 +269,11 @@ static int image_paint_poll(bContext *C)
{
Object *obact;
- if (!image_paint_brush(C)) {
+ if (!image_paint_brush(C))
return 0;
- }
- const WorkSpace *workspace = CTX_wm_workspace(C);
obact = CTX_data_active_object(C);
- if ((obact && workspace->object_mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
+ if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
return 1;
}
else {
@@ -1048,21 +1046,19 @@ static int texture_paint_toggle_poll(bContext *C)
static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
{
- wmWindowManager *wm = CTX_wm_manager(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_TEXTURE_PAINT;
- const bool is_mode_set = (workspace->object_mode & mode_flag) != 0;
+ const bool is_mode_set = (ob->mode & mode_flag) != 0;
if (!is_mode_set) {
- if (!ED_object_mode_compat_set(C, workspace, mode_flag, op->reports)) {
+ if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
}
}
- if (workspace->object_mode & mode_flag) {
- workspace->object_mode &= ~mode_flag;
+ if (ob->mode & mode_flag) {
+ ob->mode &= ~mode_flag;
if (U.glreslimit != 0)
GPU_free_images();
@@ -1112,7 +1108,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
}
}
- workspace->object_mode |= mode_flag;
+ ob->mode |= mode_flag;
BKE_paint_init(scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT);
@@ -1123,7 +1119,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
toggle_paint_cursor(C, 1);
}
- ED_workspace_object_mode_sync_from_object(wm, workspace, ob);
+ // ED_workspace_object_mode_sync_from_object(wm, workspace, ob);
GPU_drawobject_free(ob->derivedFinal);
WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
@@ -1151,10 +1147,9 @@ static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op))
{
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
Brush *br;
- if (!(ob && (workspace->object_mode & OB_MODE_VERTEX_PAINT))) {
+ if (!(ob && (ob->mode & OB_MODE_VERTEX_PAINT))) {
br = image_paint_brush(C);
}
else {
@@ -1185,11 +1180,8 @@ static int brush_colors_flip_poll(bContext *C)
}
else {
Object *ob = CTX_data_active_object(C);
- if (ob) {
- WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->object_mode & OB_MODE_VERTEX_PAINT) {
- return 1;
- }
+ if (ob && (ob->mode & OB_MODE_VERTEX_PAINT)) {
+ return 1;
}
}
return 0;
@@ -1231,12 +1223,10 @@ void ED_imapaint_bucket_fill(struct bContext *C, float color[3], wmOperator *op)
static int texture_paint_poll(bContext *C)
{
- if (texture_paint_toggle_poll(C)) {
- WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) {
+ if (texture_paint_toggle_poll(C))
+ if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT)
return 1;
- }
- }
+
return 0;
}
@@ -1247,19 +1237,16 @@ int image_texture_paint_poll(bContext *C)
int facemask_paint_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
- return BKE_paint_select_face_test(CTX_data_active_object(C), workspace->object_mode);
+ return BKE_paint_select_face_test(CTX_data_active_object(C));
}
int vert_paint_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
- return BKE_paint_select_vert_test(CTX_data_active_object(C), workspace->object_mode);
+ return BKE_paint_select_vert_test(CTX_data_active_object(C));
}
int mask_paint_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
- return BKE_paint_select_elem_test(CTX_data_active_object(C), workspace->object_mode);
+ return BKE_paint_select_elem_test(CTX_data_active_object(C));
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 6530fb5c750..18019597865 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -5941,9 +5941,9 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op))
static int add_simple_uvs_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- if (!ob || (ob->type != OB_MESH) || (workspace->object_mode != OB_MODE_TEXTURE_PAINT)) {
+
+ if (!ob || ob->type != OB_MESH || ob->mode != OB_MODE_TEXTURE_PAINT) {
return false;
}
return true;
diff --git a/source/blender/editors/sculpt_paint/paint_image_undo.c b/source/blender/editors/sculpt_paint/paint_image_undo.c
index e9b6f5a410b..ade775d14e6 100644
--- a/source/blender/editors/sculpt_paint/paint_image_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_image_undo.c
@@ -407,18 +407,17 @@ static void paint_undosys_step_decode_restore_ids(ImageUndoStep *us)
static bool image_undosys_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *obact = CTX_data_active_object(C);
ScrArea *sa = CTX_wm_area(C);
if (sa && (sa->spacetype == SPACE_IMAGE)) {
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
- if ((obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
+ if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
return true;
}
}
else if (sa && (sa->spacetype == SPACE_VIEW3D)) {
- if (obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT)) {
+ if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) {
return true;
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index c031a733630..004d2757a71 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -40,8 +40,6 @@
#include "BKE_paint.h"
#include "BKE_main.h"
-#include "DEG_depsgraph.h"
-
#include "ED_paint.h"
#include "ED_screen.h"
#include "ED_image.h"
@@ -262,9 +260,7 @@ static void PALETTE_OT_color_delete(wmOperatorType *ot)
}
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
-
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Paint *paint = BKE_paint_get_active_from_context(C);
Brush *brush = BKE_paint_brush(paint);
Object *ob = CTX_data_active_object(C);
@@ -272,7 +268,7 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
if (!ob || !brush) return OPERATOR_CANCELLED;
/* TODO: other modes */
- if (workspace->object_mode & OB_MODE_SCULPT) {
+ if (ob->mode & OB_MODE_SCULPT) {
BKE_brush_sculpt_reset(brush);
}
else {
@@ -405,7 +401,6 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
static int brush_select_exec(bContext *C, wmOperator *op)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Main *bmain = CTX_data_main(C);
ToolSettings *toolsettings = CTX_data_tool_settings(C);
Paint *paint = NULL;
@@ -419,7 +414,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
if (ob) {
/* select current paint mode */
- paint_mode = workspace->object_mode & OB_MODE_ALL_PAINT;
+ paint_mode = ob->mode & OB_MODE_ALL_PAINT;
}
else {
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index a45e33e4654..0f22973c45d 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -566,11 +566,10 @@ static int brush_curve_preset_exec(bContext *C, wmOperator *op)
Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
if (br) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
- BKE_paint_invalidate_cursor_overlay(scene, view_layer, br->curve, workspace->object_mode);
+ BKE_paint_invalidate_cursor_overlay(scene, view_layer, br->curve);
}
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index f8ad943ffef..12fe55fb956 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -201,12 +201,9 @@ static void paint_last_stroke_update(Scene *scene, ARegion *ar, const float mval
/* Returns true if vertex paint mode is active */
int vertex_paint_mode_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- return (ob &&
- (ob->type == OB_MESH) &&
- ((Mesh *)ob->data)->totpoly &&
- (workspace->object_mode & OB_MODE_VERTEX_PAINT));
+
+ return ob && ob->mode == OB_MODE_VERTEX_PAINT && ((Mesh *)ob->data)->totpoly;
}
int vertex_paint_poll(bContext *C)
@@ -226,22 +223,18 @@ int vertex_paint_poll(bContext *C)
int weight_paint_mode_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- return (ob &&
- (ob->type == OB_MESH) &&
- ((Mesh *)ob->data)->totpoly &&
- (workspace->object_mode == OB_MODE_WEIGHT_PAINT));
+
+ return ob && ob->mode == OB_MODE_WEIGHT_PAINT && ((Mesh *)ob->data)->totpoly;
}
int weight_paint_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
ScrArea *sa;
if ((ob != NULL) &&
- (workspace->object_mode & OB_MODE_WEIGHT_PAINT) &&
+ (ob->mode & OB_MODE_WEIGHT_PAINT) &&
(BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) &&
(sa = CTX_wm_area(C)) &&
(sa->spacetype == SPACE_VIEW3D))
@@ -958,18 +951,17 @@ static void vertex_paint_init_session(const EvaluationContext *eval_ctx, Scene *
}
}
-static void vertex_paint_init_session_data(
- const EvaluationContext *eval_ctx, const ToolSettings *ts, Object *ob)
+static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
{
/* Create maps */
struct SculptVertexPaintGeomMap *gmap = NULL;
const Brush *brush = NULL;
- if (eval_ctx->object_mode == OB_MODE_VERTEX_PAINT) {
+ if (ob->mode == OB_MODE_VERTEX_PAINT) {
gmap = &ob->sculpt->mode.vpaint.gmap;
brush = BKE_paint_brush(&ts->vpaint->paint);
ob->sculpt->mode_type = OB_MODE_VERTEX_PAINT;
}
- else if (eval_ctx->object_mode == OB_MODE_WEIGHT_PAINT) {
+ else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
gmap = &ob->sculpt->mode.wpaint.gmap;
brush = BKE_paint_brush(&ts->wpaint->paint);
ob->sculpt->mode_type = OB_MODE_WEIGHT_PAINT;
@@ -998,7 +990,7 @@ static void vertex_paint_init_session_data(
}
/* Create average brush arrays */
- if (eval_ctx->object_mode == OB_MODE_VERTEX_PAINT) {
+ if (ob->mode == OB_MODE_VERTEX_PAINT) {
if (!brush_use_accumulate(brush)) {
if (ob->sculpt->mode.vpaint.previous_color == NULL) {
ob->sculpt->mode.vpaint.previous_color =
@@ -1009,7 +1001,7 @@ static void vertex_paint_init_session_data(
MEM_SAFE_FREE(ob->sculpt->mode.vpaint.previous_color);
}
}
- else if (eval_ctx->object_mode == OB_MODE_WEIGHT_PAINT) {
+ else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
if (!brush_use_accumulate(brush)) {
if (ob->sculpt->mode.wpaint.alpha_weight == NULL) {
ob->sculpt->mode.wpaint.alpha_weight =
@@ -1042,12 +1034,10 @@ static void vertex_paint_init_session_data(
* \{ */
static void ed_vwpaintmode_enter_generic(
- const EvaluationContext *eval_ctx,
- wmWindowManager *wm,
- WorkSpace *workspace, Scene *scene,
+ const EvaluationContext *eval_ctx, wmWindowManager *wm, Scene *scene,
Object *ob, const eObjectMode mode_flag)
{
- workspace->object_mode |= mode_flag;
+ ob->mode |= mode_flag;
Mesh *me = BKE_mesh_from_object(ob);
if (mode_flag == OB_MODE_VERTEX_PAINT) {
@@ -1091,44 +1081,40 @@ static void ed_vwpaintmode_enter_generic(
}
vertex_paint_init_session(eval_ctx, scene, ob);
-
- ED_workspace_object_mode_sync_from_object(wm, workspace, ob);
}
void ED_object_vpaintmode_enter_ex(
const EvaluationContext *eval_ctx, wmWindowManager *wm,
- WorkSpace *workspace, Scene *scene, Object *ob)
+ Scene *scene, Object *ob)
{
ed_vwpaintmode_enter_generic(
- eval_ctx, wm, workspace, scene, ob, OB_MODE_VERTEX_PAINT);
+ eval_ctx, wm, scene, ob, OB_MODE_VERTEX_PAINT);
}
void ED_object_vpaintmode_enter(struct bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
wmWindowManager *wm = CTX_wm_manager(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- ED_object_vpaintmode_enter_ex(&eval_ctx, wm, workspace, scene, ob);
+ ED_object_vpaintmode_enter_ex(&eval_ctx, wm, scene, ob);
}
void ED_object_wpaintmode_enter_ex(
const EvaluationContext *eval_ctx, wmWindowManager *wm,
- WorkSpace *workspace, Scene *scene, Object *ob)
+ Scene *scene, Object *ob)
{
ed_vwpaintmode_enter_generic(
- eval_ctx, wm, workspace, scene, ob, OB_MODE_WEIGHT_PAINT);
+ eval_ctx, wm, scene, ob, OB_MODE_WEIGHT_PAINT);
}
void ED_object_wpaintmode_enter(struct bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
wmWindowManager *wm = CTX_wm_manager(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- ED_object_wpaintmode_enter_ex(&eval_ctx, wm, workspace, scene, ob);
+ ED_object_wpaintmode_enter_ex(&eval_ctx, wm, scene, ob);
}
/** \} */
@@ -1138,11 +1124,10 @@ void ED_object_wpaintmode_enter(struct bContext *C)
* \{ */
static void ed_vwpaintmode_exit_generic(
- WorkSpace *workspace,
Object *ob, const eObjectMode mode_flag)
{
Mesh *me = BKE_mesh_from_object(ob);
- workspace->object_mode &= ~mode_flag;
+ ob->mode &= ~mode_flag;
if (mode_flag == OB_MODE_VERTEX_PAINT) {
if (me->editflag & ME_EDIT_PAINT_FACE_SEL) {
@@ -1178,30 +1163,26 @@ static void ed_vwpaintmode_exit_generic(
ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e');
ED_mesh_mirror_topo_table(NULL, NULL, 'e');
}
-
- ED_workspace_object_mode_sync_from_object(G.main->wm.first, workspace, ob);
}
-void ED_object_vpaintmode_exit_ex(WorkSpace *workspace, Object *ob)
+void ED_object_vpaintmode_exit_ex(Object *ob)
{
- ed_vwpaintmode_exit_generic(workspace, ob, OB_MODE_VERTEX_PAINT);
+ ed_vwpaintmode_exit_generic(ob, OB_MODE_VERTEX_PAINT);
}
void ED_object_vpaintmode_exit(struct bContext *C)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- ED_object_vpaintmode_exit_ex(workspace, ob);
+ ED_object_vpaintmode_exit_ex(ob);
}
-void ED_object_wpaintmode_exit_ex(WorkSpace *workspace, Object *ob)
+void ED_object_wpaintmode_exit_ex(Object *ob)
{
- ed_vwpaintmode_exit_generic(workspace, ob, OB_MODE_WEIGHT_PAINT);
+ ed_vwpaintmode_exit_generic(ob, OB_MODE_WEIGHT_PAINT);
}
void ED_object_wpaintmode_exit(struct bContext *C)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- ED_object_wpaintmode_exit_ex(workspace, ob);
+ ED_object_wpaintmode_exit_ex(ob);
}
/** \} */
@@ -1213,14 +1194,13 @@ void ED_object_wpaintmode_exit(struct bContext *C)
*/
static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_WEIGHT_PAINT;
- const bool is_mode_set = (workspace->object_mode & mode_flag) != 0;
+ const bool is_mode_set = (ob->mode & mode_flag) != 0;
Scene *scene = CTX_data_scene(C);
if (!is_mode_set) {
- if (!ED_object_mode_compat_set(C, workspace, mode_flag, op->reports)) {
+ if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
}
}
@@ -1228,17 +1208,15 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
Mesh *me = BKE_mesh_from_object(ob);
if (is_mode_set) {
- ED_object_wpaintmode_exit_ex(workspace, ob);
+ ED_object_wpaintmode_exit_ex(ob);
}
else {
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
wmWindowManager *wm = CTX_wm_manager(C);
- ED_object_wpaintmode_enter_ex(&eval_ctx, wm, workspace, scene, ob);
+ ED_object_wpaintmode_enter_ex(&eval_ctx, wm, scene, ob);
}
- BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
-
/* Weightpaint works by overriding colors in mesh,
* so need to make sure we recalc on enter and
* exit (exit needs doing regardless because we
@@ -1427,14 +1405,11 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
bool *defbase_sel;
SculptSession *ss = ob->sculpt;
VPaint *vp = CTX_data_tool_settings(C)->wpaint;
- EvaluationContext eval_ctx;
if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, &vgroup_index) == false) {
return false;
}
- CTX_data_eval_ctx(C, &eval_ctx);
-
{
/* check if we are attempting to paint onto a locked vertex group,
* and other options disallow it from doing anything useful */
@@ -1532,10 +1507,13 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
wpd->precomputed_weight = MEM_mallocN(sizeof(float) * me->totvert, __func__);
}
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* If not previously created, create vertex/weight paint mode session data */
vertex_paint_init_session(&eval_ctx, scene, ob);
vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
- vertex_paint_init_session_data(&eval_ctx, ts, ob);
+ vertex_paint_init_session_data(ts, ob);
if (ob->sculpt->mode.wpaint.dvert_prev != NULL) {
MDeformVert *dv = ob->sculpt->mode.wpaint.dvert_prev;
@@ -2351,14 +2329,13 @@ void PAINT_OT_weight_paint(wmOperatorType *ot)
*/
static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_VERTEX_PAINT;
- const bool is_mode_set = (workspace->object_mode & mode_flag) != 0;
+ const bool is_mode_set = (ob->mode & mode_flag) != 0;
Scene *scene = CTX_data_scene(C);
if (!is_mode_set) {
- if (!ED_object_mode_compat_set(C, workspace, mode_flag, op->reports)) {
+ if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
}
}
@@ -2367,13 +2344,13 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
/* toggle: end vpaint */
if (is_mode_set) {
- ED_object_vpaintmode_exit_ex(workspace, ob);
+ ED_object_vpaintmode_exit_ex(ob);
}
else {
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
wmWindowManager *wm = CTX_wm_manager(C);
- ED_object_vpaintmode_enter_ex(&eval_ctx, wm, workspace, scene, ob);
+ ED_object_vpaintmode_enter_ex(&eval_ctx, wm, scene, ob);
}
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
@@ -2522,7 +2499,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
/* If not previously created, create vertex/weight paint mode session data */
vertex_paint_init_session(&eval_ctx, scene, ob);
vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
- vertex_paint_init_session_data(&eval_ctx, ts, ob);
+ vertex_paint_init_session_data(ts, ob);
if (ob->sculpt->mode.vpaint.previous_color != NULL) {
memset(ob->sculpt->mode.vpaint.previous_color, 0, sizeof(uint) * me->totloop);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
index f442c12cbe9..d7668a48139 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
@@ -28,7 +28,6 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "DNA_workspace_types.h"
#include "BLI_math_base.h"
#include "BLI_math_color.h"
@@ -52,10 +51,9 @@
static int vertex_weight_paint_mode_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
Mesh *me = BKE_mesh_from_object(ob);
- return (ob && ELEM(workspace->object_mode, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT)) &&
+ return (ob && (ob->mode == OB_MODE_VERTEX_PAINT || ob->mode == OB_MODE_WEIGHT_PAINT)) &&
(me && me->totpoly && me->dvert);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 7ff9c3851ac..3892b776440 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -118,10 +118,9 @@ static void wpaint_prev_destroy(struct WPaintPrev *wpp)
static int weight_from_bones_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- return (ob && (workspace->object_mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob));
+ return (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob));
}
static int weight_from_bones_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index ce34fb6d05d..4a9d2597415 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4083,9 +4083,8 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
int sculpt_mode_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- return ob && workspace->object_mode & OB_MODE_SCULPT;
+ return ob && ob->mode & OB_MODE_SCULPT;
}
int sculpt_mode_poll_view3d(bContext *C)
@@ -5220,7 +5219,7 @@ void sculpt_pbvh_clear(Object *ob)
BKE_pbvh_free(ss->pbvh);
ss->pbvh = NULL;
if (dm)
- dm->getPBVH(NULL, dm, OB_MODE_OBJECT);
+ dm->getPBVH(NULL, dm);
BKE_object_free_derived_caches(ob);
}
@@ -5649,14 +5648,14 @@ static int ed_object_sculptmode_flush_recalc_flag(Scene *scene, Object *ob, Mult
void ED_object_sculptmode_enter_ex(
const EvaluationContext *eval_ctx,
- WorkSpace *workspace, Scene *scene, Object *ob,
+ Scene *scene, Object *ob,
ReportList *reports)
{
const int mode_flag = OB_MODE_SCULPT;
Mesh *me = BKE_mesh_from_object(ob);
/* Enter sculptmode */
- workspace->object_mode |= mode_flag;
+ ob->mode |= mode_flag;
MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
@@ -5739,7 +5738,7 @@ void ED_object_sculptmode_enter_ex(
}
}
- ED_workspace_object_mode_sync_from_object(G.main->wm.first, workspace, ob);
+ // ED_workspace_object_mode_sync_from_object(G.main->wm.first, workspace, ob);
/* VBO no longer valid */
if (ob->derivedFinal) {
@@ -5749,17 +5748,16 @@ void ED_object_sculptmode_enter_ex(
void ED_object_sculptmode_enter(struct bContext *C, ReportList *reports)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
- ED_object_sculptmode_enter_ex(&eval_ctx, workspace, scene, ob, reports);
+ ED_object_sculptmode_enter_ex(&eval_ctx, scene, ob, reports);
}
void ED_object_sculptmode_exit_ex(
const EvaluationContext *eval_ctx,
- WorkSpace *workspace, Scene *scene, Object *ob)
+ Scene *scene, Object *ob)
{
const int mode_flag = OB_MODE_SCULPT;
Mesh *me = BKE_mesh_from_object(ob);
@@ -5792,9 +5790,9 @@ void ED_object_sculptmode_exit_ex(
}
/* Leave sculptmode */
- workspace->object_mode &= ~mode_flag;
+ ob->mode &= ~mode_flag;
- ED_workspace_object_mode_sync_from_object(G.main->wm.first, workspace, ob);
+ // ED_workspace_object_mode_sync_from_object(G.main->wm.first, workspace, ob);
BKE_sculptsession_free(ob);
@@ -5808,24 +5806,22 @@ void ED_object_sculptmode_exit_ex(
void ED_object_sculptmode_exit(bContext *C)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
- ED_object_sculptmode_exit_ex(&eval_ctx, workspace, scene, ob);
+ ED_object_sculptmode_exit_ex(&eval_ctx, scene, ob);
}
static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_SCULPT;
- const bool is_mode_set = (workspace->object_mode & mode_flag) != 0;
+ const bool is_mode_set = (ob->mode & mode_flag) != 0;
if (!is_mode_set) {
- if (!ED_object_mode_compat_set(C, workspace, mode_flag, op->reports)) {
+ if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
}
}
@@ -5834,10 +5830,10 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
CTX_data_eval_ctx(C, &eval_ctx);
if (is_mode_set) {
- ED_object_sculptmode_exit_ex(&eval_ctx, workspace, scene, ob);
+ ED_object_sculptmode_exit_ex(&eval_ctx, scene, ob);
}
else {
- ED_object_sculptmode_enter_ex(&eval_ctx, workspace, scene, ob, op->reports);
+ ED_object_sculptmode_enter_ex(&eval_ctx, scene, ob, op->reports);
}
WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 694e1f048f5..e12ef2df4ab 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -1020,9 +1020,8 @@ static bool sculpt_undosys_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
if (sa && (sa->spacetype == SPACE_VIEW3D)) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *obact = CTX_data_active_object(C);
- if (obact && (workspace->object_mode & OB_MODE_SCULPT)) {
+ if (obact && (obact->mode & OB_MODE_SCULPT)) {
return true;
}
}
diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt
index ec866780122..397d79e1dbe 100644
--- a/source/blender/editors/space_buttons/CMakeLists.txt
+++ b/source/blender/editors/space_buttons/CMakeLists.txt
@@ -23,7 +23,6 @@ set(INC
../../blenkernel
../../blenlib
../../blentranslation
- ../../depsgraph
../../gpu
../../makesdna
../../makesrna
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index ebb14d3caeb..8866c6b6c40 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -62,8 +62,6 @@
#include "RNA_access.h"
-#include "DEG_depsgraph.h"
-
#include "ED_buttons.h"
#include "ED_armature.h"
#include "ED_screen.h"
@@ -425,9 +423,8 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
scene = path->ptr[path->len - 1].data;
if (scene) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer, workspace->object_mode));
+ br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer));
}
if (br) {
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index 95ed8967380..c719af9e0e2 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -323,16 +323,15 @@ bool ED_image_slot_cycle(struct Image *image, int direction)
void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *sima, struct ImBuf *ibuf, bool use_view_settings)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
-
+
/* scope update can be expensive, don't update during paint modes */
if (sima->mode == SI_MODE_PAINT)
return;
- if (ob && ((workspace->object_mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) {
+ if (ob && ((ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0))
return;
- }
+
/* We also don't update scopes of render result during render. */
if (G.is_rendering) {
const Image *image = sima->image;
@@ -377,12 +376,11 @@ bool ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
}
/* matches clip function */
-bool ED_space_image_check_show_maskedit(
- SpaceImage *sima, const WorkSpace *workspace, ViewLayer *view_layer)
+bool ED_space_image_check_show_maskedit(SpaceImage *sima, ViewLayer *view_layer)
{
/* check editmode - this is reserved for UV editing */
Object *ob = OBACT(view_layer);
- if (ob && (workspace->object_mode & OB_MODE_EDIT) && ED_space_image_show_uvedit(sima, ob)) {
+ if (ob && ob->mode & OB_MODE_EDIT && ED_space_image_show_uvedit(sima, ob)) {
return false;
}
@@ -392,10 +390,10 @@ bool ED_space_image_check_show_maskedit(
int ED_space_image_maskedit_poll(bContext *C)
{
SpaceImage *sima = CTX_wm_space_image(C);
+
if (sima) {
- WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- return ED_space_image_check_show_maskedit(sima, workspace, view_layer);
+ return ED_space_image_check_show_maskedit(sima, view_layer);
}
return false;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 711f8732d71..9162b8b76a9 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -275,12 +275,11 @@ int space_image_main_region_poll(bContext *C)
/* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode or editmode */
static int space_image_main_area_not_uv_brush_poll(bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *toolsettings = scene->toolsettings;
- if (sima && !toolsettings->uvsculpt && ((workspace->object_mode & OB_MODE_EDIT) == 0)) {
+ if (sima && !toolsettings->uvsculpt && (CTX_data_edit_object(C) == NULL)) {
return 1;
}
@@ -793,7 +792,6 @@ void IMAGE_OT_view_all(wmOperatorType *ot)
static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
{
- WorkSpace *workspace = CTX_wm_workspace(C);
SpaceImage *sima;
ARegion *ar;
Scene *scene;
@@ -817,7 +815,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
}
- else if (ED_space_image_check_show_maskedit(sima, workspace, view_layer)) {
+ else if (ED_space_image_check_show_maskedit(sima, view_layer)) {
if (!ED_mask_selected_minmax(C, min, max)) {
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index c66d588c50d..54037059cc3 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -551,7 +551,7 @@ static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sc
{
ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace);
Object *ob = OBACT(view_layer);
- if (ob && (ob == wmn->reference) && (workspace->object_mode & OB_MODE_EDIT)) {
+ if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) {
if (sima->lock && (sima->flag & SI_DRAWSHADOW)) {
ED_area_tag_refresh(sa);
ED_area_tag_redraw(sa);
@@ -725,9 +725,6 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar)
static void image_main_region_draw(const bContext *C, ARegion *ar)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* draw entirely, view changes should be handled here */
SpaceImage *sima = CTX_wm_space_image(C);
Object *obact = CTX_data_active_object(C);
@@ -762,7 +759,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
- ED_uvedit_draw_main(sima, &eval_ctx, ar, scene, view_layer, obedit, obact, depsgraph);
+ ED_uvedit_draw_main(sima, ar, scene, view_layer, obedit, obact, depsgraph);
/* check for mask (delay draw) */
if (ED_space_image_show_uvedit(sima, obedit)) {
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index 800560c380c..157171481bc 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -36,7 +36,6 @@
#include "DNA_lattice_types.h"
#include "DNA_meta_types.h"
#include "DNA_scene_types.h"
-#include "DNA_workspace_types.h"
#include "BLI_math.h"
#include "BLI_string.h"
@@ -375,21 +374,22 @@ static bool stats_is_object_dynamic_topology_sculpt(Object *ob, const eObjectMod
}
/* Statistics displayed in info header. Called regularly on scene changes. */
-static void stats_update(ViewLayer *view_layer, Object *obedit, const eObjectMode object_mode)
+static void stats_update(ViewLayer *view_layer)
{
SceneStats stats = {0};
- Object *ob = (view_layer->basact) ? view_layer->basact->object : NULL;
+ Object *ob = OBACT(view_layer);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
Base *base;
if (obedit) {
/* Edit Mode */
stats_object_edit(ob, &stats);
}
- else if (ob && (object_mode & OB_MODE_POSE)) {
+ else if (ob && (ob->mode & OB_MODE_POSE)) {
/* Pose Mode */
stats_object_pose(ob, &stats);
}
- else if (stats_is_object_dynamic_topology_sculpt(ob, object_mode)) {
+ else if (stats_is_object_dynamic_topology_sculpt(ob, ob->mode)) {
/* Dynamic-topology sculpt mode */
stats_object_sculpt_dynamic_topology(ob, &stats);
}
@@ -408,12 +408,14 @@ static void stats_update(ViewLayer *view_layer, Object *obedit, const eObjectMod
*(view_layer->stats) = stats;
}
-static void stats_string(ViewLayer *view_layer, Object *obedit, const eObjectMode object_mode)
+static void stats_string(ViewLayer *view_layer)
{
#define MAX_INFO_MEM_LEN 64
SceneStats *stats = view_layer->stats;
SceneStatsFmt stats_fmt;
- Object *ob = (view_layer->basact) ? view_layer->basact->object : NULL;
+ Object *ob = OBACT(view_layer);
+ Object *obedit = OBEDIT_FROM_OBACT(ob);
+ eObjectMode object_mode = ob ? ob->mode : OB_MODE_OBJECT;
uintptr_t mem_in_use, mmap_in_use;
char memstr[MAX_INFO_MEM_LEN];
char gpumemstr[MAX_INFO_MEM_LEN] = "";
@@ -528,16 +530,11 @@ void ED_info_stats_clear(ViewLayer *view_layer)
}
}
-const char *ED_info_stats_string(Scene *UNUSED(scene), WorkSpace *workspace, ViewLayer *view_layer)
+const char *ED_info_stats_string(Scene *UNUSED(scene), ViewLayer *view_layer)
{
- Object *obact = (view_layer->basact) ? view_layer->basact->object : NULL;
- Object *obedit = (obact && (workspace->object_mode & OB_MODE_EDIT) &&
- BKE_object_is_in_editmode(obact)) ? obact : NULL;
-
if (!view_layer->stats) {
- stats_update(view_layer, obedit, workspace->object_mode);
+ stats_update(view_layer);
}
- stats_string(view_layer, obedit, workspace->object_mode);
-
+ stats_string(view_layer);
return view_layer->stats->infostr;
}
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 90e59a677ac..15b411280a5 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1902,10 +1902,10 @@ void draw_outliner(const bContext *C)
{
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
- Object *obedit = OBEDIT_FROM_EVAL_CTX(&eval_ctx);
Main *mainvar = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
SpaceOops *soops = CTX_wm_space_outliner(C);
@@ -1914,7 +1914,7 @@ void draw_outliner(const bContext *C)
TreeElement *te_edit = NULL;
bool has_restrict_icons;
- outliner_build_tree(mainvar, &eval_ctx, scene, view_layer, soops, ar); // always
+ outliner_build_tree(mainvar, scene, view_layer, soops, ar); // always
/* get extents of data */
outliner_height(soops, &soops->tree, &sizey);
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 93e9b77a837..f5d117922c0 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -63,7 +63,6 @@
#include "BKE_material.h"
#include "BKE_group.h"
-#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "../blenloader/BLO_readfile.h"
@@ -977,7 +976,6 @@ static int outliner_open_back(TreeElement *te)
static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
SpaceOops *so = CTX_wm_space_outliner(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ARegion *ar = CTX_wm_region(C);
@@ -998,13 +996,13 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
/* traverse down the bone hierarchy in case of armature */
TreeElement *te_obact = te;
- if (workspace->object_mode & OB_MODE_POSE) {
+ if (obact->mode & OB_MODE_POSE) {
bPoseChannel *pchan = CTX_data_active_pose_bone(C);
if (pchan) {
te = outliner_find_posechannel(&te_obact->subtree, pchan);
}
}
- else if (workspace->object_mode & OB_MODE_EDIT) {
+ else if (obact->mode & OB_MODE_EDIT) {
EditBone *ebone = CTX_data_active_bone(C);
if (ebone) {
te = outliner_find_editbone(&te_obact->subtree, ebone);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 148af52050d..bedd2f09f3b 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -193,7 +193,7 @@ void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree);
void outliner_remove_treestore_element(struct SpaceOops *soops, TreeStoreElem *tselem);
void outliner_build_tree(
- struct Main *mainvar, const struct EvaluationContext *eval_ctx,
+ struct Main *mainvar,
struct Scene *scene, struct ViewLayer *view_layer,
struct SpaceOops *soops, struct ARegion *ar);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 018756f2a99..bfa8633ab7d 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -193,10 +193,10 @@ static eOLDrawState tree_element_set_active_object(
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
}
-
- if (CTX_data_edit_object(C)) {
+
+ if (ob != OBEDIT_FROM_VIEW_LAYER(view_layer))
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
- }
+
return OL_DRAWSEL_NORMAL;
}
@@ -658,7 +658,6 @@ static eOLDrawState tree_element_active_text(
static eOLDrawState tree_element_active_pose(
bContext *C, ViewLayer *view_layer, TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = (Object *)tselem->id;
Base *base = BKE_view_layer_base_find(view_layer, ob);
@@ -668,18 +667,16 @@ static eOLDrawState tree_element_active_pose(
}
if (set != OL_SETSEL_NONE) {
- if (workspace->object_mode & OB_MODE_EDIT) {
+ if (OBEDIT_FROM_VIEW_LAYER(view_layer))
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
- }
- if (workspace->object_mode & OB_MODE_POSE) {
+
+ if (ob->mode & OB_MODE_POSE)
ED_armature_exit_posemode(C, base);
- }
- else {
+ else
ED_armature_enter_posemode(C, base);
- }
}
else {
- if (workspace->object_mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
return OL_DRAWSEL_NORMAL;
}
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 8c6d7783f01..eff726868c7 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -92,12 +92,10 @@
/* prototypes */
static void outliner_add_layer_collections_recursive(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *tree, ID *id, ListBase *layer_collections, TreeElement *parent_ten,
+ SpaceOops *soops, ListBase *tree, ID *id, ListBase *layer_collections, TreeElement *parent_ten,
const bool show_objects);
static void outliner_add_view_layer(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *tree, TreeElement *parent,
+ SpaceOops *soops, ListBase *tree, TreeElement *parent,
Scene *scene, ViewLayer *layer, const bool show_objects);
static void outliner_make_hierarchy(ListBase *lb);
@@ -235,25 +233,23 @@ void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree)
/* ********************************************************* */
/* Prototype, see functions below */
-static TreeElement *outliner_add_element(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *lb, void *idv, TreeElement *parent, short type, short index);
+static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv,
+ TreeElement *parent, short type, short index);
/* -------------------------------------------------------- */
/* special handling of hierarchical non-lib data */
-static void outliner_add_bone(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *lb, ID *id, Bone *curBone, TreeElement *parent, int *a)
+static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone,
+ TreeElement *parent, int *a)
{
- TreeElement *te = outliner_add_element(soops, eval_ctx, lb, id, parent, TSE_BONE, *a);
+ TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a);
(*a)++;
te->name = curBone->name;
te->directdata = curBone;
for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) {
- outliner_add_bone(soops, eval_ctx, &te->subtree, id, curBone, te, a);
+ outliner_add_bone(soops, &te->subtree, id, curBone, te, a);
}
}
@@ -261,9 +257,7 @@ static void outliner_add_bone(
#define LOG2I(x) (int)(log(x) / M_LN2)
-static void outliner_add_passes(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- TreeElement *tenla, ID *id, ViewLayer *view_layer)
+static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, ViewLayer *view_layer)
{
TreeStoreElem *tselem = NULL;
TreeElement *te = NULL;
@@ -271,7 +265,7 @@ static void outliner_add_passes(
/* log stuff is to convert bitflags (powers of 2) to small integers,
* in order to not overflow short tselem->nr */
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED));
te->name = IFACE_("Combined");
te->directdata = &view_layer->passflag;
@@ -280,71 +274,71 @@ static void outliner_add_passes(
if (tselem->flag & TSE_CLOSED)
return;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z));
te->name = IFACE_("Z");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR));
te->name = IFACE_("Vector");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL));
te->name = IFACE_("Normal");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV));
te->name = IFACE_("UV");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST));
te->name = IFACE_("Mist");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB));
te->name = IFACE_("Index Object");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA));
te->name = IFACE_("Index Material");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA));
te->name = IFACE_("Color");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE));
te->name = IFACE_("Diffuse");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC));
te->name = IFACE_("Specular");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW));
te->name = IFACE_("Shadow");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO));
te->name = IFACE_("AO");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT));
te->name = IFACE_("Reflection");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT));
te->name = IFACE_("Refraction");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT));
te->name = IFACE_("Indirect");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT));
te->name = IFACE_("Environment");
te->directdata = &view_layer->passflag;
- te = outliner_add_element(soops, eval_ctx, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT));
+ te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT));
te->name = IFACE_("Emit");
te->directdata = &view_layer->passflag;
}
@@ -379,43 +373,41 @@ static void outliner_add_line_styles(SpaceOops *soops, ListBase *lb, Scene *sce,
if (!(linestyle->id.tag & LIB_TAG_DOIT))
continue;
linestyle->id.tag &= ~LIB_TAG_DOIT;
- outliner_add_element(soops, eval_ctx, lb, linestyle, te, 0, 0);
+ outliner_add_element(soops, lb, linestyle, te, 0, 0);
}
}
}
}
#endif
-static void outliner_add_scene_contents(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *lb, Scene *sce, TreeElement *te)
+static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te)
{
ViewLayer *view_layer;
- TreeElement *tenla = outliner_add_element(soops, eval_ctx, lb, sce, te, TSE_R_LAYER_BASE, 0);
+ TreeElement *tenla = outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0);
int a;
tenla->name = IFACE_("View Layers");
for (a = 0, view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next, a++) {
- TreeElement *tenlay = outliner_add_element(soops, eval_ctx, &tenla->subtree, sce, te, TSE_R_LAYER, a);
+ TreeElement *tenlay = outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a);
tenlay->name = view_layer->name;
tenlay->directdata = &view_layer->flag;
TreeElement *te_view_layers;
- te_view_layers = outliner_add_element(soops, eval_ctx, &tenlay->subtree, sce, tenlay, TSE_LAYER_COLLECTION_BASE, 0);
+ te_view_layers = outliner_add_element(soops, &tenlay->subtree, sce, tenlay, TSE_LAYER_COLLECTION_BASE, 0);
te_view_layers->name = IFACE_("Collections");
- outliner_add_view_layer(soops, eval_ctx, &te_view_layers->subtree, te_view_layers, sce, view_layer, false);
+ outliner_add_view_layer(soops, &te_view_layers->subtree, te_view_layers, sce, view_layer, false);
TreeElement *te_passes;
- te_passes = outliner_add_element(soops, eval_ctx, &tenlay->subtree, sce, tenlay, TSE_LAYER_COLLECTION_BASE, 0);
+ te_passes = outliner_add_element(soops, &tenlay->subtree, sce, tenlay, TSE_LAYER_COLLECTION_BASE, 0);
te_passes->name = IFACE_("Passes");
- outliner_add_passes(soops, eval_ctx, te_passes, &sce->id, view_layer);
+ outliner_add_passes(soops, te_passes, &sce->id, view_layer);
}
// TODO: move this to the front?
if (outliner_animdata_test(sce->adt))
- outliner_add_element(soops, eval_ctx, lb, sce, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0);
- outliner_add_element(soops, eval_ctx, lb, sce->gpd, te, 0, 0);
+ outliner_add_element(soops, lb, sce->gpd, te, 0, 0);
#ifdef WITH_FREESTYLE
if (STREQ(sce->view_render->engine_id, RE_engine_id_BLENDER_RENDER) && (sce->r.mode & R_EDGE_FRS))
@@ -520,41 +512,37 @@ static bool outliner_object_reorder_poll(
}
// can be inlined if necessary
-static void outliner_add_object_contents(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- TreeElement *te, TreeStoreElem *tselem, Object *ob)
+static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, Object *ob)
{
te->reinsert = outliner_object_reorder;
te->reinsert_poll = outliner_object_reorder_poll;
if (outliner_animdata_test(ob->adt))
- outliner_add_element(soops, eval_ctx, &te->subtree, ob, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0);
- outliner_add_element(soops, eval_ctx, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this
+ outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this
if (ob->proxy && !ID_IS_LINKED(ob))
- outliner_add_element(soops, eval_ctx, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
+ outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
- outliner_add_element(soops, eval_ctx, &te->subtree, ob->gpd, te, 0, 0);
+ outliner_add_element(soops, &te->subtree, ob->gpd, te, 0, 0);
- outliner_add_element(soops, eval_ctx, &te->subtree, ob->data, te, 0, 0);
+ outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0);
if (ob->pose) {
bArmature *arm = ob->data;
bPoseChannel *pchan;
- TreeElement *tenla = outliner_add_element(
- soops, eval_ctx, &te->subtree, ob, te, TSE_POSE_BASE, 0);
+ TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0);
tenla->name = IFACE_("Pose");
/* channels undefined in editmode, but we want the 'tenla' pose icon itself */
- if ((arm->edbo == NULL) && (eval_ctx->object_mode & OB_MODE_POSE)) {
+ if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) {
TreeElement *ten;
int a = 0, const_index = 1000; /* ensure unique id for bone constraints */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, a++) {
- ten = outliner_add_element(
- soops, eval_ctx, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a);
+ ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a);
ten->name = pchan->name;
ten->directdata = pchan;
pchan->temp = (void *)ten;
@@ -563,14 +551,12 @@ static void outliner_add_object_contents(
//Object *target;
bConstraint *con;
TreeElement *ten1;
- TreeElement *tenla1 = outliner_add_element(
- soops, eval_ctx, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
+ TreeElement *tenla1 = outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
//char *str;
tenla1->name = IFACE_("Constraints");
for (con = pchan->constraints.first; con; con = con->next, const_index++) {
- ten1 = outliner_add_element(
- soops, eval_ctx, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index);
+ ten1 = outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index);
#if 0 /* disabled as it needs to be reworked for recoded constraints system */
target = get_constraint_target(con, &str);
if (str && str[0]) ten1->name = str;
@@ -604,15 +590,13 @@ static void outliner_add_object_contents(
/* Pose Groups */
if (ob->pose->agroups.first) {
bActionGroup *agrp;
- TreeElement *ten_bonegrp = outliner_add_element(
- soops, eval_ctx, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0);
+ TreeElement *ten_bonegrp = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0);
int a = 0;
ten_bonegrp->name = IFACE_("Bone Groups");
for (agrp = ob->pose->agroups.first; agrp; agrp = agrp->next, a++) {
TreeElement *ten;
- ten = outliner_add_element(
- soops, eval_ctx, &ten_bonegrp->subtree, ob, ten_bonegrp, TSE_POSEGRP, a);
+ ten = outliner_add_element(soops, &ten_bonegrp->subtree, ob, ten_bonegrp, TSE_POSEGRP, a);
ten->name = agrp->name;
ten->directdata = agrp;
}
@@ -620,21 +604,20 @@ static void outliner_add_object_contents(
}
for (int a = 0; a < ob->totcol; a++) {
- outliner_add_element(
- soops, eval_ctx, &te->subtree, ob->mat[a], te, 0, a);
+ outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a);
}
if (ob->constraints.first) {
//Object *target;
bConstraint *con;
TreeElement *ten;
- TreeElement *tenla = outliner_add_element(soops, eval_ctx, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0);
+ TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0);
//char *str;
int a;
tenla->name = IFACE_("Constraints");
for (con = ob->constraints.first, a = 0; con; con = con->next, a++) {
- ten = outliner_add_element(soops, eval_ctx, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a);
+ ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a);
#if 0 /* disabled due to constraints system targets recode... code here needs review */
target = get_constraint_target(con, &str);
if (str && str[0]) ten->name = str;
@@ -649,38 +632,32 @@ static void outliner_add_object_contents(
if (ob->modifiers.first) {
ModifierData *md;
- TreeElement *ten_mod = outliner_add_element(soops, eval_ctx, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0);
+ TreeElement *ten_mod = outliner_add_element(soops, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0);
int index;
ten_mod->name = IFACE_("Modifiers");
for (index = 0, md = ob->modifiers.first; md; index++, md = md->next) {
- TreeElement *ten = outliner_add_element(
- soops, eval_ctx, &ten_mod->subtree, ob, ten_mod, TSE_MODIFIER, index);
+ TreeElement *ten = outliner_add_element(soops, &ten_mod->subtree, ob, ten_mod, TSE_MODIFIER, index);
ten->name = md->name;
ten->directdata = md;
if (md->type == eModifierType_Lattice) {
- outliner_add_element(
- soops, eval_ctx, &ten->subtree, ((LatticeModifierData *) md)->object, ten, TSE_LINKED_OB, 0);
+ outliner_add_element(soops, &ten->subtree, ((LatticeModifierData *) md)->object, ten, TSE_LINKED_OB, 0);
}
else if (md->type == eModifierType_Curve) {
- outliner_add_element(
- soops, eval_ctx, &ten->subtree, ((CurveModifierData *) md)->object, ten, TSE_LINKED_OB, 0);
+ outliner_add_element(soops, &ten->subtree, ((CurveModifierData *) md)->object, ten, TSE_LINKED_OB, 0);
}
else if (md->type == eModifierType_Armature) {
- outliner_add_element(
- soops, eval_ctx, &ten->subtree, ((ArmatureModifierData *) md)->object, ten, TSE_LINKED_OB, 0);
+ outliner_add_element(soops, &ten->subtree, ((ArmatureModifierData *) md)->object, ten, TSE_LINKED_OB, 0);
}
else if (md->type == eModifierType_Hook) {
- outliner_add_element(
- soops, eval_ctx, &ten->subtree, ((HookModifierData *) md)->object, ten, TSE_LINKED_OB, 0);
+ outliner_add_element(soops, &ten->subtree, ((HookModifierData *) md)->object, ten, TSE_LINKED_OB, 0);
}
else if (md->type == eModifierType_ParticleSystem) {
ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys;
TreeElement *ten_psys;
- ten_psys = outliner_add_element(
- soops, eval_ctx, &ten->subtree, ob, te, TSE_LINKED_PSYS, 0);
+ ten_psys = outliner_add_element(soops, &ten->subtree, ob, te, TSE_LINKED_PSYS, 0);
ten_psys->directdata = psys;
ten_psys->name = psys->part->id.name + 2;
}
@@ -691,29 +668,25 @@ static void outliner_add_object_contents(
if (ob->defbase.first) {
bDeformGroup *defgroup;
TreeElement *ten;
- TreeElement *tenla = outliner_add_element(
- soops, eval_ctx, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0);
+ TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0);
int a;
tenla->name = IFACE_("Vertex Groups");
for (defgroup = ob->defbase.first, a = 0; defgroup; defgroup = defgroup->next, a++) {
- ten = outliner_add_element(soops, eval_ctx, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a);
+ ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a);
ten->name = defgroup->name;
ten->directdata = defgroup;
}
}
/* duplicated group */
- if (ob->dup_group) {
- outliner_add_element(soops, eval_ctx, &te->subtree, ob->dup_group, te, 0, 0);
- }
+ if (ob->dup_group)
+ outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0);
}
// can be inlined if necessary
-static void outliner_add_id_contents(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- TreeElement *te, TreeStoreElem *tselem, ID *id)
+static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, ID *id)
{
/* tuck pointer back in object, to construct hierarchy */
if (GS(id->name) == ID_OB) id->newid = (ID *)te;
@@ -727,26 +700,25 @@ static void outliner_add_id_contents(
}
case ID_SCE:
{
- outliner_add_scene_contents(soops, eval_ctx, &te->subtree, (Scene *)id, te);
+ outliner_add_scene_contents(soops, &te->subtree, (Scene *)id, te);
break;
}
case ID_OB:
{
- outliner_add_object_contents(soops, eval_ctx, te, tselem, (Object *)id);
+ outliner_add_object_contents(soops, te, tselem, (Object *)id);
break;
}
case ID_ME:
{
Mesh *me = (Mesh *)id;
int a;
-
- if (outliner_animdata_test(me->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, me, te, TSE_ANIM_DATA, 0);
- }
-
- outliner_add_element(soops, eval_ctx, &te->subtree, me->key, te, 0, 0);
+
+ if (outliner_animdata_test(me->adt))
+ outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0);
+
+ outliner_add_element(soops, &te->subtree, me->key, te, 0, 0);
for (a = 0; a < me->totcol; a++)
- outliner_add_element(soops, eval_ctx, &te->subtree, me->mat[a], te, 0, a);
+ outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a);
/* could do tfaces with image links, but the images are not grouped nicely.
* would require going over all tfaces, sort images in use. etc... */
break;
@@ -757,10 +729,10 @@ static void outliner_add_id_contents(
int a;
if (outliner_animdata_test(cu->adt))
- outliner_add_element(soops, eval_ctx, &te->subtree, cu, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0);
for (a = 0; a < cu->totcol; a++)
- outliner_add_element(soops, eval_ctx, &te->subtree, cu->mat[a], te, 0, a);
+ outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a);
break;
}
case ID_MB:
@@ -769,10 +741,10 @@ static void outliner_add_id_contents(
int a;
if (outliner_animdata_test(mb->adt))
- outliner_add_element(soops, eval_ctx, &te->subtree, mb, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0);
for (a = 0; a < mb->totcol; a++)
- outliner_add_element(soops, eval_ctx, &te->subtree, mb->mat[a], te, 0, a);
+ outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a);
break;
}
case ID_MA:
@@ -780,14 +752,11 @@ static void outliner_add_id_contents(
Material *ma = (Material *)id;
int a;
- if (outliner_animdata_test(ma->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, ma, te, TSE_ANIM_DATA, 0);
- }
+ if (outliner_animdata_test(ma->adt))
+ outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0);
for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- outliner_add_element(soops, eval_ctx, &te->subtree, ma->mtex[a]->tex, te, 0, a);
- }
+ if (ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a);
}
break;
}
@@ -795,10 +764,10 @@ static void outliner_add_id_contents(
{
Tex *tex = (Tex *)id;
- if (outliner_animdata_test(tex->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, tex, te, TSE_ANIM_DATA, 0);
- }
- outliner_add_element(soops, eval_ctx, &te->subtree, tex->ima, te, 0, 0);
+ if (outliner_animdata_test(tex->adt))
+ outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0);
+
+ outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0);
break;
}
case ID_CA:
@@ -806,7 +775,7 @@ static void outliner_add_id_contents(
Camera *ca = (Camera *)id;
if (outliner_animdata_test(ca->adt))
- outliner_add_element(soops, eval_ctx, &te->subtree, ca, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0);
break;
}
case ID_CF:
@@ -814,7 +783,7 @@ static void outliner_add_id_contents(
CacheFile *cache_file = (CacheFile *)id;
if (outliner_animdata_test(cache_file->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, cache_file, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(soops, &te->subtree, cache_file, te, TSE_ANIM_DATA, 0);
}
break;
@@ -825,12 +794,10 @@ static void outliner_add_id_contents(
int a;
if (outliner_animdata_test(la->adt))
- outliner_add_element(soops, eval_ctx, &te->subtree, la, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0);
for (a = 0; a < MAX_MTEX; a++) {
- if (la->mtex[a]) {
- outliner_add_element(soops, eval_ctx, &te->subtree, la->mtex[a]->tex, te, 0, a);
- }
+ if (la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a);
}
break;
}
@@ -838,18 +805,16 @@ static void outliner_add_id_contents(
{
Speaker *spk = (Speaker *)id;
- if (outliner_animdata_test(spk->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, spk, te, TSE_ANIM_DATA, 0);
- }
+ if (outliner_animdata_test(spk->adt))
+ outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0);
break;
}
case ID_LP:
{
LightProbe *prb = (LightProbe *)id;
- if (outliner_animdata_test(prb->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, prb, te, TSE_ANIM_DATA, 0);
- }
+ if (outliner_animdata_test(prb->adt))
+ outliner_add_element(soops, &te->subtree, prb, te, TSE_ANIM_DATA, 0);
break;
}
case ID_WO:
@@ -857,13 +822,11 @@ static void outliner_add_id_contents(
World *wrld = (World *)id;
int a;
- if (outliner_animdata_test(wrld->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, wrld, te, TSE_ANIM_DATA, 0);
- }
+ if (outliner_animdata_test(wrld->adt))
+ outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0);
+
for (a = 0; a < MAX_MTEX; a++) {
- if (wrld->mtex[a]) {
- outliner_add_element(soops, eval_ctx, &te->subtree, wrld->mtex[a]->tex, te, 0, a);
- }
+ if (wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a);
}
break;
}
@@ -871,9 +834,8 @@ static void outliner_add_id_contents(
{
Key *key = (Key *)id;
- if (outliner_animdata_test(key->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, key, te, TSE_ANIM_DATA, 0);
- }
+ if (outliner_animdata_test(key->adt))
+ outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0);
break;
}
case ID_AC:
@@ -887,15 +849,15 @@ static void outliner_add_id_contents(
bArmature *arm = (bArmature *)id;
int a = 0;
- if (outliner_animdata_test(arm->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, arm, te, TSE_ANIM_DATA, 0);
- }
+ if (outliner_animdata_test(arm->adt))
+ outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0);
+
if (arm->edbo) {
EditBone *ebone;
TreeElement *ten;
for (ebone = arm->edbo->first; ebone; ebone = ebone->next, a++) {
- ten = outliner_add_element(soops, eval_ctx, &te->subtree, id, te, TSE_EBONE, a);
+ ten = outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a);
ten->directdata = ebone;
ten->name = ebone->name;
ebone->temp.p = ten;
@@ -917,17 +879,13 @@ static void outliner_add_id_contents(
else {
/* do not extend Armature when we have posemode */
tselem = TREESTORE(te->parent);
- if (GS(tselem->id->name) == ID_OB &&
- (eval_ctx->object_mode & OB_MODE_POSE)
- /* (((Object *)tselem->id)->mode & OB_MODE_POSE) */
- )
- {
+ if (GS(tselem->id->name) == ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE) {
/* pass */
}
else {
Bone *curBone;
for (curBone = arm->bonebase.first; curBone; curBone = curBone->next) {
- outliner_add_bone(soops, eval_ctx, &te->subtree, id, curBone, te, &a);
+ outliner_add_bone(soops, &te->subtree, id, curBone, te, &a);
}
}
}
@@ -937,14 +895,13 @@ static void outliner_add_id_contents(
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
int a;
-
- if (outliner_animdata_test(linestyle->adt)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0);
- }
+
+ if (outliner_animdata_test(linestyle->adt))
+ outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0);
for (a = 0; a < MAX_MTEX; a++) {
if (linestyle->mtex[a])
- outliner_add_element(soops, eval_ctx, &te->subtree, linestyle->mtex[a]->tex, te, 0, a);
+ outliner_add_element(soops, &te->subtree, linestyle->mtex[a]->tex, te, 0, a);
}
break;
}
@@ -955,11 +912,11 @@ static void outliner_add_id_contents(
int a = 0;
if (outliner_animdata_test(gpd->adt))
- outliner_add_element(soops, eval_ctx, &te->subtree, gpd, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(soops, &te->subtree, gpd, te, TSE_ANIM_DATA, 0);
// TODO: base element for layers?
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- outliner_add_element(soops, eval_ctx, &te->subtree, gpl, te, TSE_GP_LAYER, a);
+ outliner_add_element(soops, &te->subtree, gpl, te, TSE_GP_LAYER, a);
a++;
}
break;
@@ -971,9 +928,8 @@ static void outliner_add_id_contents(
// TODO: this function needs to be split up! It's getting a bit too large...
// Note: "ID" is not always a real ID
-static TreeElement *outliner_add_element(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *lb, void *idv, TreeElement *parent, short type, short index)
+static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv,
+ TreeElement *parent, short type, short index)
{
TreeElement *te;
TreeStoreElem *tselem;
@@ -1046,7 +1002,7 @@ static TreeElement *outliner_add_element(
/* ID datablock */
if (tsepar == NULL || tsepar->type != TSE_ID_BASE)
- outliner_add_id_contents(soops, eval_ctx, te, tselem, id);
+ outliner_add_id_contents(soops, te, tselem, id);
}
else if (type == TSE_ANIM_DATA) {
IdAdtTemplate *iat = (IdAdtTemplate *)idv;
@@ -1057,11 +1013,11 @@ static TreeElement *outliner_add_element(
te->directdata = adt;
/* Action */
- outliner_add_element(soops, eval_ctx, &te->subtree, adt->action, te, 0, 0);
+ outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0);
/* Drivers */
if (adt->drivers.first) {
- TreeElement *ted = outliner_add_element(soops, eval_ctx, &te->subtree, adt, te, TSE_DRIVER_BASE, 0);
+ TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0);
ID *lastadded = NULL;
FCurve *fcu;
@@ -1078,7 +1034,7 @@ static TreeElement *outliner_add_element(
{
if (lastadded != dtar->id) {
// XXX this lastadded check is rather lame, and also fails quite badly...
- outliner_add_element(soops, eval_ctx, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0);
+ outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0);
lastadded = dtar->id;
}
}
@@ -1090,14 +1046,14 @@ static TreeElement *outliner_add_element(
/* NLA Data */
if (adt->nla_tracks.first) {
- TreeElement *tenla = outliner_add_element(soops, eval_ctx, &te->subtree, adt, te, TSE_NLA, 0);
+ TreeElement *tenla = outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0);
NlaTrack *nlt;
int a = 0;
tenla->name = IFACE_("NLA Tracks");
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
- TreeElement *tenlt = outliner_add_element(soops, eval_ctx, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a);
+ TreeElement *tenlt = outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a);
NlaStrip *strip;
TreeElement *ten;
int b = 0;
@@ -1105,7 +1061,7 @@ static TreeElement *outliner_add_element(
tenlt->name = nlt->name;
for (strip = nlt->strips.first; strip; strip = strip->next, b++) {
- ten = outliner_add_element(soops, eval_ctx, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b);
+ ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b);
if (ten) ten->directdata = strip;
}
}
@@ -1140,12 +1096,12 @@ static TreeElement *outliner_add_element(
if (seq->type == SEQ_TYPE_META) {
p = seq->seqbase.first;
while (p) {
- outliner_add_element(soops, eval_ctx, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
+ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
p = p->next;
}
}
else
- outliner_add_element(soops, eval_ctx, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index);
+ outliner_add_element(soops, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index);
}
}
else if (type == TSE_SEQ_STRIP) {
@@ -1206,7 +1162,7 @@ static TreeElement *outliner_add_element(
for (a = 0; a < tot; a++) {
RNA_property_collection_lookup_int(ptr, iterprop, a, &propptr);
if (!(RNA_property_flag(propptr.data) & PROP_HIDDEN)) {
- outliner_add_element(soops, eval_ctx, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a);
+ outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a);
}
}
}
@@ -1235,7 +1191,7 @@ static TreeElement *outliner_add_element(
if (pptr.data) {
if (TSELEM_OPEN(tselem, soops))
- outliner_add_element(soops, eval_ctx, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1);
+ outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1);
else
te->flag |= TE_LAZY_CLOSED;
}
@@ -1247,7 +1203,7 @@ static TreeElement *outliner_add_element(
if (TSELEM_OPEN(tselem, soops)) {
for (a = 0; a < tot; a++) {
RNA_property_collection_lookup_int(ptr, prop, a, &pptr);
- outliner_add_element(soops, eval_ctx, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a);
+ outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a);
}
}
else if (tot)
@@ -1259,7 +1215,7 @@ static TreeElement *outliner_add_element(
if (TSELEM_OPEN(tselem, soops)) {
for (a = 0; a < tot; a++)
- outliner_add_element(soops, eval_ctx, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a);
+ outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a);
}
else if (tot)
te->flag |= TE_LAZY_CLOSED;
@@ -1307,8 +1263,7 @@ static TreeElement *outliner_add_element(
}
if (ot || kmi->propvalue) {
- TreeElement *ten = outliner_add_element(
- soops, eval_ctx, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a);
+ TreeElement *ten = outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a);
ten->directdata = kmi;
@@ -1330,8 +1285,7 @@ static TreeElement *outliner_add_element(
if ((type != TSE_LAYER_COLLECTION) && (te->idcode == ID_GR)) {
Group *group = (Group *)id;
- outliner_add_layer_collections_recursive(
- soops, eval_ctx, &te->subtree, id, &group->view_layer->layer_collections, NULL, true);
+ outliner_add_layer_collections_recursive(soops, &te->subtree, id, &group->view_layer->layer_collections, NULL, true);
}
return te;
@@ -1387,9 +1341,7 @@ static int need_add_seq_dup(Sequence *seq)
return(1);
}
-static void outliner_add_seq_dup(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- Sequence *seq, TreeElement *te, short index)
+static void outliner_add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *te, short index)
{
/* TreeElement *ch; */ /* UNUSED */
Sequence *p;
@@ -1402,8 +1354,7 @@ static void outliner_add_seq_dup(
}
if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name))
- /* ch = */ /* UNUSED */ outliner_add_element(
- soops, eval_ctx, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
+ /* ch = */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
p = p->next;
}
}
@@ -1412,9 +1363,7 @@ static void outliner_add_seq_dup(
/* ----------------------------------------------- */
-static void outliner_add_library_contents(
- Main *mainvar, SpaceOops *soops, const EvaluationContext *eval_ctx,
- TreeElement *te, Library *lib)
+static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeElement *te, Library *lib)
{
TreeElement *ten;
ListBase *lbarray[MAX_LIBARRAY];
@@ -1431,7 +1380,7 @@ static void outliner_add_library_contents(
break;
if (id) {
- ten = outliner_add_element(soops, eval_ctx, &te->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
+ ten = outliner_add_element(soops, &te->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
ten->directdata = lbarray[a];
ten->name = BKE_idcode_to_name_plural(GS(id->name));
@@ -1440,7 +1389,7 @@ static void outliner_add_library_contents(
for (id = lbarray[a]->first; id; id = id->next) {
if (id->lib == lib)
- outliner_add_element(soops, eval_ctx, &ten->subtree, id, ten, 0, 0);
+ outliner_add_element(soops, &ten->subtree, id, ten, 0, 0);
}
}
}
@@ -1448,7 +1397,7 @@ static void outliner_add_library_contents(
}
-static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops, const EvaluationContext *eval_ctx)
+static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
{
TreeElement *ten;
ListBase *lbarray[MAX_LIBARRAY];
@@ -1471,7 +1420,7 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops, co
* - Add a parameter to BKE_idcode_to_name_plural to get a sane "user-visible" name instead?
* - Ensure that this uses nice icons for the datablock type involved instead of the dot?
*/
- ten = outliner_add_element(soops, eval_ctx, &soops->tree, lbarray[a], NULL, TSE_ID_BASE, 0);
+ ten = outliner_add_element(soops, &soops->tree, lbarray[a], NULL, TSE_ID_BASE, 0);
ten->directdata = lbarray[a];
ten->name = BKE_idcode_to_name_plural(GS(id->name));
@@ -1481,7 +1430,7 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops, co
/* add the orphaned datablocks - these will not be added with any subtrees attached */
for (id = lbarray[a]->first; id; id = id->next) {
if (ID_REAL_USERS(id) <= 0)
- outliner_add_element(soops, eval_ctx, &ten->subtree, id, ten, 0, 0);
+ outliner_add_element(soops, &ten->subtree, id, ten, 0, 0);
}
}
}
@@ -1527,24 +1476,22 @@ static bool outliner_layer_collections_reorder_poll(
}
static void outliner_add_layer_collections_recursive(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *tree, ID *id, ListBase *layer_collections, TreeElement *parent_ten,
+ SpaceOops *soops, ListBase *tree, ID *id, ListBase *layer_collections, TreeElement *parent_ten,
const bool show_objects)
{
for (LayerCollection *collection = layer_collections->first; collection; collection = collection->next) {
- TreeElement *ten = outliner_add_element(soops, eval_ctx, tree, id, parent_ten, TSE_LAYER_COLLECTION, 0);
+ TreeElement *ten = outliner_add_element(soops, tree, id, parent_ten, TSE_LAYER_COLLECTION, 0);
ten->name = collection->scene_collection->name;
ten->directdata = collection;
ten->reinsert = outliner_layer_collections_reorder;
ten->reinsert_poll = outliner_layer_collections_reorder_poll;
- outliner_add_layer_collections_recursive(
- soops, eval_ctx, &ten->subtree, id, &collection->layer_collections, ten, show_objects);
+ outliner_add_layer_collections_recursive(soops, &ten->subtree, id, &collection->layer_collections, ten, show_objects);
if (show_objects) {
for (LinkData *link = collection->object_bases.first; link; link = link->next) {
Base *base = (Base *)link->data;
- TreeElement *te_object = outliner_add_element(soops, eval_ctx, &ten->subtree, base->object, ten, 0, 0);
+ TreeElement *te_object = outliner_add_element(soops, &ten->subtree, base->object, ten, 0, 0);
te_object->directdata = base;
}
}
@@ -1552,13 +1499,10 @@ static void outliner_add_layer_collections_recursive(
}
}
-static void outliner_add_view_layer(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *tree, TreeElement *parent,
- Scene *scene, ViewLayer *layer, const bool show_objects)
+static void outliner_add_view_layer(SpaceOops *soops, ListBase *tree, TreeElement *parent,
+ Scene *scene, ViewLayer *layer, const bool show_objects)
{
- outliner_add_layer_collections_recursive(
- soops, eval_ctx, tree, &scene->id, &layer->layer_collections, parent, show_objects);
+ outliner_add_layer_collections_recursive(soops, tree, &scene->id, &layer->layer_collections, parent, show_objects);
}
static void outliner_scene_collections_reorder(
@@ -1629,40 +1573,35 @@ BLI_INLINE void outliner_add_scene_collection_init(TreeElement *te, SceneCollect
}
BLI_INLINE void outliner_add_scene_collection_objects(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *tree, SceneCollection *collection, TreeElement *parent)
+ SpaceOops *soops, ListBase *tree, SceneCollection *collection, TreeElement *parent)
{
for (LinkData *link = collection->objects.first; link; link = link->next) {
- outliner_add_element(soops, eval_ctx, tree, link->data, parent, 0, 0);
+ outliner_add_element(soops, tree, link->data, parent, 0, 0);
}
}
static TreeElement *outliner_add_scene_collection_recursive(
- SpaceOops *soops, const EvaluationContext *eval_ctx,
- ListBase *tree, ID *id, SceneCollection *scene_collection, TreeElement *parent_ten)
+ SpaceOops *soops, ListBase *tree, ID *id, SceneCollection *scene_collection, TreeElement *parent_ten)
{
- TreeElement *ten = outliner_add_element(soops, eval_ctx, tree, id, parent_ten, TSE_SCENE_COLLECTION, 0);
+ TreeElement *ten = outliner_add_element(soops, tree, id, parent_ten, TSE_SCENE_COLLECTION, 0);
outliner_add_scene_collection_init(ten, scene_collection);
- outliner_add_scene_collection_objects(soops, eval_ctx, &ten->subtree, scene_collection, ten);
+ outliner_add_scene_collection_objects(soops, &ten->subtree, scene_collection, ten);
for (SceneCollection *scene_collection_nested = scene_collection->scene_collections.first;
scene_collection_nested != NULL;
scene_collection_nested = scene_collection_nested->next)
{
- outliner_add_scene_collection_recursive(
- soops, eval_ctx, &ten->subtree, id, scene_collection_nested, ten);
+ outliner_add_scene_collection_recursive(soops, &ten->subtree, id, scene_collection_nested, ten);
}
outliner_make_hierarchy(&ten->subtree);
return ten;
}
-static void outliner_add_collections(
- SpaceOops *soops, const EvaluationContext *eval_ctx, Scene *scene)
+static void outliner_add_collections(SpaceOops *soops, Scene *scene)
{
SceneCollection *master_collection = BKE_collection_master(&scene->id);
- TreeElement *ten = outliner_add_scene_collection_recursive(
- soops, eval_ctx, &soops->tree, &scene->id, master_collection, NULL);
+ TreeElement *ten = outliner_add_scene_collection_recursive(soops, &soops->tree, &scene->id, master_collection, NULL);
/* Master Collection should always be expanded. */
TREESTORE(ten)->flag &= ~TSE_CLOSED;
}
@@ -2227,9 +2166,7 @@ static void outliner_filter_tree(SpaceOops *soops, ViewLayer *view_layer)
/* Main entry point for building the tree data-structure that the outliner represents */
// TODO: split each mode into its own function?
-void outliner_build_tree(
- Main *mainvar, const EvaluationContext *eval_ctx, Scene *scene,
- ViewLayer *view_layer, SpaceOops *soops, ARegion *ar)
+void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, SpaceOops *soops, ARegion *ar)
{
TreeElement *te = NULL, *ten;
TreeStoreElem *tselem;
@@ -2262,20 +2199,20 @@ void outliner_build_tree(
Library *lib;
/* current file first - mainvar provides tselem with unique pointer - not used */
- ten = outliner_add_element(soops, eval_ctx, &soops->tree, mainvar, NULL, TSE_ID_BASE, 0);
+ ten = outliner_add_element(soops, &soops->tree, mainvar, NULL, TSE_ID_BASE, 0);
ten->name = IFACE_("Current File");
tselem = TREESTORE(ten);
if (!tselem->used)
tselem->flag &= ~TSE_CLOSED;
- outliner_add_library_contents(mainvar, soops, eval_ctx, ten, NULL);
+ outliner_add_library_contents(mainvar, soops, ten, NULL);
for (lib = mainvar->library.first; lib; lib = lib->id.next) {
- ten = outliner_add_element(soops, eval_ctx, &soops->tree, lib, NULL, 0, 0);
+ ten = outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0);
lib->id.newid = (ID *)ten;
- outliner_add_library_contents(mainvar, soops, eval_ctx, ten, lib);
+ outliner_add_library_contents(mainvar, soops, ten, lib);
}
/* make hierarchy */
@@ -2295,8 +2232,8 @@ void outliner_build_tree(
}
else {
/* Else, make a new copy of the libtree for our parent. */
- TreeElement *dupten = outliner_add_element(soops, eval_ctx, &par->subtree, lib, NULL, 0, 0);
- outliner_add_library_contents(mainvar, soops, eval_ctx, dupten, lib);
+ TreeElement *dupten = outliner_add_element(soops, &par->subtree, lib, NULL, 0, 0);
+ outliner_add_library_contents(mainvar, soops, dupten, lib);
dupten->parent = par;
}
}
@@ -2310,7 +2247,7 @@ void outliner_build_tree(
else if (soops->outlinevis == SO_SCENES) {
Scene *sce;
for (sce = mainvar->scene.first; sce; sce = sce->id.next) {
- te = outliner_add_element(soops, eval_ctx, &soops->tree, sce, NULL, 0, 0);
+ te = outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0);
tselem = TREESTORE(te);
if (sce == scene && show_opened) {
@@ -2323,7 +2260,7 @@ void outliner_build_tree(
else if (soops->outlinevis == SO_GROUPS) {
Group *group;
for (group = mainvar->group.first; group; group = group->id.next) {
- te = outliner_add_element(soops, eval_ctx, &soops->tree, group, NULL, 0, 0);
+ te = outliner_add_element(soops, &soops->tree, group, NULL, 0, 0);
outliner_make_hierarchy(&te->subtree);
}
}
@@ -2342,11 +2279,11 @@ void outliner_build_tree(
while (seq) {
op = need_add_seq_dup(seq);
if (op == 1) {
- /* ten = */ outliner_add_element(soops, eval_ctx, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0);
+ /* ten = */ outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0);
}
else if (op == 0) {
- ten = outliner_add_element(soops, eval_ctx, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE_DUP, 0);
- outliner_add_seq_dup(soops, eval_ctx, seq, ten, 0);
+ ten = outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE_DUP, 0);
+ outliner_add_seq_dup(soops, seq, ten, 0);
}
seq = seq->next;
}
@@ -2356,7 +2293,7 @@ void outliner_build_tree(
RNA_main_pointer_create(mainvar, &mainptr);
- ten = outliner_add_element(soops, eval_ctx, &soops->tree, (void *)&mainptr, NULL, TSE_RNA_STRUCT, -1);
+ ten = outliner_add_element(soops, &soops->tree, (void *)&mainptr, NULL, TSE_RNA_STRUCT, -1);
if (show_opened) {
tselem = TREESTORE(ten);
@@ -2364,36 +2301,36 @@ void outliner_build_tree(
}
}
else if (soops->outlinevis == SO_ID_ORPHANS) {
- outliner_add_orphaned_datablocks(mainvar, soops, eval_ctx);
+ outliner_add_orphaned_datablocks(mainvar, soops);
}
else if (soops->outlinevis == SO_VIEW_LAYER) {
if ((soops->filter & SO_FILTER_ENABLE) && (soops->filter & SO_FILTER_NO_COLLECTION)) {
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- TreeElement *te_object = outliner_add_element(soops, eval_ctx, &soops->tree, base->object, NULL, 0, 0);
+ TreeElement *te_object = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0);
te_object->directdata = base;
}
outliner_make_hierarchy(&soops->tree);
}
else {
- outliner_add_view_layer(soops, eval_ctx, &soops->tree, NULL, scene, view_layer, true);
+ outliner_add_view_layer(soops, &soops->tree, NULL, scene, view_layer, true);
}
}
else if (soops->outlinevis == SO_COLLECTIONS) {
if ((soops->filter & SO_FILTER_ENABLE) && (soops->filter & SO_FILTER_NO_COLLECTION)) {
FOREACH_SCENE_OBJECT_BEGIN(scene, ob)
{
- outliner_add_element(soops, eval_ctx, &soops->tree, ob, NULL, 0, 0);
+ outliner_add_element(soops, &soops->tree, ob, NULL, 0, 0);
}
FOREACH_SCENE_OBJECT_END;
outliner_make_hierarchy(&soops->tree);
}
else {
- outliner_add_collections(soops, eval_ctx, scene);
+ outliner_add_collections(soops, scene);
}
}
else {
if (BASACT(view_layer)) {
- ten = outliner_add_element(soops, eval_ctx, &soops->tree, OBACT(view_layer), NULL, 0, 0);
+ ten = outliner_add_element(soops, &soops->tree, OBACT(view_layer), NULL, 0, 0);
ten->directdata = BASACT(view_layer);
}
}
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 9a736ae977f..42027f10fe6 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -402,7 +402,6 @@ static void time_draw_caches_keyframes(Main *bmain, ViewLayer *view_layer, View2
/* draw keyframe lines for timeline */
static void time_draw_keyframes(const bContext *C, ARegion *ar)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = CTX_data_active_object(C);
@@ -444,7 +443,7 @@ static void time_draw_keyframes(const bContext *C, ARegion *ar)
*/
UI_GetThemeColor3ubv(TH_TIME_KEYFRAME, color);
- if (ob && ((workspace->object_mode == OB_MODE_POSE) || onlysel)) {
+ if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
/* draw keyframes for active object only */
time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel, color);
}
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index f0adf307bda..77cd64be7c1 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -2667,10 +2667,8 @@ static void ghost_poses_tag_unselected(Object *ob, short unset)
* note: object should be in posemode
*/
static void draw_ghost_poses_range(
- const EvaluationContext *eval_ctx_init,
- Scene *scene, ViewLayer *view_layer, View3D *v3d, ARegion *ar, Base *base)
+ const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, ARegion *ar, Base *base)
{
- EvaluationContext eval_ctx = *eval_ctx_init;
Object *ob = base->object;
AnimData *adt = BKE_animdata_from_id(&ob->id);
bArmature *arm = ob->data;
@@ -2692,7 +2690,7 @@ static void draw_ghost_poses_range(
range = (float)(end - start);
/* store values */
- eval_ctx.object_mode &= ~OB_MODE_POSE;
+ ob->mode &= ~OB_MODE_POSE;
cfrao = CFRA;
flago = arm->flag;
arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES);
@@ -2713,8 +2711,8 @@ static void draw_ghost_poses_range(
UI_GetThemeColorShadeAlpha4ubv(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac)), col);
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(&eval_ctx, scene, ob);
- draw_pose_bones(&eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
+ BKE_pose_where_is(eval_ctx, scene, ob);
+ draw_pose_bones(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
}
glDisable(GL_BLEND);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -2730,17 +2728,16 @@ static void draw_ghost_poses_range(
CFRA = cfrao;
ob->pose = poseo;
arm->flag = flago;
- eval_ctx.object_mode |= OB_MODE_POSE;
+ ob->mode |= OB_MODE_POSE;
}
/* draw ghosts on keyframes in action within range
* - object should be in posemode
*/
static void draw_ghost_poses_keys(
- const struct EvaluationContext *eval_ctx_init, Scene *scene, ViewLayer *view_layer,
+ const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
View3D *v3d, ARegion *ar, Base *base)
{
- EvaluationContext eval_ctx = *eval_ctx_init;
Object *ob = base->object;
AnimData *adt = BKE_animdata_from_id(&ob->id);
bAction *act = (adt) ? adt->action : NULL;
@@ -2774,7 +2771,7 @@ static void draw_ghost_poses_keys(
if (range == 0) return;
/* store values */
- eval_ctx.object_mode &= ~OB_MODE_POSE;
+ ob->mode &= ~OB_MODE_POSE;
cfrao = CFRA;
flago = arm->flag;
arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES);
@@ -2797,8 +2794,8 @@ static void draw_ghost_poses_keys(
CFRA = (int)ak->cfra;
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(&eval_ctx, scene, ob);
- draw_pose_bones(&eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
+ BKE_pose_where_is(eval_ctx, scene, ob);
+ draw_pose_bones(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
}
glDisable(GL_BLEND);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -2815,17 +2812,16 @@ static void draw_ghost_poses_keys(
CFRA = cfrao;
ob->pose = poseo;
arm->flag = flago;
- eval_ctx.object_mode |= OB_MODE_POSE;
+ ob->mode |= OB_MODE_POSE;
}
/* draw ghosts around current frame
* - object is supposed to be armature in posemode
*/
static void draw_ghost_poses(
- const struct EvaluationContext *eval_ctx_init, Scene *scene, ViewLayer *view_layer,
+ const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
View3D *v3d, ARegion *ar, Base *base)
{
- EvaluationContext eval_ctx = *eval_ctx_init;
Object *ob = base->object;
AnimData *adt = BKE_animdata_from_id(&ob->id);
bArmature *arm = ob->data;
@@ -2850,7 +2846,7 @@ static void draw_ghost_poses(
range = (float)(arm->ghostep) * stepsize + 0.5f; /* plus half to make the for loop end correct */
/* store values */
- eval_ctx.object_mode &= ~OB_MODE_POSE;
+ ob->mode &= ~OB_MODE_POSE;
cfrao = CFRA;
actframe = BKE_nla_tweakedit_remap(adt, (float)CFRA, 0);
flago = arm->flag;
@@ -2878,8 +2874,8 @@ static void draw_ghost_poses(
if (CFRA != cfrao) {
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(&eval_ctx, scene, ob);
- draw_pose_bones(&eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
+ BKE_pose_where_is(eval_ctx, scene, ob);
+ draw_pose_bones(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
}
}
@@ -2893,8 +2889,8 @@ static void draw_ghost_poses(
if (CFRA != cfrao) {
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(&eval_ctx, scene, ob);
- draw_pose_bones(&eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
+ BKE_pose_where_is(eval_ctx, scene, ob);
+ draw_pose_bones(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
}
}
}
@@ -2912,7 +2908,7 @@ static void draw_ghost_poses(
CFRA = cfrao;
ob->pose = poseo;
arm->flag = flago;
- eval_ctx.object_mode |= OB_MODE_POSE;
+ ob->mode |= OB_MODE_POSE;
}
/* ********************************** Armature Drawing - Main ************************* */
@@ -2974,11 +2970,11 @@ bool draw_armature(
}
else
#endif
- if (eval_ctx->object_mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
arm->flag |= ARM_POSEMODE;
}
}
- else if (eval_ctx->object_mode & OB_MODE_POSE) {
+ else if (ob->mode & OB_MODE_POSE) {
if (arm->ghosttype == ARM_GHOST_RANGE) {
draw_ghost_poses_range(eval_ctx, scene, view_layer, v3d, ar, base);
}
@@ -2992,7 +2988,7 @@ bool draw_armature(
if ((dflag & DRAW_SCENESET) == 0) {
if (ob == OBACT(view_layer))
arm->flag |= ARM_POSEMODE;
- else if (OBACT(view_layer) && (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT)) {
+ else if (OBACT(view_layer) && (OBACT(view_layer)->mode & OB_MODE_WEIGHT_PAINT)) {
if (ob == modifiers_isDeformedByArmature(OBACT(view_layer)))
arm->flag |= ARM_POSEMODE;
}
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index c014c2b12a0..0d4ec4d42d1 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -59,8 +59,6 @@
#include "UI_resources.h"
-#include "DEG_depsgraph.h"
-
#include "GPU_draw.h"
#include "GPU_material.h"
#include "GPU_basic_shader.h"
@@ -327,10 +325,8 @@ void draw_mesh_paint_weight_edges(RegionView3D *rv3d, DerivedMesh *dm,
}
}
-void draw_mesh_paint(
- const EvaluationContext *eval_ctx,
- View3D *v3d, RegionView3D *rv3d,
- Object *ob, DerivedMesh *dm, const int draw_flags)
+void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
+ Object *ob, DerivedMesh *dm, const int draw_flags)
{
DMSetDrawOptions facemask = NULL;
Mesh *me = ob->data;
@@ -340,21 +336,21 @@ void draw_mesh_paint(
if (me->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL))
facemask = wpaint__setSolidDrawOptions_facemask;
- if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (ob->mode & OB_MODE_WEIGHT_PAINT) {
draw_mesh_paint_weight_faces(dm, use_light, facemask, me);
}
- else if (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) {
+ else if (ob->mode & OB_MODE_VERTEX_PAINT) {
draw_mesh_paint_vcolor_faces(dm, use_light, facemask, me, me);
}
/* draw face selection on top */
if (draw_flags & DRAW_FACE_SELECT) {
- bool draw_select_edges = (eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) == 0;
+ bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0;
draw_mesh_face_select(rv3d, me, dm, draw_select_edges);
}
else if ((use_light == false) || (ob->dtx & OB_DRAWWIRE)) {
- const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT);
- const bool use_alpha = (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) == 0;
+ const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT);
+ const bool use_alpha = (ob->mode & OB_MODE_VERTEX_PAINT) == 0;
if (use_alpha == false) {
set_inverted_drawing(1);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index f46d3c500bc..2c6d977b552 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -314,15 +314,13 @@ static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
/* check for glsl drawing */
-bool draw_glsl_material(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
- Object *ob, View3D *v3d, const char dt)
+bool draw_glsl_material(Scene *scene, ViewLayer *view_layer, Object *ob, View3D *v3d, const char dt)
{
if (G.f & G_PICKSEL)
return false;
if (!check_object_draw_texture(scene, v3d, dt))
return false;
- if (ob == OBACT(view_layer) && (ob && eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT))
+ if (ob == OBACT(view_layer) && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
return false;
if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP)
@@ -336,7 +334,7 @@ bool draw_glsl_material(
return false;
}
-static bool check_alpha_pass(const EvaluationContext *eval_ctx, Base *base)
+static bool check_alpha_pass(Base *base)
{
if (base->flag_legacy & OB_FROMDUPLI)
return false;
@@ -344,9 +342,8 @@ static bool check_alpha_pass(const EvaluationContext *eval_ctx, Base *base)
if (G.f & G_PICKSEL)
return false;
- if (eval_ctx->object_mode & OB_MODE_ALL_PAINT) {
+ if (base->object->mode & OB_MODE_ALL_PAINT)
return false;
- }
return (base->object->dtx & OB_DRAWTRANSP);
}
@@ -3893,9 +3890,8 @@ static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index)
}
}
-static void draw_em_fancy(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d,
- Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt)
+static void draw_em_fancy(Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d,
+ Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt)
{
RegionView3D *rv3d = ar->regiondata;
@@ -3932,7 +3928,7 @@ static void draw_em_fancy(
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
else if (check_object_draw_texture(scene, v3d, dt)) {
- if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) {
+ if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
finalDM->drawMappedFacesGLSL(finalDM, GPU_object_material_bind,
@@ -4225,12 +4221,10 @@ static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D
/* Mesh drawing routines */
-void draw_mesh_object_outline(
- const EvaluationContext *eval_ctx, View3D *v3d,
- Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */
+void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */
{
if ((v3d->transp == false) && /* not when we draw the transparent pass */
- (eval_ctx->object_mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
+ (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
{
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
glDepthMask(GL_FALSE);
@@ -4253,12 +4247,10 @@ void draw_mesh_object_outline(
}
}
-static void draw_mesh_object_outline_new(
- const EvaluationContext *eval_ctx, View3D *v3d, RegionView3D *rv3d,
- Mesh *me, const bool is_active)
+static void draw_mesh_object_outline_new(View3D *v3d, RegionView3D *rv3d, Object *ob, Mesh *me, const bool is_active)
{
if ((v3d->transp == false) && /* not when we draw the transparent pass */
- (eval_ctx->object_mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
+ (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
{
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
glDepthMask(GL_FALSE);
@@ -4308,9 +4300,7 @@ static void draw_mesh_fancy(
const char dt, const unsigned char ob_wire_col[4], const short dflag)
{
#ifdef WITH_GAMEENGINE
- Object *ob = (
- (rv3d->rflag & RV3D_IS_GAME_ENGINE) ?
- BKE_object_lod_meshob_get(base->object, view_layer, eval_ctx->object_mode) : base->object);
+ Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object;
#else
Object *ob = base->object;
#endif
@@ -4319,7 +4309,7 @@ static void draw_mesh_fancy(
bool /* no_verts,*/ no_edges, no_faces;
DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
const bool is_obact = (ob == OBACT(view_layer));
- int draw_flags = (is_obact && BKE_paint_select_face_test(ob, eval_ctx->object_mode)) ? DRAW_FACE_SELECT : 0;
+ int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
if (!dm)
return;
@@ -4357,7 +4347,7 @@ static void draw_mesh_fancy(
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
}
else if ((no_faces && no_edges) ||
- ((!is_obact || (eval_ctx->object_mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
+ ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
{
glPointSize(1.5f);
dm->drawVerts(dm);
@@ -4365,7 +4355,7 @@ static void draw_mesh_fancy(
else if ((dt == OB_WIRE) || no_faces) {
draw_wire = OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff */
}
- else if (((is_obact && eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT)) ||
+ else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
check_object_draw_texture(scene, v3d, dt))
{
bool draw_loose = true;
@@ -4376,17 +4366,15 @@ static void draw_mesh_fancy(
!(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
(draw_wire == OBDRAW_WIRE_OFF))
{
- draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col);
+ draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
}
- if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
+ if (draw_glsl_material(scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
Paint *p;
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt &&
- (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode)))
- {
+ if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
GPUVertexAttribs gattribs;
float planes[4][4];
float (*fpl)[4] = NULL;
@@ -4449,7 +4437,7 @@ static void draw_mesh_fancy(
(draw_wire == OBDRAW_WIRE_OFF) &&
(ob->sculpt == NULL))
{
- draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col);
+ draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
}
/* materials arent compatible with vertex colors */
@@ -4473,12 +4461,12 @@ static void draw_mesh_fancy(
(draw_wire == OBDRAW_WIRE_OFF) &&
(ob->sculpt == NULL))
{
- draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col);
+ draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
}
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode))) {
+ if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
float planes[4][4];
float (*fpl)[4] = NULL;
const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
@@ -4510,7 +4498,7 @@ static void draw_mesh_fancy(
}
}
else if (dt == OB_PAINT) {
- draw_mesh_paint(eval_ctx, v3d, rv3d, ob, dm, draw_flags);
+ draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags);
/* since we already draw wire as wp guide, don't draw over the top */
draw_wire = OBDRAW_WIRE_OFF;
@@ -4525,7 +4513,7 @@ static void draw_mesh_fancy(
* with the background. */
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if (is_obact && (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) {
+ if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
float color[3];
ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f, color);
glColor3fv(color);
@@ -4558,7 +4546,7 @@ static void draw_mesh_fancy(
}
}
- if (is_obact && BKE_paint_select_vert_test(ob, eval_ctx->object_mode)) {
+ if (is_obact && BKE_paint_select_vert_test(ob)) {
const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0;
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
@@ -4577,7 +4565,7 @@ static bool draw_mesh_object(
const char dt, const unsigned char ob_wire_col[4], const short dflag)
{
Object *ob = base->object;
- Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
bool do_alpha_after = false, drawlinked = false, retval = false;
@@ -4627,13 +4615,13 @@ static bool draw_mesh_object(
if (use_material) {
if (dt > OB_WIRE) {
- const bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt);
+ const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, eval_ctx->object_mode, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
}
}
- draw_em_fancy(eval_ctx, scene, view_layer, ar, v3d, ob, em, cageDM, finalDM, dt);
+ draw_em_fancy(scene, view_layer, ar, v3d, ob, em, cageDM, finalDM, dt);
if (use_material) {
GPU_end_object_materials();
@@ -4646,13 +4634,12 @@ static bool draw_mesh_object(
/* ob->bb was set by derived mesh system, do NULL check just to be sure */
if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) {
if (dt > OB_WIRE) {
- const bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt);
+ const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
if (dt == OB_SOLID || glsl) {
- const bool check_alpha = check_alpha_pass(eval_ctx, base);
- GPU_begin_object_materials(
- v3d, rv3d, scene, view_layer, ob,
- glsl, eval_ctx->object_mode, (check_alpha) ? &do_alpha_after : NULL);
+ const bool check_alpha = check_alpha_pass(base);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl,
+ (check_alpha) ? &do_alpha_after : NULL);
}
}
@@ -4731,9 +4718,7 @@ static void draw_mesh_fancy_new(
}
#ifdef WITH_GAMEENGINE
- Object *ob = (
- (rv3d->rflag & RV3D_IS_GAME_ENGINE) ?
- BKE_object_lod_meshob_get(base->object, view_layer, eval_ctx->object_mode) : base->object);
+ Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object;
#else
Object *ob = base->object;
#endif
@@ -4742,7 +4727,7 @@ static void draw_mesh_fancy_new(
bool no_edges, no_faces;
DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
const bool is_obact = (ob == OBACT(view_layer));
- int draw_flags = (is_obact && BKE_paint_select_face_test(ob, eval_ctx->object_mode)) ? DRAW_FACE_SELECT : 0;
+ int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
if (!dm)
return;
@@ -4785,7 +4770,7 @@ static void draw_mesh_fancy_new(
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
}
else if ((no_faces && no_edges) ||
- ((!is_obact || (eval_ctx->object_mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
+ ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
{
glPointSize(1.5f);
// dm->drawVerts(dm);
@@ -4851,7 +4836,7 @@ static void draw_mesh_fancy_new(
GWN_batch_draw(batch);
#endif
}
- else if (((is_obact && eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT)) ||
+ else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
check_object_draw_texture(scene, v3d, dt))
{
bool draw_loose = true;
@@ -4862,17 +4847,15 @@ static void draw_mesh_fancy_new(
!(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
(draw_wire == OBDRAW_WIRE_OFF))
{
- draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer)));
+ draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer)));
}
- if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
+ if (draw_glsl_material(scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
Paint *p;
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt &&
- (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode)))
- {
+ if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
GPUVertexAttribs gattribs;
float planes[4][4];
float (*fpl)[4] = NULL;
@@ -4931,7 +4914,7 @@ static void draw_mesh_fancy_new(
(draw_wire == OBDRAW_WIRE_OFF) &&
(ob->sculpt == NULL))
{
- draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer)));
+ draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer)));
}
/* materials arent compatible with vertex colors */
@@ -4956,12 +4939,12 @@ static void draw_mesh_fancy_new(
(ob->sculpt == NULL))
{
/* TODO: move this into a separate pass */
- draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer)));
+ draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer)));
}
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode))) {
+ if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
float planes[4][4];
float (*fpl)[4] = NULL;
const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
@@ -4993,7 +4976,7 @@ static void draw_mesh_fancy_new(
}
}
else if (dt == OB_PAINT) {
- draw_mesh_paint(eval_ctx, v3d, rv3d, ob, dm, draw_flags);
+ draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags);
/* since we already draw wire as wp guide, don't draw over the top */
draw_wire = OBDRAW_WIRE_OFF;
@@ -5055,7 +5038,7 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(
/* TODO: handle shadow pass separately */
return true;
}
- Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(eval_ctx->view_layer);
if (obedit && ob != obedit && ob->data == obedit->data) {
if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {}
@@ -5100,9 +5083,9 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(
DM_update_materials(cageDM, ob);
}
- const bool glsl = draw_glsl_material(eval_ctx, scene, eval_ctx->view_layer, ob, v3d, dt);
+ const bool glsl = draw_glsl_material(scene, eval_ctx->view_layer, ob, v3d, dt);
- GPU_begin_object_materials(v3d, rv3d, scene, eval_ctx->view_layer, ob, glsl, eval_ctx->object_mode, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, eval_ctx->view_layer, ob, glsl, NULL);
}
draw_em_fancy_new(scene, ar, v3d, ob, me, em, cageDM, finalDM, dt);
@@ -5118,13 +5101,12 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(
/* ob->bb was set by derived mesh system, do NULL check just to be sure */
if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) {
if (solid) {
- const bool glsl = draw_glsl_material(eval_ctx, scene, eval_ctx->view_layer, ob, v3d, dt);
+ const bool glsl = draw_glsl_material(scene, eval_ctx->view_layer, ob, v3d, dt);
if (dt == OB_SOLID || glsl) {
- const bool check_alpha = check_alpha_pass(eval_ctx, base);
- GPU_begin_object_materials(
- v3d, rv3d, scene, eval_ctx->view_layer, ob,
- eval_ctx->object_mode, glsl, (check_alpha) ? &do_alpha_after : NULL);
+ const bool check_alpha = check_alpha_pass(base);
+ GPU_begin_object_materials(v3d, rv3d, scene, eval_ctx->view_layer, ob, glsl,
+ (check_alpha) ? &do_alpha_after : NULL);
}
}
@@ -5441,9 +5423,7 @@ static void drawCurveDMWired(Object *ob)
}
/* return true when nothing was drawn */
-static bool drawCurveDerivedMesh(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d,
- Base *base, const char dt)
+static bool drawCurveDerivedMesh(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt)
{
Object *ob = base->object;
DerivedMesh *dm = ob->derivedFinal;
@@ -5457,10 +5437,8 @@ static bool drawCurveDerivedMesh(
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
if (dt > OB_WIRE && dm->getNumPolys(dm)) {
- bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt);
- GPU_begin_object_materials(
- v3d, rv3d, scene, view_layer, ob,
- eval_ctx->object_mode, glsl, NULL);
+ bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
if (!glsl)
dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
@@ -5481,9 +5459,8 @@ static bool drawCurveDerivedMesh(
* Only called by #drawDispList
* \return true when nothing was drawn
*/
-static bool drawDispList_nobackface(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d,
- Base *base, const char dt, const short dflag, const unsigned char ob_wire_col[4])
+static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const char dt, const short dflag, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
ListBase *lb = NULL;
@@ -5523,13 +5500,13 @@ static bool drawDispList_nobackface(
/* pass */
}
else {
- if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, eval_ctx->object_mode, NULL);
+ if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
GPU_end_object_materials();
}
else {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, eval_ctx->object_mode, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
GPU_end_object_materials();
}
@@ -5558,13 +5535,13 @@ static bool drawDispList_nobackface(
if (dl->nors == NULL) BKE_displist_normals_add(lb);
- if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, eval_ctx->object_mode, NULL);
+ if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
GPU_end_object_materials();
}
else {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, eval_ctx->object_mode, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
GPU_end_object_materials();
}
@@ -5583,13 +5560,13 @@ static bool drawDispList_nobackface(
if (solid) {
- if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, eval_ctx->object_mode, NULL);
+ if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
GPU_end_object_materials();
}
else {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, eval_ctx->object_mode, NULL);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL);
drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
GPU_end_object_materials();
}
@@ -5620,7 +5597,7 @@ static bool drawDispList(
ensure_curve_cache(eval_ctx, scene, base->object);
#endif
- if (drawCurveDerivedMesh(eval_ctx, scene, view_layer, v3d, rv3d, base, dt) == false) {
+ if (drawCurveDerivedMesh(scene, view_layer, v3d, rv3d, base, dt) == false) {
retval = false;
}
else {
@@ -5636,7 +5613,7 @@ static bool drawDispList(
glFrontFace(mode);
- retval = drawDispList_nobackface(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ retval = drawDispList_nobackface(scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
if (mode != GL_CCW) {
glFrontFace(GL_CCW);
@@ -5960,7 +5937,7 @@ static void draw_new_particle_system(
if (pars == NULL) return;
/* don't draw normal paths in edit mode */
- if (psys_in_edit_mode(eval_ctx, eval_ctx->view_layer, psys) && (pset->flag & PE_DRAW_PART) == 0)
+ if (psys_in_edit_mode(eval_ctx->view_layer, psys) && (pset->flag & PE_DRAW_PART) == 0)
return;
if (part->draw_as == PART_DRAW_REND)
@@ -8319,7 +8296,7 @@ static void draw_object_selected_outline(
if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->bb)) {
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
if (dm) {
- draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col);
+ draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
}
else {
/* only draw 'solid' parts of the display list as wire. */
@@ -8336,7 +8313,7 @@ static void draw_object_selected_outline(
}
}
else if (ob->type == OB_ARMATURE) {
- if (!(eval_ctx->object_mode & OB_MODE_POSE && base == view_layer->basact)) {
+ if (!(ob->mode & OB_MODE_POSE && base == view_layer->basact)) {
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
draw_armature(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, 0, ob_wire_col, true);
}
@@ -8447,13 +8424,11 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data,
immUnbindProgram();
}
-void draw_object_wire_color(
- const EvaluationContext *eval_ctx, ViewLayer *view_layer,
- Base *base, unsigned char r_ob_wire_col[4])
+void draw_object_wire_color(ViewLayer *view_layer, Base *base, unsigned char r_ob_wire_col[4])
{
Object *ob = base->object;
int colindex = 0;
- const bool is_edit = (eval_ctx->object_mode & OB_MODE_EDIT) != 0;
+ const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
/* confusing logic here, there are 2 methods of setting the color
* 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
*
@@ -8461,7 +8436,7 @@ void draw_object_wire_color(
int theme_id = is_edit ? TH_WIRE_EDIT : TH_WIRE;
int theme_shade = 0;
- if (((eval_ctx->object_mode & OB_MODE_EDIT) == 0) &&
+ if (((ob->mode & OB_MODE_EDIT) == 0) &&
(G.moving & G_TRANSFORM_OBJ) &&
((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)))
{
@@ -8515,12 +8490,10 @@ void draw_object_wire_color(
r_ob_wire_col[3] = 255;
}
-static void draw_object_matcap_check(
- const EvaluationContext *eval_ctx, View3D *v3d, Object *ob)
+static void draw_object_matcap_check(View3D *v3d, Object *ob)
{
/* fixed rule, active object draws as matcap */
- BLI_assert((eval_ctx->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0);
- UNUSED_VARS_NDEBUG(eval_ctx);
+ BLI_assert((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0);
(void)ob;
if (v3d->defmaterial == NULL) {
@@ -8606,9 +8579,10 @@ void draw_object(
unsigned char _ob_wire_col[4]; /* dont initialize this */
const unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */
bool zbufoff = false, is_paint = false, empty_object = false;
- const bool is_obact = (ob == OBACT(view_layer));
+ Object *ob_active = OBACT(view_layer);
+ const bool is_obact = (ob == ob_active);
/* this could be moved to a 'dflag'. */
- const bool is_obedit = (is_obact && (ob == OBEDIT_FROM_EVAL_CTX(eval_ctx)));
+ const bool is_obedit = (is_obact && (ob == OBEDIT_FROM_OBACT(ob_active)));
const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
const bool is_picking = (G.f & G_PICKSEL) != 0;
const bool has_particles = (ob->particlesystem.first != NULL);
@@ -8634,7 +8608,7 @@ void draw_object(
return;
}
- if (eval_ctx->object_mode == OB_MODE_OBJECT) {
+ if (ob->mode == OB_MODE_OBJECT) {
ParticleSystem *psys;
skip_object = render_override;
@@ -8674,7 +8648,7 @@ void draw_object(
/* xray delay? */
if ((dflag & DRAW_PICKING) == 0 && (base->flag_legacy & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
/* don't do xray in particle mode, need the z-buffer */
- if (!(eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) {
+ if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
/* xray and transp are set when it is drawing the 2nd/3rd pass */
if (!v3d->xray && !v3d->transp && (ob->dtx & OB_DRAWXRAY) && !(ob->dtx & OB_DRAWTRANSP)) {
ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
@@ -8725,7 +8699,7 @@ void draw_object(
ED_view3d_project_base(ar, base);
- draw_object_wire_color(eval_ctx, view_layer, base, _ob_wire_col);
+ draw_object_wire_color(view_layer, base, _ob_wire_col);
ob_wire_col = _ob_wire_col;
//glColor3ubv(ob_wire_col);
@@ -8741,14 +8715,14 @@ void draw_object(
/* faceselect exception: also draw solid when (dt == wire), except in editmode */
if (is_obact) {
- if (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
+ if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
if (ob->type == OB_MESH) {
if (dt < OB_SOLID) {
zbufoff = true;
dt = OB_SOLID;
}
- if (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
+ if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
dt = OB_PAINT;
}
@@ -8764,13 +8738,13 @@ void draw_object(
(is_paint == false && is_picking == false) &&
((v3d->flag2 & V3D_RENDER_SHADOW) == 0))
{
- draw_object_matcap_check(eval_ctx, v3d, ob);
+ draw_object_matcap_check(v3d, ob);
}
/* draw-extra supported for boundbox drawmode too */
if (dt >= OB_BOUNDBOX) {
dtx = ob->dtx;
- if (eval_ctx->object_mode & OB_MODE_EDIT) {
+ if (ob->mode & OB_MODE_EDIT) {
/* the only 2 extra drawtypes alowed in editmode */
dtx = dtx & (OB_DRAWWIRE | OB_TEXSPACE);
}
@@ -8779,7 +8753,7 @@ void draw_object(
if (!skip_object) {
/* draw outline for selected objects, mesh does itself */
if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) {
- if (dt > OB_WIRE && (eval_ctx->object_mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
+ if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
if (!(ob->dtx & OB_DRAWWIRE) && (base->flag & BASE_SELECTED) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
draw_object_selected_outline(eval_ctx, scene, view_layer, v3d, ar, base, ob_wire_col);
}
@@ -8887,7 +8861,7 @@ void draw_object(
case OB_LATTICE:
if (!render_override) {
/* Do not allow boundbox in edit nor pose mode! */
- if ((dt == OB_BOUNDBOX) && (eval_ctx->object_mode & OB_MODE_EDIT))
+ if ((dt == OB_BOUNDBOX) && (ob->mode & OB_MODE_EDIT))
dt = OB_WIRE;
if (dt == OB_BOUNDBOX) {
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
@@ -8903,7 +8877,7 @@ void draw_object(
case OB_ARMATURE:
if (!render_override) {
/* Do not allow boundbox in edit nor pose mode! */
- if ((dt == OB_BOUNDBOX) && (eval_ctx->object_mode & (OB_MODE_EDIT | OB_MODE_POSE)))
+ if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE)))
dt = OB_WIRE;
if (dt == OB_BOUNDBOX) {
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
@@ -8971,7 +8945,7 @@ afterdraw:
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
/* run this so that possible child particles get cached */
- if (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT && is_obact) {
+ if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob);
if (edit && edit->psys == psys)
draw_update_ptcache_edit(eval_ctx, scene, ob, edit);
@@ -8992,7 +8966,7 @@ afterdraw:
(is_obedit == false))
{
- if (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT && is_obact) {
+ if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob);
if (edit) {
gpuLoadMatrix(rv3d->viewmat);
@@ -9093,7 +9067,7 @@ afterdraw:
}
}
- if ((ob->gameflag & OB_BOUNDS) && (eval_ctx->object_mode == OB_MODE_OBJECT)) {
+ if ((ob->gameflag & OB_BOUNDS) && (ob->mode == OB_MODE_OBJECT)) {
if (ob->boundtype != ob->collision_boundtype || (dtx & OB_DRAWBOUNDOX) == 0) {
setlinestyle(2);
draw_bounding_volume(ob, ob->collision_boundtype, ob_wire_col);
@@ -9189,7 +9163,7 @@ afterdraw:
}
/* object centers, need to be drawn in viewmat space for speed, but OK for picking select */
- if (!is_obact || !(eval_ctx->object_mode & OB_MODE_ALL_PAINT)) {
+ if (!is_obact || !(ob->mode & OB_MODE_ALL_PAINT)) {
int do_draw_center = -1; /* defines below are zero or positive... */
if (render_override) {
@@ -9789,7 +9763,7 @@ void draw_object_backbufsel(
switch (ob->type) {
case OB_MESH:
- if (eval_ctx->object_mode & OB_MODE_EDIT) {
+ if (ob->mode & OB_MODE_EDIT) {
Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
@@ -9835,7 +9809,7 @@ void draw_object_backbufsel(
Mesh *me = ob->data;
if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) &&
/* currently vertex select supports weight paint and vertex paint*/
- ((eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) || (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT)))
+ ((ob->mode & OB_MODE_WEIGHT_PAINT) || (ob->mode & OB_MODE_VERTEX_PAINT)))
{
bbs_mesh_solid_verts(eval_ctx, scene, ob);
}
@@ -9864,7 +9838,7 @@ static void draw_object_mesh_instance(
Mesh *me = ob->data;
DerivedMesh *dm = NULL, *edm = NULL;
- if (eval_ctx->object_mode & OB_MODE_EDIT) {
+ if (ob->mode & OB_MODE_EDIT) {
edm = editbmesh_get_derived_base(ob, me->edit_btmesh, CD_MASK_BAREMESH);
DM_update_materials(edm, ob);
}
@@ -9882,11 +9856,11 @@ static void draw_object_mesh_instance(
}
else {
if (outline)
- draw_mesh_object_outline(eval_ctx, v3d, ob, dm ? dm : edm, ob_wire_col);
+ draw_mesh_object_outline(v3d, ob, dm ? dm : edm, ob_wire_col);
if (dm) {
- bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, eval_ctx->object_mode, NULL);
+ bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
+ GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
}
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 3cf915cd029..abfbccdcc27 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -910,7 +910,9 @@ static void view3d_main_region_listener(
case ND_SELECT:
{
WM_manipulatormap_tag_refresh(mmap);
- Object *obedit = OBEDIT_FROM_WINDOW(wmn->window);
+
+ ViewLayer *view_layer = WM_window_get_active_view_layer(wmn->window);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
if (obedit) {
/* TODO(sergey): Notifiers shouldn't really be doing DEG tags. */
DEG_id_tag_update((ID *)obedit->data, DEG_TAG_SELECT_UPDATE);
@@ -1127,8 +1129,9 @@ static void view3d_main_region_message_subscribe(
/* concept is to retrieve cursor type context-less */
static void view3d_main_region_cursor(wmWindow *win, ScrArea *UNUSED(sa), ARegion *UNUSED(ar))
{
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- if (workspace->object_mode & OB_MODE_EDIT) {
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
+ if (obedit) {
WM_cursor_set(win, CURSOR_EDIT);
}
else {
@@ -1380,9 +1383,9 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
if (view_layer->basact) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
+ Object *ob = view_layer->basact->object;
/* if hidden but in edit mode, we still display, can happen with animation */
- if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (workspace->object_mode & OB_MODE_EDIT)) {
+ if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (ob->mode & OB_MODE_EDIT)) {
CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, view_layer->basact);
}
}
@@ -1392,10 +1395,9 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
else if (CTX_data_equals(member, "active_object")) {
ViewLayer *view_layer = CTX_data_view_layer(C);
if (view_layer->basact) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = view_layer->basact->object;
/* if hidden but in edit mode, we still display, can happen with animation */
- if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (workspace->object_mode & OB_MODE_EDIT) != 0) {
+ if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (ob->mode & OB_MODE_EDIT) != 0) {
CTX_data_id_pointer_set(result, &ob->id);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index bd62a4fc3bf..644a6956e54 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -787,12 +787,10 @@ static void do_view3d_vgroup_buttons(bContext *C, void *UNUSED(arg), int event)
static int view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt))
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
-
if (ob && (BKE_object_is_in_editmode_vgroup(ob) ||
- BKE_object_is_in_wpaint_select_vert(ob, workspace->object_mode)))
+ BKE_object_is_in_wpaint_select_vert(ob)))
{
MDeformVert *dvert_act = ED_mesh_active_dvert_get_only(ob);
if (dvert_act) {
@@ -1130,7 +1128,6 @@ static int view3d_panel_transform_poll(const bContext *C, PanelType *UNUSED(pt))
static void view3d_panel_transform(const bContext *C, Panel *pa)
{
uiBlock *block;
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *obedit = CTX_data_edit_object(C);
@@ -1155,7 +1152,7 @@ static void view3d_panel_transform(const bContext *C, Panel *pa)
v3d_editvertex_buts(col, v3d, ob, lim);
}
}
- else if (workspace->object_mode & OB_MODE_POSE) {
+ else if (ob->mode & OB_MODE_POSE) {
v3d_posearmature_buts(col, ob);
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 152d7de4924..596bf28f6b7 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -751,7 +751,7 @@ void ED_view3d_draw_depth(
else
#endif /* WITH_OPENGL_LEGACY */
{
- DRW_draw_depth_loop(graph, ar, v3d, eval_ctx->object_mode);
+ DRW_draw_depth_loop(graph, ar, v3d);
}
if (rv3d->rflag & RV3D_CLIPPING) {
@@ -1325,7 +1325,7 @@ float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit)
return v3d->grid * ED_scene_grid_scale(scene, grid_unit);
}
-static bool is_cursor_visible(const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer)
+static bool is_cursor_visible(Scene *scene, ViewLayer *view_layer)
{
if (U.app_flag & USER_APP_VIEW3D_HIDE_CURSOR) {
return false;
@@ -1334,16 +1334,16 @@ static bool is_cursor_visible(const EvaluationContext *eval_ctx, Scene *scene, V
Object *ob = OBACT(view_layer);
/* don't draw cursor in paint modes, but with a few exceptions */
- if (ob && eval_ctx->object_mode & OB_MODE_ALL_PAINT) {
+ if (ob && ob->mode & OB_MODE_ALL_PAINT) {
/* exception: object is in weight paint and has deforming armature in pose mode */
- if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (ob->mode & OB_MODE_WEIGHT_PAINT) {
if (BKE_object_pose_armature_get(ob) != NULL) {
return true;
}
}
/* exception: object in texture paint mode, clone brush, use_clone_layer disabled */
- else if (eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) {
- const Paint *p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode);
+ else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+ const Paint *p = BKE_paint_get_active(scene, view_layer);
if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) {
@@ -1718,8 +1718,7 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect)
* framenum, object name, bone name (if available), marker name (if available)
*/
-static void draw_selected_name(
- Scene *scene, Object *ob, const eObjectMode object_mode, const rcti *rect)
+static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
{
const int cfra = CFRA;
const char *msg_pin = " (Pinned)";
@@ -1761,7 +1760,7 @@ static void draw_selected_name(
s += BLI_strcpy_rlen(s, arm->act_edbone->name);
}
}
- else if (object_mode & OB_MODE_POSE) {
+ else if (ob->mode & OB_MODE_POSE) {
if (arm->act_bone) {
if (arm->act_bone->layer & arm->layer) {
@@ -1774,9 +1773,9 @@ static void draw_selected_name(
else if (ELEM(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) {
/* try to display active bone and active shapekey too (if they exist) */
- if (ob->type == OB_MESH && object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (ob->type == OB_MESH && ob->mode & OB_MODE_WEIGHT_PAINT) {
Object *armobj = BKE_object_pose_armature_get(ob);
- if (armobj) {
+ if (armobj && armobj->mode & OB_MODE_POSE) {
bArmature *arm = armobj->data;
if (arm->act_bone) {
if (arm->act_bone->layer & arm->layer) {
@@ -1863,10 +1862,9 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset)
}
if (U.uiflag & USER_DRAWVIEWINFO) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
- draw_selected_name(scene, ob, workspace->object_mode, &rect);
+ draw_selected_name(scene, ob, &rect);
}
#if 0 /* TODO */
if (grid_unit) { /* draw below the viewport name */
@@ -1960,7 +1958,7 @@ void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx, Scene *sce
RenderEngineType *engine_type = eval_ctx->engine_type;
if (engine_type->flag & RE_USE_LEGACY_PIPELINE) {
/* shadow buffers, before we setup matrices */
- if (draw_glsl_material(eval_ctx, scene, view_layer, NULL, v3d, v3d->drawtype)) {
+ if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype)) {
VP_deprecated_gpu_update_lamps_shadows_world(eval_ctx, scene, v3d);
}
}
@@ -2051,7 +2049,7 @@ void ED_view3d_draw_offscreen(
}
else {
DRW_draw_render_loop_offscreen(
- eval_ctx->depsgraph, eval_ctx->engine_type, ar, v3d, eval_ctx->object_mode,
+ depsgraph, eval_ctx->engine_type, ar, v3d,
do_sky, ofs, viewport);
}
@@ -2331,10 +2329,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
*
* \{ */
-void VP_legacy_drawcursor(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d)
+void VP_legacy_drawcursor(Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d)
{
- if (is_cursor_visible(eval_ctx, scene, view_layer)) {
+ if (is_cursor_visible(scene, view_layer)) {
drawcursor(scene, ar, v3d);
}
}
@@ -2349,9 +2346,9 @@ void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect)
draw_viewport_name(ar, v3d, rect);
}
-void VP_legacy_draw_selected_name(Scene *scene, Object *ob, eObjectMode object_mode, const rcti *rect)
+void VP_legacy_draw_selected_name(Scene *scene, Object *ob, rcti *rect)
{
- draw_selected_name(scene, ob, object_mode, rect);
+ draw_selected_name(scene, ob, rect);
}
void VP_legacy_drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit)
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index b7a1c8663f4..f1c251891b0 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -219,23 +219,23 @@ static void backdrawview3d(
BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
- if (obact && (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
- BKE_paint_select_face_test(obact, eval_ctx->object_mode)))
+ if (obact && (obact->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
+ BKE_paint_select_face_test(obact)))
{
/* do nothing */
}
/* texture paint mode sampling */
- else if (obact && (eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) &&
+ else if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT) &&
(v3d->drawtype > OB_WIRE))
{
/* do nothing */
}
- else if ((obact && (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) &&
+ else if ((obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) &&
V3D_IS_ZBUF(v3d))
{
/* do nothing */
}
- else if ((eval_ctx->object_mode & OB_MODE_EDIT) && (obedit != NULL) &&
+ else if ((obedit && (obedit->mode & OB_MODE_EDIT)) &&
V3D_IS_ZBUF(v3d))
{
/* do nothing */
@@ -1504,7 +1504,7 @@ static void view3d_draw_objects(
Depsgraph *depsgraph = CTX_data_depsgraph(C);
RegionView3D *rv3d = ar->regiondata;
Base *base;
- Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
const bool do_camera_frame = !draw_offscreen;
const bool draw_grids = !draw_offscreen && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0;
const bool draw_floor = (rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO);
@@ -1934,9 +1934,8 @@ static void update_lods(Scene *scene, float camera_pos[3])
}
#endif
-static void view3d_main_region_draw_objects(
- const bContext *C, Scene *scene, ViewLayer *view_layer, View3D *v3d,
- ARegion *ar, const char **grid_unit)
+static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, ViewLayer *view_layer, View3D *v3d,
+ ARegion *ar, const char **grid_unit)
{
wmWindow *win = CTX_wm_window(C);
EvaluationContext eval_ctx;
@@ -1946,7 +1945,7 @@ static void view3d_main_region_draw_objects(
CTX_data_eval_ctx(C, &eval_ctx);
/* shadow buffers, before we setup matrices */
- if (draw_glsl_material(&eval_ctx, scene, view_layer, NULL, v3d, v3d->drawtype))
+ if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype))
gpu_update_lamps_shadows_world(&eval_ctx, scene, v3d);
/* reset default OpenGL lights if needed (i.e. after preferences have been altered) */
@@ -1988,13 +1987,10 @@ static void view3d_main_region_draw_objects(
}
}
-static void view3d_main_region_draw_info(
- const bContext *C, Scene *scene,
- ARegion *ar, View3D *v3d,
- const char *grid_unit, bool render_border)
+static void view3d_main_region_draw_info(const bContext *C, Scene *scene,
+ ARegion *ar, View3D *v3d,
+ const char *grid_unit, bool render_border)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
const Depsgraph *depsgraph = CTX_data_depsgraph(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
wmWindowManager *wm = CTX_wm_manager(C);
@@ -2017,7 +2013,7 @@ static void view3d_main_region_draw_info(
}
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- VP_legacy_drawcursor(&eval_ctx, scene, view_layer, ar, v3d); /* 3D cursor */
+ VP_legacy_drawcursor(scene, view_layer, ar, v3d); /* 3D cursor */
if (U.uiflag & USER_SHOW_ROTVIEWICON)
VP_legacy_draw_view_axis(rv3d, &rect);
@@ -2026,7 +2022,7 @@ static void view3d_main_region_draw_info(
if (U.uiflag & USER_DRAWVIEWINFO) {
Object *ob = OBACT(view_layer);
- VP_legacy_draw_selected_name(scene, ob, eval_ctx.object_mode, &rect);
+ VP_legacy_draw_selected_name(scene, ob, &rect);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 45284c1805a..0ae69debf18 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -244,22 +244,21 @@ void view3d_orbit_apply_dyn_ofs(
static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
{
static float lastofs[3] = {0, 0, 0};
- const WorkSpace *workspace = CTX_wm_workspace(C);
bool is_set = false;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob_act = OBACT(view_layer);
- if (ob_act && (workspace->object_mode & OB_MODE_ALL_PAINT) &&
+ if (ob_act && (ob_act->mode & OB_MODE_ALL_PAINT) &&
/* with weight-paint + pose-mode, fall through to using calculateTransformCenter */
- ((workspace->object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0)
+ ((ob_act->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0)
{
/* in case of sculpting use last average stroke position as a rotation
* center, in other cases it's not clear what rotation center shall be
* so just rotate around object origin
*/
- if (workspace->object_mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
+ if (ob_act->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
float stroke[3];
BKE_paint_stroke_get_average(scene, ob_act, stroke);
copy_v3_v3(lastofs, stroke);
@@ -269,7 +268,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
}
is_set = true;
}
- else if (ob_act && (workspace->object_mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) {
+ else if (ob_act && (ob_act->mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) {
Curve *cu = ob_act->data;
EditFont *ef = cu->editfont;
int i;
@@ -284,7 +283,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
is_set = true;
}
- else if (ob_act == NULL || workspace->object_mode == OB_MODE_OBJECT) {
+ else if (ob_act == NULL || ob_act->mode == OB_MODE_OBJECT) {
/* object mode use boundbox centers */
Base *base;
unsigned int tot = 0;
@@ -2793,7 +2792,6 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
/* like a localview without local!, was centerview() in 2.4x */
static int viewselected_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
@@ -2817,10 +2815,16 @@ static int viewselected_exec(bContext *C, wmOperator *op)
ob = NULL;
}
- if (ob && (workspace->object_mode & OB_MODE_WEIGHT_PAINT)) {
- Object *ob_armature = BKE_object_pose_armature_get_visible(ob, view_layer);
- if (ob_armature) {
- ob = ob_armature;
+ if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) {
+ /* hard-coded exception, we look for the one selected armature */
+ /* this is weak code this way, we should make a generic active/selection callback interface once... */
+ Base *base;
+ for (base = view_layer->object_bases.first; base; base = base->next) {
+ if (TESTBASELIB(base)) {
+ if (base->object->type == OB_ARMATURE)
+ if (base->object->mode & OB_MODE_POSE)
+ break;
+ }
}
}
@@ -2842,17 +2846,17 @@ static int viewselected_exec(bContext *C, wmOperator *op)
else if (obedit) {
ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */
}
- else if (ob && (workspace->object_mode & OB_MODE_POSE)) {
+ else if (ob && (ob->mode & OB_MODE_POSE)) {
ok = BKE_pose_minmax(ob, min, max, true, true);
}
- else if (BKE_paint_select_face_test(ob, workspace->object_mode)) {
+ else if (BKE_paint_select_face_test(ob)) {
ok = paintface_minmax(ob, min, max);
}
- else if (ob && (workspace->object_mode & OB_MODE_PARTICLE_EDIT)) {
+ else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
ok = PE_minmax(scene, view_layer, min, max);
}
else if (ob &&
- (workspace->object_mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)))
+ (ob->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)))
{
BKE_paint_stroke_get_average(scene, ob, min);
copy_v3_v3(max, min);
@@ -2964,8 +2968,7 @@ static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op))
v3d->ob_centre = obact; /* can be NULL */
if (obact && obact->type == OB_ARMATURE) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->object_mode & OB_MODE_POSE) {
+ if (obact->mode & OB_MODE_POSE) {
bPoseChannel *pcham_act = BKE_pose_channel_active(obact);
if (pcham_act) {
BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone));
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 35a37590642..3ed6c87b750 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -276,7 +276,6 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
bScreen *screen = CTX_wm_screen(C);
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
@@ -291,7 +290,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
uiLayout *row;
bool is_paint = (
ob && !(gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)) &&
- ELEM(workspace->object_mode,
+ ELEM(ob->mode,
OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT, OB_MODE_TEXTURE_PAINT));
RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr);
@@ -306,18 +305,18 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
row = uiLayoutRow(layout, true);
uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
- if (!ob || ELEM(workspace->object_mode, OB_MODE_OBJECT, OB_MODE_POSE, OB_MODE_WEIGHT_PAINT)) {
+ if (!ob || ELEM(ob->mode, OB_MODE_OBJECT, OB_MODE_POSE, OB_MODE_WEIGHT_PAINT)) {
uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
}
if (obedit == NULL && is_paint) {
/* Manipulators aren't used in paint modes */
- if (!ELEM(workspace->object_mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) {
+ if (!ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) {
/* masks aren't used for sculpt and particle painting */
PointerRNA meshptr;
RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr);
- if (workspace->object_mode & (OB_MODE_TEXTURE_PAINT)) {
+ if (ob->mode & (OB_MODE_TEXTURE_PAINT)) {
uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 56e5c4e932c..0f56f1265bc 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -54,7 +54,6 @@ struct wmKeyConfig;
struct wmManipulatorGroupType;
struct wmManipulatorType;
struct wmWindowManager;
-struct EvaluationContext;
/* drawing flags: */
enum {
@@ -155,19 +154,13 @@ void draw_object_select(
const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, struct ARegion *ar, View3D *v3d,
Base *base, const short dflag);
-void draw_mesh_object_outline(
- const struct EvaluationContext *eval_ctx, View3D *v3d,
- struct Object *ob, struct DerivedMesh *dm, const unsigned char ob_wire_col[4]);
+void draw_mesh_object_outline(View3D *v3d, struct Object *ob, struct DerivedMesh *dm, const unsigned char ob_wire_col[4]);
-bool draw_glsl_material(
- const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer,
- struct Object *ob, View3D *v3d, const char dt);
+bool draw_glsl_material(Scene *scene, struct ViewLayer *view_layer, struct Object *ob, View3D *v3d, const char dt);
void draw_object_instance(const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const char dt, int outline, const float wire_col[4]);
void draw_object_backbufsel(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob);
-void draw_object_wire_color(
- const struct EvaluationContext *eval_ctx, struct ViewLayer *,
- Base *base, unsigned char r_ob_wire_col[4]);
+void draw_object_wire_color(struct ViewLayer *, Base *base, unsigned char r_ob_wire_col[4]);
void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const unsigned char color[4]);
void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const short dflag, const unsigned char ob_wire_col[4],
@@ -216,10 +209,8 @@ void draw_mesh_paint_vcolor_faces(struct DerivedMesh *dm, const bool use_light,
void draw_mesh_paint_weight_edges(RegionView3D *rv3d, struct DerivedMesh *dm,
const bool use_depth, const bool use_alpha,
void *edgemask_cb, void *user_data);
-void draw_mesh_paint(
- const struct EvaluationContext *eval_ctx,
- View3D *v3d, RegionView3D *rv3d,
- struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
+void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
+ struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
/* drawsimdebug.c */
void draw_sim_debug_data(Scene *scene, View3D *v3d, ARegion *ar);
@@ -376,12 +367,10 @@ extern bool view3d_camera_border_hack_test;
#endif
/* temporary for legacy viewport to work */
-void VP_legacy_drawcursor(
- const struct EvaluationContext *eval_ctx, Scene *scene,
- struct ViewLayer *view_layer, ARegion *ar, View3D *v3d);
+void VP_legacy_drawcursor(Scene *scene, struct ViewLayer *view_layer, ARegion *ar, View3D *v3d);
void VP_legacy_draw_view_axis(RegionView3D *rv3d, const rcti *rect);
void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect);
-void VP_legacy_draw_selected_name(Scene *scene, struct Object *ob, eObjectMode object_mode, const rcti *rect);
+void VP_legacy_draw_selected_name(Scene *scene, struct Object *ob, rcti *rect);
void VP_legacy_drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit);
void VP_legacy_drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool write_depth);
void VP_legacy_view3d_main_region_setup_view(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4]);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 0d37d0bd680..be8e63dffe6 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -210,7 +210,6 @@ static void edbm_backbuf_check_and_select_tfaces(Mesh *me, const bool select)
/* *********************** GESTURE AND LASSO ******************* */
typedef struct LassoSelectUserData {
- const EvaluationContext *eval_ctx;
ViewContext *vc;
const rcti *rect;
const rctf *rect_fl;
@@ -254,15 +253,14 @@ static int view3d_selectable_data(bContext *C)
return 0;
if (ob) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->object_mode & OB_MODE_EDIT) {
+ if (ob->mode & OB_MODE_EDIT) {
if (ob->type == OB_FONT) {
return 0;
}
}
else {
- if ((workspace->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) &&
- !BKE_paint_select_elem_test(ob, workspace->object_mode))
+ if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) &&
+ !BKE_paint_select_elem_test(ob))
{
return 0;
}
@@ -393,7 +391,6 @@ static void object_deselect_all_visible(ViewLayer *view_layer)
}
static void do_lasso_select_objects(
- const EvaluationContext *eval_ctx,
ViewContext *vc, const int mcords[][2], const short moves,
const bool extend, const bool select)
{
@@ -410,7 +407,7 @@ static void do_lasso_select_objects(
ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
}
}
- if (vc->obact == base->object && (eval_ctx->object_mode & OB_MODE_POSE)) {
+ if (vc->obact == base->object && (base->object->mode & OB_MODE_POSE)) {
do_lasso_select_pose(vc, base->object, mcords, moves, select);
}
}
@@ -466,7 +463,7 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, cons
}
static void do_lasso_select_mesh(
- const EvaluationContext *eval_ctx, ViewContext *vc,
+ const struct EvaluationContext *eval_ctx, ViewContext *vc,
const int mcords[][2], short moves, bool extend, bool select)
{
LassoSelectUserData data;
@@ -522,8 +519,7 @@ static void do_lasso_select_mesh(
EDBM_selectmode_flush(vc->em);
}
-static void do_lasso_select_curve__doSelect(
- void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2])
+static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2])
{
LassoSelectUserData *data = userData;
Object *obedit = data->vc->obedit;
@@ -598,8 +594,7 @@ static void do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], shor
lattice_foreachScreenVert(vc, do_lasso_select_lattice__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
-static void do_lasso_select_armature__doSelectBone(
- void *userData, struct EditBone *ebone, const float screen_co_a[2], const float screen_co_b[2])
+static void do_lasso_select_armature__doSelectBone(void *userData, struct EditBone *ebone, const float screen_co_a[2], const float screen_co_b[2])
{
LassoSelectUserData *data = userData;
bArmature *arm = data->vc->obedit->data;
@@ -705,8 +700,7 @@ static void do_lasso_select_meta(ViewContext *vc, const int mcords[][2], short m
mball_foreachScreenElem(vc, do_lasso_select_mball__doSelectElem, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
-static void do_lasso_select_meshobject__doSelectVert(
- void *userData, MVert *mv, const float screen_co[2], int UNUSED(index))
+static void do_lasso_select_meshobject__doSelectVert(void *userData, MVert *mv, const float screen_co[2], int UNUSED(index))
{
LassoSelectUserData *data = userData;
@@ -716,9 +710,7 @@ static void do_lasso_select_meshobject__doSelectVert(
SET_FLAG_FROM_TEST(mv->flag, data->select, SELECT);
}
}
-static void do_lasso_select_paintvert(
- const EvaluationContext *eval_ctx,
- ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
+static void do_lasso_select_paintvert(const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
{
const bool use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT) != 0;
Object *ob = vc->obact;
@@ -749,8 +741,8 @@ static void do_lasso_select_paintvert(
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d);
- meshobject_foreachScreenVert(
- eval_ctx, vc, do_lasso_select_meshobject__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ meshobject_foreachScreenVert(eval_ctx, vc, do_lasso_select_meshobject__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+
}
if (select == false) {
@@ -758,9 +750,7 @@ static void do_lasso_select_paintvert(
}
paintvert_flush_flags(ob);
}
-static void do_lasso_select_paintface(
- const EvaluationContext *eval_ctx,
- ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
+static void do_lasso_select_paintface(const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
{
Object *ob = vc->obact;
Mesh *me = ob->data;
@@ -826,20 +816,20 @@ static void view3d_lasso_select(
CTX_data_eval_ctx(C, &eval_ctx);
if (vc->obedit == NULL) { /* Object Mode */
- if (BKE_paint_select_face_test(ob, eval_ctx.object_mode)) {
+ if (BKE_paint_select_face_test(ob)) {
do_lasso_select_paintface(&eval_ctx, vc, mcords, moves, extend, select);
}
- else if (BKE_paint_select_vert_test(ob, eval_ctx.object_mode)) {
+ else if (BKE_paint_select_vert_test(ob)) {
do_lasso_select_paintvert(&eval_ctx, vc, mcords, moves, extend, select);
}
- else if (ob && (eval_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
+ else if (ob && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
/* pass */
}
- else if (ob && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) {
+ else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
PE_lasso_select(C, mcords, moves, extend, select);
}
else {
- do_lasso_select_objects(&eval_ctx, vc, mcords, moves, extend, select);
+ do_lasso_select_objects(vc, mcords, moves, extend, select);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene);
}
}
@@ -1510,10 +1500,7 @@ static bool ed_object_select_pick(
}
}
}
- else if (ED_do_pose_selectbuffer(
- &eval_ctx, view_layer,
- basact, buffer, hits, extend, deselect, toggle, do_nearest))
- {
+ else if (ED_do_pose_selectbuffer(view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest)) {
/* then bone is found */
/* we make the armature selected:
@@ -1526,7 +1513,7 @@ static bool ed_object_select_pick(
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object);
/* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */
- if (BASACT(view_layer) && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) {
+ if (BASACT(view_layer) && (BASACT(view_layer)->object->mode & OB_MODE_WEIGHT_PAINT)) {
/* prevent activating */
basact = NULL;
}
@@ -1624,8 +1611,7 @@ bool edge_inside_circle(const float cent[2], float radius, const float screen_co
return (dist_squared_to_line_segment_v2(cent, screen_co_a, screen_co_b) < radius_squared);
}
-static void do_paintvert_box_select__doSelectVert(
- void *userData, MVert *mv, const float screen_co[2], int UNUSED(index))
+static void do_paintvert_box_select__doSelectVert(void *userData, MVert *mv, const float screen_co[2], int UNUSED(index))
{
BoxSelectUserData *data = userData;
@@ -1824,7 +1810,7 @@ static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, const
}
}
static int do_mesh_box_select(
- const EvaluationContext *eval_ctx, ViewContext *vc, rcti *rect, bool select, bool extend)
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, rcti *rect, bool select, bool extend)
{
BoxSelectUserData data;
ToolSettings *ts = vc->scene->toolsettings;
@@ -1878,7 +1864,7 @@ static int do_mesh_box_select(
}
static int do_meta_box_select(
- const EvaluationContext *eval_ctx, ViewContext *vc,
+ const struct EvaluationContext *eval_ctx, ViewContext *vc,
const rcti *rect, bool select, bool extend)
{
MetaBall *mb = (MetaBall *)vc->obedit->data;
@@ -1914,7 +1900,7 @@ static int do_meta_box_select(
}
static int do_armature_box_select(
- const EvaluationContext *eval_ctx, ViewContext *vc,
+ const struct EvaluationContext *eval_ctx, ViewContext *vc,
const rcti *rect, bool select, bool extend)
{
bArmature *arm = vc->obedit->data;
@@ -2023,7 +2009,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
CTX_data_eval_ctx(C, &eval_ctx);
- if ((ob) && (eval_ctx.object_mode & OB_MODE_POSE))
+ if ((ob) && (ob->mode & OB_MODE_POSE))
bone_only = 1;
else
bone_only = 0;
@@ -2178,16 +2164,16 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
}
}
else { /* no editmode, unified for bones and objects */
- if (vc.obact && eval_ctx.object_mode & OB_MODE_SCULPT) {
+ if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
ret = ED_sculpt_mask_box_select(C, &vc, &rect, select, extend);
}
- else if (vc.obact && BKE_paint_select_face_test(vc.obact, eval_ctx.object_mode)) {
+ else if (vc.obact && BKE_paint_select_face_test(vc.obact)) {
ret = do_paintface_box_select(&eval_ctx, &vc, &rect, select, extend);
}
- else if (vc.obact && BKE_paint_select_vert_test(vc.obact, eval_ctx.object_mode)) {
+ else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) {
ret = do_paintvert_box_select(&eval_ctx, &vc, &rect, select, extend);
}
- else if (vc.obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) {
+ else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
ret = PE_border_select(C, &rect, select, extend);
}
else { /* object mode with none active */
@@ -2273,7 +2259,6 @@ static bool ed_wpaint_vertex_select_pick(
static int view3d_select_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
bool extend = RNA_boolean_get(op->ptr, "extend");
@@ -2285,9 +2270,9 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
* or paint-select to allow pose bone select with vert/face select */
bool object = (RNA_boolean_get(op->ptr, "object") &&
(obedit ||
- BKE_paint_select_elem_test(obact, workspace->object_mode) ||
+ BKE_paint_select_elem_test(obact) ||
/* so its possible to select bones in weightpaint mode (LMB select) */
- (obact && (workspace->object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact))));
+ (obact && (obact->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact))));
bool retval = false;
int location[2];
@@ -2321,11 +2306,11 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
retval = ED_curve_editfont_select_pick(C, location, extend, deselect, toggle);
}
- else if (obact && workspace->object_mode & OB_MODE_PARTICLE_EDIT)
+ else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
return PE_mouse_particles(C, location, extend, deselect, toggle);
- else if (obact && BKE_paint_select_face_test(obact, workspace->object_mode))
+ else if (obact && BKE_paint_select_face_test(obact))
retval = paintface_mouse_select(C, obact, location, extend, deselect, toggle);
- else if (BKE_paint_select_vert_test(obact, workspace->object_mode))
+ else if (BKE_paint_select_vert_test(obact))
retval = ed_wpaint_vertex_select_pick(C, location, extend, deselect, toggle, obact);
else
retval = ed_object_select_pick(C, location, extend, deselect, toggle, center, enumerate, object);
@@ -2432,9 +2417,7 @@ static void mesh_circle_doSelectFace(void *userData, BMFace *efa, const float sc
}
}
-static void mesh_circle_select(
- const EvaluationContext *eval_ctx,
- ViewContext *vc, const bool select, const int mval[2], float rad)
+static void mesh_circle_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
{
ToolSettings *ts = vc->scene->toolsettings;
int bbsel;
@@ -2478,9 +2461,7 @@ static void mesh_circle_select(
EDBM_selectmode_flush(vc->em);
}
-static void paint_facesel_circle_select(
- const EvaluationContext *eval_ctx,
- ViewContext *vc, const bool select, const int mval[2], float rad)
+static void paint_facesel_circle_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
{
Object *ob = vc->obact;
Mesh *me = ob->data;
@@ -2496,8 +2477,7 @@ static void paint_facesel_circle_select(
}
}
-static void paint_vertsel_circle_select_doSelectVert(
- void *userData, MVert *mv, const float screen_co[2], int UNUSED(index))
+static void paint_vertsel_circle_select_doSelectVert(void *userData, MVert *mv, const float screen_co[2], int UNUSED(index))
{
CircleSelectUserData *data = userData;
@@ -2505,8 +2485,7 @@ static void paint_vertsel_circle_select_doSelectVert(
SET_FLAG_FROM_TEST(mv->flag, data->select, SELECT);
}
}
-static void paint_vertsel_circle_select(
- const EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
+static void paint_vertsel_circle_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
{
const bool use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT) != 0;
Object *ob = vc->obact;
@@ -2529,8 +2508,7 @@ static void paint_vertsel_circle_select(
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
- meshobject_foreachScreenVert(
- eval_ctx, vc, paint_vertsel_circle_select_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ meshobject_foreachScreenVert(eval_ctx, vc, paint_vertsel_circle_select_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
if (select != LEFTMOUSE) {
@@ -2788,7 +2766,7 @@ static void mball_circle_select(ViewContext *vc, const bool select, const int mv
/** Callbacks for circle selection in Editmode */
static void obedit_circle_select(
- const EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
{
switch (vc->obedit->type) {
case OB_MESH:
@@ -2843,48 +2821,53 @@ static bool object_circle_select(ViewContext *vc, const bool select, const int m
/* not a real operator, only for circle test */
static int view3d_circle_select_exec(bContext *C, wmOperator *op)
{
- ViewContext vc;
- ED_view3d_viewcontext_init(C, &vc);
- Object *obact = vc.obact;
- Object *obedit = vc.obedit;
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Scene *scene = CTX_data_scene(C);
+ Object *obact = CTX_data_active_object(C);
const int radius = RNA_int_get(op->ptr, "radius");
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const int mval[2] = {RNA_int_get(op->ptr, "x"),
RNA_int_get(op->ptr, "y")};
- if (obedit || BKE_paint_select_elem_test(obact, eval_ctx.object_mode) ||
- (obact && (eval_ctx.object_mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) )
+ if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(obact) ||
+ (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) )
{
+ EvaluationContext eval_ctx;
+ ViewContext vc;
+
view3d_operator_needs_opengl(C);
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+ ED_view3d_viewcontext_init(C, &vc);
if (CTX_data_edit_object(C)) {
obedit_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
- else if (BKE_paint_select_face_test(obact, eval_ctx.object_mode)) {
+ else if (BKE_paint_select_face_test(obact)) {
paint_facesel_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
- else if (BKE_paint_select_vert_test(obact, eval_ctx.object_mode)) {
+ else if (BKE_paint_select_vert_test(obact)) {
paint_vertsel_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
- else if (eval_ctx.object_mode & OB_MODE_POSE)
+ else if (obact->mode & OB_MODE_POSE)
pose_circle_select(&vc, select, mval, (float)radius);
else
return PE_circle_select(C, select, mval, (float)radius);
}
- else if (obact && eval_ctx.object_mode & OB_MODE_SCULPT) {
+ else if (obact && obact->mode & OB_MODE_SCULPT) {
return OPERATOR_CANCELLED;
}
else {
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc);
+
if (object_circle_select(&vc, select, mval, (float)radius)) {
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc.scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
}
-
+
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 40dd2f0f428..1df29201bf6 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -113,7 +113,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
- if (eval_ctx.object_mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan;
bArmature *arm = ob->data;
@@ -272,7 +272,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
ED_transverts_update_obedit(&tvs, obedit);
ED_transverts_free(&tvs);
}
- else if (obact && (eval_ctx.object_mode & OB_MODE_POSE)) {
+ else if (obact && (obact->mode & OB_MODE_POSE)) {
struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID);
bPoseChannel *pchan;
@@ -554,8 +554,6 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -601,7 +599,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
else {
Object *obact = CTX_data_active_object(C);
- if (obact && (eval_ctx.object_mode & OB_MODE_POSE)) {
+ if (obact && (obact->mode & OB_MODE_POSE)) {
bArmature *arm = obact->data;
bPoseChannel *pchan;
for (pchan = obact->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -703,8 +701,7 @@ static bool snap_calc_active_center(bContext *C, const bool select_only, float r
Object *ob = CTX_data_active_object(C);
if (ob) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->object_mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan = BKE_pose_channel_active(ob);
if (pchan) {
if (!select_only || (pchan->bone->flag & BONE_SELECTED)) {
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 4225ee8b425..1a547d07b80 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -918,7 +918,7 @@ int view3d_opengl_select(
ARegion *ar = vc->ar;
rcti rect;
int hits;
- const bool use_obedit_skip = (OBEDIT_FROM_EVAL_CTX(eval_ctx) != NULL) && (vc->obedit == NULL);
+ const bool use_obedit_skip = (OBEDIT_FROM_VIEW_LAYER(vc->view_layer) != NULL) && (vc->obedit == NULL);
const bool is_pick_select = (U.gpu_select_pick_deph != 0);
const bool do_passes = (
(is_pick_select == false) &&
@@ -1016,7 +1016,7 @@ int view3d_opengl_select(
.gpu_select_mode = gpu_select_mode,
};
DRW_draw_select_loop(
- graph, ar, v3d, eval_ctx->object_mode,
+ graph, ar, v3d,
use_obedit_skip, use_nearest, &rect,
drw_select_loop_pass, &drw_select_loop_user_data);
hits = drw_select_loop_user_data.hits;
@@ -1104,13 +1104,11 @@ int ED_view3d_view_layer_set(int lay, const int *values, int *active)
static ListBase queue_back;
static void game_engine_save_state(bContext *C, wmWindow *win)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *obact = CTX_data_active_object(C);
glPushAttrib(GL_ALL_ATTRIB_BITS);
- if (obact && eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) {
+ if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
GPU_paint_set_mipmap(1);
}
@@ -1121,11 +1119,9 @@ static void game_engine_save_state(bContext *C, wmWindow *win)
static void game_engine_restore_state(bContext *C, wmWindow *win)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *obact = CTX_data_active_object(C);
- if (obact && eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) {
+ if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
GPU_paint_set_mipmap(0);
}
/* check because closing win can set to NULL */
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index b198918b698..fe05207e645 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -655,7 +655,7 @@ void restoreBones(TransInfo *t);
#define MANIPULATOR_AXIS_LINE_WIDTH 2.0f
/* return 0 when no gimbal for selection */
-bool gimbal_axis(struct Object *ob, float gmat[3][3], const eObjectMode object_mode);
+bool gimbal_axis(struct Object *ob, float gmat[3][3]);
/*********************** TransData Creation and General Handling *********** */
void createTransData(struct bContext *C, TransInfo *t);
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 3ccf65a8a69..2d7ff1eb523 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -998,7 +998,7 @@ static short pose_grab_with_ik(Object *ob)
Bone *bonec;
short tot_ik = 0;
- if ((ob == NULL) || (ob->pose == NULL))
+ if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0)
return 0;
arm = ob->data;
@@ -2559,7 +2559,7 @@ static void createTransEditVerts(TransInfo *t)
/* detect CrazySpace [tm] */
if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1) != -1) {
int totleft = -1;
- if (modifiers_isCorrectableDeformed(&t->eval_ctx, t->scene, t->obedit)) {
+ if (modifiers_isCorrectableDeformed(t->scene, t->obedit)) {
/* check if we can use deform matrices for modifier from the
* start up to stack, they are more accurate than quats */
totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(&t->eval_ctx, t->scene, t->obedit, em, &defmats, &defcos);
@@ -6549,7 +6549,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
else if ((t->view_layer->basact) &&
(ob = t->view_layer->basact->object) &&
- (t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) &&
+ (ob->mode & OB_MODE_PARTICLE_EDIT) &&
PE_get_current(t->scene, ob))
{
/* do nothing */
@@ -8287,28 +8287,26 @@ void createTransData(bContext *C, TransInfo *t)
t->poseobj = ob; /* <- tsk tsk, this is going to give issues one day */
}
}
- else if (ob && (t->eval_ctx.object_mode & OB_MODE_POSE)) {
+ else if (ob && (ob->mode & OB_MODE_POSE)) {
// XXX this is currently limited to active armature only...
// XXX active-layer checking isn't done as that should probably be checked through context instead
createTransPose(t, ob);
}
- else if (ob && (t->eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) {
+ else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) {
/* important that ob_armature can be set even when its not selected [#23412]
* lines below just check is also visible */
Object *ob_armature = modifiers_isDeformedByArmature(ob);
- if (ob_armature) {
-// const bArmature *arm = ob_armature->data;
+ if (ob_armature && ob_armature->mode & OB_MODE_POSE) {
Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
if (base_arm) {
if (BASE_VISIBLE(base_arm)) {
createTransPose(t, ob_armature);
}
}
+
}
}
- else if (ob && (t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) &&
- PE_start_edit(PE_get_current(scene, ob)))
- {
+ else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, ob))) {
createTransParticleVerts(C, t);
t->flag |= T_POINTS;
@@ -8318,7 +8316,7 @@ void createTransData(bContext *C, TransInfo *t)
sort_trans_data_dist(t);
}
}
- else if (ob && (t->eval_ctx.object_mode & OB_MODE_ALL_PAINT)) {
+ else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
if ((t->options & CTX_PAINT_CURVE) && !ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN)) {
t->flag |= T_POINTS | T_2D_EDIT;
createTransPaintCurveVerts(C, t);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index e051b401f87..b42e00a2bb4 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -901,7 +901,7 @@ static void recalcData_objects(TransInfo *t)
else
BKE_pose_where_is(&t->eval_ctx, t->scene, ob);
}
- else if (base && (t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) &&
+ else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) &&
PE_get_current(t->scene, base->object))
{
if (t->state != TRANS_CANCEL) {
@@ -1266,7 +1266,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
- if (ob && t->eval_ctx.object_mode & OB_MODE_ALL_PAINT) {
+ if (ob && ob->mode & OB_MODE_ALL_PAINT) {
Paint *p = BKE_paint_get_active_from_context(C);
if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) {
t->options |= CTX_PAINT_CURVE;
@@ -1815,7 +1815,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
}
}
else if (t->options & CTX_PAINT_CURVE) {
- Paint *p = BKE_paint_get_active(t->scene, t->view_layer, t->eval_ctx.object_mode);
+ Paint *p = BKE_paint_get_active(t->scene, t->view_layer);
Brush *br = p->brush;
PaintCurve *pc = br->paint_curve;
copy_v3_v3(r_center, pc->points[pc->add_index - 1].bez.vec[1]);
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index cb5b17b415e..8944817baca 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -520,9 +520,9 @@ static bool test_rotmode_euler(short rotmode)
return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0 : 1;
}
-bool gimbal_axis(Object *ob, float gmat[3][3], const eObjectMode object_mode)
+bool gimbal_axis(Object *ob, float gmat[3][3])
{
- if (object_mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan = BKE_pose_channel_active(ob);
if (pchan) {
@@ -591,7 +591,6 @@ static int calc_manipulator_stats(
const bContext *C, bool use_only_center,
struct TransformBounds *tbounds)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
@@ -629,7 +628,7 @@ static int calc_manipulator_stats(
case V3D_MANIP_GIMBAL:
{
float mat[3][3];
- if (gimbal_axis(ob, mat, workspace->object_mode)) {
+ if (gimbal_axis(ob, mat)) {
copy_m4_m3(rv3d->twmat, mat);
break;
}
@@ -638,7 +637,7 @@ static int calc_manipulator_stats(
}
case V3D_MANIP_NORMAL:
{
- if (obedit || workspace->object_mode & OB_MODE_POSE) {
+ if (obedit || ob->mode & OB_MODE_POSE) {
float mat[3][3];
ED_getTransformOrientationMatrix(C, mat, v3d->around);
copy_m4_m3(rv3d->twmat, mat);
@@ -649,7 +648,7 @@ static int calc_manipulator_stats(
}
case V3D_MANIP_LOCAL:
{
- if (workspace->object_mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
/* each bone moves on its own local axis, but to avoid confusion,
* use the active pones axis for display [#33575], this works as expected on a single bone
* and users who select many bones will understand whats going on and what local means
@@ -691,7 +690,7 @@ static int calc_manipulator_stats(
#ifdef USE_AXIS_BOUNDS
copy_m3_m4(tbounds->axis, rv3d->twmat);
- if (ob && workspace->object_mode & OB_MODE_EDIT) {
+ if (ob && ob->mode & OB_MODE_EDIT) {
float diff_mat[3][3];
copy_m3_m4(diff_mat, ob->obmat);
normalize_m3(diff_mat);
@@ -934,7 +933,7 @@ static int calc_manipulator_stats(
mul_m4_v3(obedit->obmat, tbounds->max);
}
}
- else if (ob && (workspace->object_mode & OB_MODE_POSE)) {
+ else if (ob && (ob->mode & OB_MODE_POSE)) {
bPoseChannel *pchan;
int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed
bool ok = false;
@@ -972,10 +971,10 @@ static int calc_manipulator_stats(
mul_m4_v3(ob->obmat, tbounds->max);
}
}
- else if (ob && (workspace->object_mode & OB_MODE_ALL_PAINT)) {
+ else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
/* pass */
}
- else if (ob && workspace->object_mode & OB_MODE_PARTICLE_EDIT) {
+ else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) {
PTCacheEdit *edit = PE_get_current(scene, ob);
PTCacheEditPoint *point;
PTCacheEditKey *ek;
@@ -1065,13 +1064,12 @@ static void manipulator_prepare_mat(
case V3D_AROUND_CENTER_BOUNDS:
case V3D_AROUND_ACTIVE:
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
Object *ob = OBACT(view_layer);
- if (((v3d->around == V3D_AROUND_ACTIVE) && ((workspace->object_mode & OB_MODE_EDIT) == 0)) &&
+ if (((v3d->around == V3D_AROUND_ACTIVE) && (OBEDIT_FROM_OBACT(ob) == NULL)) &&
((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) &&
- (!(workspace->object_mode & OB_MODE_POSE)))
+ (!(ob->mode & OB_MODE_POSE)))
{
copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
}
@@ -1660,10 +1658,10 @@ static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulator
{
struct XFormCageWidgetGroup *xmgroup = mgroup->customdata;
wmManipulator *mpr = xmgroup->manipulator;
- const WorkSpace *workspace = CTX_wm_workspace(C);
+
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
- if (ob && workspace->object_mode & OB_MODE_EDIT) {
+ if (ob && ob->mode & OB_MODE_EDIT) {
copy_m4_m4(mpr->matrix_space, ob->obmat);
}
else {
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index b39e5f286c0..7b3f91b81da 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -55,8 +55,6 @@
#include "BKE_screen.h"
#include "BKE_workspace.h"
-#include "DEG_depsgraph.h"
-
#include "BLT_translation.h"
#include "ED_armature.h"
@@ -298,7 +296,6 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports,
ts = createViewSpace(C, reports, name, overwrite);
}
else {
- const WorkSpace *workspace = CTX_wm_workspace(C);
Object *obedit = CTX_data_edit_object(C);
Object *ob = CTX_data_active_object(C);
if (obedit) {
@@ -309,7 +306,7 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports,
else if (obedit->type == OB_CURVE)
ts = createCurveSpace(C, reports, name, overwrite);
}
- else if (ob && (workspace->object_mode & OB_MODE_POSE)) {
+ else if (ob && (ob->mode & OB_MODE_POSE)) {
ts = createBoneSpace(C, reports, name, overwrite);
}
else {
@@ -444,13 +441,13 @@ void initTransformOrientation(bContext *C, TransInfo *t)
case V3D_MANIP_GIMBAL:
unit_m3(t->spacemtx);
- if (ob && gimbal_axis(ob, t->spacemtx, t->eval_ctx.object_mode)) {
+ if (ob && gimbal_axis(ob, t->spacemtx)) {
BLI_strncpy(t->spacename, IFACE_("gimbal"), sizeof(t->spacename));
break;
}
ATTR_FALLTHROUGH; /* no gimbal fallthrough to normal */
case V3D_MANIP_NORMAL:
- if (obedit || (ob && t->eval_ctx.object_mode & OB_MODE_POSE)) {
+ if (obedit || (ob && ob->mode & OB_MODE_POSE)) {
BLI_strncpy(t->spacename, IFACE_("normal"), sizeof(t->spacename));
ED_getTransformOrientationMatrix(C, t->spacemtx, t->around);
break;
@@ -581,7 +578,6 @@ static unsigned int bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const
int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3], const short around)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *obedit = CTX_data_edit_object(C);
Base *base;
@@ -1012,7 +1008,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
mul_m3_v3(mat, plane);
}
}
- else if (ob && (workspace->object_mode & OB_MODE_POSE)) {
+ else if (ob && (ob->mode & OB_MODE_POSE)) {
bArmature *arm = ob->data;
bPoseChannel *pchan;
float imat[3][3], mat[3][3];
@@ -1052,7 +1048,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
result = ORIENTATION_EDGE;
}
}
- else if (ob && (workspace->object_mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) {
+ else if (ob && (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) {
/* pass */
}
else {
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 9946f1ad546..ad913cd2336 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -544,7 +544,7 @@ static void initSnappingMode(TransInfo *t)
}
/* Particles edit mode*/
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
- (obedit == NULL && base_act && base_act->object && t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT))
+ (obedit == NULL && base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT))
{
t->tsnap.modeSelect = SNAP_ALL;
}
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 0020b0924bb..c336cd1d31e 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -821,7 +821,7 @@ static bool raycastObjects(
Object **r_ob, float r_obmat[4][4],
ListBase *r_hit_list)
{
- Object *obedit = use_object_edit_cage ? OBEDIT_FROM_EVAL_CTX(&sctx->eval_ctx) : NULL;
+ Object *obedit = use_object_edit_cage ? OBEDIT_FROM_VIEW_LAYER(sctx->eval_ctx.view_layer) : NULL;
struct RaycastObjUserData data = {
.ray_start = ray_start,
@@ -2054,7 +2054,7 @@ static bool snapObjectsRay(
float r_loc[3], float r_no[3],
Object **r_ob, float r_obmat[4][4])
{
- Object *obedit = use_object_edit_cage ? OBEDIT_FROM_EVAL_CTX(&sctx->eval_ctx) : NULL;
+ Object *obedit = use_object_edit_cage ? OBEDIT_FROM_VIEW_LAYER(sctx->eval_ctx.view_layer) : NULL;
struct SnapObjUserData data = {
.snapdata = snapdata,
@@ -2089,7 +2089,7 @@ SnapObjectContext *ED_transform_snap_object_context_create(
sctx->scene = scene;
DEG_evaluation_context_init_from_scene(
- &sctx->eval_ctx, scene, view_layer, engine_type, OB_MODE_OBJECT, DAG_EVAL_VIEWPORT);
+ &sctx->eval_ctx, scene, view_layer, engine_type, DAG_EVAL_VIEWPORT);
sctx->cache.object_map = BLI_ghash_ptr_new(__func__);
sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c
index 5033d741c7b..b588aa8fb13 100644
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@ -45,38 +45,13 @@
#include "undo_intern.h"
-/** Store workspace modes in undo steps, this may be removed if find a better way to handle. */
-#define USE_WORKSPACE_OBJECT_MODE_HACK
-
-#ifdef USE_WORKSPACE_OBJECT_MODE_HACK
-#include "MEM_guardedalloc.h"
-#include "BLI_string.h"
-#include "BLI_listbase.h"
-#include "BKE_main.h"
-#include "DNA_workspace_types.h"
-#endif
-
-
/* -------------------------------------------------------------------- */
/** \name Implements ED Undo System
* \{ */
-#ifdef USE_WORKSPACE_OBJECT_MODE_HACK
-typedef struct WorkSpaceData {
- struct WorkSpaceData *next, *prev;
- char name[MAX_ID_NAME - 2];
- eObjectMode object_mode, object_mode_restore;
- /* TODO, view_layer? */
-} WorkSpaceData;
-#endif /* USE_WORKSPACE_OBJECT_MODE_HACK */
-
typedef struct MemFileUndoStep {
UndoStep step;
MemFileUndoData *data;
-
-#ifdef USE_WORKSPACE_OBJECT_MODE_HACK
- ListBase workspace_data;
-#endif
} MemFileUndoStep;
static bool memfile_undosys_poll(bContext *UNUSED(C))
@@ -101,18 +76,6 @@ static bool memfile_undosys_step_encode(struct bContext *C, UndoStep *us_p)
us->data = BKE_memfile_undo_encode(bmain, us_prev ? us_prev->data : NULL);
us->step.data_size = us->data->undo_size;
-#ifdef USE_WORKSPACE_OBJECT_MODE_HACK
- {
- for (WorkSpace *workspace = bmain->workspaces.first; workspace != NULL; workspace = workspace->id.next) {
- WorkSpaceData *wsd = MEM_mallocN(sizeof(*wsd), __func__);
- BLI_strncpy(wsd->name, workspace->id.name + 2, sizeof(wsd->name));
- wsd->object_mode = workspace->object_mode;
- wsd->object_mode_restore = workspace->object_mode_restore;
- BLI_addtail(&us->workspace_data, wsd);
- }
- }
-#endif
-
return true;
}
@@ -127,19 +90,6 @@ static void memfile_undosys_step_decode(struct bContext *C, UndoStep *us_p, int
BKE_memfile_undo_decode(us->data, C);
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, CTX_data_scene(C));
-
-#ifdef USE_WORKSPACE_OBJECT_MODE_HACK
- {
- struct Main *bmain = CTX_data_main(C);
- for (WorkSpaceData *wsd = us->workspace_data.first; wsd != NULL; wsd = wsd->next) {
- WorkSpace *workspace = BLI_findstring(&bmain->workspaces, wsd->name, offsetof(ID, name) + 2);
- if (workspace) {
- workspace->object_mode = wsd->object_mode;
- workspace->object_mode_restore = wsd->object_mode_restore;
- }
- }
- }
-#endif
}
static void memfile_undosys_step_free(UndoStep *us_p)
@@ -155,10 +105,6 @@ static void memfile_undosys_step_free(UndoStep *us_p)
}
BKE_memfile_undo_free(us->data);
-
-#ifdef USE_WORKSPACE_OBJECT_MODE_HACK
- BLI_freelistN(&us->workspace_data);
-#endif
}
/* Export for ED_undo_sys. */
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 4bec0d9f114..d3a9c22bc73 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -42,7 +42,6 @@
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "DNA_packedFile_types.h"
-#include "DNA_workspace_types.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
@@ -75,8 +74,6 @@
#include "ED_space_api.h"
#include "ED_util.h"
-#include "DEG_depsgraph.h"
-
#include "GPU_immediate.h"
#include "UI_interface.h"
@@ -92,6 +89,7 @@
void ED_editors_init(bContext *C)
{
+ Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->undo_stack == NULL) {
@@ -107,33 +105,22 @@ void ED_editors_init(bContext *C)
/* 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. */
- {
- wmWindow *win_orig = CTX_wm_window(C);
- CTX_wm_window_set(C, NULL);
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- Scene *scene = WM_window_get_active_scene(win);
- ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace);
- Object *obact = view_layer ? OBACT(view_layer) : NULL;
- eObjectMode object_mode = workspace->object_mode;
- workspace->object_mode = OB_MODE_OBJECT;
- if (view_layer && obact) {
- const ID *data = obact->data;
- if (!ELEM(object_mode, OB_MODE_OBJECT, OB_MODE_POSE)) {
- if (!ID_IS_LINKED(obact) && !(data && ID_IS_LINKED(data))) {
- CTX_wm_window_set(C, win);
- ED_object_mode_toggle(C, object_mode);
- CTX_wm_window_set(C, NULL);
- }
- }
- else if (object_mode == OB_MODE_POSE) {
- if (!ID_IS_LINKED(obact) && (obact->type == OB_ARMATURE)) {
- workspace->object_mode = object_mode;
- }
+ Object *obact = CTX_data_active_object(C);
+ if (obact != NULL) {
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
+ int mode = ob->mode;
+
+ if (mode == OB_MODE_OBJECT) {
+ /* pass */
+ }
+ else {
+ ID *data = ob->data;
+ ob->mode = OB_MODE_OBJECT;
+ if ((ob == obact) && !ID_IS_LINKED(ob) && !(data && ID_IS_LINKED(data))) {
+ ED_object_mode_toggle(C, mode);
}
}
}
- CTX_wm_window_set(C, win_orig);
}
/* image editor paint mode */
@@ -195,16 +182,11 @@ bool ED_editors_flush_edits(const bContext *C, bool for_render)
Object *ob;
Main *bmain = CTX_data_main(C);
- eObjectMode object_mode = WM_windows_object_mode_get(bmain->wm.first);
- if ((object_mode & (OB_MODE_SCULPT | OB_MODE_EDIT)) == 0) {
- return has_edited;
- }
-
/* loop through all data to find edit mode or object mode, because during
* exiting we might not have a context for edit object and multiple sculpt
* objects can exist at the same time */
for (ob = bmain->object.first; ob; ob = ob->id.next) {
- if (object_mode & OB_MODE_SCULPT) {
+ if (ob->mode & OB_MODE_SCULPT) {
/* Don't allow flushing while in the middle of a stroke (frees data in use).
* Auto-save prevents this from happening but scripts may cause a flush on saving: T53986. */
if ((ob->sculpt && ob->sculpt->cache) == 0) {
@@ -223,7 +205,7 @@ bool ED_editors_flush_edits(const bContext *C, bool for_render)
}
}
}
- else if (object_mode & OB_MODE_EDIT) {
+ else if (ob->mode & OB_MODE_EDIT) {
/* get editmode results */
has_edited = true;
ED_object_editmode_load(ob);
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index cb8aa9660cf..3fcc89d0973 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -1072,7 +1072,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
static void draw_uv_shadows_get(
- SpaceImage *sima, const EvaluationContext *eval_ctx, Object *ob, Object *obedit,
+ SpaceImage *sima, Object *ob, Object *obedit,
bool *show_shadow, bool *show_texpaint)
{
*show_shadow = *show_texpaint = false;
@@ -1086,18 +1086,18 @@ static void draw_uv_shadows_get(
*show_shadow = EDBM_uv_check(em);
}
- *show_texpaint = (ob && ob->type == OB_MESH && eval_ctx->object_mode == OB_MODE_TEXTURE_PAINT);
+ *show_texpaint = (ob && ob->type == OB_MESH && ob->mode == OB_MODE_TEXTURE_PAINT);
}
void ED_uvedit_draw_main(
- SpaceImage *sima, const EvaluationContext *eval_ctx,
+ SpaceImage *sima,
ARegion *ar, Scene *scene, ViewLayer *view_layer, Object *obedit, Object *obact, Depsgraph *depsgraph)
{
ToolSettings *toolsettings = scene->toolsettings;
bool show_uvedit, show_uvshadow, show_texpaint_uvshadow;
show_uvedit = ED_space_image_show_uvedit(sima, obedit);
- draw_uv_shadows_get(sima, eval_ctx, obact, obedit, &show_uvshadow, &show_texpaint_uvshadow);
+ draw_uv_shadows_get(sima, obact, obedit, &show_uvshadow, &show_texpaint_uvshadow);
if (show_uvedit || show_uvshadow || show_texpaint_uvshadow) {
if (show_uvshadow)
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index e437b4e4f58..9bbf46b2a1f 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -46,7 +46,6 @@ struct View3D;
struct RegionView3D;
struct SmokeModifierData;
struct DupliObject;
-struct EvaluationContext;
#include "DNA_object_enums.h"
@@ -79,7 +78,7 @@ void GPU_disable_program_point_size(void);
void GPU_begin_object_materials(
struct View3D *v3d, struct RegionView3D *rv3d,
struct Scene *scene, struct ViewLayer *view_layer,
- struct Object *ob, bool glsl, const eObjectMode object_mode, bool *do_alpha_after);
+ struct Object *ob, bool glsl, bool *do_alpha_after);
void GPU_end_object_materials(void);
bool GPU_object_materials_check(void);
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index e0fbdb5a2e1..8b344716a9c 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -1460,7 +1460,6 @@ static struct GPUMaterialState {
Material *gmatbuf_fixed[FIXEDMAT];
Material *gboundmat;
Object *gob;
- eObjectMode gob_object_mode;
DupliObject *dob;
Scene *gscene;
int glay;
@@ -1555,7 +1554,7 @@ void GPU_end_dupli_object(void)
void GPU_begin_object_materials(
View3D *v3d, RegionView3D *rv3d, Scene *scene, ViewLayer *view_layer, Object *ob,
- bool glsl, const eObjectMode object_mode, bool *do_alpha_after)
+ bool glsl, bool *do_alpha_after)
{
Material *ma;
GPUMaterial *gpumat;
@@ -1593,7 +1592,7 @@ void GPU_begin_object_materials(
#ifdef WITH_GAMEENGINE
if (rv3d->rflag & RV3D_IS_GAME_ENGINE) {
- ob = BKE_object_lod_matob_get(ob, view_layer, object_mode);
+ ob = BKE_object_lod_matob_get(ob, view_layer);
}
#else
UNUSED_VARS(view_layer);
@@ -1617,7 +1616,6 @@ void GPU_begin_object_materials(
GMS.two_sided_lighting = (((Mesh *)ob->data)->flag & ME_TWOSIDED) != 0;
GMS.gob = ob;
- GMS.gob_object_mode = object_mode;
GMS.gscene = scene;
GMS.is_opensubdiv = use_opensubdiv;
GMS.totmat = use_matcap ? 1 : ob->totcol + 1; /* materials start from 1, default material is 0 */
@@ -1838,7 +1836,7 @@ int GPU_object_material_bind(int nr, void *attribs)
}
GPU_material_bind(
- gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob_object_mode & OB_MODE_TEXTURE_PAINT),
+ gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT),
GMS.gviewmat, GMS.gviewinv, GMS.gviewcamtexcofac);
auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f;
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 0b7dccee9ab..74469acd275 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -172,6 +172,9 @@ typedef struct Object {
ListBase modifiers; /* list of ModifierData structures */
ListBase fmaps; /* list of facemaps */
+ int mode; /* Local object mode */
+ int restore_mode;
+
/* materials */
struct Material **mat; /* material slots */
char *matbits; /* a boolean field, with each byte 1 if corresponding material is linked to object */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index a18c9cf3712..8a0e48e3412 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1947,11 +1947,10 @@ extern const char *RE_engine_id_CYCLES;
#define OBEDIT_FROM_WORKSPACE(workspace, _view_layer) \
(((workspace)->object_mode & OD_MODE_EDIT) ? OBACT(_view_layer) : NULL)
-#define OBEDIT_FROM_EVAL_CTX(eval_ctx) \
- (((eval_ctx)->object_mode & OB_MODE_EDIT) ? OBACT((eval_ctx)->view_layer) : NULL)
-
-#define OBEDIT_FROM_WINDOW(window) \
- BKE_workspace_edit_object(WM_window_get_active_workspace(window), WM_window_get_active_scene(window))
+#define OBEDIT_FROM_OBACT(ob) \
+ (((ob)->mode & OB_MODE_EDIT) ? ob : NULL)
+#define OBEDIT_FROM_VIEW_LAYER(view_layer) \
+ OBEDIT_FROM_OBACT(OBACT(view_layer))
#define V3D_CAMERA_LOCAL(v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : NULL)
#define V3D_CAMERA_SCENE(scene, v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : (scene)->camera)
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 894119b1e72..82aa7b8b81c 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -101,9 +101,6 @@ typedef struct WorkSpace {
int pad;
int flags DNA_PRIVATE_WORKSPACE; /* enum eWorkSpaceFlags */
- short object_mode, object_mode_restore;
- char _pad[4];
-
/* should be: '#ifdef USE_WORKSPACE_TOOL'. */
bToolDef tool;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index ca8abdc8b48..1ad33b683b7 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -31,7 +31,6 @@
#include "DNA_texture_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "DNA_workspace_types.h"
#include "BLI_math.h"
@@ -44,8 +43,6 @@
#include "WM_types.h"
-#include "DEG_depsgraph.h"
-
static const EnumPropertyItem prop_direction_items[] = {
{0, "ADD", 0, "Add", "Add effect of brush"},
{BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"},
@@ -376,23 +373,21 @@ static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
static void rna_Brush_main_tex_update(bContext *C, PointerRNA *ptr)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Brush *br = (Brush *)ptr->data;
- BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mtex.tex, workspace->object_mode);
+ BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mtex.tex);
rna_Brush_update(bmain, scene, ptr);
}
static void rna_Brush_secondary_tex_update(bContext *C, PointerRNA *ptr)
{
Main *bmain = CTX_data_main(C);
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Brush *br = (Brush *)ptr->data;
- BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mask_mtex.tex, workspace->object_mode);
+ BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mask_mtex.tex);
rna_Brush_update(bmain, scene, ptr);
}
@@ -453,9 +448,8 @@ static void rna_TextureSlot_brush_angle_update(bContext *C, PointerRNA *ptr)
MTex *mtex = ptr->data;
/* skip invalidation of overlay for stencil mode */
if (mtex->mapping != MTEX_MAP_MODE_STENCIL) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex, workspace->object_mode);
+ BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex);
}
rna_TextureSlot_update(C, ptr);
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 9992ab06211..7d09f30ed6a 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -64,7 +64,6 @@ const EnumPropertyItem rna_enum_collection_type_items[] = {
#include "DNA_group_types.h"
#include "DNA_object_types.h"
-#include "DNA_workspace_types.h"
#include "RNA_access.h"
@@ -73,8 +72,6 @@ const EnumPropertyItem rna_enum_collection_type_items[] = {
#include "BKE_node.h"
#include "BKE_scene.h"
#include "BKE_mesh.h"
-#include "BKE_object.h"
-#include "BKE_workspace.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
@@ -838,18 +835,6 @@ static void rna_LayerObjects_active_object_set(PointerRNA *ptr, PointerRNA value
view_layer->basact = NULL;
}
-static void rna_LayerObjects_active_object_update(struct bContext *C, PointerRNA *ptr)
-{
- wmWindow *win = CTX_wm_window(C);
- Scene *scene = WM_window_get_active_scene(win);
-
- if (scene != ptr->id.data) {
- return;
- }
- ViewLayer *view_layer = (ViewLayer *)ptr->data;
- ED_object_base_activate(C, view_layer->basact);
-}
-
static IDProperty *rna_ViewLayer_idprops(PointerRNA *ptr, bool create)
{
ViewLayer *view_layer = (ViewLayer *)ptr->data;
@@ -2145,11 +2130,11 @@ static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop)
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_pointer_funcs(prop, "rna_LayerObjects_active_object_get", "rna_LayerObjects_active_object_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK | PROP_CONTEXT_UPDATE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_ui_text(prop, "Active Object", "Active object for this layer");
/* Could call: ED_object_base_activate(C, rl->basact);
* but would be a bad level call and it seems the notifier is enough */
- RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, "rna_LayerObjects_active_object_update");
+ RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL);
prop = RNA_def_property(srna, "selected", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 6f23b0fd281..bf6e13e587c 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -207,16 +207,23 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s
if (win == NULL) {
continue;
}
- Object *obedit = OBEDIT_FROM_WINDOW(win);
+
+ Object *obedit = NULL;
+ {
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
+ ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
+ obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
+ }
+
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
-
- if (!sima->pin)
+ if (!sima->pin) {
ED_space_image_set(sima, scene, obedit, image);
+ }
}
}
}
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 80449a77b14..e5de42c43fa 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -347,7 +347,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
Object *ob = (Object *)ptr->data;
ID *id = value.data;
- if (BKE_object_is_in_editmode(ob)) {
+ if (ob->mode & OB_MODE_EDIT) {
return;
}
@@ -1404,9 +1404,7 @@ static void rna_Object_constraints_clear(Object *object)
static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports,
const char *name, int type)
{
- Main *bmain = CTX_data_main(C);
- const WorkSpace *workspace = CTX_wm_workspace(C);
- return ED_object_modifier_add(reports, bmain, CTX_data_scene(C), object, workspace->object_mode, name, type);
+ return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
}
static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, PointerRNA *md_ptr)
@@ -2431,6 +2429,12 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Type", "Type of Object");
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
+
prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
RNA_def_property_array(prop, 8);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 649cb523e92..c2797abbc75 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -53,7 +53,6 @@ static const EnumPropertyItem effector_shape_items[] = {
#include "BLI_math_base.h"
-#include "BKE_main.h"
/* type specific return values only used from functions */
static const EnumPropertyItem curve_shape_items[] = {
@@ -524,7 +523,7 @@ static void rna_FieldSettings_shape_update(Main *bmain, Scene *scene, PointerRNA
{
if (!particle_id_check(ptr)) {
Object *ob = (Object *)ptr->id.data;
- ED_object_check_force_modifiers(bmain, scene, ob, bmain->eval_ctx->object_mode);
+ ED_object_check_force_modifiers(bmain, scene, ob);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
@@ -711,7 +710,7 @@ static void rna_CollisionSettings_dependency_update(Main *bmain, Scene *scene, P
/* add/remove modifier as needed */
if (ob->pd->deflect && !md)
- ED_object_modifier_add(NULL, bmain, scene, ob, bmain->eval_ctx->object_mode, NULL, eModifierType_Collision);
+ ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Collision);
else if (!ob->pd->deflect && md)
ED_object_modifier_remove(NULL, bmain, ob, md);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index ac9fce46384..de3476264a7 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1703,10 +1703,9 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons
static void rna_UnifiedPaintSettings_update(bContext *C, PointerRNA *UNUSED(ptr))
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer, workspace->object_mode));
+ Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer));
WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
}
@@ -6961,7 +6960,6 @@ void RNA_def_scene(BlenderRNA *brna)
/* Statistics */
func = RNA_def_function(srna, "statistics", "ED_info_stats_string");
- parm = RNA_def_pointer(func, "workspace", "WorkSpace", "", "Active workspace");
parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Active layer");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_string(func, "statistics", NULL, 0, "Statistics", "");
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index cb3c2078cfe..7a7537bcf1f 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -117,9 +117,9 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf
static void rna_Scene_uvedit_aspect(Scene *scene, Object *ob, float *aspect)
{
- if (ob->type == OB_MESH) {
- /* Will be NULL when not in editmode */
- BMEditMesh *em = BKE_editmesh_from_object(ob);
+ if ((ob->type == OB_MESH) && (ob->mode == OB_MODE_EDIT)) {
+ BMEditMesh *em;
+ em = BKE_editmesh_from_object(ob);
if (EDBM_uv_check(em)) {
ED_uvedit_get_aspect(scene, ob, em->bm, aspect, aspect + 1);
return;
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 69237cad855..49edc742a4b 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -39,7 +39,6 @@
#include "DNA_brush_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
-#include "DNA_workspace_types.h"
#include "BKE_paint.h"
#include "BKE_material.h"
@@ -393,12 +392,11 @@ static void rna_ImaPaint_stencil_update(bContext *C, PointerRNA *UNUSED(ptr))
static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr))
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
- Object *obedit = ((workspace->object_mode & OB_MODE_EDIT) && BKE_object_is_in_editmode(ob)) ? ob : NULL;
+ Object *obedit = OBEDIT_FROM_OBACT(ob);
bScreen *sc;
Image *ima = scene->toolsettings->imapaint.canvas;
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 70ec6287924..2d8385a5f83 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -868,8 +868,8 @@ static int rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr)
SpaceImage *sima = (SpaceImage *)(ptr->data);
bScreen *sc = (bScreen *)ptr->id.data;
wmWindow *win = ED_screen_window_find(sc, G.main->wm.first);
- Object *obedit = OBEDIT_FROM_WINDOW(win);
-
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
return ED_space_image_show_uvedit(sima, obedit);
}
@@ -877,11 +877,9 @@ static int rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr)
{
SpaceImage *sima = (SpaceImage *)(ptr->data);
bScreen *sc = (bScreen *)ptr->id.data;
- wmWindow *window = NULL;
- Scene *scene = ED_screen_scene_find_with_window(sc, G.main->wm.first, &window);
- ViewLayer *view_layer = BKE_view_layer_context_active_PLACEHOLDER(scene);
- const WorkSpace *workspace = WM_window_get_active_workspace(window);
- return ED_space_image_check_show_maskedit(sima, workspace, view_layer);
+ wmWindow *win = ED_screen_window_find(sc, G.main->wm.first);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+ return ED_space_image_check_show_maskedit(sima, view_layer);
}
static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
@@ -890,7 +888,8 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
bScreen *sc = (bScreen *)ptr->id.data;
wmWindow *win;
Scene *scene = ED_screen_scene_find_with_window(sc, G.main->wm.first, &win);
- Object *obedit = OBEDIT_FROM_WINDOW(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
ED_space_image_set(sima, scene, obedit, (Image *)value.data);
}
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index e2e44a8ac5c..42e3e2c83fb 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -37,7 +37,6 @@
#include "DNA_node_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h" /* MAXFRAME only */
-#include "DNA_workspace_types.h"
#include "BLI_utildefines.h"
@@ -248,11 +247,10 @@ void rna_TextureSlot_update(bContext *C, PointerRNA *ptr)
break;
case ID_BR:
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
MTex *mtex = ptr->data;
ViewLayer *view_layer = CTX_data_view_layer(C);
- BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex, workspace->object_mode);
+ BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex);
WM_main_add_notifier(NC_BRUSH, id);
break;
}
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index eaadde52940..88330ad2a8f 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -364,11 +364,8 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN
vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, btheme->tv3d.vertex_unreferenced);
for (ob = bmain->object.first; ob; ob = ob->id.next) {
- /* TODO/OBMODE (not urgent) */
- // if (ob->mode & OB_MODE_WEIGHT_PAINT)
- {
+ if (ob->mode & OB_MODE_WEIGHT_PAINT)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- }
}
rna_userdef_update(bmain, scene, ptr);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 5110f4cc27a..1d4652b0212 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -473,7 +473,6 @@ const EnumPropertyItem rna_enum_wm_report_items[] = {
#include "DNA_workspace_types.h"
#include "ED_screen.h"
-#include "ED_object.h"
#include "UI_interface.h"
@@ -761,9 +760,8 @@ static void rna_workspace_screen_update(bContext *C, PointerRNA *ptr)
static PointerRNA rna_Window_view_layer_get(PointerRNA *ptr)
{
wmWindow *win = ptr->data;
- Scene *scene = WM_window_get_active_scene(win);
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
+ Scene *scene;
+ ViewLayer *view_layer = WM_window_get_active_view_layer_ex(win, &scene);
PointerRNA scene_ptr;
RNA_id_pointer_create(&scene->id, &scene_ptr);
@@ -779,21 +777,6 @@ static void rna_Window_view_layer_set(PointerRNA *ptr, PointerRNA value)
BKE_workspace_view_layer_set(workspace, value.data, scene);
}
-static void rna_Window_view_layer_update(struct bContext *C, PointerRNA *ptr)
-{
- wmWindow *win = ptr->data;
- Scene *scene = WM_window_get_active_scene(win);
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
- Object *obact = OBACT(view_layer);
- eObjectMode object_mode = workspace->object_mode;
- if (obact && (object_mode & OB_MODE_EDIT)) {
- ED_object_editmode_exit_ex(NULL, workspace, scene, obact, EM_FREEDATA);
- }
- workspace->object_mode = object_mode;
- ED_object_base_activate(C, view_layer->basact);
-}
-
static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = ptr->data;
@@ -2077,8 +2060,8 @@ static void rna_def_window(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ViewLayer");
RNA_def_property_pointer_funcs(prop, "rna_Window_view_layer_get", "rna_Window_view_layer_set", NULL, NULL);
RNA_def_property_ui_text(prop, "Active View Layer", "The active workspace view layer showing in the window");
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL | PROP_CONTEXT_UPDATE);
- RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, "rna_Window_view_layer_update");
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
+ RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL);
prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "posx");
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 7ac4134f02b..609493c54b8 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -216,9 +216,11 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "UI Tags", "");
rna_def_workspace_owner_ids(brna, prop);
+#if 0
prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
RNA_def_property_ui_text(prop, "Mode", "Object interaction mode used in this window");
+#endif
/* View Render */
prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index a2ca9bde124..6bf735e1e5c 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -298,7 +298,7 @@ static void meshdeformModifier_do(
*
* We'll support this case once granular dependency graph is landed.
*/
- if (mmd->object == OBEDIT_FROM_EVAL_CTX(eval_ctx)) {
+ if (mmd->object == OBEDIT_FROM_VIEW_LAYER(eval_ctx->view_layer)) {
BMEditMesh *em = BKE_editmesh_from_object(mmd->object);
tmpdm = editbmesh_get_derived_cage_and_final(eval_ctx, md->scene, mmd->object, em, 0, &cagedm);
if (tmpdm)
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index 6704526ea03..2b675d36140 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -48,8 +48,6 @@
#include "MOD_modifiertypes.h"
-#include "DEG_depsgraph.h"
-
static void initData(ModifierData *md)
{
MultiresModifierData *mmd = (MultiresModifierData *)md;
@@ -69,7 +67,7 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
DerivedMesh *dm, ModifierApplyFlag flag)
{
MultiresModifierData *mmd = (MultiresModifierData *)md;
@@ -96,7 +94,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
if (ignore_simplify)
flags |= MULTIRES_IGNORE_SIMPLIFY;
- result = multires_make_derived_from_derived(dm, mmd, ob, flags, eval_ctx->object_mode);
+ result = multires_make_derived_from_derived(dm, mmd, ob, flags);
if (result == dm)
return dm;
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index e1df65dd748..cbb96b31db1 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -103,7 +103,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk,
walk(userData, ob, &smd->auxTarget, IDWALK_CB_NOP);
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -118,13 +118,13 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_c
dm = get_cddm(ob, NULL, dm, vertexCos, dependsOnNormals(md));
}
- shrinkwrapModifier_deform(eval_ctx, (ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts, forRender);
+ shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts, forRender);
if (dm != derivedData)
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
+static void deformVertsEM(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
struct BMEditMesh *editData, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts)
{
@@ -136,7 +136,7 @@ static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval
dm = get_cddm(ob, editData, dm, vertexCos, dependsOnNormals(md));
}
- shrinkwrapModifier_deform(eval_ctx, (ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts, false);
+ shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts, false);
if (dm != derivedData)
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 8fd510a6662..a09923d6dfe 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -117,7 +117,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eva
subsurf_flags |= SUBSURF_USE_RENDER_PARAMS;
if (isFinalCalc)
subsurf_flags |= SUBSURF_IS_FINAL_CALC;
- if (eval_ctx->object_mode & OB_MODE_EDIT)
+ if (ob->mode & OB_MODE_EDIT)
subsurf_flags |= SUBSURF_IN_EDIT_MODE;
#ifdef WITH_OPENSUBDIV
@@ -132,7 +132,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eva
if (U.opensubdiv_compute_type == USER_OPENSUBDIV_COMPUTE_NONE) {
modifier_setError(md, "OpenSubdiv is disabled in User Preferences");
}
- else if ((eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
+ else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
modifier_setError(md, "OpenSubdiv is not supported in paint modes");
}
else if ((DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) == 0) {
@@ -143,8 +143,6 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eva
modifier_setError(md, "OpenSubdiv is disabled due to dependencies");
}
}
-#else
- UNUSED_VARS(ob);
#endif
result = subsurf_make_derived_from_derived(derivedData, smd, NULL, subsurf_flags);
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index e7f283c4a31..b5fd1e55839 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1110,7 +1110,7 @@ static void surfacedeformModifier_do(
}
/* Handle target mesh both in and out of edit mode */
- if (smd->target == OBEDIT_FROM_EVAL_CTX(eval_ctx)) {
+ if (smd->target == OBEDIT_FROM_VIEW_LAYER(eval_ctx->view_layer)) {
BMEditMesh *em = BKE_editmesh_from_object(smd->target);
tdm = em->derivedFinal;
}
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index fab28bacff8..932b60665c4 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -35,7 +35,6 @@
#include "DNA_texture_types.h"
#include "DNA_node_types.h"
#include "DNA_space_types.h"
-#include "DNA_workspace_types.h"
#include "BLI_listbase.h"
#include "BLI_threads.h"
@@ -63,7 +62,6 @@
static void texture_get_from_context(
const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
SpaceNode *snode = CTX_wm_space_node(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -98,7 +96,7 @@ static void texture_get_from_context(
else if (snode->texfrom == SNODE_TEX_BRUSH) {
struct Brush *brush = NULL;
- if (ob && (workspace->object_mode & OB_MODE_SCULPT))
+ if (ob && (ob->mode & OB_MODE_SCULPT))
brush = BKE_paint_brush(&scene->toolsettings->sculpt->paint);
else
brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint);
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 0480ffe42d9..419316d6217 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -1341,7 +1341,7 @@ static int render_new_particle_system(const EvaluationContext *eval_ctx, Render
if (part->ren_as==PART_DRAW_OB || part->ren_as==PART_DRAW_GR || part->ren_as==PART_DRAW_NOT)
return 1;
- if ((re->r.scemode & R_VIEWPORT_PREVIEW) && (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT))
+ if ((re->r.scemode & R_VIEWPORT_PREVIEW) && (ob->mode & OB_MODE_PARTICLE_EDIT))
return 0;
if (part->ren_as == PART_DRAW_BB && part->bb_ob == NULL && RE_GetCamera(re) == NULL)
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 294134767c7..377d274a712 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -67,8 +67,7 @@ struct ARegion;
struct ScrArea;
struct Main;
struct bToolDef;
-
-#include "DNA_object_enums.h"
+struct ViewLayer;
#ifdef WITH_INPUT_NDOF
struct wmNDOFMotionData;
@@ -105,7 +104,6 @@ bool WM_window_is_fullscreen (struct wmWindow *win);
void WM_windows_scene_data_sync(const ListBase *win_lb, struct Scene *scene) ATTR_NONNULL();
struct Scene *WM_windows_scene_get_from_screen(const struct wmWindowManager *wm, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
struct WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-eObjectMode WM_windows_object_mode_get(const struct wmWindowManager *wm) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
struct Scene *WM_window_get_active_scene(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
void WM_window_change_active_scene(struct Main *bmain, struct bContext *C, struct wmWindow *win,
@@ -117,6 +115,10 @@ void WM_window_set_active_layout(
struct wmWindow *win, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL(1);
struct bScreen *WM_window_get_active_screen(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
void WM_window_set_active_screen(struct wmWindow *win, struct WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL(1);
+
+struct ViewLayer *WM_window_get_active_view_layer_ex(const struct wmWindow *win, struct Scene **r_scene) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
+struct ViewLayer *WM_window_get_active_view_layer(const struct wmWindow *win) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
+
bool WM_window_is_temp_screen(const struct wmWindow *win) ATTR_WARN_UNUSED_RESULT;
void *WM_opengl_context_create(void);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 33bbb624192..fcf06804e94 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -338,8 +338,6 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
WorkSpace *workspace = WM_window_get_active_workspace(win);
- BKE_workspace_update_object_mode(bmain->eval_ctx, workspace);
-
BKE_workspace_update_tagged(bmain->eval_ctx, bmain, workspace, scene);
}
}
@@ -384,7 +382,7 @@ void wm_event_do_notifiers(bContext *C)
UI_popup_handlers_remove_all(C, &win->modalhandlers);
- ED_workspace_change(ref_ws, C, win);
+ ED_workspace_change(ref_ws, C, wm, win);
if (G.debug & G_DEBUG_EVENTS)
printf("%s: Workspace set %p\n", __func__, note->reference);
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index d482c107fe6..51b25d3e7de 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -2123,18 +2123,6 @@ WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const
return NULL;
}
-eObjectMode WM_windows_object_mode_get(const struct wmWindowManager *wm)
-{
- eObjectMode object_mode = 0;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- const WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- if (workspace != NULL) {
- object_mode |= workspace->object_mode;
- }
- }
- return object_mode;
-}
-
Scene *WM_window_get_active_scene(const wmWindow *win)
{
return win->scene;
@@ -2184,6 +2172,26 @@ void WM_window_set_active_screen(wmWindow *win, WorkSpace *workspace, bScreen *s
BKE_workspace_active_screen_set(win->workspace_hook, workspace, screen);
}
+struct ViewLayer *WM_window_get_active_view_layer_ex(const wmWindow *win, Scene **r_scene)
+{
+ const WorkSpace *workspace = WM_window_get_active_workspace(win);
+ Scene *scene = WM_window_get_active_scene(win);
+ /* May be NULL in rare cases like closing Blender */
+ bScreen *screen = (LIKELY(workspace != NULL) ? BKE_workspace_active_screen_get(win->workspace_hook) : NULL);
+ if (screen != NULL) {
+ if (r_scene) {
+ *r_scene = scene;
+ }
+ return BKE_workspace_view_layer_get(workspace, scene);
+ }
+ return NULL;
+}
+
+struct ViewLayer *WM_window_get_active_view_layer(const wmWindow *win)
+{
+ return WM_window_get_active_view_layer_ex(win, NULL);
+}
+
bool WM_window_is_temp_screen(const wmWindow *win)
{
const bScreen *screen = WM_window_get_active_screen(win);