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:
authorAntonio Vazquez <blendergit@gmail.com>2020-05-26 11:37:47 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-05-26 11:37:47 +0300
commit49f59092e7c8c652df015bdfd27bae2480e51d01 (patch)
tree7360626291190beb7537370efc7a9a7d5af7203f /source/blender/blenkernel/intern
parent495a98d623648ca787ddb2c0dbaa08fe313f1adf (diff)
Curves: Implement Handles for selected points only
When editing a complex curve is very annoying to have all handles at a time. Also, this is a requirement for the current GSoC Edit Grease Pencil using curves. I have seen that this improvement can be used in any other area of blender, so I have decided to publish the option in the overlay panel.. Reviewed By: fclem, #user_interface, billreynish, Severin Differential Revision: https://developer.blender.org/D7754
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/curve.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 0798bc95797..e67cf8573f3 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -4485,7 +4485,7 @@ void BKE_nurbList_handles_recalculate(ListBase *editnurb, const bool calc_length
}
}
-void BKE_nurbList_flag_set(ListBase *editnurb, short flag)
+void BKE_nurbList_flag_set(ListBase *editnurb, short flag, bool set)
{
Nurb *nu;
BezTriple *bezt;
@@ -4497,7 +4497,16 @@ void BKE_nurbList_flag_set(ListBase *editnurb, short flag)
a = nu->pntsu;
bezt = nu->bezt;
while (a--) {
- bezt->f1 = bezt->f2 = bezt->f3 = flag;
+ if (set) {
+ bezt->f1 |= flag;
+ bezt->f2 |= flag;
+ bezt->f3 |= flag;
+ }
+ else {
+ bezt->f1 &= ~flag;
+ bezt->f2 &= ~flag;
+ bezt->f3 &= ~flag;
+ }
bezt++;
}
}
@@ -4505,13 +4514,47 @@ void BKE_nurbList_flag_set(ListBase *editnurb, short flag)
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
while (a--) {
- bp->f1 = flag;
+ SET_FLAG_FROM_TEST(bp->f1, set, flag);
bp++;
}
}
}
}
+/**
+ * Set \a flag for every point that already has \a from_flag set.
+ */
+bool BKE_nurbList_flag_set_from_flag(ListBase *editnurb, short from_flag, short flag)
+{
+ bool changed = false;
+
+ for (Nurb *nu = editnurb->first; nu; nu = nu->next) {
+ if (nu->type == CU_BEZIER) {
+ for (int i = 0; i < nu->pntsu; i++) {
+ BezTriple *bezt = &nu->bezt[i];
+ int old_f1 = bezt->f1, old_f2 = bezt->f2, old_f3 = bezt->f3;
+
+ SET_FLAG_FROM_TEST(bezt->f1, bezt->f1 & from_flag, flag);
+ SET_FLAG_FROM_TEST(bezt->f2, bezt->f2 & from_flag, flag);
+ SET_FLAG_FROM_TEST(bezt->f3, bezt->f3 & from_flag, flag);
+
+ changed |= (old_f1 != bezt->f1) || (old_f2 != bezt->f2) || (old_f3 != bezt->f3);
+ }
+ }
+ else {
+ for (int i = 0; i < nu->pntsu * nu->pntsv; i++) {
+ BPoint *bp = &nu->bp[i];
+ int old_f1 = bp->f1;
+
+ SET_FLAG_FROM_TEST(bp->f1, bp->f1 & from_flag, flag);
+ changed |= (old_f1 != bp->f1);
+ }
+ }
+ }
+
+ return changed;
+}
+
void BKE_nurb_direction_switch(Nurb *nu)
{
BezTriple *bezt1, *bezt2;