Cleanup: use DRW_object_is_* for object checks
authorCampbell Barton <ideasman42@gmail.com>
Sun, 7 Oct 2018 23:43:34 +0000 (10:43 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 7 Oct 2018 23:43:34 +0000 (10:43 +1100)
Also use const qualifier for object's.

15 files changed:
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/draw/engines/basic/basic_engine.c
source/blender/draw/engines/eevee/eevee_engine.c
source/blender/draw/engines/eevee/eevee_materials.c
source/blender/draw/engines/eevee/eevee_render.c
source/blender/draw/engines/gpencil/gpencil_engine.c
source/blender/draw/engines/gpencil/gpencil_render.c
source/blender/draw/engines/workbench/workbench_deferred.c
source/blender/draw/engines/workbench/workbench_forward.c
source/blender/draw/intern/DRW_render.h
source/blender/draw/intern/draw_manager.c
source/blender/draw/modes/object_mode.c

index 81182a89f3eb533745f9248d3e665ad12431bb90..6d7def8f93fd533def229d8c899de7a3cb6739ff 100644 (file)
@@ -102,7 +102,7 @@ typedef enum eObjectVisibilityCheck {
        OB_VISIBILITY_CHECK_UNKNOWN_RENDER_MODE,
 } eObjectVisibilityCheck;
 
-bool BKE_object_is_visible(struct Object *ob, const eObjectVisibilityCheck mode);
+bool BKE_object_is_visible(const struct Object *ob, const eObjectVisibilityCheck mode);
 
 void BKE_object_init(struct Object *ob);
 struct Object *BKE_object_add_only_object(
index 3279839f8b55e42d71bc47551247c679a5ad1c2f..4374046d701344b216cb71de8225cf97eed5c37f 100644 (file)
@@ -304,7 +304,7 @@ void psys_set_current_num(Object *ob, int index);
 struct LatticeDeformData *psys_create_lattice_deform_data(struct ParticleSimulationData *sim);
 
 struct ParticleSystem *psys_orig_get(struct ParticleSystem *psys);
-bool psys_in_edit_mode(struct Depsgraph *depsgraph, struct ParticleSystem *psys);
+bool psys_in_edit_mode(struct Depsgraph *depsgraph, const struct ParticleSystem *psys);
 bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
 bool psys_check_edited(struct ParticleSystem *psys);
 
index cf6f2e5d8422af46f71d12300b825e1d456af00b..71cf08e267dd4623c8ccbe0f5ee61d4f7a36ca27 100644 (file)
@@ -727,7 +727,7 @@ bool BKE_object_is_mode_compat(const struct Object *ob, eObjectMode object_mode)
 /**
  * Return if the object is visible, as evaluated by depsgraph
  */
-bool BKE_object_is_visible(Object *ob, const eObjectVisibilityCheck mode)
+bool BKE_object_is_visible(const Object *ob, const eObjectVisibilityCheck mode)
 {
        if ((ob->base_flag & BASE_VISIBLE) == 0) {
                return false;
index 802c1c6b6b96b46cb0bb0075a7815c98a2ecdaf9..7a217f59536149482104ae8c90c5f13123b517e9 100644 (file)
@@ -307,7 +307,7 @@ static PTCacheEdit *psys_orig_edit_get(ParticleSystem *psys)
        return psys->orig_psys->edit;
 }
 
-bool psys_in_edit_mode(Depsgraph *depsgraph, ParticleSystem *psys)
+bool psys_in_edit_mode(Depsgraph *depsgraph, const ParticleSystem *psys)
 {
        const ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
        if (view_layer->basact == NULL) {
@@ -319,7 +319,7 @@ bool psys_in_edit_mode(Depsgraph *depsgraph, ParticleSystem *psys)
        if (object->mode != OB_MODE_PARTICLE_EDIT) {
                return false;
        }
-       ParticleSystem *psys_orig = psys_orig_get(psys);
+       const ParticleSystem *psys_orig = psys_orig_get((ParticleSystem *)psys);
        return (psys_orig->edit || psys->pointcache->edit) &&
               (use_render_params == false);
 }
index 2e3fdf37bdb315014721d45a49878486fb12a912..720b22d58a160bd0f3bffb065686338ee8c7eaf3 100644 (file)
@@ -125,7 +125,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
                        if (!psys_check_enabled(ob, psys, false)) {
                                continue;
                        }
-                       if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
+                       if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
                                continue;
                        }
                        ParticleSettings *part = psys->part;
index 32de4266c82c5e523ba9cff78c121ccd2c0807eb..bea7d000181db5ea0b5243535c589bf6f7ae2d33 100644 (file)
@@ -137,7 +137,7 @@ void EEVEE_cache_populate(void *vedata, Object *ob)
        }
 
        if (DRW_object_is_renderable(ob) &&
-           DRW_check_object_visible_within_active_context(ob))
+           DRW_object_is_visible_in_active_context(ob))
        {
                if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
                        EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow);
index 2d27bb8e70581809079f4ccaa3578fff887db490..a1a244eb615bce750a6c375b7e1ce3bf64bfd4e2 100644 (file)
@@ -1617,7 +1617,7 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata,
                                if (!psys_check_enabled(ob, psys, false)) {
                                        continue;
                                }
-                               if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
+                               if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
                                        continue;
                                }
                                ParticleSettings *part = psys->part;
index 80d8c066a4427edaa0c4aa76d366a971919b2117..117d48e2dc519843f7eb5157244e0e263ee5c496 100644 (file)
@@ -163,7 +163,7 @@ void EEVEE_render_cache(
                EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow);
        }
 
-       if (DRW_check_object_visible_within_active_context(ob)) {
+       if (DRW_object_is_visible_in_active_context(ob)) {
                if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
                        EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow);
                }
index 0b318bd974ec2579cbd10c542c1683b6fa793b71..d854336cfd0c5b56d34dd7aafe9bc343d711e56b 100644 (file)
@@ -549,7 +549,7 @@ static void gpencil_add_draw_data(void *vedata, Object *ob)
 void GPENCIL_cache_populate(void *vedata, Object *ob)
 {
        /* object must be visible */
-       if (!DRW_check_object_visible_within_active_context(ob)) {
+       if (!DRW_object_is_visible_in_active_context(ob)) {
                return;
        }
 
index 41f0c601a13b5f03da0eb294e70021c63344510d..8dc15472a20893d1e4ab905fa75e7faa901e4cd1 100644 (file)
@@ -130,7 +130,7 @@ static void GPENCIL_render_cache(
        void *vedata, struct Object *ob,
        struct RenderEngine *UNUSED(engine), struct Depsgraph *UNUSED(depsgraph))
 {
-       if ((ob == NULL) || (DRW_check_object_visible_within_active_context(ob) == false)) {
+       if ((ob == NULL) || (DRW_object_is_visible_in_active_context(ob) == false)) {
                return;
        }
 
index 7fbe928d29e7a92f99f08e3682f4eff827c02e60..dcb60839387f6574d10f35ef62a005f69c003d35 100644 (file)
@@ -649,7 +649,7 @@ static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *o
                if (!psys_check_enabled(ob, psys, false)) {
                        continue;
                }
-               if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
+               if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
                        continue;
                }
                ParticleSettings *part = psys->part;
@@ -701,7 +701,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
                return; /* Do not draw solid in this case. */
        }
 
-       if (!DRW_check_object_visible_within_active_context(ob)) {
+       if (!DRW_object_is_visible_in_active_context(ob)) {
                return;
        }
 
index 0d4329c9699cd171f3a6943a880cbd6d4822003f..2dceb8f609d608a5940c4d7c73f7eac73bbc3533 100644 (file)
@@ -420,7 +420,7 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O
                if (!psys_check_enabled(ob, psys, false)) {
                        continue;
                }
-               if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
+               if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
                        continue;
                }
                ParticleSettings *part = psys->part;
@@ -487,7 +487,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
                return; /* Do not draw solid in this case. */
        }
 
-       if (!DRW_check_object_visible_within_active_context(ob)) {
+       if (!DRW_object_is_visible_in_active_context(ob)) {
                return;
        }
 
index 193c2416215976f0ea4a6a7562fb73ed10bde240..2e91c8fd62d760db755286f51c7e7af06363e88d 100644 (file)
@@ -507,11 +507,11 @@ DrawData *DRW_drawdata_ensure(
         DrawDataFreeCb free_cb);
 
 /* Settings */
-bool DRW_object_is_renderable(struct Object *ob);
-bool DRW_check_object_visible_within_active_context(struct Object *ob);
+bool DRW_object_is_renderable(const struct Object *ob);
+bool DRW_object_is_visible_in_active_context(const struct Object *ob);
 bool DRW_object_is_flat_normal(const struct Object *ob);
 
-bool DRW_check_psys_visible_within_active_context(struct Object *object, struct ParticleSystem *psys);
+bool DRW_object_is_visible_psys_in_active_context(const struct Object *object, const struct ParticleSystem *psys);
 
 /* Draw commands */
 void DRW_draw_pass(DRWPass *pass);
index 0566abd34360ae334e0727a80ecde8390c1e0959..f987220e575029096eb18794e3bb3598dad40f91 100644 (file)
@@ -148,7 +148,7 @@ struct DRWTextStore *DRW_text_cache_ensure(void)
 /** \name Settings
  * \{ */
 
-bool DRW_object_is_renderable(Object *ob)
+bool DRW_object_is_renderable(const Object *ob)
 {
        BLI_assert(BKE_object_is_visible(ob, OB_VISIBILITY_CHECK_UNKNOWN_RENDER_MODE));
 
@@ -173,7 +173,7 @@ bool DRW_object_is_renderable(Object *ob)
  * Return whether this object is visible depending if
  * we are rendering or drawing in the viewport.
  */
-bool DRW_check_object_visible_within_active_context(Object *ob)
+bool DRW_object_is_visible_in_active_context(const Object *ob)
 {
        const eObjectVisibilityCheck mode = DRW_state_is_scene_render() ?
                                             OB_VISIBILITY_CHECK_FOR_RENDER :
@@ -192,9 +192,9 @@ bool DRW_object_is_flat_normal(const Object *ob)
        return true;
 }
 
-bool DRW_check_psys_visible_within_active_context(
-        Object *object,
-        struct ParticleSystem *psys)
+bool DRW_object_is_visible_psys_in_active_context(
+        const Object *object,
+        const ParticleSystem *psys)
 {
        const DRWContextState *draw_ctx = DRW_context_state_get();
        const Scene *scene = draw_ctx->scene;
@@ -1660,7 +1660,7 @@ static bool DRW_render_check_grease_pencil(Depsgraph *depsgraph)
 {
        DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
        {
-               if ((ob->type == OB_GPENCIL) && (DRW_check_object_visible_within_active_context(ob))) {
+               if ((ob->type == OB_GPENCIL) && (DRW_object_is_visible_in_active_context(ob))) {
                        return true;
                }
        }
index 2df2ad570739d369f3b5628234770f7a0d8fd6a8..9bf5263bacfe8c4a3a6499bb695e03f55abb3012 100644 (file)
@@ -2281,7 +2281,7 @@ static void DRW_shgroup_relationship_lines(
         Scene *scene,
         Object *ob)
 {
-       if (ob->parent && DRW_check_object_visible_within_active_context(ob->parent)) {
+       if (ob->parent && DRW_object_is_visible_in_active_context(ob->parent)) {
                DRW_shgroup_call_dynamic_add(sgl->relationship_lines, ob->parent->obmat[3]);
                DRW_shgroup_call_dynamic_add(sgl->relationship_lines, ob->obmat[3]);
        }
@@ -2289,11 +2289,11 @@ static void DRW_shgroup_relationship_lines(
        if (ob->rigidbody_constraint) {
                Object *rbc_ob1 = ob->rigidbody_constraint->ob1;
                Object *rbc_ob2 = ob->rigidbody_constraint->ob2;
-               if (rbc_ob1 && DRW_check_object_visible_within_active_context(rbc_ob1)) {
+               if (rbc_ob1 && DRW_object_is_visible_in_active_context(rbc_ob1)) {
                        DRW_shgroup_call_dynamic_add(sgl->relationship_lines, rbc_ob1->obmat[3]);
                        DRW_shgroup_call_dynamic_add(sgl->relationship_lines, ob->obmat[3]);
                }
-               if (rbc_ob2 && DRW_check_object_visible_within_active_context(rbc_ob2)) {
+               if (rbc_ob2 && DRW_object_is_visible_in_active_context(rbc_ob2)) {
                        DRW_shgroup_call_dynamic_add(sgl->relationship_lines, rbc_ob2->obmat[3]);
                        DRW_shgroup_call_dynamic_add(sgl->relationship_lines, ob->obmat[3]);
                }
@@ -2538,7 +2538,7 @@ static void OBJECT_cache_populate_particles(Object *ob,
                if (!psys_check_enabled(ob, psys, false)) {
                        continue;
                }
-               if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
+               if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
                        continue;
                }
 
@@ -2624,7 +2624,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
                OBJECT_cache_populate_particles(ob, psl);
        }
 
-       if (DRW_check_object_visible_within_active_context(ob) == false) {
+       if (DRW_object_is_visible_in_active_context(ob) == false) {
                return;
        }