Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-01-02 23:44:46 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-01-02 23:44:46 +0400
commit202bb321343a5545d0d31d195f64b487d4c40c54 (patch)
tree6cb3d0f1b0a29a05b1c17214a4db08bfb499d317 /source/blender/editors/curve
parent9b7f30d6b0694e6a5bef34333a27f53fb86e47ea (diff)
Fix T37056: Making segment flips curves it's not needed
Made the system around splines order a bit smarter, so crating a segment between two splines wouldn't switch direction if splines are selected in a way that they're "co-linear". It is possible to make things even smarter using active point and so, but that i'd consider a TODO.
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r--source/blender/editors/curve/editcurve.c90
1 files changed, 52 insertions, 38 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index bc97515f055..6664433e952 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4151,67 +4151,81 @@ static int make_segment_exec(bContext *C, wmOperator *op)
if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic */
if (nu->type == CU_BEZIER) {
- if (nu1 == NULL) {
- if (BEZSELECTED_HIDDENHANDLES(cu, nu->bezt)) {
- nu1 = nu;
+ if (BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu - 1]))) {
+ /* Last point is selected, preferred for nu2 */
+ if (nu2 == NULL) {
+ nu2 = nu;
}
- else {
- if (BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu - 1]))) {
- nu1 = nu;
- BKE_nurb_direction_switch(nu);
- keyData_switchDirectionNurb(cu, nu);
+ else if (nu1 == NULL) {
+ nu1 = nu;
+
+ /* Just in case both of first/last CV are selected check
+ * whether we really need to switch the direction.
+ */
+ if (!BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt)) {
+ BKE_nurb_direction_switch(nu1);
+ keyData_switchDirectionNurb(cu, nu1);
}
}
}
- else if (nu2 == NULL) {
- if (BEZSELECTED_HIDDENHANDLES(cu, nu->bezt)) {
- nu2 = nu;
- BKE_nurb_direction_switch(nu);
- keyData_switchDirectionNurb(cu, nu);
+ else if (BEZSELECTED_HIDDENHANDLES(cu, nu->bezt)) {
+ /* First point is selected, preferred for nu1 */
+ if (nu1 == NULL) {
+ nu1 = nu;
}
- else {
- if (BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu - 1]))) {
- nu2 = nu;
+ else if (nu2 == NULL) {
+ nu2 = nu;
+
+ /* Just in case both of first/last CV are selected check
+ * whether we really need to switch the direction.
+ */
+ if (!BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu2->pntsu - 1]))) {
+ BKE_nurb_direction_switch(nu2);
+ keyData_switchDirectionNurb(cu, nu2);
}
}
}
- else {
- break;
- }
}
else if (nu->pntsv == 1) {
+ /* Same logic as above: if first point is selected spline is
+ * preferred for nu1, if last point is selected spline is
+ * preferred for u2u.
+ */
+
bp = nu->bp;
- if (nu1 == NULL) {
- if (bp->f1 & SELECT) {
- nu1 = nu;
+ if (bp[nu->pntsu - 1].f1 & SELECT) {
+ if (nu2 == NULL) {
+ nu2 = nu;
}
- else {
- bp = bp + (nu->pntsu - 1);
- if (bp->f1 & SELECT) {
- nu1 = nu;
+ else if (nu1 == NULL) {
+ nu1 = nu;
+
+ if ((bp->f1 & SELECT) == 0) {
BKE_nurb_direction_switch(nu);
keyData_switchDirectionNurb(cu, nu);
}
}
}
- else if (nu2 == NULL) {
- if (bp->f1 & SELECT) {
- nu2 = nu;
- BKE_nurb_direction_switch(nu);
- keyData_switchDirectionNurb(cu, nu);
+ else if (bp->f1 & SELECT) {
+ if (nu1 == NULL) {
+ nu1 = nu;
}
- else {
- bp = bp + (nu->pntsu - 1);
- if (bp->f1 & SELECT) {
- nu2 = nu;
+ else if (nu2 == NULL) {
+ nu2 = nu;
+
+ if ((bp[nu->pntsu - 1].f1 & SELECT) == 0) {
+ BKE_nurb_direction_switch(nu);
+ keyData_switchDirectionNurb(cu, nu);
}
}
}
- else {
- break;
- }
}
}
+
+ if (nu1 && nu2) {
+ /* Got second spline, no need to loop over rest of the splines. */
+ break;
+ }
}
if ((nu1 && nu2) && (nu1 != nu2)) {