Commit: 38d6e82d1a666c317118a5ebfda39e4a67639e1a
Author: Brecht Van Lommel
Date:   Mon Jun 25 14:07:14 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB38d6e82d1a666c317118a5ebfda39e4a67639e1a

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.

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

M       source/blender/blenkernel/intern/collision.c
M       source/blender/blenkernel/intern/effect.c

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

diff --git a/source/blender/blenkernel/intern/collision.c 
b/source/blender/blenkernel/intern/collision.c
index 19c170acf75..546f37dbee6 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -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)
 {
+       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;
+
        ListBase *relations = MEM_callocN(sizeof(ListBase), "CollisionRelation 
list");
-       int level = 0;
 
-       /* 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);
-                       }
+       for (; base; base = base->next) {
+               if (base->flag & base_flag) {
+                       add_collision_object(relations, base->object, 0, 
modifier_type);
                }
        }
 
diff --git a/source/blender/blenkernel/intern/effect.c 
b/source/blender/blenkernel/intern/effect.c
index 2894ff4f1e7..a3a766b2d1d 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -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) {

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

Reply via email to