72 if ((bp->
hide == 0) || (hidden == 1)) {
106 for (
i = nu->
pntsu, bezt = nu->
bezt;
i--; bezt++) {
133 for (
i = nu->
pntsu, bezt = nu->
bezt;
i--; bezt++) {
155 bool changed =
false;
159 for (
i = nu->
pntsu, bezt = nu->
bezt;
i--; bezt++) {
160 if (bezt->
hide == 0) {
184 bool changed =
false;
193 bool changed =
false;
197 for (
i = nu->
pntsu, bezt = nu->
bezt;
i--; bezt++) {
240 bool changed =
false;
249 bool changed_multi =
false;
250 for (
Base *base : bases) {
251 Object *obedit = base->object;
256 return changed_multi;
273 bool changed =
false;
277 bool swap_handles =
false;
289 if (bezt->
hide == 0) {
313 a = nu->pntsu * nu->pntsv;
334 const bool selstatus)
339 bool lastsel =
false;
351 bezt = &nu->bezt[a - 1];
357 if ((lastsel ==
false) && (bezt->
hide == 0) &&
358 ((bezt->
f2 &
SELECT) || (selstatus ==
false)))
361 if (!(bezt->
f2 &
SELECT) || (selstatus ==
false)) {
377 a = nu->pntsu * nu->pntsv;
386 if ((lastsel ==
false) && (bp->
hide == 0) && ((bp->
f1 &
SELECT) || (selstatus ==
false))) {
388 if (!(bp->
f1 &
SELECT) || (selstatus ==
false)) {
427 if (obedit ==
nullptr) {
439 if (selfirst ==
LAST) {
440 bezt = &nu->bezt[a - 1];
461 a = nu->pntsu * nu->pntsv;
464 if (selfirst ==
LAST) {
497 for (
Object *obedit : objects) {
509 ot->name =
"(De)select First";
510 ot->idname =
"CURVE_OT_de_select_first";
511 ot->description =
"(De)select first of visible part of each NURBS";
528 for (
Object *obedit : objects) {
541 ot->name =
"(De)select Last";
542 ot->idname =
"CURVE_OT_de_select_last";
543 ot->description =
"(De)select last of visible part of each NURBS";
570 for (
Object *obedit : objects) {
571 Curve *cu =
static_cast<Curve *
>(obedit->data);
580 for (
Object *obedit : objects) {
581 Curve *cu =
static_cast<Curve *
>(obedit->data);
582 bool changed =
false;
610 ot->name =
"(De)select All";
611 ot->idname =
"CURVE_OT_select_all";
612 ot->description =
"(De)select all control points";
639 for (
Object *obedit : objects) {
640 Curve *cu =
static_cast<Curve *
>(obedit->data);
643 bool changed =
false;
670 ot->name =
"Select Linked All";
671 ot->idname =
"CURVE_OT_select_linked";
672 ot->description =
"Select all control points linked to the current selection";
701 Base *basact =
nullptr;
743 ot->name =
"Select Linked";
744 ot->idname =
"CURVE_OT_select_linked_pick";
745 ot->description =
"Select all control points linked to already selected ones";
759 "Deselect linked control points rather than selecting them");
773 static BPoint *last =
nullptr;
774 static int direction = 0;
777 int u = 0,
v = 0, a,
b;
784 direction = 1 - direction;
792 for (a = 0; a < nu->
pntsv; a++) {
793 for (
b = 0;
b < nu->
pntsu;
b++, bp++) {
816 ot->name =
"Select Control Point Row";
817 ot->idname =
"CURVE_OT_select_row";
819 "Select a row of control points including active one. "
820 "Successive use on the same point switches between U/V directions";
843 for (
Object *obedit : objects) {
857 ot->name =
"Select Next";
858 ot->idname =
"CURVE_OT_select_next";
859 ot->description =
"Select control points following already selected ones along the curves";
882 for (
Object *obedit : objects) {
896 ot->name =
"Select Previous";
897 ot->idname =
"CURVE_OT_select_previous";
898 ot->description =
"Select control points preceding already selected ones along the curves";
928 a = nu->pntsu * nu->pntsv;
934 if (a % nu->pntsu != 0) {
942 if (a - nu->pntsu > 0) {
944 tempbp = bp + nu->pntsu;
955 if (a + nu->pntsu < nu->pntsu * nu->pntsv) {
956 tempbp = bp - nu->pntsu;
963 if (a % nu->pntsu != 1) {
995 for (
Object *obedit : objects) {
1006 ot->name =
"Select More";
1007 ot->idname =
"CURVE_OT_select_more";
1008 ot->description =
"Select control points at the boundary of each selection region";
1032 bool lastsel =
false;
1037 a = nu->pntsu * nu->pntsv;
1046 if ((a + 1) % nu->pntsu == 0) {
1057 if ((a + 1) % nu->pntsu == 1) {
1068 if (a + 1 > nu->pntsu * nu->pntsv - nu->pntsu) {
1081 if (a < nu->pntsu) {
1116 sel = (lastsel == 1);
1120 if (a == nu->pntsu - 1) {
1158 a = nu->pntsu * nu->pntsv;
1161 if ((lastsel ==
false) && (bp->
hide == 0) && (bp->
f1 &
SELECT)) {
1165 if (a == nu->pntsu * nu->pntsv - 1) {
1212 for (
Object *obedit : objects) {
1223 ot->name =
"Select Less";
1224 ot->idname =
"CURVE_OT_select_less";
1225 ot->description =
"Deselect control points at the boundary of each selection region";
1252 for (
const int ob_index : objects.
index_range()) {
1253 Object *obedit = objects[ob_index];
1255 int seed_iter =
seed;
1275 int a = nu->pntsu * nu->pntsv;
1287 const int count_select = totvert * randfac;
1288 for (
int i = 0;
i < count_select;
i++) {
1310 int a = nu->pntsu * nu->pntsv;
1337 ot->name =
"Select Random";
1338 ot->idname =
"CURVE_OT_select_random";
1339 ot->description =
"Randomly select some control points";
1362 start = bezt - nu->
bezt;
1364 bezt = &nu->
bezt[a - 1];
1367 const int depth =
abs(start - a);
1378 int a, startrow, startpnt;
1381 startrow = (bp - nu->
bp) / nu->
pntsu;
1382 startpnt = (bp - nu->
bp) % nu->
pntsu;
1385 bp = &nu->
bp[a - 1];
1386 row = nu->
pntsv - 1;
1387 pnt = nu->
pntsu - 1;
1390 const int depth =
abs(pnt - startpnt) +
abs(row - startrow);
1397 pnt = nu->
pntsu - 1;
1408 void *vert =
nullptr;
1430 bool changed =
false;
1437 for (
Object *obedit : objects) {
1438 Curve *cu =
static_cast<Curve *
>(obedit->data);
1467 ot->name =
"Checker Deselect";
1468 ot->description =
"Deselect every Nth point starting from the active one";
1469 ot->idname =
"CURVE_OT_select_nth";
1492 {0,
nullptr, 0,
nullptr,
nullptr},
1507 {0,
nullptr, 0,
nullptr,
nullptr},
1517 copy_m3_m4(rsmat, ob->object_to_world().ptr());
1526 copy_m3_m4(rsmat, ob->object_to_world().ptr());
1532 Object *ob,
Nurb *nu,
const int type, KDTree_1d *tree_1d, KDTree_3d *tree_3d)
1534 float tree_entry[3] = {0.0f, 0.0f, 0.0f};
1541 for (
i = nu->
pntsu, bezt = nu->
bezt;
i--; bezt++) {
1546 float radius_ref = bezt->
radius;
1547 tree_entry[0] = radius_ref;
1551 float weight_ref = bezt->
weight;
1552 tree_entry[0] = weight_ref;
1561 BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
1564 BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
1578 float radius_ref = bp->
radius;
1579 tree_entry[0] = radius_ref;
1583 float weight_ref = bp->
weight;
1584 tree_entry[0] = weight_ref;
1593 BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
1596 BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
1606 const KDTree_1d *tree_1d,
1607 const KDTree_3d *tree_3d,
1611 const float thresh_cos =
cosf(thresh *
float(
M_PI_2));
1612 bool changed =
false;
1618 for (
i = nu->
pntsu, bezt = nu->
bezt;
i--; bezt++) {
1624 float radius_ref = bezt->
radius;
1626 tree_1d, radius_ref, thresh,
eSimilarCmp(compare)))
1633 float weight_ref = bezt->
weight;
1635 tree_1d, weight_ref, thresh,
eSimilarCmp(compare)))
1644 KDTreeNearest_3d nearest;
1645 if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
1647 float delta = thresh_cos -
fabsf(
cosf(orient));
1673 float radius_ref = bp->
radius;
1675 tree_1d, radius_ref, thresh,
eSimilarCmp(compare)))
1682 float weight_ref = bp->
weight;
1684 tree_1d, weight_ref, thresh,
eSimilarCmp(compare)))
1693 KDTreeNearest_3d nearest;
1694 if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
1696 float delta =
fabsf(
cosf(orient)) - thresh_cos;
1725 int tot_nurbs_selected_all = 0;
1729 for (
Object *obedit : objects) {
1730 Curve *cu =
static_cast<Curve *
>(obedit->data);
1734 if (tot_nurbs_selected_all == 0) {
1739 KDTree_1d *tree_1d =
nullptr;
1740 KDTree_3d *tree_3d =
nullptr;
1746 tree_1d = BLI_kdtree_1d_new(tot_nurbs_selected_all);
1749 tree_3d = BLI_kdtree_3d_new(tot_nurbs_selected_all);
1754 for (
Object *obedit : objects) {
1755 Curve *cu =
static_cast<Curve *
>(obedit->data);
1764 type_ref |= nu->type;
1776 if (tree_1d !=
nullptr) {
1777 BLI_kdtree_1d_deduplicate(tree_1d);
1778 BLI_kdtree_1d_balance(tree_1d);
1780 if (tree_3d !=
nullptr) {
1781 BLI_kdtree_3d_deduplicate(tree_3d);
1782 BLI_kdtree_3d_balance(tree_3d);
1786 for (
Object *obedit : objects) {
1787 Curve *cu =
static_cast<Curve *
>(obedit->data);
1789 bool changed =
false;
1794 if (nu->type & type_ref) {
1803 obedit, nu, optype, tree_1d, tree_3d, thresh, compare);
1814 if (tree_1d !=
nullptr) {
1815 BLI_kdtree_1d_free(tree_1d);
1817 if (tree_3d !=
nullptr) {
1818 BLI_kdtree_3d_free(tree_3d);
1826 ot->name =
"Select Similar";
1827 ot->idname =
"CURVE_OT_select_similar";
1828 ot->description =
"Select similar curve points by property type";
1853 const float *a_fl, *b_fl;
1860 a_fl = nu->
bp[a].
vec;
1869 const int u = nu->
pntsu;
1876 i = (i_prev + 1) % u;
1881 if (
i == vert_dst) {
1891 const int u = nu->
pntsu;
1894 if (vert_src > vert_dst) {
1895 std::swap(vert_src, vert_dst);
1902 std::swap(vert_src, vert_dst);
1915 if (
i == vert_dst) {
1924 int totu = nu->
pntsu;
1925 int totv = nu->
pntsv;
1926 int vert_num = totu * totv;
1930 int vert, vert_prev;
1936 for (
int i = 0;
i < vert_num;
i++) {
1938 data[
i].vert_prev = -1;
1945 int vert_curr =
data[vert_src].vert;
1947 data[vert_src].cost = 0.0f;
1948 data[vert_src].vert_prev = vert_src;
1952 if (vert_curr == vert_dst) {
1961 for (
int axis = 0; axis != 2; axis += 1) {
1962 int uv_other[2] = {u,
v};
1965 uv_other[axis] +=
sign;
1968 if (vert_other != -1) {
1969 const float dist =
data[vert_curr].cost +
1972 if (
data[vert_other].cost > dist) {
1973 data[vert_other].cost = dist;
1974 if (
data[vert_other].vert_prev == -1) {
1977 data[vert_other].vert_prev = vert_curr;
1986 if (vert_curr == vert_dst) {
1988 while (vert_curr != vert_src &&
i++ < vert_num) {
1995 vert_curr =
data[vert_curr].vert_prev;
2012 Base *basact =
nullptr;
2032 if (nu_src != nu_dst) {
2037 vert_dst_p = bezt_dst ? (
void *)bezt_dst : (
void *)bp_dst;
2039 if (vert_src == vert_dst) {
2065 ot->name =
"Pick Shortest Path";
2066 ot->idname =
"CURVE_OT_shortest_path_pick";
2067 ot->description =
"Select shortest path between two selections";
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
void BKE_nurb_index_to_uv(Nurb *nu, int index, int *r_u, int *r_v)
Nurb * BKE_curve_nurb_active_get(Curve *cu)
void BKE_curve_nurb_vert_active_set(Curve *cu, const Nurb *nu, const void *vert)
int BKE_nurb_index_from_uv(Nurb *nu, int u, int v)
void BKE_nurb_bezt_calc_normal(Nurb *nu, BezTriple *bezt, float r_normal[3])
void BKE_curve_nurb_vert_active_validate(Curve *cu)
bool BKE_curve_nurb_vert_active_get(Curve *cu, Nurb **r_nu, void **r_vert)
void BKE_nurbList_flag_set(ListBase *editnurb, uint8_t flag, bool set)
void BKE_nurb_bpoint_calc_normal(Nurb *nu, BPoint *bp, float r_normal[3])
int BKE_curve_nurb_vert_index_get(const Nurb *nu, const void *vert)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
blender::Vector< Base * > BKE_view_layer_array_from_bases_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
blender::Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_SET(_bitmap, _index, _set)
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
A min-heap / priority queue ADT.
HeapSimple * BLI_heapsimple_new(void) ATTR_WARN_UNUSED_RESULT
void BLI_heapsimple_free(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1)
void * BLI_heapsimple_pop_min(HeapSimple *heap) ATTR_NONNULL(1)
bool BLI_heapsimple_is_empty(const HeapSimple *heap) ATTR_NONNULL(1)
void BLI_heapsimple_insert(HeapSimple *heap, float value, void *ptr) ATTR_NONNULL(1)
A KD-tree for nearest neighbor search.
#define LISTBASE_FOREACH(type, var, list)
void mul_m3_v3(const float M[3][3], float r[3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float n[3])
void BLI_bitmap_randomize(unsigned int *bitmap, unsigned int bits_num, unsigned int seed) ATTR_NONNULL(1)
void DEG_id_tag_update(ID *id, unsigned int flags)
#define BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)
#define BEZT_SEL_ALL(bezt)
#define BEZT_ISSEL_ANY(bezt)
#define BEZT_DESEL_ALL(bezt)
#define BEZT_ISSEL_ALL(bezt)
Object is a sort of wrapper for general info.
bool ED_operator_editsurfcurve_region_view3d(bContext *C)
bool ED_operator_editsurfcurve(bContext *C)
bool ED_operator_editcurve(bContext *C)
bool ED_operator_editsurf(bContext *C)
bool ED_select_similar_compare_float(float delta, float thresh, eSimilarCmp compare)
bool ED_select_similar_compare_float_tree(const KDTree_1d *tree, float length, float thresh, eSimilarCmp compare)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
void view3d_operator_needs_gpu(const bContext *C)
void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact)
Read Guarded memory(de)allocation.
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
static unsigned long seed
IndexRange index_range() const
bool ED_curve_pick_vert(ViewContext *vc, short sel, Nurb **r_nurb, BezTriple **r_bezt, BPoint **r_bp, short *r_handle, Base **r_base)
ListBase * object_editcurve_get(Object *ob)
void CURVE_OT_select_random(wmOperatorType *ot)
bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden)
static void select_nth_bezt(Nurb *nu, BezTriple *bezt, const CheckerIntervalParams *params)
bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Types hidden)
bool ED_curve_select_check(const View3D *v3d, const EditNurb *editnurb)
bool ED_curve_deselect_all_multi_ex(Span< Base * > bases)
bool ED_curve_nurb_select_check(const View3D *v3d, const Nurb *nu)
void CURVE_OT_select_less(wmOperatorType *ot)
static bool ed_curve_select_nth(Curve *cu, const CheckerIntervalParams *params)
void CURVE_OT_select_similar(wmOperatorType *ot)
static void curve_select_more(Object *obedit)
static void curve_nurb_selected_type_get(Object *ob, Nurb *nu, const int type, KDTree_1d *tree_1d, KDTree_3d *tree_3d)
bool ED_curve_select_all(EditNurb *editnurb)
void CURVE_OT_select_previous(wmOperatorType *ot)
static const EnumPropertyItem curve_prop_similar_types[]
static void nurb_bezt_direction_worldspace_get(Object *ob, Nurb *nu, BezTriple *bezt, float r_dir[3])
static const EnumPropertyItem curve_prop_similar_compare_types[]
void CURVE_OT_shortest_path_pick(wmOperatorType *ot)
bool ED_curve_deselect_all_multi(bContext *C)
void CURVE_OT_select_linked(wmOperatorType *ot)
bool ED_curve_nurb_deselect_all(const Nurb *nu)
static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap, bool selstatus)
static wmOperatorStatus curve_select_similar_exec(bContext *C, wmOperator *op)
static void select_adjacent_cp(ListBase *editnurb, short next, const bool cont, const bool selstatus)
bool ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
static void curve_select_less(Object *obedit)
static wmOperatorStatus select_linked_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void select_nth_bp(Nurb *nu, BPoint *bp, const CheckerIntervalParams *params)
void CURVE_OT_select_next(wmOperatorType *ot)
static wmOperatorStatus de_select_last_exec(bContext *C, wmOperator *)
static wmOperatorStatus select_linked_exec(bContext *C, wmOperator *)
int ED_curve_select_count(const View3D *v3d, const EditNurb *editnurb)
static bool curve_nurb_select_similar_type(Object *ob, Nurb *nu, const int type, const KDTree_1d *tree_1d, const KDTree_3d *tree_3d, const float thresh, const int compare)
static bool swap_selection_bpoint(BPoint *bp)
static wmOperatorStatus curve_select_more_exec(bContext *C, wmOperator *)
bool ED_curve_nurb_select_all(const Nurb *nu)
static wmOperatorStatus select_nth_exec(bContext *C, wmOperator *op)
static wmOperatorStatus curve_select_random_exec(bContext *C, wmOperator *op)
void CURVE_OT_select_all(wmOperatorType *ot)
static wmOperatorStatus de_select_first_exec(bContext *C, wmOperator *)
bool ED_curve_deselect_all(EditNurb *editnurb)
static bool swap_selection_beztriple(BezTriple *bezt)
void CURVE_OT_select_nth(wmOperatorType *ot)
static wmOperatorStatus select_row_exec(bContext *C, wmOperator *)
static wmOperatorStatus select_next_exec(bContext *C, wmOperator *)
static wmOperatorStatus select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void CURVE_OT_de_select_first(wmOperatorType *ot)
void CURVE_OT_select_more(wmOperatorType *ot)
static wmOperatorStatus select_previous_exec(bContext *C, wmOperator *)
static void nurb_bpoint_direction_worldspace_get(Object *ob, Nurb *nu, BPoint *bp, float r_dir[3])
static wmOperatorStatus de_select_all_exec(bContext *C, wmOperator *op)
void CURVE_OT_select_row(wmOperatorType *ot)
int ED_curve_nurb_select_count(const View3D *v3d, const Nurb *nu)
void CURVE_OT_de_select_last(wmOperatorType *ot)
static float curve_calc_dist_span(Nurb *nu, int vert_src, int vert_dst)
void CURVE_OT_select_linked_pick(wmOperatorType *ot)
static wmOperatorStatus curve_select_less_exec(bContext *C, wmOperator *)
static void curve_select_shortest_path_curve(Nurb *nu, int vert_src, int vert_dst)
static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst)
static wmOperatorStatus edcu_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static float curve_calc_dist_pair(const Nurb *nu, int a, int b)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
void base_activate(bContext *C, Base *base)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
struct ReportList * reports
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operator_properties_checker_interval_from_op(wmOperator *op, CheckerIntervalParams *op_params)
int WM_operator_properties_select_random_seed_increment_get(wmOperator *op)
void WM_operator_properties_select_random(wmOperatorType *ot)
void WM_operator_properties_select_all(wmOperatorType *ot)
void WM_operator_properties_checker_interval(wmOperatorType *ot, bool nth_can_disable)
bool WM_operator_properties_checker_interval_test(const CheckerIntervalParams *op_params, int depth)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)