Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_edit.c
| Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_effect.h" | #include "BKE_effect.h" | ||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_localview.h" | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_mball.h" | #include "BKE_mball.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_pointcache.h" | #include "BKE_pointcache.h" | ||||
| #include "BKE_property.h" | #include "BKE_property.h" | ||||
| #include "BKE_sca.h" | #include "BKE_sca.h" | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| View3D *v3d = sa->spacedata.first; | View3D *v3d = sa->spacedata.first; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Base *base; | Base *base; | ||||
| bool changed = false; | bool changed = false; | ||||
| /* XXX need a context loop to handle such cases */ | /* XXX need a context loop to handle such cases */ | ||||
| for (base = FIRSTBASE; base; base = base->next) { | for (base = FIRSTBASE; base; base = base->next) { | ||||
| if ((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) { | if ((base->lay & v3d->lay) && | ||||
| BKE_localview_is_object_visible(v3d, base->object) && | |||||
| (base->object->restrictflag & OB_RESTRICT_VIEW)) | |||||
brecht: I suggest to wrap this in a function (didn't check what the consistent function name would be)… | |||||
| { | |||||
| if (!(base->object->restrictflag & OB_RESTRICT_SELECT)) { | if (!(base->object->restrictflag & OB_RESTRICT_SELECT)) { | ||||
| base->flag |= SELECT; | base->flag |= SELECT; | ||||
| } | } | ||||
| base->object->flag = base->flag; | base->object->flag = base->flag; | ||||
| base->object->restrictflag &= ~OB_RESTRICT_VIEW; | base->object->restrictflag &= ~OB_RESTRICT_VIEW; | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| DAG_id_type_tag(bmain, ID_OB); | DAG_id_type_tag(bmain, ID_OB); | ||||
| DAG_relations_tag_update(bmain); | DAG_relations_tag_update(bmain); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 313 Lines • ▼ Show 20 Lines | void ED_object_editmode_enter(bContext *C, int flag) | ||||
| if (ID_IS_LINKED_DATABLOCK(scene)) return; | if (ID_IS_LINKED_DATABLOCK(scene)) return; | ||||
| if (sa && sa->spacetype == SPACE_VIEW3D) | if (sa && sa->spacetype == SPACE_VIEW3D) | ||||
| v3d = sa->spacedata.first; | v3d = sa->spacedata.first; | ||||
| if ((flag & EM_IGNORE_LAYER) == 0) { | if ((flag & EM_IGNORE_LAYER) == 0) { | ||||
| base = CTX_data_active_base(C); /* active layer checked here for view3d */ | base = CTX_data_active_base(C); /* active layer checked here for view3d */ | ||||
| if (base == NULL) return; | if (base == NULL) { | ||||
| else if (v3d && (base->lay & v3d->lay) == 0) return; | return; | ||||
| else if (!v3d && (base->lay & scene->lay) == 0) return; | } | ||||
| else if (v3d) { | |||||
| if ((base->lay & v3d->lay) == 0 || !BKE_localview_is_object_visible(v3d, base->object)) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| else if ((base->lay & scene->lay) == 0) { | |||||
| return; | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| base = scene->basact; | base = scene->basact; | ||||
| } | } | ||||
| if (ELEM(NULL, base, base->object, base->object->data)) return; | if (ELEM(NULL, base, base->object, base->object->data)) return; | ||||
| ob = base->object; | ob = base->object; | ||||
| ▲ Show 20 Lines • Show All 1,772 Lines • Show Last 20 Lines | |||||
I suggest to wrap this in a function (didn't check what the consistent function name would be):
if (view3d_is_object_visible(v3d, base)) {
For rendering you'd have something like:
if (render_is_object_visible(re, base)) {
And then use that consistently throughout the code.
For python addons, external renderers, etc, such utility functions may be the right thing to add in the RNA API as well, instead of wrapping any of the local view data structures.