Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_conversions.c
| Show First 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* ************************** CONVERSIONS ************************* */ | /* ************************** CONVERSIONS ************************* */ | ||||
| /* ********************* texture space ********* */ | /* ********************* texture space ********* */ | ||||
| static void createTransTexspace(TransInfo *t) | static void createTransTexspace(TransInfo *t) | ||||
| { | { | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| TransData *td; | TransData *td; | ||||
| Object *ob; | Object *ob; | ||||
| ID *id; | ID *id; | ||||
| short *texflag; | short *texflag; | ||||
| ob = OBACT(sl); | ob = OBACT(sl); | ||||
| if (ob == NULL) { // Shouldn't logically happen, but still... | if (ob == NULL) { // Shouldn't logically happen, but still... | ||||
| ▲ Show 20 Lines • Show All 1,590 Lines • ▼ Show 20 Lines | |||||
| /* ******************* particle edit **************** */ | /* ******************* particle edit **************** */ | ||||
| static void createTransParticleVerts(bContext *C, TransInfo *t) | static void createTransParticleVerts(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| TransData *td = NULL; | TransData *td = NULL; | ||||
| TransDataExtension *tx; | TransDataExtension *tx; | ||||
| Base *base = CTX_data_active_base(C); | Base *base = CTX_data_active_base(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| ParticleEditSettings *pset = PE_settings(t->scene); | ParticleEditSettings *pset = PE_settings(t->scene); | ||||
| PTCacheEdit *edit = PE_get_current(t->scene, t->scene_layer, ob); | PTCacheEdit *edit = PE_get_current(t->scene, t->view_layer, ob); | ||||
| ParticleSystem *psys = NULL; | ParticleSystem *psys = NULL; | ||||
| ParticleSystemModifierData *psmd = NULL; | ParticleSystemModifierData *psmd = NULL; | ||||
| PTCacheEditPoint *point; | PTCacheEditPoint *point; | ||||
| PTCacheEditKey *key; | PTCacheEditKey *key; | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| int i, k, transformparticle; | int i, k, transformparticle; | ||||
| int count = 0, hasselected = 0; | int count = 0, hasselected = 0; | ||||
| const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; | const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; | ||||
| ▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) { | ||||
| if (is_prop_edit && head != tail) | if (is_prop_edit && head != tail) | ||||
| calc_distanceCurveVerts(head, tail - 1); | calc_distanceCurveVerts(head, tail - 1); | ||||
| } | } | ||||
| } | } | ||||
| void flushTransParticles(TransInfo *t) | void flushTransParticles(TransInfo *t) | ||||
| { | { | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(sl); | ||||
| PTCacheEdit *edit = PE_get_current(scene, sl, ob); | PTCacheEdit *edit = PE_get_current(scene, sl, ob); | ||||
| ParticleSystem *psys = edit->psys; | ParticleSystem *psys = edit->psys; | ||||
| ParticleSystemModifierData *psmd = NULL; | ParticleSystemModifierData *psmd = NULL; | ||||
| PTCacheEditPoint *point; | PTCacheEditPoint *point; | ||||
| PTCacheEditKey *key; | PTCacheEditKey *key; | ||||
| TransData *td; | TransData *td; | ||||
| float mat[4][4], imat[4][4], co[3]; | float mat[4][4], imat[4][4], co[3]; | ||||
| ▲ Show 20 Lines • Show All 458 Lines • ▼ Show 20 Lines | static void createTransEditVerts(TransInfo *t) | ||||
| int cd_vert_bweight_offset = -1; | int cd_vert_bweight_offset = -1; | ||||
| bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; | bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; | ||||
| struct TransIslandData *island_info = NULL; | struct TransIslandData *island_info = NULL; | ||||
| int island_info_tot; | int island_info_tot; | ||||
| int *island_vert_map = NULL; | int *island_vert_map = NULL; | ||||
| DEG_evaluation_context_init_from_scene(&eval_ctx, | DEG_evaluation_context_init_from_scene(&eval_ctx, | ||||
| t->scene, t->scene_layer, t->engine, | t->scene, t->view_layer, t->engine, | ||||
| DAG_EVAL_VIEWPORT); | DAG_EVAL_VIEWPORT); | ||||
| /* Even for translation this is needed because of island-orientation, see: T51651. */ | /* Even for translation this is needed because of island-orientation, see: T51651. */ | ||||
| const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS); | const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS); | ||||
| /* Original index of our connected vertex when connected distances are calculated. | /* Original index of our connected vertex when connected distances are calculated. | ||||
| * Optional, allocate if needed. */ | * Optional, allocate if needed. */ | ||||
| int *dists_index = NULL; | int *dists_index = NULL; | ||||
| ▲ Show 20 Lines • Show All 3,036 Lines • ▼ Show 20 Lines | |||||
| /* sets flags in Bases to define whether they take part in transform */ | /* sets flags in Bases to define whether they take part in transform */ | ||||
| /* it deselects Bases, so we have to call the clear function always after */ | /* it deselects Bases, so we have to call the clear function always after */ | ||||
| static void set_trans_object_base_flags(TransInfo *t) | static void set_trans_object_base_flags(TransInfo *t) | ||||
| { | { | ||||
| /* TODO(sergey): Get rid of global, use explicit main. */ | /* TODO(sergey): Get rid of global, use explicit main. */ | ||||
| Main *bmain = G.main; | Main *bmain = G.main; | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl, true); | Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl, true); | ||||
| /* | /* | ||||
| * if Base selected and has parent selected: | * if Base selected and has parent selected: | ||||
| * base->flag_legacy = BA_WAS_SEL | * base->flag_legacy = BA_WAS_SEL | ||||
| */ | */ | ||||
| Base *base; | Base *base; | ||||
| /* don't do it if we're not actually going to recalculate anything */ | /* don't do it if we're not actually going to recalculate anything */ | ||||
| if (t->mode == TFM_DUMMY) | if (t->mode == TFM_DUMMY) | ||||
| return; | return; | ||||
| /* 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->scene_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, sl); | DEG_graph_relations_update(depsgraph, bmain, scene, sl); | ||||
| /* handle pending update events, otherwise they got copied below */ | /* handle pending update events, otherwise they got copied below */ | ||||
| EvaluationContext eval_ctx; | EvaluationContext eval_ctx; | ||||
| DEG_evaluation_context_init_from_scene(&eval_ctx, | DEG_evaluation_context_init_from_scene(&eval_ctx, | ||||
| t->scene, t->scene_layer, t->engine, | t->scene, t->view_layer, t->engine, | ||||
| DAG_EVAL_VIEWPORT); | DAG_EVAL_VIEWPORT); | ||||
| for (base = sl->object_bases.first; base; base = base->next) { | for (base = sl->object_bases.first; base; base = base->next) { | ||||
| if (base->object->recalc & OB_RECALC_ALL) { | if (base->object->recalc & OB_RECALC_ALL) { | ||||
| /* TODO(sergey): Ideally, it's not needed. */ | /* TODO(sergey): Ideally, it's not needed. */ | ||||
| BKE_object_handle_update(&eval_ctx, t->scene, base->object); | BKE_object_handle_update(&eval_ctx, t->scene, base->object); | ||||
| } | } | ||||
| } | } | ||||
| for (base = sl->object_bases.first; base; base = base->next) { | for (base = sl->object_bases.first; base; base = base->next) { | ||||
| base->flag_legacy &= ~BA_WAS_SEL; | base->flag_legacy &= ~BA_WAS_SEL; | ||||
| if (TESTBASELIB_BGMODE(base)) { | if (TESTBASELIB_BGMODE(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) { | while (parsel) { | ||||
| if (parsel->base_flag & BASE_SELECTED) { | if (parsel->base_flag & BASE_SELECTED) { | ||||
| Base *parbase = BKE_scene_layer_base_find(sl, parsel); | Base *parbase = BKE_view_layer_base_find(sl, parsel); | ||||
| if (parbase) { /* in rare cases this can fail */ | if (parbase) { /* in rare cases this can fail */ | ||||
| if (TESTBASELIB_BGMODE(parbase)) { | if (TESTBASELIB_BGMODE(parbase)) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| parsel = parsel->parent; | parsel = parsel->parent; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | static bool mark_children(Object *ob) | ||||
| return false; | return false; | ||||
| } | } | ||||
| static int count_proportional_objects(TransInfo *t) | static int count_proportional_objects(TransInfo *t) | ||||
| { | { | ||||
| int total = 0; | int total = 0; | ||||
| /* TODO(sergey): Get rid of global, use explicit main. */ | /* TODO(sergey): Get rid of global, use explicit main. */ | ||||
| Main *bmain = G.main; | Main *bmain = G.main; | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl, true); | Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl, true); | ||||
| Base *base; | Base *base; | ||||
| /* 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))) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if (base->object->recalc & OB_RECALC_DATA) | ||||
| base->flag_legacy |= BA_HAS_RECALC_DATA; | base->flag_legacy |= BA_HAS_RECALC_DATA; | ||||
| } | } | ||||
| return total; | return total; | ||||
| } | } | ||||
| static void clear_trans_object_base_flags(TransInfo *t) | static void clear_trans_object_base_flags(TransInfo *t) | ||||
| { | { | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| Base *base; | Base *base; | ||||
| for (base = sl->object_bases.first; base; base = base->next) { | for (base = sl->object_bases.first; base; base = base->next) { | ||||
| if (base->flag_legacy & BA_WAS_SEL) { | if (base->flag_legacy & BA_WAS_SEL) { | ||||
| base->flag |= BASE_SELECTED; | base->flag |= BASE_SELECTED; | ||||
| } | } | ||||
| base->flag_legacy &= ~(BA_WAS_SEL | BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA | BA_TEMP_TAG | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT); | base->flag_legacy &= ~(BA_WAS_SEL | BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA | BA_TEMP_TAG | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT); | ||||
| } | } | ||||
| } | } | ||||
| /* auto-keyframing feature - for objects | /* auto-keyframing feature - for objects | ||||
| * tmode: should be a transform mode | * tmode: should be a transform mode | ||||
| */ | */ | ||||
| // NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases | // NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases | ||||
| void autokeyframe_ob_cb_func(bContext *C, Scene *scene, SceneLayer *sl, View3D *v3d, Object *ob, int tmode) | void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *sl, View3D *v3d, Object *ob, int tmode) | ||||
| { | { | ||||
| ID *id = &ob->id; | ID *id = &ob->id; | ||||
| FCurve *fcu; | FCurve *fcu; | ||||
| // TODO: this should probably be done per channel instead... | // TODO: this should probably be done per channel instead... | ||||
| if (autokeyframe_cfra_can_key(scene, id)) { | if (autokeyframe_cfra_can_key(scene, id)) { | ||||
| ReportList *reports = CTX_wm_reports(C); | ReportList *reports = CTX_wm_reports(C); | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| ▲ Show 20 Lines • Show All 760 Lines • ▼ Show 20 Lines | else if ((t->flag & T_POSE) && (t->poseobj)) { | ||||
| } | } | ||||
| else | else | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| } | } | ||||
| else if (t->options & CTX_PAINT_CURVE) { | else if (t->options & CTX_PAINT_CURVE) { | ||||
| /* pass */ | /* pass */ | ||||
| } | } | ||||
| else if ((t->scene_layer->basact) && | else if ((t->view_layer->basact) && | ||||
| (ob = t->scene_layer->basact->object) && | (ob = t->view_layer->basact->object) && | ||||
| (ob->mode & OB_MODE_PARTICLE_EDIT) && | (ob->mode & OB_MODE_PARTICLE_EDIT) && | ||||
| PE_get_current(t->scene, t->scene_layer, ob)) | PE_get_current(t->scene, t->view_layer, ob)) | ||||
| { | { | ||||
| /* do nothing */ | /* do nothing */ | ||||
| } | } | ||||
| else { /* Objects */ | else { /* Objects */ | ||||
| int i; | int i; | ||||
| BLI_assert(t->flag & (T_OBJECT | T_TEXTURE)); | BLI_assert(t->flag & (T_OBJECT | T_TEXTURE)); | ||||
| Show All 24 Lines | for (i = 0; i < t->total; i++) { | ||||
| /* Needed for proper updating of "quick cached" dynamics. */ | /* Needed for proper updating of "quick cached" dynamics. */ | ||||
| /* Creates troubles for moving animated objects without */ | /* Creates troubles for moving animated objects without */ | ||||
| /* autokey though, probably needed is an anim sys override? */ | /* autokey though, probably needed is an anim sys override? */ | ||||
| /* Please remove if some other solution is found. -jahka */ | /* Please remove if some other solution is found. -jahka */ | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_OB); | DEG_id_tag_update(&ob->id, OB_RECALC_OB); | ||||
| /* Set autokey if necessary */ | /* Set autokey if necessary */ | ||||
| if (!canceled) { | if (!canceled) { | ||||
| autokeyframe_ob_cb_func(C, t->scene, t->scene_layer, (View3D *)t->view, ob, t->mode); | autokeyframe_ob_cb_func(C, t->scene, t->view_layer, (View3D *)t->view, ob, t->mode); | ||||
| } | } | ||||
| /* restore rigid body transform */ | /* restore rigid body transform */ | ||||
| if (ob->rigidbody_object && canceled) { | if (ob->rigidbody_object && canceled) { | ||||
| float ctime = BKE_scene_frame_get(t->scene); | float ctime = BKE_scene_frame_get(t->scene); | ||||
| if (BKE_rigidbody_check_sim_running(t->scene->rigidbody_world, ctime)) | if (BKE_rigidbody_check_sim_running(t->scene->rigidbody_world, ctime)) | ||||
| BKE_rigidbody_aftertrans_update(ob, td->ext->oloc, td->ext->orot, td->ext->oquat, td->ext->orotAxis, td->ext->orotAngle); | BKE_rigidbody_aftertrans_update(ob, td->ext->oloc, td->ext->orot, td->ext->oquat, td->ext->orotAxis, td->ext->orotAngle); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | CTX_DATA_BEGIN(C, Base *, base, selected_bases) | ||||
| ObjectToTransData(t, td, ob); | ObjectToTransData(t, td, ob); | ||||
| td->val = NULL; | td->val = NULL; | ||||
| td++; | td++; | ||||
| tx++; | tx++; | ||||
| } | } | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| if (is_prop_edit) { | if (is_prop_edit) { | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *view_layer = t->view_layer; | ||||
| Base *base; | Base *base; | ||||
| for (base = sl->object_bases.first; base; base = base->next) { | for (base = view_layer->object_bases.first; base; base = base->next) { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| /* if base is not selected, not a parent of selection or not a child of selection and it is editable */ | /* if base is not selected, not a parent of selection or not a child of selection and it is editable */ | ||||
| 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_BGMODE(base)) | BASE_EDITABLE_BGMODE(base)) | ||||
| { | { | ||||
| td->protectflag = ob->protectflag; | td->protectflag = ob->protectflag; | ||||
| ▲ Show 20 Lines • Show All 1,436 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void createTransData(bContext *C, TransInfo *t) | void createTransData(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(sl); | ||||
| /* if tests must match recalcData for correct updates */ | /* if tests must match recalcData for correct updates */ | ||||
| if (t->options & CTX_TEXTURE) { | if (t->options & CTX_TEXTURE) { | ||||
| t->flag |= T_TEXTURE; | t->flag |= T_TEXTURE; | ||||
| createTransTexspace(t); | createTransTexspace(t); | ||||
| } | } | ||||
| else if (t->options & CTX_EDGE) { | else if (t->options & CTX_EDGE) { | ||||
| ▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | else if (ob && (ob->mode & OB_MODE_POSE)) { | ||||
| // XXX active-layer checking isn't done as that should probably be checked through context instead | // XXX active-layer checking isn't done as that should probably be checked through context instead | ||||
| createTransPose(t, ob); | createTransPose(t, ob); | ||||
| } | } | ||||
| else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) { | else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) { | ||||
| /* important that ob_armature can be set even when its not selected [#23412] | /* important that ob_armature can be set even when its not selected [#23412] | ||||
| * lines below just check is also visible */ | * lines below just check is also visible */ | ||||
| Object *ob_armature = modifiers_isDeformedByArmature(ob); | Object *ob_armature = modifiers_isDeformedByArmature(ob); | ||||
| if (ob_armature && ob_armature->mode & OB_MODE_POSE) { | if (ob_armature && ob_armature->mode & OB_MODE_POSE) { | ||||
| Base *base_arm = BKE_scene_layer_base_find(t->scene_layer, ob_armature); | Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature); | ||||
| if (base_arm) { | if (base_arm) { | ||||
| if (BASE_VISIBLE(base_arm)) { | if (BASE_VISIBLE(base_arm)) { | ||||
| createTransPose(t, ob_armature); | createTransPose(t, ob_armature); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Show All 39 Lines | |||||