[Bf-blender-cvs] [5846dad216d] soc-2021-curves: Exposed 2 functions in editcurve.c and used in curve pen
dilithjay
noreply at git.blender.org
Mon Jun 21 16:26:44 CEST 2021
Commit: 5846dad216d15049d8c4f829229c73c80035e266
Author: dilithjay
Date: Mon Jun 21 12:14:44 2021 +0530
Branches: soc-2021-curves
https://developer.blender.org/rB5846dad216d15049d8c4f829229c73c80035e266
Exposed 2 functions in editcurve.c and used in curve pen
===================================================================
M source/blender/editors/curve/curve_intern.h
M source/blender/editors/curve/editcurve.c
M source/blender/editors/curve/editcurve_pen.c
===================================================================
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index ebf91e145e6..659510516a1 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -141,6 +141,10 @@ void CURVE_OT_match_texture_space(struct wmOperatorType *ot);
struct GHash *ED_curve_keyindex_hash_duplicate(struct GHash *keyindex);
void ED_curve_keyindex_update_nurb(struct EditNurb *editnurb, struct Nurb *nu, struct Nurb *newnu);
+/* exported for editcurve_pen.c */
+bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d);
+int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, View3D *v3d, const float location_init[3]);
+
/* helper functions */
void ed_editnurb_translate_flag(struct ListBase *editnurb,
uint8_t flag,
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 535ccaa06fd..e6c562dc210 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -5109,7 +5109,7 @@ void CURVE_OT_spin(wmOperatorType *ot)
/** \name Extrude Vertex Operator
* \{ */
-static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
+bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
{
bool changed = false;
@@ -5358,10 +5358,7 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
/** \name Add Vertex Operator
* \{ */
-static int ed_editcurve_addvert(Curve *cu,
- EditNurb *editnurb,
- View3D *v3d,
- const float location_init[3])
+int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, View3D *v3d, const float location_init[3])
{
float center[3];
float temp[3];
diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c
index 8eae7818c0b..f587f7d249a 100644
--- a/source/blender/editors/curve/editcurve_pen.c
+++ b/source/blender/editors/curve/editcurve_pen.c
@@ -68,396 +68,6 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
-static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
-{
- bool changed = false;
-
- Nurb *cu_actnu;
- union {
- BezTriple *bezt;
- BPoint *bp;
- void *p;
- } cu_actvert;
-
- if (BLI_listbase_is_empty(&editnurb->nurbs)) {
- return changed;
- }
-
- BKE_curve_nurb_vert_active_get(cu, &cu_actnu, &cu_actvert.p);
- int act_offset = 0;
-
- LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
- BLI_assert(nu->pntsu > 0);
- int i;
- int pnt_len = nu->pntsu;
- int new_points = 0;
- int offset = 0;
- bool is_prev_selected = false;
- bool duplic_first = false;
- bool duplic_last = false;
- if (nu->type == CU_BEZIER) {
- BezTriple *bezt, *bezt_prev = NULL;
- BezTriple bezt_stack;
- bool is_cyclic = false;
- if (pnt_len == 1) {
- /* Single point extrusion.
- * Keep `is_prev_selected` false to force extrude. */
- bezt_prev = &nu->bezt[0];
- }
- else if (nu->flagu & CU_NURB_CYCLIC) {
- is_cyclic = true;
- bezt_prev = &nu->bezt[pnt_len - 1];
- is_prev_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt_prev);
- }
- else {
- duplic_first = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, &nu->bezt[0]) &&
- BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, &nu->bezt[1]);
-
- duplic_last = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, &nu->bezt[pnt_len - 2]) &&
- BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, &nu->bezt[pnt_len - 1]);
-
- if (duplic_first) {
- bezt_stack = nu->bezt[0];
- BEZT_DESEL_ALL(&bezt_stack);
- bezt_prev = &bezt_stack;
- }
- if (duplic_last) {
- new_points++;
- }
- }
- i = pnt_len;
- for (bezt = &nu->bezt[0]; i--; bezt++) {
- bool is_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt);
- if (bezt_prev && is_prev_selected != is_selected) {
- new_points++;
- }
- if (bezt == cu_actvert.bezt) {
- act_offset = new_points;
- }
- bezt_prev = bezt;
- is_prev_selected = is_selected;
- }
-
- if (new_points) {
- if (pnt_len == 1) {
- /* Single point extrusion.
- * Set `is_prev_selected` as false to force extrude. */
- BLI_assert(bezt_prev == &nu->bezt[0]);
- is_prev_selected = false;
- }
- else if (is_cyclic) {
- BLI_assert(bezt_prev == &nu->bezt[pnt_len - 1]);
- BLI_assert(is_prev_selected == BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt_prev));
- }
- else if (duplic_first) {
- bezt_prev = &bezt_stack;
- is_prev_selected = false;
- }
- else {
- bezt_prev = NULL;
- }
- BezTriple *bezt_src, *bezt_dst, *bezt_src_iter, *bezt_dst_iter;
- const int new_len = pnt_len + new_points;
-
- bezt_src = nu->bezt;
- bezt_dst = MEM_mallocN(new_len * sizeof(BezTriple), __func__);
- bezt_src_iter = &bezt_src[0];
- bezt_dst_iter = &bezt_dst[0];
- i = 0;
- for (bezt = &nu->bezt[0]; i < pnt_len; i++, bezt++) {
- bool is_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt);
- /* While this gets de-selected, selecting here ensures newly created verts are selected.
- * without this, the vertices are copied but only the handles are transformed.
- * which seems buggy from a user perspective. */
- if (is_selected) {
- bezt->f2 |= SELECT;
- }
- if (bezt_prev && is_prev_selected != is_selected) {
- int count = i - offset + 1;
- if (is_prev_selected) {
- ED_curve_beztcpy(editnurb, bezt_dst_iter, bezt_src_iter, count - 1);
- ED_curve_beztcpy(editnurb, &bezt_dst_iter[count - 1], bezt_prev, 1);
- }
- else {
- ED_curve_beztcpy(editnurb, bezt_dst_iter, bezt_src_iter, count);
- }
- ED_curve_beztcpy(editnurb, &bezt_dst_iter[count], bezt, 1);
- BEZT_DESEL_ALL(&bezt_dst_iter[count - 1]);
-
- bezt_dst_iter += count + 1;
- bezt_src_iter += count;
- offset = i + 1;
- }
- bezt_prev = bezt;
- is_prev_selected = is_selected;
- }
-
- int remain = pnt_len - offset;
- if (remain) {
- ED_curve_beztcpy(editnurb, bezt_dst_iter, bezt_src_iter, remain);
- }
-
- if (duplic_last) {
- ED_curve_beztcpy(editnurb, &bezt_dst[new_len - 1], &bezt_src[pnt_len - 1], 1);
- BEZT_DESEL_ALL(&bezt_dst[new_len - 1]);
- }
-
- MEM_freeN(nu->bezt);
- nu->bezt = bezt_dst;
- nu->pntsu += new_points;
- changed = true;
- }
- }
- else {
- BPoint *bp, *bp_prev = NULL;
- BPoint bp_stack;
- if (pnt_len == 1) {
- /* Single point extrusion.
- * Reference a `prev_bp` to force extrude. */
- bp_prev = &nu->bp[0];
- }
- else {
- duplic_first = (nu->bp[0].f1 & SELECT) && (nu->bp[1].f1 & SELECT);
- duplic_last = (nu->bp[pnt_len - 2].f1 & SELECT) && (nu->bp[pnt_len - 1].f1 & SELECT);
- if (duplic_first) {
- bp_stack = nu->bp[0];
- bp_stack.f1 &= ~SELECT;
- bp_prev = &bp_stack;
- }
- if (duplic_last) {
- new_points++;
- }
- }
-
- i = pnt_len;
- for (bp = &nu->bp[0]; i--; bp++) {
- bool is_selected = (bp->f1 & SELECT) != 0;
- if (bp_prev && is_prev_selected != is_selected) {
- new_points++;
- }
- if (bp == cu_actvert.bp) {
- act_offset = new_points;
- }
- bp_prev = bp;
- is_prev_selected = is_selected;
- }
-
- if (new_points) {
- BPoint *bp_src, *bp_dst, *bp_src_iter, *bp_dst_iter;
- const int new_len = pnt_len + new_points;
-
- is_prev_selected = false;
- if (pnt_len == 1) {
- /* Single point extrusion.
- * Keep `is_prev_selected` false to force extrude. */
- BLI_assert(bp_prev == &nu->bp[0]);
- }
- else if (duplic_first) {
- bp_prev = &bp_stack;
- is_prev_selected = false;
- }
- else {
- bp_prev = NULL;
- }
- bp_src = nu->bp;
- bp_dst = MEM_mallocN(new_len * sizeof(BPoint), __func__);
- bp_src_iter = &bp_src[0];
- bp_dst_iter = &bp_dst[0];
- i = 0;
- for (bp = &nu->bp[0]; i < pnt_len; i++, bp++) {
- bool is_selected = (bp->f1 & SELECT) != 0;
- if (bp_prev && is_prev_selected != is_selected) {
- int count = i - offset + 1;
- if (is_prev_selected) {
- ED_curve_bpcpy(editnurb, bp_dst_iter, bp_src_iter, count - 1);
- ED_curve_bpcpy(editnurb, &bp_dst_iter[count - 1], bp_prev, 1);
- }
- else {
- ED_curve_bpcpy(editnurb, bp_dst_iter, bp_src_iter, count);
- }
- ED_curve_bpcpy(editnurb, &bp_dst_iter[count], bp, 1);
- bp_dst_iter[count - 1].f1 &= ~SELECT;
-
- bp_dst_iter += count + 1;
- bp_src_iter += count;
- offset = i + 1;
- }
- bp_prev = bp;
- is_prev_selected = is_selected;
- }
-
- int remain = pnt_len - offset;
- if (remain) {
- ED_curve_bpcpy(editnurb, bp_dst_iter, bp_src_iter, remain);
- }
-
- if (duplic_last) {
- ED_curve_bpcpy(editnurb, &bp_dst[new_len - 1], &bp_src[pnt_len - 1], 1);
- bp_dst[new_len - 1].f1 &= ~SELECT;
- }
-
- MEM_freeN(nu->bp);
- nu->bp = bp_dst;
- nu->pntsu += new_points;
-
- BKE_nurb_knot_calc_u(nu);
- changed = true;
- }
- }
- }
-
- cu->actvert += act_offset;
-
- return changed;
-}
-
-static int ed_editcurve_addvert(bContext *C, const float location_init[3])
-{
- Object *obedit = CTX_data_edit_object(C);
- View3D *v3d = CTX_wm_view3d(C);
- Curve *cu = obedit->data;
- EditNurb *edi
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list