69#include "curve_fit_nd.h"
85 ListBaseT<Nurb> *newnurb,
118void printknots(
Object *obedit)
124 for (nu = editnurb->first; nu; nu = nu->next) {
128 for (a = 0; a <
num; a++) {
129 printf(
"knotu %d: %f\n", a, nu->knotsu[a]);
134 for (a = 0; a <
num; a++) {
135 printf(
"knotv %d: %f\n", a, nu->knotsv[a]);
150 void *cv,
int key_index,
int nu_index,
int pt_index,
int vertex_index)
167 Nurb *orignu = origBase->first();
171 int a, key_index = 0, nu_index = 0, pt_index = 0, vertex_index = 0;
177 auto *gh = MEM_new<CVKeyIndexMap>(
"editNurb keyIndex");
183 origbezt = orignu->
bezt;
191 *origbezt_cpy = *origbezt;
192 keyIndex =
init_cvKeyIndex(origbezt_cpy, key_index, nu_index, pt_index, vertex_index);
193 gh->add(bezt, keyIndex);
212 *origbp_cpy = *origbp;
213 keyIndex =
init_cvKeyIndex(origbp_cpy, key_index, nu_index, pt_index, vertex_index);
214 gh->add(bp, keyIndex);
224 orignu = orignu->
next;
271 return index->key_index;
322 for (
Nurb &nu : *nubase) {
332 if (editnurb->
keyindex ==
nullptr) {
337 for (i = 0; i < count; i++) {
352 reinterpret_cast<char *
>(bezt),
353 reinterpret_cast<char *
>(newbezt),
361 reinterpret_cast<char *
>(bp),
362 reinterpret_cast<char *
>(newbp),
401 bezt2 = bezt1 + (a - 1);
417 if (bezt1 != bezt2) {
432 if (nu->
pntsv == 1) {
437 while (bp1 != bp2 && a > 0) {
468 while (bp1 != bp2 && a > 0) {
496 ListBaseT<Nurb> *nubase = &editnurb->
nurbs;
501 fp =
static_cast<float *
>(currkey.
data);
503 for (
Nurb &nu : *nubase) {
511 *(fp + 9) = -*(fp + 9);
523 a = nu.pntsu * nu.pntsv;
527 *(fp + 3) = -*(fp + 3);
558 CVKeyIndexMap *gh = MEM_new<CVKeyIndexMap>(
"dupli_keyIndex gh");
561 for (
const auto &item : keyindex->
items()) {
562 const void *cv = item.key;
569 gh->
add(cv, newIndex);
577 memcpy(bezt, basebezt,
sizeof(
BezTriple));
578 memcpy(bezt->
vec, key,
sizeof(
float[9]));
585 memcpy(key, bezt->
vec,
sizeof(
float[9]));
596 for (
Nurb &nu : *nurb) {
606 float *startfp, *prevfp, *nextfp;
613 prevp = bezt + (a - 1);
659 a = nu.pntsu * nu.pntsv;
667 Curve *cu = id_cast<Curve *>(obedit->
data);
669 if (cu->
key ==
nullptr) {
681 float (*ofs)[3] =
nullptr;
682 std::optional<Array<bool>> dependent;
683 const float *oldkey, *ofp;
698 totvec += nu.
pntsu * 4;
716 for (j = 0; j < 3; j++) {
720 ofs[i][0] = bezt->
tilt - oldbezt->
tilt;
737 ofs[i + 1][0] = bp->
tilt - oldbp->
tilt;
748 for (
const auto [currkey_i, currkey] : cu->
key->
block.enumerate()) {
749 const bool apply_offset = (ofs && (&currkey != actkey) && (*dependent)[currkey_i]);
751 float *fp = newkey =
static_cast<float *
>(
753 ofp = oldkey =
static_cast<float *
>(currkey.data);
759 newnu = newnurbs->first();
762 if (&currkey == actkey) {
763 const bool restore = actkey != cu->
key->
refkey;
773 for (j = 0; j < 3; j++, i++) {
776 if (restore && oldbezt) {
783 if (restore && oldbezt) {
806 if (restore && oldbp) {
832 curofp = ofp +
index;
834 for (j = 0; j < 3; j++, i++) {
854 for (j = 0; j < 3; j++, i++) {
872 curofp = ofp +
index;
905 currkey.totelem = totvert;
909 currkey.data = newkey;
912 MEM_SAFE_DELETE(ofs);
936 const int len = strlen(orig_rna_path);
938 for (
FCurve *fcu : orig_curves) {
939 if (processed_fcurves.
contains(fcu)) {
942 if (!
STREQLEN(fcu->rna_path().c_str(), orig_rna_path,
len)) {
946 processed_fcurves.
add(fcu);
948 const char *suffix = fcu->rna_path().c_str() +
len;
950 fcu->rna_path_set_move(new_rna_path);
970 char rna_path[64], orig_rna_path[64];
975 for (
const auto [nu_index, nu] : editnurb->
nurbs.enumerate()) {
987 "splines[%d].bezier_points[%d]",
992 char handle_path[64], orig_handle_path[64];
993 SNPRINTF_UTF8(orig_handle_path,
"%s.handle_left", orig_rna_path);
997 SNPRINTF_UTF8(orig_handle_path,
"%s.handle_right", orig_rna_path);
1024 a = nu.pntsu * nu.pntsv;
1033 orig_rna_path,
"splines[%d].points[%d]", keyIndex->
nu_index, keyIndex->
pt_index);
1059 for (
FCurve *fcu : orig_curves) {
1060 if (processed_fcurves.
contains(fcu)) {
1064 if (
STRPREFIX(fcu->rna_path().c_str(),
"splines")) {
1065 const char *ch = strchr(fcu->rna_path().c_str(),
'.');
1068 fcurves_to_remove.
append(fcu);
1069 processed_fcurves.
add(fcu);
1074 for (
const auto [nu_index, nu] : editnurb->
nurbs.enumerate()) {
1094 for (
FCurve *fcu : orig_curves) {
1095 if (processed_fcurves.
contains(fcu)) {
1098 if (
STRPREFIX(fcu->rna_path().c_str(),
"splines")) {
1099 fcurves_to_remove.
append(fcu);
1103 processed_fcurves.
add(fcu);
1107 return fcurves_to_remove;
1123 if (adt->
action !=
nullptr) {
1129 for (
FCurve *fcurve : fcurves_to_remove) {
1141 for (
FCurve *driver : fcurves_to_remove) {
1162 Curve *curve = id_cast<Curve *>(obedit->
data);
1165 int *old_to_new_map;
1167 int old_totvert = 0;
1170 old_totvert += nu.
pntsu * 3;
1178 for (
int i = 0; i < old_totvert; i++) {
1179 old_to_new_map[i] = -1;
1182 int vertex_index = 0;
1190 if (keyIndex && keyIndex->
vertex_index + 2 < old_totvert) {
1192 old_to_new_map[keyIndex->
vertex_index] = vertex_index + 2;
1193 old_to_new_map[keyIndex->
vertex_index + 1] = vertex_index + 1;
1194 old_to_new_map[keyIndex->
vertex_index + 2] = vertex_index;
1198 old_to_new_map[keyIndex->
vertex_index + 1] = vertex_index + 1;
1199 old_to_new_map[keyIndex->
vertex_index + 2] = vertex_index + 2;
1221 *r_old_totvert = old_totvert;
1222 return old_to_new_map;
1227 Curve *curve = id_cast<Curve *>(obedit->
data);
1229 int *old_to_new_map =
nullptr;
1232 if (editnurb->
keyindex ==
nullptr) {
1242 if ((
object.parent) && (
object.parent->data == id_cast<const ID *>(curve)) &&
1245 if (old_to_new_map ==
nullptr) {
1249 if (
object.par1 < old_totvert) {
1250 index = old_to_new_map[
object.par1];
1252 object.par1 =
index;
1255 if (
object.par2 < old_totvert) {
1256 index = old_to_new_map[
object.par2];
1258 object.par2 =
index;
1261 if (
object.par3 < old_totvert) {
1262 index = old_to_new_map[
object.par3];
1264 object.par3 =
index;
1268 if (
object.
data == id_cast<const ID *>(curve)) {
1274 if (old_to_new_map ==
nullptr) {
1279 if (hmd->
indexar[i] < old_totvert) {
1295 if (old_to_new_map !=
nullptr) {
1296 MEM_delete(old_to_new_map);
1304 if (obedit ==
nullptr) {
1309 Curve *cu = id_cast<Curve *>(obedit->
data);
1310 ListBaseT<Nurb> newnurb = {
nullptr,
nullptr}, oldnurb = cu->
nurb;
1314 for (
Nurb &nu : *editnurb) {
1339 Curve *cu = id_cast<Curve *>(obedit->
data);
1349 undo_editmode_clear();
1358 editnurb = MEM_new<EditNurb>(
"editnurb");
1383 Curve *cu = id_cast<Curve *>(obedit->
data);
1404 int error_vertex_keys;
1412 for (
Base *oldbase : bases) {
1415 Curve *oldcu, *newcu;
1417 ListBaseT<Nurb> newnurb = {
nullptr,
nullptr};
1419 oldob = oldbase->object;
1420 oldcu = id_cast<Curve *>(oldob->
data);
1423 status.error_vertex_keys++;
1428 status.unselected++;
1435 if (newnurb.is_empty()) {
1436 status.error_generic++;
1474 if (status.unselected == bases.
size()) {
1479 const int tot_errors = status.error_vertex_keys + status.error_generic;
1480 if (tot_errors > 0) {
1483 if (status.changed) {
1489 if (((status.error_vertex_keys ? 1 : 0) + (status.error_generic ? 1 : 0)) > 1) {
1494 if (status.error_vertex_keys) {
1512 ot->
name =
"Separate";
1513 ot->
idname =
"CURVE_OT_separate";
1514 ot->
description =
"Separate selected points from connected unselected points into a new object";
1536 bool changed =
false;
1537 int count_failed = 0;
1541 for (
Object *obedit : objects) {
1542 Curve *cu = id_cast<Curve *>(obedit->data);
1548 ListBaseT<Nurb> newnurb = {
nullptr,
nullptr};
1552 if (newnurb.is_empty()) {
1558 const int len_orig = editnurb->count();
1561 cu->
actnu -= len_orig - editnurb->count();
1573 if (changed ==
false) {
1574 if (count_failed != 0) {
1586 ot->
idname =
"CURVE_OT_split";
1587 ot->
description =
"Split off selected points from connected unselected points";
1613 for (a = 0; a < nu->
pntsu; a++, bp++) {
1614 if (bp->
f1 & flag) {
1618 if (sel == nu->
pntsu) {
1621 else if (sel >= 1) {
1638 for (a = 0; a < nu->
pntsu; a++) {
1642 if (bp->f1 & flag) {
1646 if (sel == nu->
pntsv) {
1649 else if (sel >= 1) {
1660 const float cent[3],
1661 const float rotmat[3][3])
1667 for (
Nurb &nu : *editnurb) {
1670 a = nu.pntsu * nu.pntsv;
1673 if (bp->
f1 & flag) {
1694 for (
Nurb &nu : *editnurb) {
1699 if (bezt->
f1 & flag) {
1702 if (bezt->
f2 & flag) {
1705 if (bezt->
f3 & flag) {
1712 a = nu.pntsu * nu.pntsv;
1715 if (bp->
f1 & flag) {
1733 for (
Nurb &nu : *editnurb) {
1735 a = nu.pntsu * nu.pntsv;
1738 if (bp->
f1 & flag) {
1750 Curve *cu = id_cast<Curve *>(obedit->
data);
1752 BPoint *bp, *bpn, *newbp;
1753 int a,
b, newu, newv;
1757 for (
Nurb &nu : editnurb->items_mutable()) {
1760 a = nu.pntsu * nu.pntsv;
1783 newv = nu.pntsv - newv;
1784 if (newv != nu.pntsv) {
1788 for (
b = 0;
b < nu.pntsv;
b++) {
1790 memcpy(bpn, bp, nu.pntsu *
sizeof(
BPoint));
1809 newu = nu.pntsu - newu;
1810 if (newu != nu.pntsu) {
1814 for (
b = 0;
b < nu.pntsv;
b++) {
1815 for (a = 0; a < nu.pntsu; a++, bp++) {
1828 if (newu == 1 && nu.pntsv > 1) {
1829 nu.pntsu = nu.pntsv;
1831 std::swap(nu.orderu, nu.orderv);
1833 MEM_SAFE_DELETE(nu.knotsv);
1848 Curve *cu = id_cast<Curve *>(obedit->
data);
1850 ListBaseT<Nurb> *nubase = &editnurb->
nurbs;
1853 int a, type, nuindex = 0;
1856 for (
Nurb &nu : nubase->items_mutable()) {
1857 bool nu_deleted =
false;
1874 if (cu->
actnu == nuindex) {
1887 a = nu.pntsu * nu.pntsv;
1900 if (cu->
actnu == nuindex) {
1915 if (!nu_deleted && (nu.type ==
CU_NURBS)) {
1916 clamp_nurb_order_u(&nu);
1924 for (
Nurb &nu : nubase->items_mutable()) {
1928 for (a = 0; a < nu.pntsu; a++) {
1930 memmove(bezt, bezt + 1, (nu.pntsu - a - 1) *
sizeof(
BezTriple));
1943 memcpy(bezt1, nu.bezt, (nu.pntsu) *
sizeof(
BezTriple));
1945 MEM_delete(nu.bezt);
1950 else if (nu.pntsv == 1) {
1953 for (a = 0; a < nu.pntsu; a++) {
1955 memmove(bp, bp + 1, (nu.pntsu - a - 1) *
sizeof(
BPoint));
1968 memcpy(bp1, nu.bp, (nu.pntsu) *
sizeof(
BPoint));
1977 clamp_nurb_order_u(nu);
1990 const bool selstatus,
1994 for (
int i = 0; i < count; i++) {
2013 int copy_intervals[],
2014 int *interval_count,
2015 bool *out_is_first_sel)
2019 int selected_leg_count = 0;
2021 int selected_in_prev_leg = -1;
2024 bool is_first_sel =
false;
2025 bool is_last_sel =
false;
2027 for (
int j = 0; j < max_j; j++, bp_j += next_j) {
2028 const BPoint *bp_j_i = bp_j;
2029 int selected_in_curr_leg = 0;
2030 for (
int i = 0; i < max_i; i++, bp_j_i += next_i) {
2031 if (bp_j_i->
f1 & flag) {
2032 selected_in_curr_leg++;
2035 if (selected_in_curr_leg == max_i) {
2036 selected_leg_count++;
2038 is_first_sel =
true;
2040 else if (j + 1 == max_j) {
2044 else if (not_full == -1) {
2045 not_full = selected_in_curr_leg;
2048 else if (not_full != selected_in_curr_leg) {
2052 if (selected_in_prev_leg != selected_in_curr_leg) {
2053 copy_intervals[ins] = selected_in_curr_leg == max_i || j == 0 ? j : j - 1;
2055 selected_in_prev_leg = selected_in_curr_leg;
2057 copy_intervals[ins] = j;
2059 if (selected_leg_count &&
2062 (selected_leg_count < max_j || max_j == 1))
2066 if (is_first_sel && (copy_intervals[0] < copy_intervals[1] || max_j == 1)) {
2067 memmove(copy_intervals + 1, copy_intervals, (ins + 1) *
sizeof(copy_intervals[0]));
2068 copy_intervals[0] = 0;
2070 is_first_sel =
false;
2073 if (is_last_sel && copy_intervals[ins - 1] < copy_intervals[ins]) {
2074 copy_intervals[ins + 1] = copy_intervals[ins];
2078 *interval_count = ins;
2079 *out_is_first_sel = ins > 1 ? is_first_sel :
false;
2080 return selected_leg_count;
2109 bool is_first_sel_u;
2113 nu.
bp, 1, nu.
pntsu, nu.
pntsu, nu.
pntsv, flag, intvls_u, &intvl_cnt_u, &is_first_sel_u);
2114 if (selected_us == -1) {
2118 bool is_first_sel_v;
2120 const bool is_point = nu.
pntsu == 1;
2121 const bool is_curve = nu.
pntsv == 1;
2122 const bool extrude_every_u_point = selected_us == nu.
pntsu;
2123 if (is_point || (is_curve && !extrude_every_u_point)) {
2124 intvls_v[0] = intvls_v[1] = 0;
2126 is_first_sel_v =
false;
2130 nu.
bp, nu.
pntsu, nu.
pntsv, 1, nu.
pntsu, flag, intvls_v, &intvl_cnt_v, &is_first_sel_v);
2131 if (selected_vs == -1) {
2136 const int new_pntsu = nu.
pntsu + intvl_cnt_u - 1;
2137 const int new_pntsv = nu.
pntsv + intvl_cnt_v - 1;
2140 BPoint *new_bp_v = new_bp;
2142 bool selected_v = is_first_sel_v;
2143 for (
int j = 1; j <= intvl_cnt_v; j++, selected_v = !selected_v) {
2145 for (
int v_j = intvls_v[j - 1]; v_j <= intvls_v[j];
2146 v_j++, new_bp_v += new_pntsu, old_bp_v += nu.
pntsu)
2148 BPoint *new_bp_u_v = new_bp_v;
2149 bool selected_u = is_first_sel_u;
2150 for (
int i = 1; i <= intvl_cnt_u; i++, selected_u = !selected_u) {
2151 const int copy_from = intvls_u[i - 1];
2152 const int copy_to = intvls_u[i];
2153 const int copy_count = copy_to - copy_from + 1;
2154 const bool sel_status = selected_u || selected_v ?
true :
false;
2155 ED_curve_bpcpy(editnurb, new_bp_u_v, old_bp_v + copy_from, copy_count);
2157 new_bp_u_v += copy_count;
2164 nu.
pntsu = new_pntsu;
2165 if (nu.
pntsv == 1 && new_pntsv > 1) {
2168 nu.
pntsv = new_pntsv;
2175 MEM_delete(intvls_u);
2176 MEM_delete(intvls_v);
2181 const ListBaseT<Nurb> *newnurb,
2184 cu->
actnu = editnurb->count() + newnurb->count();
2188 const ListBaseT<Nurb> *newnurb,
2199 if ((start <= cu->actvert) && (end > cu->
actvert)) {
2209 ListBaseT<Nurb> *newnurb,
2216 BPoint *bp, *bp1, *bp2, *bp3;
2217 Curve *cu = id_cast<Curve *>(obedit->
data);
2218 int a,
b, c, starta, enda, diffa, cyclicu, cyclicv, newu, newv;
2221 for (
const auto [i, nu] : (editnurb)->enumerate()) {
2222 cyclicu = cyclicv = 0;
2224 for (a = 0, bezt = nu.bezt; a < nu.pntsu; a++, bezt++) {
2227 while ((bezt->
f1 & flag) || (bezt->
f2 & flag) || (bezt->
f3 & flag)) {
2232 if (a >= nu.pntsu - 1) {
2238 if (enda >= starta) {
2239 newu = diffa = enda - starta + 1;
2241 if (starta == 0 && newu != nu.pntsu && (nu.flagu &
CU_NURB_CYCLIC)) {
2245 if (enda == nu.pntsu - 1) {
2248 if (i == cu->
actnu) {
2250 editnurb, newnurb, cu, starta, starta + diffa, cu->
actvert - starta);
2254 memcpy(newnu->
bezt, &nu.bezt[starta], diffa *
sizeof(
BezTriple));
2255 if (newu != diffa) {
2256 memcpy(&newnu->
bezt[diffa], nu.bezt, cyclicu *
sizeof(
BezTriple));
2257 if (i == cu->
actnu) {
2259 editnurb, newnurb, cu, 0, cyclicu, newu - cyclicu + cu->
actvert);
2264 if (newu != nu.pntsu) {
2278 if (i == cu->
actnu) {
2293 else if (nu.pntsv == 1) {
2294 for (a = 0, bp = nu.bp; a < nu.pntsu; a++, bp++) {
2297 while (bp->
f1 & flag) {
2302 if (a >= nu.pntsu - 1) {
2308 if (enda >= starta) {
2309 newu = diffa = enda - starta + 1;
2311 if (starta == 0 && newu != nu.pntsu && (nu.flagu &
CU_NURB_CYCLIC)) {
2315 if (enda == nu.pntsu - 1) {
2318 if (i == cu->
actnu) {
2320 editnurb, newnurb, cu, starta, starta + diffa, cu->
actvert - starta);
2324 memcpy(newnu->
bp, &nu.bp[starta], diffa *
sizeof(
BPoint));
2325 if (newu != diffa) {
2326 memcpy(&newnu->
bp[diffa], nu.bp, cyclicu *
sizeof(
BPoint));
2327 if (i == cu->
actnu) {
2329 editnurb, newnurb, cu, 0, cyclicu, newu - cyclicu + cu->
actvert);
2334 if (newu != nu.pntsu) {
2348 if (i == cu->
actnu) {
2353 memcpy(newnu->
bp, nu.bp, cyclicu *
sizeof(
BPoint));
2369 for (a = 0; a < nu.pntsv; a++) {
2370 for (
b = 0;
b < nu.pntsu;
b++, bp++) {
2371 if (bp->
f1 & flag) {
2378 for (a = 0; a < nu.pntsu; a++) {
2380 if (
ELEM(newv, 0, usel[a])) {
2396 printf(
"Can't duplicate Nurb\n");
2400 for (a = 0, bp1 = nu.bp; a < nu.pntsu * nu.pntsv; a++, bp1++) {
2405 for (
b = a % nu.pntsu, bp2 = bp1;
b < nu.pntsu;
b++, bp2++) {
2406 if (bp2->
f1 & flag) {
2408 for (c = a / nu.pntsu, bp3 = bp2; c < nu.pntsv; c++, bp3 += nu.pntsu) {
2409 if (bp3->
f1 & flag) {
2427 if ((newu + newv) > 2) {
2437 if (cyclicu != 0 || cyclicv != 0) {
2442 if (a + newu == nu.pntsu && cyclicu != 0) {
2445 for (
b = 0;
b < newv;
b++) {
2446 memcpy(&newnu->
bp[
b * newnu->
pntsu],
2447 &nu.bp[
b * nu.pntsu + a],
2449 memcpy(&newnu->
bp[
b * newnu->
pntsu + newu],
2450 &nu.bp[
b * nu.pntsu],
2451 cyclicu *
sizeof(
BPoint));
2454 if (cu->
actnu == i) {
2459 for (
b = 0, diffa = 0;
b < newv;
b++, diffa += nu.pntsu - newu) {
2460 starta =
b * nu.pntsu + a;
2484 cyclicu = cyclicv = 0;
2486 else if ((a / nu.pntsu) + newv == nu.pntsv && cyclicv != 0) {
2489 memcpy(newnu->
bp, &nu.bp[a], newu * newv *
sizeof(
BPoint));
2490 memcpy(&newnu->
bp[newu * newv], nu.bp, newu * cyclicv *
sizeof(
BPoint));
2493 if (cu->
actnu == i) {
2495 editnurb, newnurb, cu, cu->
actvert, a, (newu * newv) + cu->
actvert);
2497 cyclicu = cyclicv = 0;
2501 for (
b = 0;
b < newv;
b++) {
2502 memcpy(&newnu->
bp[
b * newu], &nu.bp[
b * nu.pntsu + a], newu *
sizeof(
BPoint));
2507 if (cu->
actnu == i) {
2512 for (
b = 0, diffa = 0;
b < newv;
b++, diffa += nu.pntsu - newu) {
2513 starta =
b * nu.pntsu + a;
2520 cu->
actvert - (a / nu.pntsu * nu.pntsu + diffa + (starta % nu.pntsu))))
2529 if (newu != nu.pntsu) {
2532 if (newv != nu.pntsv) {
2538 if (cyclicu != 0 || cyclicv != 0) {
2540 newu = cyclicu == 0 ? nu.pntsu : cyclicu;
2541 newv = cyclicv == 0 ? nu.pntsv : cyclicv;
2544 for (
b = 0;
b < newv;
b++) {
2545 memcpy(&newnu->
bp[
b * newu], &nu.bp[
b * nu.pntsu], newu *
sizeof(
BPoint));
2549 if (cu->
actnu == i) {
2554 for (
b = 0, diffa = 0;
b < newv;
b++, diffa += nu.pntsu - newu) {
2555 starta =
b * nu.pntsu;
2561 cu->
actvert - (diffa + (starta % nu.pntsu))))
2570 if (newu != nu.pntsu) {
2573 if (newv != nu.pntsv) {
2578 for (
b = 0, bp1 = nu.bp;
b < nu.pntsu * nu.pntsv;
b++, bp1++) {
2589 if (newnurb->is_empty() ==
false) {
2590 for (
Nurb &nu : *newnurb) {
2604 for (a = 0, bp = nu.bp; a < nu.pntsu * nu.pntsv; a++, bp++) {
2631 for (
Object *obedit : objects) {
2632 Curve *cu = id_cast<Curve *>(obedit->data);
2640 for (
const auto [i, nu] : editnurb->
nurbs.enumerate()) {
2663 ot->
name =
"Switch Direction";
2664 ot->
description =
"Switch direction of selected splines";
2665 ot->
idname =
"CURVE_OT_switch_direction";
2689 for (
Object *obedit : objects) {
2696 for (
Nurb &nu : *editnurb) {
2698 for (bezt = nu.bezt, a = 0; a < nu.pntsu; a++, bezt++) {
2705 for (bp = nu.bp, a = 0; a < nu.pntsu * nu.pntsv; a++, bp++) {
2723 ot->
name =
"Set Goal Weight";
2724 ot->
description =
"Set softbody goal weight for selected points";
2725 ot->
idname =
"CURVE_OT_spline_weight_set";
2755 for (
Object *obedit : objects) {
2769 for (
Nurb &nu : *editnurb) {
2771 for (bezt = nu.bezt, a = 0; a < nu.pntsu; a++, bezt++) {
2778 for (bp = nu.bp, a = 0; a < nu.pntsu * nu.pntsv; a++, bp++) {
2796 ot->
name =
"Set Curve Radius";
2797 ot->
description =
"Set per-point radius which is used for bevel tapering";
2798 ot->
idname =
"CURVE_OT_radius_set";
2826 for (
int i = 0; i < 3; i++) {
2828 float val_old = bezt->
vec[1][i];
2831 float val_new = (bezt_orig_prev->
vec[1][i] * 0.5f) + (bezt_orig_next->
vec[1][i] * 0.5f);
2832 float offset = (val_old * (1.0f - factor)) + (val_new * factor) - val_old;
2835 bezt->
vec[1][i] += offset;
2836 bezt->
vec[0][i] += offset;
2837 bezt->
vec[2][i] += offset;
2845 const BPoint *bp_orig_prev,
2846 const BPoint *bp_orig_next,
2851 for (
int i = 0; i < 3; i++) {
2852 float val_old, val_new, offset;
2854 val_old = bp->
vec[i];
2855 val_new = (bp_orig_prev->
vec[i] * 0.5f) + (bp_orig_next->
vec[i] * 0.5f);
2856 offset = (val_old * (1.0f - factor)) + (val_new * factor) - val_old;
2858 bp->
vec[i] += offset;
2864 const float factor = 1.0f / 6.0f;
2873 for (
Object *obedit : objects) {
2885 for (
Nurb &nu : *editnurb) {
2888 const BezTriple *bezt_orig = MEM_dupalloc(nu.bezt);
2890 bool changed =
false;
2899 a_end = nu.pntsu - 1;
2903 for (; a < a_end; a++) {
2907 const BezTriple *bezt_orig_prev, *bezt_orig_next;
2909 bezt_orig_prev = &bezt_orig[
mod_i(a - 1, nu.pntsu)];
2910 bezt_orig_next = &bezt_orig[
mod_i(a + 1, nu.pntsu)];
2917 MEM_delete(bezt_orig);
2924 const BPoint *bp_orig = MEM_dupalloc(nu.bp);
2933 a_end = nu.pntsu - 1;
2936 for (; a < a_end; a++) {
2939 const BPoint *bp_orig_prev, *bp_orig_next;
2941 bp_orig_prev = &bp_orig[
mod_i(a - 1, nu.pntsu)];
2942 bp_orig_next = &bp_orig[
mod_i(a + 1, nu.pntsu)];
2947 MEM_delete(bp_orig);
2961 ot->
name =
"Smooth";
2962 ot->
description =
"Flatten angles of selected points";
2963 ot->
idname =
"CURVE_OT_smooth";
2984 const int bezt_offsetof,
2985 const int bp_offset)
2993 int start_sel, end_sel;
2994 float start_rad, end_rad, fac, range;
2996 for (
Nurb &nu : *editnurb) {
2998#define BEZT_VALUE(bezt) (*((float *)((char *)(bezt) + bezt_offsetof)))
3000 for (last_sel = 0; last_sel < nu.pntsu; last_sel++) {
3006 for (bezt = &nu.bezt[last_sel], a = last_sel; a < nu.pntsu; a++, bezt++) {
3013 end_sel = start_sel;
3014 for (bezt = &nu.bezt[start_sel + 1], a = start_sel + 1; a < nu.pntsu; a++, bezt++) {
3021 if (start_sel == -1) {
3022 last_sel = nu.pntsu;
3028 start_rad = end_rad =
FLT_MAX;
3030 if (start_sel == end_sel) {
3032 if (start_sel > 0) {
3033 start_rad =
BEZT_VALUE(&nu.bezt[start_sel - 1]);
3035 if (start_sel + 1 < nu.pntsu) {
3036 end_rad =
BEZT_VALUE(&nu.bezt[start_sel + 1]);
3040 BEZT_VALUE(&nu.bezt[start_sel]) = (start_rad + end_rad) / 2.0f;
3042 else if (start_rad !=
FLT_MAX) {
3045 else if (end_rad !=
FLT_MAX) {
3051 if (start_sel == 0) {
3056 start_rad =
BEZT_VALUE(&nu.bezt[start_sel - 1]);
3058 if (end_sel == nu.pntsu - 1) {
3067 range =
float(end_sel - start_sel) + 2.0f;
3068 for (bezt = &nu.bezt[start_sel], a = start_sel; a <= end_sel; a++, bezt++) {
3069 fac =
float(1 + a - start_sel) / range;
3070 BEZT_VALUE(bezt) = start_rad * (1.0f - fac) + end_rad * fac;
3078#define BP_VALUE(bp) (*((float *)((char *)(bp) + bp_offset)))
3081 for (last_sel = 0; last_sel < nu.pntsu; last_sel++) {
3087 for (bp = &nu.bp[last_sel], a = last_sel; a < nu.pntsu; a++, bp++) {
3094 end_sel = start_sel;
3095 for (bp = &nu.bp[start_sel + 1], a = start_sel + 1; a < nu.pntsu; a++, bp++) {
3102 if (start_sel == -1) {
3103 last_sel = nu.pntsu;
3109 start_rad = end_rad =
FLT_MAX;
3111 if (start_sel == end_sel) {
3113 if (start_sel > 0) {
3114 start_rad =
BP_VALUE(&nu.bp[start_sel - 1]);
3116 if (start_sel + 1 < nu.pntsu) {
3117 end_rad =
BP_VALUE(&nu.bp[start_sel + 1]);
3121 BP_VALUE(&nu.bp[start_sel]) = (start_rad + end_rad) / 2;
3123 else if (start_rad !=
FLT_MAX) {
3124 BP_VALUE(&nu.bp[start_sel]) = start_rad;
3126 else if (end_rad !=
FLT_MAX) {
3127 BP_VALUE(&nu.bp[start_sel]) = end_rad;
3132 if (start_sel == 0) {
3133 start_rad =
BP_VALUE(&nu.bp[start_sel]);
3137 start_rad =
BP_VALUE(&nu.bp[start_sel - 1]);
3139 if (end_sel == nu.pntsu - 1) {
3140 end_rad =
BP_VALUE(&nu.bp[end_sel]);
3144 end_rad =
BP_VALUE(&nu.bp[end_sel + 1]);
3148 range =
float(end_sel - start_sel) + 2.0f;
3149 for (bp = &nu.bp[start_sel], a = start_sel; a <= end_sel; a++, bp++) {
3150 fac =
float(1 + a - start_sel) / range;
3151 BP_VALUE(bp) = start_rad * (1.0f - fac) + end_rad * fac;
3175 for (
Object *obedit : objects) {
3190 ot->
name =
"Smooth Curve Weight";
3191 ot->
description =
"Interpolate weight of selected points";
3192 ot->
idname =
"CURVE_OT_smooth_weight";
3219 for (
Object *obedit : objects) {
3241 ot->
name =
"Smooth Curve Radius";
3242 ot->
description =
"Interpolate radii of selected points";
3243 ot->
idname =
"CURVE_OT_smooth_radius";
3269 for (
Object *obedit : objects) {
3291 ot->
name =
"Smooth Curve Tilt";
3292 ot->
description =
"Interpolate tilt of selected points";
3293 ot->
idname =
"CURVE_OT_smooth_tilt";
3320 for (
Object *obedit : objects) {
3321 Curve *cu = id_cast<Curve *>(obedit->data);
3332 for (
Nurb &nu : *editnurb) {
3351 if (sel == nu.pntsu) {
3357 a = nu.pntsu * nu.pntsv;
3373 if (sel == nu.pntsu * nu.pntsv) {
3389 ot->
name =
"Hide Selected";
3390 ot->
idname =
"CURVE_OT_hide";
3391 ot->
description =
"Hide (un)selected control points";
3402 ot->
srna,
"unselected",
false,
"Unselected",
"Hide unselected rather than selected");
3417 bool changed_multi =
false;
3421 for (
Object *obedit : objects) {
3426 bool changed =
false;
3428 for (
Nurb &nu : *editnurb) {
3444 a = nu.pntsu * nu.pntsv;
3460 changed_multi =
true;
3469 ot->
name =
"Reveal Hidden";
3470 ot->
idname =
"CURVE_OT_reveal";
3507 Curve *cu = id_cast<Curve *>(obedit->
data);
3510 BPoint *bp, *prevbp, *bpnew, *bpn;
3512 int a,
b, sel, amount, *usel, *vsel;
3532 if (nextbezt ==
nullptr) {
3538 amount += number_cuts;
3555 if (nextbezt ==
nullptr) {
3562 float prevvec[3][3];
3563 float prev_tilt = bezt->
tilt;
3564 float prev_radius = bezt->
radius;
3565 float prev_weight = bezt->
weight;
3567 memcpy(prevvec, bezt->
vec,
sizeof(
float[9]));
3569 for (
int i = 0; i < number_cuts; i++) {
3570 factor = 1.0f / (number_cuts + 1 - i);
3572 memcpy(beztn, nextbezt,
sizeof(
BezTriple));
3600 memcpy(prevvec, beztn->
vec,
sizeof(
float[9]));
3609 MEM_delete(nu.
bezt);
3616 else if (nu.
pntsv == 1) {
3628 if (nextbp ==
nullptr) {
3633 amount += number_cuts;
3648 memcpy(bpn, bp,
sizeof(
BPoint));
3653 if (nextbp ==
nullptr) {
3659 for (
int i = 0; i < number_cuts; i++) {
3660 factor =
float(i + 1) / (number_cuts + 1);
3662 memcpy(bpn, nextbp,
sizeof(
BPoint));
3728 for (a = 0; a < nu.
pntsv; a++) {
3743 int countu = nu.
pntsu + (nu.
pntsu - 1) * number_cuts;
3746 int tot = ((number_cuts + 1) * nu.
pntsu - number_cuts) *
3747 ((number_cuts + 1) * nu.
pntsv - number_cuts);
3752 for (a = 0; a < nu.
pntsv; a++) {
3760 for (
int i = 0; i < number_cuts; i++) {
3761 factor =
float(i + 1) / (number_cuts + 1);
3768 bpn += number_cuts * countu;
3771 bpn = bpnew + ((number_cuts + 1) * nu.
pntsu - number_cuts);
3772 bp = bpnew + (number_cuts + 1) * ((number_cuts + 1) * nu.
pntsu - number_cuts);
3774 for (a = 1; a < nu.
pntsv; a++) {
3776 for (
b = 0;
b < (number_cuts + 1) * nu.
pntsu - number_cuts;
b++) {
3778 for (
int i = 0; i < number_cuts; i++) {
3779 factor =
float(i + 1) / (number_cuts + 1);
3788 bp += number_cuts * countu;
3789 bpn += number_cuts * countu;
3790 prevbp += number_cuts * countu;
3794 nu.
pntsu = (number_cuts + 1) * nu.
pntsu - number_cuts;
3795 nu.
pntsv = (number_cuts + 1) * nu.
pntsv - number_cuts;
3802 for (a = 0; a < nu.
pntsv - 1; a++) {
3803 if (vsel[a] == nu.
pntsu && vsel[a + 1] == nu.
pntsu) {
3812 for (a = 0; a < nu.
pntsv; a++) {
3819 if ((a < nu.
pntsv - 1) && vsel[a] == nu.
pntsu && vsel[a + 1] == nu.
pntsu) {
3820 for (
int i = 0; i < number_cuts; i++) {
3821 factor =
float(i + 1) / (number_cuts + 1);
3822 prevbp = bp - nu.
pntsu;
3850 for (a = 0; a < nu.
pntsu - 1; a++) {
3851 if (usel[a] == nu.
pntsv && usel[a + 1] == nu.
pntsv) {
3862 for (a = 0; a < nu.
pntsv; a++) {
3876 for (
int i = 0; i < number_cuts; i++) {
3877 factor =
float(i + 1) / (number_cuts + 1);
3911 for (
Object *obedit : objects) {
3912 Curve *cu = id_cast<Curve *>(obedit->data);
3936 ot->
name =
"Subdivide";
3938 ot->
idname =
"CURVE_OT_subdivide";
3947 prop =
RNA_def_int(ot->
srna,
"number_cuts", 1, 1, 1000,
"Number of Cuts",
"", 1, 10);
3968 for (
Object *obedit : objects) {
3972 bool changed =
false;
3973 bool changed_size =
false;
3977 for (
Nurb &nu : *editnurb) {
3979 const int pntsu_prev = nu.pntsu;
3980 const char *err_msg =
nullptr;
3983 if (pntsu_prev != nu.pntsu) {
3984 changed_size =
true;
4002 Curve *cu = id_cast<Curve *>(obedit->data);
4016 {
CU_POLY,
"POLY", 0,
"Poly",
""},
4017 {
CU_BEZIER,
"BEZIER", 0,
"Bézier",
""},
4018 {
CU_NURBS,
"NURBS", 0,
"NURBS",
""},
4019 {0,
nullptr, 0,
nullptr,
nullptr},
4023 ot->
name =
"Set Spline Type";
4025 ot->
idname =
"CURVE_OT_spline_type_set";
4041 "Use handles when converting Bézier curves into polygons");
4063 for (
Object *obedit : objects) {
4064 Curve *cu = id_cast<Curve *>(obedit->data);
4083 {
HD_AUTO,
"AUTOMATIC", ICON_HANDLE_AUTO,
"Automatic",
""},
4084 {
HD_VECT,
"VECTOR", ICON_HANDLE_VECTOR,
"Vector",
""},
4085 {5,
"ALIGNED", ICON_HANDLE_ALIGNED,
"Aligned",
""},
4086 {6,
"FREE_ALIGN", ICON_HANDLE_FREE,
"Free",
""},
4087 {3,
"TOGGLE_FREE_ALIGN", 0,
"Toggle Free/Align",
""},
4088 {0,
nullptr, 0,
nullptr,
nullptr},
4092 ot->
name =
"Set Handle Type";
4093 ot->
description =
"Set type of handles for selected control points";
4094 ot->
idname =
"CURVE_OT_handle_type_set";
4105 ot->
prop =
RNA_def_enum(ot->
srna,
"type", editcurve_handle_type_items, 1,
"Type",
"Spline type");
4128 for (
Object *obedit : objects) {
4129 Curve *cu = id_cast<Curve *>(obedit->data);
4153 ot->
name =
"Recalculate Handles";
4154 ot->
description =
"Recalculate the direction of selected handles";
4155 ot->
idname =
"CURVE_OT_normals_make_consistent";
4178 float *fp1, *fp2, *tempf;
4181 if (base ==
nullptr || tot == 0) {
4188 fp2 = fp1 + (a - 1);
4190 while (fp1 != fp2 && a > 0) {
4191 std::swap(*fp1, *fp2);
4202 fp2[0] =
fabsf(fp1[1] - fp1[0]);
4214 fp1[0] = fp1[-1] + fp2[0];
4223 BPoint *bp1, *bp2, *temp;
4234 temp = MEM_dupalloc(nu->
bp);
4237 for (u = 0; u < nu->
pntsu; u++, bp1++) {
4238 bp2 = temp + (nu->
pntsu - u - 1) * (nu->
pntsv) +
v;
4269 ListBaseT<Nurb> *editnurb,
4270 ListBaseT<NurbSort> *nsortbase)
4272 ListBaseT<NurbSort> nbase = {
nullptr,
nullptr};
4273 NurbSort *nus, *nustest, *headdo, *taildo;
4275 float dist, headdist, taildist;
4278 for (
Nurb &nu : *editnurb) {
4296 nus = nbase.first();
4301 while (nbase.first_) {
4303 headdist = taildist = 1.0e30;
4304 headdo = taildo =
nullptr;
4306 nustest = nbase.first();
4308 dist =
len_v3v3(nustest->
vec, (nsortbase->first())->vec);
4310 if (dist < headdist) {
4314 dist =
len_v3v3(nustest->
vec, (nsortbase->last())->vec);
4316 if (dist < taildist) {
4320 nustest = nustest->
next;
4323 if (headdist < taildist) {
4343 BPoint *bp, *bp1, *bp2, *temp;
4378 if (nu1->
pntsv != 1) {
4411 if (nu1->
pntsu == 1) {
4414 if (nu2->
pntsv != 1) {
4430 bp1 = &nu1->
bp[nu1->
pntsu - 1];
4438 bp1 = &nu1->
bp[nu1->
pntsu - 1];
4471 for (u = 0; u < nu1->
pntsu; u++, bp++) {
4502 Curve *cu = id_cast<Curve *>(obedit->
data);
4506 ListBaseT<NurbSort> nsortbase = {
nullptr,
nullptr};
4510 if (nsortbase.first_ == nsortbase.last()) {
4511 nsortbase.free_no_destruct();
4515 nus1 = nsortbase.first();
4527 else if (nus2->
nu->
pntsv == 1) {
4546 nsortbase.free_no_destruct();
4557 nsortbase.free_no_destruct();
4573 int error_selected_few;
4574 int error_resolution;
4580 for (
Object *obedit : objects) {
4581 Curve *cu = id_cast<Curve *>(obedit->data);
4584 status.unselected++;
4589 Nurb *nu, *nu1 =
nullptr, *nu2 =
nullptr;
4595 nu = nubase->first();
4603 if (nu_select_num) {
4609 if (nu_select_num > 1) {
4613 if (nu->
pntsv == 1) {
4627 switch (merge_result) {
4630 goto curve_merge_tag_object;
4632 status.error_resolution++;
4633 goto curve_merge_tag_object;
4635 status.error_selected_few++;
4638 status.error_resolution++;
4645 for (
Nurb &nu : *nubase) {
4646 if (nu.
pntsu == 1) {
4654 if (nu2 ==
nullptr) {
4657 else if (nu1 ==
nullptr) {
4671 if (nu1 ==
nullptr) {
4674 else if (nu2 ==
nullptr) {
4687 else if (nu.
pntsv == 1) {
4695 if (nu2 ==
nullptr) {
4698 else if (nu1 ==
nullptr) {
4708 if (nu1 ==
nullptr) {
4711 else if (nu2 ==
nullptr) {
4729 if ((nu1 && nu2) && (nu1 != nu2)) {
4730 if (nu1->
type == nu2->type) {
4737 MEM_delete(nu1->
bezt);
4739 nu1->
pntsu += nu2->pntsu;
4750 MEM_delete(nu1->
bp);
4755 nu1->
pntsu += nu2->pntsu;
4760 MEM_SAFE_DELETE(nu1->
knotsu);
4773 else if ((nu1 && !nu2) || (!nu1 && nu2)) {
4775 std::swap(nu1, nu2);
4797 status.error_generic++;
4807 curve_merge_tag_object:
4812 if (status.unselected == objects.
size()) {
4817 const int tot_errors = status.error_selected_few + status.error_resolution +
4818 status.error_generic;
4819 if (tot_errors > 0) {
4821 if (status.changed) {
4827 if (((status.error_selected_few ? 1 : 0) + (status.error_resolution ? 1 : 0) +
4828 (status.error_generic ? 1 : 0)) > 1)
4834 if (status.error_selected_few) {
4837 else if (status.error_resolution) {
4853 ot->
name =
"Make Segment";
4854 ot->
idname =
"CURVE_OT_make_segment";
4855 ot->
description =
"Join two curves by their selected ends";
4880 Base *basact =
nullptr;
4882 bool changed =
false;
4902 for (
Object *ob_iter : objects) {
4913 Curve *cu = id_cast<Curve *>(obedit->
data);
4921 if (use_handle_select) {
4947 if (use_handle_select) {
4957 else if (hand == 0) {
4976 if (use_handle_select) {
4987 if (use_handle_select) {
4996 else if (hand == 0) {
5023 if (use_handle_select) {
5071 return changed || found;
5081 float viewmat[4][4],
View3D *v3d,
Object *obedit,
const float axis[3],
const float cent[3])
5083 Curve *cu = id_cast<Curve *>(obedit->
data);
5085 float cmat[3][3], tmat[3][3], imat[3][3];
5086 float bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3];
5087 float persmat[3][3], persinv[3][3];
5088 bool ok, changed =
false;
5095 copy_m3_m4(bmat, obedit->object_to_world().ptr());
5122 for (a = 0; a < 7; a++) {
5144 for (
Nurb &nu : *editnurb) {
5166 float cent[3], axis[3], viewmat[4][4];
5167 bool changed =
false;
5168 int count_failed = 0;
5182 for (
Object *obedit : objects) {
5183 Curve *cu = id_cast<Curve *>(obedit->data);
5189 invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr());
5190 mul_m4_v3(obedit->world_to_object().ptr(), cent);
5206 if (changed ==
false) {
5207 if (count_failed != 0) {
5219 float axis[3] = {0.0f, 0.0f, 1.0f};
5235 ot->
idname =
"CURVE_OT_spin";
5236 ot->
description =
"Extrude selected boundary row around pivot point and current view axis";
5253 "Center in global view space",
5257 ot->
srna,
"axis", 3,
nullptr, -1.0f, 1.0f,
"Axis",
"Axis in global view space", -1.0f, 1.0f);
5268 bool changed =
false;
5277 if (editnurb->
nurbs.is_empty()) {
5287 int pnt_len = nu.
pntsu;
5290 bool is_prev_selected =
false;
5291 bool duplic_first =
false;
5292 bool duplic_last =
false;
5296 bool is_cyclic =
false;
5300 bezt_prev = &nu.
bezt[0];
5304 bezt_prev = &nu.
bezt[pnt_len - 1];
5315 bezt_stack = nu.
bezt[0];
5317 bezt_prev = &bezt_stack;
5324 for (bezt = &nu.
bezt[0]; i--; bezt++) {
5326 if (bezt_prev && is_prev_selected != is_selected) {
5329 if (bezt == cu_actvert.bezt) {
5330 act_offset = new_points;
5333 is_prev_selected = is_selected;
5341 is_prev_selected =
false;
5343 else if (is_cyclic) {
5347 else if (duplic_first) {
5348 bezt_prev = &bezt_stack;
5349 is_prev_selected =
false;
5352 bezt_prev =
nullptr;
5354 BezTriple *bezt_src, *bezt_dst, *bezt_src_iter, *bezt_dst_iter;
5355 const int new_len = pnt_len + new_points;
5359 bezt_src_iter = &bezt_src[0];
5360 bezt_dst_iter = &bezt_dst[0];
5362 for (bezt = &nu.
bezt[0]; i < pnt_len; i++, bezt++) {
5370 if (bezt_prev && is_prev_selected != is_selected) {
5371 int count = i - offset + 1;
5372 if (is_prev_selected) {
5382 bezt_dst_iter += count + 1;
5383 bezt_src_iter += count;
5387 is_prev_selected = is_selected;
5390 int remain = pnt_len - offset;
5396 ED_curve_beztcpy(editnurb, &bezt_dst[new_len - 1], &bezt_src[pnt_len - 1], 1);
5400 MEM_delete(nu.
bezt);
5402 nu.
pntsu += new_points;
5407 BPoint *bp, *bp_prev =
nullptr;
5412 bp_prev = &nu.
bp[0];
5418 bp_stack = nu.
bp[0];
5420 bp_prev = &bp_stack;
5428 for (bp = &nu.
bp[0]; i--; bp++) {
5429 bool is_selected = (bp->
f1 &
SELECT) != 0;
5430 if (bp_prev && is_prev_selected != is_selected) {
5433 if (bp == cu_actvert.bp) {
5434 act_offset = new_points;
5437 is_prev_selected = is_selected;
5441 BPoint *bp_src, *bp_dst, *bp_src_iter, *bp_dst_iter;
5442 const int new_len = pnt_len + new_points;
5444 is_prev_selected =
false;
5450 else if (duplic_first) {
5451 bp_prev = &bp_stack;
5452 is_prev_selected =
false;
5459 bp_src_iter = &bp_src[0];
5460 bp_dst_iter = &bp_dst[0];
5462 for (bp = &nu.
bp[0]; i < pnt_len; i++, bp++) {
5463 bool is_selected = (bp->
f1 &
SELECT) != 0;
5464 if (bp_prev && is_prev_selected != is_selected) {
5465 int count = i - offset + 1;
5466 if (is_prev_selected) {
5476 bp_dst_iter += count + 1;
5477 bp_src_iter += count;
5481 is_prev_selected = is_selected;
5484 int remain = pnt_len - offset;
5490 ED_curve_bpcpy(editnurb, &bp_dst[new_len - 1], &bp_src[pnt_len - 1], 1);
5496 nu.
pntsu += new_points;
5520 bool changed =
false;
5530 for (i = 0, bezt = nu.
bezt; i < nu.
pntsu; i++, bezt++) {
5540 for (i = 0, bp = nu.
bp; i < nu.
pntsu; i++, bp++) {
5553 mul_v3_fl(center, 1.0f /
float(verts_len));
5563 for (i = 0, bezt = nu.
bezt; i < nu.
pntsu; i++, bezt++) {
5580 for (i = 0, bp = nu.
bp; i < nu.
pntsu; i++, bp++) {
5604 nurb_new = MEM_new<Nurb>(
"BLI_editcurve_addvert new_bezt_nurb 2");
5618 memcpy(nurb_new->
bp, nu->
bp,
sizeof(
BPoint));
5660 Curve *cu = id_cast<Curve *>(obedit->
data);
5743 const float eps = 1e-6f;
5750 const float *plane_co = vc.
obedit->object_to_world().location();
5762 float location_test[3];
5787 ot->
name =
"Extrude to Cursor or Add";
5788 ot->
idname =
"CURVE_OT_vertex_add";
5789 ot->
description =
"Add a new control point (linked to only selected end-curve one, if any)";
5807 "Location to add new vertex at",
5827 for (
Object *obedit : objects) {
5828 Curve *cu = id_cast<Curve *>(obedit->data);
5830 bool changed =
false;
5858 ot->
name =
"Extrude";
5859 ot->
description =
"Extrude selected control point(s)";
5860 ot->
idname =
"CURVE_OT_extrude";
5889 bool changed =
false;
5891 for (
Nurb &nu : *editnurb) {
5892 if (nu.pntsu > 1 || nu.pntsv > 1) {
5918 else if (nu.pntsv == 1 && nu.type ==
CU_NURBS) {
5935 a = nu.pntsu * nu.pntsv;
5940 if (direction == 0 && nu.pntsu > 1) {
5946 if (direction == 1 && nu.pntsv > 1) {
5969 bool changed_multi =
false;
5973 for (
Object *obedit : objects) {
5974 Curve *cu = id_cast<Curve *>(obedit->data);
5982 changed_multi =
true;
5999 for (
Nurb &nu : *editnurb) {
6000 if (nu.pntsu > 1 || nu.pntsv > 1) {
6003 ui::Layout &layout = *popup_menu_layout(pup);
6005 popup_menu_end(
C, pup);
6018 {0,
"CYCLIC_U", 0,
"Cyclic U",
""},
6019 {1,
"CYCLIC_V", 0,
"Cyclic V",
""},
6020 {0,
nullptr, 0,
nullptr,
nullptr},
6024 ot->
name =
"Toggle Cyclic";
6025 ot->
description =
"Make active spline closed/open loop";
6026 ot->
idname =
"CURVE_OT_cyclic_toggle";
6042 "Direction to make surface cyclic in");
6058 bool changed =
false;
6059 int count_failed = 0;
6063 for (
Object *obedit : objects) {
6064 Curve *cu = id_cast<Curve *>(obedit->data);
6070 ListBaseT<Nurb> newnurb = {
nullptr,
nullptr};
6073 if (newnurb.is_empty()) {
6084 if (changed ==
false) {
6085 if (count_failed != 0) {
6096 ot->
name =
"Duplicate Curve";
6097 ot->
description =
"Duplicate selected control points";
6098 ot->
idname =
"CURVE_OT_duplicate";
6128 Curve *cu = id_cast<Curve *>(obedit->
data);
6130 ListBaseT<Nurb> *nubase = &editnurb->
nurbs, newnurb = {
nullptr,
nullptr};
6134 int a,
b, starta, enda, cut, cyclicut;
6136 for (
Nurb &nu : *nubase) {
6138 starta = enda = cut = -1;
6142 for (a = 0, bezt = nu.bezt; a < nu.pntsu; a++, bezt++) {
6148 if (a < nu.pntsu - 1) {
6159 if (starta <= 1 && a == nu.pntsu - 1) {
6161 if (starta == 1 && enda != a) {
6167 cut = enda - starta + 1;
6170 else if (starta == 0) {
6173 cut = enda - starta + 1;
6174 bezt1 = &nu.bezt[nu.pntsu - 1];
6175 bezt2 = &nu.bezt[nu.pntsu - 2];
6183 starta = nu.pntsu - 1;
6195 else if (enda == nu.pntsu - 1) {
6198 cut = enda - starta + 1;
6200 bezt2 = &nu.bezt[1];
6209 else if (cyclicut != 0) {
6223 cut = enda - starta + 1;
6227 if (nu1 !=
nullptr) {
6231 if (starta != 0 || enda != nu.pntsu - 1) {
6243 bezt2 = &nu.bezt[1];
6251 bezt1 = &nu.bezt[nu.pntsu - 1];
6252 bezt2 = &nu.bezt[nu.pntsu - 2];
6261 else if (nu.pntsv >= 1) {
6265 for (a = 0, bp = nu.bp; a < nu.pntsu; a++, bp++) {
6271 if (a < nu.pntsu - 1) {
6275 else if (a < nu.pntsu - 1 && !((bp + 1)->f1 &
SELECT)) {
6282 if (starta <= 1 && a == nu.pntsu - 1) {
6284 if (starta == 1 && enda != a) {
6290 cut = enda - starta + 1;
6293 else if (starta == 0) {
6296 cut = enda - starta + 1;
6297 bp1 = &nu.bp[nu.pntsu - 1];
6298 bp2 = &nu.bp[nu.pntsu - 2];
6303 for (
b = 0;
b < nu.pntsv;
b++) {
6305 editnurb, &nu1->
bp[
b * nu1->
pntsu + 1], &nu.bp[
b * nu.pntsu], cut);
6307 starta = nu.pntsu - 1;
6319 else if (enda == nu.pntsu - 1) {
6322 cut = enda - starta + 1;
6329 for (
b = 0;
b < nu.pntsv;
b++) {
6331 editnurb, &nu1->
bp[
b * nu1->
pntsu + cut], &nu.bp[
b * nu.pntsu], 1);
6334 else if (cyclicut != 0) {
6337 for (
b = 0;
b < nu.pntsv;
b++) {
6339 editnurb, &nu1->
bp[
b * nu1->
pntsu + cut], &nu.bp[
b * nu.pntsu], cyclicut);
6350 cut = enda - starta + 1;
6354 if (nu1 !=
nullptr) {
6355 for (
b = 0;
b < nu.pntsv;
b++) {
6357 editnurb, &nu1->
bp[
b * nu1->
pntsu], &nu.bp[
b * nu.pntsu + starta], cut);
6361 if (starta != 0 || enda != nu.pntsu - 1) {
6377 for (
b = 0;
b < nu.pntsv;
b++) {
6383 bp1 = &nu.bp[nu.pntsu - 1];
6384 bp2 = &nu.bp[nu.pntsu - 2];
6388 for (
b = 0;
b < nu.pntsv;
b++) {
6396 for (a = 0, bp = nu.bp; a < nu.pntsv; a++, bp += nu.pntsu) {
6402 if (a < nu.pntsv - 1) {
6406 else if (a < nu.pntsv - 1 && !((bp + nu.pntsu)->f1 &
SELECT)) {
6413 if (starta <= 1 && a == nu.pntsv - 1) {
6415 if (starta == 1 && enda != a) {
6421 cut = enda - starta + 1;
6424 else if (starta == 0) {
6427 cut = enda - starta + 1;
6428 bp1 = &nu.bp[nu.pntsv * nu.pntsu - nu.pntsu];
6429 bp2 = &nu.bp[nu.pntsv * nu.pntsu - (nu.pntsu * 2)];
6435 starta = nu.pntsv - 1;
6447 else if (enda == nu.pntsv - 1) {
6450 cut = enda - starta + 1;
6452 bp2 = &nu.bp[nu.pntsu];
6459 else if (cyclicut != 0) {
6462 ED_curve_bpcpy(editnurb, &nu1->
bp[cut * nu.pntsu], nu.bp, nu.pntsu * cyclicut);
6473 cut = enda - starta + 1;
6477 if (nu1 !=
nullptr) {
6478 ED_curve_bpcpy(editnurb, nu1->
bp, &nu.bp[starta * nu.pntsu], cut * nu.pntsu);
6481 if (starta != 0 || enda != nu.pntsv - 1) {
6493 bp2 = &nu.bp[nu.pntsu];
6501 bp1 = &nu.bp[nu.pntsu * nu.pntsv - nu.pntsu];
6502 bp2 = &nu.bp[nu.pntsu * nu.pntsv - (nu.pntsu * 2)];
6506 ED_curve_bpcpy(editnurb, nu1->
bp, &nu.bp[nu.pntsu * nu.pntsv - nu.pntsu], nu.pntsu);
6520 for (
Nurb &nu : newnurb) {
6524 for (
b = 0, bezt1 = nu.bezt;
b < nu.pntsu;
b++, bezt1++) {
6534 for (
b = 0, bp1 = nu.bp;
b < nu.pntsu * nu.pntsv;
b++, bp1++) {
6565 bool changed_multi =
false;
6567 for (
Object *obedit : objects) {
6568 Curve *cu = id_cast<Curve *>(obedit->data);
6569 bool changed =
false;
6587 changed_multi =
true;
6599 if (changed_multi) {
6608 {0,
nullptr, 0,
nullptr,
nullptr},
6636 ot->
name =
"Delete";
6637 ot->
description =
"Delete selected control points or segments";
6638 ot->
idname =
"CURVE_OT_delete";
6673 const uint span_len,
6674 const uint span_step[2])
6676 int i_span_edge_len = span_len + 1;
6679 const int points_len = ((cu->
resolu - 1) * i_span_edge_len) + 1;
6681 float *points_stride = points;
6682 const int points_stride_len = (cu->
resolu - 1);
6684 for (
int segment = 0; segment < i_span_edge_len; segment++) {
6688 for (
int axis = 0; axis < dims; axis++) {
6690 bezt_a->
vec[2][axis],
6691 bezt_b->
vec[0][axis],
6692 bezt_b->
vec[1][axis],
6693 points_stride + axis,
6695 dims *
sizeof(
float));
6698 points_stride += dims * points_stride_len;
6701 BLI_assert(points_stride + dims == points + (points_len * dims));
6703 float tan_l[3], tan_r[3], error_sq_dummy;
6704 uint error_index_dummy;
6711 curve_fit_cubic_to_points_single_fl(points,
6721 &error_index_dummy);
6742 for (
Object *obedit : objects) {
6743 Curve *cu = id_cast<Curve *>(obedit->data);
6751 for (
Nurb &nu : *editnurb) {
6752 if ((nu.type ==
CU_BEZIER) && (nu.pntsu > 2)) {
6765 BezTriple *bezt_prev = &nu.bezt[
mod_i(span_step[0] - 1, nu.pntsu)];
6766 BezTriple *bezt_next = &nu.bezt[
mod_i(span_step[1] + 1, nu.pntsu)];
6790 ot->
name =
"Dissolve Vertices";
6791 ot->
description =
"Delete selected control points, correcting surrounding handles";
6792 ot->
idname =
"CURVE_OT_dissolve_verts";
6813 for (i = nu->
pntsu, bezt = nu->
bezt; i--; bezt++) {
6825 const float error_sq_max =
FLT_MAX;
6827 bool all_supported_multi =
true;
6833 for (
Object *obedit : objects) {
6834 Curve *cu = id_cast<Curve *>(obedit->data);
6835 bool all_supported =
true;
6836 bool changed =
false;
6841 for (
Nurb &nu : *editnurb) {
6844 const int error_target_len =
max_ii(2, nu.pntsu * ratio);
6845 if (error_target_len != nu.pntsu) {
6852 all_supported =
false;
6857 if (all_supported ==
false) {
6858 all_supported_multi =
false;
6872 if (all_supported_multi ==
false) {
6882 ot->
name =
"Decimate Curve";
6884 ot->
idname =
"CURVE_OT_decimate";
6909 int clear =
STREQ(op->
idname,
"CURVE_OT_shade_flat");
6914 for (
Object *obedit : objects) {
6921 for (
Nurb &nu : *editnurb) {
6943 ot->
name =
"Shade Smooth";
6944 ot->
idname =
"CURVE_OT_shade_smooth";
6958 ot->
name =
"Shade Flat";
6959 ot->
idname =
"CURVE_OT_shade_flat";
6984 ListBaseT<Nurb> tempbase;
6985 float imat[4][4], cmat[4][4];
6990 if (ob_iter == ob_active) {
7003 tempbase.clear_no_delete();
7008 Curve *cu_active = id_cast<Curve *>(ob_active->
data);
7011 if (ob_iter->type == ob_active->
type) {
7012 if (ob_iter != ob_active) {
7014 cu = id_cast<Curve *>(ob_iter->data);
7016 if (cu->
nurb.first_) {
7018 mul_m4_m4m4(cmat, imat, ob_iter->object_to_world().ptr());
7021 bool do_radius =
false;
7022 float compensate_radius = 0.0f;
7039 if ((bezt = newnu->
bezt)) {
7044 bezt->
radius *= compensate_radius;
7054 if ((bp = newnu->
bp)) {
7070 cu = id_cast<Curve *>(ob_active->
data);
7107 for (
Object *obedit : objects) {
7108 Curve *cu = id_cast<Curve *>(obedit->data);
7125 for (
Nurb &nu : *editnurb) {
7138 a = nu.pntsu * nu.pntsv;
7157 ot->
name =
"Clear Tilt";
7158 ot->
idname =
"CURVE_OT_tilt_clear";
7159 ot->
description =
"Clear the tilt of selected control points";
7171 memcpy(dst, src, count *
sizeof(
BezTriple));
7177 memcpy(dst, src, count *
sizeof(
BPoint));
7204 float min[3],
max[3], texspace_size[3], texspace_location[3];
7214 texspace_size[0] = (
max[0] -
min[0]) / 2.0f;
7215 texspace_size[1] = (
max[1] -
min[1]) / 2.0f;
7216 texspace_size[2] = (
max[2] -
min[2]) / 2.0f;
7218 for (a = 0; a < 3; a++) {
7219 if (texspace_size[a] == 0.0f) {
7220 texspace_size[a] = 1.0f;
7222 else if (texspace_size[a] > 0.0f && texspace_size[a] < 0.00001f) {
7223 texspace_size[a] = 0.00001f;
7225 else if (texspace_size[a] < 0.0f && texspace_size[a] > -0.00001f) {
7226 texspace_size[a] = -0.00001f;
7244 ot->
name =
"Match Texture Space";
7245 ot->
idname =
"CURVE_OT_match_texture_space";
7246 ot->
description =
"Match texture space to object's bounding box";
Functions and classes to work with Actions.
Functions to work with AnimData.
Blender kernel action and pose functionality.
#define CTX_DATA_BEGIN(C, Type, instance, member)
display list (or rather multi purpose list) stuff.
Generic array manipulation API.
#define BLI_array_iter_span(arr, arr_len, use_wrap, use_delimit_bounds, test_fn, user_data, span_step, r_span_len)
#define SNPRINTF_UTF8(dst, format,...)
#define BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)
#define BEZT_SEL_ALL(bezt)
#define BEZT_DESEL_ALL(bezt)
#define KEYELEM_FLOAT_LEN_BEZTRIPLE
#define KEYELEM_FLOAT_LEN_BPOINT
Object is a sort of wrapper for general info.
#define OBJECT_ADD_SIZE_MAXF
Read Blender memory allocation and freeing.
#define INIT_MINMAX(min, max)
#define BLI_assert_unreachable()
#define STREQLEN(a, b, n)
#define UNUSED_VARS_NDEBUG(...)
#define IN_RANGE_INCL(a, b, c)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
bool add(const Key &key, const Value &value)
Value lookup_default(const Key &key, const Value &default_value) const
Value pop_default(const Key &key, const Value &default_value)
ItemIterator items() const &
bool contains(const Key &key) const
constexpr bool is_empty() const
void append(const T &value)
float2x2 invert(float2x2 mat)
bool flag_test(uint flag, uint val)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
bool action_fcurve_remove(Action &action, FCurve &fcu)
Span< FCurve * > fcurves_for_assigned_action(AnimData *adt)
bool shape_key_report_if_locked(const Object *obedit, ReportList *reports)
void base_activate(bContext *C, Base *base)
Base * add_duplicate(Main *bmain, Scene *scene, ViewLayer *view_layer, Base *base, eDupli_ID_Flags dupflag)
bool material_active_index_set(Object *ob, int index)
void base_free_and_unlink(Main *bmain, Scene *scene, Object *ob)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
PopupMenu * popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
bool isect_ray_plane_v3_factor(const float ray_origin[3], const float ray_direction[3], const float plane_co[3], const float plane_no[3], float *r_lambda)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
static wmOperatorStatus hide_exec(bContext *C, wmOperator *op)
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_curve_nurb_vert_active_set(Curve *cu, const Nurb *nu, const void *vert)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
void mul_m3_v3(const float M[3][3], float r[3])
static wmOperatorStatus toggle_cyclic_exec(bContext *C, wmOperator *op)
static wmOperatorStatus add_vertex_exec(bContext *C, wmOperator *op)
void BKE_curve_editNurb_free(Curve *cu)
void ED_curve_bpcpy(EditNurb *editnurb, BPoint *dst, BPoint *src, int count)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
MINLINE int mod_i(int i, int n)
Nurb * BKE_curve_nurb_active_get(Curve *cu)
static wmOperatorStatus shade_smooth_exec(bContext *C, wmOperator *op)
static wmOperatorStatus separate_exec(bContext *C, wmOperator *op)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
static wmOperatorStatus smooth_exec(bContext *C, wmOperator *op)
int RNA_enum_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void CURVE_OT_make_segment(wmOperatorType *ot)
void ED_curve_editnurb_load(Main *bmain, Object *obedit)
void CURVE_OT_match_texture_space(wmOperatorType *ot)
void CURVE_OT_duplicate(wmOperatorType *ot)
static wmOperatorStatus curve_decimate_exec(bContext *C, wmOperator *op)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
wmOperatorStatus WM_operator_flag_only_pass_through_on_press(wmOperatorStatus retval, const wmEvent *event)
MINLINE void copy_v3_v3(float r[3], const float a[3])
static void keyIndex_delBP(EditNurb *editnurb, BPoint *bp)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static const EnumPropertyItem * rna_curve_delete_type_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static wmOperatorStatus clear_tilt_exec(bContext *C, wmOperator *op)
static wmOperatorStatus switch_direction_exec(bContext *C, wmOperator *)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void CURVE_OT_tilt_clear(wmOperatorType *ot)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void CURVE_OT_vertex_add(wmOperatorType *ot)
static wmOperatorStatus make_segment_exec(bContext *C, wmOperator *op)
void CURVE_OT_extrude(wmOperatorType *ot)
static void rotate_direction_nurb(Nurb *nu)
bool ed_editnurb_extrude_flag(EditNurb *editnurb, eBezTriple_Flag flag)
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], float t)
float mat4_to_scale(const float mat[4][4])
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void ED_curve_nurb_vert_selected_find(Curve *cu, View3D *v3d, Nurb **r_nu, BezTriple **r_bezt, BPoint **r_bp)
void BKE_nurbList_free(ListBaseT< Nurb > *lb)
MINLINE float mul_project_m4_v3_zfac(const float mat[4][4], const float co[3]) ATTR_WARN_UNUSED_RESULT
static void switch_keys_direction(Curve *cu, Nurb *actnu)
static void key_to_bezt(float *key, BezTriple *basebezt, BezTriple *bezt)
static wmOperatorStatus set_radius_exec(bContext *C, wmOperator *op)
static void make_selection_list_nurb(View3D *v3d, ListBaseT< Nurb > *editnurb, ListBaseT< NurbSort > *nsortbase)
KeyBlock * BKE_keyblock_from_object(Object *ob)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void BKE_keyblock_convert_to_curve(KeyBlock *kb, Curve *cu, ListBaseT< Nurb > *nurb)
int ED_curve_updateAnimPaths(Main *bmain, Curve *cu)
bool ED_operator_editcurve(bContext *C)
static BezTriple * getKeyIndexOrig_bezt(EditNurb *editnurb, const BezTriple *bezt)
static void keyIndex_delBezt(EditNurb *editnurb, BezTriple *bezt)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
static wmOperatorStatus curve_smooth_weight_exec(bContext *C, wmOperator *)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
static bool curve_delete_vertices(Object *obedit, View3D *v3d)
bool BKE_nurb_order_clamp_u(Nurb *nu)
void ED_curve_keyindex_update_nurb(EditNurb *editnurb, Nurb *nu, Nurb *newnu)
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
void CURVE_OT_cyclic_toggle(wmOperatorType *ot)
void void void BLI_movelisttolist(ListBase *dst, ListBase *src) ATTR_NONNULL(1
int RNA_int_get(PointerRNA *ptr, const char *name)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void view3d_operator_needs_gpu(const bContext *C)
void CURVE_OT_smooth_weight(wmOperatorType *ot)
void ED_curve_beztcpy(EditNurb *editnurb, BezTriple *dst, BezTriple *src, int count)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
MINLINE int max_ii(int a, int b)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void CURVE_OT_spin(wmOperatorType *ot)
@ NURB_HANDLE_TEST_KNOT_OR_EACH
@ NURB_HANDLE_TEST_KNOT_ONLY
static wmOperatorStatus curve_smooth_tilt_exec(bContext *C, wmOperator *op)
void BKE_nurbList_flag_set(ListBaseT< Nurb > *editnurb, eBezTriple_Flag flag, bool set)
static int getKeyIndexOrig_keyIndex(EditNurb *editnurb, void *cv)
void ED_curve_editnurb_free(Object *obedit)
static wmOperatorStatus curve_smooth_radius_exec(bContext *C, wmOperator *op)
RegionView3D * ED_view3d_context_rv3d(bContext *C)
static void select_bpoints(BPoint *bp, const int stride, const int count, const bool selstatus, const eBezTriple_Flag flag, const bool hidden)
@ CURVE_MERGE_ERR_FEW_SELECTION
@ CURVE_MERGE_ERR_RESOLUTION_ALL
@ CURVE_MERGE_ERR_RESOLUTION_SOME
void BKE_nurb_project_2d(Nurb *nu)
void BKE_nurbList_handles_set(ListBaseT< Nurb > *editnurb, eNurbHandleTest_Mode handle_mode, eBezTriple_Handle code)
void MEM_delete_void(void *vmemh)
void ED_view3d_global_to_vector(const RegionView3D *rv3d, const float coord[3], float r_out[3])
void BKE_nurb_handle_calc(BezTriple *bezt, BezTriple *prev, BezTriple *next, bool is_fcurve, char smoothing)
ViewLayer * CTX_data_view_layer(const bContext *C)
void ED_outliner_select_sync_from_object_tag(bContext *C)
void BKE_curve_nurb_vert_active_validate(Curve *cu)
std::optional< Array< bool > > BKE_keyblock_get_dependent_keys(const Key *key, int index)
MINLINE void mul_v3_fl(float r[3], float f)
static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
static void ed_surf_delete_selected(Object *obedit)
Vector< T * > listbase_to_vector(ListBase &list)
void BKE_curve_nurb_active_set(Curve *cu, const Nurb *nu)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
static NurbDim editnurb_find_max_points_num(const EditNurb *editnurb)
static void keyIndex_swap(EditNurb *editnurb, void *a, void *b)
void CURVE_OT_decimate(wmOperatorType *ot)
void BKE_nurb_knot_calc_v(Nurb *nu)
void CURVE_OT_delete(wmOperatorType *ot)
MINLINE void sub_v3_v3(float r[3], const float a[3])
static void keyIndex_updateBezt(EditNurb *editnurb, BezTriple *bezt, BezTriple *newbezt, int count)
static void switchdirection_knots(float *base, int tot)
static bool match_texture_space_poll(bContext *C)
static int sel_to_copy_ints(const BPoint *bp, const int next_j, const int max_j, const int next_i, const int max_i, const uint8_t flag, int copy_intervals[], int *interval_count, bool *out_is_first_sel)
void BKE_nurb_bezierPoints_add(Nurb *nu, int number)
PropertyRNA * RNA_def_float_factor(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)
void mul_m4_v3(const float M[4][4], float r[3])
void CURVE_OT_normals_make_consistent(wmOperatorType *ot)
AnimData * BKE_animdata_from_id(const ID *id)
static wmOperatorStatus spin_invoke(bContext *C, wmOperator *op, const wmEvent *)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
KeyBlock * BKE_keyblock_find_by_index(Key *key, int index)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void CURVE_OT_smooth_tilt(wmOperatorType *ot)
@ SCE_SNAP_TARGET_NOT_ACTIVE
void CURVE_OT_dissolve_verts(wmOperatorType *ot)
bool ED_curve_nurb_select_check(const View3D *v3d, const Nurb *nu)
void CURVE_OT_subdivide(wmOperatorType *ot)
static wmOperatorStatus subdivide_exec(bContext *C, wmOperator *op)
static bool test_bezt_is_sel_any(const void *bezt_v, void *user_data)
void * MEM_dupalloc_void(const void *vmemh) ATTR_WARN_UNUSED_RESULT
KeyBlock * ED_curve_get_edit_shape_key(const Curve *cu)
void CURVE_OT_hide(wmOperatorType *ot)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
static void curve_smooth_value(ListBaseT< Nurb > *editnurb, const int bezt_offsetof, const int bp_offset)
static void smooth_single_bp(BPoint *bp, const BPoint *bp_orig_prev, const BPoint *bp_orig_next, float factor)
void CURVE_OT_spline_weight_set(wmOperatorType *ot)
void BKE_nurb_handles_calc(Nurb *nu)
void CURVE_OT_radius_set(wmOperatorType *ot)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void DEG_id_tag_update(ID *id, unsigned int flags)
MINLINE void swap_v3_v3(float a[3], float b[3])
void BKE_report(ReportList *reports, eReportType type, const char *message)
wmOperatorStatus ED_curve_join_objects_exec(bContext *C, wmOperator *op)
BMesh const char void * data
static void keyIndex_delNurbList(EditNurb *editnurb, ListBaseT< Nurb > *nubase)
void BKE_curve_editNurb_keyIndex_delCV(CVKeyIndexMap *keyindex, const void *cv)
static void rotateflagNurb(ListBaseT< Nurb > *editnurb, eBezTriple_Flag flag, const float cent[3], const float rotmat[3][3])
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
void CURVE_OT_switch_direction(wmOperatorType *ot)
static wmOperatorStatus curve_extrude_exec(bContext *C, wmOperator *)
static wmOperatorStatus toggle_cyclic_invoke(bContext *C, wmOperator *op, const wmEvent *)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void ed_editnurb_translate_flag(ListBaseT< Nurb > *editnurb, eBezTriple_Flag flag, const float vec[3], bool is_2d)
Object * CTX_data_edit_object(const bContext *C)
static void interp_bpoint(BPoint *bp_target, const BPoint *bp_a, const BPoint *bp_b, const float factor)
@ SCE_SNAP_INDIVIDUAL_PROJECT
static bool isNurbselU(Nurb *nu, int *v, eBezTriple_Flag flag)
static void keyIndex_updateCV(EditNurb *editnurb, char *cv, char *newcv, int count, int size)
static Vector< FCurve * > curve_rename_fcurves(Curve *cu, Span< FCurve * > orig_curves)
wmOperatorStatus WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void BKE_displist_minmax(const ListBaseT< DispList > *dispbase, float min[3], float max[3])
bool ED_operator_editsurfcurve(bContext *C)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
void unit_m4(float m[4][4])
CVKeyIndexMap * ED_curve_keyindex_hash_duplicate(CVKeyIndexMap *keyindex)
static wmOperatorStatus set_goal_weight_exec(bContext *C, wmOperator *op)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
BezTriple * BKE_nurb_bezt_get_next(Nurb *nu, BezTriple *bezt)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], const int dist_px, const SelectPick_Params ¶ms)
ATTR_WARN_UNUSED_RESULT const size_t num
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void CURVE_OT_smooth_radius(wmOperatorType *ot)
static void init_editNurb_keyIndex(EditNurb *editnurb, ListBaseT< Nurb > *origBase)
void CURVE_OT_separate(wmOperatorType *ot)
ListBaseT< Nurb > * object_editcurve_get(Object *ob)
static CVKeyIndex * popCVKeyIndex(EditNurb *editnurb, const void *cv)
MINLINE void zero_v3(float r[3])
void CURVE_OT_split(wmOperatorType *ot)
static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
static int merge_nurb(View3D *v3d, Object *obedit)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
static wmOperatorStatus curve_dissolve_exec(bContext *C, wmOperator *)
static wmOperatorStatus reveal_exec(bContext *C, wmOperator *op)
static wmOperatorStatus curve_split_exec(bContext *C, wmOperator *op)
static void keyIndex_delNurb(EditNurb *editnurb, Nurb *nu)
Nurb * BKE_nurb_duplicate(const Nurb *nu)
const EnumPropertyItem rna_enum_transform_mode_type_items[]
MINLINE float normalize_v3_v3(float r[3], const float a[3])
static const EnumPropertyItem curve_delete_type_items[]
static wmOperatorStatus curve_delete_exec(bContext *C, wmOperator *op)
static void smooth_single_bezt(BezTriple *bezt, const BezTriple *bezt_orig_prev, const BezTriple *bezt_orig_next, float factor)
void CURVE_OT_shade_smooth(wmOperatorType *ot)
static bool nurb_bezt_flag_any(const Nurb *nu, const char flag_test)
void BKE_nurbList_handles_recalculate(ListBaseT< Nurb > *editnurb, bool calc_length, eBezTriple_Flag flag)
MINLINE float normalize_v3(float n[3])
static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
MINLINE void add_v3_v3(float r[3], const float a[3])
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
void BKE_fcurve_free(FCurve *fcu)
PropertyRNA * RNA_def_float_vector_xyz(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
static wmOperatorStatus duplicate_exec(bContext *C, wmOperator *op)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, View3D *v3d, const float location_init[3])
Main * CTX_data_main(const bContext *C)
void unit_m3(float m[3][3])
void CURVE_OT_reveal(wmOperatorType *ot)
void BKE_curve_editNurb_keyIndex_free(CVKeyIndexMap **keyindex)
bool BKE_curve_nurb_vert_active_get(Curve *cu, Nurb **r_nu, void **r_vert)
int BKE_keyblock_curve_element_count(const ListBaseT< Nurb > *nurb)
static bool calc_duplicate_actvert(const ListBaseT< Nurb > *editnurb, const ListBaseT< Nurb > *newnurb, Curve *cu, int start, int end, int vert)
bool select_beztriple(BezTriple *bezt, bool selstatus, eBezTriple_Flag flag, eVisible_Types hidden)
void CURVE_OT_smooth(wmOperatorType *ot)
void BKE_nurb_handle_calc_simple_auto(Nurb *nu, BezTriple *bezt)
static BPoint * getKeyIndexOrig_bp(EditNurb *editnurb, BPoint *bp)
bool ED_curve_pick_vert_ex(ViewContext *vc, bool select, int dist_px, Nurb **r_nurb, BezTriple **r_bezt, BPoint **r_bp, short *r_handle, Base **r_base)
bool ED_curve_select_check(const View3D *v3d, const EditNurb *editnurb)
Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
void CURVE_OT_shade_flat(wmOperatorType *ot)
static wmOperatorStatus set_spline_type_exec(bContext *C, wmOperator *op)
void ED_curve_editnurb_make(Object *obedit)
bool BKE_nurb_type_convert(Nurb *nu, eNurbType type, bool use_handles, const char **r_err_msg)
static CVKeyIndex * init_cvKeyIndex(void *cv, int key_index, int nu_index, int pt_index, int vertex_index)
Vector< Base * > BKE_view_layer_array_from_bases_in_edit_mode_unique_data(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
static bool isNurbselV(Nurb *nu, int *u, eBezTriple_Flag flag)
MINLINE float interpf(float target, float origin, float t)
void ED_view3d_win_to_3d_int(const View3D *v3d, const ARegion *region, const float depth_pt[3], const int mval[2], float r_out[3])
bool select_bpoint(BPoint *bp, bool selstatus, eBezTriple_Flag flag, bool hidden)
void DEG_relations_tag_update(Main *bmain)
static void fcurve_path_rename(const char *orig_rna_path, const char *rna_path, const Span< FCurve * > orig_curves, Set< FCurve * > &processed_fcurves)
Scene * CTX_data_scene(const bContext *C)
static wmOperatorStatus match_texture_space_exec(bContext *C, wmOperator *)
void BKE_nurb_handle_calc_simple(Nurb *nu, BezTriple *bezt)
static CVKeyIndex * getCVKeyIndex(EditNurb *editnurb, const void *cv)
void CURVE_OT_spline_type_set(wmOperatorType *ot)
BPoint * BKE_nurb_bpoint_get_next(Nurb *nu, BPoint *bp)
static void keyIndex_updateBP(EditNurb *editnurb, BPoint *bp, BPoint *newbp, int count)
@ OPTYPE_DEPENDS_ON_CURSOR
static wmOperatorStatus set_handle_type_exec(bContext *C, wmOperator *op)
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void CURVE_OT_handle_type_set(wmOperatorType *ot)
static void bezt_to_key(BezTriple *bezt, float *key)
int ED_curve_nurb_select_count(const View3D *v3d, const Nurb *nu)
void * BKE_curve_vert_active_get(Curve *cu)
static void weightflagNurb(ListBaseT< Nurb > *editnurb, short flag, float w)
bool ED_curve_deselect_all(EditNurb *editnurb)
void BKE_nurb_knot_calc_u(Nurb *nu)
bool ed_editnurb_spin(float viewmat[4][4], View3D *v3d, Object *obedit, const float axis[3], const float cent[3])
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
bool ED_operator_editsurf(bContext *C)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
static int * init_index_map(Object *obedit, int *r_old_totvert)
static void calc_keyHandles(ListBaseT< Nurb > *nurb, float *key)
Nurb * BKE_nurb_copy(Nurb *src, int pntsu, int pntsv)
static bool merge_2_nurb(Curve *cu, ListBaseT< Nurb > *editnurb, Nurb *nu1, Nurb *nu2)
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
static void calc_duplicate_actnurb(const ListBaseT< Nurb > *editnurb, const ListBaseT< Nurb > *newnurb, Curve *cu)
static bool curve_is_animated(Curve *cu)
void WM_cursor_wait(bool val)
ID * BKE_id_copy(Main *bmain, const ID *id)
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)
Object * CTX_data_active_object(const bContext *C)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BKE_curve_decimate_nurb(Nurb *nu, unsigned int resolu, float error_sq_max, unsigned int error_target_len)
static bool is_u_selected(Nurb *nu, int u)
float RNA_float_get(PointerRNA *ptr, const char *name)
static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBaseT< Nurb > *newnurb, const eBezTriple_Flag flag, const bool split)
static wmOperatorStatus spin_exec(bContext *C, wmOperator *op)
View3D * CTX_wm_view3d(const bContext *C)
Map< const void *, struct CVKeyIndex * > CVKeyIndexMap
void invert_m4_m4_safe_ortho(float inverse[4][4], const float mat[4][4])
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
static void calc_shapeKeys(Object *obedit, ListBaseT< Nurb > *newnurbs)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static void keyData_switchDirectionNurb(Curve *cu, Nurb *nu)
void ed_dissolve_bez_segment(BezTriple *bezt_prev, BezTriple *bezt_next, const Nurb *nu, const Curve *cu, const uint span_len, const uint span_step[2])
bool curve_toggle_cyclic(View3D *v3d, ListBaseT< Nurb > *editnurb, int direction)
bool BKE_nurb_order_clamp_v(Nurb *nu)
void BKE_nurb_direction_switch(Nurb *nu)
void selectend_nurb(Object *obedit, enum eEndPoint_Types selfirst, bool doswap, bool selstatus)
void BKE_nurb_free(Nurb *nu)
void BKE_curve_dimension_update(Curve *cu)
static wmOperatorStatus curve_normals_make_consistent_exec(bContext *C, wmOperator *op)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ListBaseT< FCurve > drivers
ListBaseT< DispList > disp
float texspace_location[3]
ListBaseT< KeyBlock > block
ShapekeyContainerType type
ListBaseT< Object > objects
bke::ObjectRuntime * runtime
struct ToolSettings * toolsettings
eHandleDisplay handle_display
void op_enum(StringRefNull opname, StringRefNull propname, IDProperty *properties, wm::OpCallContext context, eUI_Item_Flag flag, const int active=-1)
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type