diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-05-17 04:03:09 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-05-17 04:03:09 +0300 |
commit | 2f6bc538742da1147619a60c6245d6697bd4d057 (patch) | |
tree | 6c6d02a628465f8528bc4d1e504facae3b32e108 /source/blender | |
parent | 8adec78ca574f09242aa4588ad04f498f1e074aa (diff) |
DWM: Add obact for convenience
Modes often need to check if the object is the active one.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 16 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 7 | ||||
-rw-r--r-- | source/blender/draw/modes/object_mode.c | 8 | ||||
-rw-r--r-- | source/blender/draw/modes/pose_mode.c | 7 | ||||
-rw-r--r-- | source/blender/draw/modes/sculpt_mode.c | 3 |
5 files changed, 22 insertions, 19 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 9654087f0d8..6f214440bdd 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -354,14 +354,18 @@ struct DRWTextStore *DRW_state_text_cache_get(void); /* Avoid too many lookups while drawing */ typedef struct DRWContextState { - struct ARegion *ar; - struct RegionView3D *rv3d; - struct View3D *v3d; + struct ARegion *ar; /* 'CTX_wm_region(C)' */ + struct RegionView3D *rv3d; /* 'CTX_wm_region_view3d(C)' */ + struct View3D *v3d; /* 'CTX_wm_view3d(C)' */ - struct Scene *scene; /* CTX_data_scene(C) */ - struct SceneLayer *sl; /* CTX_data_scene_layer(C) */ + struct Scene *scene; /* 'CTX_data_scene(C)' */ + struct SceneLayer *sl; /* 'CTX_data_scene_layer(C)' */ - /* last resort (some functions take this as an arg so we can't easily avoid) */ + /* Use 'scene->obedit' for edit-mode */ + struct Object *obact; /* 'OBACT_NEW' */ + + /* Last resort (some functions take this as an arg so we can't easily avoid). + * May be NULL when used for selection or depth buffer. */ const struct bContext *evil_C; } DRWContextState; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 0c45ce9ec2b..91ab4e858ae 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2785,7 +2785,7 @@ void DRW_draw_render_loop( cache_is_dirty = GPU_viewport_cache_validate(DST.viewport, DRW_engines_get_hash()); DST.draw_ctx = (DRWContextState){ - ar, rv3d, v3d, scene, sl, + ar, rv3d, v3d, scene, sl, OBACT_NEW, /* reuse if caller sets */ DST.draw_ctx.evil_C, }; @@ -2943,7 +2943,7 @@ void DRW_draw_select_loop( /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */ DST.draw_ctx = (DRWContextState){ - ar, rv3d, v3d, scene, sl, (bContext *)NULL, + ar, rv3d, v3d, scene, sl, OBACT_NEW, (bContext *)NULL, }; DRW_viewport_var_init(); @@ -3034,7 +3034,7 @@ void DRW_draw_depth_loop( /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */ DST.draw_ctx = (DRWContextState){ - ar, rv3d, v3d, scene, sl, (bContext *)NULL, + ar, rv3d, v3d, scene, sl, OBACT_NEW, (bContext *)NULL, }; DRW_viewport_var_init(); @@ -3141,6 +3141,7 @@ void DRW_context_state_init(const bContext *C, DRWContextState *r_draw_ctx) r_draw_ctx->scene = CTX_data_scene(C); r_draw_ctx->sl = CTX_data_scene_layer(C); + r_draw_ctx->obact = r_draw_ctx->sl->basact ? r_draw_ctx->sl->basact->object : NULL; /* grr, cant avoid! */ r_draw_ctx->evil_C = C; diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index badf532fe2c..f7ffa7bbbb2 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1188,7 +1188,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (do_outlines) { Object *obedit = scene->obedit; - if (ob != obedit && !(OBACT_NEW == ob && (ob->mode & OB_MODE_ALL_PAINT))) { + if (ob != obedit && !((ob == draw_ctx->obact) && (ob->mode & OB_MODE_ALL_PAINT))) { struct Batch *geom = DRW_cache_object_surface_get(ob); if (geom) { theme_id = DRW_object_wire_theme_get(ob, sl, NULL); @@ -1248,10 +1248,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) { bArmature *arm = ob->data; if (arm->edbo == NULL) { - if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, OBACT_NEW)) { + if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { DRW_shgroup_armature_object( - ob, sl, psl->bone_solid, psl->bone_wire, - stl->g_data->relationship_lines); + ob, sl, psl->bone_solid, psl->bone_wire, + stl->g_data->relationship_lines); } } break; diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index 19ec4057bb5..b83f78d8896 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -109,16 +109,15 @@ static void POSE_cache_populate(void *vedata, Object *ob) POSE_PassList *psl = ((POSE_Data *)vedata)->psl; POSE_StorageList *stl = ((POSE_Data *)vedata)->stl; const DRWContextState *draw_ctx = DRW_context_state_get(); - SceneLayer *sl = draw_ctx->sl; /* In the future this will allow us to implement face manipulators, * and similar functionalities. For now we handle only pose bones. */ if (ob->type == OB_ARMATURE) { - if (DRW_pose_mode_armature(ob, OBACT_NEW)) { + if (DRW_pose_mode_armature(ob, draw_ctx->obact)) { DRW_shgroup_armature_pose( - ob, psl->bone_solid, psl->bone_wire, - stl->g_data->relationship_lines); + ob, psl->bone_solid, psl->bone_wire, + stl->g_data->relationship_lines); } } } diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index ba9f530ae40..a3f29b5bb8f 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -191,9 +191,8 @@ static void SCULPT_cache_populate(void *vedata, Object *ob) if (ob->type == OB_MESH) { const DRWContextState *draw_ctx = DRW_context_state_get(); - SceneLayer *sl = draw_ctx->sl; - if (ob->sculpt && ob == OBACT_NEW) { + if (ob->sculpt && (ob == draw_ctx->obact)) { /* XXX, needed for dyntopo-undo (which clears). * probably depsgraph should handlle? in 2.7x getting derived-mesh does this (mesh_build_data) */ |