Fix use of non-evaluated collision and effector objects.

Only enabled objects in the view layer should be used, while temporarily
hidden objects should still have an effect.
This commit is contained in:
2018-06-25 14:07:14 +02:00
parent 817bf582c2
commit 38d6e82d1a
2 changed files with 16 additions and 21 deletions

View File

@@ -517,27 +517,16 @@ static void add_collision_object(ListBase *relations, Object *ob, int level, uns
* lookup of colliders during evaluation. */
ListBase *BKE_collision_relations_create(Depsgraph *depsgraph, Collection *collection, unsigned int modifier_type)
{
ListBase *relations = MEM_callocN(sizeof(ListBase), "CollisionRelation list");
int level = 0;
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
Base *base = BKE_collection_or_layer_objects(NULL, NULL, view_layer, collection);
const bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
const int base_flag = (for_render) ? BASE_ENABLED_RENDER : BASE_ENABLED_VIEWPORT;
/* gather all collision objects */
if (collection) {
/* use specified collection */
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, object)
{
add_collision_object(relations, object, level, modifier_type);
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
else {
Scene *scene = DEG_get_input_scene(depsgraph);
Scene *sce_iter;
Base *base;
/* add objects in same layer in scene */
for (SETLOOPER(scene, sce_iter, base)) {
if ((base->flag & BASE_VISIBLE) != 0) {
add_collision_object(relations, base->object, level, modifier_type);
}
ListBase *relations = MEM_callocN(sizeof(ListBase), "CollisionRelation list");
for (; base; base = base->next) {
if (base->flag & base_flag) {
add_collision_object(relations, base->object, 0, modifier_type);
}
}

View File

@@ -228,11 +228,17 @@ ListBase *BKE_effector_relations_create(
ViewLayer *view_layer,
Collection *collection)
{
const bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
Base *base = BKE_collection_or_layer_objects(NULL, NULL, view_layer, collection);
const bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
const int base_flag = (for_render) ? BASE_ENABLED_RENDER : BASE_ENABLED_VIEWPORT;
ListBase *relations = MEM_callocN(sizeof(ListBase), "effector relations");
for (; base; base = base->next) {
if (!(base->flag & base_flag)) {
continue;
}
Object *ob = base->object;
if (ob->pd && ob->pd->forcefield) {