diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_screen.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/screen.c | 26 |
2 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 4cbd7e966f2..188b8e22815 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -53,6 +53,8 @@ struct wmNotifier; struct wmWindow; struct wmWindowManager; +#include "BLI_compiler_attrs.h" + #include "RNA_types.h" /* spacetype has everything stored to get an editor working, it gets initialized via @@ -280,6 +282,11 @@ struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type); struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa); struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min); +unsigned int BKE_screen_view3d_layer_active_ex( + const struct View3D *v3d, const struct Scene *scene, bool use_localvd) ATTR_NONNULL(2); +unsigned int BKE_screen_view3d_layer_active( + const struct View3D *v3d, const struct Scene *scene) ATTR_NONNULL(2); + void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene); void BKE_screen_view3d_scene_sync(struct bScreen *sc); void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 9d40ee6e667..b2296151cf7 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -425,6 +425,32 @@ ScrArea *BKE_screen_find_big_area(bScreen *sc, const int spacetype, const short return big; } +/** + * Utility function to get the active layer to use when adding new objects. + */ +unsigned int BKE_screen_view3d_layer_active_ex(const View3D *v3d, const Scene *scene, bool use_localvd) +{ + unsigned int lay; + if ((v3d == NULL) || (v3d->scenelock && !v3d->localvd)) { + lay = scene->layact; + } + else { + lay = v3d->layact; + } + + if (use_localvd) { + if (v3d && v3d->localvd) { + lay |= v3d->lay; + } + } + + return lay; +} +unsigned int BKE_screen_view3d_layer_active(const struct View3D *v3d, const struct Scene *scene) +{ + return BKE_screen_view3d_layer_active_ex(v3d, scene, true); +} + void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene) { int bit; |