33#define DNA_DEPRECATED_ALLOW
75 Curve *curve = id_cast<Curve *>(
id);
81 std::optional<Library *> owner_library,
86 Curve *curve_dst = id_cast<Curve *>(id_dst);
87 const Curve *curve_src = id_cast<const Curve *>(id_src);
89 curve_dst->
nurb.clear_no_delete();
92 curve_dst->
mat = MEM_dupalloc(curve_src->
mat);
94 curve_dst->
str = MEM_dupalloc(curve_src->
str);
96 curve_dst->
tb = MEM_dupalloc(curve_src->
tb);
106 reinterpret_cast<ID **
>(&curve_dst->
key),
121 Curve *curve = id_cast<Curve *>(
id);
135 MEM_SAFE_DELETE(curve->
mat);
136 MEM_SAFE_DELETE(curve->
str);
137 MEM_SAFE_DELETE(curve->
strinfo);
138 MEM_SAFE_DELETE(curve->
tb);
149 for (
int i = 0; i < curve->
totcol; i++) {
160 Curve *cu = id_cast<Curve *>(
id);
207 Curve *cu = id_cast<Curve *>(
id);
212 if ((cu->
len_char32 == 0) && (cu->
str !=
nullptr) && (cu->
str[0] !=
'\0')) {
232 if (is_font ==
false) {
236 cu->
nurb.first_ = cu->
nurb.last_ =
nullptr;
238 if (cu->
str ==
nullptr) [[unlikely]] {
242 if (cu->
strinfo ==
nullptr) [[unlikely]] {
288 if (is_font ==
false) {
301 .id_code = Curve::id_type,
305 .struct_size =
sizeof(
Curve),
307 .name_plural =
N_(
"curves"),
310 .asset_type_info =
nullptr,
315 .make_local =
nullptr,
317 .foreach_cache =
nullptr,
318 .foreach_path =
nullptr,
319 .foreach_working_space_color =
nullptr,
320 .foreach_asset_weak_reference =
nullptr,
321 .owner_pointer_get =
nullptr,
325 .blend_read_after_liblink =
nullptr,
327 .blend_read_undo_preserve =
nullptr,
329 .lib_override_apply_post =
nullptr,
374 MEM_delete(*keyindex);
406 memcpy(cu->
str,
str, len_bytes + 1);
412 cu->
strinfo = MEM_new_array<CharInfo>(len_char32 + 1,
"strinfo new");
416 cu->
tb[0].
w = cu->
tb[0].
h = 0.0;
464 for (
Nurb &nu : *nurbs) {
481 if (dimension_update) {
498 float texspace_location[3], texspace_size[3];
501 texspace_size[0] = (
bounds->max[0] -
bounds->min[0]) / 2.0f;
502 texspace_size[1] = (
bounds->max[1] -
bounds->min[1]) / 2.0f;
503 texspace_size[2] = (
bounds->max[2] -
bounds->min[2]) / 2.0f;
505 for (
int a = 0; a < 3; a++) {
506 if (texspace_size[a] == 0.0f) {
507 texspace_size[a] = 1.0f;
509 else if (texspace_size[a] > 0.0f && texspace_size[a] < 0.00001f) {
510 texspace_size[a] = 0.00001f;
512 else if (texspace_size[a] < 0.0f && texspace_size[a] > -0.00001f) {
513 texspace_size[a] = -0.00001f;
537 for (
Nurb &nu : *nurb) {
541 if (
index - tot < tot_nu) {
547 tot_nu = nu.pntsu * nu.pntsv;
548 if (
index - tot < tot_nu) {
563 for (
const Nurb &nu : *nurb) {
568 tot += nu.pntsu * nu.pntsv;
579 for (
Nurb &nu : *nurb) {
584 tot += nu.pntsu * nu.pntsv;
600 MEM_delete(nu->
bezt);
625 for (
Nurb &nu : lb->items_mutable()) {
628 lb->clear_no_delete();
636 newnu = MEM_new<Nurb>(
"duplicateNurb");
637 if (newnu ==
nullptr) {
673 Nurb *newnu = MEM_new<Nurb>(
"copyNurb");
677 std::swap(pntsu, pntsv);
679 newnu->
pntsu = pntsu;
680 newnu->
pntsv = pntsv;
701 for (
const Nurb &nu : *lb2) {
717 bezt->
vec[0][2] = 0.0;
718 bezt->
vec[1][2] = 0.0;
719 bezt->
vec[2][2] = 0.0;
745 float radius_vector[3];
746 radius_vector[0] = radius_vector[1] = radius_vector[2] = bezt->
radius;
766 if (nu->
pntsv == 1 && use_radius) {
767 float radius_vector[3];
768 radius_vector[0] = radius_vector[1] = radius_vector[2] = bp->
radius;
791 int resolu = resolution ? resolution : nu->
resolu;
792 int pntsu = nu->
pntsu;
793 float *points, *pntsit, *prevpntsit;
800 prevbp = nu->
bp + (nu->
pntsu - 1);
831 for (
int j = 0; j < 3; j++) {
841 prevpntsit = pntsit = points;
856 if (nu->
pntsv == 1) {
863 b = pntsu * resolu + 1;
864 prevpntsit = points + 3 * (pntsu * resolu - 1);
868 b = (pntsu - 1) * resolu;
893 for (i = 0, bp = &nu->
bp[nu->
pntsu]; i < number; i++, bp++) {
908 for (i = 0, bezt = &nu->
bezt[nu->
pntsu]; i < number; i++, bezt++) {
917 const int totu = nu->
pntsu;
918 const int totv = nu->
pntsv;
923 else if (u < 0 || u >= totu) {
934 return (
v * totu) + u;
939 const int totu = nu->
pntsu;
940 const int totv = nu->
pntsv;
942 *r_u = (
index % totu);
943 *r_v = (
index / totu) % totv;
954 bezt_next = nu->
bezt;
961 bezt_next = bezt + 1;
973 if (bp == &nu->
bp[nu->
pntsu - 1]) {
995 if (bezt == nu->
bezt) {
1000 bezt_prev =
nullptr;
1004 bezt_prev = bezt - 1;
1019 bp_prev = &nu->
bp[nu->
pntsu - 1];
1035 float dir_prev[3], dir_next[3];
1049 float dir_prev[3], dir_next[3];
1075 float dir_mid[3], tvec[3];
1112 float dir_prev[3] = {0.0f}, dir_next[3] = {0.0f};
1126 float dir_mid[3], tvec[3];
1137static void calcknots(
float *knots,
const int pnts,
const short order,
const short flag)
1143 const int repeat_inner = is_bezier ? order - 1 : 1;
1145 const int head = is_end_point ? (order - (is_cyclic ? 1 : 0)) :
1146 (is_bezier ?
min_ii(2, repeat_inner) : 1);
1149 const int tail = is_cyclic ? 2 * order - 1 : (is_end_point ? order : 0);
1151 const int knot_count = pnts + order + (is_cyclic ? order - 1 : 0);
1154 float current = 0.0f;
1156 const int offset = is_end_point && is_cyclic ? 1 : 0;
1162 for (
const int i :
IndexRange(offset, knot_count - offset - tail)) {
1171 const int tail_index = knot_count - tail;
1173 knots[tail_index + i] = current + (knots[i] - knots[0]);
1225 float t,
short order,
int pnts,
const float *knots,
float *basis,
int *start,
int *end)
1228 int i, i1 = 0, i2 = 0, j, orderpluspnts, opp2, o2;
1230 orderpluspnts = order + pnts;
1231 opp2 = orderpluspnts - 1;
1237 else if (t > knots[opp2]) {
1243 for (i = 0; i < opp2; i++) {
1244 if (knots[i] != knots[i + 1] && t >= knots[i] && t <= knots[i + 1]) {
1247 i1 = std::max(i1, 0);
1262 for (j = 2; j <= order; j++) {
1264 if (i2 + j >= orderpluspnts) {
1268 for (i = i1; i <= i2; i++) {
1269 if (basis[i] != 0.0f) {
1270 d = ((t - knots[i]) * basis[i]) / (knots[i + j - 1] - knots[i]);
1276 if (basis[i + 1] != 0.0f) {
1277 e = ((knots[i + j] - t) * basis[i + 1]) / (knots[i + j] - knots[i + 1]);
1290 for (i = i1; i <= i2; i++) {
1291 if (basis[i] > 0.0f) {
1293 if (*start == 1000) {
1303 float *basisu, *basis, *basisv, *sum, *fp, *
in;
1304 float u,
v, ustart, uend, ustep, vstart, vend, vstep, sumdiv;
1305 int i, j, iofs, jofs, cycl,
len, curu, curv;
1306 int istart, iend, jsta, jen, *jstart, *jend, ratcomp;
1308 int totu = nu->
pntsu * resolu, totv = nu->
pntsv * resolv;
1319 if (coord_array ==
nullptr) {
1335 if (bp->
vec[3] != 1.0f) {
1343 ustart = fp[nu->
orderu - 1];
1348 uend = fp[nu->
pntsu];
1355 vstart = fp[nu->
orderv - 1];
1361 vend = fp[nu->
pntsv];
1401 jsta = jstart[curv];
1408 for (j = jsta; j <= jen; j++) {
1410 if (j >= nu->
pntsv) {
1411 jofs = (j - nu->
pntsv);
1416 bp = nu->
bp + nu->
pntsu * jofs + istart - 1;
1418 for (i = istart; i <= iend; i++, fp++) {
1419 if (i >= nu->
pntsu) {
1420 iofs = i - nu->
pntsu;
1421 bp = nu->
bp + nu->
pntsu * jofs + iofs;
1428 *fp = basisu[i] * basis[j] * bp->
vec[3];
1432 *fp = basisu[i] * basis[j];
1439 for (j = jsta; j <= jen; j++) {
1440 for (i = istart; i <= iend; i++, fp++) {
1450 for (j = jsta; j <= jen; j++) {
1452 if (j >= nu->
pntsv) {
1453 jofs = (j - nu->
pntsv);
1458 bp = nu->
bp + nu->
pntsu * jofs + istart - 1;
1460 for (i = istart; i <= iend; i++, fp++) {
1461 if (i >= nu->
pntsu) {
1462 iofs = i - nu->
pntsu;
1463 bp = nu->
bp + nu->
pntsu * jofs + iofs;
1479 if (rowstride != 0) {
1480 in =
reinterpret_cast<float *
>((
reinterpret_cast<uchar *
>(
in)) +
1481 (rowstride - 3 * totv *
sizeof(*in)));
1496 float *radius_array,
1497 float *weight_array,
1501 const float eps = 1e-6f;
1503 float u, ustart, uend, ustep, sumdiv;
1504 float *basisu, *sum, *fp;
1505 float *coord_fp = coord_array, *tilt_fp = tilt_array, *radius_fp = radius_array,
1506 *weight_fp = weight_array;
1507 int i,
len, istart, iend, cycl;
1509 if (nu->
knotsu ==
nullptr) {
1515 if (coord_array ==
nullptr) {
1534 ustart = fp[nu->
orderu - 1];
1539 uend = fp[nu->
pntsu];
1559 bp = nu->
bp + istart - 1;
1560 for (i = istart; i <= iend; i++, fp++) {
1561 if (i >= nu->
pntsu) {
1562 bp = nu->
bp + (i - nu->
pntsu);
1568 *fp = basisu[i] * bp->
vec[3];
1571 if ((sumdiv != 0.0f) && (sumdiv < 1.0f - eps || sumdiv > 1.0f +
eps)) {
1574 for (i = istart; i <= iend; i++, fp++) {
1583 bp = nu->
bp + istart - 1;
1584 for (i = istart; i <= iend; i++, fp++) {
1585 if (i >= nu->
pntsu) {
1586 bp = nu->
bp + (i - nu->
pntsu);
1596 (*tilt_fp) += (*fp) * bp->
tilt;
1600 (*radius_fp) += (*fp) * bp->
radius;
1604 (*weight_fp) += (*fp) * bp->
weight;
1609 coord_fp =
static_cast<float *
> POINTER_OFFSET(coord_fp, stride);
1615 radius_fp =
static_cast<float *
> POINTER_OFFSET(radius_fp, stride);
1618 weight_fp =
static_cast<float *
> POINTER_OFFSET(weight_fp, stride);
1631 const bool is_cyclic,
1632 const bool use_cyclic_duplicate_endpoint)
1634 const uint segments = bezt_array_len - (is_cyclic ? 0 : 1);
1635 const uint points_len = (segments * resolu) + (is_cyclic ? (use_cyclic_duplicate_endpoint) : 1);
1640 const uint bezt_array_len,
1642 const bool is_cyclic,
1643 const bool use_cyclic_duplicate_endpoint,
1650 bezt_array_len, resolu, is_cyclic, use_cyclic_duplicate_endpoint);
1651 float *r_points_offset = r_points;
1653 const uint resolu_stride = resolu * stride;
1654 const uint bezt_array_last = bezt_array_len - 1;
1656 for (
uint i = 0; i < bezt_array_last; i++) {
1657 const BezTriple *bezt_curr = &bezt_array[i];
1658 const BezTriple *bezt_next = &bezt_array[i + 1];
1660 bezt_curr->
vec[2][axis],
1661 bezt_next->
vec[0][axis],
1662 bezt_next->
vec[1][axis],
1666 r_points_offset =
static_cast<float *
> POINTER_OFFSET(r_points_offset, resolu_stride);
1670 const BezTriple *bezt_curr = &bezt_array[bezt_array_last];
1671 const BezTriple *bezt_next = &bezt_array[0];
1673 bezt_curr->
vec[2][axis],
1674 bezt_next->
vec[0][axis],
1675 bezt_next->
vec[1][axis],
1679 r_points_offset =
static_cast<float *
> POINTER_OFFSET(r_points_offset, resolu_stride);
1680 if (use_cyclic_duplicate_endpoint) {
1681 *r_points_offset = *r_points;
1682 r_points_offset =
static_cast<float *
> POINTER_OFFSET(r_points_offset, stride);
1686 float *r_points_last =
static_cast<float *
> POINTER_OFFSET(r_points,
1687 bezt_array_last * resolu_stride);
1688 *r_points_last = bezt_array[bezt_array_last].
vec[1][axis];
1689 r_points_offset =
static_cast<float *
> POINTER_OFFSET(r_points_offset, stride);
1697 float q0,
float q1,
float q2,
float q3,
float *p,
int it,
int stride)
1699 float rt0, rt1, rt2, rt3, f;
1704 rt1 = 3.0f * (q1 - q0) / f;
1706 rt2 = 3.0f * (q0 - 2.0f * q1 + q2) / f;
1708 rt3 = (q3 - q0 + 3.0f * (q1 - q2)) / f;
1711 q1 = rt1 + rt2 + rt3;
1712 q2 = 2 * rt2 + 6 * rt3;
1715 for (a = 0; a <= it; a++) {
1725 float q0,
float q1,
float q2,
float q3,
float *p,
int it,
int stride)
1727 float rt0, rt1, rt2, f;
1730 f = 1.0f /
float(it);
1732 rt0 = 3.0f * (q1 - q0);
1733 rt1 = f * (3.0f * (q3 - q0) + 9.0f * (q1 - q2));
1734 rt2 = 6.0f * (q0 + q2) - 12.0f * q1;
1737 q1 = f * (rt1 + rt2);
1738 q2 = 2.0f * f * rt1;
1740 for (a = 0; a <= it; a++) {
1760 for (
int a = 0; a <= it; a++) {
1763 for (
int i = 0; i < 3; i++) {
1764 p[i] = (-6.0f * t + 6.0f) * p0[i] + (18.0f * t - 12.0f) * p1[i] +
1765 (-18.0f * t + 6.0f) * p2[i] + (6.0f * t) * p3[i];
1790 deler = (v1[cox] -
v2[cox]) * (v3[coy] - v4[coy]) - (v3[cox] - v4[cox]) * (v1[coy] -
v2[coy]);
1791 if (deler == 0.0f) {
1795 *lambda = (v1[coy] - v3[coy]) * (v3[cox] - v4[cox]) - (v1[cox] - v3[cox]) * (v3[coy] - v4[coy]);
1796 *lambda = -(*lambda / deler);
1798 deler = v3[coy] - v4[coy];
1800 deler = v3[cox] - v4[cox];
1801 *mu = -(*lambda * (
v2[cox] - v1[cox]) + v1[cox] - v3[cox]) / deler;
1804 *mu = -(*lambda * (
v2[coy] - v1[coy]) + v1[coy] - v3[coy]) / deler;
1806 vec[cox] = *lambda * (
v2[cox] - v1[cox]) + v1[cox];
1807 vec[coy] = *lambda * (
v2[coy] - v1[coy]) + v1[coy];
1809 if (*lambda >= 0.0f && *lambda <= 1.0f && *mu >= 0.0f && *mu <= 1.0f) {
1810 if (*lambda == 0.0f || *lambda == 1.0f || *mu == 0.0f || *mu == 1.0f) {
1823 float min,
max, vec[3], hvec1[3], hvec2[3], lab, mu;
1824 int nr, links = 0, rechts = 0, mode;
1829 hvec1[0] = bevp->
vec[0];
1830 hvec1[1] = bevp->
vec[1];
1840 prevbevp = bevp + (nr - 1);
1850 if (
min <= hvec1[1] &&
max >= hvec1[1]) {
1852 mode =
cu_isectLL(prevbevp->
vec, bevp->
vec, hvec1, hvec2, 0, 1, &lab, &mu, vec);
1856 if (mode >= 0 && lab != 0.0f) {
1857 if (vec[0] < hvec1[0]) {
1870 return (links & 1) && (rechts & 1);
1882 *x2 =
static_cast<BevelSort *
>(
const_cast<void *
>(a2));
1884 if (x1->
left > x2->left) {
1887 if (x1->
left < x2->left) {
1896 float x1,
float y1,
float x2,
float y2,
float *r_sina,
float *r_cosa)
1898 float t01, t02, x3, y3;
1900 t01 =
sqrtf(x1 * x1 + y1 * y1);
1901 t02 =
sqrtf(x2 * x2 + y2 * y2);
1914 t02 = x1 * x2 + y1 * y2;
1915 if (
fabsf(t02) >= 1.0f) {
1929 if (x3 == 0 && y3 == 0) {
1934 t01 =
sqrtf(x3 * x3 + y3 * y3);
1939 *r_sina = -y3 / t02;
1947 float *radius_array,
1948 float *weight_array,
1953 float fac, dfac, t[4];
1956 if (tilt_array ==
nullptr && radius_array ==
nullptr) {
1963 if (prevbezt == nu->
bezt) {
1972 pprev = prevbezt - 1;
1989 dfac = 1.0f /
float(resolu);
1991 for (a = 0; a < resolu; a++, fac += dfac) {
1995 *tilt_array = prevbezt->
tilt +
1996 (bezt->
tilt - prevbezt->
tilt) * (3.0f * fac * fac - 2.0f * fac * fac * fac);
2000 *tilt_array = t[0] * pprev->
tilt + t[1] * prevbezt->
tilt + t[2] * bezt->
tilt +
2004 tilt_array =
static_cast<float *
> POINTER_OFFSET(tilt_array, stride);
2013 (3.0f * fac * fac - 2.0f * fac * fac * fac);
2021 *radius_array = t[0] * pprev->
radius + t[1] * prevbezt->
radius + t[2] * bezt->
radius +
2025 radius_array =
static_cast<float *
> POINTER_OFFSET(radius_array, stride);
2031 (3.0f * fac * fac - 2.0f * fac * fac * fac);
2033 weight_array =
static_cast<float *
> POINTER_OFFSET(weight_array, stride);
2046 const bool is_cyclic = bl->
poly != -1;
2050 bevp1 = bevp2 + (bl->
nr - 1);
2084 if (is_cyclic ==
false) {
2110 bevp1 = bevp2 + (bl->
nr - 1);
2132 bevp1 = bevp2 + (bl->
nr - 1);
2154 float bevp0_quat[4];
2157 for (a = 0; a < smooth_iter; a++) {
2159 bevp1 = bevp2 + (bl->
nr - 1);
2164 if (bl->
poly == -1) {
2181 float zaxis[3] = {0, 0, 1},
cross[3], q2[4];
2236 const bool is_cyclic = bl->
poly != -1;
2248 const int nr_init = bl->
nr - (is_cyclic ? 1 : 2);
2253 bevp1 = bevp2 + (bl->
nr - 1);
2259 if (nr >= nr_init) {
2272 if (bl->
poly != -1) {
2285 float vec_1[3] = {0, 1, 0}, vec_2[3] = {0, 1, 0},
angle, ang_fac, cross_tmp[3];
2291 bevp_first += bl->
nr - 1;
2292 bevp_last = bevp_first;
2320 bevp1 = bevp2 + (bl->
nr - 1);
2346 bevp1 = bevp2 + (bl->
nr - 1);
2364 bevp1 = bevp2 + (bl->
nr - 1);
2381 bevp1 = bevp2 + (bl->
nr - 1);
2390 const float zero[3] = {0, 0, 0};
2404 switch (twist_mode) {
2453 const float x1 = bevp1->
vec[0] - bevp2->
vec[0];
2454 const float y1 = bevp1->
vec[1] - bevp2->
vec[1];
2472 if (bl->
poly != -1) {
2474 bevp1 = bevp2 + (bl->
nr - 1);
2487 const float x1 = bevp1->
vec[0] - bevp0->
vec[0];
2488 const float x2 = bevp1->
vec[0] - bevp2->
vec[0];
2489 const float y1 = bevp1->
vec[1] - bevp0->
vec[1];
2490 const float y2 = bevp1->
vec[1] - bevp2->
vec[1];
2506 if (bl->
poly == -1) {
2519 bevp += (bl->
nr - 1);
2529 if (nu->
pntsu > 1) {
2534 last_bevp = first_bevp + (bl->
nr - 1);
2546 for (
BevList &bl : bev->items_mutable()) {
2547 if (bl.seglen !=
nullptr) {
2548 MEM_delete(bl.seglen);
2550 if (bl.segbevcount !=
nullptr) {
2551 MEM_delete(bl.segbevcount);
2553 if (bl.bevpoints !=
nullptr) {
2554 MEM_delete(bl.bevpoints);
2559 bev->clear_no_delete();
2575 BevPoint *bevp2, *bevp1 =
nullptr, *bevp0;
2576 const float threshold = 0.00001f;
2578 float *seglen =
nullptr;
2580 int a,
b, nr, poly, resolu = 0,
len = 0, segcount;
2582 bool do_tilt, do_radius, do_weight;
2583 bool is_editmode =
false;
2584 ListBaseT<BevList> *bev;
2587 const bool need_seglen =
ELEM(
2606 for (
const Nurb &nu : *nurbs) {
2607 if (nu.hide && is_editmode) {
2614 BevList *bl = MEM_new<BevList>(
"makeBevelList1");
2644 BevList *bl = MEM_new<BevList>(__func__);
2668 if (seglen !=
nullptr &&
len != 0) {
2672 if (*seglen > threshold) {
2692 len = segcount * resolu + 1;
2694 BevList *bl = MEM_new<BevList>(__func__);
2710 if (seglen !=
nullptr) {
2719 prevbezt = nu.bezt + (nu.pntsu - 1);
2742 if (seglen !=
nullptr) {
2747 if (bevp->
offset > threshold) {
2758 for (j = 0; j < 3; j++) {
2760 prevbezt->
vec[2][j],
2772 do_tilt ? &bevp->
tilt :
nullptr,
2773 do_radius ? &bevp->
radius :
nullptr,
2774 do_weight ? &bevp->
weight :
nullptr,
2789 if (seglen !=
nullptr) {
2792 for (j = 0; j < resolu; j++) {
2797 if (bevp->
offset > threshold) {
2827 if (nu.pntsv == 1) {
2828 len = (resolu * segcount);
2830 BevList *bl = MEM_new<BevList>(__func__);
2848 do_tilt ? &bevp->
tilt :
nullptr,
2849 do_radius ? &bevp->
radius :
nullptr,
2850 do_weight ? &bevp->
weight :
nullptr,
2855 if (seglen !=
nullptr) {
2864 for (j = 0; j < ((nr == 1) ? (resolu - 1) : resolu); j++) {
2866 if (bevp->
offset > threshold) {
2893 const float threshold_resolu = 0.00001f / resolu;
2894 const bool is_cyclic = bl.poly != -1;
2897 bevp1 = bl.bevpoints;
2898 bevp0 = bevp1 + (nr - 1);
2901 bevp0 = bl.bevpoints;
2907 if (seglen !=
nullptr) {
2909 bevp0->dupe_tag =
true;
2915 bevp0->dupe_tag =
true;
2924 for (
BevList &bl : bev->items_mutable()) {
2925 if (bl.nr == 0 || bl.dupe_nr == 0) {
2929 nr = bl.nr - bl.dupe_nr + 1;
2930 blnew = MEM_new<BevList>(
"makeBevelList4", bl);
2937 blnew->
seglen = bl.seglen;
2941 bevp0 = bl.bevpoints;
2945 if (bevp0->dupe_tag == 0) {
2946 memcpy(bevp1, bevp0,
sizeof(
BevPoint));
2952 if (bl.bevpoints !=
nullptr) {
2953 MEM_delete(bl.bevpoints);
2962 if (bl.nr && bl.poly >= 0) {
2976 bevp = bl.bevpoints;
2977 bevp1 = bl.bevpoints;
2981 if (
min > bevp->
vec[0]) {
2990 bevp = bl.bevpoints;
2991 if (bevp1 == bevp) {
2992 bevp0 = bevp + (bl.nr - 1);
2997 bevp = bevp + (bl.nr - 1);
2998 if (bevp1 == bevp) {
2999 bevp2 = bl.bevpoints;
3005 inp = ((bevp1->
vec[0] - bevp0->vec[0]) * (bevp0->vec[1] - bevp2->
vec[1]) +
3006 (bevp0->vec[1] - bevp1->
vec[1]) * (bevp0->vec[0] - bevp2->
vec[0]));
3021 for (a = 1; a < poly; a++, sd++) {
3023 sd1 = sortdata + (a - 1);
3024 for (
b = a - 1;
b >= 0;
b--, sd1--) {
3037 for (a = 0; a < poly; a++, sd++) {
3043 bevp2 = bevp1 + (bl->
nr - 1);
3046 std::swap(*bevp1, *bevp2);
3053 MEM_delete(sortdata);
3064 else if (bl.nr == 2) {
3079 else if (bl.nr == 2) {
3097 char fcurve_smoothing)
3100#define p2_h1 ((p2) - 3)
3101#define p2_h2 ((p2) + 3)
3103 const float *p1, *p3;
3106 float dvec_a[3], dvec_b[3];
3107 float len, len_a, len_b;
3108 const float eps = 1
e-5;
3113 if (bezt->
h1 == 0 && bezt->
h2 == 0) {
3117 if (prev ==
nullptr && next ==
nullptr) {
3124 if (prev ==
nullptr) {
3126 pt[0] = 2.0f * p2[0] - p3[0];
3127 pt[1] = 2.0f * p2[1] - p3[1];
3128 pt[2] = 2.0f * p2[2] - p3[2];
3135 if (next ==
nullptr) {
3136 pt[0] = 2.0f * p2[0] - p1[0];
3137 pt[1] = 2.0f * p2[1] - p1[1];
3138 pt[2] = 2.0f * p2[2] - p1[2];
3157 if (len_a == 0.0f) {
3160 if (len_b == 0.0f) {
3166 tvec[0] = dvec_b[0] / len_b + dvec_a[0] / len_a;
3167 tvec[1] = dvec_b[1] / len_b + dvec_a[1] / len_a;
3168 tvec[2] = dvec_b[2] / len_b + dvec_a[2] / len_a;
3174 len = 6.0f / 2.5614f;
3187 bool leftviolate =
false, rightviolate =
false;
3190 len_a = std::min(len_a, 5.0f * len_b);
3191 len_b = std::min(len_b, 5.0f * len_a);
3199 float ydiff1 = prev->vec[1][1] - bezt->
vec[1][1];
3200 float ydiff2 = next->
vec[1][1] - bezt->
vec[1][1];
3201 if ((ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f)) {
3202 bezt->
vec[0][1] = bezt->
vec[1][1];
3206 if (ydiff1 <= 0.0f) {
3207 if (prev->vec[1][1] > bezt->
vec[0][1]) {
3208 bezt->
vec[0][1] = prev->vec[1][1];
3213 if (prev->vec[1][1] < bezt->
vec[0][1]) {
3214 bezt->
vec[0][1] = prev->vec[1][1];
3226 float ydiff1 = prev->vec[1][1] - bezt->
vec[1][1];
3227 float ydiff2 = next->
vec[1][1] - bezt->
vec[1][1];
3228 if ((ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f)) {
3229 bezt->
vec[2][1] = bezt->
vec[1][1];
3233 if (ydiff1 <= 0.0f) {
3234 if (next->
vec[1][1] < bezt->
vec[2][1]) {
3235 bezt->
vec[2][1] = next->
vec[1][1];
3236 rightviolate =
true;
3240 if (next->
vec[1][1] > bezt->
vec[2][1]) {
3241 bezt->
vec[2][1] = next->
vec[1][1];
3242 rightviolate =
true;
3248 if (leftviolate || rightviolate) {
3251 float h1_x =
p2_h1[0] - p2[0];
3252 float h2_x = p2[0] -
p2_h2[0];
3255 p2_h2[1] = p2[1] + ((p2[1] -
p2_h1[1]) / h1_x) * h2_x;
3258 p2_h1[1] = p2[1] + ((p2[1] -
p2_h2[1]) / h2_x) * h1_x;
3286 if (len_a == 0.0f) {
3289 if (len_b == 0.0f) {
3293 const float len_ratio = len_a / len_b;
3295 if (bezt->
f1 & handle_sel_flag) {
3298 len = 1.0f / len_ratio;
3324 len = 1.0f / len_ratio;
3344 if (nu->
pntsu < 2) {
3351 prev = bezt + (a - 1);
3369 else if (next !=
nullptr) {
3389 size_t num_floats = 0, num_chars = 0;
3391 while (floats && floats[num_floats]) {
3395 while (chars && chars[num_chars]) {
3400 count, (
sizeof(
float) * num_floats + num_chars), name);
3406 float *fptr =
static_cast<float *
>(buffer);
3408 for (
int i = 0; i < num_floats; i++, fptr += count) {
3412 char *cptr =
reinterpret_cast<char *
>(fptr);
3414 for (
int i = 0; i < num_chars; i++, cptr += count) {
3436 float state = a[i] * h[(i + count - 1) % count] +
b[i] * h[i] + c[i] * h[(i + 1) % count] - d[i];
3474 float *a0, *b0, *c0, *d0;
3475 float **arrays[] = {&a0, &b0, &c0, &d0,
nullptr};
3476 char *is_locked, *num_unlocks;
3477 char **flagarrays[] = {&is_locked, &num_unlocks,
nullptr};
3479 void *tmps =
allocate_arrays(solve_count, arrays, flagarrays,
"tridiagonal_solve_with_limits");
3484 memcpy(a0, a,
sizeof(
float) * solve_count);
3485 memcpy(b0,
b,
sizeof(
float) * solve_count);
3486 memcpy(c0, c,
sizeof(
float) * solve_count);
3487 memcpy(d0, d,
sizeof(
float) * solve_count);
3489 memset(is_locked, 0, solve_count);
3490 memset(num_unlocks, 0, solve_count);
3492 bool overshoot, unlocked;
3501 bool all =
false, locked =
false;
3503 overshoot = unlocked =
false;
3506 for (
int i = 0; i < solve_count; i++) {
3507 if (h[i] >= hmin[i] && h[i] <= hmax[i]) {
3513 float target = h[i] > hmax[i] ? hmax[i] : hmin[i];
3516 if (target != 0.0f ||
all) {
3526 }
while (overshoot && !locked);
3531 for (
int i = 0; i < solve_count; i++) {
3533 if (!is_locked[i] || num_unlocks[i] >= 2) {
3540 if ((relax > 0 && h[i] < hmax[i]) || (relax < 0 && h[i] > hmin[i])) {
3549 }
while (overshoot || unlocked);
3628 float *a,
float *
b,
float *c,
float *d,
const float *dy,
const float *
l,
int i)
3631 b[i] = 2.0f * (
l[i] + 1);
3632 c[i] = 1.0f /
l[i + 1];
3633 d[i] = dy[i] *
l[i] *
l[i] + dy[i + 1];
3637 float *a,
float *
b,
float *c,
float *d,
const float *dy,
const float *
l,
int i)
3641 c[i] = 1.0f /
l[i + 1];
3646 float *a,
float *
b,
float *c,
float *d,
const float *dy,
const float *
l,
int i)
3651 d[i] = dy[i] *
l[i] *
l[i];
3656 float *hmax,
float *hmin,
int i,
float dy,
bool no_reverse,
bool no_overshoot)
3660 hmax[i] =
min_ff(hmax[i], dy);
3671 hmin[i] =
max_ff(hmin[i], dy);
3674 else if (no_reverse || no_overshoot) {
3675 hmax[i] = hmin[i] = 0.0f;
3682 const float newval[3],
3687 int idx = right ? 2 : 0;
3688 char hr = right ? bezt->
h2 : bezt->
h1;
3689 char hm = right ? bezt->
h1 : bezt->
h2;
3719 tmp[1] = bezt->
vec[1][1] + dy;
3733 float fac = dx / (hsize[0] + dx / 3.0f);
3737 return 1.0f - 3.0f * hsize[0] / dx;
3741 BezTriple *bezt,
int total,
int start,
int count,
bool cycle)
3743 float *dx, *dy, *
l, *a, *
b, *c, *d, *h, *hmax, *hmin;
3744 float **arrays[] = {&dx, &dy, &
l, &a, &
b, &c, &d, &h, &hmax, &hmin,
nullptr};
3746 int solve_count = count;
3754 BLI_assert(start < total - 1 && count <= total);
3757 bool full_cycle = (start == 0 && count == total && cycle);
3761 &bezt[(start + count > total) ? start + count - total : start + count - 1];
3765 bezt_last, bezt_last->
h1, start + count == total);
3767 if (count == 2 && !full_cycle && solve_first == solve_last) {
3773 void *tmp_buffer =
allocate_arrays(count, arrays,
nullptr,
"bezier_calc_smooth_tmp");
3782 for (
int i = 1, j = start + 1; i < count; i++, j++) {
3783 dx[i] = bezt[j].
vec[1][0] - bezt[j - 1].
vec[1][0];
3784 dy[i] = bezt[j].
vec[1][1] - bezt[j - 1].
vec[1][1];
3787 if (cycle && j == total - 1) {
3795 dx[0] = dx[count - 1];
3796 dy[0] = dy[count - 1];
3798 l[0] =
l[count - 1] = dx[1] / dx[0];
3801 l[0] =
l[count - 1] = 1.0f;
3804 for (
int i = 1; i < count - 1; i++) {
3805 l[i] = dx[i + 1] / dx[i];
3812 for (
int i = 0; i < count; i++) {
3817 for (
int i = 1, j = start + 1; i < count; i++, j++) {
3818 clamped_prev = clamped_cur;
3821 if (cycle && j == total - 1) {
3826 bezier_clamp(hmax, hmin, i - 1, dy[i], clamped_prev, clamped_prev);
3827 bezier_clamp(hmax, hmin, i, dy[i] *
l[i], clamped_cur, clamped_cur);
3832 float first_handle_adj = 0.0f, last_handle_adj = 0.0f;
3836 int i = solve_count = count - 1;
3838 hmin[0] =
max_ff(hmin[0], hmin[i]);
3839 hmax[0] =
min_ff(hmax[0], hmax[i]);
3841 solve_first = solve_last =
true;
3872 for (
int i = 1; i < count - 1; i++) {
3879 if (count > 2 || solve_last) {
3880 b[1] +=
l[1] * first_handle_adj;
3883 if (count > 2 || solve_first) {
3884 b[count - 2] += last_handle_adj;
3892 h[count - 1] = h[0];
3895 for (
int i = 1, j = start + 1; i < count - 1; i++, j++) {
3896 bool end = (j == total - 1);
3932 int search_base = 0;
3935 for (
int i = 1; i < total - 1; i++) {
3943 if (search_base == 0) {
3951 int start = search_base, count = 1;
3953 for (
int i = 1, j = start + 1; i < total; i++, j++) {
3955 if (j == total - 1 && cyclic) {
3985 const bool is_fcurve,
3986 const char smoothing)
3989 bezt, prev, next,
eBezTriple_Flag(handle_sel_flag), is_fcurve,
false, smoothing);
4006 for (i = nu->
pntsu, bezt = nu->
bezt; i--; bezt++) {
4024 if (nu->
pntsu > 1) {
4033 if (nu->
pntsu > 1) {
4046#define SEL_F1 (1 << 0)
4047#define SEL_F2 (1 << 1)
4048#define SEL_F3 (1 << 2)
4056 switch (handle_mode) {
4062 if (bezt->
f2 & sel_flag) {
4068 if (bezt->
f1 & sel_flag) {
4071 if (bezt->
f2 & sel_flag) {
4074 if (bezt->
f3 & sel_flag) {
4086 const bool use_around_local)
4089 if (use_around_local) {
4121 const bool use_around_local)
4143 const float eps = 0.0001f;
4144 const float eps_sq =
eps *
eps;
4146 if (nu ==
nullptr || nu->
bezt ==
nullptr) {
4156 bool align =
false, leftsmall =
false, rightsmall =
false;
4159 if (flag == 0 || (bezt1->
f1 & flag)) {
4179 if (flag == 0 || (bezt1->
f3 & flag)) {
4223 for (
Nurb &nu : *editnurb) {
4236 for (
Nurb &nu : *editnurb) {
4242 if ((flag & (1 << 0)) || (flag & (1 << 2))) {
4243 if (flag & (1 << 0)) {
4246 if (flag & (1 << 2)) {
4249 if (bezt->
h1 != bezt->
h2) {
4273 else if (code == 6) {
4278 for (
Nurb &nu : *editnurb) {
4284 if (((flag & (1 << 0)) && bezt->
h1 !=
HD_FREE) ||
4285 ((flag & (1 << 2)) && bezt->
h2 !=
HD_FREE))
4296 for (
Nurb &nu : *editnurb) {
4302 if (flag & (1 << 0)) {
4305 if (flag & (1 << 2)) {
4320 const bool calc_length,
4326 for (
Nurb &nu : *editnurb) {
4331 bool changed =
false;
4333 for (a = nu.pntsu, bezt = nu.bezt; a--; bezt++) {
4335 const bool h1_select = (bezt->
f1 & flag) == flag;
4336 const bool h2_select = (bezt->
f3 & flag) == flag;
4338 if (h1_select || h2_select) {
4340 float co1_back[3], co2_back[3];
4382 for (
Nurb &nu : *editnurb) {
4401 a = nu.pntsu * nu.pntsv;
4415 bool changed =
false;
4417 for (
Nurb &nu : *editnurb) {
4419 for (
int i = 0; i < nu.pntsu; i++) {
4427 changed |= (old_f1 != bezt->
f1) || (old_f2 != bezt->
f2) || (old_f3 != bezt->
f3);
4431 for (
int i = 0; i < nu.pntsu * nu.pntsv; i++) {
4436 changed |= (old_f1 != bp->
f1);
4448 float *fp1, *fp2, *tempf;
4458 bezt2 = bezt1 + (a - 1);
4464 if (bezt1 != bezt2) {
4465 std::swap(*bezt1, *bezt2);
4470 if (bezt1 != bezt2) {
4474 std::swap(bezt1->
h1, bezt1->
h2);
4475 std::swap(bezt1->
f1, bezt1->
f3);
4477 if (bezt1 != bezt2) {
4478 std::swap(bezt2->
h1, bezt2->
h2);
4479 std::swap(bezt2->
f1, bezt2->
f3);
4491 else if (nu->
pntsv == 1) {
4494 bp2 = bp1 + (a - 1);
4496 while (bp1 != bp2 && a > 0) {
4497 std::swap(*bp1, *bp2);
4507 if (nu->
pntsu & 1) {
4516 fp2 = fp1 + (a - 1);
4518 while (fp1 != fp2 && a > 0) {
4519 std::swap(*fp1, *fp2);
4531 fp2[0] =
fabsf(fp1[1] - fp1[0]);
4542 fp1[0] = fp1[-1] + fp2[0];
4554 bp2 = bp1 + (a - 1);
4557 while (bp1 != bp2 && a > 0) {
4558 std::swap(*bp1, *bp2);
4570 for (
const Nurb &nu : *lb) {
4573 for (
int i = 0; i < nu.pntsu; i++, bezt++) {
4583 const BPoint *bp = nu.bp;
4584 for (
int i = 0; i < nu.pntsu * nu.pntsv; i++, bp++) {
4602 const bool constrain_2d)
4605 for (
Nurb &nu : *lb) {
4609 for (
int i = 0; i < nu.pntsu; i++, bezt++) {
4621 for (
int i = 0; i < nu.pntsu * nu.pntsv; i++, bp++) {
4637 const bool constrain_2d)
4640 for (
Nurb &nu : *lb) {
4644 for (
int i = 0; i < nu.pntsu; i++, bezt++) {
4656 for (
int i = 0; i < nu.pntsu * nu.pntsv; i++, bp++) {
4675 for (
const Nurb &nu : *lb) {
4678 for (
int i = 0; i < nu.pntsu; i++) {
4679 vert_coords[
index] = &key[0];
4681 vert_coords[
index] = &key[3];
4683 vert_coords[
index] = &key[6];
4689 for (
int i = 0; i < nu.pntsu * nu.pntsv; i++) {
4690 vert_coords[
index] = key;
4701 for (
Nurb &nu : *lb) {
4705 for (
int i = 0; i < nu.pntsu; i++, bezt++) {
4706 bezt->
tilt = key[9];
4714 for (
int i = 0; i < nu.pntsu * nu.pntsv; i++, bp++) {
4728 int *r_points_needed)
4738 int points_needed = 0;
4740 const int remainder = pnts % (order - 1);
4741 points_needed = remainder > 0 ? order - 1 - remainder : 0;
4744 points_needed = order + 1 - pnts;
4746 if (points_needed) {
4747 *r_points_needed = points_needed;
4763 const size_t maxncpy)
4767 pnts, order, flag, type, is_surf, &points_needed);
4779 BLI_strncpy(message_dst,
RPT_(
"At least two points required"), maxncpy);
4782 BLI_strncpy(message_dst,
RPT_(
"Must have more control points than Order"), maxncpy);
4787 RPT_(
"%d more %s row(s) needed for Bézier"),
4789 dir == 0 ?
"U" :
"V");
4793 message_dst, maxncpy,
RPT_(
"%d more point(s) needed for Bézier"), points_needed);
4830 bool changed =
false;
4840 bool changed =
false;
4850 const bool use_handles,
4851 const char **r_err_msg)
4895 nr = use_handles ? (3 * nu->
pntsu) : nu->
pntsu;
4902 (use_handles ==
false))
4917 for (c = 0; c < 3; c++, f++) {
4928 MEM_delete(nu->
bezt);
4950 MEM_SAFE_DELETE(nu->
knotsv);
4956 if (r_err_msg !=
nullptr) {
4957 *r_err_msg =
"At least 6 points required for conversion";
5012 if (nu ==
nullptr) {
5031 void *vert =
nullptr;
5041 return static_cast<BezTriple *
>(
const_cast<void *
>(vert)) - nu->
bezt;
5045 return static_cast<BPoint *
>(
const_cast<void *
>(vert)) - nu->
bp;
5068 void *vert =
nullptr;
5089 return (*r_vert !=
nullptr);
5118 const bool use_radius)
5120 if (nurbs->is_empty()) {
5121 return std::nullopt;
5123 float3 min(std::numeric_limits<float>::max());
5124 float3 max(std::numeric_limits<float>::lowest());
5125 for (
const Nurb &nu : *nurbs) {
5134 const bool is_font = nurb_lb->is_empty() && (cu->
len != 0);
5141 ListBaseT<Nurb> temp_nurb_lb{};
5143 nullptr, *cu,
FO_EDIT, &temp_nurb_lb,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr);
5158 for (
Nurb &nu : *nurb_lb) {
5165 for (bezt = nu.bezt; i--; bezt++) {
5173 i = nu.pntsu * nu.pntsv;
5175 for (bp = nu.bp; i--; bp++) {
5185 return (total != 0);
5189 const float mat[4][4],
5191 const bool do_props,
5192 const float unit_scale)
5203 for (bezt = nu.
bezt; i--; bezt++) {
5208 bezt->
radius *= unit_scale;
5210 if (!is_uniform_scaled) {
5220 for (bp = nu.
bp; i--; bp++) {
5223 bp->
radius *= unit_scale;
5229 if (do_keys && cu->
key) {
5231 float *fp =
static_cast<float *
>(kb.
data);
5241 fp[10] *= unit_scale;
5250 fp[4] *= unit_scale;
5270 for (
Nurb &nu : *nurb_lb) {
5273 for (
BezTriple *bezt = nu.bezt; i--; bezt++) {
5280 int i = nu.pntsu * nu.pntsv;
5281 for (
BPoint *bp = nu.bp; i--; bp++) {
5287 if (do_keys && cu->
key) {
5289 float *fp =
static_cast<float *
>(kb.
data);
5316 for (
int i = cu->
len_char32 - 1; i >= 0; i--, info++) {
5335 for (
int i = cu->
len_char32 - 1; i >= 0; i--, info++) {
5356 for (
int i = cu->
len_char32 - 1; i >= 0; i--, info++) {
5369 bool is_valid =
true;
5375 for (i = cu->
len_char32 - 1; i >= 0; i--, info++) {
5376 if (info->
mat_nr > max_idx) {
5385 if (nu.
mat_nr > max_idx) {
5401 const short remap_len_short = short(remap_len);
5403#define MAT_NR_REMAP(n) \
5404 if (n < remap_len_short) { \
5405 BLI_assert(n >= 0 && remap[n] < remap_len_short); \
5412 int charinfo_len, i;
5417 charinfo_len = ef->
len;
5424 for (i = 0; i <= charinfo_len; i++) {
5432 for (
Nurb &nu : *nurbs) {
5466 float h1[2], h2[2], len1, len2,
len, fac;
5469 h1[0] = v1[0] -
v2[0];
5470 h1[1] = v1[1] -
v2[1];
5472 h2[0] = v4[0] - v3[0];
5473 h2[1] = v4[1] - v3[1];
5480 len = v4[0] - v1[0];
5481 len1 =
fabsf(h1[0]);
5482 len2 =
fabsf(h2[0]);
5485 if ((len1 + len2) == 0.0f) {
5492 if ((len1 + len2) >
len) {
5493 fac =
len / (len1 + len2);
5495 v2[0] = (v1[0] - fac * h1[0]);
5496 v2[1] = (v1[1] - fac * h1[1]);
5498 v3[0] = (v4[0] - fac * h2[0]);
5499 v3[1] = (v4[1] - fac * h2[1]);
5503std::optional<int> Curve::material_index_max()
const
5505 if (this->
nurb.is_empty()) {
5506 return std::nullopt;
5509 for (
const Nurb &
nurb : this->
nurb) {
5510 max_index = std::max<int>(max_index,
nurb.mat_nr);
#define CU_DO_RADIUS(cu, nu)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
#define BLI_SCOPED_DEFER(function_to_defer)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct(reader, struct_name, ptr_p)
#define BLT_I18NCONTEXT_ID_CURVE_LEGACY
#define FILTER_ID_CU_LEGACY
#define BEZT_IS_AUTOH(bezt)
#define BEZT_ISSEL_ANY(bezt)
#define KEYELEM_ELEM_LEN_BPOINT
#define KEYELEM_FLOAT_LEN_BEZTRIPLE
#define KEYELEM_FLOAT_LEN_BPOINT
#define KEYELEM_ELEM_LEN_BEZTRIPLE
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define ARRAY_HAS_ITEM(arr_item, arr_start, arr_len)
#define UNUSED_VARS_NDEBUG(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
#define POINTER_OFFSET(v, ofs)
#define MEM_realloc_zeroed(vmemh, len)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
constexpr IndexRange()=default
Value pop_default(const Key &key, const Value &default_value)
bool all(VecOp< bool, D >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
float length(VecOp< float, D >) RET
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
bool BLI_tridiagonal_solve_cyclic(const float *a, const float *b, const float *c, const float *d, float *r_x, int count)
Solve a possibly cyclic tridiagonal system using the Sherman-Morrison formula.
MINLINE float min_ff(float a, float b)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BKE_curve_nurb_vert_active_set(Curve *cu, const Nurb *nu, const void *vert)
static void bevel_list_smooth(BevList *bl, int smooth_iter)
IDTypeInfo IDType_ID_CU_LEGACY
void BKE_curve_editNurb_free(Curve *cu)
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
bool is_uniform_scaled_m4(const float m[4][4])
int BKE_curve_nurb_vert_index_get(const Nurb *nu, const void *vert)
MINLINE int mod_i(int i, int n)
Nurb * BKE_curve_nurb_active_get(Curve *cu)
void BKE_curve_eval_geometry(Depsgraph *depsgraph, Curve *curve)
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BKE_nurb_points_add(Nurb *nu, int number)
static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *r_sina, float *r_cosa)
static void bezier_handle_calc_smooth_fcurve(BezTriple *bezt, int total, int start, int count, bool cycle)
static std::optional< Bounds< float3 > > calc_nurblist_bounds(const ListBaseT< Nurb > *nurbs, const bool use_radius)
static void nurb_handles_calc__align_selected(Nurb *nu)
static void curve_blend_read_data(BlendDataReader *reader, ID *id)
static void nurbList_handles_swap_select(Nurb *nu)
@ HD_AUTOTYPE_LOCKED_FINAL
static bool bezier_check_solve_end_handle(BezTriple *bezt, char htype, bool end)
void BKE_curve_forward_diff_tangent_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
static void calchandleNurb_intern(BezTriple *bezt, const BezTriple *prev, const BezTriple *next, eBezTriple_Flag handle_sel_flag, bool is_fcurve, bool skip_align, char fcurve_smoothing)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_curve_translate(Curve *cu, const float offset[3], bool do_keys)
const ListBaseT< Nurb > * BKE_curve_nurbs_get_for_read(const Curve *cu)
static bool bevelinside(const BevList *bl1, const BevList *bl2)
void BKE_curve_init(Curve *cu, ObjectType curve_type)
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
bool DEG_is_active(const Depsgraph *depsgraph)
static void bezier_eq_noaccel_left(float *a, float *b, float *c, float *d, const float *dy, const float *l, int i)
void BKE_nurb_bezt_handle_test(BezTriple *bezt, eBezTriple_Flag__Alias sel_flag, const eNurbHandleTest_Mode handle_mode, bool use_around_local)
void BLO_read_pointer_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static void calchandlesNurb_intern(Nurb *nu, eBezTriple_Flag handle_sel_flag, bool skip_align)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void vec_to_quat(float q[4], const float vec[3], short axis, short upflag)
MINLINE void mul_v2_fl(float r[2], float f)
ListBaseT< Nurb > * BKE_curve_nurbs_get(Curve *cu)
void BKE_curve_type_test(Object *ob, bool dimension_update)
float mat4_to_scale(const float mat[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
static void make_bevel_list_2D(BevList *bl)
void BKE_nurbList_free(ListBaseT< Nurb > *lb)
float tri_to_quat(float q[4], const float a[3], const float b[3], const float c[3])
static void calcknots(float *knots, const int pnts, const short order, const short flag)
float normalize_qt(float q[4])
MINLINE float safe_acosf(float a)
void DEG_debug_print_eval(Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address)
bool BKE_nurb_order_clamp_u(Nurb *nu)
BezTriple * BKE_nurb_bezt_get_prev(Nurb *nu, BezTriple *bezt)
static void make_bevel_list_3D_minimum_twist(BevList *bl)
static void calc_nurb_minmax(const Nurb *nu, bool use_radius, float min[3], float max[3])
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
void BKE_curve_transform_ex(Curve *cu, const float mat[4][4], bool do_keys, bool do_props, float unit_scale)
void BKE_nurb_bezt_calc_normal(Nurb *nu, BezTriple *bezt, float r_normal[3])
Curve * BKE_curve_add(Main *bmain, const char *name, ObjectType type)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
void BKE_curve_batch_cache_dirty_tag(Curve *cu, int mode)
MINLINE int max_ii(int a, int b)
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
ATTR_WARN_UNUSED_RESULT const BMVert * v
@ NURB_HANDLE_TEST_KNOT_OR_EACH
@ NURB_HANDLE_TEST_KNOT_ONLY
void BKE_nurbList_flag_set(ListBaseT< Nurb > *editnurb, eBezTriple_Flag flag, bool set)
MatBase< float, 4, 4 > float4x4
static void bevel_list_apply_tilt(BevList *bl)
void BKE_curve_material_remap(Curve *cu, const unsigned int *remap, unsigned int remap_len)
void BKE_curve_batch_cache_free(Curve *cu)
void BKE_nurb_project_2d(Nurb *nu)
void BKE_id_blend_write(BlendWriter *writer, ID *id)
void(*) BKE_curve_batch_cache_free_cb(Curve *cu)
void BKE_nurbList_handles_set(ListBaseT< Nurb > *editnurb, eNurbHandleTest_Mode handle_mode, eBezTriple_Handle code)
void BKE_nurb_knot_alloc_u(Nurb *nu)
void MEM_delete_void(void *vmemh)
void BKE_curve_texspace_ensure(Curve *cu)
void BKE_nurb_handle_calc(BezTriple *bezt, BezTriple *prev, BezTriple *next, bool is_fcurve, char smoothing)
bool BKE_curve_material_index_validate(Curve *cu)
static void curve_copy_data(Main *bmain, std::optional< Library * > owner_library, ID *id_dst, const ID *id_src, const int flag)
void BKE_nurbList_handles_autocalc(ListBaseT< Nurb > *editnurb, eBezTriple_Flag flag)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
void BKE_nurb_index_to_uv(Nurb *nu, int index, int *r_u, int *r_v)
void BKE_curve_nurb_vert_active_validate(Curve *cu)
MINLINE void mul_v3_fl(float r[3], float f)
static void * allocate_arrays(int count, float ***floats, char ***chars, const char *name)
void BKE_curve_nurb_active_set(Curve *cu, const Nurb *nu)
float dist_squared_to_line_v3(const float p[3], const float l1[3], const float l2[3])
unsigned int BKE_curve_calc_coords_axis_len(unsigned int bezt_array_len, unsigned int resolu, bool is_cyclic, bool use_cyclic_duplicate_endpoint)
static void forward_diff_bezier_cotangent(const float p0[3], const float p1[3], const float p2[3], const float p3[3], float p[3], int it, int stride)
bool BKE_vfont_to_curve_ex(Object *ob, const Curve &cu, eEditFontMode mode, ListBaseT< Nurb > *r_nubase, const char32_t **r_text, int *r_text_len, bool *r_text_free, CharTrans **r_chartransdata, float *r_font_size_eval)
void BKE_nurb_knot_calc_v(Nurb *nu)
const ListBaseT< Nurb > * BKE_curve_editNurbs_get_for_read(const Curve *cu)
void mul_qt_v3(const float q[4], float r[3])
void BKE_curve_nurbs_key_vert_tilts_apply(ListBaseT< Nurb > *lb, const float *key)
void BKE_nurb_bezierPoints_add(Nurb *nu, int number)
static void make_bevel_list_segment_3D(BevList *bl)
void mul_m4_v3(const float M[4][4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
static void curve_init_data(ID *id)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
static int vergxcobev(const void *a1, const void *a2)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode)
void BKE_curve_transform(Curve *cu, const float mat[4][4], bool do_keys, bool do_props)
void dist_ensure_v3_v3fl(float v1[3], const float v2[3], float dist)
static void tilt_bezpart(const BezTriple *prevbezt, const BezTriple *bezt, const Nurb *nu, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void BKE_nurb_handles_calc(Nurb *nu)
static void bevlist_firstlast_direction_calc_from_bpoint(const Nurb *nu, BevList *bl)
bool BKE_nurbList_index_get_co(ListBaseT< Nurb > *nurb, int index, float r_co[3])
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void copy_qt_qt(float q[4], const float a[4])
static void make_bevel_list_segment_2D(BevList *bl)
void DEG_id_tag_update(ID *id, unsigned int flags)
MINLINE void swap_v3_v3(float a[3], float b[3])
BMesh const char void * data
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
void BKE_curve_editNurb_keyIndex_delCV(CVKeyIndexMap *keyindex, const void *cv)
void BKE_nurb_makeCurve(const Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
void BKE_nurb_handle_calc_ex(BezTriple *bezt, BezTriple *prev, BezTriple *next, eBezTriple_Flag__Alias handle_sel_flag, bool is_fcurve, char smoothing)
void BKE_curve_nurbs_vert_coords_apply(ListBaseT< Nurb > *lb, const Span< float3 > vert_coords, bool constrain_2d)
bool BKE_nurbList_flag_set_from_flag(ListBaseT< Nurb > *editnurb, eBezTriple_Flag from_flag, eBezTriple_Flag flag)
static void free_arrays(void *buffer)
bool BKE_curve_material_index_used(const Curve *cu, int index)
bool BKE_nurb_valid_message(int pnts, short order, short flag, short type, bool is_surf, int dir, char *message_dst, size_t maxncpy)
static void make_bevel_list_3D_zup(BevList *bl)
static void bezier_output_handle(BezTriple *bezt, bool right, float dy, bool endpoint)
static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], const float v4[3], short cox, short coy, float *lambda, float *mu, float vec[3])
MINLINE void negate_v3(float r[3])
static void curve_free_data(ID *id)
void BKE_curve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2])
static void makeknots(Nurb *nu, short uv)
BezTriple * BKE_nurb_bezt_get_next(Nurb *nu, BezTriple *bezt)
void BKE_curve_nurbs_vert_coords_apply_with_mat4(ListBaseT< Nurb > *lb, const Span< float3 >, const float4x4 &transform, bool constrain_2d)
void BKE_curve_smooth_flag_set(Curve *cu, bool use_smooth)
Array< float3 > BKE_curve_nurbs_key_vert_coords_alloc(const ListBaseT< Nurb > *lb, const float *key)
static bool tridiagonal_solve_with_limits(float *a, float *b, float *c, float *d, float *h, const float *hmin, const float *hmax, int solve_count)
void BKE_curve_material_index_remove(Curve *cu, int index)
static void bezier_clamp(float *hmax, float *hmin, int i, float dy, bool no_reverse, bool no_overshoot)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
bool BKE_nurb_check_valid_v(const Nurb *nu)
static void curve_foreach_id(ID *id, LibraryForeachIDData *data)
static void bezier_restore_equation(float *a, float *b, float *c, float *d, const float *a0, const float *b0, const float *c0, const float *d0, int i)
MINLINE void zero_v3(float r[3])
int eBezTriple_Flag__Alias
static void basisNurb(float t, short order, int pnts, const float *knots, float *basis, int *start, int *end)
void BKE_curve_nurbs_vert_coords_get(const ListBaseT< Nurb > *lb, MutableSpan< float3 > vert_coords)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
void BKE_curveprofile_blend_write(struct BlendWriter *writer, const struct CurveProfile *profile)
bool BLO_read_array(BlendDataReader *reader, T **ptr_p, const SizeT array_size, const int elems=1)
Nurb * BKE_nurb_duplicate(const Nurb *nu)
void BKE_nurb_handle_smooth_fcurve(BezTriple *bezt, int total, bool cyclic)
void BLO_read_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size, const int elems=1)
void BKE_curve_rect_from_textbox(const Curve *cu, const TextBox *tb, rctf *r_rect)
static void curve_blend_write(BlendWriter *writer, ID *id, const void *id_address)
static void bevel_list_calc_bisect(BevList *bl)
int BKE_nurb_index_from_uv(Nurb *nu, int u, int v)
void BKE_nurb_handles_autocalc(Nurb *nu, eBezTriple_Flag flag)
void BKE_nurbList_handles_recalculate(ListBaseT< Nurb > *editnurb, bool calc_length, eBezTriple_Flag flag)
MINLINE float normalize_v3(float n[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
BPoint * BKE_nurb_bpoint_get_prev(Nurb *nu, BPoint *bp)
Array< float3 > BKE_curve_nurbs_vert_coords_alloc(const ListBaseT< Nurb > *lb)
void BKE_curveprofile_free(struct CurveProfile *profile)
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_nurbList_duplicate(ListBaseT< Nurb > *lb1, const ListBaseT< Nurb > *lb2)
bool BKE_nurb_check_valid_u(const Nurb *nu)
MINLINE bool compare_v3v3(const float v1[3], const float v2[3], float limit) ATTR_WARN_UNUSED_RESULT
T * DEG_get_original(T *id)
bool BKE_curve_center_median(Curve *cu, float cent[3])
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static void minimum_twist_between_two_points(BevPoint *bevp_curr, const BevPoint *bevp_prev)
void BKE_curve_editNurb_keyIndex_free(CVKeyIndexMap **keyindex)
bool BKE_curve_nurb_vert_active_get(Curve *cu, Nurb **r_nu, void **r_vert)
void BKE_nurb_handles_test(Nurb *nu, eNurbHandleTest_Mode handle_mode, bool use_around_local)
void BKE_nurb_handle_calc_simple_auto(Nurb *nu, BezTriple *bezt)
MINLINE float max_ff(float a, float b)
void BKE_nurb_bpoint_calc_plane(Nurb *nu, BPoint *bp, float r_plane[3])
void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
void(*) BKE_curve_batch_cache_dirty_tag_cb(Curve *cu, int mode)
static void bezier_eq_noaccel_right(float *a, float *b, float *c, float *d, const float *dy, const float *l, int i)
VFont * BKE_vfont_builtin_ensure()
void BKE_nurb_bpoint_calc_normal(Nurb *nu, BPoint *bp, float r_normal[3])
static void bezier_eq_continuous(float *a, float *b, float *c, float *d, const float *dy, const float *l, int i)
static void make_bevel_list_3D_tangent(BevList *bl)
bool BKE_nurb_type_convert(Nurb *nu, eNurbType type, bool use_handles, const char **r_err_msg)
static void bezier_lock_unknown(float *a, float *b, float *c, float *d, int i, float value)
@ CU_TEXSPACE_FLAG_AUTO_EVALUATED
short BKE_nurb_bezt_handle_test_calc_flag(const BezTriple *bezt, const eBezTriple_Flag__Alias sel_flag, const eNurbHandleTest_Mode handle_mode)
bool BKE_nurb_check_valid_uv(const Nurb *nu)
ListBaseT< Nurb > * BKE_curve_editNurbs_get(Curve *cu)
void BKE_nurb_handle_calc_simple(Nurb *nu, BezTriple *bezt)
BPoint * BKE_nurb_bpoint_get_next(Nurb *nu, BPoint *bp)
size_t BLI_strlen_utf8_ex(const char *strc, size_t *r_len_bytes) ATTR_NONNULL(1
struct CurveProfile * BKE_curveprofile_copy(const struct CurveProfile *profile)
void key_curve_position_weights(float t, float data[4], KeyInterpolationType type)
std::optional< Bounds< float3 > > BKE_curve_minmax(const Curve *cu, bool use_radius)
static bool is_free_auto_point(BezTriple *bezt)
VecBase< float, 3 > float3
void * BKE_curve_vert_active_get(Curve *cu)
void BKE_curve_bevelList_make(Object *ob, const ListBaseT< Nurb > *nurbs, bool for_render)
void BKE_nurb_knot_calc_u(Nurb *nu)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
static void bezier_output_handle_inner(BezTriple *bezt, bool right, const float newval[3], bool endpoint)
void BKE_curveprofile_blend_read(struct BlendDataReader *reader, struct CurveProfile *profile)
void BKE_nurb_bezt_calc_plane(Nurb *nu, BezTriple *bezt, float r_plane[3])
Nurb * BKE_nurb_copy(Nurb *src, int pntsu, int pntsv)
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
MINLINE int min_ii(int a, int b)
MINLINE int clamp_i(int value, int min, int max)
void BKE_curve_calc_coords_axis(const BezTriple *bezt_array, unsigned int bezt_array_len, unsigned int resolu, bool is_cyclic, bool use_cyclic_duplicate_endpoint, unsigned int axis, unsigned int stride, float *r_points)
void BKE_curve_texspace_calc(Curve *cu)
void BKE_curve_material_index_clear(Curve *cu)
@ MorePointsThanOrderRequired
@ AtLeastTwoPointsRequired
@ MorePointsForBezierRequired
@ MoreRowsForBezierRequired
void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv)
float BKE_nurb_calc_length(const Nurb *nu, int resolution)
void * BKE_libblock_alloc(Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
struct ID * BKE_id_copy_in_lib(Main *bmain, std::optional< Library * > owner_library, const ID *id, std::optional< const ID * > new_owner_id, ID **new_id_p, int flag)
static float bezier_calc_handle_adj(float hsize[2], float dx)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
Map< const void *, struct CVKeyIndex * > CVKeyIndexMap
int BKE_nurbList_verts_count(const ListBaseT< Nurb > *nurb)
void BKE_curve_editfont_free(Curve *cu)
int BKE_nurbList_verts_count_without_handles(const ListBaseT< Nurb > *nurb)
static NURBSValidationStatus nurb_check_valid(const int pnts, const short order, const short flag, const short type, const bool is_surf, int *r_points_needed)
void BKE_curve_bevelList_free(ListBaseT< BevList > *bev)
static void bevel_list_flip_tangents(BevList *bl)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool BKE_nurb_order_clamp_v(Nurb *nu)
void BKE_nurb_direction_switch(Nurb *nu)
void BKE_nurb_free(Nurb *nu)
static float bezier_relax_direction(const float *a, const float *b, const float *c, const float *d, const float *h, int i, int count)
void BKE_curve_dimension_update(Curve *cu)
static void curve_editNurb_keyIndex_cv_free_cb(CVKeyIndex *index)
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBezTriple_Auto_Type auto_handle_type
void write_pointer_array(int64_t num, const void *data)
void write_string(const char *data)
void write_float_array(int64_t num, const float *data)
void write_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_array(const int64_t array_size, const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
draw::CurveBatchCache * batch_cache
eCurveTwistMode twist_mode
float texspace_location[3]
eCurveBevfacMapping bevfac2_mapping
struct EditFont * editfont
CurveFillSolverType fill_solver
struct Object * textoncurve
struct CurveProfile * bevel_profile
CurveFillRuleType fill_rule
eCurveBevfacMapping bevfac1_mapping
struct CharInfo * strinfo
char edit_data_from_original
EditFontSelBox * selboxes
ListBaseT< KeyBlock > block
bke::ObjectRuntime * runtime