Commit: 103b6aedf981f68185b2fc7ef610d842e37df70c
Author: Julian Eisel
Date:   Thu Aug 4 17:25:38 2016 +0200
Branches: temp_localview_split
https://developer.blender.org/rB103b6aedf981f68185b2fc7ef610d842e37df70c

Use inline functions instead of macros for local view utilities

===================================================================

M       source/blender/blenkernel/BKE_localview.h
M       source/blender/blenloader/intern/readfile.c
M       source/blender/editors/gpencil/gpencil_convert.c
M       source/blender/editors/object/object_add.c
M       source/blender/editors/object/object_edit.c
M       source/blender/editors/object/object_relations.c
M       source/blender/editors/render/render_internal.c
M       source/blender/editors/screen/screen_context.c
M       source/blender/editors/sculpt_paint/paint_image_proj.c
M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/editors/space_view3d/space_view3d.c
M       source/blender/editors/space_view3d/view3d_draw.c
M       source/blender/editors/space_view3d/view3d_view.c
M       source/blender/gpu/intern/gpu_draw.c
M       source/blender/render/intern/source/convertblender.c
M       source/blender/render/intern/source/envmap.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_localview.h 
b/source/blender/blenkernel/BKE_localview.h
index 9cd5352..327810e 100644
--- a/source/blender/blenkernel/BKE_localview.h
+++ b/source/blender/blenkernel/BKE_localview.h
@@ -23,31 +23,67 @@
 
 /** \file BKE_localview.h
  *  \ingroup bke
- *  \brief Local view utility macros
+ *  \brief Local view utility functions
  *
  * Even though it's possible to access LocalView DNA structs directly,
- * please only access using these macros (or extend it if needed).
+ * please only access using these functions (or extend it if needed).
  */
 
+#include "BLI_compiler_attrs.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_object_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_view3d_types.h"
+
+
+/* Forcing inline as some of these are called a lot, mostly in loops even. */
+
+BLI_INLINE bool BKE_localview_info_cmp(LocalViewInfo a, LocalViewInfo b) 
ATTR_WARN_UNUSED_RESULT;
+BLI_INLINE bool BKE_localview_is_object_visible(View3D *v3d, Object *ob) 
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+BLI_INLINE bool BKE_localview_is_valid(LocalViewInfo localview) 
ATTR_WARN_UNUSED_RESULT;
+
+BLI_INLINE void BKE_localview_object_assign(View3D *v3d, Object *ob) 
ATTR_NONNULL();
+BLI_INLINE void BKE_localview_object_unassign(View3D *v3d, Object *ob) 
ATTR_NONNULL();
+
+
 /* visibility checks */
-#define BKE_LOCALVIEW_INFO_CMP(a, b) \
-       ((a).viewbits & (b).viewbits)
-#define BKE_LOCALVIEW_IS_OBJECT_VISIBLE(v3d, ob) \
-       (((v3d)->localviewd == NULL) || 
BKE_LOCALVIEW_INFO_CMP((v3d)->localviewd->info, (ob)->localview))
-
-/* Check if info defines a visible local view */
-#define BKE_LOCALVIEW_IS_VALID(info) \
-       ((info).viewbits != 0)
-
-/* Adjust local view info of ob to be visible if v3d is in local view */
-#define BKE_LOCALVIEW_OBJECT_ASSIGN(v3d, ob) \
-       if ((v3d)->localviewd) { \
-               (ob)->localview.viewbits |= (v3d)->localviewd->info.viewbits; \
-       } (void)0
-/* Remove object from local view */
-#define BKE_LOCALVIEW_OBJECT_UNASSIGN(v3d, ob) \
-       if ((v3d)->localviewd) { \
-               (ob)->localview.viewbits &= ~(v3d)->localviewd->info.viewbits; \
-       } (void)0
+BLI_INLINE bool BKE_localview_info_cmp(LocalViewInfo a, LocalViewInfo b)
+{
+       return (a.viewbits & b.viewbits) != 0;
+}
+
+BLI_INLINE bool BKE_localview_is_object_visible(View3D *v3d, Object *ob)
+{
+       return (v3d->localviewd == NULL) || 
BKE_localview_info_cmp(v3d->localviewd->info, ob->localview);
+}
+
+/**
+ * Check if \a localview defines a visible local view.
+ */
+BLI_INLINE bool BKE_localview_is_valid(LocalViewInfo localview)
+{
+       return localview.viewbits != 0;
+}
+
+/**
+ * Adjust local view info of \a ob to be visible if \a v3d is in local view
+ */
+BLI_INLINE void BKE_localview_object_assign(View3D *v3d, Object *ob)
+{
+       if (v3d->localviewd) { \
+               ob->localview.viewbits |= v3d->localviewd->info.viewbits;
+       }
+}
+
+/**
+ * Remove \a from local view of \a v3d.
+ */
+BLI_INLINE void BKE_localview_object_unassign(View3D *v3d, Object *ob)
+{
+       if (v3d->localviewd) {
+               ob->localview.viewbits &= ~v3d->localviewd->info.viewbits;
+       }
+}
 
 #endif // __BKE_LOCALVIEW_H__
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 2a25123..a231de8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9739,8 +9739,8 @@ static void give_base_to_objects(Main *mainvar, Scene 
*scene, View3D *v3d, Libra
                                /* Add to localview (only if FILE_ACTIVELAY, 
this is how it was
                                 * done when local view was using Object.lay 
bitfield) */
                                if (v3d && (flag & FILE_ACTIVELAY)) {
-                                       /* macro checks if v3d is in local view 
*/
-                                       BKE_LOCALVIEW_OBJECT_ASSIGN(v3d, ob);
+                                       /* function checks if v3d is in local 
view */
+                                       BKE_localview_object_assign(v3d, ob);
                                }
 
                                base->lay = ob->lay;
@@ -9776,8 +9776,8 @@ static void give_base_to_groups(
                        ob->type = OB_EMPTY;
                        ob->lay = active_lay;
                        if (v3d) {
-                               /* Add to localview (macro checks if v3d is in 
local view) */
-                               BKE_LOCALVIEW_OBJECT_ASSIGN(v3d, ob);
+                               /* Add to localview (function checks if v3d is 
in local view) */
+                               BKE_localview_object_assign(v3d, ob);
                        }
 
                        /* assign the base */
@@ -9879,8 +9879,8 @@ static void link_object_postprocess(ID *id, Scene *scene, 
View3D *v3d, const sho
                        /* Add to localview (only if FILE_ACTIVELAY, this is 
how it was
                         * done when local view was using Object.lay bitfield) 
*/
                        if (v3d) {
-                               /* macro checks if v3d is in local view */
-                               BKE_LOCALVIEW_OBJECT_ASSIGN(v3d, ob);
+                               /* function checks if v3d is in local view */
+                               BKE_localview_object_assign(v3d, ob);
                        }
                }
 
diff --git a/source/blender/editors/gpencil/gpencil_convert.c 
b/source/blender/editors/gpencil/gpencil_convert.c
index 5357991..cfbf98f 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1220,8 +1220,8 @@ static void gp_layer_to_curve(bContext *C, ReportList 
*reports, bGPdata *gpd, bG
        base_new->lay  = ob->lay  = base_orig ? base_orig->lay : 
BKE_screen_view3d_layer_active(v3d, scene);
        base_new->flag = ob->flag = base_new->flag | SELECT;
        if (v3d) {
-               /* Add to localview (macro checks if v3d is in local view) */
-               BKE_LOCALVIEW_OBJECT_ASSIGN(v3d, ob);
+               /* Add to localview (function checks if v3d is in local view) */
+               BKE_localview_object_assign(v3d, ob);
        }
 }
 
diff --git a/source/blender/editors/object/object_add.c 
b/source/blender/editors/object/object_add.c
index 1096e3b..25c9d12 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -419,7 +419,7 @@ Object *ED_object_add_type(
 
        /* Add to local view if needed */
        if (v3d) {
-               BKE_LOCALVIEW_OBJECT_ASSIGN(v3d, ob);
+               BKE_localview_object_assign(v3d, ob);
        }
 
        /* more editor stuff */
@@ -2275,8 +2275,8 @@ static int add_named_exec(bContext *C, wmOperator *op)
        basen->lay = basen->object->lay = BKE_screen_view3d_layer_active(v3d, 
scene);
        basen->object->restrictflag &= ~OB_RESTRICT_VIEW;
        if (v3d) {
-               /* Add to localview (macro checks if v3d is in local view) */
-               BKE_LOCALVIEW_OBJECT_ASSIGN(v3d, basen->object);
+               /* Add to localview (function checks if v3d is in local view) */
+               BKE_localview_object_assign(v3d, basen->object);
        }
 
        if (event) {
diff --git a/source/blender/editors/object/object_edit.c 
b/source/blender/editors/object/object_edit.c
index e48c1d6..8d441ab 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -145,7 +145,7 @@ static int object_hide_view_clear_exec(bContext *C, 
wmOperator *UNUSED(op))
        /* XXX need a context loop to handle such cases */
        for (base = FIRSTBASE; base; base = base->next) {
                if ((base->lay & v3d->lay) &&
-                   BKE_LOCALVIEW_IS_OBJECT_VISIBLE(v3d, base->object) &&
+                   BKE_localview_is_object_visible(v3d, base->object) &&
                    (base->object->restrictflag & OB_RESTRICT_VIEW))
                {
                        if (!(base->object->restrictflag & OB_RESTRICT_SELECT)) 
{
@@ -486,7 +486,7 @@ void ED_object_editmode_enter(bContext *C, int flag)
                        return;
                }
                else if (v3d) {
-                       if ((base->lay & v3d->lay) == 0 || 
!BKE_LOCALVIEW_IS_OBJECT_VISIBLE(v3d, base->object)) {
+                       if ((base->lay & v3d->lay) == 0 || 
!BKE_localview_is_object_visible(v3d, base->object)) {
                                return;
                        }
                }
diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 38dff0f..49ef344 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1366,7 +1366,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
                /* Move object out of local view and deselect */
                /* TODO maybe this can be done a bit nicer? */
                if (v3d && v3d->localviewd) {
-                       BKE_LOCALVIEW_OBJECT_UNASSIGN(v3d, base->object);
+                       BKE_localview_object_unassign(v3d, base->object);
                        base->object->flag &= ~SELECT;
                        base->flag &= ~SELECT;
                }
diff --git a/source/blender/editors/render/render_internal.c 
b/source/blender/editors/render/render_internal.c
index 2ad65df..7d80167 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -793,7 +793,7 @@ static void clean_viewport_memory(Main *bmain, Scene 
*scene, LocalViewInfo *loca
        }
 
        for (SETLOOPER(scene, sce_iter, base)) {
-               if ((base->lay & renderlay) == 0 || 
BKE_LOCALVIEW_INFO_CMP(*localview, base->object->localview) == 0) {
+               if ((base->lay & renderlay) == 0 || 
BKE_localview_info_cmp(*localview, base->object->localview) == 0) {
                        continue;
                }
                if (RE_allow_render_generic_object(base->object)) {
diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 04b22ca..f005a6b 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -119,8 +119,8 @@ int ed_screen_context(const bContext *C, const char 
*member, bContextDataResult
 
 /* helper to check if base is visible considering layer and local view */
 #define LAYER_AND_LOCALVIEW_CHECK(localviews, base, lay) \
-       (BKE_LOCALVIEW_IS_VALID(localviews) ? \
-            BKE_LOCALVIEW_INFO_CMP(localviews, base->object->localview) : 
(base->lay & lay))
+       (BKE_localview_is_valid(localviews) ? \
+            BKE_localview_info_cmp(localviews, base->object->localview) : 
(base->lay & lay))
 
        if (CTX_data_dir(member)) {
                CTX_data_dir_set(result, screen_context_dir);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c 
b/source/blender/editors/sculpt_paint/paint_image_proj.c
index a5d3b22..4a3a8a5 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -5177,7 +5177,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, 
const float mouse[2], int m
 
                if ((ps->ob == NULL) ||
                    !(ps->ob->lay & ps->v3d->lay) ||
-                   !BKE_LOCALVIEW_IS_OBJECT_VISIBLE(ps->v3d, ps->ob))
+                   !BKE_localview_is_object_visible(ps->v3d, ps->ob))
                {
                        ps_handle->ps_views_tot = i + 1;
                        goto fail;
diff --git a/source/blender/editors/space_view3d/drawobject.c 
b/source/blender/editors/space_view3

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to