Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/curve/editcurve.c
| Context not available. | |||||
| BezTriple *bezt, *beztOrig; | BezTriple *bezt, *beztOrig; | ||||
campbellbarton: Dont think this is needed - just `BLI_assert(factor >= 0.0f && factor <= 1.0f)` | |||||
| BPoint *bp, *bpOrig; | BPoint *bp, *bpOrig; | ||||
| float val, newval, offset; | float val, newval, offset; | ||||
| int a, i; | int point_final; | ||||
| int a, i, ind_prev, ind_next; | |||||
| bool changed = false; | bool changed = false; | ||||
| for (nu = editnurb->first; nu; nu = nu->next) { | for (nu = editnurb->first; nu; nu = nu->next) { | ||||
| if (nu->bezt) { | if (nu->bezt) { | ||||
| changed = false; | changed = false; | ||||
| /* duplicate the curve to use in weight calculation */ | |||||
| beztOrig = MEM_dupallocN(nu->bezt); | beztOrig = MEM_dupallocN(nu->bezt); | ||||
| for (bezt = &nu->bezt[1], a = 1; a < nu->pntsu - 1; a++, bezt++) { | |||||
| /* check whether its cyclic or not, and set initial & final conditions */ | |||||
Not Done Inline Actionsops, missed to change this one :/ walid: ops, missed to change this one :/ | |||||
| if (nu->flagu & CU_NURB_CYCLIC) { | |||||
| bezt = &nu->bezt[0]; | |||||
| a = 0; | |||||
| point_final = nu->pntsu; | |||||
| } | |||||
| else { | |||||
| bezt = &nu->bezt[1]; | |||||
| a = 1; | |||||
| point_final = nu->pntsu - 1; | |||||
| } | |||||
| /* for all the curve points */ | |||||
| for (; a < point_final; a++, bezt++) { | |||||
| /* respect selection */ | |||||
| if (bezt->f2 & SELECT) { | if (bezt->f2 & SELECT) { | ||||
Not Done Inline Actionsagain, just remove. campbellbarton: again, just remove. | |||||
| /* respect cyclic in getting the previous/next points' indices */ | |||||
| if (nu->flagu & CU_NURB_CYCLIC) { | |||||
| ind_prev = (a - 1 + nu->pntsu) % nu->pntsu; | |||||
| ind_next = (a + 1 + nu->pntsu) % nu->pntsu; | |||||
| } | |||||
| else { | |||||
| ind_prev = a - 1; | |||||
| ind_next = a + 1; | |||||
| } | |||||
| /* iterate over 3 dimensions */ | |||||
| for (i = 0; i < 3; i++) { | for (i = 0; i < 3; i++) { | ||||
| /* get single dimension pos of the mid handle */ | |||||
| val = bezt->vec[1][i]; | val = bezt->vec[1][i]; | ||||
| newval = ((beztOrig + (a - 1))->vec[1][i] * 0.5f) + ((beztOrig + (a + 1))->vec[1][i] * 0.5f); | /* get the weights of the previous/next mid handles and calc offset */ | ||||
| newval = ((beztOrig + (ind_prev))->vec[1][i] * 0.5f) + ((beztOrig + (ind_next))->vec[1][i] * 0.5f); | |||||
Not Done Inline Actions
campbellbarton: - No need to set these for every x/y/z axis.
- Theres no check for cyclic. | |||||
| offset = (val * ((1.0f / 6.0f) * 5.0f)) + (newval * (1.0f / 6.0f)) - val; | offset = (val * ((1.0f / 6.0f) * 5.0f)) + (newval * (1.0f / 6.0f)) - val; | ||||
| /* offset handles */ | /* offset midpoint and 2 handles */ | ||||
| bezt->vec[1][i] += offset; | bezt->vec[1][i] += offset; | ||||
| bezt->vec[0][i] += offset; | bezt->vec[0][i] += offset; | ||||
| bezt->vec[2][i] += offset; | bezt->vec[2][i] += offset; | ||||
| Context not available. | |||||
| else if (nu->bp) { | else if (nu->bp) { | ||||
| bpOrig = MEM_dupallocN(nu->bp); | bpOrig = MEM_dupallocN(nu->bp); | ||||
| /* Same as above, keep these the same! */ | /* Same as above, keep these the same! */ | ||||
| for (bp = &nu->bp[1], a = 1; a < nu->pntsu - 1; a++, bp++) { | |||||
| if (nu->flagu & CU_NURB_CYCLIC) { | |||||
| bp = &nu->bp[0]; | |||||
| a = 0; | |||||
| point_final = nu->pntsu; | |||||
| } | |||||
| else { | |||||
| bp = &nu->bp[1]; | |||||
| a = 1; | |||||
| point_final = nu->pntsu - 1; | |||||
| } | |||||
| for (; a < point_final; a++, bp++) { | |||||
walidUnsubmitted Not Done Inline Actionswe could be a bit cryptic and make it for(bp = &nu->bp[bias], a = bias; a < nu->pntsu - bias; a++, bp++) should you make it cryptic, or leave it very simple like that? walid: we could be a bit cryptic and make it for(bp = &nu->bp[bias], a = bias; a < nu->pntsu - bias… | |||||
| if (bp->f1 & SELECT) { | if (bp->f1 & SELECT) { | ||||
| /* respect cyclic in getting the previous/next points' indices */ | |||||
| if (nu->flagu & CU_NURB_CYCLIC) { | |||||
| ind_prev = (a - 1 + nu->pntsu) % nu->pntsu; | |||||
| ind_next = (a + 1 + nu->pntsu) % nu->pntsu; | |||||
| } | |||||
| else { | |||||
| ind_prev = a - 1; | |||||
| ind_next = a + 1; | |||||
| } | |||||
| for (i = 0; i < 3; i++) { | for (i = 0; i < 3; i++) { | ||||
| val = bp->vec[i]; | val = bp->vec[i]; | ||||
| newval = ((bpOrig + (a - 1))->vec[i] * 0.5f) + ((bpOrig + (a + 1))->vec[i] * 0.5f); | newval = ((bpOrig + (ind_prev))->vec[i] * 0.5f) + ((bpOrig + (ind_next))->vec[i] * 0.5f); | ||||
| offset = (val * ((1.0f / 6.0f) * 5.0f)) + (newval * (1.0f / 6.0f)) - val; | offset = (val * ((1.0f / 6.0f) * 5.0f)) + (newval * (1.0f / 6.0f)) - val; | ||||
| bp->vec[i] += offset; | bp->vec[i] += offset; | ||||
| Context not available. | |||||
Dont think this is needed - just BLI_assert(factor >= 0.0f && factor <= 1.0f)