diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-08 20:26:46 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-12 23:36:43 +0300 |
commit | 77879ac038e3576eeeeb651ce78706cb95399098 (patch) | |
tree | e3816728abb2e98b92c4c639f356afba0a8dd3b6 /source/blender | |
parent | 6700c02e53ed02fbabc36cd6763f65f74e2ab304 (diff) |
Fix T55376: instanced collection render visibility ignored.
For physics simulation it's still fuzzy though, but this needs bigger
design for how it works with view layers and visibility.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_collection.h | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 23 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/dynamicpaint.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_dupli.c | 45 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 49 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/softbody.c | 33 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_nodes.cc | 9 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 28 |
10 files changed, 111 insertions, 130 deletions
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index fc5b19ccb4f..7dce3b2c703 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -90,14 +90,13 @@ void BKE_collections_child_remove_nulls(struct Main *bmain, struct Collection *o bool BKE_collection_is_in_scene(struct Collection *collection); void BKE_collections_after_lib_link(struct Main *bmain); bool BKE_collection_object_cyclic_check(struct Main *bmain, struct Object *object, struct Collection *collection); -bool BKE_collection_is_animated(struct Collection *collection, struct Object *parent); /* Object list cache. */ struct ListBase BKE_collection_object_cache_get(struct Collection *collection); void BKE_collection_object_cache_free(struct Collection *collection); -struct Base *BKE_collection_or_layer_objects(struct Depsgraph *depsgraph, +struct Base *BKE_collection_or_layer_objects(const struct Depsgraph *depsgraph, const struct Scene *scene, const struct ViewLayer *view_layer, struct Collection *collection); @@ -139,13 +138,21 @@ void BKE_scene_objects_callback(struct Scene *scene, BKE_scene_objects_Cb callba /* Iteratorion over objects in collection. */ -#define FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(_collection, _base) \ - for (Base *_base = (Base*)BKE_collection_object_cache_get(_collection).first; \ - _base; \ - _base = _base->next) \ - { - -#define FOREACH_COLLECTION_BASE_RECURSIVE_END \ +#define FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(_collection, _object, _mode) \ + { \ + int _base_flag = (_mode == DAG_EVAL_VIEWPORT) ? \ + BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER; \ + int _base_id = 0; \ + for (Base *_base = (Base*)BKE_collection_object_cache_get(_collection).first; \ + _base; \ + _base = _base->next, _base_id++) \ + { \ + if (_base->flag & _base_flag) { \ + Object *_object = _base->object; \ + +#define FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END \ + } \ + } \ } #define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object) \ diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index ab0ec8b0491..3f30082576c 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -297,20 +297,6 @@ void BKE_collection_new_name_get(Collection *collection_parent, char *rname) MEM_freeN(name); } -/************************* Dependencies ****************************/ - -bool BKE_collection_is_animated(Collection *collection, Object *UNUSED(parent)) -{ - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, object) - { - if (object->proxy) { - return true; - } - } - FOREACH_COLLECTION_OBJECT_RECURSIVE_END; - return false; -} - /* **************** Object List Cache *******************/ static void collection_object_cache_fill(ListBase *lb, Collection *collection, int parent_restrict) @@ -325,13 +311,8 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i base->object = cob->ob; if ((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) { - base->flag |= BASE_VISIBLED | BASE_VISIBLE_VIEWPORT; - - if ((child_restrict & COLLECTION_RESTRICT_SELECT) == 0) { - base->flag |= BASE_SELECTABLED; - } + base->flag |= BASE_VISIBLE_VIEWPORT; } - if ((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) { base->flag |= BASE_VISIBLE_RENDER; } @@ -377,7 +358,7 @@ void BKE_collection_object_cache_free(Collection *collection) collection_object_cache_free(collection); } -Base *BKE_collection_or_layer_objects(Depsgraph *depsgraph, +Base *BKE_collection_or_layer_objects(const Depsgraph *depsgraph, const Scene *scene, const ViewLayer *view_layer, Collection *collection) diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 0b2c65a7b8d..ed2566c9bb5 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -490,9 +490,9 @@ static void scene_setSubframe(Scene *scene, float subframe) scene->r.subframe = subframe; } -static int surface_getBrushFlags(DynamicPaintSurface *surface, const ViewLayer *view_layer) +static int surface_getBrushFlags(DynamicPaintSurface *surface, const Depsgraph *depsgraph) { - Base *base = BKE_collection_or_layer_objects(NULL, NULL, view_layer, surface->brush_group); + Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, surface->brush_group); Object *brushObj = NULL; ModifierData *md = NULL; @@ -5758,7 +5758,7 @@ static void dynamic_paint_generate_bake_data_cb( } } -static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const ViewLayer *view_layer, Object *ob) +static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Depsgraph *depsgraph, Object *ob) { PaintSurfaceData *sData = surface->data; PaintBakeData *bData = sData->bData; @@ -5766,7 +5766,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Vie int index; bool new_bdata = false; const bool do_velocity_data = ((surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) || - (surface_getBrushFlags(surface, view_layer) & BRUSH_USES_VELOCITY)); + (surface_getBrushFlags(surface, depsgraph) & BRUSH_USES_VELOCITY)); const bool do_accel_data = (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) != 0; int canvasNumOfVerts = dm->getNumVerts(dm); @@ -5912,8 +5912,7 @@ static int dynamicPaint_doStep( { Object *brushObj = NULL; ModifierData *md = NULL; - ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); - Base *base = BKE_collection_or_layer_objects(NULL, NULL, view_layer, surface->brush_group); + Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, surface->brush_group); /* backup current scene frame */ int scene_frame = scene->r.cfra; @@ -6051,8 +6050,7 @@ int dynamicPaint_calculateFrame( dynamicPaint_applySurfaceDisplace(surface, surface->canvas->dm); /* update bake data */ - ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); - dynamicPaint_generateBakeData(surface, view_layer, cObject); + dynamicPaint_generateBakeData(surface, depsgraph, cObject); /* don't do substeps for first frame */ if (surface->substeps && (frame != surface->start_frame)) { diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index bdf6e84a3b1..3bf58b8886a 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -219,10 +219,6 @@ ListBase *pdInitEffectors( ListBase *effectors = NULL; for (; base; base = base->next) { - if ((base->flag & BASE_VISIBLED) == 0) { - continue; - } - if (base->object->pd && base->object->pd->forcefield) { add_object_to_effectors(&effectors, depsgraph, scene, weights, base->object, ob_src, for_simulation); } diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index 57cdfdebcd3..e48a04c5726 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -233,13 +233,12 @@ static void make_child_duplis(const DupliContext *ctx, void *userdata, MakeChild Object *parent = ctx->object; if (ctx->collection) { - int collectionid = 0; - FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(ctx->collection, base) + eEvaluationMode mode = DEG_get_mode(ctx->depsgraph); + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(ctx->collection, ob, mode) { - Object *ob = base->object; - if ((base->flag & BASE_VISIBLED) && ob != ctx->obedit && is_child(ob, parent)) { + if ((ob != ctx->obedit) && is_child(ob, parent)) { DupliContext pctx; - copy_dupli_context(&pctx, ctx, ctx->object, NULL, collectionid); + copy_dupli_context(&pctx, ctx, ctx->object, NULL, _base_id); /* mballs have a different dupli handling */ if (ob->type != OB_MBALL) { @@ -247,9 +246,8 @@ static void make_child_duplis(const DupliContext *ctx, void *userdata, MakeChild } make_child_duplis_cb(&pctx, userdata, ob); } - collectionid++; } - FOREACH_COLLECTION_BASE_RECURSIVE_END + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; } else { int baseid = 0; @@ -278,9 +276,7 @@ static void make_duplis_collection(const DupliContext *ctx) { Object *ob = ctx->object; Collection *collection; - Base *base; float collection_mat[4][4]; - int id; if (ob->dup_group == NULL) return; collection = ob->dup_group; @@ -291,20 +287,22 @@ static void make_duplis_collection(const DupliContext *ctx) mul_m4_m4m4(collection_mat, ob->obmat, collection_mat); /* don't access 'ob->obmat' from now on. */ - const ListBase dup_collection_objects = BKE_collection_object_cache_get(collection); - for (base = dup_collection_objects.first, id = 0; base; base = base->next, id++) { - if (base->object != ob && (base->flag & BASE_VISIBLED)) { + eEvaluationMode mode = DEG_get_mode(ctx->depsgraph); + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(collection, cob, mode) + { + if (cob != ob) { float mat[4][4]; /* collection dupli offset, should apply after everything else */ - mul_m4_m4m4(mat, collection_mat, base->object->obmat); + mul_m4_m4m4(mat, collection_mat, cob->obmat); - make_dupli(ctx, base->object, mat, id); + make_dupli(ctx, cob, mat, _base_id); /* recursion */ - make_recursive_duplis(ctx, base->object, collection_mat, id); + make_recursive_duplis(ctx, cob, collection_mat, _base_id); } } + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; } static const DupliGenerator gen_dupli_collection = { @@ -822,7 +820,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem { Scene *scene = ctx->scene; Object *par = ctx->object; - bool for_render = DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER; + eEvaluationMode mode = DEG_get_mode(ctx->depsgraph); + bool for_render = mode == DAG_EVAL_RENDER; bool use_texcoords = for_render; Object *ob = NULL, **oblist = NULL, obcopy, *obcopylist = NULL; @@ -849,7 +848,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem if (part == NULL) return; - if (!psys_check_enabled(par, psys, (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER))) + if (!psys_check_enabled(par, psys, for_render)) return; if (!for_render) @@ -913,12 +912,12 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem totcollection += dw->count; } else { - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(part->dup_group, object) + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(part->dup_group, object, mode) { (void) object; totcollection++; } - FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; } /* we also copy the actual objects to restore afterwards, since @@ -938,7 +937,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem } else { a = 0; - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(part->dup_group, object) + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(part->dup_group, object, mode) { oblist[a] = object; obcopylist[a] = *object; @@ -948,7 +947,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem continue; } } - FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; } } else { @@ -1038,7 +1037,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem if (part->ren_as == PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { b = 0; - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(part->dup_group, object) + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(part->dup_group, object, mode) { copy_m4_m4(tmat, oblist[b]->obmat); @@ -1063,7 +1062,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem b++; } - FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; } else { /* to give ipos in object correct offset */ diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index af13909bf89..8d55a1d2690 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1743,16 +1743,15 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup * for baking with linking dupligroups. Once we have better overrides * this can be revisited so users select the local objects directly. */ if (scene && (duplis-- > 0) && (ob->dup_group)) { - Collection *collection = ob->dup_group; - Base *base = BKE_collection_object_cache_get(collection).first; - - for (; base; base = base->next) { - if (base->object != ob) { + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(ob->dup_group, object) + { + if (object != ob) { ListBase lb_dupli_pid; - BKE_ptcache_ids_from_object(&lb_dupli_pid, base->object, scene, duplis); + BKE_ptcache_ids_from_object(&lb_dupli_pid, object, scene, duplis); BLI_movelisttolist(lb, &lb_dupli_pid); } } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; } } diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index f7628d081a6..cb5887c07af 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1202,17 +1202,20 @@ void BKE_rigidbody_remove_constraint(Scene *scene, Object *ob) /* Update object array and rigid body count so they're in sync with the rigid body group */ static void rigidbody_update_ob_array(RigidBodyWorld *rbw) { - const ListBase objects = BKE_collection_object_cache_get(rbw->group); - int i, n; - - n = BLI_listbase_count(&objects); + int n = 0; + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, object) + { + (void)object; + n++; + } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; if (rbw->numbodies != n) { rbw->numbodies = n; rbw->objects = realloc(rbw->objects, sizeof(Object *) * rbw->numbodies); } - i = 0; + int i = 0; FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, object) { rbw->objects[i] = object; @@ -1241,7 +1244,7 @@ static void rigidbody_update_sim_world(Scene *scene, RigidBodyWorld *rbw) rigidbody_update_ob_array(rbw); } -static void rigidbody_update_sim_ob(struct Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo) +static void rigidbody_update_sim_ob(Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo) { float loc[3]; float rot[4]; @@ -1330,7 +1333,7 @@ static void rigidbody_update_sim_ob(struct Depsgraph *depsgraph, Scene *scene, R * * \param rebuild Rebuild entire simulation */ -static void rigidbody_update_simulation(struct Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, bool rebuild) +static void rigidbody_update_simulation(Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, bool rebuild) { /* update world */ if (rebuild) @@ -1437,8 +1440,10 @@ static void rigidbody_update_simulation(struct Depsgraph *depsgraph, Scene *scen FOREACH_COLLECTION_OBJECT_RECURSIVE_END; } -static void rigidbody_update_simulation_post_step(ViewLayer *view_layer, RigidBodyWorld *rbw) +static void rigidbody_update_simulation_post_step(Depsgraph *depsgraph, RigidBodyWorld *rbw) { + ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, ob) { Base *base = BKE_view_layer_base_find(view_layer, ob); @@ -1567,7 +1572,7 @@ void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw) /* Rebuild rigid body world */ /* NOTE: this needs to be called before frame update to work correctly */ -void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, Scene *scene, float ctime) +void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime) { RigidBodyWorld *rbw = scene->rigidbody_world; PointCache *cache; @@ -1579,8 +1584,15 @@ void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, Scene *scene, floa cache = rbw->pointcache; /* flag cache as outdated if we don't have a world or number of objects in the simulation has changed */ - const ListBase objects = BKE_collection_object_cache_get(rbw->group); - if (rbw->physics_world == NULL || rbw->numbodies != BLI_listbase_count(&objects)) { + int n = 0; + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, object) + { + (void)object; + n++; + } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + + if (rbw->physics_world == NULL || rbw->numbodies != n) { cache->flag |= PTCACHE_OUTDATED; } @@ -1596,7 +1608,7 @@ void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, Scene *scene, floa } /* Run RigidBody simulation for the specified physics world */ -void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, Scene *scene, float ctime) +void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime) { float timestep; RigidBodyWorld *rbw = scene->rigidbody_world; @@ -1648,8 +1660,7 @@ void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, Scene *scene, floa /* step simulation by the requested timestep, steps per second are adjusted to take time scale into account */ RB_dworld_step_simulation(rbw->physics_world, timestep, INT_MAX, 1.0f / (float)rbw->steps_per_second * min_ff(rbw->time_scale, 1.0f)); - ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); - rigidbody_update_simulation_post_step(view_layer, rbw); + rigidbody_update_simulation_post_step(depsgraph, rbw); /* write cache for current frame */ BKE_ptcache_validate(cache, (int)ctime); @@ -1686,8 +1697,8 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle) {} bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float ctime) { return false; } void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw) {} -void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, Scene *scene, float ctime) {} -void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, Scene *scene, float ctime) {} +void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime) {} +void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime) {} #if defined(__GNUC__) || defined(__clang__) # pragma GCC diagnostic pop @@ -1698,7 +1709,7 @@ void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, Scene *scene, floa /* -------------------- */ /* Depsgraph evaluation */ -void BKE_rigidbody_rebuild_sim(struct Depsgraph *depsgraph, +void BKE_rigidbody_rebuild_sim(Depsgraph *depsgraph, Scene *scene) { float ctime = DEG_get_ctime(depsgraph); @@ -1709,7 +1720,7 @@ void BKE_rigidbody_rebuild_sim(struct Depsgraph *depsgraph, } } -void BKE_rigidbody_eval_simulation(struct Depsgraph *depsgraph, +void BKE_rigidbody_eval_simulation(Depsgraph *depsgraph, Scene *scene) { float ctime = DEG_get_ctime(depsgraph); @@ -1720,7 +1731,7 @@ void BKE_rigidbody_eval_simulation(struct Depsgraph *depsgraph, } } -void BKE_rigidbody_object_sync_transforms(struct Depsgraph *depsgraph, +void BKE_rigidbody_object_sync_transforms(Depsgraph *depsgraph, Scene *scene, Object *ob) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 9aa6c172a90..fe31222bbba 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -75,6 +75,7 @@ variables on the UI for now #include "BKE_curve.h" #include "BKE_effect.h" #include "BKE_global.h" +#include "BKE_layer.h" #include "BKE_modifier.h" #include "BKE_softbody.h" #include "BKE_pointcache.h" @@ -516,19 +517,17 @@ static void ccd_build_deflector_hash_single(GHash *hash, Object *ob) /** * \note collection overrides scene when not NULL. */ -static void ccd_build_deflector_hash(ViewLayer *view_layer, Collection *collection, Object *vertexowner, GHash *hash) +static void ccd_build_deflector_hash(Depsgraph *depsgraph, Collection *collection, Object *vertexowner, GHash *hash) { - Object *ob; - if (!hash) return; /* Explicit collision collection. */ - Base *base = BKE_collection_or_layer_objects(NULL, NULL, view_layer, collection); + Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, collection); for (; base; base = base->next) { /* Only proceed for mesh object in same layer. */ if (base->object->type == OB_MESH) { - ob = base->object; + Object *ob = base->object; if (ob == vertexowner) { /* If vertexowner is given we don't want to check collision with owner object. */ continue; @@ -551,19 +550,17 @@ static void ccd_update_deflector_hash_single(GHash *hash, Object *ob) /** * \note collection overrides scene when not NULL. */ -static void ccd_update_deflector_hash(ViewLayer *view_layer, Collection *collection, Object *vertexowner, GHash *hash) +static void ccd_update_deflector_hash(Depsgraph *depsgraph, Collection *collection, Object *vertexowner, GHash *hash) { - Object *ob; - if ((!hash) || (!vertexowner)) return; /* Explicit collision collection. */ - Base *base = BKE_collection_or_layer_objects(NULL, NULL, view_layer, collection); + Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, collection); for (; base; base = base->next) { /* Only proceed for mesh object in same layer. */ if (base->object->type == OB_MESH) { - ob = base->object; + Object *ob = base->object; if (ob == vertexowner) { /* If vertexowner is given we don't want to check collision with owner object. */ continue; @@ -974,9 +971,9 @@ static bool are_there_deflectors(Base *first_base) return 0; } -static int query_external_colliders(ViewLayer *view_layer, Collection *collection) +static int query_external_colliders(Depsgraph *depsgraph, Collection *collection) { - return(are_there_deflectors(BKE_collection_or_layer_objects(NULL, NULL, view_layer, collection))); + return(are_there_deflectors(BKE_collection_or_layer_objects(depsgraph, NULL, NULL, collection))); } /* --- dependency information functions*/ @@ -2220,7 +2217,7 @@ static void softbody_calc_forcesEx(struct Depsgraph *depsgraph, Scene *scene, Ob /* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */ /* check conditions for various options */ - do_deflector= query_external_colliders(DEG_get_evaluated_view_layer(depsgraph), sb->collision_group); + do_deflector= query_external_colliders(depsgraph, sb->collision_group); /* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */ do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); @@ -2284,7 +2281,7 @@ static void softbody_calc_forces(struct Depsgraph *depsgraph, Scene *scene, Obje } /* check conditions for various options */ - do_deflector= query_external_colliders(DEG_get_evaluated_view_layer(depsgraph), sb->collision_group); + do_deflector= query_external_colliders(depsgraph, sb->collision_group); do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); @@ -3495,13 +3492,11 @@ static void softbody_step(struct Depsgraph *depsgraph, Scene *scene, Object *ob, */ if (dtime < 0 || dtime > 10.5f) return; - ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); - - ccd_update_deflector_hash(view_layer, sb->collision_group, ob, sb->scratch->colliderhash); + ccd_update_deflector_hash(depsgraph, sb->collision_group, ob, sb->scratch->colliderhash); if (sb->scratch->needstobuildcollider) { - if (query_external_colliders(view_layer, sb->collision_group)) { - ccd_build_deflector_hash(view_layer, sb->collision_group, ob, sb->scratch->colliderhash); + if (query_external_colliders(depsgraph, sb->collision_group)) { + ccd_build_deflector_hash(depsgraph, sb->collision_group, ob, sb->scratch->colliderhash); } sb->scratch->needstobuildcollider=0; } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index d67f702ba85..4ea2840648f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -897,11 +897,9 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene) /* objects - simulation participants */ if (rbw->group) { - const ListBase group_objects = BKE_collection_object_cache_get(rbw->group); - LISTBASE_FOREACH (Base *, base, &group_objects) { - Object *object = base->object; - - if (!object || (object->type != OB_MESH)) + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, object) + { + if (object->type != OB_MESH) continue; /* 2) create operation for flushing results */ @@ -915,6 +913,7 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene) get_cow_datablock(object)), DEG_OPCODE_RIGIDBODY_TRANSFORM_COPY); } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index eb1ee0c1535..f1eb637e9eb 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -478,16 +478,12 @@ void DepsgraphRelationBuilder::build_collection( } } if (object != NULL) { - const ListBase group_objects = BKE_collection_object_cache_get(collection); - const int base_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? - BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER; - LISTBASE_FOREACH (Base *, base, &group_objects) { - if ((base->flag & base_flag) == 0) { - continue; - } - ComponentKey dupli_transform_key(&base->object->id, DEG_NODE_TYPE_TRANSFORM); + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(collection, ob, graph_->mode) + { + ComponentKey dupli_transform_key(&ob->id, DEG_NODE_TYPE_TRANSFORM); add_relation(dupli_transform_key, object_local_transform_key, "Dupligroup"); } + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; } } @@ -1430,10 +1426,9 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) /* objects - simulation participants */ if (rbw->group) { - const ListBase group_objects = BKE_collection_object_cache_get(rbw->group); - LISTBASE_FOREACH (Base *, base, &group_objects) { - Object *object = base->object; - if (object == NULL || object->type != OB_MESH) { + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, object) + { + if (object->type != OB_MESH) { continue; } @@ -1481,14 +1476,14 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) /* Needed to get correct base values. */ add_relation(trans_op, sim_key, "Base Ob Transform -> Rigidbody Sim Eval"); } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; } /* constraints */ if (rbw->constraints) { - const ListBase constraint_objects = BKE_collection_object_cache_get(rbw->constraints); - LISTBASE_FOREACH (Base *, base, &constraint_objects) { - Object *object = base->object; - if (object == NULL || !object->rigidbody_constraint) { + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->constraints, object) + { + if (!object->rigidbody_constraint) { continue; } @@ -1508,6 +1503,7 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) /* - ensure that sim depends on this constraint's transform */ add_relation(trans_key, sim_key, "RigidBodyConstraint Transform -> RB Simulation"); } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; } } |