Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_object.c
| Show First 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | else { | ||||
| /* no conversion to/from dataspace */ | /* no conversion to/from dataspace */ | ||||
| unit_m3(td->smtx); | unit_m3(td->smtx); | ||||
| unit_m3(td->mtx); | unit_m3(td->mtx); | ||||
| } | } | ||||
| } | } | ||||
| static void trans_object_base_deps_flag_prepare(ViewLayer *view_layer) | static void trans_object_base_deps_flag_prepare(ViewLayer *view_layer) | ||||
| { | { | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| base->object->id.tag &= ~LIB_TAG_DOIT; | base->object->id.tag &= ~LIB_TAG_DOIT; | ||||
| } | } | ||||
| } | } | ||||
| static void set_trans_object_base_deps_flag_cb(ID *id, | static void set_trans_object_base_deps_flag_cb(ID *id, | ||||
| eDepsObjectComponentType component, | eDepsObjectComponentType component, | ||||
| void *UNUSED(user_data)) | void *UNUSED(user_data)) | ||||
| { | { | ||||
| Show All 17 Lines | DEG_foreach_dependent_ID_component(depsgraph, | ||||
| set_trans_object_base_deps_flag_cb, | set_trans_object_base_deps_flag_cb, | ||||
| NULL); | NULL); | ||||
| } | } | ||||
| static void trans_object_base_deps_flag_finish(const TransInfo *t, ViewLayer *view_layer) | static void trans_object_base_deps_flag_finish(const TransInfo *t, ViewLayer *view_layer) | ||||
| { | { | ||||
| if ((t->options & CTX_OBMODE_XFORM_OBDATA) == 0) { | if ((t->options & CTX_OBMODE_XFORM_OBDATA) == 0) { | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| if (base->object->id.tag & LIB_TAG_DOIT) { | if (base->object->id.tag & LIB_TAG_DOIT) { | ||||
| base->flag_legacy |= BA_SNAP_FIX_DEPS_FIASCO; | base->flag_legacy |= BA_SNAP_FIX_DEPS_FIASCO; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* sets flags in Bases to define whether they take part in transform */ | /* sets flags in Bases to define whether they take part in transform */ | ||||
| Show All 14 Lines | static void set_trans_object_base_flags(TransInfo *t) | ||||
| } | } | ||||
| /* Makes sure base flags and object flags are identical. */ | /* Makes sure base flags and object flags are identical. */ | ||||
| BKE_scene_base_flag_to_objects(t->view_layer); | BKE_scene_base_flag_to_objects(t->view_layer); | ||||
| /* Make sure depsgraph is here. */ | /* Make sure depsgraph is here. */ | ||||
| DEG_graph_relations_update(depsgraph, bmain, scene, view_layer); | DEG_graph_relations_update(depsgraph, bmain, scene, view_layer); | ||||
| /* Clear all flags we need. It will be used to detect dependencies. */ | /* Clear all flags we need. It will be used to detect dependencies. */ | ||||
| trans_object_base_deps_flag_prepare(view_layer); | trans_object_base_deps_flag_prepare(view_layer); | ||||
| /* Traverse all bases and set all possible flags. */ | /* Traverse all bases and set all possible flags. */ | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| base->flag_legacy &= ~(BA_WAS_SEL | BA_TRANSFORM_LOCKED_IN_PLACE); | base->flag_legacy &= ~(BA_WAS_SEL | BA_TRANSFORM_LOCKED_IN_PLACE); | ||||
| if (BASE_SELECTED_EDITABLE(v3d, base)) { | if (BASE_SELECTED_EDITABLE(v3d, base)) { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| Object *parsel = ob->parent; | Object *parsel = ob->parent; | ||||
| /* If parent selected, deselect. */ | /* If parent selected, deselect. */ | ||||
| while (parsel != NULL) { | while (parsel != NULL) { | ||||
| if (parsel->base_flag & BASE_SELECTED) { | if (parsel->base_flag & BASE_SELECTED) { | ||||
| Base *parbase = BKE_view_layer_base_find(view_layer, parsel); | Base *parbase = BKE_view_layer_base_find(view_layer, parsel); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | static int count_proportional_objects(TransInfo *t) | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true); | Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true); | ||||
| /* Clear all flags we need. It will be used to detect dependencies. */ | /* Clear all flags we need. It will be used to detect dependencies. */ | ||||
| trans_object_base_deps_flag_prepare(view_layer); | trans_object_base_deps_flag_prepare(view_layer); | ||||
| /* Rotations around local centers are allowed to propagate, so we take all objects. */ | /* Rotations around local centers are allowed to propagate, so we take all objects. */ | ||||
| if (!((t->around == V3D_AROUND_LOCAL_ORIGINS) && | if (!((t->around == V3D_AROUND_LOCAL_ORIGINS) && | ||||
| (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL))) { | (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL))) { | ||||
| /* Mark all parents. */ | /* Mark all parents. */ | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| if (BASE_SELECTED_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) { | if (BASE_SELECTED_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) { | ||||
| Object *parent = base->object->parent; | Object *parent = base->object->parent; | ||||
| /* flag all parents */ | /* flag all parents */ | ||||
| while (parent != NULL) { | while (parent != NULL) { | ||||
| parent->flag |= BA_TRANSFORM_PARENT; | parent->flag |= BA_TRANSFORM_PARENT; | ||||
| parent = parent->parent; | parent = parent->parent; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Mark all children. */ | /* Mark all children. */ | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| /* all base not already selected or marked that is editable */ | /* all base not already selected or marked that is editable */ | ||||
| if ((base->object->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 && | if ((base->object->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 && | ||||
| (base->flag & BASE_SELECTED) == 0 && | (base->flag & BASE_SELECTED) == 0 && | ||||
| (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) { | (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) { | ||||
| mark_children(base->object); | mark_children(base->object); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Flush changed flags to all dependencies. */ | /* Flush changed flags to all dependencies. */ | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| /* If base is not selected, not a parent of selection or not a child of | /* If base is not selected, not a parent of selection or not a child of | ||||
| * selection and it is editable and selectable. | * selection and it is editable and selectable. | ||||
| */ | */ | ||||
| if ((ob->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 && | if ((ob->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 && | ||||
| (base->flag & BASE_SELECTED) == 0 && | (base->flag & BASE_SELECTED) == 0 && | ||||
| (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) { | (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) { | ||||
| flush_trans_object_base_deps_flag(depsgraph, ob); | flush_trans_object_base_deps_flag(depsgraph, ob); | ||||
| ▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | for (int i = 0; i < tc->data_len; i++, td++) { | ||||
| if ((td->flag & TD_SKIP) == 0) { | if ((td->flag & TD_SKIP) == 0) { | ||||
| BLI_gset_add(objects_in_transdata, td->ob); | BLI_gset_add(objects_in_transdata, td->ob); | ||||
| } | } | ||||
| } | } | ||||
| ViewLayer *view_layer = t->view_layer; | ViewLayer *view_layer = t->view_layer; | ||||
| View3D *v3d = t->view; | View3D *v3d = t->view; | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| /* if base is not selected, not a parent of selection | /* if base is not selected, not a parent of selection | ||||
| * or not a child of selection and it is editable and selectable */ | * or not a child of selection and it is editable and selectable */ | ||||
| if ((base->flag_legacy & BA_WAS_SEL) && (base->flag & BASE_SELECTED) == 0 && | if ((base->flag_legacy & BA_WAS_SEL) && (base->flag & BASE_SELECTED) == 0 && | ||||
| BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) { | BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) { | ||||
| Object *ob_parent = ob->parent; | Object *ob_parent = ob->parent; | ||||
| Show All 30 Lines | ((base->flag_legacy & BA_WAS_SEL) && (base->flag & BASE_SELECTED) == 0) | ||||
| for (int i = 0; i < tc->data_len; i++, td++) { | for (int i = 0; i < tc->data_len; i++, td++) { | ||||
| if ((td->flag & TD_SKIP) == 0) { | if ((td->flag & TD_SKIP) == 0) { | ||||
| BLI_gset_add(objects_in_transdata, td->ob); | BLI_gset_add(objects_in_transdata, td->ob); | ||||
| } | } | ||||
| } | } | ||||
| ViewLayer *view_layer = t->view_layer; | ViewLayer *view_layer = t->view_layer; | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| if (ob->parent != NULL) { | if (ob->parent != NULL) { | ||||
| if (ob->parent && !BLI_gset_haskey(objects_in_transdata, ob->parent) && | if (ob->parent && !BLI_gset_haskey(objects_in_transdata, ob->parent) && | ||||
| !BLI_gset_haskey(objects_in_transdata, ob)) { | !BLI_gset_haskey(objects_in_transdata, ob)) { | ||||
| if (((base->flag_legacy & BA_WAS_SEL) && (base->flag & BASE_SELECTED) == 0)) { | if (((base->flag_legacy & BA_WAS_SEL) && (base->flag & BASE_SELECTED) == 0)) { | ||||
| Base *base_parent = BKE_view_layer_base_find(view_layer, ob->parent); | Base *base_parent = BKE_view_layer_base_find(view_layer, ob->parent); | ||||
| if (base_parent && !BASE_XFORM_INDIRECT(base_parent)) { | if (base_parent && !BASE_XFORM_INDIRECT(base_parent)) { | ||||
| Object *ob_parent_recurse = ob->parent; | Object *ob_parent_recurse = ob->parent; | ||||
| Show All 13 Lines | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| if (BASE_XFORM_INDIRECT(base) || BLI_gset_haskey(objects_in_transdata, ob)) { | if (BASE_XFORM_INDIRECT(base) || BLI_gset_haskey(objects_in_transdata, ob)) { | ||||
| /* pass. */ | /* pass. */ | ||||
| } | } | ||||
| else if (ob->parent != NULL) { | else if (ob->parent != NULL) { | ||||
| Base *base_parent = BKE_view_layer_base_find(view_layer, ob->parent); | Base *base_parent = BKE_view_layer_base_find(view_layer, ob->parent); | ||||
| if (base_parent) { | if (base_parent) { | ||||
| ▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines | |||||