Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert.c
| Show All 21 Lines | |||||
| */ | */ | ||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_constraint_types.h" | #include "DNA_constraint_types.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_kdtree.h" | #include "BLI_kdtree.h" | ||||
| #include "BLI_linklist_stack.h" | |||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_anim_data.h" | #include "BKE_anim_data.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| ▲ Show 20 Lines • Show All 366 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Curve Surface | /** \name Curve Surface | ||||
| * \{ */ | * \{ */ | ||||
| void calc_distanceCurveVerts(TransData *head, TransData *tail) | void calc_distanceCurveVerts(TransData *head, TransData *tail, bool cyclic) | ||||
| { | { | ||||
| TransData *td, *td_near = NULL; | TransData *td; | ||||
| BLI_LINKSTACK_DECLARE(queue, TransData *); | |||||
| BLI_LINKSTACK_INIT(queue); | |||||
| for (td = head; td <= tail; td++) { | for (td = head; td <= tail; td++) { | ||||
| if (td->flag & TD_SELECTED) { | if (td->flag & TD_SELECTED) { | ||||
| td_near = td; | |||||
| td->dist = 0.0f; | td->dist = 0.0f; | ||||
| BLI_LINKSTACK_PUSH(queue, td); | |||||
| } | |||||
| else { | |||||
| td->dist = FLT_MAX; | |||||
| } | |||||
| } | } | ||||
| else if (td_near) { | |||||
| while ((td = BLI_LINKSTACK_POP(queue))) { | |||||
| float dist; | float dist; | ||||
| float vec[3]; | float vec[3]; | ||||
| sub_v3_v3v3(vec, td_near->center, td->center); | TransData *next_td = NULL; | ||||
| mul_m3_v3(head->mtx, vec); | |||||
| dist = len_v3(vec); | |||||
| if (dist < (td - 1)->dist) { | if (td + 1 <= tail) { | ||||
| td->dist = (td - 1)->dist; | next_td = td + 1; | ||||
| } | } | ||||
| else { | else if (cyclic) { | ||||
| td->dist = dist; | next_td = head; | ||||
| } | } | ||||
| if (next_td != NULL && !(next_td->flag & TD_NOTCONNECTED)) { | |||||
| sub_v3_v3v3(vec, next_td->center, td->center); | |||||
| mul_m3_v3(head->mtx, vec); | |||||
| dist = len_v3(vec) + td->dist; | |||||
| if (dist < next_td->dist) { | |||||
| next_td->dist = dist; | |||||
| BLI_LINKSTACK_PUSH(queue, next_td); | |||||
| } | } | ||||
| else { | |||||
| td->dist = FLT_MAX; | |||||
| td->flag |= TD_NOTCONNECTED; | |||||
| } | } | ||||
| if (td - 1 >= head) { | |||||
| next_td = td - 1; | |||||
| } | } | ||||
| td_near = NULL; | else if (cyclic) { | ||||
| for (td = tail; td >= head; td--) { | next_td = tail; | ||||
| if (td->flag & TD_SELECTED) { | |||||
| td_near = td; | |||||
| td->dist = 0.0f; | |||||
| } | } | ||||
| else if (td_near) { | |||||
| float dist; | |||||
| float vec[3]; | |||||
| sub_v3_v3v3(vec, td_near->center, td->center); | if (next_td != NULL && !(next_td->flag & TD_NOTCONNECTED)) { | ||||
| sub_v3_v3v3(vec, next_td->center, td->center); | |||||
| mul_m3_v3(head->mtx, vec); | mul_m3_v3(head->mtx, vec); | ||||
| dist = len_v3(vec); | dist = len_v3(vec) + td->dist; | ||||
| if (td->flag & TD_NOTCONNECTED || dist < td->dist || (td + 1)->dist < td->dist) { | if (dist < next_td->dist) { | ||||
| td->flag &= ~TD_NOTCONNECTED; | next_td->dist = dist; | ||||
| if (dist < (td + 1)->dist) { | BLI_LINKSTACK_PUSH(queue, next_td); | ||||
| td->dist = (td + 1)->dist; | |||||
| } | |||||
| else { | |||||
| td->dist = dist; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| BLI_LINKSTACK_FREE(queue); | |||||
| } | } | ||||
| /* Utility function for getting the handle data from bezier's */ | /* Utility function for getting the handle data from bezier's */ | ||||
| TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTriple *bezt) | TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTriple *bezt) | ||||
| { | { | ||||
| TransDataCurveHandleFlags *hdata; | TransDataCurveHandleFlags *hdata; | ||||
| td->flag |= TD_BEZTRIPLE; | td->flag |= TD_BEZTRIPLE; | ||||
| hdata = td->hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data"); | hdata = td->hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data"); | ||||
| ▲ Show 20 Lines • Show All 992 Lines • Show Last 20 Lines | |||||