Commit: 73b9531dcfa34bea4ab8b4f5fc37039786bf809c
Author: Brecht Van Lommel
Date:   Mon Jun 11 11:40:26 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB73b9531dcfa34bea4ab8b4f5fc37039786bf809c

Fix incorrect object selection test in outliner and rigid body.

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

M       source/blender/blenkernel/intern/rigidbody.c
M       source/blender/editors/space_outliner/outliner_select.c
M       source/blender/render/intern/source/pipeline.c

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

diff --git a/source/blender/blenkernel/intern/rigidbody.c 
b/source/blender/blenkernel/intern/rigidbody.c
index e79f86c6520..f7628d081a6 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -58,6 +58,7 @@
 #include "BKE_collection.h"
 #include "BKE_effect.h"
 #include "BKE_global.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_library_query.h"
 #include "BKE_mesh.h"
@@ -1436,14 +1437,14 @@ static void rigidbody_update_simulation(struct 
Depsgraph *depsgraph, Scene *scen
        FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
 }
 
-static void rigidbody_update_simulation_post_step(RigidBodyWorld *rbw)
+static void rigidbody_update_simulation_post_step(ViewLayer *view_layer, 
RigidBodyWorld *rbw)
 {
-       FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(rbw->group, base)
+       FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, ob)
        {
-               Object *ob = base->object;
+               Base *base = BKE_view_layer_base_find(view_layer, ob);
                RigidBodyOb *rbo = ob->rigidbody_object;
                /* Reset kinematic state for transformed objects. */
-               if (rbo && (base->flag & BASE_SELECTED) && (G.moving & 
G_TRANSFORM_OBJ)) {
+               if (rbo && base && (base->flag & BASE_SELECTED) && (G.moving & 
G_TRANSFORM_OBJ)) {
                        RB_body_set_kinematic_state(rbo->physics_object, 
rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
                        RB_body_set_mass(rbo->physics_object, 
RBO_GET_MASS(rbo));
                        /* Deactivate passive objects so they don't interfere 
with deactivation of active objects. */
@@ -1451,7 +1452,7 @@ static void 
rigidbody_update_simulation_post_step(RigidBodyWorld *rbw)
                                RB_body_deactivate(rbo->physics_object);
                }
        }
-       FOREACH_COLLECTION_BASE_RECURSIVE_END
+       FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
 }
 
 bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float ctime)
@@ -1647,7 +1648,8 @@ 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));
 
-               rigidbody_update_simulation_post_step(rbw);
+               ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
+               rigidbody_update_simulation_post_step(view_layer, rbw);
 
                /* write cache for current frame */
                BKE_ptcache_validate(cache, (int)ctime);
diff --git a/source/blender/editors/space_outliner/outliner_select.c 
b/source/blender/editors/space_outliner/outliner_select.c
index af1b11b28d2..36fd37e1134 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -941,18 +941,22 @@ static void do_outliner_item_activate_tree_element(
 
                        if (extend) {
                                int sel = BA_SELECT;
-                               FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(gr, 
base)
+                               FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(gr, 
object)
                                {
-                                       if (base->flag & BASE_SELECTED) {
+                                       Base *base = 
BKE_view_layer_base_find(view_layer, object);
+                                       if (base && (base->flag & 
BASE_SELECTED)) {
                                                sel = BA_DESELECT;
                                                break;
                                        }
                                }
-                               FOREACH_COLLECTION_BASE_RECURSIVE_END
+                               FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
 
                                FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(gr, 
object)
                                {
-                                       
ED_object_base_select(BKE_view_layer_base_find(view_layer, object), sel);
+                                       Base *base = 
BKE_view_layer_base_find(view_layer, object);
+                                       if (base) {
+                                               ED_object_base_select(base, 
sel);
+                                       }
                                }
                                FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
                        }
diff --git a/source/blender/render/intern/source/pipeline.c 
b/source/blender/render/intern/source/pipeline.c
index e9bc87762e3..8493913bd29 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1338,12 +1338,11 @@ static void tag_dependend_object_for_render(Scene 
*scene, Object *object)
                                                        break;
                                                case PART_DRAW_GR:
                                                        if (part->dup_group != 
NULL) {
-                                                               
FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(part->dup_group, base)
+                                                               
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(part->dup_group, ob)
                                                                {
-                                                                       Object 
*ob = base->object;
                                                                        
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
                                                                }
-                                                               
FOREACH_COLLECTION_BASE_RECURSIVE_END
+                                                               
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
                                                        }
                                                        break;
                                        }

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

Reply via email to