Fix incorrect object selection test in outliner and rigid body.
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
					}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user