Fix gizmos showing for non-visible objects

Active object gizmos were showing even when the object wasn't visible
(local view or with their object type disabled).
This commit is contained in:
Campbell Barton 2018-12-18 11:57:12 +11:00
parent 7aeb24e037
commit 4fceaf3848
Notes: blender-bot 2023-02-14 05:25:44 +01:00
Referenced by issue #59566, Help please Blender 2.8 blender-2.80.0-git.4fceaf3848b-windows64 December 18 is not running at all!
Referenced by issue #59558, deleting an object causes a crash
Referenced by issue #59560, Blender 2.8 Beta Crash
Referenced by issue #59563, Blender 2.8 Beta Crash
Referenced by issue #59538, Crash when deleting cube in default scene
Referenced by issue #59541, Blender 2.8 4fceaf3848 64bit crash when deleting object from the first startup file
Referenced by issue #59435, Crash when loading a file saved during multi-object editing
Referenced by issue #59354, Reference Image locking not working
5 changed files with 83 additions and 49 deletions

View File

@ -129,19 +129,22 @@ static void gizmo_bbone_offset_set(
static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
if (ob != NULL) {
const bArmature *arm = ob->data;
if (arm->drawtype == ARM_B_BONE) {
bPoseChannel *pchan = BKE_pose_channel_active(ob);
if (pchan && pchan->bone->segments > 1) {
View3D *v3d = CTX_wm_view3d(C);
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
{
/* pass */
}
else {
View3D *v3d = CTX_wm_view3d(C);
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
{
return false;
}
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = BASACT(view_layer);
if (base && BASE_VISIBLE(v3d, base)) {
Object *ob = BKE_object_pose_armature_get(base->object);
if (ob) {
const bArmature *arm = ob->data;
if (arm->drawtype == ARM_B_BONE) {
bPoseChannel *pchan = BKE_pose_channel_active(ob);
if (pchan && pchan->bone->segments > 1) {
return true;
}
}
@ -153,7 +156,8 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType
static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = BKE_object_pose_armature_get(OBACT(view_layer));
bPoseChannel *pchan = BKE_pose_channel_active(ob);
const wmGizmoType *gzt_move = WM_gizmotype_find("GIZMO_GT_move_3d", true);
@ -183,7 +187,8 @@ static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *g
static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = BKE_object_pose_armature_get(OBACT(view_layer));
if (!gzgroup->customdata)
return;

View File

@ -70,12 +70,16 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED(
return false;
}
Object *ob = CTX_data_active_object(C);
if (ob && ob->type == OB_CAMERA) {
Camera *camera = ob->data;
/* TODO: support overrides. */
if (camera->id.lib == NULL) {
return true;
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = BASACT(view_layer);
if (base && BASE_VISIBLE(v3d, base)) {
Object *ob = base->object;
if (ob->type == OB_CAMERA) {
Camera *camera = ob->data;
/* TODO: support overrides. */
if (camera->id.lib == NULL) {
return true;
}
}
}
return false;
@ -83,7 +87,8 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED(
static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
Object *ob = CTX_data_active_object(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
float dir[3];
const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true);
@ -132,7 +137,8 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
return;
struct CameraWidgetGroup *cagzgroup = gzgroup->customdata;
Object *ob = CTX_data_active_object(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
Camera *ca = ob->data;
PointerRNA camera_ptr;
float dir[3];
@ -234,7 +240,8 @@ static void WIDGETGROUP_camera_message_subscribe(
const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus)
{
ARegion *ar = CTX_wm_region(C);
Object *ob = CTX_data_active_object(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
Camera *ca = ob->data;
wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = {

View File

@ -118,11 +118,14 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UN
return false;
}
Object *ob = CTX_data_active_object(C);
if (ob && ob->type == OB_EMPTY) {
if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
return BKE_object_empty_image_is_visible_in_view3d(ob, rv3d);
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = BASACT(view_layer);
if (BASE_VISIBLE(v3d, base)) {
Object *ob = base->object;
if (ob->type == OB_EMPTY) {
if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
return BKE_object_empty_image_is_visible_in_view3d(ob, rv3d);
}
}
}
return false;
@ -147,8 +150,9 @@ static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmGizmoGrou
static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
struct EmptyImageWidgetGroup *igzgroup = gzgroup->customdata;
Object *ob = CTX_data_active_object(C);
wmGizmo *gz = igzgroup->gizmo;
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
copy_m4_m4(gz->matrix_basis, ob->obmat);

View File

@ -62,9 +62,15 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmGizmoGroupType *UNU
return false;
}
Object *ob = CTX_data_active_object(C);
return (ob && ob->pd && ob->pd->forcefield);
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = BASACT(view_layer);
if (base && BASE_VISIBLE(v3d, base)) {
Object *ob = base->object;
if (ob->pd && ob->pd->forcefield) {
return true;
}
}
return false;
}
static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
@ -87,7 +93,8 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmGizmoGroup *gzgr
{
wmGizmoWrapper *wwrapper = gzgroup->customdata;
wmGizmo *gz = wwrapper->gizmo;
Object *ob = CTX_data_active_object(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
PartDeflect *pd = ob->pd;
if (pd->forcefield == PFIELD_WIND) {

View File

@ -63,11 +63,14 @@ static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmGizmoGroupType *UNUS
return false;
}
Object *ob = CTX_data_active_object(C);
if (ob && ob->type == OB_LAMP) {
Lamp *la = ob->data;
return (la->type == LA_SPOT);
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = BASACT(view_layer);
if (base && BASE_VISIBLE(v3d, base)) {
Object *ob = base->object;
if (ob->type == OB_LAMP) {
Lamp *la = ob->data;
return (la->type == LA_SPOT);
}
}
return false;
}
@ -91,7 +94,8 @@ static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmGizmoGroup *gzgro
{
wmGizmoWrapper *wwrapper = gzgroup->customdata;
wmGizmo *gz = wwrapper->gizmo;
Object *ob = CTX_data_active_object(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
Lamp *la = ob->data;
float dir[3];
@ -168,10 +172,14 @@ static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmGizmoGroupType *UNUS
return false;
}
Object *ob = CTX_data_active_object(C);
if (ob && ob->type == OB_LAMP) {
Lamp *la = ob->data;
return (la->type == LA_AREA);
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = BASACT(view_layer);
if (base && BASE_VISIBLE(v3d, base)) {
Object *ob = base->object;
if (ob->type == OB_LAMP) {
Lamp *la = ob->data;
return (la->type == LA_AREA);
}
}
return false;
}
@ -195,7 +203,8 @@ static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmGizmoGroup
static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
wmGizmoWrapper *wwrapper = gzgroup->customdata;
Object *ob = CTX_data_active_object(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
Lamp *la = ob->data;
wmGizmo *gz = wwrapper->gizmo;
@ -247,9 +256,10 @@ static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmGizmoGroupType *UN
return false;
}
Object *ob = CTX_data_active_object(C);
if (ob != NULL) {
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = BASACT(view_layer);
if (base && BASE_VISIBLE(v3d, base)) {
Object *ob = base->object;
if (ob->type == OB_LAMP) {
Lamp *la = ob->data;
return (ELEM(la->type, LA_SUN, LA_SPOT, LA_AREA));
@ -287,7 +297,8 @@ static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmGizmoGrou
static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
wmGizmoWrapper *wwrapper = gzgroup->customdata;
Object *ob = CTX_data_active_object(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
wmGizmo *gz = wwrapper->gizmo;
copy_m4_m4(gz->matrix_basis, ob->obmat);