diff options
author | Bastien Montagne <bastien@blender.org> | 2022-03-28 18:34:36 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-03-29 18:59:55 +0300 |
commit | 5596f79821caae3d4c1eb608ce77371904f74b80 (patch) | |
tree | 92dbb06728dd7bbecfa71d17dbe25cde49dfdeb5 /source/blender/editors/physics | |
parent | 354db59fb12a5ee595ae650ac3a736e3cc6df39d (diff) |
LibOverride: Massive edits to 'editable' IDs checks in editors code.
Add new `BKE_id_is_editable` helper in `BKE_lib_id.h`, that supercedes
previous check (simple `ID_IS_LINKED()` macro) for many editing cases.
This allows to also take into account 'system override' (aka
non-editable override) case.
Ref: {T95707}.
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 6 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_object.c | 4 | ||||
-rw-r--r-- | source/blender/editors/physics/rigidbody_constraint.c | 19 | ||||
-rw-r--r-- | source/blender/editors/physics/rigidbody_object.c | 23 |
4 files changed, 34 insertions, 18 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 4a639e227f7..eba647a1b17 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -5406,10 +5406,10 @@ static bool particle_edit_toggle_poll(bContext *C) Object *ob = CTX_data_active_object(C); if (ob == NULL || ob->type != OB_MESH) { - return 0; + return false; } - if (!ob->data || ID_IS_LINKED(ob->data)) { - return 0; + if (!ob->data || ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob->data)) { + return false; } return ED_object_particle_edit_mode_supported(ob); diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 24860b9c4d8..6bea6e2c19e 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -1048,7 +1048,7 @@ static void remove_particle_systems_from_object(Object *ob_to) if (ob_to->type != OB_MESH) { return; } - if (!ob_to->data || ID_IS_LINKED(ob_to->data)) { + if (!ob_to->data || ID_IS_LINKED(ob_to->data) || ID_IS_OVERRIDE_LIBRARY(ob_to->data)) { return; } @@ -1090,7 +1090,7 @@ static bool copy_particle_systems_to_object(const bContext *C, if (ob_to->type != OB_MESH) { return false; } - if (!ob_to->data || ID_IS_LINKED(ob_to->data)) { + if (!ob_to->data || !BKE_id_is_editable(bmain, ob_to->data)) { return false; } diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index eb799f46177..66ae2d323fd 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -40,12 +40,21 @@ /* ********************************************** */ /* Helper API's for RigidBody Constraint Editing */ +static bool operator_rigidbody_constraints_editable_poll(Scene *scene) +{ + if (scene == NULL || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && + (ID_IS_LINKED(scene->rigidbody_world->constraints) || + ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->constraints)))) { + return false; + } + return true; +} + static bool ED_operator_rigidbody_con_active_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene == NULL || ID_IS_LINKED(&scene->id) || - (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && - ID_IS_LINKED(&scene->rigidbody_world->constraints->id))) { + if (!operator_rigidbody_constraints_editable_poll(scene)) { return false; } @@ -59,9 +68,7 @@ static bool ED_operator_rigidbody_con_active_poll(bContext *C) static bool ED_operator_rigidbody_con_add_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene == NULL || ID_IS_LINKED(&scene->id) || - (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && - ID_IS_LINKED(&scene->rigidbody_world->constraints->id))) { + if (!operator_rigidbody_constraints_editable_poll(scene)) { return false; } return ED_operator_object_active_editable(C); diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index 8f69947ceb0..5ff687bce1a 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -44,12 +44,21 @@ /* ********************************************** */ /* Helper API's for RigidBody Objects Editing */ +static bool operator_rigidbody_editable_poll(Scene *scene) +{ + if (scene == NULL || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL && + (ID_IS_LINKED(scene->rigidbody_world->group) || + ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->group)))) { + return false; + } + return true; +} + static bool ED_operator_rigidbody_active_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene == NULL || ID_IS_LINKED(&scene->id) || - (scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL && - ID_IS_LINKED(&scene->rigidbody_world->group->id))) { + if (!operator_rigidbody_editable_poll(scene)) { return false; } @@ -57,15 +66,14 @@ static bool ED_operator_rigidbody_active_poll(bContext *C) Object *ob = ED_object_active_context(C); return (ob && ob->rigidbody_object); } - return 0; + + return false; } static bool ED_operator_rigidbody_add_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene == NULL || ID_IS_LINKED(&scene->id) || - (scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL && - ID_IS_LINKED(&scene->rigidbody_world->group->id))) { + if (!operator_rigidbody_editable_poll(scene)) { return false; } @@ -73,6 +81,7 @@ static bool ED_operator_rigidbody_add_poll(bContext *C) Object *ob = ED_object_active_context(C); return (ob && ob->type == OB_MESH); } + return false; } |