@ -129,9 +129,11 @@ static eContextResult screen_ctx_visible_objects(const bContext *C, bContextData
{
wmWindow * win = CTX_wm_window ( C ) ;
View3D * v3d = CTX_wm_view3d ( C ) ; /* This may be NULL in a lot of cases. */
Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
LISTBASE_FOREACH ( Base * , base , & view_layer - > object_bases ) {
LISTBASE_FOREACH ( Base * , base , BKE_view_layer_object_bases_get ( view_layer ) ) {
if ( BASE_VISIBLE ( v3d , base ) ) {
CTX_data_id_list_add ( result , & base - > object - > id ) ;
}
@ -143,9 +145,11 @@ static eContextResult screen_ctx_selectable_objects(const bContext *C, bContextD
{
wmWindow * win = CTX_wm_window ( C ) ;
View3D * v3d = CTX_wm_view3d ( C ) ; /* This may be NULL in a lot of cases. */
Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
LISTBASE_FOREACH ( Base * , base , & view_layer - > object_bases ) {
LISTBASE_FOREACH ( Base * , base , BKE_view_layer_object_bases_get ( view_layer ) ) {
if ( BASE_SELECTABLE ( v3d , base ) ) {
CTX_data_id_list_add ( result , & base - > object - > id ) ;
}
@ -157,9 +161,11 @@ static eContextResult screen_ctx_selected_objects(const bContext *C, bContextDat
{
wmWindow * win = CTX_wm_window ( C ) ;
View3D * v3d = CTX_wm_view3d ( C ) ; /* This may be NULL in a lot of cases. */
Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
LISTBASE_FOREACH ( Base * , base , & view_layer - > object_bases ) {
LISTBASE_FOREACH ( Base * , base , BKE_view_layer_object_bases_get ( view_layer ) ) {
if ( BASE_SELECTED ( v3d , base ) ) {
CTX_data_id_list_add ( result , & base - > object - > id ) ;
}
@ -172,9 +178,11 @@ static eContextResult screen_ctx_selected_editable_objects(const bContext *C,
{
wmWindow * win = CTX_wm_window ( C ) ;
View3D * v3d = CTX_wm_view3d ( C ) ; /* This may be NULL in a lot of cases. */
Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
LISTBASE_FOREACH ( Base * , base , & view_layer - > object_bases ) {
LISTBASE_FOREACH ( Base * , base , BKE_view_layer_object_bases_get ( view_layer ) ) {
if ( BASE_SELECTED_EDITABLE ( v3d , base ) ) {
CTX_data_id_list_add ( result , & base - > object - > id ) ;
}
@ -186,10 +194,12 @@ static eContextResult screen_ctx_editable_objects(const bContext *C, bContextDat
{
wmWindow * win = CTX_wm_window ( C ) ;
View3D * v3d = CTX_wm_view3d ( C ) ; /* This may be NULL in a lot of cases. */
Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
/* Visible + Editable, but not necessarily selected */
LISTBASE_FOREACH ( Base * , base , & view_layer - > object_bases ) {
LISTBASE_FOREACH ( Base * , base , BKE_view_layer_object_bases_get ( view_layer ) ) {
if ( BASE_EDITABLE ( v3d , base ) ) {
CTX_data_id_list_add ( result , & base - > object - > id ) ;
}
@ -203,7 +213,8 @@ static eContextResult screen_ctx_objects_in_mode(const bContext *C, bContextData
View3D * v3d = CTX_wm_view3d ( C ) ; /* This may be NULL in a lot of cases. */
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact & & ( obact - > mode ! = OB_MODE_OBJECT ) ) {
FOREACH_OBJECT_IN_MODE_BEGIN ( scene , view_layer , v3d , obact - > type , obact - > mode , ob_iter ) {
@ -221,7 +232,8 @@ static eContextResult screen_ctx_objects_in_mode_unique_data(const bContext *C,
View3D * v3d = CTX_wm_view3d ( C ) ; /* This may be NULL in a lot of cases. */
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact & & ( obact - > mode ! = OB_MODE_OBJECT ) ) {
FOREACH_OBJECT_IN_MODE_BEGIN ( scene , view_layer , v3d , obact - > type , obact - > mode , ob_iter ) {
@ -246,6 +258,7 @@ static eContextResult screen_ctx_visible_or_editable_bones_(const bContext *C,
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obedit = BKE_view_layer_edit_object_get ( view_layer ) ;
bArmature * arm = ( obedit & & obedit - > type = = OB_ARMATURE ) ? obedit - > data : NULL ;
@ -318,6 +331,7 @@ static eContextResult screen_ctx_selected_bones_(const bContext *C,
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obedit = BKE_view_layer_edit_object_get ( view_layer ) ;
bArmature * arm = ( obedit & & obedit - > type = = OB_ARMATURE ) ? obedit - > data : NULL ;
EditBone * flipbone = NULL ;
@ -389,7 +403,8 @@ static eContextResult screen_ctx_visible_pose_bones(const bContext *C, bContextD
View3D * v3d = CTX_wm_view3d ( C ) ; /* This may be NULL in a lot of cases. */
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
Object * obpose = BKE_object_pose_armature_get ( obact ) ;
if ( obpose & & obpose - > pose & & obpose - > data ) {
if ( obpose ! = obact ) {
@ -418,7 +433,7 @@ static eContextResult screen_ctx_selected_pose_bones(const bContext *C, bContext
View3D * v3d = CTX_wm_view3d ( C ) ; /* This may be NULL in a lot of cases. */
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
Object * obpose = BKE_object_pose_armature_get ( obact ) ;
if ( obpose & & obpose - > pose & & obpose - > data ) {
if ( obpose ! = obact ) {
@ -445,8 +460,10 @@ static eContextResult screen_ctx_selected_pose_bones_from_active_object(const bC
bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
Object * obpose = BKE_object_pose_armature_get ( obact ) ;
if ( obpose & & obpose - > pose & & obpose - > data ) {
if ( obpose ! = obact ) {
@ -469,8 +486,10 @@ static eContextResult screen_ctx_selected_pose_bones_from_active_object(const bC
static eContextResult screen_ctx_active_bone ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact & & obact - > type = = OB_ARMATURE ) {
bArmature * arm = obact - > data ;
if ( arm - > edbo ) {
@ -491,8 +510,10 @@ static eContextResult screen_ctx_active_bone(const bContext *C, bContextDataResu
static eContextResult screen_ctx_active_pose_bone ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
Object * obpose = BKE_object_pose_armature_get ( obact ) ;
bPoseChannel * pchan = BKE_pose_channel_active_if_layer_visible ( obpose ) ;
@ -505,8 +526,10 @@ static eContextResult screen_ctx_active_pose_bone(const bContext *C, bContextDat
static eContextResult screen_ctx_active_object ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact ) {
CTX_data_id_pointer_set ( result , & obact - > id ) ;
@ -517,8 +540,10 @@ static eContextResult screen_ctx_active_object(const bContext *C, bContextDataRe
static eContextResult screen_ctx_object ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact ) {
CTX_data_id_pointer_set ( result , & obact - > id ) ;
@ -529,7 +554,9 @@ static eContextResult screen_ctx_object(const bContext *C, bContextDataResult *r
static eContextResult screen_ctx_edit_object ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obedit = BKE_view_layer_edit_object_get ( view_layer ) ;
/* convenience for now, 1 object per scene in editmode */
if ( obedit ) {
@ -541,8 +568,10 @@ static eContextResult screen_ctx_edit_object(const bContext *C, bContextDataResu
static eContextResult screen_ctx_sculpt_object ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact & & ( obact - > mode & OB_MODE_SCULPT ) ) {
CTX_data_id_pointer_set ( result , & obact - > id ) ;
@ -553,8 +582,10 @@ static eContextResult screen_ctx_sculpt_object(const bContext *C, bContextDataRe
static eContextResult screen_ctx_vertex_paint_object ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact & & ( obact - > mode & OB_MODE_VERTEX_PAINT ) ) {
CTX_data_id_pointer_set ( result , & obact - > id ) ;
}
@ -564,8 +595,10 @@ static eContextResult screen_ctx_vertex_paint_object(const bContext *C, bContext
static eContextResult screen_ctx_weight_paint_object ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact & & ( obact - > mode & OB_MODE_ALL_WEIGHT_PAINT ) ) {
CTX_data_id_pointer_set ( result , & obact - > id ) ;
}
@ -575,8 +608,10 @@ static eContextResult screen_ctx_weight_paint_object(const bContext *C, bContext
static eContextResult screen_ctx_image_paint_object ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact & & ( obact - > mode & OB_MODE_TEXTURE_PAINT ) ) {
CTX_data_id_pointer_set ( result , & obact - > id ) ;
}
@ -587,8 +622,10 @@ static eContextResult screen_ctx_particle_edit_object(const bContext *C,
bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
if ( obact & & ( obact - > mode & OB_MODE_PARTICLE_EDIT ) ) {
CTX_data_id_pointer_set ( result , & obact - > id ) ;
}
@ -598,8 +635,10 @@ static eContextResult screen_ctx_particle_edit_object(const bContext *C,
static eContextResult screen_ctx_pose_object ( const bContext * C , bContextDataResult * result )
{
wmWindow * win = CTX_wm_window ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
Object * obpose = BKE_object_pose_armature_get ( obact ) ;
if ( obpose ) {
CTX_data_id_pointer_set ( result , & obpose - > id ) ;
@ -742,8 +781,10 @@ static eContextResult screen_ctx_gpencil_data(const bContext *C, bContextDataRes
{
wmWindow * win = CTX_wm_window ( C ) ;
ScrArea * area = CTX_wm_area ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
/* FIXME: for some reason, CTX_data_active_object(C) returns NULL when called from these
* situations ( as outlined above - see Campbell ' s # ifdefs ) .
* That causes the get_active function to fail when called from context .
@ -761,8 +802,10 @@ static eContextResult screen_ctx_gpencil_data_owner(const bContext *C, bContextD
{
wmWindow * win = CTX_wm_window ( C ) ;
ScrArea * area = CTX_wm_area ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
/* Pointer to which data/datablock owns the reference to the Grease Pencil data being used
* ( as gpencil_data ) . */
@ -812,8 +855,10 @@ static eContextResult screen_ctx_active_gpencil_layer(const bContext *C,
{
wmWindow * win = CTX_wm_window ( C ) ;
ScrArea * area = CTX_wm_area ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
bGPdata * gpd = ED_gpencil_data_get_active_direct ( area , obact ) ;
if ( gpd ) {
@ -850,8 +895,10 @@ static eContextResult screen_ctx_active_gpencil_frame(const bContext *C,
{
wmWindow * win = CTX_wm_window ( C ) ;
ScrArea * area = CTX_wm_area ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
bGPdata * gpd = ED_gpencil_data_get_active_direct ( area , obact ) ;
if ( gpd ) {
@ -869,8 +916,10 @@ static eContextResult screen_ctx_visible_gpencil_layers(const bContext *C,
{
wmWindow * win = CTX_wm_window ( C ) ;
ScrArea * area = CTX_wm_area ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
bGPdata * gpd = ED_gpencil_data_get_active_direct ( area , obact ) ;
if ( gpd ) {
@ -889,8 +938,10 @@ static eContextResult screen_ctx_editable_gpencil_layers(const bContext *C,
{
wmWindow * win = CTX_wm_window ( C ) ;
ScrArea * area = CTX_wm_area ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
bGPdata * gpd = ED_gpencil_data_get_active_direct ( area , obact ) ;
if ( gpd ) {
@ -909,8 +960,10 @@ static eContextResult screen_ctx_editable_gpencil_strokes(const bContext *C,
{
wmWindow * win = CTX_wm_window ( C ) ;
ScrArea * area = CTX_wm_area ( C ) ;
const Scene * scene = WM_window_get_active_scene ( win ) ;
ViewLayer * view_layer = WM_window_get_active_view_layer ( win ) ;
Object * obact = view_layer - > basact ? view_layer - > basact - > object : NULL ;
BKE_view_layer_synced_ensure ( scene , view_layer ) ;
Object * obact = BKE_view_layer_active_object_get ( view_layer ) ;
bGPdata * gpd = ED_gpencil_data_get_active_direct ( area , obact ) ;
const bool is_multiedit = ( bool ) GPENCIL_MULTIEDIT_SESSIONS_ON ( gpd ) ;